Bug 3322 - Run a statement each time a connection is created via ODBC
Summary: Run a statement each time a connection is created via ODBC
Status: NEW
Alias: None
Product: Client interfaces
Classification: Unclassified
Component: ODBC (show other bugs)
Version: -- development
Hardware: All Linux
: Normal enhancement
Assignee: clients devs
Depends on:
Reported: 2013-07-12 13:10 CEST by Michael König
Modified: 2019-02-12 13:57 CET (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Michael König 2013-07-12 13:10:30 CEST
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20100101 Firefox/13.0.1
Build Identifier: 

MonetDB's data source section in odbc.ini should provide an option for running a query every time a connection is opened.

Reproducible: Always

Typical usage scenario:
Since ODBC does not support time zone information, the result of queries for timestamps depends on the session time zone of the connection. To make sure that all users retrieve the same values, we would like to fix the session time zone to UTC. A workaround is to fire a SET TIME ZONE query every time a session is created.

Client applications using ODBC should not need knowledge of the specifics of a database represented by an ODBC data source. Thus, client applications should not be forced to execute a (not standardized) statement such as SET TIME ZONE themselves.

The correct place for such a query would be in the configuration of the data source, i.e., in odbc.ini. Here, the logic for fixing the time zone is centralized instead of being scattered around different client applications.

Other databases such as MySQL and PostgreSQL (and probably many more) provide such an option in the odbc.ini file. Here is an excerpt of how a PostgreSQL data source looks like:

[PostgreSQL database]
Driver              = PostgreSQL ODBC Driver
Database            = test_database
Servername          = test_server
Port                = 5432
Protocol            = 8.3.9
ConnSettings        = set time zone 'UTC';

I would like to see a similar option for MonetDB's ODBC driver.
Comment 1 Martin van Dinther cwiconfidential 2014-01-31 16:13:48 CET
A more generic solution is suggested in id=3426
Comment 2 Michael König 2014-01-31 17:02:33 CET
I agree that the solution suggested in 3426 would indeed resolve my issue. Still, it would require appropriate rights (and syntax skills) on the database which my solution would not.