Changeset: df64f8667fdf for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=df64f8667fdf Added Files: sql/test/Tests/ifexists.sql sql/test/Tests/ifexists.stable.err sql/test/Tests/ifexists.stable.out Branch: default Log Message:
IF (NOT) EXISTS testcases diffs (truncated from 318 to 300 lines): diff --git a/sql/test/Tests/ifexists.sql b/sql/test/Tests/ifexists.sql new file mode 100644 --- /dev/null +++ b/sql/test/Tests/ifexists.sql @@ -0,0 +1,94 @@ +# Test IF (NOT) EXISTS functionality for tables + +START TRANSACTION; +CREATE TABLE hello(i INTEGER); +INSERT INTO hello VALUES (2), (3), (4); +CREATE TABLE IF NOT EXISTS hello(i INTEGER); + +# (2,3,4) +SELECT * FROM hello; +ROLLBACK; + +# verify that the table is gone +# () +SELECT name FROM tables WHERE name='hello'; + +START TRANSACTION; +CREATE TABLE hello(i INTEGER); +# !CREATE TABLE: name 'hello' already in use +CREATE TABLE hello(i INTEGER); +ROLLBACK; + +START TRANSACTION; +# test DROP TABLE IF EXISTS +CREATE TABLE hello(i INTEGER); +# verify that the table exists +# ('hello') +SELECT name FROM tables WHERE name='hello'; +DROP TABLE IF EXISTS hello; +DROP TABLE IF EXISTS hello; +# (1) +SELECT 1; +ROLLBACK; + +START TRANSACTION; +# this should still fail +CREATE TABLE hello(i INTEGER); +DROP TABLE hello; +# !DROP TABLE: no such table 'hello' +DROP TABLE hello; +ROLLBACK; + +# Test IF (NOT) EXISTS functionality for schemas + +START TRANSACTION; +# create the initial schema +CREATE SCHEMA IF NOT EXISTS hello; +# verify that the schema exists +# ('hello') +SELECT name FROM schemas WHERE name='hello'; +# this statement should fail silently because the schema already exists +CREATE SCHEMA IF NOT EXISTS hello; + +# use the schema to make sure it's there +CREATE TABLE hello.tbl(i INTEGER); +INSERT INTO hello.tbl VALUES (3); +# (3) +SELECT * FROM hello.tbl; + +ROLLBACK; + +# verify that the schema is gone +# () +SELECT name FROM schemas WHERE name='hello'; + +START TRANSACTION; +CREATE SCHEMA hello; +# CREATE SCHEMA: name 'hello' already in use +CREATE SCHEMA hello; +ROLLBACK; + +START TRANSACTION; +# test DROP SCHEMA IF EXISTS +CREATE SCHEMA hello; +# verify that the schema exists +# ('hello') +SELECT name FROM schemas WHERE name='hello'; +DROP SCHEMA IF EXISTS hello; +DROP SCHEMA IF EXISTS hello; +# (1) +SELECT 1; + +# verify that the schema is gone +# () +SELECT name FROM schemas WHERE name='hello'; +ROLLBACK; + + +START TRANSACTION; +# this should still fail +CREATE SCHEMA hello; +DROP SCHEMA hello; +# !DROP SCHEMA: name hello does not exist +DROP SCHEMA hello; +ROLLBACK; diff --git a/sql/test/Tests/ifexists.stable.err b/sql/test/Tests/ifexists.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/Tests/ifexists.stable.err @@ -0,0 +1,48 @@ +stderr of test 'ifexists` in directory 'sql/test` itself: + + +# 16:49:35 > +# 16:49:35 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=38832" "--set" "mapi_usock=/var/tmp/mtest-81010/.s.monetdb.38832" "--set" "monet_prompt=" "--forcemito" "--dbpath=/Users/myth/opt/var/MonetDB/mTests_sql_test" "--set" "embedded_r=yes" "--set" "embedded_py=true" +# 16:49:35 > + +# builtin opt gdk_dbpath = /Users/myth/opt/var/monetdb5/dbfarm/demo +# builtin opt gdk_debug = 0 +# builtin opt gdk_vmtrim = no +# 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 = 38832 +# cmdline opt mapi_usock = /var/tmp/mtest-81010/.s.monetdb.38832 +# cmdline opt monet_prompt = +# cmdline opt gdk_dbpath = /Users/myth/opt/var/MonetDB/mTests_sql_test +# cmdline opt embedded_r = yes +# cmdline opt embedded_py = true +# cmdline opt gdk_debug = 536870922 + +# 16:49:36 > +# 16:49:36 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-81010" "--port=38832" +# 16:49:36 > + +MAPI = (monetdb) /var/tmp/mtest-81010/.s.monetdb.38832 +QUERY = CREATE TABLE hello(i INTEGER); +ERROR = !CREATE TABLE: name 'hello' already in use +MAPI = (monetdb) /var/tmp/mtest-81010/.s.monetdb.38832 +QUERY = DROP TABLE hello; +ERROR = !DROP TABLE: no such table 'hello' +MAPI = (monetdb) /var/tmp/mtest-81010/.s.monetdb.38832 +QUERY = CREATE SCHEMA hello; +ERROR = !CREATE SCHEMA: name 'hello' already in use +MAPI = (monetdb) /var/tmp/mtest-81010/.s.monetdb.38832 +QUERY = DROP SCHEMA hello; +ERROR = !DROP SCHEMA: name hello does not exist + +# 16:49:36 > +# 16:49:36 > "Done." +# 16:49:36 > + diff --git a/sql/test/Tests/ifexists.stable.out b/sql/test/Tests/ifexists.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/Tests/ifexists.stable.out @@ -0,0 +1,161 @@ +stdout of test 'ifexists` in directory 'sql/test` itself: + + +# 16:49:35 > +# 16:49:35 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=38832" "--set" "mapi_usock=/var/tmp/mtest-81010/.s.monetdb.38832" "--set" "monet_prompt=" "--forcemito" "--dbpath=/Users/myth/opt/var/MonetDB/mTests_sql_test" "--set" "embedded_r=yes" "--set" "embedded_py=true" +# 16:49:35 > + +# MonetDB 5 server v11.26.0 +# This is an unreleased version +# Serving database 'mTests_sql_test', using 4 threads +# Compiled for x86_64-apple-darwin15.6.0/64bit with 128bit integers +# Found 8.000 GiB available main-memory. +# Copyright (c) 1993-July 2008 CWI. +# Copyright (c) August 2008-2016 MonetDB B.V., all rights reserved +# Visit http://www.monetdb.org/ for further information +# Listening for connection requests on mapi:monetdb://dhcp-46.eduroam.cwi.nl:38832/ +# Listening for UNIX domain connection requests on mapi:monetdb:///var/tmp/mtest-81010/.s.monetdb.38832 +# MonetDB/SQL module loaded +# MonetDB/Python module loaded +# MonetDB/R module loaded + +Ready. +# SQL catalog created, loading sql scripts once +# loading sql script: 09_like.sql +# loading sql script: 10_math.sql +# loading sql script: 11_times.sql +# loading sql script: 12_url.sql +# loading sql script: 13_date.sql +# loading sql script: 14_inet.sql +# loading sql script: 15_querylog.sql +# loading sql script: 16_tracelog.sql +# loading sql script: 17_temporal.sql +# loading sql script: 18_index.sql +# loading sql script: 20_vacuum.sql +# loading sql script: 21_dependency_functions.sql +# loading sql script: 22_clients.sql +# loading sql script: 23_skyserver.sql +# loading sql script: 25_debug.sql +# loading sql script: 26_sysmon.sql +# loading sql script: 27_rejects.sql +# loading sql script: 39_analytics.sql +# loading sql script: 39_analytics_hge.sql +# loading sql script: 40_json.sql +# loading sql script: 40_json_hge.sql +# loading sql script: 41_md5sum.sql +# loading sql script: 45_uuid.sql +# loading sql script: 46_profiler.sql +# loading sql script: 51_sys_schema_extension.sql +# loading sql script: 72_fits.sql +# loading sql script: 74_netcdf.sql +# loading sql script: 75_storagemodel.sql +# loading sql script: 80_statistics.sql +# loading sql script: 80_udf.sql +# loading sql script: 80_udf_hge.sql +# loading sql script: 90_generator.sql +# loading sql script: 90_generator_hge.sql +# loading sql script: 99_system.sql + +# 16:49:36 > +# 16:49:36 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-81010" "--port=38832" +# 16:49:36 > + +#START TRANSACTION; +#CREATE TABLE hello(i INTEGER); +#INSERT INTO hello VALUES (2), (3), (4); +[ 3 ] +#SELECT * FROM hello; +% sys.hello # table_name +% i # name +% int # type +% 1 # length +[ 2 ] +[ 3 ] +[ 4 ] +#ROLLBACK; +#SELECT name FROM tables WHERE name='hello'; +% .tables # table_name +% name # name +% varchar # type +% 0 # length +#START TRANSACTION; +#CREATE TABLE hello(i INTEGER); +#ROLLBACK; +#START TRANSACTION; +#CREATE TABLE hello(i INTEGER); +#SELECT name FROM tables WHERE name='hello'; +% .tables # table_name +% name # name +% varchar # type +% 5 # length +[ "hello" ] +#DROP TABLE IF EXISTS hello; +#DROP TABLE IF EXISTS hello; +#SELECT 1; +% .L2 # table_name +% L2 # name +% tinyint # type +% 1 # length +[ 1 ] +#ROLLBACK; +#START TRANSACTION; +#CREATE TABLE hello(i INTEGER); +#DROP TABLE hello; +#ROLLBACK; +#START TRANSACTION; +#CREATE SCHEMA IF NOT EXISTS hello; +#SELECT name FROM schemas WHERE name='hello'; +% sys.schemas # table_name +% name # name +% varchar # type +% 5 # length +[ "hello" ] +#CREATE TABLE hello.tbl(i INTEGER); +#INSERT INTO hello.tbl VALUES (3); +[ 1 ] +#SELECT * FROM hello.tbl; +% hello.tbl # table_name +% i # name +% int # type +% 1 # length +[ 3 ] +#ROLLBACK; +#SELECT name FROM schemas WHERE name='hello'; +% sys.schemas # table_name +% name # name +% varchar # type +% 0 # length +#START TRANSACTION; +#CREATE SCHEMA hello; +#ROLLBACK; +#START TRANSACTION; +#CREATE SCHEMA hello; +#SELECT name FROM schemas WHERE name='hello'; +% sys.schemas # table_name +% name # name +% varchar # type +% 5 # length +[ "hello" ] +#DROP SCHEMA IF EXISTS hello; +#DROP SCHEMA IF EXISTS hello; +#SELECT 1; +% .L2 # table_name +% L2 # name _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list