Changeset: 4cfad18a81ae for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4cfad18a81ae
Modified Files:
        clients/ChangeLog.Feb2013
        clients/odbc/driver/ODBCConvert.c
        clients/odbc/samples/arraytest.c
Branch: Feb2013
Log Message:

SQL_C_SLONG refers to 32 bit int, not to potentially 64 bit long.
This hopefully fixes bug 3392.


diffs (80 lines):

diff --git a/clients/ChangeLog.Feb2013 b/clients/ChangeLog.Feb2013
--- a/clients/ChangeLog.Feb2013
+++ b/clients/ChangeLog.Feb2013
@@ -2,6 +2,10 @@
 # This file is updated with Maddlog
 
 * Wed Nov  6 2013 Sjoerd Mullender <[email protected]>
+- ODBC: Fixed interpretation SQL_C_SLONG/SQL_C_ULONG/SQL_C_LONG to
+  refer to a 32 bit integer always (i.e. "int" on 64 bit architectures
+  despite the name and the Microsoft documentation).  This seems to be
+  the consensus.
 - ODBC: Fixed transaction level: MonetDB only supports the highest level
   (SQL_TXN_SERIALIZABLE), so setting the transaction level can be accepted
   and ignored.
diff --git a/clients/odbc/driver/ODBCConvert.c 
b/clients/odbc/driver/ODBCConvert.c
--- a/clients/odbc/driver/ODBCConvert.c
+++ b/clients/odbc/driver/ODBCConvert.c
@@ -1985,9 +1985,9 @@ ODBCFetch(ODBCStmt *stmt,
                case SQL_C_LONG:
                        maxval <<= 31;
                        if (lenp)
-                               *lenp = sizeof(long);
+                               *lenp = sizeof(int);
                        if (ardrec && row > 0)
-                               ptr = (SQLPOINTER) ((char *) ptr + row * 
(bind_type == SQL_BIND_BY_COLUMN ? sizeof(long) : bind_type));
+                               ptr = (SQLPOINTER) ((char *) ptr + row * 
(bind_type == SQL_BIND_BY_COLUMN ? sizeof(int) : bind_type));
                        break;
                case SQL_C_SBIGINT:
                        maxval <<= 63;
@@ -2047,7 +2047,7 @@ ODBCFetch(ODBCStmt *stmt,
                                break;
                        case SQL_C_SLONG:
                        case SQL_C_LONG:
-                               *(long *) ptr = nval.sign ? (long) nval.val : 
-(long) nval.val;
+                               *(int *) ptr = nval.sign ? (int) nval.val : 
-(int) nval.val;
                                break;
                        case SQL_C_SBIGINT:
                                *(SQLBIGINT *) ptr = nval.sign ? (SQLBIGINT) 
nval.val : -(SQLBIGINT) nval.val;
@@ -2086,9 +2086,9 @@ ODBCFetch(ODBCStmt *stmt,
                case SQL_C_ULONG:
                        maxval <<= 32;
                        if (lenp)
-                               *lenp = sizeof(unsigned long);
+                               *lenp = sizeof(unsigned int);
                        if (ardrec && row > 0)
-                               ptr = (SQLPOINTER) ((char *) ptr + row * 
(bind_type == SQL_BIND_BY_COLUMN ? sizeof(unsigned long) : bind_type));
+                               ptr = (SQLPOINTER) ((char *) ptr + row * 
(bind_type == SQL_BIND_BY_COLUMN ? sizeof(unsigned int) : bind_type));
                        break;
                case SQL_C_UBIGINT:
                        if (lenp)
@@ -2145,7 +2145,7 @@ ODBCFetch(ODBCStmt *stmt,
                                *(unsigned short *) ptr = (unsigned short) 
nval.val;
                                break;
                        case SQL_C_ULONG:
-                               *(unsigned long *) ptr = (unsigned long) 
nval.val;
+                               *(unsigned int *) ptr = (unsigned int) nval.val;
                                break;
                        case SQL_C_UBIGINT:
                                *(SQLUBIGINT *) ptr = (SQLUBIGINT) nval.val;
diff --git a/clients/odbc/samples/arraytest.c b/clients/odbc/samples/arraytest.c
--- a/clients/odbc/samples/arraytest.c
+++ b/clients/odbc/samples/arraytest.c
@@ -126,7 +126,7 @@ main(int argc, char **argv)
        SQLULEN *processed;
        SQLUSMALLINT *status;
        SQLINTEGER offset;
-       long *data_i;
+       int *data_i;
        char (*data_s)[20];
        SQLLEN *data_slen;
        float *data_f;
@@ -370,7 +370,7 @@ main(int argc, char **argv)
                                data[i].t.hour, data[i].t.minute,
                                data[i].t.second);
                        fprintf(stderr,
-                               "%ld %g %s %04d-%02d-%02d %02d:%02d:%02d\n",
+                               "%d %g %s %04d-%02d-%02d %02d:%02d:%02d\n",
                                data_i[i], data_f[i], data_s[i],
                                data_d[i].year, data_d[i].month, data_d[i].day,
                                data_t[i].hour, data_t[i].minute,
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to