Mercurial > hg > monetdb-java
comparison src/main/java/org/monetdb/util/MDBvalidator.java @ 934:80ade6a717c2
Add double quotes around column names which will become reserved keywords: schema, table, column.
These are used in system tables/views/functions: schemastorage, statistics, storage(), storage, storagemodel, storagemodelinput, tablestorage, tablestoragemodel.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 12 Dec 2024 15:11:27 +0100 (4 months ago) |
parents | f16966084980 |
children | 540d8b5944b1 |
comparison
equal
deleted
inserted
replaced
933:1295183c400c | 934:80ade6a717c2 |
---|---|
546 } | 546 } |
547 isNullCond.append(colx).append(" IS NULL"); | 547 isNullCond.append(colx).append(" IS NULL"); |
548 | 548 |
549 /* for some sys/tmp columns also check for empty strings */ | 549 /* for some sys/tmp columns also check for empty strings */ |
550 if (colx.endsWith("name") || colx.endsWith("keyword") | 550 if (colx.endsWith("name") || colx.endsWith("keyword") |
551 || "schema".equals(colx) || "table".equals(colx) || "column".equals(colx) || "func".equals(colx) || "mod".equals(colx) || "statement".equals(colx) | 551 || "\"schema\"".equals(colx) || "\"table\"".equals(colx) || "\"column\"".equals(colx) |
552 || "func".equals(colx) || "mod".equals(colx) || "statement".equals(colx) | |
552 || ("type".equals(colx) && ("_columns".equals(tbl) || "args".equals(tbl) || "storage()".equals(tbl) || "storagemodelinput".equals(tbl)))) { | 553 || ("type".equals(colx) && ("_columns".equals(tbl) || "args".equals(tbl) || "storage()".equals(tbl) || "storagemodelinput".equals(tbl)))) { |
553 isNullCond.append(" OR ").append(colx).append(" = ''"); | 554 isNullCond.append(" OR ").append(colx).append(" = ''"); |
554 } | 555 } |
555 } | 556 } |
556 } else { | 557 } else { |
557 isNullCond.append(col).append(" IS NULL"); | 558 isNullCond.append(col).append(" IS NULL"); |
558 | 559 |
559 /* for some sys/tmp columns also check for empty strings */ | 560 /* for some sys/tmp columns also check for empty strings */ |
560 if (col.endsWith("name") || col.endsWith("keyword") | 561 if (col.endsWith("name") || col.endsWith("keyword") |
561 || "schema".equals(col) || "table".equals(col) || "column".equals(col) || "func".equals(col) || "mod".equals(col) || "statement".equals(col) | 562 || "\"schema\"".equals(col) || "\"table\"".equals(col) || "\"column\"".equals(col) |
563 || "func".equals(col) || "mod".equals(col) || "statement".equals(col) | |
562 || ("type".equals(col) && ("_columns".equals(tbl) || "args".equals(tbl) || "storage()".equals(tbl) || "storagemodelinput".equals(tbl)))) { | 564 || ("type".equals(col) && ("_columns".equals(tbl) || "args".equals(tbl) || "storage()".equals(tbl) || "storagemodelinput".equals(tbl)))) { |
563 isNullCond.append(" OR ").append(col).append(" = ''"); | 565 isNullCond.append(" OR ").append(col).append(" = ''"); |
564 } | 566 } |
565 } | 567 } |
566 // reuse the StringBuilder by cleaning it partial | 568 // reuse the StringBuilder by cleaning it partial |
985 {"optimizers", "name", null}, | 987 {"optimizers", "name", null}, |
986 {"environment", "name", null}, // is a view on sys.env() | 988 {"environment", "name", null}, // is a view on sys.env() |
987 {"db_user_info", "name", null}, | 989 {"db_user_info", "name", null}, |
988 {"statistics", "column_id", null}, | 990 {"statistics", "column_id", null}, |
989 // old {"tracelog", "event", null}, -- Error: Profiler not started. This table now (from Jun2020) contains only: ticks, stmt | 991 // old {"tracelog", "event", null}, -- Error: Profiler not started. This table now (from Jun2020) contains only: ticks, stmt |
990 {"\"storage\"()", "schema, table, column", null}, // the function "storage"() also lists the storage for system tables | 992 {"\"storage\"()", "\"schema\", \"table\", \"column\"", null}, // the function "storage"() also lists the storage for system tables |
991 // {"storage", "schema, table, column", null}, // is a view on table producing function: sys.storage() which filters out all system tables. | 993 // {"\"storage\"", "\"schema\", \"table\", \"column\"", null}, // is a view on table producing function: sys.storage() which filters out all system tables. |
992 {"storagemodelinput", "schema, table, column", null}, | 994 {"storagemodelinput", "\"schema\", \"table\", \"column\"", null}, |
993 // {"storagemodel", "schema, table, column", null}, // is a view on storagemodelinput | 995 // {"storagemodel", "\"schema\", \"table\", \"column\"", null}, // is a view on storagemodelinput |
994 // {"tablestoragemodel", "schema, table", null}, // is a view on storagemodelinput | 996 // {"tablestoragemodel", "\"schema\", \"table\"", null}, // is a view on storagemodelinput |
995 | 997 |
996 {"rejects", "rowid", "19"}, // querying this view caused problems in versions pre Jul2015, see https://github.com/MonetDB/MonetDB/issues/3794 | 998 {"rejects", "rowid", "19"}, // querying this view caused problems in versions pre Jul2015, see https://github.com/MonetDB/MonetDB/issues/3794 |
997 | 999 |
998 // new tables introduced in Jul2015 release (11.21.5) | 1000 // new tables introduced in Jul2015 release (11.21.5) |
999 {"keywords", "keyword", "21"}, | 1001 {"keywords", "keyword", "21"}, |
1010 {"comments", "id", "29"}, | 1012 {"comments", "id", "29"}, |
1011 {"ids", "id", "29"}, // is a view | 1013 {"ids", "id", "29"}, // is a view |
1012 {"var_values", "var_name", "29"}, // is a view | 1014 {"var_values", "var_name", "29"}, // is a view |
1013 | 1015 |
1014 // new views introduced in Apr2019 feature release (11.33.3) | 1016 // new views introduced in Apr2019 feature release (11.33.3) |
1015 // {"tablestorage", "schema, table", "33"}, // is a view on view storage, see check on "storage"() above | 1017 // {"tablestorage", "\"schema\", \"table\"", "33"}, // is a view on view storage, see check on "storage"() above |
1016 // {"schemastorage", "schema", "33"}, // is a view on view storage, see check on "storage"() above | 1018 // {"schemastorage", "\"schema\"", "33"}, // is a view on view storage, see check on "storage"() above |
1017 // new tables introduced in Apr2019 feature release (11.33.3) | 1019 // new tables introduced in Apr2019 feature release (11.33.3) |
1018 {"table_partitions", "id", "33"}, | 1020 {"table_partitions", "id", "33"}, |
1019 {"range_partitions", "table_id, partition_id, minimum", "33"}, | 1021 {"range_partitions", "table_id, partition_id, minimum", "33"}, |
1020 {"value_partitions", "table_id, partition_id, \"value\"", "33"}, | 1022 {"value_partitions", "table_id, partition_id, \"value\"", "33"}, |
1021 | 1023 |
1181 // not a fk: {"queue", "\"username\"", "name", "users", null}, // as queue contains a historical list, the user may have been removed in the meantime, so not a real persistent fk | 1183 // not a fk: {"queue", "\"username\"", "name", "users", null}, // as queue contains a historical list, the user may have been removed in the meantime, so not a real persistent fk |
1182 {"sessions", "\"username\"", "name", "users", "37"}, | 1184 {"sessions", "\"username\"", "name", "users", "37"}, |
1183 {"sessions", "sessions.optimizer", "name", "optimizers", "37"}, // without the sessions. prefix it will give an error on Jun2020 release | 1185 {"sessions", "sessions.optimizer", "name", "optimizers", "37"}, // without the sessions. prefix it will give an error on Jun2020 release |
1184 {"statistics", "column_id", "id", "(SELECT id FROM sys._columns UNION ALL SELECT id FROM tmp._columns) as c", null}, | 1186 {"statistics", "column_id", "id", "(SELECT id FROM sys._columns UNION ALL SELECT id FROM tmp._columns) as c", null}, |
1185 {"statistics", "type", "sqlname", "types", null}, | 1187 {"statistics", "type", "sqlname", "types", null}, |
1186 {"storage()", "schema", "name", "schemas", null}, | 1188 {"storage()", "\"schema\"", "name", "schemas", null}, |
1187 {"storage()", "table", "name", "(SELECT name FROM sys._tables UNION ALL SELECT name FROM tmp._tables) as t", null}, | 1189 {"storage()", "\"table\"", "name", "(SELECT name FROM sys._tables UNION ALL SELECT name FROM tmp._tables) as t", null}, |
1188 {"storage()", "schema, table", "sname, tname", "(SELECT sch.name as sname, tbl.name as tname FROM sys.schemas AS sch JOIN sys.tables AS tbl ON sch.id = tbl.schema_id) as t", null}, | 1190 {"storage()", "\"schema\", \"table\"", "sname, tname", "(SELECT sch.name as sname, tbl.name as tname FROM sys.schemas AS sch JOIN sys.tables AS tbl ON sch.id = tbl.schema_id) as t", null}, |
1189 {"storage()", "column", "name", "(SELECT name FROM sys._columns UNION ALL SELECT name FROM tmp._columns UNION ALL SELECT name FROM sys.keys UNION ALL SELECT name FROM tmp.keys UNION ALL SELECT name FROM sys.idxs UNION ALL SELECT name FROM tmp.idxs) as c", null}, | 1191 {"storage()", "\"column\"", "name", "(SELECT name FROM sys._columns UNION ALL SELECT name FROM tmp._columns UNION ALL SELECT name FROM sys.keys UNION ALL SELECT name FROM tmp.keys UNION ALL SELECT name FROM sys.idxs UNION ALL SELECT name FROM tmp.idxs) as c", null}, |
1190 {"storage()", "type", "sqlname", "types", null}, | 1192 {"storage()", "type", "sqlname", "types", null}, |
1191 {"storage", "schema", "name", "schemas", null}, | 1193 {"storage", "\"schema\"", "name", "schemas", null}, |
1192 {"storage", "table", "name", "(SELECT name FROM sys._tables UNION ALL SELECT name FROM tmp._tables) as t", null}, | 1194 {"storage", "\"table\"", "name", "(SELECT name FROM sys._tables UNION ALL SELECT name FROM tmp._tables) as t", null}, |
1193 {"storage", "schema, table", "sname, tname", "(SELECT sch.name as sname, tbl.name as tname FROM sys.schemas AS sch JOIN sys.tables AS tbl ON sch.id = tbl.schema_id) as t", null}, | 1195 {"storage", "\"schema\", \"table\"", "sname, tname", "(SELECT sch.name as sname, tbl.name as tname FROM sys.schemas AS sch JOIN sys.tables AS tbl ON sch.id = tbl.schema_id) as t", null}, |
1194 {"storage", "column", "name", "(SELECT name FROM sys._columns UNION ALL SELECT name FROM tmp._columns UNION ALL SELECT name FROM sys.keys UNION ALL SELECT name FROM tmp.keys UNION ALL SELECT name FROM sys.idxs UNION ALL SELECT name FROM tmp.idxs) as c", null}, | 1196 {"storage", "\"column\"", "name", "(SELECT name FROM sys._columns UNION ALL SELECT name FROM tmp._columns UNION ALL SELECT name FROM sys.keys UNION ALL SELECT name FROM tmp.keys UNION ALL SELECT name FROM sys.idxs UNION ALL SELECT name FROM tmp.idxs) as c", null}, |
1195 {"storage", "type", "sqlname", "types", null}, | 1197 {"storage", "type", "sqlname", "types", null}, |
1196 {"storagemodel", "schema", "name", "schemas", null}, | 1198 {"storagemodel", "\"schema\"", "name", "schemas", null}, |
1197 {"storagemodel", "table", "name", "(SELECT name FROM sys._tables UNION ALL SELECT name FROM tmp._tables) as t", null}, | 1199 {"storagemodel", "\"table\"", "name", "(SELECT name FROM sys._tables UNION ALL SELECT name FROM tmp._tables) as t", null}, |
1198 {"storagemodel", "schema, table", "sname, tname", "(SELECT sch.name as sname, tbl.name as tname FROM sys.schemas AS sch JOIN sys.tables AS tbl ON sch.id = tbl.schema_id) as t", null}, | 1200 {"storagemodel", "\"schema\", \"table\"", "sname, tname", "(SELECT sch.name as sname, tbl.name as tname FROM sys.schemas AS sch JOIN sys.tables AS tbl ON sch.id = tbl.schema_id) as t", null}, |
1199 {"storagemodel", "column", "name", "(SELECT name FROM sys._columns UNION ALL SELECT name FROM tmp._columns UNION ALL SELECT name FROM sys.keys UNION ALL SELECT name FROM tmp.keys UNION ALL SELECT name FROM sys.idxs UNION ALL SELECT name FROM tmp.idxs) as c", null}, | 1201 {"storagemodel", "\"column\"", "name", "(SELECT name FROM sys._columns UNION ALL SELECT name FROM tmp._columns UNION ALL SELECT name FROM sys.keys UNION ALL SELECT name FROM tmp.keys UNION ALL SELECT name FROM sys.idxs UNION ALL SELECT name FROM tmp.idxs) as c", null}, |
1200 {"storagemodel", "type", "sqlname", "types", null}, | 1202 {"storagemodel", "type", "sqlname", "types", null}, |
1201 {"storagemodelinput", "schema", "name", "schemas", null}, | 1203 {"storagemodelinput", "\"schema\"", "name", "schemas", null}, |
1202 {"storagemodelinput", "table", "name", "(SELECT name FROM sys._tables UNION ALL SELECT name FROM tmp._tables) as t", null}, | 1204 {"storagemodelinput", "\"table\"", "name", "(SELECT name FROM sys._tables UNION ALL SELECT name FROM tmp._tables) as t", null}, |
1203 {"storagemodelinput", "schema, table", "sname, tname", "(SELECT sch.name as sname, tbl.name as tname FROM sys.schemas AS sch JOIN sys.tables AS tbl ON sch.id = tbl.schema_id) as t", null}, | 1205 {"storagemodelinput", "\"schema\", \"table\"", "sname, tname", "(SELECT sch.name as sname, tbl.name as tname FROM sys.schemas AS sch JOIN sys.tables AS tbl ON sch.id = tbl.schema_id) as t", null}, |
1204 {"storagemodelinput", "column", "name", "(SELECT name FROM sys._columns UNION ALL SELECT name FROM tmp._columns UNION ALL SELECT name FROM sys.keys UNION ALL SELECT name FROM tmp.keys UNION ALL SELECT name FROM sys.idxs UNION ALL SELECT name FROM tmp.idxs) as c", null}, | 1206 {"storagemodelinput", "\"column\"", "name", "(SELECT name FROM sys._columns UNION ALL SELECT name FROM tmp._columns UNION ALL SELECT name FROM sys.keys UNION ALL SELECT name FROM tmp.keys UNION ALL SELECT name FROM sys.idxs UNION ALL SELECT name FROM tmp.idxs) as c", null}, |
1205 {"storagemodelinput", "type", "sqlname", "types", null}, | 1207 {"storagemodelinput", "type", "sqlname", "types", null}, |
1206 {"tablestoragemodel", "schema", "name", "schemas", null}, | 1208 {"tablestoragemodel", "\"schema\"", "name", "schemas", null}, |
1207 {"tablestoragemodel", "table", "name", "(SELECT name FROM sys._tables UNION ALL SELECT name FROM tmp._tables) as t", null}, | 1209 {"tablestoragemodel", "\"table\"", "name", "(SELECT name FROM sys._tables UNION ALL SELECT name FROM tmp._tables) as t", null}, |
1208 {"tablestoragemodel", "schema, table", "sname, tname", "(SELECT sch.name as sname, tbl.name as tname FROM sys.schemas AS sch JOIN sys.tables AS tbl ON sch.id = tbl.schema_id) as t", null}, | 1210 {"tablestoragemodel", "\"schema\", \"table\"", "sname, tname", "(SELECT sch.name as sname, tbl.name as tname FROM sys.schemas AS sch JOIN sys.tables AS tbl ON sch.id = tbl.schema_id) as t", null}, |
1209 // new tables / views introduced in Apr2019 "33" | 1211 // new tables / views introduced in Apr2019 "33" |
1210 {"schemastorage", "schema", "name", "schemas", "33"}, | 1212 {"schemastorage", "\"schema\"", "name", "schemas", "33"}, |
1211 {"tablestorage", "schema", "name", "schemas", "33"}, | 1213 {"tablestorage", "\"schema\"", "name", "schemas", "33"}, |
1212 {"tablestorage", "table", "name", "(SELECT name FROM sys._tables UNION ALL SELECT name FROM tmp._tables) as t", "33"}, | 1214 {"tablestorage", "\"table\"", "name", "(SELECT name FROM sys._tables UNION ALL SELECT name FROM tmp._tables) as t", "33"}, |
1213 {"tablestorage", "schema, table", "sname, tname", "(SELECT sch.name as sname, tbl.name as tname FROM sys.schemas AS sch JOIN sys.tables AS tbl ON sch.id = tbl.schema_id) as t", "33"}, | 1215 {"tablestorage", "\"schema\", \"table\"", "sname, tname", "(SELECT sch.name as sname, tbl.name as tname FROM sys.schemas AS sch JOIN sys.tables AS tbl ON sch.id = tbl.schema_id) as t", "33"}, |
1214 {"table_partitions", "table_id", "id", "_tables", "33"}, | 1216 {"table_partitions", "table_id", "id", "_tables", "33"}, |
1215 {"table_partitions WHERE column_id IS NOT NULL AND ", "column_id", "id", "_columns", "33"}, | 1217 {"table_partitions WHERE column_id IS NOT NULL AND ", "column_id", "id", "_columns", "33"}, |
1216 {"range_partitions", "table_id", "id", "_tables", "33"}, | 1218 {"range_partitions", "table_id", "id", "_tables", "33"}, |
1217 {"range_partitions", "partition_id", "id", "table_partitions", "33"}, | 1219 {"range_partitions", "partition_id", "id", "table_partitions", "33"}, |
1218 {"value_partitions", "table_id", "id", "_tables", "33"}, | 1220 {"value_partitions", "table_id", "id", "_tables", "33"}, |
1355 {"sequences", "cycle", null}, | 1357 {"sequences", "cycle", null}, |
1356 {"statistics", "column_id", null}, | 1358 {"statistics", "column_id", null}, |
1357 {"statistics", "\"schema\"", "43"}, // new column as of Jan2022 release (11.43.1) | 1359 {"statistics", "\"schema\"", "43"}, // new column as of Jan2022 release (11.43.1) |
1358 {"statistics", "\"table\"", "43"}, // new column as of Jan2022 release (11.43.1) | 1360 {"statistics", "\"table\"", "43"}, // new column as of Jan2022 release (11.43.1) |
1359 {"statistics", "\"column\"", "43"}, // new column as of Jan2022 release (11.43.1) | 1361 {"statistics", "\"column\"", "43"}, // new column as of Jan2022 release (11.43.1) |
1360 {"statistics", "\"type\"", null}, | 1362 {"statistics", "type", null}, |
1361 {"statistics", "\"width\"", null}, | 1363 {"statistics", "\"width\"", null}, |
1362 {"statistics", "\"count\"", null}, | 1364 {"statistics", "\"count\"", null}, |
1363 {"statistics", "\"unique\"", null}, | 1365 {"statistics", "\"unique\"", null}, |
1364 {"statistics", "nils", null}, | 1366 {"statistics", "nils", null}, |
1365 {"statistics", "sorted", null}, | 1367 {"statistics", "sorted", null}, |
1366 {"statistics", "revsorted", null}, | 1368 {"statistics", "revsorted", null}, |
1367 // the table producing function "storage"() also lists the storage for system tables, whereas the view "storage" does not, so use "storage"() | 1369 // the table producing function "storage"() also lists the storage for system tables, whereas the view "storage" does not, so use "storage"() |
1368 {"\"storage\"()", "schema", null}, | 1370 {"\"storage\"()", "\"schema\"", null}, |
1369 {"\"storage\"()", "table", null}, | 1371 {"\"storage\"()", "\"table\"", null}, |
1370 {"\"storage\"()", "column", null}, | 1372 {"\"storage\"()", "\"column\"", null}, |
1371 {"\"storage\"()", "type", null}, | 1373 {"\"storage\"()", "type", null}, |
1372 {"\"storage\"()", "mode", null}, | 1374 {"\"storage\"()", "mode", null}, |
1373 {"\"storage\"()", "location", null}, | 1375 {"\"storage\"()", "location", null}, |
1374 {"\"storage\"()", "count", null}, | 1376 {"\"storage\"()", "count", null}, |
1375 {"\"storage\"()", "typewidth", null}, | 1377 {"\"storage\"()", "typewidth", null}, |
1377 {"\"storage\"()", "heapsize", null}, | 1379 {"\"storage\"()", "heapsize", null}, |
1378 {"\"storage\"()", "hashes", null}, | 1380 {"\"storage\"()", "hashes", null}, |
1379 {"\"storage\"()", "phash", null}, | 1381 {"\"storage\"()", "phash", null}, |
1380 {"\"storage\"()", "imprints", null}, | 1382 {"\"storage\"()", "imprints", null}, |
1381 {"\"storage\"()", "orderidx", null}, | 1383 {"\"storage\"()", "orderidx", null}, |
1382 {"storagemodelinput", "schema", null}, | 1384 {"storagemodelinput", "\"schema\"", null}, |
1383 {"storagemodelinput", "table", null}, | 1385 {"storagemodelinput", "\"table\"", null}, |
1384 {"storagemodelinput", "column", null}, | 1386 {"storagemodelinput", "\"column\"", null}, |
1385 {"storagemodelinput", "type", null}, | 1387 {"storagemodelinput", "type", null}, |
1386 {"storagemodelinput", "typewidth", null}, | 1388 {"storagemodelinput", "typewidth", null}, |
1387 {"storagemodelinput", "count", null}, | 1389 {"storagemodelinput", "count", null}, |
1388 {"storagemodelinput", "\"distinct\"", null}, | 1390 {"storagemodelinput", "\"distinct\"", null}, |
1389 {"storagemodelinput", "atomwidth", null}, | 1391 {"storagemodelinput", "atomwidth", null}, |