[Gdal-dev] GDAL and ODBC >= 3.52

David Herring dherring at mohicam.com
Tue Jan 11 01:18:35 EST 2005


I'm wondering if anyone else has noticed that GDAL 1.2.5 doesn't compile
against ODBC 3.52.

Here are the details:

GDAL does not compile against ODBC 3.52 due to the new types introduced
in ODBC to handle 64 bit compiles. It appears that calls to
SQLDescribeCol and SQLGetData compiled against ODBC 3.52 should use the
new datatypes SQLLEN and SQLULEN for a few parameters instead of
SQLINTEGER and SQLUINTEGER.

This change is documented here: 

http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/odbc/htm/dasdkodbcoverview_64bit.asp

Note that the Microsoft documentation above applies to UNIX drivers as
well I've tried several including OpenLink and drivers from unixODBC.

I've attached a patch file for two source files: cpl_odbc.cpp and
cpl_odbc.h (cd gdal-1.2.5/port; patch < patch-gdal-odbc-3.52). 

This patch allows me to compile against ODBC 3.52, but a 'real' fix for
all GDAL users is slightly more complicated since the new types SQLLEN
and SQLULEN are not defined in ODBC <= 3.51.

I've downloaded ODBC 3.51 and 3.52 and am working on a patch to
configure.in and related files which I'll submit for consideration if
Frank or others feel it might help.


Regards,

David Herring
dherring at mohicam.com

-------------- next part --------------
--- cpl_odbc.cpp	2004-08-18 13:47:12.000000000 -0500
+++ cpl_odbc.cpp-patched	2005-01-08 00:35:03.398348631 -0600
@@ -352,9 +352,9 @@
     m_papszColNames = (char **) VSICalloc(sizeof(char *),(m_nColCount+1));
     m_papszColValues = (char **) VSICalloc(sizeof(char *),(m_nColCount+1));
 
     m_panColType = (short *) VSICalloc(sizeof(short),m_nColCount);
-    m_panColSize = (SQLUINTEGER *) VSICalloc(sizeof(SQLUINTEGER),m_nColCount);
+    m_panColSize = (SQLULEN *) VSICalloc(sizeof(SQLULEN),m_nColCount);
     m_panColPrecision = (short *) VSICalloc(sizeof(short),m_nColCount);
     m_panColNullable = (short *) VSICalloc(sizeof(short),m_nColCount);
 
 /* -------------------------------------------------------------------- */
@@ -567,9 +567,9 @@
     
     for( iCol = 0; iCol < m_nColCount; iCol++ )
     {
         char szWrkData[256];
-        SQLINTEGER cbDataLen;
+        SQLLEN cbDataLen;
         int nRetCode;
 
         szWrkData[0] = '\0';
         szWrkData[sizeof(szWrkData)-1] = '\0';
@@ -1026,9 +1026,9 @@
     m_papszColNames = (char **) calloc(sizeof(char *),(m_nColCount+1));
     m_papszColValues = (char **) calloc(sizeof(char *),(m_nColCount+1));
 
     m_panColType = (short *) calloc(sizeof(short),m_nColCount);
-    m_panColSize = (SQLUINTEGER *) calloc(sizeof(SQLUINTEGER),m_nColCount);
+    m_panColSize = (SQLULEN *) calloc(sizeof(SQLULEN),m_nColCount);
     m_panColPrecision = (short *) calloc(sizeof(short),m_nColCount);
     m_panColNullable = (short *) calloc(sizeof(short),m_nColCount);
 
 /* -------------------------------------------------------------------- */
@@ -1040,9 +1040,9 @@
 
     for( iCol = 0; iCol < m_nColCount; iCol++ )
     {
         char szWrkData[8193];
-        SQLINTEGER cbDataLen;
+        SQLLEN cbDataLen;
 
         if( Failed( SQLFetch( m_hStmt ) ) )
         {
             m_nColCount = (SQLUSMALLINT) iCol;
--- cpl_odbc.h	2004-06-23 11:11:30.000000000 -0500
+++ cpl_odbc.h-patched	2005-01-08 00:35:08.789358787 -0600
@@ -125,9 +125,9 @@
 
     short          m_nColCount;
     char         **m_papszColNames;
     short         *m_panColType;
-    SQLUINTEGER   *m_panColSize;
+    SQLULEN       *m_panColSize;
     short         *m_panColPrecision;
     short         *m_panColNullable;
 
     char         **m_papszColValues;


More information about the Gdal-dev mailing list