Changeset: 19a77406afe7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/19a77406afe7
Modified Files:
sql/server/sql_parser.y
sql/test/BugTracker-2025/Tests/7625_missing_temporary_view_types.test
Branch: Mar2025
Log Message:
Adapt the parser to only allow creation of LOCAL TEMP VIEW, not GLOBAL TEMP
VIEW.
diffs (196 lines):
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,7 +1792,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 VIEW qname opt_column_list AS SelectStmt opt_with_check_option
+ | local_temp VIEW qname opt_column_list AS SelectStmt opt_with_check_option
{ dlist *l = L();
append_int(l, $1);
append_list(l, $3);
@@ -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,7 +2294,7 @@ 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
opt_with_check_option
{ dlist *l = L();
append_int(l, SQL_PERSIST);
append_list(l, $6);
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
@@ -194,19 +141,15 @@ 31
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
--- Error: syntax error, unexpected GLOBAL in: "create or replace global"
statement ok
CREATE OR REPLACE LOCAL TEMPORARY VIEW ltv AS select name, schema_id, query,
type, system, commit_action, access, temporary from sys.tables where not system
--- Error: syntax error, unexpected LOCAL in: "create or replace local"
-- cleanup
@@ -217,7 +160,7 @@ statement ok
DROP VIEW tmp.tv
statement ok
-DROP VIEW sys.gtv
+DROP VIEW IF EXISTS sys.gtv
statement ok
DROP VIEW tmp.ltv
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]