pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
bug in sqlGetInfo on Linux i386 platform
2+ messages / 2 participants
[nested] [flat]

* bug in sqlGetInfo on Linux i386 platform
@ 2013-01-29 18:26  Son Nguyen <son102yh@yahoo.ca>
  0 siblings, 1 reply; 2+ messages in thread

From: Son Nguyen @ 2013-01-29 18:26 UTC (permalink / raw)
  To: pgsql-odbc

Hi,
 
sqlGetInfo on SQL_DBMS_VER returns different string when I have the protocol setting in the odbc.ini file
 
1)  Here is the odbc.ini file that has entry Protocol which is set to 7.2, or 6.4.  The SQM_DBMS_VER string contains some other info.
[GOSALES1_PG_92]
Driver=/usr/pgsql-9.1/lib/psqlodbc.so
Description=Sample PostgreSQL DSN
Servername=vottdts26
Database=gosales1
Username=gosales1
Password=gosales1
Servertype=postgres
Port=5432
Protocol = 7.2
 drv-mob:/uda/dev/nguyens/postgres> ./a.out
SQL_DBMS_NAME = PostgreSQL, StringLengthPtr = 10 
SQL_DBMS_VER = PostgreSQL 9.2.1, compiled by Visual C++ build 1600, 64-bit, StringLengthPtr = 59 
SQL_DRIVER_NAME = psqlodbcw.so, StringLengthPtr = 12 
SQL_DRIVER_VER = 09.00.0310, StringLengthPtr = 10 
 
 
2)  Here is the odbc.ini that Protocol entry is commented out.  The SQM_DBMS_VER string does not contain other info.
[GOSALES1_PG_92]
Driver=/usr/pgsql-9.1/lib/psqlodbc.so
Description=Sample PostgreSQL DSN
Servername=vottdts26
Database=gosales1
Username=gosales1
Password=gosales1
Servertype=postgres
Port=5432
;Protocol = 7.2
 
drv-mob:/uda/dev/nguyens/postgres> ./a.out
SQL_DBMS_NAME = PostgreSQL, StringLengthPtr = 10 
SQL_DBMS_VER = 9.2.1, StringLengthPtr = 5 
SQL_DRIVER_NAME = psqlodbcw.so, StringLengthPtr = 12 
SQL_DRIVER_VER = 09.00.0310, StringLengthPtr = 10
 
Thanks
 
Son Nguyen=

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

Attachments:

getDatabaseInfo.c (text/plain, 5.0K) download #if defined(WIN32) #include <windows.h> #endif #include "sql.h" #include "sqlext.h" #include "sqltypes.h" #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <locale.h> #include <ctype.h> #define NUMBER_THREADS 40 #define UDA_MAX_STRING_LENGTH 1024 void print_error( char * api, SQLSMALLINT HandleType, SQLHANDLE Handle ) { SQLRETURN rc = SQL_SUCCESS; SQLCHAR Sqlstate[ SQL_MAX_MESSAGE_LENGTH ]; SQLINTEGER NativeErrorPtr; SQLCHAR MessageText[ SQL_MAX_MESSAGE_LENGTH ]; SQLSMALLINT BufferLength = sizeof( MessageText ); SQLSMALLINT TextLengthPtr; int i = 1; while( SQL_NO_DATA != SQLGetDiagRec ( HandleType, Handle, i++, Sqlstate, &NativeErrorPtr, MessageText, BufferLength, &TextLengthPtr ) ) { printf( "api = %s, Error: %s\n", api, MessageText ); } } SQLRETURN connect1( SQLHANDLE * henv, SQLHANDLE * hdbc ) { SQLRETURN rc = SQL_SUCCESS; rc = SQLAllocHandle ( SQL_HANDLE_ENV, SQL_NULL_HANDLE, henv ); if ( rc != SQL_SUCCESS ) { print_error( "SQLAllocHandle", SQL_HANDLE_ENV, NULL ); } rc = SQLSetEnvAttr(*henv, SQL_ATTR_ODBC_VERSION, ( SQLPOINTER )SQL_OV_ODBC3, 0); if ( rc != SQL_SUCCESS ) { print_error( "SQLSetEnvAttr", SQL_HANDLE_ENV, *henv ); } rc = SQLAllocHandle( SQL_HANDLE_DBC, *henv, hdbc ); if ( rc != SQL_SUCCESS ) { print_error( "SQLAllocHandle", SQL_HANDLE_ENV, *henv ); } rc = SQLSetConnectAttr ( *hdbc, SQL_LOGIN_TIMEOUT, 0, 0 ); if ( rc != SQL_SUCCESS ) { print_error( "SQLSetConnectAttr", SQL_HANDLE_DBC, *hdbc ); } { SQLHWND WindowHandle = NULL; SQLCHAR InConnectionString[ 1024 ] = "DSN=GOSALES1_PG_92;UID=gosales1;PWD=gosales1"; SQLSMALLINT StringLength1 = sizeof( InConnectionString ); SQLCHAR OutConnectionString[ 1024 ]; SQLSMALLINT BufferLength = sizeof( OutConnectionString ); SQLSMALLINT StringLength2Ptr; SQLUSMALLINT DriverCompletion = SQL_DRIVER_COMPLETE; rc = SQLDriverConnect( *hdbc, WindowHandle, InConnectionString, StringLength1, OutConnectionString, BufferLength, &StringLength2Ptr, DriverCompletion ); if ( rc != SQL_SUCCESS ) { print_error( "SQLDriverConnect", SQL_HANDLE_DBC, *hdbc ); } } return rc; } SQLRETURN disconnect1( SQLHENV henv, SQLHDBC hdbc ) { SQLRETURN rc = SQL_SUCCESS; rc = SQLDisconnect( hdbc ); if ( rc != SQL_SUCCESS ) { print_error( "SQLDisconnect", SQL_HANDLE_DBC, hdbc ); } rc = SQLFreeHandle( SQL_HANDLE_DBC, hdbc ); if ( rc != SQL_SUCCESS ) { print_error( "SQLFreeHandle", SQL_HANDLE_DBC, hdbc ); } rc = SQLFreeHandle( SQL_HANDLE_ENV, henv ); if ( rc != SQL_SUCCESS ) { print_error( "SQLFreeHandle", SQL_HANDLE_ENV, henv ); } return rc; } SQLRETURN getDatabaseInfo( SQLHENV henv, SQLHDBC hdbc ) { SQLSMALLINT StringLengthPtr; SQLRETURN rc = SQL_SUCCESS; union { SQLCHAR infoChar [ UDA_MAX_STRING_LENGTH + 4 ]; SQLUINTEGER infoUInteger ; SQLUSMALLINT infoUSmallInt ; } infoData; rc = SQLGetInfo ( hdbc, SQL_DBMS_NAME, infoData.infoChar, sizeof(infoData.infoChar), &StringLengthPtr ); if ( rc != SQL_SUCCESS ) { print_error( "SQLGetInfo", SQL_HANDLE_DBC, hdbc ); } printf ("SQL_DBMS_NAME = %s, StringLengthPtr = %d \n", infoData.infoChar, StringLengthPtr ); rc = SQLGetInfo ( hdbc, SQL_DBMS_VER, infoData.infoChar, sizeof(infoData.infoChar), &StringLengthPtr ); if ( rc != SQL_SUCCESS ) { print_error( "SQLGetInfo", SQL_HANDLE_DBC, hdbc ); } printf ("SQL_DBMS_VER = %s, StringLengthPtr = %d \n", infoData.infoChar, StringLengthPtr ); rc = SQLGetInfo ( hdbc, SQL_DRIVER_NAME, infoData.infoChar, sizeof(infoData.infoChar), &StringLengthPtr ); if ( rc != SQL_SUCCESS ) { print_error( "SQLGetInfo", SQL_HANDLE_DBC, hdbc ); } printf ("SQL_DRIVER_NAME = %s, StringLengthPtr = %d \n", infoData.infoChar, StringLengthPtr ); rc = SQLGetInfo ( hdbc, SQL_DRIVER_VER, infoData.infoChar, sizeof(infoData.infoChar), &StringLengthPtr ); if ( rc != SQL_SUCCESS ) { print_error( "SQLGetInfo", SQL_HANDLE_DBC, hdbc ); } printf ("SQL_DRIVER_VER = %s, StringLengthPtr = %d \n", infoData.infoChar, StringLengthPtr ); return rc; } void test1( void *dummyPtr ) { SQLRETURN rc = SQL_SUCCESS; SQLHENV henv; SQLHDBC hdbc; rc = connect1( &henv, &hdbc ); if ( rc != SQL_SUCCESS ) { printf( "connect() failed \n" ); } rc = getDatabaseInfo( henv, hdbc ); if ( rc != SQL_SUCCESS ) { printf( "getDatabaseInfo() failed \n" ); } rc = disconnect1( henv, hdbc ); if ( rc != SQL_SUCCESS ) { printf( "disconnect() failed \n" ); } } int main(int argc, char *argv[]) { test1( NULL ); return 0; } void strupr1( char *str ) { char * c; for( c = str; *c != '\0'; c++ ) { *c = toupper( *c ); } }
^ permalink raw reply [nested|flat] 2+ messages in thread

* Re: bug in sqlGetInfo on Linux i386 platform
@ 2013-01-31 00:12  Inoue, Hiroshi <inoue@tpf.co.jp>
  parent: Son Nguyen <son102yh@yahoo.ca>
  0 siblings, 0 replies; 2+ messages in thread

From: Inoue, Hiroshi @ 2013-01-31 00:12 UTC (permalink / raw)
  To: Son Nguyen <son102yh@yahoo.ca>; +Cc: pgsql-odbc

Hi Son,

(2013/01/30 3:26), Son Nguyen wrote:
> Hi,
> sqlGetInfo on SQL_DBMS_VER returns different string when I have the
> protocol setting in the odbc.ini file
> 1)  Here is the odbc.ini file that has entry Protocol which is set to
> 7.2, or 6.4.

The effective values for *Protocol* are 6.2, 6.3, 6.4 or 7.4 and the
  default is 7.4. Setting the protocol to values other than 7.4 has
  little meaning for recent versions of PostgreSQL servers. In case
of old protocols the SQL_DBMS_VER string is simply the string which 
'select version();' returns.

regards,
Hiroshi Inoue

 > The SQM_DBMS_VER string contains some other info.
> [GOSALES1_PG_92]
> Driver=/usr/pgsql-9.1/lib/psqlodbc.so
> Description=Sample PostgreSQL DSN
> Servername=vottdts26
> Database=gosales1
> Username=gosales1
> Password=gosales1
> Servertype=postgres
> Port=5432
> Protocol = 7.2
> drv-mob:/uda/dev/nguyens/postgres> ./a.out
> SQL_DBMS_NAME = PostgreSQL, StringLengthPtr = 10
> SQL_DBMS_VER = PostgreSQL 9.2.1, compiled by Visual C++ build 1600,
> 64-bit, StringLengthPtr = 59
> SQL_DRIVER_NAME = psqlodbcw.so, StringLengthPtr = 12
> SQL_DRIVER_VER = 09.00.0310, StringLengthPtr = 10
> 2)  Here is the odbc.ini that Protocol entry is commented out.  The
> SQM_DBMS_VER string does not contain other info.
> [GOSALES1_PG_92]
> Driver=/usr/pgsql-9.1/lib/psqlodbc.so
> Description=Sample PostgreSQL DSN
> Servername=vottdts26
> Database=gosales1
> Username=gosales1
> Password=gosales1
> Servertype=postgres
> Port=5432
> ;Protocol = 7.2
> drv-mob:/uda/dev/nguyens/postgres> ./a.out
> SQL_DBMS_NAME = PostgreSQL, StringLengthPtr = 10
> SQL_DBMS_VER = 9.2.1, StringLengthPtr = 5
> SQL_DRIVER_NAME = psqlodbcw.so, StringLengthPtr = 12
> SQL_DRIVER_VER = 09.00.0310, StringLengthPtr = 10
> Thanks
> Son Nguyen




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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2013-01-31 00:12 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-01-29 18:26 bug in sqlGetInfo on Linux i386 platform Son Nguyen <son102yh@yahoo.ca>
2013-01-31 00:12 ` Inoue, Hiroshi <inoue@tpf.co.jp>

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