Changeset: 57ec80e19fed for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/57ec80e19fed
Modified Files:
        clients/Tests/exports.stable.out
        monetdb5/mal/mal_client.c
        monetdb5/mal/mal_session.c
        sql/storage/store.c
Branch: userprofile
Log Message:

Merge with default branch.


diffs (truncated from 3217 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1009,6 +1009,7 @@ int getBitConstant(MalBlkPtr mb, bit val
 int getBlockBegin(MalBlkPtr mb, int pc);
 int getBlockExit(MalBlkPtr mb, int pc);
 int getBteConstant(MalBlkPtr mb, bte val);
+Client getClientContext(void);
 int getDblConstant(MalBlkPtr mb, dbl val);
 lng getDiskReads(void);
 lng getDiskSpace(void);
diff --git a/clients/odbc/ChangeLog b/clients/odbc/ChangeLog
--- a/clients/odbc/ChangeLog
+++ b/clients/odbc/ChangeLog
@@ -1,6 +1,13 @@
 # ChangeLog file for odbc
 # This file is updated with Maddlog
 
+* Thu Jul 14 2022 Martin van Dinther <[email protected]>
+- Removed the possibility to retrieve or set the CURRENT_CATALOG
+  via SQLGetConnectAttr(hdbc, SQL_ATTR_CURRENT_CATALOG, ...) and
+  SQLSetConnectAttr(hdbc, SQL_ATTR_CURRENT_CATALOG, ...) as MonetDB does
+  not support CATALOG objects (no SQL support for: CREATE CATALOG abc
+  or SET CATALOG abc) and therefore there is no CURRENT_CATALOG.
+
 * Thu Jun 23 2022 Martin van Dinther <[email protected]>
 - Corrected ODBC functions SQLTablePrivileges() and SQLColumnPrivileges()
   for local temporary tables located in schema tmp. They did not return
diff --git a/clients/odbc/driver/ODBCError.c b/clients/odbc/driver/ODBCError.c
--- a/clients/odbc/driver/ODBCError.c
+++ b/clients/odbc/driver/ODBCError.c
@@ -43,7 +43,7 @@ const char ODBCErrorMsgPrefix[] = "[Mone
 const int ODBCErrorMsgPrefixLength = (int) sizeof(ODBCErrorMsgPrefix) - 1;
 
 /*
- * Local utility function which retuns the standard ODBC/ISO error
+ * Local utility function which returns the standard ODBC/ISO error
  * message text for a given ISO SQLState code.
  * When no message could be found for a given SQLState a msg is
  * printed to stderr to warn that the programmer has forgotten to
diff --git a/clients/odbc/driver/SQLGetConnectAttr.c 
b/clients/odbc/driver/SQLGetConnectAttr.c
--- a/clients/odbc/driver/SQLGetConnectAttr.c
+++ b/clients/odbc/driver/SQLGetConnectAttr.c
@@ -84,9 +84,16 @@ MNDBGetConnectAttr(ODBCDbc *dbc,
                break;
        case SQL_ATTR_CURRENT_CATALOG:          /* SQLCHAR* */
                /* SQL_CURRENT_QUALIFIER */
-               copyString(dbc->dbname, strlen(dbc->dbname), ValuePtr,
-                          BufferLength, StringLengthPtr, SQLINTEGER,
-                          addDbcError, dbc, return SQL_ERROR);
+               /* MonetDB does NOT support SQL catalog concept, return empty 
string */
+               if (BufferLength <= 0) {
+                       /* Invalid string or buffer length */
+                       addDbcError(dbc, "HY090", NULL, 0);
+                       return SQL_ERROR;
+               }
+               strcpy_len((char *) ValuePtr, "", BufferLength);
+               if (StringLengthPtr) {
+                       *(StringLengthPtr) = (SQLINTEGER) 0;
+               }
                break;
        case SQL_ATTR_TXN_ISOLATION:            /* SQLUINTEGER */
                /* SQL_TXN_ISOLATION */
diff --git a/clients/odbc/driver/SQLGetTypeInfo.c 
b/clients/odbc/driver/SQLGetTypeInfo.c
--- a/clients/odbc/driver/SQLGetTypeInfo.c
+++ b/clients/odbc/driver/SQLGetTypeInfo.c
@@ -1033,7 +1033,7 @@ MNDBGetTypeInfo(ODBCStmt *stmt,
 {
        const struct types *t;
        int i;
-       char query[4096];
+       char query[4352];
 
        switch (DataType) {
        case SQL_ALL_TYPES:
@@ -1220,29 +1220,30 @@ MNDBGetTypeInfo(ODBCStmt *stmt,
                }
        }
        i += snprintf(query+ i, sizeof(query) - i, ") as monetdb_types "
-                     "(type_name"
-                     ",data_type"
-                     ",column_size"
-                     ",literal_prefix"
-                     ",literal_suffix"
-                     ",create_params"
-                     ",nullable"
-                     ",case_sensitive"
-                     ",searchable"
-                     ",unsigned_attribute"
-                     ",fixed_prec_scale"
-                     ",auto_unique_value"
-                     ",local_type_name"
-                     ",minimum_scale"
-                     ",maximum_scale"
-                     ",sql_data_type"
-                     ",sql_datetime_sub"
-                     ",num_prec_radix"
-                     ",interval_precision)");
+                     "(\"TYPE_NAME\""
+                     ",\"DATA_TYPE\""
+                     ",\"COLUMN_SIZE\""
+                     ",\"LITERAL_PREFIX\""
+                     ",\"LITERAL_SUFFIX\""
+                     ",\"CREATE_PARAMS\""
+                     ",\"NULLABLE\""
+                     ",\"CASE_SENSITIVE\""
+                     ",\"SEARCHABLE\""
+                     ",\"UNSIGNED_ATTRIBUTE\""
+                     ",\"FIXED_PREC_SCALE\""
+                     ",\"AUTO_UNIQUE_VALUE\""
+                     ",\"LOCAL_TYPE_NAME\""
+                     ",\"MINIMUM_SCALE\""
+                     ",\"MAXIMUM_SCALE\""
+                     ",\"SQL_DATA_TYPE\""
+                     ",\"SQL_DATETIME_SUB\""
+                     ",\"NUM_PREC_RADIX\""
+                     ",\"INTERVAL_PRECISION\")");
        assert(i < (int) sizeof(query));
 
-       return MNDBExecDirect(stmt, (SQLCHAR *) query,
-                             (SQLINTEGER) i);
+       /* debug: fprintf(stdout, "SQLGetTypeInfo query (pos: %d, len: 
%zu):\n%s\n\n", i, strlen(query), query); */
+
+       return MNDBExecDirect(stmt, (SQLCHAR *) query, (SQLINTEGER) i);
 }
 
 #ifdef ODBCDEBUG
diff --git a/clients/odbc/driver/SQLSetConnectAttr.c 
b/clients/odbc/driver/SQLSetConnectAttr.c
--- a/clients/odbc/driver/SQLSetConnectAttr.c
+++ b/clients/odbc/driver/SQLSetConnectAttr.c
@@ -58,22 +58,9 @@ MNDBSetConnectAttr(ODBCDbc *dbc,
                }
                return SQL_SUCCESS;
        case SQL_ATTR_CURRENT_CATALOG:          /* SQLCHAR* */
-               fixODBCstring(ValuePtr, StringLength, SQLINTEGER,
-                             addDbcError, dbc, return SQL_ERROR);
-               if (dbc->Connected) {
-                       /* Driver does not support this functions */
-                       addDbcError(dbc, "IM001", NULL, 0);
-                       return SQL_ERROR;
-               }
-               if (dbc->dbname)
-                       free(dbc->dbname);
-               dbc->dbname = dupODBCstring(ValuePtr, StringLength);
-               if (dbc->dbname == NULL) {
-                       /* Memory allocation error */
-                       addDbcError(dbc, "HY001", NULL, 0);
-                       return SQL_ERROR;
-               }
-               break;
+               /* Driver does not support this function */
+               addDbcError(dbc, "IM001", NULL, 0);
+               return SQL_ERROR;
        case SQL_ATTR_CONNECTION_TIMEOUT:       /* SQLUINTEGER */
                dbc->sql_attr_connection_timeout = (SQLUINTEGER) (uintptr_t) 
ValuePtr;
                if (dbc->mid)
diff --git a/clients/odbc/driver/SQLSetStmtAttr.c 
b/clients/odbc/driver/SQLSetStmtAttr.c
--- a/clients/odbc/driver/SQLSetStmtAttr.c
+++ b/clients/odbc/driver/SQLSetStmtAttr.c
@@ -267,14 +267,7 @@ MNDBSetStmtAttr(ODBCStmt *stmt,
                }
                break;
 
-       case SQL_ATTR_ROW_NUMBER:            /* SQLULEN */
-               /* read-only attribute */
-       default:
-               /* Invalid attribute/option identifier */
-               addStmtError(stmt, "HY092", NULL, 0);
-               return SQL_ERROR;
-
-               /* TODO: implement requested behavior */
+       /* TODO: implement requested behavior */
        case SQL_ATTR_ASYNC_ENABLE:             /* SQLULEN */
 #ifdef SQL_ATTR_ASYNC_STMT_EVENT
        case SQL_ATTR_ASYNC_STMT_EVENT:         /* SQLPOINTER */
@@ -293,6 +286,13 @@ MNDBSetStmtAttr(ODBCStmt *stmt,
                /* Optional feature not implemented */
                addStmtError(stmt, "HYC00", NULL, 0);
                return SQL_ERROR;
+
+       case SQL_ATTR_ROW_NUMBER:            /* SQLULEN */
+               /* invalid attribute, can only be used with SQLGetStmtAttr */
+       default:
+               /* Invalid attribute/option identifier */
+               addStmtError(stmt, "HY092", NULL, 0);
+               return SQL_ERROR;
        }
 
        return stmt->Error ? SQL_SUCCESS_WITH_INFO : SQL_SUCCESS;
diff --git a/clients/odbc/samples/CMakeLists.txt 
b/clients/odbc/samples/CMakeLists.txt
--- a/clients/odbc/samples/CMakeLists.txt
+++ b/clients/odbc/samples/CMakeLists.txt
@@ -16,12 +16,6 @@ if(TESTING)
     PRIVATE
     ODBC::ODBC)
 
-  add_executable(testgetinfo
-    testgetinfo.c)
-  target_link_libraries(testgetinfo
-    PRIVATE
-    ODBC::ODBC)
-
   add_executable(arraytest
     arraytest.c)
 
@@ -29,18 +23,9 @@ if(TESTING)
     PRIVATE
     ODBC::ODBC)
 
-  add_executable(metadata
-    metadata.c)
-
-  target_link_libraries(metadata
-    PRIVATE
-    ODBC::ODBC)
-
   install(TARGETS
     odbcsample1
-    testgetinfo
     arraytest
-    metadata
     RUNTIME
     DESTINATION
     ${CMAKE_INSTALL_BINDIR}
@@ -49,9 +34,7 @@ if(TESTING)
   if(WIN32)
     install(FILES
       $<TARGET_PDB_FILE:odbcsample1>
-      $<TARGET_PDB_FILE:testgetinfo>
       $<TARGET_PDB_FILE:arraytest>
-      $<TARGET_PDB_FILE:metadata>
       DESTINATION ${CMAKE_INSTALL_BINDIR}
       OPTIONAL)
   endif()
diff --git a/clients/odbc/tests/CMakeLists.txt 
b/clients/odbc/tests/CMakeLists.txt
--- a/clients/odbc/tests/CMakeLists.txt
+++ b/clients/odbc/tests/CMakeLists.txt
@@ -9,6 +9,12 @@
 include_directories($<$<BOOL:${ODBC_FOUND}>:${ODBC_INCLUDE_DIRS}>)
 
 if(TESTING)
+  add_executable(ODBCgetInfo
+    ODBCgetInfo.c)
+  target_link_libraries(ODBCgetInfo
+    PRIVATE
+    ODBC::ODBC)
+
   add_executable(ODBCStmtAttr
     ODBCStmtAttr.c)
 
@@ -16,8 +22,17 @@ if(TESTING)
     PRIVATE
     ODBC::ODBC)
 
+  add_executable(ODBCmetadata
+    ODBCmetadata.c)
+
+  target_link_libraries(ODBCmetadata
+    PRIVATE
+    ODBC::ODBC)
+
   install(TARGETS
+    ODBCgetInfo
     ODBCStmtAttr
+    ODBCmetadata
     RUNTIME
     DESTINATION
     ${CMAKE_INSTALL_BINDIR}
@@ -25,7 +40,9 @@ if(TESTING)
 
   if(WIN32)
     install(FILES
+      $<TARGET_PDB_FILE:ODBCgetInfo>
       $<TARGET_PDB_FILE:ODBCStmtAttr>
+      $<TARGET_PDB_FILE:ODBCmetadata>
       DESTINATION ${CMAKE_INSTALL_BINDIR}
       OPTIONAL)
   endif()
diff --git a/clients/odbc/tests/ODBCStmtAttr.c 
b/clients/odbc/tests/ODBCStmtAttr.c
--- a/clients/odbc/tests/ODBCStmtAttr.c
+++ b/clients/odbc/tests/ODBCStmtAttr.c
@@ -12,6 +12,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
+#include <string.h>
 #include <sql.h>
 #include <sqlext.h>
 
@@ -31,7 +32,12 @@ prerr(SQLSMALLINT tpe, SQLHANDLE hnd, co
                        fprintf(stderr, "(message truncated)\n");
                /* fall through */
        case SQL_SUCCESS:
-               fprintf(stderr, "%s: %s: SQLstate %s, Errnr %d, Message %s\n", 
func, pref, (char*)state, (int)errnr, (char*)msg);
+               if ((strcmp(func,"SQLSetStmtAttr") != 0)
+                || (strcmp(pref,"Info") != 0)
+                || (strcmp((char*)state,"01S02") != 0)
+                || errnr != 0
+                || (strncmp((char*)msg,"[MonetDB][ODBC Driver 11.", 25) != 0))
+                       fprintf(stderr, "%s: %s: SQLstate %s, Errnr %d, Message 
%s\n", func, pref, (char*)state, (int)errnr, (char*)msg);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to