Changeset: 7dda8d397726 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/7dda8d397726
Modified Files:
        sql/server/rel_exp.c
        sql/server/rel_optimize_sel.c
        sql/storage/bat/bat_storage.c
Branch: default
Log Message:

Merge with Aug2024 branch.


diffs (159 lines):

diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -1419,11 +1419,19 @@ exp_match_exp_semantics( sql_exp *e1, sq
 {
        if (exp_match(e1, e2))
                return 1;
-       if (is_ascending(e1) != is_ascending(e2) || nulls_last(e1) != 
nulls_last(e2) || zero_if_empty(e1) != zero_if_empty(e2) ||
-               need_no_nil(e1) != need_no_nil(e2) || is_anti(e1) != 
is_anti(e2) || (semantics && is_semantics(e1) != is_semantics(e2)) ||
+
+       if (is_ascending(e1) != is_ascending(e2) ||
+               nulls_last(e1) != nulls_last(e2) ||
+               zero_if_empty(e1) != zero_if_empty(e2) ||
+               need_no_nil(e1) != need_no_nil(e2) ||
+               is_anti(e1) != is_anti(e2) ||
+               (semantics && is_semantics(e1) != is_semantics(e2)) ||
                (semantics && is_any(e1) != is_any(e2)) ||
-               is_symmetric(e1) != is_symmetric(e2) || is_unique(e1) != 
is_unique(e2) || need_distinct(e1) != need_distinct(e2))
+               is_symmetric(e1) != is_symmetric(e2) ||
+               is_unique(e1) != is_unique(e2) ||
+               need_distinct(e1) != need_distinct(e2))
                return 0;
+
        if (e1->type == e2->type) {
                switch(e1->type) {
                case e_cmp:
diff --git a/sql/server/rel_optimize_sel.c b/sql/server/rel_optimize_sel.c
--- a/sql/server/rel_optimize_sel.c
+++ b/sql/server/rel_optimize_sel.c
@@ -980,7 +980,7 @@ cleanup_equal_exps(mvc *sql, sql_rel *re
        bool needed = false;
        for(node *n = exps->h; !needed && n; n = n->next) {
                for (node *m = n->next; !needed && m; m = m->next) {
-                       if (exp_match_exp_semantics(n->data, m->data, false))
+                       if (exp_match_exp_semantics(n->data, m->data, true))
                                needed = true;
                }
        }
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -2110,7 +2110,7 @@ update_idx(sql_trans *tr, sql_idx * i, v
 }
 
 static int
-delta_append_bat(sql_trans *tr, sql_delta **batp, sqlid id, BUN offset, BAT 
*offsets, BAT *i, char *storage_type, bool istemp)
+delta_append_bat(sql_trans *tr, sql_delta **batp, sqlid id, BUN offset, BAT 
*offsets, BAT *i, char *storage_type)
 {
        BAT *b, *oi = i;
        int err = 0;
@@ -2153,13 +2153,7 @@ delta_append_bat(sql_trans *tr, sql_delt
                        bat_destroy(oi);
                return LOG_ERR;
        }
-       if (istemp && !offsets && offset == 0 && BATcount(b) == 0 && 
bat->cs.ucnt == 0) {
-               bat_set_access(i, BAT_READ);
-               if (bat->cs.bid)
-                       temp_destroy(bat->cs.bid);
-               i = transfer_to_systrans(i);
-               bat->cs.bid = temp_create(i);
-       } else if (!offsets && offset == b->hseqbase+BATcount(b)) {
+       if (!offsets && offset == b->hseqbase+BATcount(b)) {
                if (BATappend(b, oi, NULL, true) != GDK_SUCCEED)
                        err = 1;
        } else if (!offsets) {
@@ -2309,7 +2303,7 @@ dup_storage( sql_trans *tr, storage *oba
 }
 
 static int
-append_col_execute(sql_trans *tr, sql_delta **delta, sqlid id, BUN offset, BAT 
*offsets, void *incoming_data, BUN cnt, bool isbat, int tt, char *storage_type, 
bool isnew)
+append_col_execute(sql_trans *tr, sql_delta **delta, sqlid id, BUN offset, BAT 
*offsets, void *incoming_data, BUN cnt, bool isbat, int tt, char *storage_type)
 {
        int ok = LOG_OK;
 
@@ -2319,7 +2313,7 @@ append_col_execute(sql_trans *tr, sql_de
                BAT *bat = incoming_data;
 
                if (BATcount(bat))
-                       ok = delta_append_bat(tr, delta, id, offset, offsets, 
bat, storage_type, isnew);
+                       ok = delta_append_bat(tr, delta, id, offset, offsets, 
bat, storage_type);
        } else {
                ok = delta_append_val(tr, delta, id, offset, offsets, 
incoming_data, cnt, storage_type, tt);
        }
@@ -2344,7 +2338,7 @@ append_col(sql_trans *tr, sql_column *c,
        assert(delta->cs.st == ST_DEFAULT || delta->cs.st == ST_DICT || 
delta->cs.st == ST_FOR);
 
        odelta = delta;
-       if ((res = append_col_execute(tr, &delta, c->base.id, offset, offsets, 
data, cnt, isbat, tpe, c->storage_type, isTempTable(c->t))) != LOG_OK)
+       if ((res = append_col_execute(tr, &delta, c->base.id, offset, offsets, 
data, cnt, isbat, tpe, c->storage_type)) != LOG_OK)
                return res;
        if (odelta != delta) {
                delta->next = odelta;
@@ -2376,7 +2370,7 @@ append_idx(sql_trans *tr, sql_idx *i, BU
 
        assert(delta->cs.st == ST_DEFAULT);
 
-       res = append_col_execute(tr, &delta, i->base.id, offset, offsets, data, 
cnt, isbat, tpe, NULL, isTempTable(i->t));
+       res = append_col_execute(tr, &delta, i->base.id, offset, offsets, data, 
cnt, isbat, tpe, NULL);
        return res;
 }
 
diff --git a/sql/test/BugTracker-2024/Tests/7569-temp-table-column-reuse.test 
b/sql/test/BugTracker-2024/Tests/7569-temp-table-column-reuse.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2024/Tests/7569-temp-table-column-reuse.test
@@ -0,0 +1,23 @@
+statement ok
+START TRANSACTION
+
+statement ok
+CREATE TEMPORARY TABLE nums(x INT, y INT)
+
+statement ok
+INSERT INTO nums
+SELECT value AS x, value AS y
+FROM sys.generate_series(0, 1)
+
+statement ok
+UPDATE nums SET y = 100
+
+query II nosort
+SELECT * FROM nums
+----
+0
+100
+
+statement ok
+ROLLBACK
+
diff --git a/sql/test/BugTracker-2024/Tests/All 
b/sql/test/BugTracker-2024/Tests/All
--- a/sql/test/BugTracker-2024/Tests/All
+++ b/sql/test/BugTracker-2024/Tests/All
@@ -84,3 +84,4 @@ 7556-missing-ignore-case
 7465-fwf-block-boundary-error
 7566-connections-refused
 7562-interval-overflow
+7569-temp-table-column-reuse
diff --git a/sql/test/rel-optimizers/Tests/groupjoin.test 
b/sql/test/rel-optimizers/Tests/groupjoin.test
--- a/sql/test/rel-optimizers/Tests/groupjoin.test
+++ b/sql/test/rel-optimizers/Tests/groupjoin.test
@@ -14,6 +14,6 @@ project (
 | | project (
 | | | table("sys"."integers") [ "integers"."i" ]
 | | ) [ "integers"."i" as "%1"."%1" ]
-| ) [ ("i1"."i") + = ("%1"."%1") ] [ boolean(1) "true" as "%4"."%4" ]
+| ) [ ("i1"."i") + = ("%1"."%1"), ("i1"."i") = ("%1"."%1") ] [ boolean(1) 
"true" as "%4"."%4" ]
 ) [ "i1"."i", "sys"."or"("%4"."%4", "sys"."isnull"("i1"."i") NOT NULL) ]
 
diff --git a/testing/sqllogictest.py b/testing/sqllogictest.py
--- a/testing/sqllogictest.py
+++ b/testing/sqllogictest.py
@@ -769,6 +769,7 @@ class SQLLogic:
             if line == '\n':
                 self.writeline()
                 continue
+            self.qline = self.line
             conn = None
             # look for connection string
             if line.startswith('@connection'):
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to