[ psqlodbc-Bugs-1000601 ] Strange different behaviour of with SQLColAttribute with SQL_DESC_OCTET or

[ psqlodbc-Bugs-1000601 ] Strange different behaviour of with SQLColAttribute with SQL_DESC_OCTET or

am 30.03.2006 12:47:07 von noreply

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=10006 01&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
#include
#include
#include
#include
#include
#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=10006 01&group_id=1000125

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org