Changeset: 448f31f472f4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/448f31f472f4 Modified Files: monetdb5/ChangeLog.Dec2023 monetdb5/modules/mal/remote.c Branch: Dec2023 Log Message:
Fixed remote mserver support when only one has 128 bit integer support. diffs (173 lines): 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); } /** _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org