Changeset: 19f0a1f83f67 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=19f0a1f83f67 Modified Files: sql/server/sql_parser.y sql/test/BugTracker-2015/Tests/reserved_keywords.Bug-3613.sql sql/test/BugTracker-2015/Tests/reserved_keywords.Bug-3613.stable.err sql/test/BugTracker-2015/Tests/reserved_keywords.Bug-3613.stable.out Branch: default Log Message:
Removed sloppy parsing for default and user as it changes the way the statement is processed. Added sloppy parsing for keywords: 'as', 'authorization', 'column', 'cycle', 'distinct', 'increment', 'maxvalue', 'minvalue', 'plan', 'sample' and 'table'. Also updated and extended tests for the occurences of these keywords as column name. Also included a query which synthesizes the test queries. Whenever the SQL data dictionary changes and new column are introduced which are reserved keywords, this query will detect it. This fix is related to bug 3613 diffs (truncated from 2317 to 300 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 @@ -4905,11 +4905,20 @@ non_reserved_word: | ZONE { $$ = sa_strdup(SA, "zone"); } /* sloppy: officially reserved */ | ACTION { $$ = sa_strdup(SA, "action"); } /* sloppy: officially reserved */ -| DEFAULT { $$ = sa_strdup(SA, "default"); } /* sloppy: officially reserved */ +| AS { $$ = sa_strdup(SA, "as"); } /* sloppy: officially reserved */ +| AUTHORIZATION { $$ = sa_strdup(SA, "authorization"); }/* sloppy: officially reserved */ +| COLUMN { $$ = sa_strdup(SA, "column"); } /* sloppy: officially reserved */ +| CYCLE { $$ = sa_strdup(SA, "cycle"); } /* sloppy: officially reserved */ +| DISTINCT { $$ = sa_strdup(SA, "distinct"); } /* sloppy: officially reserved */ +| INCREMENT { $$ = sa_strdup(SA, "increment"); } /* sloppy: officially reserved */ +| MAXVALUE { $$ = sa_strdup(SA, "maxvalue"); } /* sloppy: officially reserved */ +| MINVALUE { $$ = sa_strdup(SA, "minvalue"); } /* sloppy: officially reserved */ +| SQL_PLAN { $$ = sa_strdup(SA, "plan"); } /* sloppy: officially reserved */ +| SAMPLE { $$ = sa_strdup(SA, "sample"); } /* sloppy: officially reserved */ | SCHEMA { $$ = sa_strdup(SA, "schema"); } /* sloppy: officially reserved */ | START { $$ = sa_strdup(SA, "start"); } /* sloppy: officially reserved */ | STATEMENT { $$ = sa_strdup(SA, "statement"); } /* sloppy: officially reserved */ -| USER { $$ = sa_strdup(SA, "user"); } /* sloppy: officially reserved */ +| TABLE { $$ = sa_strdup(SA, "table"); } /* sloppy: officially reserved */ | CACHE { $$ = sa_strdup(SA, "cache"); } | DATA { $$ = sa_strdup(SA, "data"); } diff --git a/sql/test/BugTracker-2015/Tests/reserved_keywords.Bug-3613.sql b/sql/test/BugTracker-2015/Tests/reserved_keywords.Bug-3613.sql --- a/sql/test/BugTracker-2015/Tests/reserved_keywords.Bug-3613.sql +++ b/sql/test/BugTracker-2015/Tests/reserved_keywords.Bug-3613.sql @@ -1,44 +1,36 @@ -SELECT tbl.action FROM sys.keys tbl; -SELECT tbl.action FROM tmp.keys tbl; +-- next query synthesizes the queries for SQL systems table column names which are also reserved words except for +-- 'default', 'null', 'unique' and 'user' as those names need to be avoided as SQL systems table column names at all times. +SELECT 'SELECT DISTINCT '||C.name||' FROM '||S.name||'.'||T.name||' WHERE '||C.name||' IS NOT NULL ORDER BY '||C.name||';' as SQL_query + FROM sys.columns C join sys.tables T on C.table_id = T.id join sys.schemas S on T.schema_id = S.id + WHERE lower(C.name) in ('action', 'as', 'authorization', 'column', 'cycle', 'distinct', 'increment', 'maxvalue', 'minvalue', 'plan', 'sample', 'schema', 'start', 'statement', 'table') + ORDER BY C.name, S.name, T.name; -SELECT tbl.default FROM sys._columns tbl; -SELECT tbl.default FROM sys.columns tbl; -SELECT tbl.default FROM tmp._columns tbl; +SELECT DISTINCT action FROM sys.keys WHERE action IS NOT NULL ORDER BY action; +SELECT DISTINCT action FROM tmp.keys WHERE action IS NOT NULL ORDER BY action; +SELECT DISTINCT as FROM bam.sq WHERE as IS NOT NULL ORDER BY as; +SELECT DISTINCT authorization FROM sys.schemas WHERE authorization IS NOT NULL ORDER BY authorization; +SELECT DISTINCT column FROM sys.storage WHERE column IS NOT NULL ORDER BY column; +SELECT DISTINCT column FROM sys.storagemodel WHERE column IS NOT NULL ORDER BY column; +SELECT DISTINCT column FROM sys.storagemodelinput WHERE column IS NOT NULL ORDER BY column; +SELECT DISTINCT cycle FROM sys.sequences WHERE cycle IS NOT NULL ORDER BY cycle; +SELECT DISTINCT distinct FROM sys.storagemodelinput WHERE distinct IS NOT NULL ORDER BY distinct; +SELECT DISTINCT increment FROM sys.sequences WHERE increment IS NOT NULL ORDER BY increment; +SELECT DISTINCT maxvalue FROM sys.sequences WHERE maxvalue IS NOT NULL ORDER BY maxvalue; +SELECT DISTINCT minvalue FROM sys.sequences WHERE minvalue IS NOT NULL ORDER BY minvalue; +SELECT DISTINCT plan FROM sys.querylog_catalog WHERE plan IS NOT NULL ORDER BY plan; +SELECT DISTINCT plan FROM sys.querylog_history WHERE plan IS NOT NULL ORDER BY plan; +SELECT DISTINCT sample FROM sys.statistics WHERE sample IS NOT NULL ORDER BY sample; +SELECT DISTINCT schema FROM sys.storage WHERE schema IS NOT NULL ORDER BY schema; +SELECT DISTINCT schema FROM sys.storagemodel WHERE schema IS NOT NULL ORDER BY schema; +SELECT DISTINCT schema FROM sys.storagemodelinput WHERE schema IS NOT NULL ORDER BY schema; +SELECT DISTINCT schema FROM sys.tablestoragemodel WHERE schema IS NOT NULL ORDER BY schema; +SELECT DISTINCT start FROM sys.querylog_calls WHERE start IS NOT NULL ORDER BY start; +SELECT DISTINCT start FROM sys.querylog_history WHERE start IS NOT NULL ORDER BY start; +SELECT DISTINCT start FROM sys.sequences WHERE start IS NOT NULL ORDER BY start; +SELECT DISTINCT statement FROM sys.triggers WHERE statement IS NOT NULL ORDER BY statement; +SELECT DISTINCT statement FROM tmp.triggers WHERE statement IS NOT NULL ORDER BY statement; +SELECT DISTINCT table FROM sys.storage WHERE table IS NOT NULL ORDER BY table; +SELECT DISTINCT table FROM sys.storagemodel WHERE table IS NOT NULL ORDER BY table; +SELECT DISTINCT table FROM sys.storagemodelinput WHERE table IS NOT NULL ORDER BY table; +SELECT DISTINCT table FROM sys.tablestoragemodel WHERE table IS NOT NULL ORDER BY table; -SELECT tbl.schema FROM sys.statistics tbl; -SELECT tbl.schema FROM sys.storage tbl; -SELECT tbl.schema FROM sys.storagemodel tbl; -SELECT tbl.schema FROM sys.storagemodelinput tbl; -SELECT tbl.schema FROM sys.tablestoragemodel tbl; - -SELECT tbl.start FROM sys.querylog_calls tbl; -SELECT tbl.start FROM sys.querylog_history tbl; -SELECT tbl.start FROM sys.sequences tbl; - -SELECT tbl.statement FROM sys.triggers tbl; -SELECT tbl.statement FROM tmp.triggers tbl; - -SELECT tbl.user FROM sys.connections tbl; -SELECT tbl.user FROM sys.queue tbl; -SELECT tbl.user FROM sys.sessions tbl; -SELECT tbl.user FROM sys.tracelog tbl; - -SELECT action FROM sys.keys; -SELECT action FROM tmp.keys; - -SELECT default FROM sys._columns; -SELECT default FROM sys.columns; -SELECT default FROM tmp._columns; - -SELECT schema FROM sys.statistics; -SELECT schema FROM sys.storage; -SELECT schema FROM sys.storagemodel; -SELECT schema FROM sys.storagemodelinput; -SELECT schema FROM sys.tablestoragemodel; - -SELECT start FROM sys.querylog_calls; -SELECT start FROM sys.querylog_history; -SELECT start FROM sys.sequences; - -SELECT statement FROM sys.triggers; -SELECT statement FROM tmp.triggers; diff --git a/sql/test/BugTracker-2015/Tests/reserved_keywords.Bug-3613.stable.err b/sql/test/BugTracker-2015/Tests/reserved_keywords.Bug-3613.stable.err --- a/sql/test/BugTracker-2015/Tests/reserved_keywords.Bug-3613.stable.err +++ b/sql/test/BugTracker-2015/Tests/reserved_keywords.Bug-3613.stable.err @@ -32,21 +32,13 @@ stderr of test 'reserved_keywords.Bug-36 ## HASHnew(tpe=6,size=256,mask=1024): width = 2 ## ## HASHnew(tpe=6,size=256,mask=1024): width = 2 ## -# 18:58:09 > -# 18:58:09 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-21543" "--port=39106" -# 18:58:09 > +# 13:11:58 > +# 13:11:58 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-20832" "--port=35803" +# 13:11:58 > -MAPI = (monetdb) /var/tmp/mtest-16764/.s.monetdb.34170 -QUERY = SELECT tbl.schema FROM sys.statistics tbl; -MAPI = (monetdb) /var/tmp/mtest-16764/.s.monetdb.34170 -QUERY = SELECT tbl.user FROM sys.tracelog tbl; -MAPI = (monetdb) /var/tmp/mtest-16764/.s.monetdb.34170 -QUERY = SELECT schema FROM sys.statistics; +# 13:11:59 > +# 13:11:59 > "Done." +# 13:11:59 > - -# 18:58:09 > -# 18:58:09 > "Done." -# 18:58:09 > - diff --git a/sql/test/BugTracker-2015/Tests/reserved_keywords.Bug-3613.stable.out b/sql/test/BugTracker-2015/Tests/reserved_keywords.Bug-3613.stable.out --- a/sql/test/BugTracker-2015/Tests/reserved_keywords.Bug-3613.stable.out +++ b/sql/test/BugTracker-2015/Tests/reserved_keywords.Bug-3613.stable.out @@ -29,1891 +29,257 @@ Ready. # 18:58:09 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-21543" "--port=39106" # 18:58:09 > -#SELECT tbl.action FROM sys.keys tbl; -% sys.tbl # table_name -% action # name -% int # type -% 3 # length -[ -1 ] -[ -1 ] -[ 514 ] -[ -1 ] -[ 514 ] -[ -1 ] -[ 514 ] -#SELECT tbl.action FROM tmp.keys tbl; -% tmp.tbl # table_name -% action # name -% int # type -% 1 # length -#SELECT tbl.default FROM sys._columns tbl; -% sys.tbl # table_name -% default # name +#SELECT 'SELECT DISTINCT '||C.name||' FROM '||S.name||'.'||T.name||' WHERE '||C.name||' IS NOT NULL ORDER BY '||C.name||';' as SQL_query +# FROM sys.columns C join sys.tables T on C.table_id = T.id join sys.schemas S on T.schema_id = S.id +# WHERE lower(C.name) in ('action', 'as', 'authorization', 'column', 'cycle', 'distinct', 'increment', 'maxvalue', 'minvalue', 'plan', 'sample', 'schema', 'start', 'statement', 'table') +# ORDER BY C.name, S.name, T.name; +% .L # table_name +% sql_query # name % varchar # type -% 0 # length -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] -[ NULL ] _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list