pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Son Nguyen <son102yh@yahoo.ca>
To: pgsql-odbc@postgresql.org <pgsql-odbc@postgresql.org>
Subject: bug in sqlGetInfo on Linux i386 platform
Date: Tue, 29 Jan 2013 10:26:35 -0800 (PST)
Message-ID: <1359483995.96753.YahooMailNeo@web163902.mail.gq1.yahoo.com> (raw )
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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 );
}
}
view thread (2+ messages) latest in thread
Message-ID: <1359483995.96753.YahooMailNeo@web163902.mail.gq1.yahoo.com>
Permalink: ../1359483995.96753.YahooMailNeo@web163902.mail.gq1.yahoo.com/
Also on: postgresql.org/message-id/1359483995.96753.YahooMailNeo@web163902.mail.gq1.yahoo.com
copy link · copy postgr.es
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: son102yh@yahoo.ca
Subject: Re: bug in sqlGetInfo on Linux i386 platform
In-Reply-To: <1359483995.96753.YahooMailNeo@web163902.mail.gq1.yahoo.com>
References: <1359483995.96753.YahooMailNeo@web163902.mail.gq1.yahoo.com>
* 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