Re: Setting Database Name During Connection

Поиск
Список
Период
Сортировка
От Steve Marvin
Тема Re: Setting Database Name During Connection
Дата
Msg-id 0NOO00C1V0TNIYA0@vms173025.mailsrvcs.net
обсуждение исходный текст
Ответ на Setting Database Name During Connection  (Daniel Homerick <daniel.homerick@2d3sensing.com>)
Список pgsql-odbc
SQL_ATTR_CURRENT_CATALOG maps to SQL_CURRENT_QUALIFIER in the SQLext .h file.

Looking in options.c at line 396 in function PGAPI_SetConnectOption()
I see case SQL_CURRENT_QUALIFIER:        /* ignored */

The equivalent in PGAPI_GetConnectOption() function at line 570 returns
the database/catalog name using p = CurrCatString(conn);

---------------------------------


On Wed, 20 May 2015 10:59:46 -0700, Daniel Homerick wrote:

>The common way to control which database you connect to is apparently through the DSN, or connection string. However,
ODBCalso allows the database name (distinct from which host/port) to be specified programmatically, but it appears that
thismay be unimplemented in psqlODBC. 

>Calling SQLSetConnectAttr with the SQL_ATTR_CURRENT_CATALOG attribute should allow you to specify which database. My
expectationis that doing so should override any value specified in the DSN or connection string. 

>In practice, the SQLSetConnectAttr call returns SQL_SUCCESS, regardless of what database ("catalog") name you specify,
andregardless of whether you call it prior to SQLConnect or after. However, calling SQLGetConnectAttr afterwards
revealsthat nothing was changed by the Set. Attempting to use the specified database fails, consistent with the current
databasestill being whatever was specified in the DSN. 

>I downloaded the current snapshot (psqlodbc-355ac88) and grepped around, but did not find any references to
SQL_ATTR_CURRENT_CATALOG,nor to 3D000 which is the error code for an "Invalid catalog name", which leads me to think it
mayjust be unimplemented and not a more subtle bug. I did not do a more serious investigation however, so take that
witha large grain of salt. 

>Tested on Windows 7, using the odbc driver "Postgre SQL ANSI(x64) 9.03.03.00" with PostgreSQL 9.2. Testing using the
samecode works as expected for SQL Server. 

>-

>As an aside from the bug report, is it correct that there is NOT a way to change the current database through a SQL
commandwith Postgres (i.e. there is no equivalent to "USE" in SQL Server)? 








В списке pgsql-odbc по дате отправления:

Предыдущее
От: Daniel Homerick
Дата:
Сообщение: Setting Database Name During Connection
Следующее
От: Tristan St-Cyr
Дата:
Сообщение: Incorrect OCTET_LENGTH for column of type interval?