documentation icon indicating copy to clipboard operation
documentation copied to clipboard

fix: wrong field in odbc conf for db connection

Open gibix opened this issue 1 year ago • 6 comments

The current "Server" field is invalid and cannot be used to configure remote database server

gibix avatar Oct 18 '24 10:10 gibix

The unixODBC 2.3.12 man page for odbc.ini does show Servername as the parameter but the mysql/mariadb connector will accept Server as well. If Socket is also specified it will ignore Server/Servername and use the socket specified. If neither Server/Servername nor Socket are specified the driver will use localhost as the server and connect via TCP.

The Postgresql driver on the other hand, oinly accepts Servername and ignores Server altogether. If neither Servername nor Socket are specified, it will connect via the default socket /var/run/postgresql/.s.PGSQL.5432.

So, it does seem that Servername is correct.

gtjoseph avatar Oct 18 '24 14:10 gtjoseph

Oh, for both drivers, if both Servername and Socket are specified, Socket takes precedence and Servername is ignored.

@gibix You might want to add a note to that effect on those pages.

gtjoseph avatar Oct 18 '24 14:10 gtjoseph

The Postgresql driver on the other hand, oinly accepts Servername and ignores Server altogether.

Can you cite your source on this?

seanbright avatar Oct 18 '24 14:10 seanbright

This is really minor but I would love to see some documentation that Server is "invalid."

seanbright avatar Oct 18 '24 15:10 seanbright

odbc.ini:

[asterisk-pgsql]                                        
Description=PostgreSQL connection to 'asterisk' database
Driver=PostgreSQL                                       
Database=asterisk                                       
Server=foobar                                           
UserName=asterisk                                       
Password=asterisk                                       
Port=5432                                               
Protocol=13.0                                           
# isql asterisk-pgsql
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| echo [string]                         |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> 

# netstat -anxp | grep '[.]5432'
unix  2      [ ACC ]     STREAM     LISTENING     13184    2812/postgres        /tmp/.s.PGSQL.5432
unix  3      [ ]         STREAM     CONNECTED     46871406 1788870/postgres: a  /var/run/postgresql/.s.PGSQL.5432
unix  2      [ ACC ]     STREAM     LISTENING     13183    2812/postgres        /var/run/postgresql/.s.PGSQL.5432

[asterisk-pgsql]                                          
Description=PostgreSQL connection to 'asterisk' database  
Driver=PostgreSQL                                         
Database=asterisk                                         
Servername=foobar                                         
UserName=asterisk                                         
Password=asterisk                                         
Port=5432                                                 
Protocol=13.0                                             
# isql asterisk-pgsql
[ISQL]ERROR: Could not SQLConnect

gtjoseph avatar Oct 18 '24 15:10 gtjoseph

Hello, thanks for the review. I can confirm that I spotted the bug while trying to connect odbc with postgres on a remote server. I add a note for server

gibix avatar Oct 24 '24 07:10 gibix