Changeset: dac95afa6436 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=dac95afa6436
Added Files:
sql/test/BugTracker-2018/Tests/update-transaction-select.Bug-6649.sql
sql/test/BugTracker-2018/Tests/update-transaction-select.Bug-6649.stable.err
sql/test/BugTracker-2018/Tests/update-transaction-select.Bug-6649.stable.out
Modified Files:
clients/mapiclient/ReadlineTools.c
sql/backends/monet5/sql.c
sql/test/BugTracker-2018/Tests/All
Branch: default
Log Message:
Merge with Aug2018 branch.
diffs (truncated from 324 to 300 lines):
diff --git a/clients/mapiclient/ReadlineTools.c
b/clients/mapiclient/ReadlineTools.c
--- a/clients/mapiclient/ReadlineTools.c
+++ b/clients/mapiclient/ReadlineTools.c
@@ -136,7 +136,7 @@ sql_completion(const char *text, int sta
/* The MAL completion help */
-static char *mal_commands[] = {
+static const char *mal_commands[] = {
"address",
"atom",
"barrier",
@@ -209,7 +209,8 @@ mal_command_generator(const char *text,
static int64_t seekpos, rowcount;
static size_t len;
static MapiHdl table_hdl;
- char *name, *buf;
+ const char *name;
+ char *buf;
/* we pick our own portion of the linebuffer */
text = rl_line_buffer + strlen(rl_line_buffer) - 1;
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -1768,58 +1768,42 @@ DELTAproject(bat *result, const bat *sub
}
if (BATcount(u_val)) {
- BAT *o, *nu_id, *nu_val;
- /* create subsets of u_id and u_val where the tail
- * values of u_id are also in s, and where those tail
- * values occur as head value in res */
- if ((o = BATintersect(u_id, s, NULL, NULL, false, BUN_NONE)) ==
NULL) {
+ BAT *os, *ou;
+ /* figure out the positions in res that we have to
+ * replace with values from u_val */
+ if (BATsemijoin(&ou, &os, u_id, s, NULL, NULL, false, BUN_NONE)
!= GDK_SUCCEED) {
BBPunfix(s->batCacheid);
BBPunfix(res->batCacheid);
BBPunfix(u_id->batCacheid);
BBPunfix(u_val->batCacheid);
throw(MAL, "sql.delta", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
}
- nu_id = BATproject(o, u_id);
- nu_val = BATproject(o, u_val);
- BBPunfix(u_id->batCacheid);
- BBPunfix(u_val->batCacheid);
- BBPunfix(o->batCacheid);
- tres = BATdense(res->hseqbase, res->hseqbase, BATcount(res));
- if (nu_id == NULL ||
- nu_val == NULL ||
- tres == NULL ||
- (o = BATintersect(nu_id, tres, NULL, NULL, false,
BUN_NONE)) == NULL) {
- BBPunfix(s->batCacheid);
- BBPunfix(res->batCacheid);
- BBPreclaim(nu_id);
- BBPreclaim(nu_val);
- BBPreclaim(tres);
- throw(MAL, "sql.delta", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
+ /* BATcount(ou) == BATcount(os) */
+ if (BATcount(ou) != 0) {
+ /* ou contains the position in u_id/u_val that
+ * contain the new values */
+ BAT *nu_val = BATproject(ou, u_val);
+ BBPunfix(ou->batCacheid);
+ /* os contains the corresponding positions in
+ * res that need to be replaced with those new
+ * values */
+ if ((res = setwritable(res)) == NULL ||
+ BATreplace(res, os, nu_val, false) != GDK_SUCCEED) {
+ if (res)
+ BBPunfix(res->batCacheid);
+ BBPunfix(os->batCacheid);
+ BBPunfix(s->batCacheid);
+ BBPunfix(u_id->batCacheid);
+ BBPunfix(u_val->batCacheid);
+ BBPunfix(nu_val->batCacheid);
+ throw(MAL, "sql.delta", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
+ }
+ BBPunfix(nu_val->batCacheid);
+ } else {
+ /* nothing to replace */
+ BBPunfix(ou->batCacheid);
}
- BBPunfix(tres->batCacheid);
- u_id = BATproject(o, nu_id);
- u_val = BATproject(o, nu_val);
- BBPunfix(nu_id->batCacheid);
- BBPunfix(nu_val->batCacheid);
- BBPunfix(o->batCacheid);
- if (u_id == NULL || u_val == NULL) {
- BBPunfix(s->batCacheid);
- BBPunfix(res->batCacheid);
- BBPreclaim(u_id);
- BBPreclaim(u_val);
- throw(MAL, "sql.delta", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
- }
- /* now update res with the subset of u_id and u_val we
- * calculated */
- if ((res = setwritable(res)) == NULL ||
- BATreplace(res, u_id, u_val, false) != GDK_SUCCEED) {
- if (res)
- BBPunfix(res->batCacheid);
- BBPunfix(s->batCacheid);
- BBPunfix(u_id->batCacheid);
- BBPunfix(u_val->batCacheid);
- throw(MAL, "sql.delta", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
- }
+ BBPunfix(os->batCacheid);
}
BBPunfix(s->batCacheid);
BBPunfix(u_id->batCacheid);
diff --git a/sql/test/BugTracker-2018/Tests/All
b/sql/test/BugTracker-2018/Tests/All
--- a/sql/test/BugTracker-2018/Tests/All
+++ b/sql/test/BugTracker-2018/Tests/All
@@ -84,3 +84,4 @@ crash-after-call-non-existing-loader
timestamp-as-boolean.Bug-6642
timestamp-roundtrip.Bug-6640
convert-key.Bug-6648
+update-transaction-select.Bug-6649
diff --git
a/sql/test/BugTracker-2018/Tests/update-transaction-select.Bug-6649.sql
b/sql/test/BugTracker-2018/Tests/update-transaction-select.Bug-6649.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2018/Tests/update-transaction-select.Bug-6649.sql
@@ -0,0 +1,28 @@
+start transaction;
+create table updating (a int);
+insert into updating values (1), (2);
+update updating set a = 3 where a = 2;
+select a from updating where a = 3;
+rollback;
+
+create table updating (a int);
+insert into updating values (2);
+start transaction;
+update updating set a = 3 where a = 2;
+select a from updating where a = 3;
+rollback;
+
+truncate updating;
+insert into updating values (1), (1);
+start transaction;
+update updating set a = 3 where a = 2;
+select a from updating where a = 3;
+rollback;
+
+truncate updating;
+insert into updating values (1), (2);
+start transaction;
+update updating set a = 3 where a = 2;
+select a from updating where a = 3;
+rollback;
+drop table updating;
diff --git
a/sql/test/BugTracker-2018/Tests/update-transaction-select.Bug-6649.stable.err
b/sql/test/BugTracker-2018/Tests/update-transaction-select.Bug-6649.stable.err
new file mode 100644
--- /dev/null
+++
b/sql/test/BugTracker-2018/Tests/update-transaction-select.Bug-6649.stable.err
@@ -0,0 +1,35 @@
+stderr of test 'update-transaction-select.Bug-6649` in directory
'sql/test/BugTracker-2018` itself:
+
+
+# 14:20:45 >
+# 14:20:45 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=31957" "--set"
"mapi_usock=/var/tmp/mtest-3236/.s.monetdb.31957" "--set" "monet_prompt="
"--forcemito"
"--dbpath=/home/ferreira/repositories/MonetDB-Aug2018/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2018"
"--set" "embedded_c=true"
+# 14:20:45 >
+
+# builtin opt gdk_dbpath =
/home/ferreira/repositories/MonetDB-Aug2018/BUILD/var/monetdb5/dbfarm/demo
+# builtin opt gdk_debug = 0
+# builtin opt gdk_vmtrim = no
+# 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 = 31957
+# cmdline opt mapi_usock = /var/tmp/mtest-3236/.s.monetdb.31957
+# cmdline opt monet_prompt =
+# cmdline opt gdk_dbpath =
/home/ferreira/repositories/MonetDB-Aug2018/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2018
+# cmdline opt embedded_c = true
+# cmdline opt gdk_debug = 553648138
+
+# 14:20:45 >
+# 14:20:45 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-3236" "--port=31957"
+# 14:20:45 >
+
+
+# 14:20:46 >
+# 14:20:46 > "Done."
+# 14:20:46 >
+
diff --git
a/sql/test/BugTracker-2018/Tests/update-transaction-select.Bug-6649.stable.out
b/sql/test/BugTracker-2018/Tests/update-transaction-select.Bug-6649.stable.out
new file mode 100644
--- /dev/null
+++
b/sql/test/BugTracker-2018/Tests/update-transaction-select.Bug-6649.stable.out
@@ -0,0 +1,125 @@
+stdout of test 'update-transaction-select.Bug-6649` in directory
'sql/test/BugTracker-2018` itself:
+
+
+# 14:20:45 >
+# 14:20:45 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=31957" "--set"
"mapi_usock=/var/tmp/mtest-3236/.s.monetdb.31957" "--set" "monet_prompt="
"--forcemito"
"--dbpath=/home/ferreira/repositories/MonetDB-Aug2018/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2018"
"--set" "embedded_c=true"
+# 14:20:45 >
+
+# MonetDB 5 server v11.31.8
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2018', using 8 threads
+# Compiled for x86_64-pc-linux-gnu/64bit with 128bit integers
+# Found 15.492 GiB available main-memory.
+# Copyright (c) 1993 - July 2008 CWI.
+# Copyright (c) August 2008 - 2018 MonetDB B.V., all rights reserved
+# Visit https://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://wired-142.cwi.nl:31957/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-3236/.s.monetdb.31957
+# 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.
+
+# 14:20:45 >
+# 14:20:45 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-3236" "--port=31957"
+# 14:20:45 >
+
+#start transaction;
+#create table updating (a int);
+#insert into updating values (1), (2);
+[ 2 ]
+#update updating set a = 3 where a = 2;
+[ 1 ]
+#select a from updating where a = 3;
+% sys.updating # table_name
+% a # name
+% int # type
+% 1 # length
+[ 3 ]
+#rollback;
+#create table updating (a int);
+#insert into updating values (2);
+[ 1 ]
+#start transaction;
+#update updating set a = 3 where a = 2;
+[ 1 ]
+#select a from updating where a = 3;
+% sys.updating # table_name
+% a # name
+% int # type
+% 1 # length
+[ 3 ]
+#rollback;
+#truncate updating;
+[ 1 ]
+#insert into updating values (1), (1);
+[ 2 ]
+#start transaction;
+#update updating set a = 3 where a = 2;
+[ 0 ]
+#select a from updating where a = 3;
+% sys.updating # table_name
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list