Changeset: b4673eacf027 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b4673eacf027 Added Files: sql/test/mergetables/Tests/transaction-conflict.stable.err sql/test/mergetables/Tests/transaction-conflict.stable.out Modified Files: sql/common/sql_list.c sql/include/sql_catalog.h sql/storage/store.c sql/test/analytics/Tests/analytics01.sql sql/test/analytics/Tests/analytics01.stable.out sql/test/mergetables/Tests/transaction-conflict.py Branch: default Log Message:
Merge with Nov2019 diffs (truncated from 329 to 300 lines): diff --git a/sql/common/sql_list.c b/sql/common/sql_list.c --- a/sql/common/sql_list.c +++ b/sql/common/sql_list.c @@ -318,6 +318,7 @@ list_remove_node(list *l, node *n) MT_lock_unset(&l->ht_lock); node_destroy(l, n); l->cnt--; + assert(l->cnt >= 0); return p; } diff --git a/sql/include/sql_catalog.h b/sql/include/sql_catalog.h --- a/sql/include/sql_catalog.h +++ b/sql/include/sql_catalog.h @@ -364,13 +364,13 @@ typedef enum sql_ftype { F_LOADER = 7 } sql_ftype; -#define IS_FUNC(f) (f->type == F_FUNC) -#define IS_PROC(f) (f->type == F_PROC) -#define IS_AGGR(f) (f->type == F_AGGR) -#define IS_FILT(f) (f->type == F_FILT) -#define IS_UNION(f) (f->type == F_UNION) -#define IS_ANALYTIC(f) (f->type == F_ANALYTIC) -#define IS_LOADER(f) (f->type == F_LOADER) +#define IS_FUNC(f) ((f)->type == F_FUNC) +#define IS_PROC(f) ((f)->type == F_PROC) +#define IS_AGGR(f) ((f)->type == F_AGGR) +#define IS_FILT(f) ((f)->type == F_FILT) +#define IS_UNION(f) ((f)->type == F_UNION) +#define IS_ANALYTIC(f) ((f)->type == F_ANALYTIC) +#define IS_LOADER(f) ((f)->type == F_LOADER) typedef enum sql_flang { FUNC_LANG_INT = 0, /* internal */ diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -1155,7 +1155,7 @@ load_schema(sql_trans *tr, sqlid id, oid type_id = find_sql_column(types, "id"); rs = table_funcs.rids_select(tr, type_schema, &s->base.id, &s->base.id, type_id, &tmpid, NULL, NULL); for (rid = table_funcs.rids_next(rs); !is_oid_nil(rid); rid = table_funcs.rids_next(rs)) - cs_add(&s->types, load_type(tr, s, rid), 0); + cs_add(&s->types, load_type(tr, s, rid), 0); table_funcs.rids_destroy(rs); /* second tables */ @@ -1703,7 +1703,6 @@ bootstrap_create_table(sql_trans *tr, sq return t; } - static sql_schema * bootstrap_create_schema(sql_trans *tr, char *name, sqlid auth_id, int owner) { @@ -2201,7 +2200,6 @@ store_exit(void) store_initialized=0; } - /* call locked! */ int store_apply_deltas(bool not_locked) @@ -2340,7 +2338,6 @@ idle_manager(void) } } - void store_lock(void) { @@ -3032,7 +3029,6 @@ sql_trans_copy_part( sql_trans *tr, sql_ { sql_schema *syss = find_sql_schema(tr, isGlobal(t)?"sys":"tmp"); sql_table *sysic = find_sql_table(syss, "objects"); - node *n; sql_part *npt = SA_ZNEW(tr->sa, sql_part); base_init(tr->sa, &npt->base, pt->base.id, TR_NEW, npt->base.name); @@ -3041,7 +3037,7 @@ sql_trans_copy_part( sql_trans *tr, sql_ npt->with_nills = pt->with_nills; npt->t = t; - assert(!npt->t || isMergeTable(npt->t) || isReplicaTable(npt->t)); + assert(isMergeTable(npt->t) || isReplicaTable(npt->t)); if (isRangePartitionTable(t)) { npt->part.range.minvalue = sa_alloc(tr->sa, pt->part.range.minlength); npt->part.range.maxvalue = sa_alloc(tr->sa, pt->part.range.maxlength); @@ -3051,7 +3047,7 @@ sql_trans_copy_part( sql_trans *tr, sql_ npt->part.range.maxlength = pt->part.range.maxlength; } else if (isListPartitionTable(t)) { npt->part.values = list_new(tr->sa, (fdestroy) NULL); - for (n = pt->part.values->h ; n ; n = n->next) { + for (node *n = pt->part.values->h ; n ; n = n->next) { sql_part_value *prev = (sql_part_value*) n->data, *nextv = SA_ZNEW(tr->sa, sql_part_value); nextv->tpe = prev->tpe; nextv->value = sa_alloc(tr->sa, prev->length); @@ -3077,7 +3073,6 @@ trigger_dup(sql_trans *tr, int flags, sq { sql_allocator *sa = (newFlagSet(flags))?tr->parent->sa:tr->sa; sql_trigger *nt = SA_ZNEW(sa, sql_trigger); - node *n; base_init(sa, &nt->base, i->base.id, tr_flag(&i->base, flags), i->base.name); @@ -3095,7 +3090,7 @@ trigger_dup(sql_trans *tr, int flags, sq nt->condition = sa_strdup(sa, i->condition); nt->statement = sa_strdup(sa, i->statement); - for (n = i->columns->h; n; n = n->next) { + for (node *n = i->columns->h; n; n = n->next) { sql_kc *okc = n->data; list_append(nt->columns, kc_dup(tr, flags, okc, t)); @@ -5915,6 +5910,7 @@ sql_trans_del_table(sql_trans *tr, sql_t sql_table *sysobj = find_sql_table(syss, "objects"); node *n = cs_find_name(&mt->members, pt->base.name); oid obj_oid = table_funcs.column_find_row(tr, find_sql_column(sysobj, "nr"), &pt->base.id, NULL), rid; + sql_part *p = (sql_part*) n->data; if (is_oid_nil(obj_oid)) return NULL; @@ -5936,7 +5932,7 @@ sql_trans_del_table(sql_trans *tr, sql_t /* merge table depends on part table */ sql_trans_drop_dependency(tr, pt->base.id, mt->base.id, TABLE_DEPENDENCY); - cs_del(&mt->members, n, pt->base.flags); + cs_del(&mt->members, n, p->base.flags); pt->p = NULL; table_funcs.table_delete(tr, sysobj, obj_oid); diff --git a/sql/test/analytics/Tests/analytics01.sql b/sql/test/analytics/Tests/analytics01.sql --- a/sql/test/analytics/Tests/analytics01.sql +++ b/sql/test/analytics/Tests/analytics01.sql @@ -238,6 +238,34 @@ select col1, col2, lag(col2) over (parti select lag(col2, -1) over (partition by col1 ORDER BY col2), lag(col2, 1) over (partition by col1 ORDER BY col2), lag(col2, 2) over (partition by col1 ORDER BY col2) from t1; select lead(col2, -1) over (partition by col1 ORDER BY col2), lead(col2, 1) over (partition by col1 ORDER BY col2), lead(col2, 2) over (partition by col1 ORDER BY col2) from t1; +CREATE TABLE "sys"."test1" ( + "name" VARCHAR(100), + "points" DOUBLE, + "start_time" TIMESTAMP +); +COPY 8 RECORDS INTO "sys"."test1" FROM stdin USING DELIMITERS E'\t',E'\n','"'; +"Hello" 20 "2017-12-01 00:00:00.000000" +"Hello" 40 "2017-12-01 01:00:00.000000" +"Hello" 60 "2017-12-01 00:00:00.000000" +"World" 10 "2017-12-01 00:00:00.000000" +"World" 50 "2017-12-01 01:00:00.000000" +"World" 90 "2017-12-01 00:00:00.000000" +"World" 11 "2017-12-02 01:02:00.000000" +"World" 15 "2017-12-02 02:02:00.000000" + +SELECT CAST(t0.start_time AS DATE) AS start_time, +FIRST_VALUE(t0.points) OVER (PARTITION BY CAST(t0.start_time AS DATE) ORDER BY t0.start_time) AS first_point, +LAST_VALUE(t0.points) OVER (PARTITION BY CAST(t0.start_time AS DATE) ORDER BY t0.start_time) AS last_point +FROM test1 t0 +WHERE (t0.start_time >= '2017/12/01 00:00:00' AND t0.start_time <= '2017/12/02 00:00:00'); + +SELECT DISTINCT CAST(t0.start_time AS DATE) AS start_time, +FIRST_VALUE(t0.points) OVER (PARTITION BY CAST(t0.start_time AS DATE) ORDER BY t0.start_time) AS first_point, +LAST_VALUE(t0.points) OVER (PARTITION BY CAST(t0.start_time AS DATE) ORDER BY t0.start_time) AS last_point +FROM test1 t0 +WHERE (t0.start_time >= '2017/12/01 00:00:00' AND t0.start_time <= '2017/12/02 00:00:00'); + + rollback; select lag(null, aa) over () from analytics; --error diff --git a/sql/test/analytics/Tests/analytics01.stable.out b/sql/test/analytics/Tests/analytics01.stable.out --- a/sql/test/analytics/Tests/analytics01.stable.out +++ b/sql/test/analytics/Tests/analytics01.stable.out @@ -2850,6 +2850,47 @@ stdout of test 'analytics01` in director [ NULL, 1, 2 ] [ 0, 2, NULL ] [ 1, NULL, NULL ] +#CREATE TABLE "sys"."test1" ( +# "name" VARCHAR(100), +# "points" DOUBLE, +# "start_time" TIMESTAMP +#); +#COPY 8 RECORDS INTO "sys"."test1" FROM stdin USING DELIMITERS E'\t',E'\n','"'; +#"Hello" 20 "2017-12-01 00:00:00.000000" +#"Hello" 40 "2017-12-01 01:00:00.000000" +#"Hello" 60 "2017-12-01 00:00:00.000000" +#"World" 10 "2017-12-01 00:00:00.000000" +#"World" 50 "2017-12-01 01:00:00.000000" +#"World" 90 "2017-12-01 00:00:00.000000" +#"World" 11 "2017-12-02 01:02:00.000000" +#"World" 15 "2017-12-02 02:02:00.000000" +[ 8 ] +#SELECT CAST(t0.start_time AS DATE) AS start_time, +#FIRST_VALUE(t0.points) OVER (PARTITION BY CAST(t0.start_time AS DATE) ORDER BY t0.start_time) AS first_point, +#LAST_VALUE(t0.points) OVER (PARTITION BY CAST(t0.start_time AS DATE) ORDER BY t0.start_time) AS last_point +#FROM test1 t0 +#WHERE (t0.start_time >= '2017/12/01 00:00:00' AND t0.start_time <= '2017/12/02 00:00:00'); +% sys.L2, sys.L7, sys.L13 # table_name +% start_time, first_point, last_point # name +% date, double, double # type +% 10, 24, 24 # length +[ 2017-12-01, 20, 90 ] +[ 2017-12-01, 20, 90 ] +[ 2017-12-01, 20, 90 ] +[ 2017-12-01, 20, 90 ] +[ 2017-12-01, 20, 50 ] +[ 2017-12-01, 20, 50 ] +#SELECT DISTINCT CAST(t0.start_time AS DATE) AS start_time, +#FIRST_VALUE(t0.points) OVER (PARTITION BY CAST(t0.start_time AS DATE) ORDER BY t0.start_time) AS first_point, +#LAST_VALUE(t0.points) OVER (PARTITION BY CAST(t0.start_time AS DATE) ORDER BY t0.start_time) AS last_point +#FROM test1 t0 +#WHERE (t0.start_time >= '2017/12/01 00:00:00' AND t0.start_time <= '2017/12/02 00:00:00'); +% sys.L2, sys.L7, sys.L13 # table_name +% start_time, first_point, last_point # name +% date, double, double # type +% 10, 24, 24 # length +[ 2017-12-01, 20, 90 ] +[ 2017-12-01, 20, 50 ] #rollback; #drop table analytics; diff --git a/sql/test/mergetables/Tests/transaction-conflict.py b/sql/test/mergetables/Tests/transaction-conflict.py --- a/sql/test/mergetables/Tests/transaction-conflict.py +++ b/sql/test/mergetables/Tests/transaction-conflict.py @@ -66,7 +66,6 @@ cursor.execute(""" START TRANSACTION; DROP TABLE "mt"; DROP TABLE "part"; -DROP TABLE "dummy"; COMMIT; """) diff --git a/sql/test/mergetables/Tests/transaction-conflict.stable.err b/sql/test/mergetables/Tests/transaction-conflict.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/mergetables/Tests/transaction-conflict.stable.err @@ -0,0 +1,24 @@ +stderr of test 'transaction-conflict` in directory 'sql/test/mergetables` itself: + + +# 09:38:29 > +# 09:38:29 > "/usr/bin/python3" "transaction-conflict.py" "transaction-conflict" +# 09:38:29 > + +# builtin opt gdk_dbpath = /home/ferreira/repositories/MonetDB-Nov2019/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 +# cmdline opt gdk_nr_threads = 0 +# cmdline opt mapi_open = true +# cmdline opt mapi_port = 38130 +# cmdline opt mapi_usock = /var/tmp/mtest-42574/.s.monetdb.38130 +# cmdline opt gdk_dbpath = /home/ferreira/repositories/MonetDB-Nov2019/BUILD/var/MonetDB/mTests_sql_test_mergetables + +# 09:38:31 > +# 09:38:31 > "Done." +# 09:38:31 > + diff --git a/sql/test/mergetables/Tests/transaction-conflict.stable.out b/sql/test/mergetables/Tests/transaction-conflict.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/mergetables/Tests/transaction-conflict.stable.out @@ -0,0 +1,64 @@ +stdout of test 'transaction-conflict` in directory 'sql/test/mergetables` itself: + + +# 09:38:29 > +# 09:38:29 > "/usr/bin/python3" "transaction-conflict.py" "transaction-conflict" +# 09:38:29 > + +# MonetDB 5 server v11.35.4 (hg id: fa6ec6bdafb1) +# This is an unreleased version +# Serving database 'mTests_sql_test_mergetables', using 8 threads +# Compiled for x86_64-pc-linux-gnu/64bit with 128bit integers +# Found 15.504 GiB available main-memory of which we use 12.635 GiB +# 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:38130/ +# Listening for UNIX domain connection requests on mapi:monetdb:///var/tmp/mtest-42574/.s.monetdb.38130 +# 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: 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 _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list