unixODBC + PostgreSQL error "Unable to query database columns on connection"

I’m trying to use asterisk realtime with postgreSQL but getting the following error:

[Jun 4 10:39:13] ERROR[3352312]: res_odbc.c:280 ast_odbc_find_table: Unable to query database columns on connection ‘postgres’.
[Jun 4 10:39:13] WARNING[3352312]: res_odbc.c:538 ast_odbc_print_errors: SQL Execute returned an error: 42601: ERROR: syntax error at or near “WHERE”; Error while preparing parameters

it appears to be working as expected apart from receiving lots of the above errors (2 every time there is a registration).


Trace = yes
TraceFile = /tmp/odbctrace.log

Description=FreeTDS MSSQL Driver

Description = ODBC for PostgreSQL
Driver = /usr/lib64/psqlodbc.so
UsageCount = 2


Description=postgres IVR database
TraceFile  = /tmp/odbc.trace
Trace      = 1
ShowOidColumn = No
Protocol = 7.4+


enabled => yes
dsn => postgres-connector
pooling => yes
limit => 50
username => -----------
password => ----------
pre-connect => yes
backslash_is_escape => yes


sippeers => odbc,postgres,registration.sip_conf

This is on asterisk version 16.18.0, unixODBC version 2.3.7-1, postgresql-odbc version 10.03.0000-2

any help / advice would be much appreciated.

After some more investigation it’s looking more likely to be an issue with unixODBC or postgres-odbc rather then asterisk itself…

connecting using isql and running “help roles” I get the following error:

[S1000]Error while executing the query
[ISQL]ERROR: Could not SQLColumns

looking through asterisk source it’s a failing call to SQLColumns which is causing the error to appear in the CLI (res_odbc.c line 277)

anyone else experienced a similar issue?

Turns out this was an issue within postgres-odbc and was resolved by updating to the latest version of postgres-odbc (13.01) and moving my table into the the “public” schema.