pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Steve Marvin <smarvin@pobox.com>
To: pgsql-odbc@postgresql.org <pgsql-odbc@postgresql.org>
Subject: Re: Setting Database Name During Connection
Date: Wed, 20 May 2015 16:26:44 -0400
Message-ID: <0NOO00C1V0TNIYA0@vms173025.mailsrvcs.net> (raw)
In-Reply-To: <9570C4F8577FC041964C389777970D774A525D90A8@KITT.sensingsystems.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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, ODBC also allows the database name (distinct from which host/port) to be specified programmatically, but it appears that this may be unimplemented in psqlODBC.

>Calling SQLSetConnectAttr with the SQL_ATTR_CURRENT_CATALOG attribute should allow you to specify which database. My expectation is 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, and regardless of whether you call it prior to SQLConnect or after. However, calling SQLGetConnectAttr afterwards reveals that nothing was changed by the Set. Attempting to use the specified database fails, consistent with the current database still 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 may just be unimplemented and not a more subtle bug. I did not do a more serious investigation however, so take that with a 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 same code 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 command with Postgres (i.e. there is no equivalent to "USE" in SQL Server)?








-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



view thread (2+ messages)

Message-ID: <0NOO00C1V0TNIYA0@vms173025.mailsrvcs.net>
Permalink:  ../0NOO00C1V0TNIYA0@vms173025.mailsrvcs.net/
Also on:    postgresql.org/message-id/0NOO00C1V0TNIYA0@vms173025.mailsrvcs.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: smarvin@pobox.com
  Subject: Re: Setting Database Name During Connection
  In-Reply-To: <0NOO00C1V0TNIYA0@vms173025.mailsrvcs.net>
  References: <9570C4F8577FC041964C389777970D774A525D90A8@KITT.sensingsystems.com> <0NOO00C1V0TNIYA0@vms173025.mailsrvcs.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox