Changeset: 433cb0132bb1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/433cb0132bb1
Modified Files:
        sql/backends/monet5/sql_upgrades.c
Branch: default
Log Message:

Merge with Mar2025 branch.


diffs (truncated from 317 to 300 lines):

diff --git a/clients/mapiclient/mhelp.c b/clients/mapiclient/mhelp.c
--- a/clients/mapiclient/mhelp.c
+++ b/clients/mapiclient/mhelp.c
@@ -103,9 +103,10 @@ SQLhelp sqlhelp1[] = {
         "See also 
https://www.monetdb.org/documentation/user-guide/sql-programming/flow-of-control/"},
        {"COMMENT",
         "Add, update or remove a comment or description for a database object",
-        "COMMENT ON { SCHEMA | TABLE | VIEW | COLUMN | INDEX | SEQUENCE | 
function_type }\n"
-        "     qname IS { 'my description text' | NULL | '' }",
-        "function_type,qname",
+        "COMMENT ON { SCHEMA | TABLE | VIEW | INDEX | SEQUENCE | function_type 
}\n"
+        "     qname IS { 'my description text' | NULL | '' }\n"
+        "COMMENT ON COLUMN q3name IS { 'my description text' | NULL | '' }",
+        "function_type,qname,q3name",
         NULL},
        {"COMMIT",
         "Commit the current transaction",
@@ -258,8 +259,10 @@ SQLhelp sqlhelp1[] = {
         "See also 
https://www.monetdb.org/documentation/user-guide/sql-manual/data-definition/privileges/"},
        {"CREATE VIEW",
         "Create a new view",
-        "CREATE [ OR REPLACE ] VIEW qname [ column_list ] AS { 
query_expression | '(' query_expression ')' }\n"
-        "[ WITH CHECK OPTION ]",
+        "CREATE [ OR REPLACE ] VIEW qname [ column_list ]\n"
+        "    AS { query_expression | '(' query_expression ')' } [ WITH CHECK 
OPTION ]\n"
+        "CREATE [ OR REPLACE ] [ LOCAL ] { TEMPORARY | TEMP } VIEW qname [ 
column_list ]\n"
+        "    AS { query_expression | '(' query_expression ')' }",
         "qname,column_list,query_expression",
         "See also 
https://www.monetdb.org/documentation/user-guide/sql-manual/data-definition/view-definition/"},
        {"CREATE WINDOW",
@@ -862,7 +865,12 @@ SQLhelp sqlhelp2[] = {
         NULL},
        {"qname",
         NULL,
-        "ident [ '.' ident ['.' ident]]",
+        "ident [ '.' ident ]",
+        NULL,
+        NULL},
+       {"q3name",
+        NULL,
+        "ident [ '.' ident ['.' ident] ]",
         NULL,
         NULL},
        {"ref_action",
diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -4758,35 +4758,27 @@ sql_update_mar2025(Client c, mvc *sql, s
 static str
 sql_update_mar2025_sp1(Client c, mvc *sql)
 {
-       size_t bufsize = 65536, pos = 0;
-       char *err = NULL, *buf = GDKmalloc(bufsize);
+       char *err = NULL;
        res_table *output = NULL;
        BAT *b;
 
-       if (buf == NULL)
-               throw(SQL, __func__, SQLSTATE(HY013) MAL_MALLOC_FAIL);
-
        /* 10_sys_schema_extension.sql */
        /* if the table type LOCAL TEMPORARY VIEW is
         * not in the list of table_types, upgrade */
-       pos = snprintf(buf, bufsize, "select table_type_name from 
sys.table_types where table_type_name = 'LOCAL TEMPORARY VIEW';\n");
-       (void)pos;
-       assert(pos < bufsize);
-       err = SQLstatementIntern(c, buf, "update", true, false, &output);
+       const char query1[] = "select table_type_name from sys.table_types 
where table_type_name = 'LOCAL TEMPORARY VIEW';";
+       err = SQLstatementIntern(c, query1, "update", true, false, &output);
        if (err == MAL_SUCCEED && (b = BBPquickdesc(output->cols[0].b)) && 
BATcount(b) == 0) {
-               pos = snprintf(buf, bufsize,
-                               "ALTER TABLE sys.table_types SET READ WRITE;\n"
-                               "INSERT INTO sys.table_types VALUES (31, 'LOCAL 
TEMPORARY VIEW');\n");
-               assert(pos < bufsize);
-               printf("Running database upgrade commands:\n%s\n", buf);
+               const char stmt2[] =
+                       "ALTER TABLE sys.table_types SET READ WRITE;\n"
+                       "INSERT INTO sys.table_types VALUES (31, 'LOCAL 
TEMPORARY VIEW');\n";
+               printf("Running database upgrade commands:\n%s\n", stmt2);
                fflush(stdout);
-               err = SQLstatementIntern(c, buf, "update", true, false, NULL);
+               err = SQLstatementIntern(c, stmt2, "update", true, false, NULL);
                if (err == MAL_SUCCEED) {
-                       pos = snprintf(buf, bufsize, "ALTER TABLE 
sys.table_types SET READ ONLY;\n");
-                       assert(pos < bufsize);
-                       printf("Running database upgrade commands:\n%s\n", buf);
+                       const char stmt3[] = "ALTER TABLE sys.table_types SET 
READ ONLY;\n";
+                       printf("Running database upgrade commands:\n%s\n", 
stmt3);
                        fflush(stdout);
-                       err = SQLstatementIntern(c, buf, "update", true, false, 
NULL);
+                       err = SQLstatementIntern(c, stmt3, "update", true, 
false, NULL);
                }
 
                /* 91_information_schema.sql */
@@ -4873,7 +4865,6 @@ sql_update_mar2025_sp1(Client c, mvc *sq
        return err;
 }
 
-
 int
 SQLupgrades(Client c, mvc *m)
 {
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -533,6 +533,8 @@ int yydebug=1;
        grantor
        intval
        join_type
+       local_global_temp
+       local_temp
        non_second_datetime_field
        nonzero
        asymmetric
@@ -550,7 +552,6 @@ int yydebug=1;
        opt_recursive
        opt_ref_action
        opt_sign
-       opt_temp
        opt_XML_content_option
        opt_XML_returning_clause
        XML_returning_clause
@@ -1777,7 +1778,7 @@ table_def:
          append_int(l, $2);
          append_symbol(l, NULL); /* only used for merge table */
          $$ = _symbol_create_list( SQL_CREATE_TABLE, l ); }
-  | opt_temp table_if_not_exists qname table_content_source opt_on_commit
+  | local_global_temp table_if_not_exists qname table_content_source 
opt_on_commit
        { int commit_action = CA_COMMIT;
          dlist *l = L();
          append_int(l, $1);
@@ -1791,13 +1792,13 @@ table_def:
          append_int(l, $2);
          append_symbol(l, NULL); /* only used for merge table */
          $$ = _symbol_create_list( SQL_CREATE_TABLE, l ); }
-  | opt_temp VIEW qname opt_column_list AS SelectStmt opt_with_check_option
+  | local_temp VIEW qname opt_column_list AS SelectStmt
        {  dlist *l = L();
          append_int(l, $1);
          append_list(l, $3);
          append_list(l, $4);
          append_symbol(l, $6);
-         append_int(l, $7);
+         append_int(l, FALSE);
          append_int(l, TRUE);
          append_int(l, FALSE);
          $$ = _symbol_create_list( SQL_CREATE_VIEW, l );
@@ -1909,11 +1910,15 @@ with_opt_credentials:
   }
   ;
 
-opt_temp:
+local_temp:
     TEMPORARY          { $$ = SQL_LOCAL_TEMP; }
  |  TEMP               { $$ = SQL_LOCAL_TEMP; }
  |  LOCAL TEMPORARY    { $$ = SQL_LOCAL_TEMP; }
  |  LOCAL TEMP         { $$ = SQL_LOCAL_TEMP; }
+ ;
+
+local_global_temp:
+    local_temp         { $$ = SQL_LOCAL_TEMP; }
  |  GLOBAL TEMPORARY   { $$ = SQL_GLOBAL_TEMP; }
  |  GLOBAL TEMP                { $$ = SQL_GLOBAL_TEMP; }
  ;
@@ -2289,13 +2294,13 @@ view_def:
          append_int(l, $1);
          $$ = _symbol_create_list( SQL_CREATE_VIEW, l );
        }
-  | CREATE OR REPLACE opt_temp VIEW qname opt_column_list AS SelectStmt 
opt_with_check_option
+  | CREATE OR REPLACE local_temp VIEW qname opt_column_list AS SelectStmt
        {  dlist *l = L();
          append_int(l, SQL_PERSIST);
          append_list(l, $6);
          append_list(l, $7);
          append_symbol(l, $9);
-         append_int(l, $10);
+         append_int(l, FALSE);
          append_int(l, TRUE);  /* persistent view */
          append_int(l, $4);
          $$ = _symbol_create_list( SQL_CREATE_VIEW, l );
diff --git 
a/sql/test/BugTracker-2025/Tests/7625_missing_temporary_view_types.test 
b/sql/test/BugTracker-2025/Tests/7625_missing_temporary_view_types.test
--- a/sql/test/BugTracker-2025/Tests/7625_missing_temporary_view_types.test
+++ b/sql/test/BugTracker-2025/Tests/7625_missing_temporary_view_types.test
@@ -28,7 +28,6 @@ LOCAL TEMPORARY TABLE
 31
 LOCAL TEMPORARY VIEW
 
---DROP VIEW v
 statement ok
 CREATE VIEW v AS select name, schema_id, query, type, system, commit_action, 
access, temporary from sys.tables where not system
 
@@ -44,7 +43,6 @@ 0
 0
 0
 
---DROP VIEW tv
 statement ok
 CREATE TEMPORARY VIEW tv AS select name, schema_id, query, type, system, 
commit_action, access, temporary from sys.tables where not system
 
@@ -68,58 +66,16 @@ 0
 0
 1
 
---DROP VIEW gtv
-statement ok
+statement error 42000!syntax error, unexpected VIEW, expecting TABLE in: 
"create global temporary view"
 CREATE GLOBAL TEMPORARY VIEW gtv AS select name, schema_id, query, type, 
system, commit_action, access, temporary from sys.tables where not system
 
-query TITIIIII nosort
-select * from gtv order by schema_id, name
-----
-gtv
-2000
-create global temporary view gtv as select name, schema_id, query, type, 
system, commit_action, access, temporary from sys.tables where not system@;
-1
-0
-0
-0
-0
-v
-2000
-create view v as select name, schema_id, query, type, system, commit_action, 
access, temporary from sys.tables where not system@;
-1
-0
-0
-0
-0
-tv
-2114
-create temporary view tv as select name, schema_id, query, type, system, 
commit_action, access, temporary from sys.tables where not system@;
-31
-0
-0
-0
-1
 
--- lists 3 rows, gtv has type = 1, temporary = 0 !! this is wrong !!
--- The type should have been 21 (so commit_action set to 1) and temporary set 
to 1
--- Currently a GLOBAL TEMPORARY VIEW  is not distinguisable from a normal user 
VIEW and thus treated as equal
-
-
---DROP VIEW ltv
 statement ok
 CREATE LOCAL TEMPORARY VIEW ltv AS select name, schema_id, query, type, 
system, commit_action, access, temporary from sys.tables where not system
 
 query TITIIIII nosort
 select * from ltv order by schema_id, name
 ----
-gtv
-2000
-create global temporary view gtv as select name, schema_id, query, type, 
system, commit_action, access, temporary from sys.tables where not system@;
-1
-0
-0
-0
-0
 v
 2000
 create view v as select name, schema_id, query, type, system, commit_action, 
access, temporary from sys.tables where not system@;
@@ -150,11 +106,6 @@ query TTTII nosort
 select table_schema, table_name, table_type, table_type_id, is_view from 
information_schema.tables where not is_system order by 1,2
 ----
 sys
-gtv
-VIEW
-1
-1
-sys
 v
 VIEW
 1
@@ -175,10 +126,6 @@ query TTTI nosort
 select table_schema, table_name, view_definition, table_type_id from 
information_schema.views where not is_system order by 1,2
 ----
 sys
-gtv
-create global temporary view gtv as select name, schema_id, query, type, 
system, commit_action, access, temporary from sys.tables where not system@;
-1
-sys
 v
 create view v as select name, schema_id, query, type, system, commit_action, 
access, temporary from sys.tables where not system@;
 1
@@ -192,21 +139,20 @@ create temporary view tv as select name,
 31
 
 
+statement error 3F000!CREATE VIEW: local temporary views should be stored in 
the 'tmp' schema
+CREATE LOCAL TEMPORARY VIEW sys.sysltv AS select name, schema_id, query, type, 
system, commit_action, access, temporary from sys.tables where not system
+
 statement ok
 CREATE OR REPLACE VIEW v AS select name, schema_id, query, type, system, 
commit_action, access, temporary from sys.tables where not system
--- Succeeds
 
 statement ok
 CREATE OR REPLACE TEMPORARY VIEW tv AS select name, schema_id, query, type, 
system, commit_action, access, temporary from sys.tables where not system
--- Error: syntax error, unexpected TEMPORARY in: "create or replace temporary"
 
-statement ok
+statement error 42000!syntax error, unexpected GLOBAL in: "create or replace 
global"
 CREATE OR REPLACE GLOBAL TEMPORARY VIEW gtv AS select name, schema_id, query, 
type, system, commit_action, access, temporary from sys.tables where not system
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to