pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: noreply@pgfoundry.org
To: noreply@pgfoundry.org
Subject: [ psqlodbc-Bugs-1000601 ] Strange different behaviour of with SQLColAttribute with SQL_DESC_OCTET or SQL_DESC_LENGHT
Date: Thu, 30 Mar 2006 10:47:07 +0000 (GMT)
Message-ID: <20060330104707.28833103385C@pgfoundry.org> (raw)

Bugs item #1000601, was opened at 2006-03-30 10:47
You can respond by visiting: 
http://pgfoundry.org/tracker/?func=detail&atid=538&aid=1000601&group_id=1000125

Category: Interface (example)
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Nobody (None)
Assigned to: Nobody (None)
Summary: Strange different behaviour of with SQLColAttribute with SQL_DESC_OCTET or SQL_DESC_LENGHT

Initial Comment:
Dear ladies and gentlemen I stumbeled upon the following problelm
PSQL 8.1.x, (Unicode)
System Windows 2003 Server
I have a database test with the following table
t2 (i_val integer)

I run a query against this table and try to retrieve informaton about the result.
Here's the code (bare all error handling) now

#include <stdio.h>
#include <windows.h>
#include <winnls.h>
#include <sql.h>
#include <sqlext.h>
#include <assert.h>
#include "odb.h"
enum {SOME_LIMIT=512};



int main(void){
	char * dsn = "DSN=t2_psql";
	enum {BUF_SIZE=512};
	SQLHENV henv;
	SQLHDBC hdbc;
	SQLHSTMT hstmt;
	SQLRETURN rc;
	SQLINTEGER data_size;
	SQLCHAR con_out[BUF_SIZE];
	SQLSMALLINT con_out_count;

	rc = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
	assert(SUCCEEDED(rc));
	rc = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, 0);
	assert(SUCCEEDED(rc));
	rc = SQLAllocHandle (SQL_HANDLE_DBC, henv, &hdbc);
	assert(SUCCEEDED(rc));
	rc = SQLDriverConnect(hdbc, NULL, dsn, SQL_NTS,
        	               con_out, sizeof(con_out), &con_out_count, SQL_DRIVER_COMPLETE);
	assert(SUCCEEDED(rc));
	rc = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
	assert(SUCCEEDED(rc));
	rc = SQLExecDirect(hstmt, (SQLCHAR*) "select * from t2", SQL_NTS);
	assert(SUCCEEDED(rc));
	rc = SQLColAttribute(hstmt, 1, SQL_DESC_OCTET_LENGTH, NULL, 0, NULL, &con_out_count);
	assert(SUCCEEDED(rc));
	printf("con_out_count = %d\n", con_out_count);
	/* con_out_count = -1;
	rc = SQLColAttribute(hstmt, 1, SQL_DESC_LENGTH, NULL, 0, NULL, &con_out_count);
	printf("con_out_count = %d\n", con_out_count);
	*/
	SQLCloseCursor(hstmt);
	SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
	rc = SQLDisconnect(hdbc);
	SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
	SQLFreeHandle(SQL_HANDLE_ENV, henv);
	return 0;
}


If I run SQLColAttribute with SQL_DESC_OCTET_LENGTH I got as size for the 
first field an integer! 0

But if I use SQL_DESC_LENGTH I got 4. Of course here the 4 is correct AFAIKT.

This difference leads to a crash in an application in which I try to fetch the information for a generic SQL call.

Now is this an error in my usage? Is this correct behaviour or is it a bug in 
psqlODBC?

Regards
Friedrich

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

You can respond by visiting: 
http://pgfoundry.org/tracker/?func=detail&atid=538&aid=1000601&group_id=1000125



view thread (2+ messages)  latest in thread

Message-ID: <20060330104707.28833103385C@pgfoundry.org>
Permalink:  ../20060330104707.28833103385C@pgfoundry.org/
Also on:    postgresql.org/message-id/20060330104707.28833103385C@pgfoundry.org

 · 

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: noreply@pgfoundry.org
  Subject: Re: [ psqlodbc-Bugs-1000601 ] Strange different behaviour of with SQLColAttribute with SQL_DESC_OCTET or SQL_DESC_LENGHT
  In-Reply-To: <20060330104707.28833103385C@pgfoundry.org>
  References: <20060330104707.28833103385C@pgfoundry.org>

* 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