Changeset: 2f9390c86965 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2f9390c86965
Branch: userprofile
Log Message:

merge with default


diffs (truncated from 38627 to 300 lines):

diff --git a/clients/ChangeLog.Jan2022 b/clients/ChangeLog.Jan2022
--- a/clients/ChangeLog.Jan2022
+++ b/clients/ChangeLog.Jan2022
@@ -1,6 +1,11 @@
 # ChangeLog file for clients
 # This file is updated with Maddlog
 
+* Fri Jun 10 2022 Sjoerd Mullender <[email protected]>
+- Implemented dump of global grants, that is to say, grants for COPY INTO
+  and COPY FROM which grant permission to users to write to or read from
+  files on the server (COPY INTO queries without the ON CLIENT option).
+
 * Tue May 31 2022 Sjoerd Mullender <[email protected]>
 - Fixed a bug where when the semicolon at the end of a COPY INTO query
   that reads from STDIN is at exactly a 10240 byte boundary in a file,
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
@@ -198,6 +198,7 @@ gdk_return BATsubcross(BAT **r1p, BAT **
 BAT *BATsubexist(BAT *l, BAT *g, BAT *e, BAT *s);
 BAT *BATsubnot_exist(BAT *l, BAT *g, BAT *e, BAT *s);
 gdk_return BATsum(void *res, int tp, BAT *b, BAT *s, bool skip_nils, bool 
nil_if_empty);
+const char *BATtailname(const BAT *b);
 gdk_return BATthetajoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT 
*sr, int op, bool nil_matches, BUN estimate) 
__attribute__((__warn_unused_result__));
 BAT *BATthetaselect(BAT *b, BAT *s, const void *val, const char *op);
 void BATtseqbase(BAT *b, oid o);
@@ -209,11 +210,13 @@ BBPrec *BBP[N_BBPINIT];
 gdk_return BBPaddfarm(const char *dirname, uint32_t rolemask, bool logerror);
 void BBPcold(bat i);
 int BBPfix(bat b);
+unsigned BBPheader(FILE *fp, int *lineno, bat *bbpsize, lng *logno, lng 
*transid);
 bat BBPindex(const char *nme);
 void BBPkeepref(BAT *b) __attribute__((__nonnull__(1)));
 bat BBPlimit;
 void BBPlock(void);
 BAT *BBPquickdesc(bat b);
+int BBPreadBBPline(FILE *fp, unsigned bbpversion, int *lineno, BAT *bn, int 
*hashash, char *batname, char *filename, char **options);
 int BBPreclaim(BAT *b);
 int BBPrelease(bat b);
 int BBPrename(BAT *b, const char *nme);
diff --git a/clients/odbc/CMakeLists.txt b/clients/odbc/CMakeLists.txt
--- a/clients/odbc/CMakeLists.txt
+++ b/clients/odbc/CMakeLists.txt
@@ -14,4 +14,5 @@ if(ODBC_FOUND)
   endif()
   add_subdirectory(driver)
   add_subdirectory(samples)
+  add_subdirectory(tests)
 endif()
diff --git a/clients/odbc/ChangeLog b/clients/odbc/ChangeLog
--- a/clients/odbc/ChangeLog
+++ b/clients/odbc/ChangeLog
@@ -1,6 +1,28 @@
 # ChangeLog file for odbc
 # This file is updated with Maddlog
 
+* 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
+  any rows when the temporary table had privileges set. Now they do return
+  rows as expected.
+
+* Wed Jun 22 2022 Martin van Dinther <[email protected]>
+- Improved SQLProcedures() and SQLProcedureColumns(). They now list
+  information also for all built-in system procedures and functions, not
+  only those created via SQL. Also corrected the value of ORDINAL_POSITION
+  for scalar function arguments. It would start at 2 instead of 1.
+- Extended output of SQLProcedures() and SQLProcedureColumns() resultsets
+  with an extra column SPECIFIC_NAME. This column contains the name which
+  uniquely identifies this procedure or function within its schema. As
+  MonetDB supports overloaded procedures and functions, the combination of
+  PROCEDURE_SCHEM and PROCEDURE_NAME is not enough to uniquely identify
+  a procedure or function. This extra column allows you to correctly
+  match the corresponding rows returned by SQLProcedureColumns() with the
+  specific rows of SQLProcedures(). This extra column SPECIFIC_NAME is
+  implemented similar to the JDBC DatabaseMetaData methods getProcedures()
+  and getProcedureColumns().
+
 * Thu Jun  9 2022 Martin van Dinther <[email protected]>
 - For SQLForeignKeys() corrected the output of columns UPDATE_RULE and
   DELETE_RULE. These columns used to always return 3 (= SQL_NO_ACTION)
@@ -32,7 +54,7 @@
   always returned NULL for the CARDINALITY result column.
 
 * Thu Apr 21 2022 Martin van Dinther <[email protected]>
-- Corrected ODBC API functions SQLPrimaryKeys(), SQLSpecialColumns() and
+- Corrected ODBC functions SQLPrimaryKeys(), SQLSpecialColumns() and
   SQLStatistics() for local temporary tables located in schema tmp. They did
   not return any rows when the temp table had a primary or unique key or
   index. Now they do return rows as expected.
diff --git a/clients/odbc/driver/ODBCStmt.c b/clients/odbc/driver/ODBCStmt.c
--- a/clients/odbc/driver/ODBCStmt.c
+++ b/clients/odbc/driver/ODBCStmt.c
@@ -76,8 +76,8 @@ newODBCStmt(ODBCDbc *dbc)
                .retrieveData = SQL_RD_ON,
                .noScan = SQL_NOSCAN_OFF,
 
-               .ApplRowDescr = newODBCDesc(dbc),
-               .ApplParamDescr = newODBCDesc(dbc),
+               .AutoApplRowDescr = newODBCDesc(dbc),
+               .AutoApplParamDescr = newODBCDesc(dbc),
                .ImplRowDescr = newODBCDesc(dbc),
                .ImplParamDescr = newODBCDesc(dbc),
 
@@ -90,20 +90,20 @@ newODBCStmt(ODBCDbc *dbc)
                destroyODBCStmt(stmt);
                return NULL;
        }
-       if (stmt->ApplRowDescr == NULL || stmt->ApplParamDescr == NULL ||
+       if (stmt->AutoApplRowDescr == NULL || stmt->AutoApplParamDescr == NULL 
||
            stmt->ImplRowDescr == NULL || stmt->ImplParamDescr == NULL) {
                destroyODBCStmt(stmt);
                return NULL;
        }
 
-       stmt->ApplRowDescr->sql_desc_alloc_type = SQL_DESC_ALLOC_AUTO;
-       stmt->ApplParamDescr->sql_desc_alloc_type = SQL_DESC_ALLOC_AUTO;
+       stmt->AutoApplRowDescr->sql_desc_alloc_type = SQL_DESC_ALLOC_AUTO;
+       stmt->AutoApplParamDescr->sql_desc_alloc_type = SQL_DESC_ALLOC_AUTO;
        stmt->ImplRowDescr->sql_desc_alloc_type = SQL_DESC_ALLOC_AUTO;
        stmt->ImplParamDescr->sql_desc_alloc_type = SQL_DESC_ALLOC_AUTO;
        stmt->ImplRowDescr->Stmt = stmt;
        stmt->ImplParamDescr->Stmt = stmt;
-       stmt->AutoApplRowDescr = stmt->ApplRowDescr;
-       stmt->AutoApplParamDescr = stmt->ApplParamDescr;
+       stmt->ApplRowDescr = stmt->AutoApplRowDescr;
+       stmt->ApplParamDescr = stmt->AutoApplParamDescr;
 
        /* add this stmt to the administrative linked stmt list */
        stmt->next = dbc->FirstStmt,
@@ -191,19 +191,20 @@ destroyODBCStmt(ODBCStmt *stmt)
 
        /* remove this stmt from the dbc */
        assert(stmt->Dbc);
-       assert(stmt->Dbc->FirstStmt);
 
        /* search for stmt in linked list */
        stmtp = &stmt->Dbc->FirstStmt;
 
        while (*stmtp && *stmtp != stmt)
                stmtp = &(*stmtp)->next;
-       /* stmtp points to location in list where stmt is found */
+       /* stmtp points to location in list where stmt is found, or
+        * *stmtp is NULL in case it wasn't there (presumably not added
+        * yet) */
 
-       assert(*stmtp == stmt); /* we must have found it */
-
-       /* now remove it from the linked list */
-       *stmtp = stmt->next;
+       if (*stmtp) {
+               /* now remove it from the linked list */
+               *stmtp = stmt->next;
+       }
 
        /* cleanup own managed data */
        deleteODBCErrorList(&stmt->Error);
diff --git a/clients/odbc/driver/SQLColumnPrivileges.c 
b/clients/odbc/driver/SQLColumnPrivileges.c
--- a/clients/odbc/driver/SQLColumnPrivileges.c
+++ b/clients/odbc/driver/SQLColumnPrivileges.c
@@ -72,14 +72,14 @@ MNDBColumnPrivileges(ODBCStmt *stmt,
                                goto nomem;
                }
                if (NameLength3 > 0) {
-                       tab = ODBCParseOA("t", "name",
+                       tab = ODBCParseOA("tc", "tname",
                                          (const char *) TableName,
                                          (size_t) NameLength3);
                        if (tab == NULL)
                                goto nomem;
                }
                if (NameLength4 > 0) {
-                       col = ODBCParsePV("c", "name",
+                       col = ODBCParsePV("tc", "cname",
                                          (const char *) ColumnName,
                                          (size_t) NameLength4);
                        if (col == NULL)
@@ -94,14 +94,14 @@ MNDBColumnPrivileges(ODBCStmt *stmt,
                                goto nomem;
                }
                if (NameLength3 > 0) {
-                       tab = ODBCParseID("t", "name",
+                       tab = ODBCParseID("tc", "tname",
                                          (const char *) TableName,
                                          (size_t) NameLength3);
                        if (tab == NULL)
                                goto nomem;
                }
                if (NameLength4 > 0) {
-                       col = ODBCParseID("c", "name",
+                       col = ODBCParseID("tc", "cname",
                                          (const char *) ColumnName,
                                          (size_t) NameLength4);
                        if (col == NULL)
@@ -110,7 +110,7 @@ MNDBColumnPrivileges(ODBCStmt *stmt,
        }
 
        /* construct the query now */
-       querylen = 1200 + strlen(stmt->Dbc->dbname) + (sch ? strlen(sch) : 0) +
+       querylen = 1300 + strlen(stmt->Dbc->dbname) + (sch ? strlen(sch) : 0) +
                (tab ? strlen(tab) : 0) + (col ? strlen(col) : 0);
        query = malloc(querylen);
        if (query == NULL)
@@ -130,8 +130,8 @@ MNDBColumnPrivileges(ODBCStmt *stmt,
        pos += snprintf(query + pos, querylen - pos,
                "select '%s' as \"TABLE_CAT\", "
                       "s.name as \"TABLE_SCHEM\", "
-                      "t.name as \"TABLE_NAME\", "
-                      "c.name as \"COLUMN_NAME\", "
+                      "tc.tname as \"TABLE_NAME\", "
+                      "tc.cname as \"COLUMN_NAME\", "
                       "case a.id "
                            "when s.owner "
                            "then '_SYSTEM' "
@@ -147,17 +147,23 @@ MNDBColumnPrivileges(ODBCStmt *stmt,
                            "when 0 then 'NO' "
                            "end as \"IS_GRANTABLE\" "
                "from sys.schemas as s, "
-                    "sys._tables as t, "
-                    "sys._columns as c, "
+                    /* next union all subquery is much more efficient than 
using sys.tables join sys.columns */
+                    "(select t1.id as tid, t1.name as tname, t1.schema_id, 
c1.id as cid, c1.name as cname"
+                    " from sys._tables as t1"
+                    " join sys._columns as c1 on t1.id = c1.table_id"
+                    " where not t1.system"     /* exclude system tables and 
views */
+                    " union all"
+                    " select t2.id as tid, t2.name as tname, t2.schema_id, 
c2.id as cid, c2.name as cname"
+                    " from tmp._tables as t2"
+                    " join tmp._columns as c2 on t2.id = c2.table_id)"
+                    " as tc(tid, tname, schema_id, cid, cname), "
                     "sys.auths as a, "
                     "sys.privileges as p, "
                     "sys.auths as g, "
                     "%s "
-               "where p.obj_id = c.id and "
-                     "c.table_id = t.id and "
+               "where p.obj_id = tc.cid and "
                      "p.auth_id = a.id and "
-                     "t.schema_id = s.id and "
-                     "not t.system and "
+                     "tc.schema_id = s.id and "
                      "p.grantor = g.id and "
                      "p.privileges = pc.privilege_code_id",
                stmt->Dbc->dbname,
@@ -170,7 +176,7 @@ MNDBColumnPrivileges(ODBCStmt *stmt,
                             "(8, 'DELETE'), "
                             "(16, 'EXECUTE'), "
                             "(32, 'GRANT')) as pc(privilege_code_id, 
privilege_code_name)");
-       assert(pos < querylen);
+       assert(pos < 1200);
 
        /* Construct the selection condition query part */
        if (NameLength1 > 0 && CatalogName != NULL) {
@@ -198,7 +204,9 @@ MNDBColumnPrivileges(ODBCStmt *stmt,
 
        /* add the ordering (exclude table_cat as it is the same for all rows) 
*/
        pos += strcpy_len(query + pos, " order by \"TABLE_SCHEM\", 
\"TABLE_NAME\", \"COLUMN_NAME\", \"PRIVILEGE\"", querylen - pos);
-       assert(pos <= querylen);
+       assert(pos < querylen);
+
+       /* debug: fprintf(stdout, "SQLColumnPrivileges query (pos: %zu, len: 
%zu):\n%s\n\n", pos, strlen(query), query); */
 
        /* query the MonetDB data dictionary tables */
        rc = MNDBExecDirect(stmt, (SQLCHAR *) query, (SQLINTEGER) pos);
diff --git a/clients/odbc/driver/SQLColumns.c b/clients/odbc/driver/SQLColumns.c
--- a/clients/odbc/driver/SQLColumns.c
+++ b/clients/odbc/driver/SQLColumns.c
@@ -244,6 +244,9 @@ MNDBColumns(ODBCStmt *stmt,
 
        /* add the ordering (exclude table_cat as it is the same for all rows) 
*/
        pos += strcpy_len(query + pos, " order by \"TABLE_SCHEM\", 
\"TABLE_NAME\", \"ORDINAL_POSITION\"", querylen - pos);
+       assert(pos < querylen);
+
+       /* debug: fprintf(stdout, "SQLColumns query (pos: %zu, len: 
%zu):\n%s\n\n", pos, strlen(query), query); */
 
        /* query the MonetDB data dictionary tables */
        rc = MNDBExecDirect(stmt, (SQLCHAR *) query, (SQLINTEGER) pos);
diff --git a/clients/odbc/driver/SQLForeignKeys.c 
b/clients/odbc/driver/SQLForeignKeys.c
--- a/clients/odbc/driver/SQLForeignKeys.c
+++ b/clients/odbc/driver/SQLForeignKeys.c
@@ -252,8 +252,9 @@ MNDBForeignKeys(ODBCStmt *stmt,
                        PKTableName != NULL ? "FK" : "PK",
                        PKTableName != NULL ? "FK" : "PK",
                        PKTableName != NULL ? "FK" : "PK");
+       assert(pos < querylen);
 
-       /* debug: fprintf(stdout, "SQLForeignKeys SQL (%zu):\n%s\n\n", pos, 
query); */
+       /* debug: fprintf(stdout, "SQLForeignKeys query (pos: %zu, len: 
%zu):\n%s\n\n", pos, strlen(query), query); */
 
        /* query the MonetDB data dictionary tables */
        rc = MNDBExecDirect(stmt, (SQLCHAR *) query, (SQLINTEGER) pos);
diff --git a/clients/odbc/driver/SQLPrimaryKeys.c 
b/clients/odbc/driver/SQLPrimaryKeys.c
--- a/clients/odbc/driver/SQLPrimaryKeys.c
+++ b/clients/odbc/driver/SQLPrimaryKeys.c
@@ -206,8 +206,9 @@ MNDBPrimaryKeys(ODBCStmt *stmt,
 
        /* add the ordering */
        pos += strcpy_len(query + pos, " order by \"TABLE_SCHEM\", 
\"TABLE_NAME\", \"KEY_SEQ\"", querylen - pos);
+       assert(pos < querylen);
 
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to