Changeset: fc3b9784a0bc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fc3b9784a0bc
Modified Files:
        sql/server/rel_distribute.c
        sql/server/rel_exp.c
        sql/storage/store.c
        sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade/Tests/upgrade.stable.out
        sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade/Tests/upgrade.stable.out
        sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: default
Log Message:

Merge with Dec2023 branch.


diffs (truncated from 631 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -822,3 +822,4 @@ 1230526af30f40eeea30fb87c47c3e414920561f
 1230526af30f40eeea30fb87c47c3e414920561f Dec2023_release
 95d8feaa1167b5ba87bd99253c3f4e62ebf528a1 Dec2023_3
 dcc8c702e685a4faf21ccf663028d1bc3d1165d1 Dec2023_5
+dcc8c702e685a4faf21ccf663028d1bc3d1165d1 Dec2023_SP1_release
diff --git a/monetdb5/ChangeLog.Dec2023 b/monetdb5/ChangeLog.Dec2023
--- a/monetdb5/ChangeLog.Dec2023
+++ b/monetdb5/ChangeLog.Dec2023
@@ -1,3 +1,7 @@
 # ChangeLog file for MonetDB5
 # This file is updated with Maddlog
 
+* Tue Mar 19 2024 Sjoerd Mullender <sjo...@acm.org>
+- Fixed interaction between mserver5 and remote mserver5 when only one
+  of the two has 128 bit integer support.
+
diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c
--- a/monetdb5/modules/mal/remote.c
+++ b/monetdb5/modules/mal/remote.c
@@ -86,12 +86,14 @@
 #define RMTT_64_BITS    (1<<2)
 #define RMTT_32_OIDS    (0<<3)
 #define RMTT_64_OIDS    (1<<3)
+#define RMTT_HGE           (1<<4)
 
 typedef struct _connection {
        MT_Lock lock;                           /* lock to avoid interference */
        str name;                                       /* the handle for this 
connection */
        Mapi mconn;                                     /* the Mapi handle for 
the connection */
        unsigned char type;                     /* binary profile of the 
connection target */
+       bool int128;                            /* has int128 support */
        size_t nextid;                          /* id counter */
        struct _connection *next;       /* the next connection in the list */
 } *connection;
@@ -106,6 +108,7 @@ static MT_Lock mal_remoteLock = MT_LOCK_
 
 static connection conns = NULL;
 static unsigned char localtype = 0177;
+static bool int128 = false;
 
 static inline str RMTquery(MapiHdl *ret, const char *func, Mapi conn,
                                                   const char *query);
@@ -297,7 +300,19 @@ RMTconnectScen(str *ret,
 #ifdef _DEBUG_MAPI_
        mapi_trace(c->mconn, true);
 #endif
-
+       if (c->type != localtype && (c->type | RMTT_HGE) == localtype) {
+               /* we support hge, and for remote, we don't know */
+               msg = RMTquery(&hdl, "remote.connect", m, "x := 0:hge;");
+               if (msg) {
+                       c->int128 = false;
+               } else {
+                       mapi_close_handle(hdl);
+                       c->int128 = true;
+                       c->type |= RMTT_HGE;
+               }
+       } else if (c->type == localtype) {
+               c->int128 = int128;
+       }
        MT_lock_unset(&mal_remoteLock);
 
        *ret = GDKstrdup(conn);
@@ -502,6 +517,10 @@ RMTprelude(void)
 #else
        type |= RMTT_32_OIDS;
 #endif
+#ifdef HAVE_HGE
+       type |= RMTT_HGE;
+       int128 = true;
+#endif
        localtype = (unsigned char) type;
 
        return (MAL_SUCCEED);
@@ -570,7 +589,7 @@ typedef struct _binbat_v1 {
 } binbat;
 
 static str
-RMTinternalcopyfrom(BAT **ret, char *hdr, stream *in, bool must_flush)
+RMTinternalcopyfrom(BAT **ret, char *hdr, stream *in, bool must_flush, bool 
cint128)
 {
        binbat bb = { 0, 0, 0, false, false, false, false, false, 0, 0, 0 };
        char *nme = NULL;
@@ -581,6 +600,7 @@ RMTinternalcopyfrom(BAT **ret, char *hdr
 
        BAT *b;
 
+       (void) cint128;
        /* hdr is a JSON structure that looks like
         * {"version":1,"ttype":6,"tseqbase":0,"tailsize":4,"theapsize":0}
         * we take the binary data directly from the stream */
@@ -684,6 +704,12 @@ RMTinternalcopyfrom(BAT **ret, char *hdr
                }
                hdr++;
        }
+#ifdef HAVE_HGE
+       if (int128 && !cint128 && bb.Ttype >= TYPE_hge)
+               bb.Ttype++;
+#else
+       (void) cint128;
+#endif
 
        b = COLnew2(bb.Hseqbase, bb.Ttype, bb.size, TRANSIENT,
                                bb.size > 0 ? (uint16_t) (bb.tailsize / 
bb.size) : 0);
@@ -788,7 +814,7 @@ RMTget(Client cntxt, MalBlkPtr mb, MalSt
        }
        GDKfree(rt);
 
-       if (isaBatType(rtype) && (localtype == 0177 || localtype != c->type)) {
+       if (isaBatType(rtype) && (localtype == 0177 || (localtype != c->type && 
localtype != (c->type | RMTT_HGE)))) {
                int t;
                size_t s;
                ptr r;
@@ -880,7 +906,7 @@ RMTget(Client cntxt, MalBlkPtr mb, MalSt
                        return tmp;
                }
 
-               if ((tmp = RMTinternalcopyfrom(&b, buf, sin, true)) != 
MAL_SUCCEED) {
+               if ((tmp = RMTinternalcopyfrom(&b, buf, sin, true, c->int128)) 
!= MAL_SUCCEED) {
                        MT_lock_unset(&c->lock);
                        return (tmp);
                }
@@ -1378,7 +1404,7 @@ RMTexec(Client cntxt, MalBlkPtr mb, MalS
                                BAT *b = NULL;
 
                                if ((tmp = RMTreadbatheader(sin, buf)) != 
MAL_SUCCEED ||
-                                       (tmp = RMTinternalcopyfrom(&b, buf, 
sin, i == fields - 1)) != MAL_SUCCEED) {
+                                       (tmp = RMTinternalcopyfrom(&b, buf, 
sin, i == fields - 1, c->int128)) != MAL_SUCCEED) {
                                        break;
                                }
 
@@ -1589,8 +1615,7 @@ RMTbincopyfrom(Client cntxt, MalBlkPtr m
 
        cntxt->fdin->buf[cntxt->fdin->len] = '\0';
        err = RMTinternalcopyfrom(&b,
-                                                         
&cntxt->fdin->buf[cntxt->fdin->pos],
-                                                         cntxt->fdin->s, true);
+                       &cntxt->fdin->buf[cntxt->fdin->pos], cntxt->fdin->s, 
true, int128 /* library should be compatible */);
        /* skip the JSON line */
        cntxt->fdin->pos = ++cntxt->fdin->len;
        if (err !=MAL_SUCCEED)
@@ -1611,30 +1636,13 @@ RMTbincopyfrom(Client cntxt, MalBlkPtr m
 static str
 RMTbintype(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
-       int type = 0;
-       (void) mb;
-       (void) stk;
-       (void) pci;
+       (void)mb;
+       (void)stk;
+       (void)pci;
 
-#ifdef WORDS_BIGENDIAN
-       type |= RMTT_B_ENDIAN;
-#else
-       type |= RMTT_L_ENDIAN;
-#endif
-#if SIZEOF_SIZE_T == SIZEOF_LNG
-       type |= RMTT_64_BITS;
-#else
-       type |= RMTT_32_BITS;
-#endif
-#if SIZEOF_OID == SIZEOF_LNG
-       type |= RMTT_64_OIDS;
-#else
-       type |= RMTT_32_OIDS;
-#endif
-
-       mnstr_printf(cntxt->fdout, "[ %d ]\n", type);
-
-       return (MAL_SUCCEED);
+       /* TODO bintype should include the (bin) protocol version */
+       mnstr_printf(cntxt->fdout, "[ %d ]\n", localtype);
+       return(MAL_SUCCEED);
 }
 
 /**
diff --git a/sql/ChangeLog.Dec2023 b/sql/ChangeLog.Dec2023
--- a/sql/ChangeLog.Dec2023
+++ b/sql/ChangeLog.Dec2023
@@ -1,3 +1,7 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Tue Mar 19 2024 Sjoerd Mullender <sjo...@acm.org>
+- Fixed issue where equal column aliases where created. When those
+  aliases where parsed on the remote side it could give crashes.
+
diff --git a/sql/server/rel_distribute.c b/sql/server/rel_distribute.c
--- a/sql/server/rel_distribute.c
+++ b/sql/server/rel_distribute.c
@@ -24,6 +24,30 @@ typedef struct rmt_prop_state {
        bool no_rmt_branch_rpl_leaf;
 } rps;
 
+static sql_rel*
+rel_unique_exps(mvc *sql, sql_rel *rel)
+{
+       list *l;
+
+       if (!is_project(rel->op))
+               return rel;
+       l = sa_list(sql->sa);
+       for (node *n = rel->exps->h; n; n = n->next) {
+               sql_exp *e = n->data;
+               if (e->type == e_column) {
+                       const char *name = exp_name(e);
+                       const char *rname = exp_relname(e);
+
+                       /* If there are two identical expression names, there 
will be ambiguity */
+                       if (name && rname && exps_bind_column2(l, rname, name, 
NULL))
+                               exp_label(sql->sa, e, ++sql->label);
+               }
+               append(l,e);
+       }
+       rel->exps = l;
+       return rel;
+}
+
 static int
 has_remote_or_replica( sql_rel *rel )
 {
@@ -497,6 +521,7 @@ rel_remote_func_(visitor *v, sql_rel *re
 
        if (find_prop(rel->p, PROP_REMOTE) != NULL) {
                list *exps = rel_projections(v->sql, rel, NULL, 1, 1);
+               rel = rel_unique_exps(v->sql, rel); /* remove any duplicate 
results (aliases) */
                rel = rel_relational_func(v->sql->sa, rel, exps);
        }
        return rel;
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
@@ -2653,6 +2653,8 @@ exps_bind_column2(list *exps, const char
                                                *multiple = 1;
                                        if (!res)
                                                res = e;
+                                       if (res && res->alias.label) /* aliases 
maybe used multiple times without problems */
+                                               return res;
                                }
                        }
                        return res;
@@ -2665,6 +2667,8 @@ exps_bind_column2(list *exps, const char
                                        *multiple = 1;
                                if (!res)
                                        res = e;
+                               if (res && res->alias.label) /* aliases maybe 
used multiple times without problems */
+                                       return res;
                        }
                }
        }
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -759,7 +759,7 @@ load_table(sql_trans *tr, sql_schema *s,
 
        if (isTable(t)) {
                if (store->storage_api.create_del(tr, t) != LOG_OK) {
-                       TRC_DEBUG(SQL_STORE, "Load table '%s' is missing 
'deletes'", t->base.name);
+                       TRC_ERROR(SQL_STORE, "Load table '%s' is missing 
'deletes'", t->base.name);
                        ATOMIC_PTR_DESTROY(&t->data);
                        return NULL;
                }
@@ -1164,6 +1164,8 @@ load_schema(sql_trans *tr, res_table *rt
                if (!instore(tid)) {
                        sql_table *t = load_table(tr, s, rt_tables, rt_parts,
                                        rt_cols, rt_idx, rt_idxcols, rt_keys, 
rt_keycols, rt_triggers, rt_triggercols, tid);
+                       if (t == NULL && store->debug&8) /* try to continue 
without this table */
+                               continue;
                        if (t == NULL) {
                                schema_destroy(store, s);
                                return NULL;
@@ -2239,6 +2241,8 @@ store_init(int debug, store_type store_t
        MT_lock_unset(&store->lock);
        MT_lock_unset(&store->flush);
        if (!store_load(store, pa)) {
+               /* zap current change list */
+               store->changes = NULL;
                store_exit(store);
                return NULL;
        }
diff --git a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
@@ -1,13 +1,6 @@
 Running database upgrade commands to update system tables.
 
 Running database upgrade commands:
-drop function json.isvalid(json);
-create function json.isvalid(js json)
-returns bool begin return case when js is NULL then NULL else true end; end;
-GRANT EXECUTE ON FUNCTION json.isvalid(json) TO PUBLIC;
-update sys.functions set system = true where system <> true and name = 
'isvalid' and schema_id = (select id from sys.schemas where name = 'json');
-
-Running database upgrade commands:
 update sys._columns set type_digits = 7 where type = 'tinyint' and type_digits 
<> 7;
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to