Using Asterisk 13.9.1 from package on OpenBSD 6.0. I receive the following errors when attempting to use PostgreSQL via ODBC:
[Oct 18 14:34:18] WARNING[-1]: res_odbc.c:821 odbc_obj_connect: res_odbc: Error SQLConnect=-1 errno=0 [iODBC][Driver Manager]Can't open file
[Oct 18 14:34:18] ERROR[-1]: res_config_odbc.c:195 realtime_odbc: No database handle available with the name of 'asteriskodbc' (check res_odbc.conf)
[Oct 18 14:34:18] WARNING[-1]: res_odbc.c:821 odbc_obj_connect: res_odbc: Error SQLConnect=-1 errno=138743321 [iODBC][Driver Manager]Can't open file
[Oct 18 14:34:18] ERROR[-1]: res_config_odbc.c:195 realtime_odbc: No database handle available with the name of 'asteriskodbc' (check res_odbc.conf)
[Oct 18 14:34:18] WARNING[-1]: res_odbc.c:821 odbc_obj_connect: res_odbc: Error SQLConnect=-1 errno=2086272416 [iODBC][Driver Manager]Can't open file
[Oct 18 14:34:18] ERROR[-1]: res_config_odbc.c:195 realtime_odbc: No database handle available with the name of 'asteriskodbc' (check res_odbc.conf)
I’ve been trying ODBC as a workaround to problems with the native PostgreSQL support in Asterisk. UnixODBC isn’t readily available on OpenBSD, and their port utilizes iodbc instead. That is correctly configured, which also strongly implies to me that odbcinst.ini and odbc.ini are correct too. Here is the output of an SQL test:
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.52.1015.0210
Enter ODBC connect string (? shows list): ?
DSN | Driver
------------------------------------------------------------------------------
asteriskodbc | PostgreSQL
Enter ODBC connect string (? shows list): dsn=asteriskodbc
Driver: 09.03.0400 (psqlodbcw.so)
SQL>select count(*) from ps_endpoints
count
--------------------
2
result set 1 returned 1 rows.
SQL>
The ODBC installation was performed by package for PostgreSQL
odbc.ini
[ODBC Data Sources]
asteriskodbc = PostgreSQL
[asteriskodbc]
Driver = /usr/local/lib/psqlodbcw.so
Description = Asterisk on PostgreSQL
Server = localhost
Port = 5432
Database = asterisk
Username = postgres
Password = password
Trace = 1
Tracefile = /var/log/PostgreSQL_test_trace.log
Debug = 1
Debugfile = /var/log/PostgreSQL_test_debug.log
[Default]
Driver = /usr/local/lib/psqlodbcw.so
Description = PostgreSQL Data Source
Server = localhost
Port = 5432
Username = asterisk
Password = password
odbcinst.ini
[ODBC Drivers]
PostgreSQL = Installed
FreeTDS = Installed
[PostgreSQL]
Description = ODBC driver for PostgreSQL
Driver = /usr/local/lib/psqlodbcw.so
[FreeTDS]
Description = FreeTDS ODBC driver for MSSQL
Driver = /usr/local/lib/libtdsodbc.so
extconfig.conf (excerpt, everything else is stock)
ps_endpoints => odbc,asteriskodbc
ps_auths => odbc,asteriskodbc
ps_aors => odbc,asteriskodbc
res_odbc.conf
[asteriskodbc]
enabled => yes
dsn => asteriskodbc
username => postgres
password => password
preconnect => yes