Changeset: f02c941f4e25 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f02c941f4e25 Added Files: sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.sql sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.stable.err sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.stable.out Modified Files: sql/test/BugTracker-2019/Tests/All Branch: Apr2019 Log Message:
Add test and desired output for bug 6701 diffs (truncated from 352 to 300 lines): diff --git a/sql/test/BugTracker-2019/Tests/All b/sql/test/BugTracker-2019/Tests/All --- a/sql/test/BugTracker-2019/Tests/All +++ b/sql/test/BugTracker-2019/Tests/All @@ -8,3 +8,4 @@ subselect-count.Bug-6686 subselect.Bug-6688 timestamptransformation.Bug-6695 duplicates-not-eliminated-long-CASE-stmt.Bug-6697 +alter_table_set_schema.Bug-6701 diff --git a/sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.sql b/sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.sql new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.sql @@ -0,0 +1,78 @@ +-- First check that no invalid FK references exist in the db. All next queries should return zero rows: +SELECT * FROM sys.columns WHERE table_id NOT IN (SELECT id FROM sys.tables); +SELECT * FROM sys._columns WHERE table_id NOT IN (SELECT id FROM sys._tables); +SELECT * FROM sys.keys WHERE table_id NOT IN (SELECT id FROM sys.tables); +SELECT * FROM sys.objects WHERE id NOT IN (SELECT id FROM sys.ids); +SELECT * FROM sys.idxs WHERE table_id NOT IN (SELECT id FROM sys.tables); +SELECT * FROM sys.dependencies WHERE id NOT IN (SELECT id FROM sys.ids); +SELECT * FROM sys.dependencies WHERE depend_id NOT IN (SELECT id FROM sys.ids); + +-- create a table with a serial column (which implicitly createa a primary key constraint and index and a sequence) +create table sys.test2 (col1 serial); +select count(*) as count_rows from tables where name = 'test2'; +-- 1 row: test2 (id = 9046) +select count(*) as count_rows from keys where table_id in (select id from tables where name = 'test2'); +-- 1 row: test2_col1_pkey +select count(*) as count_rows from objects where id in (select id from keys where table_id in (select id from tables where name = 'test2')); +-- 1 row: col1 + +ALTER TABLE sys.test2 SET SCHEMA profiler; +select count(*) as count_rows from tables where name = 'test2'; +-- 1 row: test2. NOTE that the id has changed from 9046 into 9048 +select count(*) as count_rows from keys where table_id in (select id from tables where name = 'test2'); +-- 1 row: test2_col1_pkey +select count(*) as count_rows from objects where id in (select id from keys where table_id in (select id from tables where name = 'test2')); +-- 2 rows! which are also identical: col1 + +ALTER TABLE profiler.test2 SET SCHEMA json; +select count(*) as count_rows from tables where name = 'test2'; +-- 1 row: test2. NOTE that the id has changed from 9048 into 9050 +select count(*) as count_rows from keys where table_id in (select id from tables where name = 'test2'); +-- 1 row: test2_col1_pkey +select count(*) as count_rows from objects where id in (select id from keys where table_id in (select id from tables where name = 'test2')); +-- 3 rows! which are also identical: col1 + +ALTER TABLE json.test2 SET SCHEMA sys; +select count(*) as count_rows from tables where name = 'test2'; +-- 1 row: test2. NOTE that the id has changed from 9050 into 9052 +select count(*) as count_rows from keys where table_id in (select id from tables where name = 'test2'); +-- 1 row: test2_col1_pkey +select count(*) as count_rows from objects where id in (select id from keys where table_id in (select id from tables where name = 'test2')); +-- 4 rows! which are also identical: col1 + +-- Now repeat the invalid FK references exist in the db. All next queries should return zero rows: +SELECT * FROM sys.columns WHERE table_id NOT IN (SELECT id FROM sys.tables); +-- lists 3 invalid rows +SELECT * FROM sys._columns WHERE table_id NOT IN (SELECT id FROM sys._tables); +-- lists 3 invalid rows +SELECT * FROM sys.keys WHERE table_id NOT IN (SELECT id FROM sys.tables); +-- lists 3 invalid rows +SELECT * FROM sys.objects WHERE id NOT IN (SELECT id FROM sys.ids); +-- lists 3 invalid rows +SELECT * FROM sys.idxs WHERE table_id NOT IN (SELECT id FROM sys.tables); +-- lists 3 invalid rows +SELECT * FROM sys.dependencies WHERE id NOT IN (SELECT id FROM sys.ids); +SELECT * FROM sys.dependencies WHERE depend_id NOT IN (SELECT id FROM sys.ids); + +drop table sys.test2; + +-- Now repeat the invalid FK references exist in the db. All next queries should return zero rows: +SELECT * FROM sys.columns WHERE table_id NOT IN (SELECT id FROM sys.tables); +-- lists 4 invalid rows +SELECT * FROM sys._columns WHERE table_id NOT IN (SELECT id FROM sys._tables); +-- lists 4 invalid rows +SELECT * FROM sys.keys WHERE table_id NOT IN (SELECT id FROM sys.tables); +-- lists 4 invalid rows +SELECT * FROM sys.objects WHERE id NOT IN (SELECT id FROM sys.ids); +-- lists 4 invalid rows +SELECT * FROM sys.idxs WHERE table_id NOT IN (SELECT id FROM sys.tables); +-- lists 4 invalid rows +SELECT * FROM sys.dependencies WHERE id NOT IN (SELECT id FROM sys.ids); +SELECT * FROM sys.dependencies WHERE depend_id NOT IN (SELECT id FROM sys.ids); + +-- now try to recreate the dropped table +create table sys.test2 (col1 serial); +-- it produces Error: CONSTRAINT PRIMARY KEY: key test2_col1_pkey already exists SQLState: 42000 + +drop table if exists sys.test2; + diff --git a/sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.stable.err b/sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.stable.err @@ -0,0 +1,34 @@ +stderr of test 'alter_table_set_schema.Bug-6701` in directory 'sql/test/BugTracker-2019` itself: + + +# 19:03:56 > +# 19:03:56 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=38092" "--set" "mapi_usock=/var/tmp/mtest-21054/.s.monetdb.38092" "--set" "monet_prompt=" "--forcemito" "--dbpath=/export/scratch1/dinther/INSTALL/var/MonetDB/mTests_sql_test_BugTracker-2019" "--set" "embedded_r=yes" "--set" "embedded_py=2" "--set" "embedded_c=true" +# 19:03:56 > + +# builtin opt gdk_dbpath = /export/scratch1/dinther/INSTALL/var/monetdb5/dbfarm/demo +# builtin opt monet_prompt = > +# builtin opt monet_daemon = no +# builtin opt mapi_port = 50000 +# builtin opt mapi_open = false +# builtin opt mapi_autosense = false +# builtin opt sql_optimizer = default_pipe +# builtin opt sql_debug = 0 +# cmdline opt gdk_nr_threads = 0 +# cmdline opt mapi_open = true +# cmdline opt mapi_port = 38092 +# cmdline opt mapi_usock = /var/tmp/mtest-21054/.s.monetdb.38092 +# cmdline opt monet_prompt = +# cmdline opt gdk_dbpath = /export/scratch1/dinther/INSTALL/var/MonetDB/mTests_sql_test_BugTracker-2019 +# cmdline opt embedded_r = yes +# cmdline opt embedded_py = 2 +# cmdline opt embedded_c = true + +# 19:09:41 > +# 19:09:41 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-21731" "--port=39182" +# 19:09:41 > + + +# 19:25:10 > +# 19:25:10 > "Done." +# 19:25:10 > + diff --git a/sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.stable.out b/sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.stable.out @@ -0,0 +1,217 @@ +stdout of test 'alter_table_set_schema.Bug-6701` in directory 'sql/test/BugTracker-2019` itself: + + +# 19:03:56 > +# 19:03:56 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=38092" "--set" "mapi_usock=/var/tmp/mtest-21054/.s.monetdb.38092" "--set" "monet_prompt=" "--forcemito" "--dbpath=/export/scratch1/dinther/INSTALL/var/MonetDB/mTests_sql_test_BugTracker-2019" "--set" "embedded_r=yes" "--set" "embedded_py=2" "--set" "embedded_c=true" +# 19:03:56 > + +# MonetDB 5 server v11.33.2 (hg id: fda2e61de6c7) +# This is an unreleased version +# Serving database 'mTests_sql_test_BugTracker-2019', using 4 threads +# Compiled for x86_64-unknown-linux-gnu/64bit with 128bit integers +# Found 31.305 GiB available main-memory. +# Copyright (c) 1993 - July 2008 CWI. +# Copyright (c) August 2008 - 2019 MonetDB B.V., all rights reserved +# Visit https://www.monetdb.org/ for further information +# Listening for connection requests on mapi:monetdb://catskill.da.cwi.nl:38092/ +# Listening for UNIX domain connection requests on mapi:monetdb:///var/tmp/mtest-21054/.s.monetdb.38092 +# MonetDB/GIS module loaded +# MonetDB/SQL module loaded +# MonetDB/Python2 module loaded +# MonetDB/R module loaded + +Ready. + +# 19:03:57 > +# 19:03:57 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-21054" "--port=38092" +# 19:03:57 > + +#SELECT * FROM sys.columns WHERE table_id NOT IN (SELECT id FROM sys.tables); +% .columns, .columns, .columns, .columns, .columns, .columns, .columns, .columns, .columns, .columns # table_name +% id, name, type, type_digits, type_scale, table_id, default, null, number, storage # name +% int, varchar, varchar, int, int, int, varchar, boolean, int, varchar # type +% 1, 0, 0, 1, 1, 1, 0, 5, 1, 0 # length +#SELECT * FROM sys._columns WHERE table_id NOT IN (SELECT id FROM sys._tables); +% sys._columns, sys._columns, sys._columns, sys._columns, sys._columns, sys._columns, sys._columns, sys._columns, sys._columns, sys._columns # table_name +% id, name, type, type_digits, type_scale, table_id, default, null, number, storage # name +% int, varchar, varchar, int, int, int, varchar, boolean, int, varchar # type +% 1, 0, 0, 1, 1, 1, 0, 5, 1, 0 # length +#SELECT * FROM sys.keys WHERE table_id NOT IN (SELECT id FROM sys.tables); +% sys.keys, sys.keys, sys.keys, sys.keys, sys.keys, sys.keys # table_name +% id, table_id, type, name, rkey, action # name +% int, int, int, varchar, int, int # type +% 1, 1, 1, 0, 1, 1 # length +#SELECT * FROM sys.objects WHERE id NOT IN (SELECT id FROM sys.ids); +% sys.objects, sys.objects, sys.objects # table_name +% id, name, nr # name +% int, varchar, int # type +% 1, 0, 1 # length +#SELECT * FROM sys.idxs WHERE table_id NOT IN (SELECT id FROM sys.tables); +% sys.idxs, sys.idxs, sys.idxs, sys.idxs # table_name +% id, table_id, type, name # name +% int, int, int, varchar # type +% 1, 1, 1, 0 # length +#SELECT * FROM sys.dependencies WHERE id NOT IN (SELECT id FROM sys.ids); +% sys.dependencies, sys.dependencies, sys.dependencies # table_name +% id, depend_id, depend_type # name +% int, int, smallint # type +% 1, 1, 1 # length +#SELECT * FROM sys.dependencies WHERE depend_id NOT IN (SELECT id FROM sys.ids); +% sys.dependencies, sys.dependencies, sys.dependencies # table_name +% id, depend_id, depend_type # name +% int, int, smallint # type +% 1, 1, 1 # length +#create table sys.test2 (col1 serial); +#select count(*) as count_rows from tables where name = 'test2'; +% .L42 # table_name +% count_rows # name +% bigint # type +% 1 # length +[ 1 ] +#select count(*) as count_rows from keys where table_id in (select id from tables where name = 'test2'); +% sys.L103 # table_name +% count_rows # name +% bigint # type +% 1 # length +[ 1 ] +#select count(*) as count_rows from objects where id in (select id from keys where table_id in (select id from tables where name = 'test2')); +% sys.L205 # table_name +% count_rows # name +% bigint # type +% 1 # length +[ 1 ] +#ALTER TABLE sys.test2 SET SCHEMA profiler; +#select count(*) as count_rows from tables where name = 'test2'; +% .L42 # table_name +% count_rows # name +% bigint # type +% 1 # length +[ 1 ] +#select count(*) as count_rows from keys where table_id in (select id from tables where name = 'test2'); +% sys.L103 # table_name +% count_rows # name +% bigint # type +% 1 # length +[ 1 ] +#select count(*) as count_rows from objects where id in (select id from keys where table_id in (select id from tables where name = 'test2')); +% sys.L205 # table_name +% count_rows # name +% bigint # type +% 1 # length +[ 1 ] +#ALTER TABLE profiler.test2 SET SCHEMA json; +#select count(*) as count_rows from tables where name = 'test2'; +% .L42 # table_name +% count_rows # name +% bigint # type +% 1 # length +[ 1 ] +#select count(*) as count_rows from keys where table_id in (select id from tables where name = 'test2'); +% sys.L103 # table_name +% count_rows # name +% bigint # type +% 1 # length +[ 1 ] +#select count(*) as count_rows from objects where id in (select id from keys where table_id in (select id from tables where name = 'test2')); +% sys.L205 # table_name +% count_rows # name +% bigint # type +% 1 # length +[ 1 ] +#ALTER TABLE json.test2 SET SCHEMA sys; +#select count(*) as count_rows from tables where name = 'test2'; +% .L42 # table_name +% count_rows # name +% bigint # type +% 1 # length +[ 1 ] +#select count(*) as count_rows from keys where table_id in (select id from tables where name = 'test2'); +% sys.L103 # table_name +% count_rows # name +% bigint # type +% 1 # length +[ 1 ] +#select count(*) as count_rows from objects where id in (select id from keys where table_id in (select id from tables where name = 'test2')); +% sys.L205 # table_name +% count_rows # name +% bigint # type +% 1 # length +[ 1 ] +#SELECT * FROM sys.columns WHERE table_id NOT IN (SELECT id FROM sys.tables); +% .columns, .columns, .columns, .columns, .columns, .columns, .columns, .columns, .columns, .columns # table_name +% id, name, type, type_digits, type_scale, table_id, default, null, number, storage # name +% int, varchar, varchar, int, int, int, varchar, boolean, int, varchar # type +% 4, 4, 3, 2, 1, 4, 31, 5, 1, 0 # length +#SELECT * FROM sys._columns WHERE table_id NOT IN (SELECT id FROM sys._tables); +% sys._columns, sys._columns, sys._columns, sys._columns, sys._columns, sys._columns, sys._columns, sys._columns, sys._columns, sys._columns # table_name +% id, name, type, type_digits, type_scale, table_id, default, null, number, storage # name +% int, varchar, varchar, int, int, int, varchar, boolean, int, varchar # type +% 4, 4, 3, 2, 1, 4, 31, 5, 1, 0 # length +#SELECT * FROM sys.keys WHERE table_id NOT IN (SELECT id FROM sys.tables); +% sys.keys, sys.keys, sys.keys, sys.keys, sys.keys, sys.keys # table_name +% id, table_id, type, name, rkey, action # name +% int, int, int, varchar, int, int # type +% 4, 4, 1, 15, 2, 2 # length +#SELECT * FROM sys.objects WHERE id NOT IN (SELECT id FROM sys.ids); +% sys.objects, sys.objects, sys.objects # table_name +% id, name, nr # name +% int, varchar, int # type +% 1, 0, 1 # length +#SELECT * FROM sys.idxs WHERE table_id NOT IN (SELECT id FROM sys.tables); +% sys.idxs, sys.idxs, sys.idxs, sys.idxs # table_name +% id, table_id, type, name # name +% int, int, int, varchar # type +% 4, 4, 1, 15 # length +#SELECT * FROM sys.dependencies WHERE id NOT IN (SELECT id FROM sys.ids); _______________________________________________ checkin-list mailing list [email protected] https://www.monetdb.org/mailman/listinfo/checkin-list
