Changeset: d3433f5b5acb for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d3433f5b5acb Added Files: sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.sql sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.stable.err sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.stable.out Modified Files: sql/server/rel_sequence.c sql/test/BugTracker-2019/Tests/All Branch: Apr2019 Log Message:
Added test and fix for bug 6745. diffs (242 lines): diff --git a/sql/server/rel_sequence.c b/sql/server/rel_sequence.c --- a/sql/server/rel_sequence.c +++ b/sql/server/rel_sequence.c @@ -139,7 +139,7 @@ list_create_seq( bit bedropped) { dnode *n; - sql_subtype* t = NULL; + sql_subtype *t = NULL; lng start = lng_nil, inc = lng_nil, min = lng_nil, max = lng_nil, cache = lng_nil; unsigned int used = 0; bit cycle = 0; @@ -150,12 +150,24 @@ list_create_seq( symbol *s = n->data.sym; switch(s->token) { - case SQL_TYPE: + case SQL_TYPE: { + bool found = false; + const char *valid_types[4] = {"tinyint", "smallint", "int", "bigint"}; + size_t number_valid_types = sizeof(valid_types) / sizeof(valid_types[0]); + if ((used&(1<<SEQ_TYPE))) return sql_error(sql, 02, SQLSTATE(3F000) "CREATE SEQUENCE: AS type found should be used as most once"); used |= (1<<SEQ_TYPE); t = &s->data.lval->h->data.typeval; - break; + for (size_t i = 0; i < number_valid_types; i++) { + if (strcasecmp(valid_types[i], t->type->sqlname) == 0) { + found = true; + break; + } + } + if (!found) + return sql_error(sql, 02, SQLSTATE(42000) "CREATE SEQUENCE: The type of the sequence must be either tinyint, smallint, int or bigint"); + } break; case SQL_START: if ((used&(1<<SEQ_START))) return sql_error(sql, 02, SQLSTATE(3F000) "CREATE SEQUENCE: START value should be passed as most once"); 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 @@ -27,3 +27,4 @@ view-too-few-rows.Bug-6736 slow-inner-join.Bug-6737 sum-over-hge.Bug.6738 sequences-defaults.Bug-6744 +sequences-types.Bug-6745 diff --git a/sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.sql b/sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.sql new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.sql @@ -0,0 +1,19 @@ +CREATE SEQUENCE seqBool AS boolean; +CREATE SEQUENCE seqChar AS char; +CREATE SEQUENCE seqClob AS CLOB; +CREATE SEQUENCE seqBlob AS BLOB; +CREATE SEQUENCE seqDate AS date; +CREATE SEQUENCE seqTime AS time; +CREATE SEQUENCE seqInet AS inet; +CREATE SEQUENCE seqUuid AS uuid; + +start transaction; +CREATE SEQUENCE seqTiny AS tinyint; +CREATE SEQUENCE seqSmall AS smallint; +CREATE SEQUENCE seqInt AS int; +CREATE SEQUENCE seqBint AS bigint; + +select name, start, minvalue, maxvalue, increment, cacheinc, cycle from sequences +where name in ('seqbool', 'seqchar', 'seqclob', 'seqblob', 'seqdate', 'seqtime', 'seqinet', 'sequuid', 'seqtiny', + 'seqsmall', 'seqint', 'seqbint'); +rollback; diff --git a/sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.stable.err b/sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.stable.err @@ -0,0 +1,73 @@ +stderr of test 'sequences-types.Bug-6745` in directory 'sql/test/BugTracker-2019` itself: + + +# 13:26:38 > +# 13:26:38 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=37773" "--set" "mapi_usock=/var/tmp/mtest-7925/.s.monetdb.37773" "--set" "monet_prompt=" "--forcemito" "--dbpath=/home/ferreira/repositories/MonetDB-Apr2019/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2019" "--set" "embedded_c=true" +# 13:26:38 > + +# builtin opt gdk_dbpath = /home/ferreira/repositories/MonetDB-Apr2019/BUILD/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 = 37773 +# cmdline opt mapi_usock = /var/tmp/mtest-7925/.s.monetdb.37773 +# cmdline opt monet_prompt = +# cmdline opt gdk_dbpath = /home/ferreira/repositories/MonetDB-Apr2019/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2019 +# cmdline opt embedded_c = true +#client2:!ERROR:ParseException:SQLparser:42000!CREATE SEQUENCE: The type of the sequence must be either tinyint, smallint, int or bigint +#client2:!ERROR:ParseException:SQLparser:42000!CREATE SEQUENCE: The type of the sequence must be either tinyint, smallint, int or bigint +#client2:!ERROR:ParseException:SQLparser:42000!CREATE SEQUENCE: The type of the sequence must be either tinyint, smallint, int or bigint +#client2:!ERROR:ParseException:SQLparser:42000!CREATE SEQUENCE: The type of the sequence must be either tinyint, smallint, int or bigint +#client2:!ERROR:ParseException:SQLparser:42000!CREATE SEQUENCE: The type of the sequence must be either tinyint, smallint, int or bigint +#client2:!ERROR:ParseException:SQLparser:42000!CREATE SEQUENCE: The type of the sequence must be either tinyint, smallint, int or bigint +#client2:!ERROR:ParseException:SQLparser:42000!CREATE SEQUENCE: The type of the sequence must be either tinyint, smallint, int or bigint +#client2:!ERROR:ParseException:SQLparser:42000!CREATE SEQUENCE: The type of the sequence must be either tinyint, smallint, int or bigint +#main thread:!ERROR:MALException:client.quit:Server stopped + +# 13:26:39 > +# 13:26:39 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-7925" "--port=37773" +# 13:26:39 > + +MAPI = (monetdb) /var/tmp/mtest-7925/.s.monetdb.37773 +QUERY = CREATE SEQUENCE seqBool AS boolean; +ERROR = !CREATE SEQUENCE: The type of the sequence must be either tinyint, smallint, int or bigint +CODE = 42000 +MAPI = (monetdb) /var/tmp/mtest-7925/.s.monetdb.37773 +QUERY = CREATE SEQUENCE seqChar AS char; +ERROR = !CREATE SEQUENCE: The type of the sequence must be either tinyint, smallint, int or bigint +CODE = 42000 +MAPI = (monetdb) /var/tmp/mtest-7925/.s.monetdb.37773 +QUERY = CREATE SEQUENCE seqClob AS CLOB; +ERROR = !CREATE SEQUENCE: The type of the sequence must be either tinyint, smallint, int or bigint +CODE = 42000 +MAPI = (monetdb) /var/tmp/mtest-7925/.s.monetdb.37773 +QUERY = CREATE SEQUENCE seqBlob AS BLOB; +ERROR = !CREATE SEQUENCE: The type of the sequence must be either tinyint, smallint, int or bigint +CODE = 42000 +MAPI = (monetdb) /var/tmp/mtest-7925/.s.monetdb.37773 +QUERY = CREATE SEQUENCE seqDate AS date; +ERROR = !CREATE SEQUENCE: The type of the sequence must be either tinyint, smallint, int or bigint +CODE = 42000 +MAPI = (monetdb) /var/tmp/mtest-7925/.s.monetdb.37773 +QUERY = CREATE SEQUENCE seqTime AS time; +ERROR = !CREATE SEQUENCE: The type of the sequence must be either tinyint, smallint, int or bigint +CODE = 42000 +MAPI = (monetdb) /var/tmp/mtest-7925/.s.monetdb.37773 +QUERY = CREATE SEQUENCE seqInet AS inet; +ERROR = !CREATE SEQUENCE: The type of the sequence must be either tinyint, smallint, int or bigint +CODE = 42000 +MAPI = (monetdb) /var/tmp/mtest-7925/.s.monetdb.37773 +QUERY = CREATE SEQUENCE seqUuid AS uuid; +ERROR = !CREATE SEQUENCE: The type of the sequence must be either tinyint, smallint, int or bigint +CODE = 42000 + +# 13:26:39 > +# 13:26:39 > "Done." +# 13:26:39 > + diff --git a/sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.stable.out b/sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.stable.out @@ -0,0 +1,88 @@ +stdout of test 'sequences-types.Bug-6745` in directory 'sql/test/BugTracker-2019` itself: + + +# 13:26:38 > +# 13:26:38 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=37773" "--set" "mapi_usock=/var/tmp/mtest-7925/.s.monetdb.37773" "--set" "monet_prompt=" "--forcemito" "--dbpath=/home/ferreira/repositories/MonetDB-Apr2019/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2019" "--set" "embedded_c=true" +# 13:26:38 > + +# MonetDB 5 server v11.33.4 (hg id: 101e6463524a+) +# This is an unreleased version +# Serving database 'mTests_sql_test_BugTracker-2019', using 8 threads +# Compiled for x86_64-pc-linux-gnu/64bit with 128bit integers +# Found 15.527 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://localhost.localdomain:37773/ +# Listening for UNIX domain connection requests on mapi:monetdb:///var/tmp/mtest-7925/.s.monetdb.37773 +# MonetDB/GIS module loaded +# 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_views.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_geom.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: 60_wlcr.sql +# loading sql script: 72_fits.sql +# loading sql script: 74_netcdf.sql +# loading sql script: 75_lidar.sql +# loading sql script: 75_shp.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: 85_bam.sql +# loading sql script: 90_generator.sql +# loading sql script: 90_generator_hge.sql +# loading sql script: 99_system.sql +# MonetDB/SQL module loaded + +Ready. + +# 13:26:39 > +# 13:26:39 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-7925" "--port=37773" +# 13:26:39 > + +#start transaction; +#CREATE SEQUENCE seqTiny AS tinyint; +#CREATE SEQUENCE seqSmall AS smallint; +#CREATE SEQUENCE seqInt AS int; +#CREATE SEQUENCE seqBint AS bigint; +#select name, start, minvalue, maxvalue, increment, cacheinc, cycle from sequences +#where name in ('seqbool', 'seqchar', 'seqclob', 'seqblob', 'seqdate', 'seqtime', 'seqinet', 'sequuid', 'seqtiny', +# 'seqsmall', 'seqint', 'seqbint'); +% sys.sequences, sys.sequences, sys.sequences, sys.sequences, sys.sequences, sys.sequences, sys.sequences # table_name +% name, start, minvalue, maxvalue, increment, cacheinc, cycle # name +% varchar, bigint, bigint, bigint, bigint, bigint, boolean # type +% 8, 1, 1, 1, 1, 1, 5 # length +[ "seqtiny", 1, 0, 0, 1, 1, false ] +[ "seqsmall", 1, 0, 0, 1, 1, false ] +[ "seqint", 1, 0, 0, 1, 1, false ] +[ "seqbint", 1, 0, 0, 1, 1, false ] +#rollback; + +# 13:26:39 > +# 13:26:39 > "Done." +# 13:26:39 > + _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list