Changeset: 52cdf22c521f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/52cdf22c521f
Modified Files:
        clients/odbc/tests/ODBCtester.c
        sql/backends/monet5/vaults/odbc/odbc_loader.c
        sql/test/proto_loader/monetdb/Tests/monetdb.test.in
        sql/test/proto_loader/odbc/Tests/All
Branch: Mar2025
Log Message:

Backed out changeset aab6e4888b74


diffs (229 lines):

diff --git a/clients/odbc/tests/ODBCtester.c b/clients/odbc/tests/ODBCtester.c
--- a/clients/odbc/tests/ODBCtester.c
+++ b/clients/odbc/tests/ODBCtester.c
@@ -212,86 +212,6 @@ testGetDataTruncatedString(SQLHANDLE stm
        return ret;
 }
 
-static SQLRETURN
-testGetDataGUID(SQLHANDLE stmt)
-{
-       SQLRETURN ret;
-       SQLLEN RowCount = 0;
-       SWORD NumResultCols = 0;
-
-       size_t outp_len = 1800;
-       char * outp = malloc(outp_len);
-       size_t pos = 0;
-
-       char * sql = "select cast('eda7b074-3e0f-4bef-bdec-19c61bedb18f' as 
uuid) as val1, cast('beefc4f7-0264-4735-9b7a-75fd371ef803' as uuid) as val2, 
cast(NULL as uuid) as valnil;";
-       ret = SQLExecDirect(stmt, (SQLCHAR *) sql, SQL_NTS);
-       pos += snprintf(outp + pos, outp_len - pos, "SQLExecDirect\n");
-       check(ret, SQL_HANDLE_STMT, stmt, "SQLExecDirect");
-
-       ret = SQLRowCount(stmt, &RowCount);
-       pos += snprintf(outp + pos, outp_len - pos, "SQLRowCount is " LLFMT 
"\n", (int64_t) RowCount);
-       check(ret, SQL_HANDLE_STMT, stmt, "SQLRowCount");
-
-       ret = SQLNumResultCols(stmt, &NumResultCols);
-       pos += snprintf(outp + pos, outp_len - pos, "SQLNumResultCols is %d\n", 
NumResultCols);
-       check(ret, SQL_HANDLE_STMT, stmt, "SQLNumResultCols");
-
-       ret = SQLFetch(stmt);
-       pos += snprintf(outp + pos, outp_len - pos, "SQLFetch\n");
-       check(ret, SQL_HANDLE_STMT, stmt, "SQLFetch");
-
-       for (SWORD col = 1; col <= NumResultCols; col++) {
-               char buf[99];
-               SQLGUID guid_val;
-               char guid_str_val[40];
-               SQLLEN vallen = 0;
-               SQLLEN NumAttr = 0;
-
-               /* retrieve query result column metadata */
-               ret = SQLColAttribute(stmt, (UWORD)col, SQL_DESC_CONCISE_TYPE, 
(PTR)&buf, (SQLLEN)20, NULL, &NumAttr);
-               pos += snprintf(outp + pos, outp_len - pos, 
"SQLColAttribute(%d, SQL_DESC_CONCISE_TYPE) returns %d, NumAttr " LLFMT "\n", 
col, ret, (int64_t) NumAttr);
-               ret = SQLColAttribute(stmt, (UWORD)col, SQL_DESC_LENGTH, 
(PTR)&buf, (SQLLEN)20, NULL, &NumAttr);
-               pos += snprintf(outp + pos, outp_len - pos, 
"SQLColAttribute(%d, SQL_DESC_LENGTH) returns %d, NumAttr " LLFMT "\n", col, 
ret, (int64_t) NumAttr);
-               ret = SQLColAttribute(stmt, (UWORD)col, SQL_DESC_DISPLAY_SIZE, 
(PTR)&buf, (SQLLEN)20, NULL, &NumAttr);
-               pos += snprintf(outp + pos, outp_len - pos, 
"SQLColAttribute(%d, SQL_DESC_DISPLAY_SIZE) returns %d, NumAttr " LLFMT "\n", 
col, ret, (int64_t) NumAttr);
-
-               /* test SQLGetData(SQL_C_CHAR) */
-               ret = SQLGetData(stmt, (UWORD)col, (SWORD)SQL_C_CHAR, 
(PTR)&guid_str_val, (SQLLEN)40, &vallen);
-               pos += snprintf(outp + pos, outp_len - pos, "SQLGetData(%d, 
SQL_C_CHAR, 36) returns %d, vallen " LLFMT ", str_val: '%s'\n",
-                       col, ret, (int64_t) vallen, (vallen == SQL_NULL_DATA) ? 
"NULL" : guid_str_val);
-               check(ret, SQL_HANDLE_STMT, stmt, "SQLGetData(col)");
-
-               /* test SQLGetData(SQL_C_GUID) */
-               ret = SQLGetData(stmt, (UWORD)col, (SWORD)SQL_C_GUID, 
(PTR)&guid_val, (SQLLEN)16, &vallen);
-               pos += snprintf(outp + pos, outp_len - pos, "SQLGetData(%d, 
SQL_C_GUID, 16) returns %d, vallen " LLFMT ", data_val: 
%x-%x-%x-%x%x-%x%x%x%x%x%x\n",
-                       col, ret, (int64_t) vallen, guid_val.Data1, 
guid_val.Data2, guid_val.Data3,
-                       guid_val.Data4[0], guid_val.Data4[1], 
guid_val.Data4[2], guid_val.Data4[3], guid_val.Data4[4], guid_val.Data4[5], 
guid_val.Data4[6], guid_val.Data4[7]);
-               check(ret, SQL_HANDLE_STMT, stmt, "SQLGetData(col)");
-       }
-
-       compareResult("testGetDataGUID()", outp,
-                       "SQLExecDirect\nSQLRowCount is 1\nSQLNumResultCols is 
3\nSQLFetch\n"
-                       "SQLColAttribute(1, SQL_DESC_CONCISE_TYPE) returns 0, 
NumAttr -11\n"    /* -11 = SQL_GUID */
-                       "SQLColAttribute(1, SQL_DESC_LENGTH) returns 0, NumAttr 
36\n"
-                       "SQLColAttribute(1, SQL_DESC_DISPLAY_SIZE) returns 0, 
NumAttr 36\n"
-                       "SQLGetData(1, SQL_C_CHAR, 36) returns 0, vallen 36, 
str_val: 'eda7b074-3e0f-4bef-bdec-19c61bedb18f'\n"
-                       "SQLGetData(1, SQL_C_GUID, 16) returns 0, vallen 16, 
data_val: eda7b074-3e0f-4bef-bdec-19c61bedb18f\n"
-                       "SQLColAttribute(2, SQL_DESC_CONCISE_TYPE) returns 0, 
NumAttr -11\n"    /* -11 = SQL_GUID */
-                       "SQLColAttribute(2, SQL_DESC_LENGTH) returns 0, NumAttr 
36\n"
-                       "SQLColAttribute(2, SQL_DESC_DISPLAY_SIZE) returns 0, 
NumAttr 36\n"
-                       "SQLGetData(2, SQL_C_CHAR, 36) returns 0, vallen 36, 
str_val: 'beefc4f7-0264-4735-9b7a-75fd371ef803'\n"
-                       "SQLGetData(2, SQL_C_GUID, 16) returns 0, vallen 16, 
data_val: beefc4f7-0264-4735-9b7a-75fd371ef803\n"
-                       "SQLColAttribute(3, SQL_DESC_CONCISE_TYPE) returns 0, 
NumAttr -11\n"    /* -11 = SQL_GUID */
-                       "SQLColAttribute(3, SQL_DESC_LENGTH) returns 0, NumAttr 
36\n"
-                       "SQLColAttribute(3, SQL_DESC_DISPLAY_SIZE) returns 0, 
NumAttr 36\n"
-                       "SQLGetData(3, SQL_C_CHAR, 36) returns 0, vallen -1, 
str_val: 'NULL'\n"
-                       "SQLGetData(3, SQL_C_GUID, 16) returns 0, vallen -1, 
data_val: beefc4f7-0264-4735-9b7a-75fd371ef803\n");
-
-       /* cleanup */
-       free(outp);
-       return ret;
-}
-
 int
 main(int argc, char **argv)
 {
@@ -346,12 +266,6 @@ main(int argc, char **argv)
        ret = testGetDataTruncatedString(stmt, SQL_C_WCHAR);
        check(ret, SQL_HANDLE_STMT, stmt, "testGetDataTruncatedString(STMT, 
SQL_C_WCHAR)");
 
-       ret = SQLCloseCursor(stmt);
-       check(ret, SQL_HANDLE_STMT, stmt, "SQLCloseCursor");
-
-       ret = testGetDataGUID(stmt);
-       check(ret, SQL_HANDLE_STMT, stmt, "testGetDataGUID(STMT)");
-
        /* cleanup */
        ret = SQLFreeHandle(SQL_HANDLE_STMT, stmt);
        check(ret, SQL_HANDLE_STMT, stmt, "SQLFreeHandle (STMT)");
diff --git a/sql/backends/monet5/vaults/odbc/odbc_loader.c 
b/sql/backends/monet5/vaults/odbc/odbc_loader.c
--- a/sql/backends/monet5/vaults/odbc/odbc_loader.c
+++ b/sql/backends/monet5/vaults/odbc/odbc_loader.c
@@ -508,7 +508,7 @@ odbc_query(int caller, mvc *sql, sql_sub
                for (SQLUSMALLINT col = 1; col <= (SQLUSMALLINT) nr_cols; 
col++) {
                        /* for each result column get name, datatype, size and 
decdigits */
                        // TODO use ODBC W function
-                       ret = SQLDescribeCol(stmt, col, (SQLCHAR *) cname, 
(SQLSMALLINT) MAX_COL_NAME_LEN,
+                       ret = SQLDescribeCol(stmt, col, (SQLCHAR *) cname, 
(SQLSMALLINT) sizeof(cname) -1,
                                        NULL, &dataType, &columnSize, 
&decimalDigits, NULL);
                        if (ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO) 
{
                                errmsg = "SQLDescribeCol failed.";
@@ -525,7 +525,7 @@ odbc_query(int caller, mvc *sql, sql_sub
                        if (res_exps) {
                                /* also get the table name for this result 
column */
                                // TODO use ODBC W function
-                               ret = SQLColAttribute(stmt, col, 
SQL_DESC_TABLE_NAME, (SQLPOINTER) tname, (SQLSMALLINT) MAX_TBL_NAME_LEN, NULL, 
NULL);
+                               ret = SQLColAttribute(stmt, col, 
SQL_DESC_TABLE_NAME, (SQLPOINTER) tname, (SQLSMALLINT) sizeof(tname) -1, NULL, 
NULL);
                                if (ret != SQL_SUCCESS && ret != 
SQL_SUCCESS_WITH_INFO) {
                                        strcpy(tname, "");
                                }
@@ -566,7 +566,7 @@ odbc_query(int caller, mvc *sql, sql_sub
 
                        /* for each result column get SQL datatype, size and 
decdigits */
                        // TODO use ODBC W function
-                       ret = SQLDescribeCol(stmt, col+1, (SQLCHAR *) cname, 
(SQLSMALLINT) MAX_COL_NAME_LEN,
+                       ret = SQLDescribeCol(stmt, col+1, (SQLCHAR *) cname, 
(SQLSMALLINT) sizeof(cname) -1,
                                        NULL, &dataType, &columnSize, 
&decimalDigits, NULL);
                        if (ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO) 
{
                                errmsg = "SQLDescribeCol failed.";
@@ -657,15 +657,12 @@ odbc_query(int caller, mvc *sql, sql_sub
                TIME_STRUCT time_val;
                TIMESTAMP_STRUCT ts_val;
                SQLGUID guid_val;
-               uuid uuid_val = uuid_nil;
 
                /* allocate storage for all the var sized atom types. */
                char * str_val = NULL;          // TODO: change to wchar
                bte * blob_val = NULL;
                if (largestStringSize == 0)     // no valid string length, use 
65535 (64kB) as default
                        largestStringSize = 65535;
-               if (largestStringSize < 256)
-                       largestStringSize = 256;
                if (largestStringSize > 16777215) // string length too large, 
limit to 16MB
                        largestStringSize = 16777215;
                str_val = (char *)GDKzalloc((largestStringSize +1) * 
sizeof(char));     // +1 for the eos char
@@ -801,13 +798,8 @@ odbc_query(int caller, mvc *sql, sql_sub
                                                targetValuePtr = (SQLPOINTER *) 
&lng_val;
                                                break;
                                        case SQL_GUID:
-                                               /* read guid data as string 
data */
-//                                             targetType = SQL_C_CHAR;
-//                                             targetValuePtr = (SQLPOINTER *) 
str_val;
-//                                             bufferLength = 
largestStringSize;
                                                targetType = SQL_C_GUID;
                                                targetValuePtr = (SQLPOINTER *) 
&guid_val;
-                                               bufferLength = 16;
                                                break;
                                        case SQL_BINARY:
                                        case SQL_VARBINARY:
@@ -817,12 +809,10 @@ odbc_query(int caller, mvc *sql, sql_sub
                                                bufferLength = largestBlobSize;
                                                break;
                                }
-                               if (trace_enabled || true)
-                                       printf("Before SQLGetData(col %u C_type 
%d buflen %ld\n", col+1, targetType, bufferLength);
                                ret = SQLGetData(stmt, col+1, targetType, 
targetValuePtr, bufferLength, &strLen);
                                if (ret != SQL_SUCCESS && ret != 
SQL_SUCCESS_WITH_INFO) {
                                        if (trace_enabled || true)
-                                               printf("Failed to get C_type %d 
data for col %u of row %lu\n", targetType, col+1, row);
+                                               printf("Failed to get data for 
col %u of row %lu\n", col+1, row);
                                        /* as all bats need to be the correct 
length, append NULL value */
                                        if (BUNappend(b, ATOMnilptr(b->ttype), 
false) != GDK_SUCCEED)
                                                if (trace_enabled)
@@ -997,14 +987,10 @@ odbc_query(int caller, mvc *sql, sql_sub
                                                                gdkret = 
BUNappend(b, (void *) &lng_val, false);
                                                                break;
                                                        case SQL_GUID:
-                                                               if 
(trace_enabled || true)
-                                                                       
printf("Data row %lu col %u: %x-%x-%x-%x%x-%x%x%x%x%x%x\n", row, col+1,
-                                                                               
guid_val.Data1, guid_val.Data2, guid_val.Data3, guid_val.Data4[0], 
guid_val.Data4[1], guid_val.Data4[2],
-                                                                               
guid_val.Data4[3], guid_val.Data4[4], guid_val.Data4[5], guid_val.Data4[6], 
guid_val.Data4[7]);
+                                                               if 
(trace_enabled)
+                                                                       
printf("Data row %lu col %u: guid_val\n", row, col+1);
                                                                // uuid is 16 
bytes, same as SQLGUID guid_val
-                                                               memcpy((void *) 
&uuid_val, (void *) &guid_val, sizeof(uuid));
-//                                                             gdkret = 
BUNappend(b, (void *) &uuid_val, false);
-                                                               gdkret = 
BUNappend(b, ATOMnilptr(b->ttype), false);
+                                                               gdkret = 
BUNappend(b, (void *) &guid_val, false);
                                                                break;
                                                        case SQL_BINARY:
                                                        case SQL_VARBINARY:
diff --git a/sql/test/proto_loader/monetdb/Tests/monetdb.test.in 
b/sql/test/proto_loader/monetdb/Tests/monetdb.test.in
--- a/sql/test/proto_loader/monetdb/Tests/monetdb.test.in
+++ b/sql/test/proto_loader/monetdb/Tests/monetdb.test.in
@@ -6,12 +6,6 @@ select id from 'monetdb://127.0.0.1:$MAP
 2067
 2115
 
-query I nosort
-select id from 'monetdb://127.0.0.1:$MAPIPORT/$TSTDB/sys/tables' where name = 
'_tables' order by id
-----
-2067
-2115
-
 statement error 42000!SELECT: proto_loader function failed 'Table sys.tables2 
is missing on remote server'
 select * from 'monetdb://127.0.0.1:$MAPIPORT/$TSTDB/sys/tables2'
 
diff --git a/sql/test/proto_loader/odbc/Tests/All 
b/sql/test/proto_loader/odbc/Tests/All
--- a/sql/test/proto_loader/odbc/Tests/All
+++ b/sql/test/proto_loader/odbc/Tests/All
@@ -1,9 +1,7 @@
-# incomplete_uri
-# HAVE_ODBC?monetodbc
+incomplete_uri
+HAVE_ODBC?monetodbc
 !NOT_WIN32?monetodbc-Windows
 HAVE_SQLITE3ODBC&HAVE_DATA_PATH?sqlite3odbc
-# HAVE_ODBC?monetodbc_datatypes
-# HAVE_ODBC&HAVE_HGE?monetodbc_datatypes_hge
-HAVE_ODBC?wip
-# sqlite3odbc_local
-# HAVE_ODBC?monetodbc_local_41000
+HAVE_ODBC?monetodbc_datatypes
+HAVE_ODBC&HAVE_HGE?monetodbc_datatypes_hge
+
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to