Changeset: e56aa53454b1 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e56aa53454b1 Added Files: sql/test/BugTracker-2019/Tests/select-char.Bug-6761.stable.err sql/test/BugTracker-2019/Tests/select-char.Bug-6761.stable.out Modified Files: sql/backends/monet5/rel_bin.c sql/server/rel_optimizer.c sql/test/BugTracker-2019/Tests/select-char.Bug-6761.sql Branch: Apr2019 Log Message:
Fix for bug 6761 (.i.e. at MAL code generation, we don't need to convert between string types) diffs (238 lines): diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c --- a/sql/backends/monet5/rel_bin.c +++ b/sql/backends/monet5/rel_bin.c @@ -497,6 +497,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l } break; case e_convert: { /* if input is type any NULL or column of nulls, change type */ + sql_exp *ll = (sql_exp *) e->l; list *tps = e->r; sql_subtype *from = tps->h->data; sql_subtype *to = tps->h->next->data; @@ -505,11 +506,16 @@ exp_bin(backend *be, sql_exp *e, stmt *l if (from->type->localtype == 0) { l = stmt_atom(be, atom_general(sql->sa, to, NULL)); } else { - l = exp_bin(be, e->l, left, right, grp, ext, cnt, sel); + l = exp_bin(be, ll, left, right, grp, ext, cnt, sel); } - if (!l) + if (!l) return NULL; - s = stmt_convert(be, l, from, to, sel); + /* if attempting to convert between strings, no conversion is needed */ + if (ll->type == e_column && EC_VARCHAR(from->type->eclass) && EC_VARCHAR(to->type->eclass)) { + s = l; + } else { + s = stmt_convert(be, l, from, to, sel); + } } break; case e_func: { node *en; diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c --- a/sql/server/rel_optimizer.c +++ b/sql/server/rel_optimizer.c @@ -7739,7 +7739,7 @@ rel_reduce_casts(int *changes, mvc *sql, } } } - n->data = e; + n->data = e; } } return rel; diff --git a/sql/test/BugTracker-2019/Tests/select-char.Bug-6761.sql b/sql/test/BugTracker-2019/Tests/select-char.Bug-6761.sql --- a/sql/test/BugTracker-2019/Tests/select-char.Bug-6761.sql +++ b/sql/test/BugTracker-2019/Tests/select-char.Bug-6761.sql @@ -403,5 +403,7 @@ 2019-09-17 "EMLDU" "EMLDU" "Inter-Region 2019-09-17 "EMLDU" "EMLDU" "Inter-Region" "Hybrid" "Investment" "Bullish" "Directional" "EMLDU" "Un-Assigned(0)" "Emerging Europe" "Czech Republic" "CZK" "IR/Currency Swap" "IRS_SLYLSSJS9" "ZZZ" 2024-08-08 "Steinberg Bernard" "Trading" "CZK PFL RFI 1.395 080819-080824 (SLYLSSJS9)" "Fixed Income" "IR/Currency Swap" 500025138 "" "EMLDU" "" "CZK" 76 "1" "0" "500025138|EMLDU|EMLDU|Bernard Steinberg|76" "1" 95393837.75 NULL NULL NULL NULL " " "" "" "" " " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "COSLYLSSJS" "" "" "" "" "" "" "" "" "" "" "" "Rates" "BPUSD" NULL NULL "Deutsche Bank AG, London" "" "" "" "" "Bernard Steinberg" NULL "500025138" "Y" "N" "N" "N" "N" "N" "N" "N" "N" -600.27 0.00 1865.62 NULL NULL NULL NULL NULL NULL 1865.62 NULL NULL 0.00 NULL 1865.53 0.00 -72.00 -97.44 5.32 11.56 17.09 225.65 1775.35 0.00 0.00 0.00 1.15 NULL NULL NULL NULL NULL NULL 1.15 NULL NULL NULL NULL 0.97 0.00 -0.01 -0.01 0.00 0.00 0.01 0.04 0.94 0.00 0.00 0.00 NULL NULL NULL NULL NULL 0.00 0.00 0. 00 0.00 0.00 60027.46 569971.00 60027.46 569971.00 "20190917121752" 2019-09-17 "GOSP" "GOSP" "LatAm" "Hybrid" "Special" "Bullish" "Directional" "PRISMA" "Falkinhoff Maria" "Latin America" "Guatemala" "USD" "Equity" "AEI" "Utilities" 2036-01-01 "Gutierrez Miguel" "Trading" "Ashmore Energy Int." "Equity" "Equity" 500009948 "" "PRISMA" "" "USD" 196 "1" "0" "500009948|PRISMA|PRISMA|Miguel Gutierrez|196" "1" 8226438.00 NULL NULL NULL NULL " " "" "" "" " " "" "" "" "" "" "" "" "" "" "" "" "null N/A" "" "" "" "EQ0528222901189271" "" "" "" "" "" "" "" "" "" "" "" "Equity" "PercentageOfADV" NULL NULL "ZIDE9" "" "" "" "" "Miguel Gutierrez" NULL "500009948" "Y" "N" "N" "N" "N" "N" "N" "N" "N" 0.00 0.00 0.00 0.00 NULL NULL NULL NULL NULL NULL NULL NULL 0.00 NULL 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 NULL NULL NULL NULL NULL 0.00 0.00 0.00 0.00 0.00 4919581.50 4919581.50 4919581.50 4919581.50 "20190917121752" +select fundid from actual_positionmart_pfx_intraday_test where fundid = 10 and currencyexposed <> 'TOTAL'; +select fundid from actual_positionmart_pfx_intraday_test where fundid = 10 and currencyexposed = 'TOTAL'; select fundid, CAST(sum(fxcurdlttot) AS BIGINT) as fxcurdlttotfx from actual_positionmart_pfx_intraday_test where asofdate='2019-09-11' and fundid = 10 and currencyexposed <> 'TOTAL' group by fundid; ROLLBACK; diff --git a/sql/test/BugTracker-2019/Tests/select-char.Bug-6761.stable.err b/sql/test/BugTracker-2019/Tests/select-char.Bug-6761.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2019/Tests/select-char.Bug-6761.stable.err @@ -0,0 +1,33 @@ +stderr of test 'select-char.Bug-6761` in directory 'sql/test/BugTracker-2019` itself: + + +# 10:56:46 > +# 10:56:46 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=39102" "--set" "mapi_usock=/var/tmp/mtest-25170/.s.monetdb.39102" "--set" "monet_prompt=" "--forcemito" "--dbpath=/home/ferreira/repositories/MonetDB-Apr2019/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2019" "--set" "embedded_c=true" +# 10:56:46 > + +# 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 = 39102 +# cmdline opt mapi_usock = /var/tmp/mtest-25170/.s.monetdb.39102 +# 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 +#main thread:!ERROR:MALException:client.quit:Server stopped + +# 10:56:46 > +# 10:56:46 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-25170" "--port=39102" +# 10:56:46 > + + +# 10:56:46 > +# 10:56:46 > "Done." +# 10:56:46 > + diff --git a/sql/test/BugTracker-2019/Tests/select-char.Bug-6761.stable.out b/sql/test/BugTracker-2019/Tests/select-char.Bug-6761.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2019/Tests/select-char.Bug-6761.stable.out @@ -0,0 +1,141 @@ +stdout of test 'select-char.Bug-6761` in directory 'sql/test/BugTracker-2019` itself: + + +# 10:56:46 > +# 10:56:46 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=39102" "--set" "mapi_usock=/var/tmp/mtest-25170/.s.monetdb.39102" "--set" "monet_prompt=" "--forcemito" "--dbpath=/home/ferreira/repositories/MonetDB-Apr2019/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2019" "--set" "embedded_c=true" +# 10:56:46 > + +# MonetDB 5 server v11.33.12 (hg id: 11f022e6b68c+) +# 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:39102/ +# Listening for UNIX domain connection requests on mapi:monetdb:///var/tmp/mtest-25170/.s.monetdb.39102 +# MonetDB/GIS module loaded +# MonetDB/SQL module loaded + +Ready. + +# 10:56:46 > +# 10:56:46 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-25170" "--port=39102" +# 10:56:46 > + +#START TRANSACTION; +#CREATE TABLE "sys"."actual_positionmart_pfx_intraday_test" ( +# "asofdate" DATE, +# "fundcode" VARCHAR(50), +# "fundname" VARCHAR(50), +# "riceregion" VARCHAR(50), +# "riceassetclass" VARCHAR(30), +# "ricestrattype" VARCHAR(50), +# "ricebias" VARCHAR(50), +# "ricestyle" VARCHAR(30), +# "ricestrategy" VARCHAR(120), +# "primaryresearchername" VARCHAR(100), +#COPY 245 RECORDS INTO "sys"."actual_positionmart_pfx_intraday_test" FROM stdin USING DELIMITERS E'\t',E'\n','"'; +#2019-09-17 "LCOF" "LCOF" "LatAm" "Equity" "Investment" "Bullish" "Directional" "CHILEQ" "Un-Assigned(0)" "Latin America" "Chile" "USD" "Equity" "ECH" "*None*" 2036-01-01 "Mosca Guido" "Trading" "ISHARES MSCI CHILE ETF (BAT)" "Equity" "Equity" 12833911 "" "CHILEQ" "" "USD" 10 "1" "0" "12833911|CHILEQ|CHILEQ|Guido Mosca|10" "1" 15929779.00 NULL NULL NULL NULL "US" "" "" "" "US" "" "" "" "" "" "" "" "" "" "" "" "ISHARES MSCI CHILE ETF" "" "" "" "EQ0000000005066100" "" "" "" "" "" "" "" "" "" "" "" "Equity" "PercentageOfADV" NULL NULL "Interactive Brokers" "US4642866408" "" "B29FC81" "" "Guido Mosca" NULL "12833911" "Y" "N" "N" "N" "N" "N" "N" "N" "N" 0.00 0.00 0.00 0.00 NULL NULL NULL NULL NULL NULL NULL NULL 0.00 NULL 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 NULL NULL NULL NULL NULL 0.00 0.00 0.00 0.00 0.00 94925.00 94925.00 94925.00 94925.00 "201 90917121751" +[ 245 ] +#select fundid from actual_positionmart_pfx_intraday_test where fundid = 10 and currencyexposed <> 'TOTAL'; +% sys.actual_positionmart_pfx_intraday_test # table_name +% fundid # name +% int # type +% 2 # length +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +[ 10 ] +#select fundid from actual_positionmart_pfx_intraday_test where fundid = 10 and currencyexposed = 'TOTAL'; +% sys.actual_positionmart_pfx_intraday_test # table_name +% fundid # name +% int # type +% 1 # length +#select fundid, CAST(sum(fxcurdlttot) AS BIGINT) as fxcurdlttotfx from actual_positionmart_pfx_intraday_test where asofdate='2019-09-11' and fundid = 10 and currencyexposed <> 'TOTAL' group by fundid; +% sys.actual_positionmart_pfx_intraday_test, sys.L5 # table_name +% fundid, fxcurdlttotfx # name +% int, bigint # type +% 1, 1 # length +#ROLLBACK; + +# 10:56:46 > +# 10:56:46 > "Done." +# 10:56:46 > + _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list