Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrong field in odbc conf for db connection #115

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gibix
Copy link

@gibix gibix commented Oct 18, 2024

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

Copy link
Member

@jcolp jcolp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When did this change? Is it different between MySQL and MariaDB entries? I'm seeing both online in documentation, and on the official MySQL site it is "Server"

@gtjoseph
Copy link
Member

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
Copy link
Member

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.

@seanbright
Copy link
Contributor

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

Can you cite your source on this?

@seanbright
Copy link
Contributor

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

@gtjoseph
Copy link
Member

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

Copy link
Member

@jcolp jcolp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation is referring to MySQL ODBC based configuration, so like @seanbright I would like to see documentation from elsewhere stating that "Server" is invalid for this, or further information on what triggered this change in the first place.

@gibix
Copy link
Author

gibix commented Oct 24, 2024

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

@@ -173,7 +173,10 @@ Socket = /var/run/mysqld/mysqld.sock

```

Take care to use your database access UserName and Password, and not necessarily what's defined in this example.
Keep in mind that the `Servername` parameter should not be confused with `Server` that is invalid.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this isn't true. These examples are for MySQL, where it IS valid. It MAY be invalid for other databases. I think the documentation should be updated to state that different drivers may support different options, and so the MySQL based ones may not be applicable to others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants