Changeset: f9968e961c9a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f9968e961c9a
Modified Files:
sql/server/rel_select.c
Branch: reducedstack
Log Message:
merged with default
diffs (truncated from 10862 to 300 lines):
diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -840,3 +840,4 @@ 30e6380820842b9e0325536eb22d7cb3843ab095
fd30df6fc710aa7615a995dd826389a67cddd47f Mar2025_root
11a26808ab1bc96546077899924e5c31d7f2553c Mar2025_1
ad290be8174693266b1e4eeab06af0266686af38 Mar2025_3
+ad290be8174693266b1e4eeab06af0266686af38 Mar2025_release
diff --git a/clients/odbc/driver/ODBCConvert.c
b/clients/odbc/driver/ODBCConvert.c
--- a/clients/odbc/driver/ODBCConvert.c
+++ b/clients/odbc/driver/ODBCConvert.c
@@ -2806,15 +2806,14 @@ ODBCFetch(ODBCStmt *stmt,
ODBCLOG("Writing 16 bytes to %p\n", ptr);
#endif
SQLGUID su;
+ unsigned int sudata1; /* DWORD su.Data1 either long or int */
sscanf(data,
- "%8"SCNx32
- "-%4"SCNx16
- "-%4"SCNx16
- "-%2"SCNx8"%2"SCNx8
- "-%2"SCNx8"%2"SCNx8"%2"SCNx8"%2"SCNx8"%2"SCNx8"%2"SCNx8,
- &su.Data1, &su.Data2, &su.Data3,
+ "%8x-%4hx-%4hx-%2hhx%2hhx"
+ "-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
+ &sudata1, &su.Data2, &su.Data3,
&su.Data4[0], &su.Data4[1],
&su.Data4[2], &su.Data4[3], &su.Data4[4], &su.Data4[5],
&su.Data4[6], &su.Data4[7]);
+ su.Data1 = sudata1;
WriteData(ptr, su, SQLGUID);
if (lenp)
*lenp = sizeof(SQLGUID);
@@ -3348,11 +3347,9 @@ ODBCStore(ODBCStmt *stmt,
case SQL_C_GUID:
u = *(SQLGUID *)ptr;
snprintf(data, sizeof(data),
- "%08"PRIx32"-%04"PRIx16"-%04"PRIx16
- "-%02"PRIx8"%02"PRIx8
- "-%02"PRIx8"%02"PRIx8"%02"PRIx8
- "%02"PRIx8"%02"PRIx8"%02"PRIx8,
- u.Data1, u.Data2, u.Data3,
+ "%08x-%04x-%04x-%02x%02x"
+ "-%02x%02x%02x%02x%02x%02x",
+ (unsigned int) u.Data1, u.Data2, u.Data3,
u.Data4[0], u.Data4[1],
u.Data4[2], u.Data4[3],
u.Data4[4], u.Data4[5],
@@ -3899,12 +3896,9 @@ ODBCStore(ODBCStmt *stmt,
u = *(SQLGUID *)ptr;
snprintf(data, sizeof(data),
"UUID '"
- "%08"PRIx32"-%04"PRIx16"-%04"PRIx16
- "-%02"PRIx8"%02"PRIx8
- "-%02"PRIx8"%02"PRIx8"%02"PRIx8
- "%02"PRIx8"%02"PRIx8"%02"PRIx8
- "'",
- u.Data1, u.Data2, u.Data3,
+ "%08x-%04x-%04x-%02x%02x"
+ "-%02x%02x%02x%02x%02x%02x'",
+ (unsigned int) u.Data1, u.Data2, u.Data3,
u.Data4[0], u.Data4[1],
u.Data4[2], u.Data4[3],
u.Data4[4], u.Data4[5],
diff --git a/clients/odbc/tests/ODBCtester.c b/clients/odbc/tests/ODBCtester.c
--- a/clients/odbc/tests/ODBCtester.c
+++ b/clients/odbc/tests/ODBCtester.c
@@ -29,7 +29,7 @@
static void
prerr(SQLSMALLINT tpe, SQLHANDLE hnd, const char *func, const char *pref)
{
- SQLCHAR state[6];
+ SQLCHAR state[SQL_SQLSTATE_SIZE +1];
SQLINTEGER errnr;
SQLCHAR msg[256];
SQLSMALLINT msglen;
@@ -207,6 +207,9 @@ testGetDataTruncatedString(SQLHANDLE stm
"SQLstate 01004, Errnr 0, Message [MonetDB][ODBC Driver
11.##.#][MonetDB-Test]String data, right truncated\n");
}
+ ret = SQLCloseCursor(stmt);
+ check(ret, SQL_HANDLE_STMT, stmt, "SQLCloseCursor");
+
/* cleanup */
free(outp);
return ret;
@@ -266,7 +269,7 @@ testGetDataGUID(SQLHANDLE stmt)
pos += snprintf(outp + pos, outp_len - pos, "NULL\n");
else
pos += snprintf(outp + pos, outp_len - pos,
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
- guid_val.Data1, guid_val.Data2, guid_val.Data3,
+ (unsigned int) guid_val.Data1,
guid_val.Data2, guid_val.Data3,
guid_val.Data4[0], guid_val.Data4[1],
guid_val.Data4[2], guid_val.Data4[3], guid_val.Data4[4], guid_val.Data4[5],
guid_val.Data4[6], guid_val.Data4[7]);
check(ret, SQL_HANDLE_STMT, stmt, "SQLGetData(col)");
}
@@ -286,6 +289,9 @@ testGetDataGUID(SQLHANDLE stmt)
"SQLGetData(3, SQL_C_CHAR, 36) returns 0, vallen 36,
str_val: 'beefc4f7-0264-4735-9b7a-75fd371ef803'\n"
"SQLGetData(3, SQL_C_GUID, 16) returns 0, vallen 16,
data_val: beefc4f7-0264-4735-9b7a-75fd371ef803\n");
+ ret = SQLCloseCursor(stmt);
+ check(ret, SQL_HANDLE_STMT, stmt, "SQLCloseCursor");
+
/* cleanup */
free(outp);
return ret;
@@ -335,19 +341,13 @@ main(int argc, char **argv)
ret = SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
check(ret, SQL_HANDLE_DBC, dbc, "SQLAllocHandle (STMT)");
- /* run tests */
+ /**** run tests ****/
ret = testGetDataTruncatedString(stmt, SQL_C_CHAR);
check(ret, SQL_HANDLE_STMT, stmt, "testGetDataTruncatedString(STMT,
SQL_C_CHAR)");
- ret = SQLCloseCursor(stmt);
- check(ret, SQL_HANDLE_STMT, stmt, "SQLCloseCursor");
-
ret = testGetDataTruncatedString(stmt, SQL_C_WCHAR);
check(ret, SQL_HANDLE_STMT, stmt, "testGetDataTruncatedString(STMT,
SQL_C_WCHAR)");
- ret = SQLCloseCursor(stmt);
- check(ret, SQL_HANDLE_STMT, stmt, "SQLCloseCursor");
-
ret = testGetDataGUID(stmt);
check(ret, SQL_HANDLE_STMT, stmt, "testGetDataGUID(STMT)");
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -1640,7 +1640,7 @@ BUNinplacemulti(BAT *b, const oid *posit
b->tseqbase = * (oid *) t;
}
}
- } else if (b->tnosorted >= p)
+ } else if (b->tnosorted == p || b->tnosorted == p + 1)
b->tnosorted = 0;
if (b->trevsorted) {
if (prv != BUN_NONE &&
@@ -1652,7 +1652,7 @@ BUNinplacemulti(BAT *b, const oid *posit
b->trevsorted = false;
b->tnorevsorted = nxt;
}
- } else if (b->tnorevsorted >= p)
+ } else if (b->tnorevsorted == p || b->tnorevsorted == p + 1)
b->tnorevsorted = 0;
if (((b->ttype != TYPE_void) & b->tkey) && b->batCount > 1) {
BATkey(b, false);
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -767,9 +767,11 @@ la_bat_updates(logger *lg, logaction *la
const void *t = BUNtail(vi, p);
if (q < cnt) {
- if (b->tnosorted == q)
+ if (b->tnosorted == q ||
+ b->tnosorted == q + 1)
b->tnosorted = 0;
- if (b->tnorevsorted == q)
+ if (b->tnorevsorted == q ||
+ b->tnorevsorted == q + 1)
b->tnorevsorted = 0;
if (b->tnokey[0] == q ||
b->tnokey[1] == q) {
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
@@ -88,12 +88,13 @@
#define RMTT_64_OIDS (1<<3)
#define RMTT_HGE (1<<4)
+#define MAXTYPE 64
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 */
+ int typemap[MAXTYPE]; /* map types from remote back to local
types */
size_t nextid; /* id counter */
struct _connection *next; /* the next connection in the list */
} *connection;
@@ -108,7 +109,6 @@ 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);
@@ -284,36 +284,28 @@ RMTconnectScen(str *ret,
c->next = conns;
conns = c;
- msg = RMTquery(&hdl, "remote.connect", m, "remote.bintype();");
+ msg = RMTquery(&hdl, "remote.connect", m, "x := inspect.getAtomNames();
io.print(x);");
if (msg) {
MT_lock_unset(&mal_remoteLock);
return msg;
}
- if (hdl != NULL && mapi_fetch_row(hdl)) {
- char *val = mapi_fetch_field(hdl, 0);
- c->type = (unsigned char) atoi(val);
- mapi_close_handle(hdl);
- } else {
- c->type = 0;
+ int i = 0;
+ while (hdl != NULL && mapi_fetch_row(hdl)) {
+ if (i>=MAXTYPE) {
+ mapi_close_handle(hdl);
+ GDKfree(c);
+ mapi_destroy(m);
+ MT_lock_unset(&mal_remoteLock);
+ throw(MAL, "remote.connect", "too many types");
+ }
+ char *type = mapi_fetch_field(hdl, 1);
+ c->typemap[i++] = ATOMindex(type);
}
-
+ c->type = localtype;
+ mapi_close_handle(hdl);
#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) {
- freeException(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);
@@ -514,7 +506,6 @@ RMTprelude(void)
#endif
#ifdef HAVE_HGE
type |= RMTT_HGE;
- int128 = true;
#endif
localtype = (unsigned char) type;
@@ -584,7 +575,7 @@ typedef struct _binbat_v1 {
} binbat;
static str
-RMTinternalcopyfrom(BAT **ret, char *hdr, stream *in, bool must_flush, bool
cint128)
+RMTinternalcopyfrom(BAT **ret, char *hdr, stream *in, bool must_flush, int
*typemap)
{
binbat bb = { 0, 0, 0, false, false, false, false, false, 0, 0, 0 };
char *nme = NULL;
@@ -595,7 +586,6 @@ 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 */
@@ -658,7 +648,13 @@ RMTinternalcopyfrom(BAT **ret, char *hdr
#endif
bb.Hseqbase = (oid) lv;
} else if (strcmp(nme, "ttype") == 0) {
- if (lv >= GDKatomcnt)
+ if (lv < 0 || lv >= MAXTYPE)
+ throw(MAL, "remote.bincopyfrom",
+ "bad %s value: GDK
atom number %s doesn't exist",
+ nme, val);
+ if (lv >= 0 && typemap)
+ lv = typemap[lv];
+ if (lv < 0)
throw(MAL, "remote.bincopyfrom",
"bad %s value: GDK
atom number %s doesn't exist",
nme, val);
@@ -699,12 +695,6 @@ 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);
@@ -904,7 +894,7 @@ RMTget(Client cntxt, MalBlkPtr mb, MalSt
return tmp;
}
- if ((tmp = RMTinternalcopyfrom(&b, buf, sin, true, c->int128))
!= MAL_SUCCEED) {
+ if ((tmp = RMTinternalcopyfrom(&b, buf, sin, true, c->typemap))
!= MAL_SUCCEED) {
MT_lock_unset(&c->lock);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]