diff options
author | Bruce Momjian <bruce@momjian.us> | 2001-01-26 22:41:59 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2001-01-26 22:41:59 +0000 |
commit | 5a832218fd24e659826a8e5ca6cdafbdba1dde4b (patch) | |
tree | b6141aa4086978d09e5982e0d868b2d2b4ef356d /src/interfaces/odbc/connection.c | |
parent | 7edafafd731c36466daf99440882ae9225a141f1 (diff) | |
download | postgresql-5a832218fd24e659826a8e5ca6cdafbdba1dde4b.tar.gz postgresql-5a832218fd24e659826a8e5ca6cdafbdba1dde4b.zip |
odbc1.diff changes the text on the Protocol Radio buttons on the driver
dialogue from '6.4/6.5' to '6.5+' and removes some C++ comments from
resource.h (which VC++ insists on putting there).
odbc2.diff adds code to query the PostgreSQL version upon connection. This
is then used to determine what values to return for from SQLGetInfo for
SQL_DBMS_VER, SQL_MAX_ROW_SIZE, SQL_MAX_STATEMENT_LEN, SQL_OJ_CAPABILITIES
and SQL_OUTER_JOINS. The version string as returned by SELECT vERSION() (as
a char array) and the major.minor version number (as a flost) have been
added to the ConnectionClass structure.
Dave Page
Diffstat (limited to 'src/interfaces/odbc/connection.c')
-rw-r--r-- | src/interfaces/odbc/connection.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/interfaces/odbc/connection.c b/src/interfaces/odbc/connection.c index d5b0d12dffe..fe1344df8ab 100644 --- a/src/interfaces/odbc/connection.c +++ b/src/interfaces/odbc/connection.c @@ -699,6 +699,7 @@ static char *func="CC_connect"; */ CC_send_settings(self); CC_lookup_lo(self); /* a hack to get the oid of our large object oid type */ + CC_lookup_pg_version(self); /* Get PostgreSQL version for SQLGetInfo use */ CC_clear_error(self); /* clear any initial command errors */ self->status = CONN_CONNECTED; @@ -1364,6 +1365,62 @@ static char *func = "CC_lookup_lo"; result = SQLFreeStmt(hstmt, SQL_DROP); } +/* This function gets the version of PostgreSQL that we're connected to. + This is used to return the correct info in SQLGetInfo + DJP - 25-1-2001 +*/ +void +CC_lookup_pg_version(ConnectionClass *self) +{ +HSTMT hstmt; +StatementClass *stmt; +RETCODE result; +char *szVersion = "0.0"; +static char *func = "CC_lookup_pg_version"; + + mylog( "%s: entering...\n", func); + +/* This function must use the local odbc API functions since the odbc state + has not transitioned to "connected" yet. +*/ + result = SQLAllocStmt( self, &hstmt); + if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { + return; + } + stmt = (StatementClass *) hstmt; + + result = SQLExecDirect(hstmt, "select version()", SQL_NTS); + if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { + SQLFreeStmt(hstmt, SQL_DROP); + return; + } + + result = SQLFetch(hstmt); + if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { + SQLFreeStmt(hstmt, SQL_DROP); + return; + } + + result = SQLGetData(hstmt, 1, SQL_C_CHAR, self->pg_version, MAX_INFO_STRING, NULL); + if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { + SQLFreeStmt(hstmt, SQL_DROP); + return; + } + + /* There's proably a nicer way of doing this... */ + /* Extract the Major and Minor numbers from the string. */ + /* This assumes the string starts 'Postgresql X.X' */ + sprintf(szVersion, "%c.%c", self->pg_version[11], self->pg_version[13]); + self->pg_version_number = (float) atof(szVersion); + + mylog("Got the PostgreSQL version string: '%s'\n", self->pg_version); + mylog("Extracted PostgreSQL version number: '%1.1f'\n", self->pg_version_number); + qlog(" [ PostgreSQL version string = '%s' ]\n", self->pg_version); + qlog(" [ PostgreSQL version number = '%1.1f' ]\n", self->pg_version_number); + + result = SQLFreeStmt(hstmt, SQL_DROP); +} + void CC_log_error(char *func, char *desc, ConnectionClass *self) { |