Changeset: 6218f107b2bb for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6218f107b2bb Added Files: sql/test/BugTracker-2020/Tests/remote-table-like.Bug-6641.py sql/test/BugTracker-2020/Tests/remote-table-like.Bug-6641.stable.err sql/test/BugTracker-2020/Tests/remote-table-like.Bug-6641.stable.out Modified Files: sql/server/rel_dump.c sql/server/rel_select.c sql/test/BugTracker-2020/Tests/All Branch: Jun2020 Log Message:
Added test and fix for Bug 6641, ie use the right lists to find the filter function at rel_read. Small cleanup diffs (203 lines): diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c --- a/sql/server/rel_dump.c +++ b/sql/server/rel_dump.c @@ -911,10 +911,22 @@ exp_read(mvc *sql, sql_rel *lrel, sql_re if (!(rexps = read_exps(sql, lrel, rrel, pexps, r, pos, '(', 0))) return NULL; if (filter) { - sql_subfunc *func = sql_find_func(sql->sa, mvc_bind_schema(sql, "sys"), fname, 1+list_length(exps), F_FILT, NULL); - if (!func) + sql_subfunc *func = NULL; + list *tl = sa_list(sql->sa); + + for (node *n = lexps->h; n; n = n->next){ + sql_exp *e = n->data; + + list_append(tl, exp_subtype(e)); + } + for (node *n = rexps->h; n; n = n->next){ + sql_exp *e = n->data; + + list_append(tl, exp_subtype(e)); + } + + if (!(func = sql_bind_func_(sql->sa, mvc_bind_schema(sql, "sys"), fname, tl, F_FILT))) return sql_error(sql, -1, SQLSTATE(42000) "Filter: missing function '%s'\n", fname); - return exp_filter(sql->sa, lexps, rexps, func, anti); } return exp_or(sql->sa, lexps, rexps, anti); diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -1401,20 +1401,16 @@ rel_filter(mvc *sql, sql_rel *rel, list sql_exp *L = l->h->data, *R = r->h->data, *e = NULL; sql_subfunc *f = NULL; sql_schema *s = cur_schema(sql); - list *tl, *exps; - - exps = sa_list(sql->sa); - tl = sa_list(sql->sa); + list *tl = sa_list(sql->sa); + for (n = l->h; n; n = n->next){ sql_exp *e = n->data; - list_append(exps, e); list_append(tl, exp_subtype(e)); } for (n = r->h; n; n = n->next){ sql_exp *e = n->data; - list_append(exps, e); list_append(tl, exp_subtype(e)); } if (sname && !(s = mvc_bind_schema(sql, sname))) @@ -1423,7 +1419,7 @@ rel_filter(mvc *sql, sql_rel *rel, list f = sql_bind_func_(sql->sa, s, filter_op, tl, F_FILT); if (!f) - f = find_func(sql, s, filter_op, list_length(exps), F_FILT, NULL); + f = find_func(sql, s, filter_op, list_length(tl), F_FILT, NULL); if (f) { node *n,*m = f->func->ops->h; list *nexps = sa_list(sql->sa); diff --git a/sql/test/BugTracker-2020/Tests/All b/sql/test/BugTracker-2020/Tests/All --- a/sql/test/BugTracker-2020/Tests/All +++ b/sql/test/BugTracker-2020/Tests/All @@ -15,3 +15,4 @@ select-and.Bug-6878 copy-decimal-with-space.Bug-6917 isauuid.Bug-6934 tpch-cube.Bug-6938 +remote-table-like.Bug-6641 diff --git a/sql/test/BugTracker-2020/Tests/remote-table-like.Bug-6641.py b/sql/test/BugTracker-2020/Tests/remote-table-like.Bug-6641.py new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2020/Tests/remote-table-like.Bug-6641.py @@ -0,0 +1,62 @@ +import os +import socket +import sys +import tempfile +import threading + +import pymonetdb + +try: + from MonetDBtesting import process +except ImportError: + import process + + +# Find a free network port +def freeport(): + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.bind(('', 0)) + port = sock.getsockname()[1] + sock.close() + return port + + +with tempfile.TemporaryDirectory() as farm_dir: + os.mkdir(os.path.join(farm_dir, 'node1')) + os.mkdir(os.path.join(farm_dir, 'node2')) + + node1_port = freeport() + with process.server(mapiport=node1_port, dbname='node1', + dbfarm=os.path.join(farm_dir, 'node1'), + stdin=process.PIPE, stdout=process.PIPE, + stderr=process.PIPE) as node1_proc: + node1_conn = pymonetdb.connect(database='node1', port=node1_port, autocommit=True) + node1_cur = node1_conn.cursor() + + node1_cur.execute("create table remote_data (id int, name varchar(2048))") + node1_cur.execute("insert into remote_data values (1, 'Name 1')") + node1_cur.execute("select * from remote_data") + print(node1_cur.fetchall()) + node1_cur.execute("select * from remote_data where name like 'N%'") + print(node1_cur.fetchall()) + + node2_port = freeport() + with process.server(mapiport=node2_port, dbname='node2', + dbfarm=os.path.join(farm_dir, 'node2'), + stdin=process.PIPE, stdout=process.PIPE, + stderr=process.PIPE) as node2_proc: + node2_conn = pymonetdb.connect(database='node2', port=node2_port, autocommit=True) + node2_cur = node2_conn.cursor() + + node2_cur.execute("create remote table remote_data (id int, name varchar(2048)) on 'mapi:monetdb://localhost:{}/node1/sys/remote_data'".format(node1_port)) + node2_cur.execute("select * from remote_data") + print(node2_cur.fetchall()) + node2_cur.execute("select * from remote_data where name like 'N%'") + print(node2_cur.fetchall()) + + # cleanup: shutdown the monetdb servers and remove tempdir + out, err = node1_proc.communicate() + sys.stderr.write(err) + + out, err = node2_proc.communicate() + sys.stderr.write(err) diff --git a/sql/test/BugTracker-2020/Tests/remote-table-like.Bug-6641.stable.err b/sql/test/BugTracker-2020/Tests/remote-table-like.Bug-6641.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2020/Tests/remote-table-like.Bug-6641.stable.err @@ -0,0 +1,38 @@ +stderr of test 'remote-table-like.Bug-6641` in directory 'sql/test/BugTracker-2020` itself: + + +# 10:29:34 > +# 10:29:34 > "/usr/bin/python3" "remote-table-like.Bug-6641.py" "remote-table-like.Bug-6641" +# 10:29:34 > + +# builtin opt gdk_dbpath = /home/ferreira/repositories/MonetDB-Jun2020/BUILD/var/monetdb5/dbfarm/demo +# builtin opt mapi_port = 50000 +# builtin opt mapi_open = false +# builtin opt mapi_ipv6 = false +# builtin opt mapi_autosense = false +# builtin opt sql_optimizer = default_pipe +# builtin opt sql_debug = 0 +# builtin opt raw_strings = false +# cmdline opt gdk_nr_threads = 0 +# cmdline opt mapi_open = true +# cmdline opt mapi_port = 37609 +# cmdline opt mapi_usock = /var/tmp/mtest-86984/.s.monetdb.37609 +# cmdline opt gdk_dbpath = /tmp/tmph7n3d2d_/node1/node1 +# builtin opt gdk_dbpath = /home/ferreira/repositories/MonetDB-Jun2020/BUILD/var/monetdb5/dbfarm/demo +# builtin opt mapi_port = 50000 +# builtin opt mapi_open = false +# builtin opt mapi_ipv6 = false +# builtin opt mapi_autosense = false +# builtin opt sql_optimizer = default_pipe +# builtin opt sql_debug = 0 +# builtin opt raw_strings = false +# cmdline opt gdk_nr_threads = 0 +# cmdline opt mapi_open = true +# cmdline opt mapi_port = 37745 +# cmdline opt mapi_usock = /var/tmp/mtest-86984/.s.monetdb.37745 +# cmdline opt gdk_dbpath = /tmp/tmph7n3d2d_/node2/node2 + +# 10:29:37 > +# 10:29:37 > "Done." +# 10:29:37 > + diff --git a/sql/test/BugTracker-2020/Tests/remote-table-like.Bug-6641.stable.out b/sql/test/BugTracker-2020/Tests/remote-table-like.Bug-6641.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2020/Tests/remote-table-like.Bug-6641.stable.out @@ -0,0 +1,16 @@ +stdout of test 'remote-table-like.Bug-6641` in directory 'sql/test/BugTracker-2020` itself: + + +# 10:29:34 > +# 10:29:34 > "/usr/bin/python3" "remote-table-like.Bug-6641.py" "remote-table-like.Bug-6641" +# 10:29:34 > + +[(1, 'Name 1')] +[(1, 'Name 1')] +[(1, 'Name 1')] +[(1, 'Name 1')] + +# 10:29:37 > +# 10:29:37 > "Done." +# 10:29:37 > + _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list