Changeset: eafce9e7afba for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=eafce9e7afba Added Files: sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.err.int128 sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.out.int128 sql/test/BugTracker-2014/Tests/hexadecimal_literals.Bug-3621.sql sql/test/BugTracker-2014/Tests/hexadecimal_literals.Bug-3621.stable.err sql/test/BugTracker-2014/Tests/hexadecimal_literals.Bug-3621.stable.err.int128 sql/test/BugTracker-2014/Tests/hexadecimal_literals.Bug-3621.stable.out sql/test/BugTracker-2014/Tests/hexadecimal_literals.Bug-3621.stable.out.int128 Modified Files: sql/server/sql_parser.y sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.sql sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.err sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.out sql/test/BugTracker-2014/Tests/All Branch: default Log Message:
Merge with Oct2014 branch. diffs (truncated from 3092 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 @@ -4060,36 +4060,65 @@ literal: | HEXADECIMAL { int len = _strlen($1), i = 2, err = 0; char * hexa = $1; sql_subtype t; - long res = 0; - - while (i<len) - { - res <<= 4; - if ('0'<= hexa[i] && hexa[i] <= '9') - res = res + (hexa[i] - '0'); - else if ('A' <= hexa[i] && hexa[i] <= 'F') - res = res + (hexa[i] - 'A' + 10); - else if ('a' <= hexa[i] && hexa[i] <= 'f') - res = res + (hexa[i] - 'a' + 10); - else - err = 1; +#ifdef HAVE_HGE + hge res = 0; +#else + lng res = 0; +#endif + /* skip leading '0' */ + while (i < len && hexa[i] == '0') i++; - } - - if ( i >= 2 && i <= 6) - sql_find_subtype(&t, "smallint", 16, 0); - else if ( i > 6 && i <= 10) - sql_find_subtype(&t, "int", 32, 0); - else if ( i > 10 && i <= 18) - sql_find_subtype(&t, "bigint", 64, 0); + #ifdef HAVE_HGE - else if ( i > 18 && i <= 34) - sql_find_subtype(&t, "hugeint", 128, 0); + /* we only support positive values that fit in a signed 128-bit type, + * i.e., max. 127 bit => < 2^127 => < 0x80000000000000000000000000000000 + * (leading sign (-0x...) is handled separately elsewhere) + */ + if (len - i < 32 || (len - i == 32 && hexa[i] < '8')) +#else + /* we only support positive values that fit in a signed 64-bit type, + * i.e., max. 63 bit => < 2^63 => < 0x8000000000000000 + * (leading sign (-0x...) is handled separately elsewhere) + */ + if (len - i < 16 || (len - i == 16 && hexa[i] < '8')) #endif + while (err == 0 && i < len) + { + res <<= 4; + if ('0'<= hexa[i] && hexa[i] <= '9') + res = res + (hexa[i] - '0'); + else if ('A' <= hexa[i] && hexa[i] <= 'F') + res = res + (hexa[i] - 'A' + 10); + else if ('a' <= hexa[i] && hexa[i] <= 'f') + res = res + (hexa[i] - 'a' + 10); + else + err = 1; + i++; + } else err = 1; - - if (err) { + + if (err == 0) { + assert(res >= 0); + + /* use smallest type that can accommodate the given value */ + if (res <= GDK_bte_max) + sql_find_subtype(&t, "tinyint", 8, 0 ); + else if (res <= GDK_sht_max) + sql_find_subtype(&t, "smallint", 16, 0 ); + else if (res <= GDK_int_max) + sql_find_subtype(&t, "int", 32, 0 ); + else if (res <= GDK_lng_max) + sql_find_subtype(&t, "bigint", 64, 0 ); +#ifdef HAVE_HGE + else if (res <= GDK_hge_max) + sql_find_subtype(&t, "hugeint", 128, 0 ); +#endif + else + err = 1; + } + + if (err != 0) { char *msg = sql_message("\b22003!invalid hexadecimal number or hexadecimal too large (%s)", $1); yyerror(m, msg); diff --git a/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.sql b/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.sql --- a/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.sql +++ b/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.sql @@ -1,1 +1,3 @@ +select bit_and(3749090034127126942, -1); +select bit_and(3749090034127126942, 0x7fffffffffffffff); select bit_and(3749090034127126942, 0xffffffffffffffff); diff --git a/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.err b/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.err --- a/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.err +++ b/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.err @@ -67,6 +67,10 @@ stderr of test 'bit_and.SF-2850341` in d # 22:31:14 > mclient -lsql -umonetdb -Pmonetdb --host=alf --port=36767 # 22:31:14 > +MAPI = (monetdb) /var/tmp/mtest-28528/.s.monetdb.33240 +QUERY = select bit_and(3749090034127126942, 0xffffffffffffffff); +ERROR = !invalid hexadecimal number or hexadecimal too large (0xffffffffffffffff) in: "select bit_and(3749090034127126942, 0xffffffffffffffff" + !syntax error, unexpected ')' in: ")" # 22:31:14 > # 22:31:14 > Done. diff --git a/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.err.int128 b/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.err.int128 new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.err.int128 @@ -0,0 +1,74 @@ +stderr of test 'bit_and.SF-2850341` in directory 'sql/test/BugTracker-2009` itself: + + +# 22:31:14 > +# 22:31:14 > mserver5 "--config=/ufs/niels/scratch/rc/Linux-x86_64/etc/monetdb5.conf" --debug=10 --set gdk_nr_threads=0 --set "monet_mod_path=/ufs/niels/scratch/rc/Linux-x86_64/lib/MonetDB5:/ufs/niels/scratch/rc/Linux-x86_64/lib/MonetDB5/lib:/ufs/niels/scratch/rc/Linux-x86_64/lib/MonetDB5/bin" --set "gdk_dbfarm=/ufs/niels/scratch/rc/Linux-x86_64/var/MonetDB5/dbfarm" --set mapi_open=true --set xrpc_open=true --set mapi_port=36767 --set xrpc_port=40172 --set monet_prompt= --trace "--dbname=mTests_src_test_BugTracker-2009" --set mal_listing=0 "--dbinit= include sql;" ; echo ; echo Over.. +# 22:31:14 > + +# builtin opt gdk_arch = 64bitx86_64-unknown-linux-gnu +# builtin opt gdk_version = 1.32.0 +# builtin opt prefix = /ufs/niels/scratch/rc/Linux-x86_64 +# builtin opt exec_prefix = ${prefix} +# builtin opt gdk_dbname = tst +# builtin opt gdk_dbfarm = ${prefix}/var/MonetDB +# builtin opt gdk_debug = 8 +# builtin opt gdk_alloc_map = yes +# builtin opt gdk_vmtrim = yes +# builtin opt monet_admin = adm +# builtin opt monet_prompt = > +# builtin opt monet_welcome = yes +# builtin opt monet_mod_path = ${exec_prefix}/lib/MonetDB +# builtin opt monet_daemon = yes +# builtin opt host = localhost +# builtin opt mapi_port = 50000 +# builtin opt mapi_noheaders = no +# builtin opt mapi_debug = 0 +# builtin opt mapi_clients = 2 +# builtin opt sql_debug = 0 +# builtin opt standoff_ns = http://monetdb.cwi.nl/standoff +# builtin opt standoff_start = start +# builtin opt standoff_end = end +# config opt prefix = /ufs/niels/scratch/rc/Linux-x86_64 +# config opt config = ${prefix}/etc/monetdb5.conf +# config opt prefix = /ufs/niels/scratch/rc/Linux-x86_64 +# config opt exec_prefix = ${prefix} +# config opt gdk_dbfarm = ${prefix}/var/MonetDB5/dbfarm +# config opt gdk_dbname = demo +# config opt gdk_alloc_map = no +# config opt gdk_embedded = no +# config opt gdk_debug = 0 +# config opt monet_mod_path = ${exec_prefix}/lib/MonetDB5:${exec_prefix}/lib/MonetDB5/lib:${exec_prefix}/lib/MonetDB5/bin +# config opt monet_daemon = no +# config opt monet_welcome = yes +# config opt mero_msglog = ${prefix}/var/log/MonetDB/merovingian.log +# config opt mero_errlog = ${prefix}/var/log/MonetDB/merovingian.log +# config opt mero_pidfile = ${prefix}/var/run/MonetDB/merovingian.pid +# config opt mal_init = ${exec_prefix}/lib/MonetDB5/mal_init.mal +# config opt mal_listing = 2 +# config opt mapi_port = 50000 +# config opt mapi_autosense = false +# config opt mapi_open = false +# config opt sql_optimizer = inline,remap,evaluate,costModel,coercions,emptySet,aliases,mergetable,deadcode,constants,commonTerms,joinPath,deadcode,reduce,garbageCollector,dataflow,history,multiplex +# cmdline opt config = /ufs/niels/scratch/rc/Linux-x86_64/etc/monetdb5.conf +# cmdline opt gdk_nr_threads = 0 +# cmdline opt monet_mod_path = /ufs/niels/scratch/rc/Linux-x86_64/lib/MonetDB5:/ufs/niels/scratch/rc/Linux-x86_64/lib/MonetDB5/lib:/ufs/niels/scratch/rc/Linux-x86_64/lib/MonetDB5/bin +# cmdline opt gdk_dbfarm = /ufs/niels/scratch/rc/Linux-x86_64/var/MonetDB5/dbfarm +# cmdline opt mapi_open = true +# cmdline opt xrpc_open = true +# cmdline opt mapi_port = 36767 +# cmdline opt xrpc_port = 40172 +# cmdline opt monet_prompt = +# cmdline opt gdk_dbname = mTests_src_test_BugTracker-2009 +# cmdline opt mal_listing = 0 +#warning: please don't forget to set your vault key! +#(see /ufs/niels/scratch/rc/Linux-x86_64/etc/monetdb5.conf) + +# 22:31:14 > +# 22:31:14 > mclient -lsql -umonetdb -Pmonetdb --host=alf --port=36767 +# 22:31:14 > + + +# 22:31:14 > +# 22:31:14 > Done. +# 22:31:14 > + diff --git a/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.out b/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.out --- a/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.out +++ b/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.out @@ -24,14 +24,21 @@ Ready. # 22:31:14 > mclient -lsql -umonetdb -Pmonetdb --host=alf --port=36767 # 22:31:14 > -#select bit_and(3749090034127126942, 0xffffffffffffffff); +#select bit_and(3749090034127126942, -1); % .L # table_name % bit_and_single_value # name % bigint # type % 19 # length [ 3749090034127126942 ] -# 22:31:14 > -# 22:31:14 > Done. -# 22:31:14 > +#select bit_and(3749090034127126942, 0x7fffffffffffffff); +% .L # table_name +% bit_and_single_value # name +% bigint # type +% 19 # length +[ 3749090034127126942 ] +# 18:18:45 > +# 18:18:45 > "Done." +# 18:18:45 > + diff --git a/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.out.int128 b/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.out.int128 new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.out.int128 @@ -0,0 +1,50 @@ +stdout of test 'bit_and.SF-2850341` in directory 'sql/test/BugTracker-2009` itself: + + +# 22:31:14 > +# 22:31:14 > mserver5 "--config=/ufs/niels/scratch/rc/Linux-x86_64/etc/monetdb5.conf" --debug=10 --set gdk_nr_threads=0 --set "monet_mod_path=/ufs/niels/scratch/rc/Linux-x86_64/lib/MonetDB5:/ufs/niels/scratch/rc/Linux-x86_64/lib/MonetDB5/lib:/ufs/niels/scratch/rc/Linux-x86_64/lib/MonetDB5/bin" --set "gdk_dbfarm=/ufs/niels/scratch/rc/Linux-x86_64/var/MonetDB5/dbfarm" --set mapi_open=true --set xrpc_open=true --set mapi_port=36767 --set xrpc_port=40172 --set monet_prompt= --trace "--dbname=mTests_src_test_BugTracker-2009" --set mal_listing=0 "--dbinit= include sql;" ; echo ; echo Over.. +# 22:31:14 > + +# MonetDB server v5.14.0, based on kernel v1.32.0 +# Serving database 'mTests_src_test_BugTracker-2009', using 4 threads +# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically linked +# Copyright (c) 1993-July 2008 CWI. +# Copyright (c) August 2008-2009 MonetDB B.V., all rights reserved +# Visit http://monetdb.cwi.nl/ for further information +# Listening for connection requests on mapi:monetdb://alf.ins.cwi.nl:36767/ +# MonetDB/SQL module v2.32.0 loaded + +Ready. +#function user.main():void; +# clients.quit(); +#end main; + + +# 22:31:14 > +# 22:31:14 > mclient -lsql -umonetdb -Pmonetdb --host=alf --port=36767 +# 22:31:14 > + +#select bit_and(3749090034127126942, -1); +% .L # table_name +% bit_and_single_value # name +% bigint # type +% 19 # length +[ 3749090034127126942 ] + +#select bit_and(3749090034127126942, 0x7fffffffffffffff); +% .L # table_name +% bit_and_single_value # name +% bigint # type +% 19 # length +[ 3749090034127126942 ] +#select bit_and(3749090034127126942, 0xffffffffffffffff); +% .L # table_name +% bit_and_single_value # name +% hugeint # type +% 19 # length +[ 3749090034127126942 ] + +# 18:18:45 > +# 18:18:45 > "Done." +# 18:18:45 > + diff --git a/sql/test/BugTracker-2014/Tests/All b/sql/test/BugTracker-2014/Tests/All --- a/sql/test/BugTracker-2014/Tests/All +++ b/sql/test/BugTracker-2014/Tests/All @@ -51,3 +51,4 @@ queueError.Bug-3604 querylog.Bug-3607 fk-property-assert.Bug-3612 coalesce.Bug-3616 +hexadecimal_literals.Bug-3621 diff --git a/sql/test/BugTracker-2014/Tests/hexadecimal_literals.Bug-3621.sql b/sql/test/BugTracker-2014/Tests/hexadecimal_literals.Bug-3621.sql new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2014/Tests/hexadecimal_literals.Bug-3621.sql @@ -0,0 +1,213 @@ +select 0x0; +select 0x1; +select 0x2; +select 0x3; +select 0x4; +select 0x5; +select 0x6; +select 0x7; +select 0x8; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list