MonetDB: strimps_update - Merged with default
Changeset: 0bb23124813a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/0bb23124813a Branch: strimps_update Log Message: Merged with default diffs (truncated from 368 to 300 lines): diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -766,3 +766,4 @@ 025239a5a6f122042798c0f1132a2c6298514e06 2e54857a91306cc6304825c5596f65d00595db6b Jul2021_23 2e54857a91306cc6304825c5596f65d00595db6b Jul2021_SP6_release 1252291e5c0ddc91ccb16d612d04e34e6a7d3bc3 Jun2020_13 +1252291e5c0ddc91ccb16d612d04e34e6a7d3bc3 Jun2020_SP2_release diff --git a/clients/odbc/samples/CMakeLists.txt b/clients/odbc/samples/CMakeLists.txt --- a/clients/odbc/samples/CMakeLists.txt +++ b/clients/odbc/samples/CMakeLists.txt @@ -36,11 +36,19 @@ if(TESTING) PRIVATE ODBC::ODBC) + add_executable(metadata +metadata.c) + + target_link_libraries(metadata +PRIVATE +ODBC::ODBC) + install(TARGETS odbcsample1 testgetinfo arraytest testStmtAttr +metadata RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} @@ -52,6 +60,7 @@ if(TESTING) $ $ $ + $ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) endif() diff --git a/clients/odbc/samples/metadata.c b/clients/odbc/samples/metadata.c new file mode 100644 --- /dev/null +++ b/clients/odbc/samples/metadata.c @@ -0,0 +1,261 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Copyright 1997 - July 2008 CWI, August 2008 - 2022 MonetDB B.V. + */ + +#ifdef _MSC_VER +#include +#endif +#include +#include +#include +#include +#include +#include + +static void +prerr(SQLSMALLINT tpe, SQLHANDLE hnd, const char *func, const char *pref) +{ + SQLCHAR state[6]; + SQLINTEGER errnr; + SQLCHAR msg[256]; + SQLSMALLINT msglen; + SQLRETURN ret; + + ret = SQLGetDiagRec(tpe, hnd, 1, state, &errnr, msg, sizeof(msg), &msglen); + switch (ret) { + case SQL_SUCCESS_WITH_INFO: + if (msglen >= (signed int) sizeof(msg)) + fprintf(stderr, "(message truncated)\n"); + /* fall through */ + case SQL_SUCCESS: + fprintf(stderr, "%s: %s: SQLstate %s, Errnr %d, Message %s\n", func, pref, (char*)state, (int)errnr, (char*)msg); + break; + case SQL_INVALID_HANDLE: + fprintf(stderr, "%s: %s, invalid handle passed to error function\n", func, pref); + break; + case SQL_ERROR: + fprintf(stderr, "%s: %s, unexpected error from SQLGetDiagRec\n", func, pref); + break; + case SQL_NO_DATA: + break; + default: + fprintf(stderr, "%s: %s, weird return value from SQLGetDiagRec\n", func, pref); + break; + } +} + +static void +check(SQLRETURN ret, SQLSMALLINT tpe, SQLHANDLE hnd, const char *func) +{ + switch (ret) { + case SQL_SUCCESS: + break; + case SQL_SUCCESS_WITH_INFO: + prerr(tpe, hnd, func, "Info"); + break; + case SQL_ERROR: + prerr(tpe, hnd, func, "Error"); + break; + case SQL_NO_DATA: + break; + case SQL_INVALID_HANDLE: + fprintf(stderr, "%s: Error: invalid handle\n", func); + exit(1); + default: + fprintf(stderr, "%s: Unexpected return value\n", func); + break; + } +} + +static void +compareResult(SQLHANDLE stmt, SQLRETURN retcode, const char * functionname, const char * expected) +{ + SQLRETURN ret; + SQLSMALLINT columns;// Number of columns in result-set + size_t expct_len = strlen(expected); + size_t outp_len = expct_len + 1000; + char * outp = malloc(outp_len); + size_t pos = 0; + SQLUSMALLINT col; + SQLLEN indicator; + char buf[255]; + + check(retcode, SQL_HANDLE_STMT, stmt, functionname); + + // How many columns are there + ret = SQLNumResultCols(stmt, &columns); + check(ret, SQL_HANDLE_STMT, stmt, "SQLNumResultCols()"); + pos += snprintf(outp + pos, outp_len - pos, "Resultset with %d columns\n", columns); + + // get Result Column Names and print them + for (col = 1; col <= columns; col++) { + ret = SQLDescribeCol(stmt, col, (SQLCHAR *) buf, sizeof(buf), + NULL, NULL, NULL, NULL, NULL); + check(ret, SQL_HANDLE_STMT, stmt, "SQLDescribeCol()"); + pos += snprintf(outp + pos, outp_len - pos, + (col > 1) ? "\t%s" : "%s", buf); + } + pos += snprintf(outp + pos, outp_len - pos, "\n"); + + /* Loop through the rows in the result-set */ + ret = SQLFetch(stmt); + check(ret, SQL_HANDLE_STMT, stmt, "SQLFetch(1)
MonetDB: default - Dynamically lower boundary when we start memo...
Changeset: c9ad3649c580 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/c9ad3649c580 Modified Files: gdk/gdk_heap.c Branch: default Log Message: Dynamically lower boundary when we start memory mapping heaps. If a to-be-allocated heap is larger than 1/64th of the available memory (total memory minus what we've already allocated), then use memory map. diffs (67 lines): diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c --- a/gdk/gdk_heap.c +++ b/gdk/gdk_heap.c @@ -152,9 +152,11 @@ HEAPalloc(Heap *h, size_t nitems, size_t h->free = 0; h->cleanhash = false; + size_t allocated; if (GDKinmemory(h->farmid) || - (GDKmem_cursize() + h->size < GDK_mem_maxsize && -h->size < (h->farmid == 0 ? GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient))) { + ((allocated = GDKmem_cursize()) + h->size < GDK_mem_maxsize && +h->size < (h->farmid == 0 ? GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient) && +h->size < ((GDK_mem_maxsize - allocated) >> 6))) { h->storage = STORE_MEM; h->base = GDKmalloc(h->size); TRC_DEBUG(HEAP, "%s %zu %p\n", h->filename, h->size, h->base); @@ -162,6 +164,8 @@ HEAPalloc(Heap *h, size_t nitems, size_t if (!GDKinmemory(h->farmid) && h->base == NULL) { char *nme; + if (h->size < (h->farmid == 0 ? GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient)) + fprintf(stderr, "#%s: emergency mmap %11zu %11zu %11zu\n", __func__, h->size, (size_t) GDKmem_cursize(), (size_t) GDKvm_cursize()); nme = GDKfilepath(h->farmid, BATDIR, h->filename, NULL); if (nme == NULL) return GDK_FAIL; @@ -244,8 +248,12 @@ HEAPextend(Heap *h, size_t size, bool ma /* extend a malloced heap, possibly switching over to * file-mapped storage */ Heap bak = *h; - bool exceeds_swap = size + GDKmem_cursize() >= GDK_mem_maxsize; - bool must_mmap = !GDKinmemory(h->farmid) && (exceeds_swap || h->newstorage != STORE_MEM || size >= (h->farmid == 0 ? GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient)); + size_t allocated; + bool must_mmap = (!GDKinmemory(h->farmid) && + (h->newstorage != STORE_MEM || + (allocated = GDKmem_cursize()) + size >= GDK_mem_maxsize || + size >= (h->farmid == 0 ? GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient) || + size >= ((GDK_mem_maxsize - allocated) >> 6))); h->size = size; @@ -266,6 +274,8 @@ HEAPextend(Heap *h, size_t size, bool ma /* too big: convert it to a disk-based temporary heap */ bool existing = false; + if (size < (h->farmid == 0 ? GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient)) + fprintf(stderr, "#%s: emergency mmap %11zu %11zu %11zu\n", __func__, h->size, (size_t) GDKmem_cursize(), (size_t) GDKvm_cursize()); assert(h->storage == STORE_MEM); assert(ext != NULL); /* if the heap file already exists, we want to switch @@ -750,8 +760,14 @@ HEAPload_intern(Heap *h, const char *nme char *srcpath, *dstpath, *tmp; int t0; - if (h->storage == STORE_INVALID || h->newstorage == STORE_INVALID) - h->storage = h->newstorage = h->size < (h->farmid == 0 ? GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient) ? STORE_MEM : STORE_MMAP; + if (h->storage == STORE_INVALID || h->newstorage == STORE_INVALID) { + size_t allocated; + h->storage = h->newstorage = h->size < (h->farmid == 0 ? GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient) && + (allocated = GDKmem_cursize()) < GDK_mem_maxsize && + h->size < ((GDK_mem_maxsize - allocated) >> 6) ? STORE_MEM : STORE_MMAP; + if (h->storage == STORE_MMAP && h->size < (h->farmid == 0 ? GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient)) + fprintf(stderr, "#%s: emergency mmap %11zu %11zu\n", __func__, h->size, (size_t) GDKmem_cursize()); + } minsize = (h->size + GDK_mmap_pagesize - 1) & ~(GDK_mmap_pagesize - 1); if (h->storage != STORE_MEM && minsize != h->size) ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Nov2019 - Get this to compile on Fedora 36.
Changeset: dd786555f32b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/dd786555f32b Modified Files: clients/mapiclient/mclient.c clients/mapilib/mapi.c configure.ag gdk/gdk.h gdk/gdk_aggr.c sql/server/Makefile.ag Branch: Nov2019 Log Message: Get this to compile on Fedora 36. diffs (162 lines): diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -916,7 +916,7 @@ EXPANDEDrenderer(MapiHdl hdl) data = nullstring; do { edata = utf8skip(data, ~(size_t)0); - mnstr_printf(toConsole, "%-*s | %.*s\n", fieldw, name, (int) (edata - data), data); + mnstr_printf(toConsole, "%-*s | %.*s\n", fieldw, name, (int) (edata - data), data ? data : ""); name = ""; data = edata; if (*data) diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -961,15 +961,15 @@ static ATOMIC_FLAG mapi_initialized = AT return (e); \ } \ } while (0) -#define REALLOC(p, c) \ - do {\ - if (p) {\ - void *tmp = (p);\ - (p) = realloc((p), (c) * sizeof(*(p))); \ - if ((p) == NULL)\ - free(tmp); \ - } else \ - (p) = malloc((c) * sizeof(*(p))); \ +#define REALLOC(p, c) \ + do {\ + if (p) {\ + void *tmp = realloc((p), (c) * sizeof(*(p))); \ + if (tmp == NULL)\ + free(p);\ + (p) = tmp; \ + } else \ + (p) = malloc((c) * sizeof(*(p))); \ } while (0) /* @@ -3324,11 +3324,11 @@ mapi_prepare(Mapi mid, const char *cmd) do {\ /* note: k==strlen(hdl->query) */ \ if (k+len >= lim) { \ - char *q = hdl->query; \ lim = k + len + MAPIBLKSIZE;\ - hdl->query = realloc(hdl->query, lim); \ - if (hdl->query == NULL) { \ - free(q);\ + char *q = realloc(hdl->query, lim); \ + if (q == NULL) {\ + free(hdl->query); \ + hdl->query = NULL; \ return; \ } \ hdl->query = q; \ @@ -3465,11 +3465,11 @@ mapi_param_store(MapiHdl hdl) val = mapi_quote(buf, 1); /* note: k==strlen(hdl->query) */ if (k + strlen(val) + 3 >= lim) { - char *q = hdl->query; lim = k + strlen(val) + 3 + MAPIBLKSIZE; - hdl->query = realloc(hdl->query, lim); - if (hdl->query == NULL) { - free(q); + char *q = realloc(hdl->query, lim); + if (q == NULL) { + free(hdl->query); + hdl->query = NULL; free(val); return; } @@ -3482,11 +3482,11 @@ mapi_param_store(MapiHdl hdl) val = mapi_quote((char *) src, hdl->params[i].sizeptr ? *hdl->params[i].sizeptr : -1); /* note: k==strl
MonetDB: Nov2019 - R 4.2.0 removed SET_INTERNAL.
Changeset: 9eb639ebc8cc for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/9eb639ebc8cc Modified Files: monetdb5/extras/rapi/rapi.c Branch: Nov2019 Log Message: R 4.2.0 removed SET_INTERNAL. diffs (16 lines): diff --git a/monetdb5/extras/rapi/rapi.c b/monetdb5/extras/rapi/rapi.c --- a/monetdb5/extras/rapi/rapi.c +++ b/monetdb5/extras/rapi/rapi.c @@ -160,10 +160,12 @@ static char *RAPIinitialize(void) { if ((e = RAPIinstalladdons()) != 0) { return e; } +#if R_VERSION < R_Version(4,2,0) // patch R internals to disallow quit and system. Setting them to NULL produces an error. SET_INTERNAL(install("quit"), R_NilValue); // install.packages() uses system2 to call gcc etc., so we cannot disable it (perhaps store the pointer somewhere just for that?) //SET_INTERNAL(install("system"), R_NilValue); +#endif rapiInitialized = true; return NULL; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Nov2019 - Always initialize.
Changeset: a26ecace0540 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/a26ecace0540 Modified Files: sql/backends/monet5/sql.c Branch: Nov2019 Log Message: Always initialize. diffs (29 lines): 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 @@ -851,10 +851,8 @@ mvc_bat_next_get_value(Client cntxt, Mal if (!BATcount(it)) goto bailout; /* Success case */ - if (b) - bi = bat_iterator(b); - if (c) - ci = bat_iterator(c); + bi = bat_iterator(b); + ci = bat_iterator(c); BATloop(it, p, q) { str nsname, nseqname; @@ -1027,10 +1025,8 @@ mvc_bat_restart_seq(Client cntxt, MalBlk if (!BATcount(it)) goto bailout; /* Success case */ - if (b) - bi = bat_iterator(b); - if (c) - ci = bat_iterator(c); + bi = bat_iterator(b); + ci = bat_iterator(c); if (d) di = (lng *) Tloc(d, 0); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Jun2020 - Merge with Nov2019 branch.
Changeset: 10a95fa017b8 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/10a95fa017b8 Modified Files: clients/mapiclient/mclient.c clients/mapilib/mapi.c configure.ag gdk/gdk.h gdk/gdk_aggr.c monetdb5/extras/rapi/rapi.c sql/backends/monet5/sql.c sql/server/Makefile.ag Branch: Jun2020 Log Message: Merge with Nov2019 branch. diffs (135 lines): diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1010,15 +1010,15 @@ static ATOMIC_FLAG mapi_initialized = AT return (e); \ } \ } while (0) -#define REALLOC(p, c) \ - do {\ - if (p) {\ - void *tmp = (p);\ - (p) = realloc((p), (c) * sizeof(*(p))); \ - if ((p) == NULL)\ - free(tmp); \ - } else \ - (p) = malloc((c) * sizeof(*(p))); \ +#define REALLOC(p, c) \ + do {\ + if (p) {\ + void *tmp = realloc((p), (c) * sizeof(*(p))); \ + if (tmp == NULL)\ + free(p);\ + (p) = tmp; \ + } else \ + (p) = malloc((c) * sizeof(*(p))); \ } while (0) /* @@ -3377,11 +3377,11 @@ mapi_prepare(Mapi mid, const char *cmd) do {\ /* note: k==strlen(hdl->query) */ \ if (k+len >= lim) { \ - char *q = hdl->query; \ lim = k + len + MAPIBLKSIZE;\ - hdl->query = realloc(hdl->query, lim); \ - if (hdl->query == NULL) { \ - free(q);\ + char *q = realloc(hdl->query, lim); \ + if (q == NULL) {\ + free(hdl->query); \ + hdl->query = NULL; \ return; \ } \ hdl->query = q; \ @@ -3518,11 +3518,11 @@ mapi_param_store(MapiHdl hdl) val = mapi_quote(buf, 1); /* note: k==strlen(hdl->query) */ if (k + strlen(val) + 3 >= lim) { - char *q = hdl->query; lim = k + strlen(val) + 3 + MAPIBLKSIZE; - hdl->query = realloc(hdl->query, lim); - if (hdl->query == NULL) { - free(q); + char *q = realloc(hdl->query, lim); + if (q == NULL) { + free(hdl->query); + hdl->query = NULL; free(val); return; } @@ -3535,11 +3535,11 @@ mapi_param_store(MapiHdl hdl) val = mapi_quote((char *) src, hdl->params[i].sizeptr ? *hdl->params[i].sizeptr : -1); /* note: k==strlen(hdl->query) */ if (k + strlen(val) + 3 >= lim) { - char *q = hdl->query; lim = k + strlen(val) + 3 + MAPIBLKSIZE; - hdl->query = realloc(hdl->query, lim); - if (hdl->query == NULL) { - free(q); + char *q = realloc(hdl->query, lim); + if (q == NULL) { + free(hdl->query); +
MonetDB: Oct2020 - Merge with Jun2020 branch.
Changeset: ceaa337f8fef for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/ceaa337f8fef Modified Files: clients/mapiclient/mclient.c clients/mapilib/mapi.c gdk/gdk.h gdk/gdk_aggr.c monetdb5/extras/rapi/rapi.c sql/backends/monet5/sql.c Branch: Oct2020 Log Message: Merge with Jun2020 branch. diffs (135 lines): diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1011,15 +1011,15 @@ static ATOMIC_FLAG mapi_initialized = AT return (e); \ } \ } while (0) -#define REALLOC(p, c) \ - do {\ - if (p) {\ - void *tmp = (p);\ - (p) = realloc((p), (c) * sizeof(*(p))); \ - if ((p) == NULL)\ - free(tmp); \ - } else \ - (p) = malloc((c) * sizeof(*(p))); \ +#define REALLOC(p, c) \ + do {\ + if (p) {\ + void *tmp = realloc((p), (c) * sizeof(*(p))); \ + if (tmp == NULL)\ + free(p);\ + (p) = tmp; \ + } else \ + (p) = malloc((c) * sizeof(*(p))); \ } while (0) /* @@ -3351,11 +3351,11 @@ mapi_prepare(Mapi mid, const char *cmd) do {\ /* note: k==strlen(hdl->query) */ \ if (k+len >= lim) { \ - char *q = hdl->query; \ lim = k + len + MAPIBLKSIZE;\ - hdl->query = realloc(hdl->query, lim); \ - if (hdl->query == NULL) { \ - free(q);\ + char *q = realloc(hdl->query, lim); \ + if (q == NULL) {\ + free(hdl->query); \ + hdl->query = NULL; \ return; \ } \ } \ @@ -3491,11 +3491,11 @@ mapi_param_store(MapiHdl hdl) val = mapi_quote(buf, 1); /* note: k==strlen(hdl->query) */ if (k + strlen(val) + 3 >= lim) { - char *q = hdl->query; lim = k + strlen(val) + 3 + MAPIBLKSIZE; - hdl->query = realloc(hdl->query, lim); - if (hdl->query == NULL) { - free(q); + char *q = realloc(hdl->query, lim); + if (q == NULL) { + free(hdl->query); + hdl->query = NULL; free(val); return; } @@ -3508,11 +3508,11 @@ mapi_param_store(MapiHdl hdl) val = mapi_quote((char *) src, hdl->params[i].sizeptr ? *hdl->params[i].sizeptr : -1); /* note: k==strlen(hdl->query) */ if (k + strlen(val) + 3 >= lim) { - char *q = hdl->query; lim = k + strlen(val) + 3 + MAPIBLKSIZE; - hdl->query = realloc(hdl->query, lim); - if (hdl->query == NULL) { - free(q); + char *q = realloc(hdl->query, lim); + if (q == NULL) { + free(hdl->query); + hdl->query = NULL;
MonetDB: Jul2021 - Merge with Oct2020 branch.
Changeset: 98270f7a2d48 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/98270f7a2d48 Modified Files: clients/mapiclient/mclient.c clients/mapilib/mapi.c gdk/gdk.h gdk/gdk_aggr.c monetdb5/extras/rapi/rapi.c sql/backends/monet5/sql.c Branch: Jul2021 Log Message: Merge with Oct2020 branch. diffs (102 lines): diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1046,15 +1046,15 @@ static ATOMIC_FLAG mapi_initialized = AT return (e); \ } \ } while (0) -#define REALLOC(p, c) \ - do {\ - if (p) {\ - void *tmp = (p);\ - (p) = realloc((p), (c) * sizeof(*(p))); \ - if ((p) == NULL)\ - free(tmp); \ - } else \ - (p) = malloc((c) * sizeof(*(p))); \ +#define REALLOC(p, c) \ + do {\ + if (p) {\ + void *tmp = realloc((p), (c) * sizeof(*(p))); \ + if (tmp == NULL)\ + free(p);\ + (p) = tmp; \ + } else \ + (p) = malloc((c) * sizeof(*(p))); \ } while (0) /* @@ -3469,11 +3469,11 @@ mapi_prepare(Mapi mid, const char *cmd) do {\ /* note: k==strlen(hdl->query) */ \ if (k+len >= lim) { \ - char *q = hdl->query; \ lim = k + len + MAPIBLKSIZE;\ - hdl->query = realloc(hdl->query, lim); \ - if (hdl->query == NULL) { \ - free(q);\ + char *q = realloc(hdl->query, lim); \ + if (q == NULL) {\ + free(hdl->query); \ + hdl->query = NULL; \ return; \ } \ } \ @@ -3609,11 +3609,11 @@ mapi_param_store(MapiHdl hdl) val = mapi_quote(buf, 1); /* note: k==strlen(hdl->query) */ if (k + strlen(val) + 3 >= lim) { - char *q = hdl->query; lim = k + strlen(val) + 3 + MAPIBLKSIZE; - hdl->query = realloc(hdl->query, lim); - if (hdl->query == NULL) { - free(q); + char *q = realloc(hdl->query, lim); + if (q == NULL) { + free(hdl->query); + hdl->query = NULL; free(val); return; } @@ -3626,11 +3626,11 @@ mapi_param_store(MapiHdl hdl) val = mapi_quote((char *) src, hdl->params[i].sizeptr ? *hdl->params[i].sizeptr : -1); /* note: k==strlen(hdl->query) */ if (k + strlen(val) + 3 >= lim) { - char *q = hdl->query; lim = k + strlen(val) + 3 + MAPIBLKSIZE; - hdl->query = realloc(hdl->query, lim); - if (hdl->query == NULL) { - free(q); + char *q = realloc(hdl->query, lim); + if (q == NULL) { + free(hdl->query); + hdl->query = NULL;
MonetDB: Jul2021 - Don't use BUNtloc for TYPE_msk and introduce ...
Changeset: c98ff0244d13 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/c98ff0244d13 Modified Files: gdk/gdk.h gdk/gdk_bat.c gdk/gdk_batop.c Branch: Jul2021 Log Message: Don't use BUNtloc for TYPE_msk and introduce BUNtmsk for TYPE_msk. diffs (49 lines): diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -1150,10 +1150,11 @@ typedef var_t stridx_t; #define BUNtvaroff(bi,p) VarHeapVal((bi).base, (p), (bi).width) -#define BUNtloc(bi,p) (ATOMstorage((bi).type) == TYPE_msk ? Tmsk(&(bi), p) : (void *) ((char *) (bi).base + ((p) << (bi).shift))) +#define BUNtmsk(bi,p) Tmsk(&(bi), (p)) +#define BUNtloc(bi,p) (assert((bi).type != TYPE_msk), ((void *) ((char *) (bi).base + ((p) << (bi).shift #define BUNtpos(bi,p) Tpos(&(bi),p) #define BUNtvar(bi,p) (assert((bi).type && (bi).b->tvarsized), (void *) ((bi).vh->base+BUNtvaroff(bi,p))) -#define BUNtail(bi,p) ((bi).type?(bi).b->tvarsized?BUNtvar(bi,p):BUNtloc(bi,p):BUNtpos(bi,p)) +#define BUNtail(bi,p) ((bi).type?(bi).b->tvarsized?BUNtvar(bi,p):(bi).type==TYPE_msk?BUNtmsk(bi,p):BUNtloc(bi,p):BUNtpos(bi,p)) #define BUNlast(b) (assert((b)->batCount <= BUN_MAX), (b)->batCount) @@ -1955,6 +1956,7 @@ Tpos(BATiter *bi, BUN p) static inline bool Tmskval(BATiter *bi, BUN p) { + assert(ATOMstorage(bi->type) == TYPE_msk); return ((uint32_t *) bi->base)[p / 32] & (1U << (p % 32)); } diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -1438,6 +1438,8 @@ BUNinplacemulti(BAT *b, const oid *posit } else { val = BUNtpos(bi, p); } + } else if (bi.type == TYPE_msk) { + val = BUNtmsk(bi, p); } else { val = BUNtloc(bi, p); } diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -1332,7 +1332,7 @@ BATappend_or_update(BAT *b, BAT *p, cons bat_iterator_end(&ni); return GDK_FAIL; } - if (BUNappend(b, Tmsk(&ni, i), force) != GDK_SUCCEED) { + if (BUNappend(b, BUNtmsk(ni, i), force) != GDK_SUCCEED) { bat_iterator_end(&ni); return GDK_FAIL; } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Jan2022 - Merge with Jul2021 branch.
Changeset: a68879af1230 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/a68879af1230 Modified Files: clients/mapiclient/mclient.c clients/mapilib/mapi.c gdk/gdk.h gdk/gdk_aggr.c gdk/gdk_bat.c gdk/gdk_batop.c monetdb5/extras/rapi/rapi.c sql/backends/monet5/sql.c Branch: Jan2022 Log Message: Merge with Jul2021 branch. diffs (125 lines): diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1046,15 +1046,15 @@ static ATOMIC_FLAG mapi_initialized = AT return (e); \ } \ } while (0) -#define REALLOC(p, c) \ - do {\ - if (p) {\ - void *tmp = (p);\ - (p) = realloc((p), (c) * sizeof(*(p))); \ - if ((p) == NULL)\ - free(tmp); \ - } else \ - (p) = malloc((c) * sizeof(*(p))); \ +#define REALLOC(p, c) \ + do {\ + if (p) {\ + void *tmp = realloc((p), (c) * sizeof(*(p))); \ + if (tmp == NULL)\ + free(p);\ + (p) = tmp; \ + } else \ + (p) = malloc((c) * sizeof(*(p))); \ } while (0) /* @@ -3443,11 +3443,11 @@ mapi_prepare(Mapi mid, const char *cmd) do {\ /* note: k==strlen(hdl->query) */ \ if (k+len >= lim) { \ - char *q = hdl->query; \ lim = k + len + MAPIBLKSIZE;\ - hdl->query = realloc(hdl->query, lim); \ - if (hdl->query == NULL) { \ - free(q);\ + char *q = realloc(hdl->query, lim); \ + if (q == NULL) {\ + free(hdl->query); \ + hdl->query = NULL; \ return; \ } \ } \ @@ -3583,11 +3583,11 @@ mapi_param_store(MapiHdl hdl) val = mapi_quote(buf, 1); /* note: k==strlen(hdl->query) */ if (k + strlen(val) + 3 >= lim) { - char *q = hdl->query; lim = k + strlen(val) + 3 + MAPIBLKSIZE; - hdl->query = realloc(hdl->query, lim); - if (hdl->query == NULL) { - free(q); + char *q = realloc(hdl->query, lim); + if (q == NULL) { + free(hdl->query); + hdl->query = NULL; free(val); return; } @@ -3599,11 +3599,11 @@ mapi_param_store(MapiHdl hdl) val = mapi_quote((char *) src, hdl->params[i].sizeptr ? *hdl->params[i].sizeptr : -1); /* note: k==strlen(hdl->query) */ if (k + strlen(val) + 3 >= lim) { - char *q = hdl->query; lim = k + strlen(val) + 3 + MAPIBLKSIZE; - hdl->query = realloc(hdl->query, lim); - if (hdl->query == NULL) { - free(q); + char *q = realloc(hdl->query, lim); + if (q == NULL) { + free(hdl->query); +
MonetDB: default - Merge with Jan2022 branch.
Changeset: 369d2c0ae9da for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/369d2c0ae9da Modified Files: clients/mapiclient/mclient.c gdk/gdk.h gdk/gdk_aggr.c gdk/gdk_bat.c gdk/gdk_batop.c monetdb5/extras/rapi/rapi.c sql/backends/monet5/sql.c Branch: default Log Message: Merge with Jan2022 branch. diffs (76 lines): diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1046,15 +1046,15 @@ static ATOMIC_FLAG mapi_initialized = AT return (e); \ } \ } while (0) -#define REALLOC(p, c) \ - do {\ - if (p) {\ - void *tmp = (p);\ - (p) = realloc((p), (c) * sizeof(*(p))); \ - if ((p) == NULL)\ - free(tmp); \ - } else \ - (p) = malloc((c) * sizeof(*(p))); \ +#define REALLOC(p, c) \ + do {\ + if (p) {\ + void *tmp = realloc((p), (c) * sizeof(*(p))); \ + if (tmp == NULL)\ + free(p);\ + (p) = tmp; \ + } else \ + (p) = malloc((c) * sizeof(*(p))); \ } while (0) /* @@ -3443,11 +3443,11 @@ mapi_prepare(Mapi mid, const char *cmd) do {\ /* note: k==strlen(hdl->query) */ \ if (k+len >= lim) { \ - char *q = hdl->query; \ lim = k + len + MAPIBLKSIZE;\ - hdl->query = realloc(hdl->query, lim); \ - if (hdl->query == NULL) { \ - free(q);\ + char *q = realloc(hdl->query, lim); \ + if (q == NULL) {\ + free(hdl->query); \ + hdl->query = NULL; \ return; \ } \ } \ @@ -3583,11 +3583,11 @@ mapi_param_store(MapiHdl hdl) val = mapi_quote(buf, 1); /* note: k==strlen(hdl->query) */ if (k + strlen(val) + 3 >= lim) { - char *q = hdl->query; lim = k + strlen(val) + 3 + MAPIBLKSIZE; - hdl->query = realloc(hdl->query, lim); - if (hdl->query == NULL) { - free(q); + char *q = realloc(hdl->query, lim); + if (q == NULL) { + free(hdl->query); + hdl->query = NULL; free(val); return; } @@ -3599,11 +3599,11 @@ mapi_param_store(MapiHdl hdl) val = mapi_quote((char *) src, hdl->params[i].sizeptr ? *hdl->params[i].sizeptr : -1); /* note: k==strlen(hdl->query) */ if (k + strlen(val) + 3 >= lim) { - char *q = hdl->query; lim = k + strlen(val) + 3 + MAPIBLKSIZE; - hdl->query = realloc(hdl->query, lim); - if (hdl->query == NULL) { - free(q); + char *q = realloc(hdl->query, lim); + if (q == NULL) { + free(hdl->query); + hdl->query = NUL
MonetDB: Oct2020 - Fix merge.
Changeset: feed63df7713 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/feed63df7713 Modified Files: clients/mapilib/mapi.c Branch: Oct2020 Log Message: Fix merge. diffs (11 lines): diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -3358,6 +3358,7 @@ mapi_prepare(Mapi mid, const char *cmd) hdl->query = NULL; \ return; \ } \ + hdl->query = q; \ } \ } while (0) ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Jul2021 - Merge with Oct2020 branch.
Changeset: 3755f2a16a4f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/3755f2a16a4f Modified Files: clients/mapilib/mapi.c Branch: Jul2021 Log Message: Merge with Oct2020 branch. diffs (11 lines): diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -3476,6 +3476,7 @@ mapi_prepare(Mapi mid, const char *cmd) hdl->query = NULL; \ return; \ } \ + hdl->query = q; \ } \ } while (0) ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Jan2022 - Merge with Jul2021 branch + fix previous merge.
Changeset: 92ffe21f3a79 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/92ffe21f3a79 Modified Files: clients/mapilib/mapi.c Branch: Jan2022 Log Message: Merge with Jul2021 branch + fix previous merge. diffs (27 lines): diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -3450,6 +3450,7 @@ mapi_prepare(Mapi mid, const char *cmd) hdl->query = NULL; \ return; \ } \ + hdl->query = q; \ } \ } while (0) @@ -3591,6 +3592,7 @@ mapi_param_store(MapiHdl hdl) free(val); return; } + hdl->query = q; } snprintf(hdl->query + k, lim - k, "'%s'", val); free(val); @@ -3607,6 +3609,7 @@ mapi_param_store(MapiHdl hdl) free(val); return; } + hdl->query = q; } snprintf(hdl->query + k, lim - k, "'%s'", val); free(val); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Merge with Jan2022 branch.
Changeset: b5994ef4b3fb for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/b5994ef4b3fb Branch: default Log Message: Merge with Jan2022 branch. diffs (27 lines): diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -3450,6 +3450,7 @@ mapi_prepare(Mapi mid, const char *cmd) hdl->query = NULL; \ return; \ } \ + hdl->query = q; \ } \ } while (0) @@ -3591,6 +3592,7 @@ mapi_param_store(MapiHdl hdl) free(val); return; } + hdl->query = q; } snprintf(hdl->query + k, lim - k, "'%s'", val); free(val); @@ -3607,6 +3609,7 @@ mapi_param_store(MapiHdl hdl) free(val); return; } + hdl->query = q; } snprintf(hdl->query + k, lim - k, "'%s'", val); free(val); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: pax-log - Fix compilations error on Windows.
Changeset: 7d469723b217 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/7d469723b217 Modified Files: gdk/gdk_logger.c Branch: pax-log Log Message: Fix compilations error on Windows. diffs (19 lines): diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -423,12 +423,12 @@ log_read_updates(logger *lg, trans *tr, if (BATcount(*cands) == 0 || lg->flushing) { // when flushing, we only need the offset and count of the last segment of inserts. assert((*cands)->ttype == TYPE_void); - BATtseqbase(*cands, offset); - BATsetcount(*cands, nr); + BATtseqbase(*cands, (oid) offset); + BATsetcount(*cands, (BUN) nr); } else if (!lg->flushing) { assert(BATcount(*cands) > 0); - BAT* dense = BATdense(0,offset, nr); + BAT* dense = BATdense(0, (oid) offset, (BUN) nr); BAT* newcands = NULL; if (!dense ) { res = LOG_ERR; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: strimps_update - First draft of parallel construction
Changeset: 05018afa3a3f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/05018afa3a3f Modified Files: gdk/gdk_strimps.c monetdb5/modules/mal/pcre.c Branch: strimps_update Log Message: First draft of parallel construction diffs (truncated from 377 to 300 lines): diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c --- a/gdk/gdk_strimps.c +++ b/gdk/gdk_strimps.c @@ -403,76 +403,69 @@ BATcheckstrimps(BAT *b) return false; assert(b->batCacheid > 0); + if (b->tstrimps == (Strimps *)1) { - assert(!GDKinmemory(b->theap->farmid)); - MT_lock_set(&b->batIdxLock); - if (b->tstrimps == (Strimps *)1) { - Strimps *hp; - const char *nme = BBP_physical(b->batCacheid); - int fd; + Strimps *hp; + const char *nme = BBP_physical(b->batCacheid); + int fd; - b->tstrimps = NULL; - if ((hp = GDKzalloc(sizeof(Strimps))) != NULL && - (hp->strimps.farmid = BBPselectfarm(b->batRole, b->ttype, strimpheap)) >= 0) { - strconcat_len(hp->strimps.filename, - sizeof(hp->strimps.filename), - nme, ".tstrimps", NULL); + b->tstrimps = NULL; + if ((hp = GDKzalloc(sizeof(Strimps))) != NULL && + (hp->strimps.farmid = BBPselectfarm(b->batRole, b->ttype, strimpheap)) >= 0) { + strconcat_len(hp->strimps.filename, + sizeof(hp->strimps.filename), + nme, ".tstrimps", NULL); - /* check whether a persisted strimp can be found */ - if ((fd = GDKfdlocate(hp->strimps.farmid, nme, "rb+", "tstrimps")) >= 0) { - struct stat st; - uint64_t desc; - size_t npairs; - size_t hsize; - /* Read the 8 byte long strimp -* descriptor. -* -* NPAIRS must be 64 in the -* current implementation. -* -* HSIZE must be between 200 and -* 584 (inclusive): 8 bytes the -* descritor, 64 bytes the pair -* sizes and n*64 bytes the -* actual pairs where 2 <= n <= -* 8. -*/ - if (read(fd, &desc, 8) == 8 - && (desc & 0xff) == STRIMP_VERSION - && ((npairs = NPAIRS(desc)) == STRIMP_PAIRS) - && (hsize = HSIZE(desc)) >= 200 && hsize <= 584 - && ((desc >> 32) & 0xff) == 1 /* check the persistence byte */ - && fstat(fd, &st) == 0 - /* TODO: We might need padding in the UTF-8 case. */ - && st.st_size >= (off_t) (hp->strimps.free = hp->strimps.size = - /* header size (desc + offsets + pairs) */ - hsize + - /* bitmasks */ - BATcount(b)*sizeof(uint64_t)) - && HEAPload(&hp->strimps, nme, "tstrimps", false) == GDK_SUCCEED) { - hp->sizes_base = (uint8_t *)hp->strimps.base + 8; /* sizes just after the descriptor */ - hp->pairs_base = hp->sizes_base + STRIMP_HEADER_SIZE; /* pairs just after the offsets. */ - hp->bitstrings_base = hp->strimps.base + hsize; /* bitmasks just after the pairs */ + /* check whether a persisted strimp can be found */ + if ((fd = GDKfdlocate(hp->strimps.farmid, nme, "rb+", "tstrimps")) >= 0) { + struct stat st; + uint64_t desc; + size_t npairs; + size_t hsize; +
MonetDB: strimps_update - Return early if the strimp is construc...
Changeset: a1ef01c49f73 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/a1ef01c49f73 Modified Files: gdk/gdk_strimps.c Branch: strimps_update Log Message: Return early if the strimp is constructed to avoid duplicate work diffs (94 lines): diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c --- a/gdk/gdk_strimps.c +++ b/gdk/gdk_strimps.c @@ -467,10 +467,7 @@ BATcheckstrimps(BAT *b) GDKfree(hp); GDKclrerr();/* we're not currently interested in errors */ } - /* The string imprint is initialized if the strimp pointer is -* not null and the number of bitstrings is equal to the bat -* count. -*/ + ret = b->tstrimps != NULL; if (ret) { TRC_DEBUG(ACCELERATOR, @@ -517,9 +514,11 @@ STRMPfilter(BAT *b, BAT *s, const char * pb = b; } - if (!BATcheckstrimps(pb)) + MT_lock_set(&pb->batIdxLock); + if (!BATcheckstrimps(pb)) { + MT_lock_unset(&pb->batIdxLock); goto sfilter_fail; - MT_lock_set(&pb->batIdxLock); + } strmps = pb->tstrimps; STRMPincref(strmps); MT_lock_unset(&pb->batIdxLock); @@ -725,6 +724,7 @@ BAThasstrimps(BAT *b) */ #define STRIMP_COMPLETE(b) \ b->tstrimps != NULL && \ + b->tstrimps != (Strimps *)1 && \ ((b->tstrimps->strimps.free - ((char *)b->tstrimps->bitstrings_base - b->tstrimps->strimps.base)) == b->batCount*sizeof(uint64_t)) @@ -775,6 +775,9 @@ STRMPcreate(BAT *b, BAT *s) MT_lock_unset(&pb->batIdxLock); } + if (STRIMP_COMPLETE(pb)) { + return GDK_SUCCEED; + } r = pb->tstrimps; assert(r); dh = (uint64_t *)r->bitstrings_base + b->hseqbase; @@ -799,46 +802,6 @@ STRMPcreate(BAT *b, BAT *s) } MT_lock_unset(&b->batIdxLock); - - /* - if (pb->tstrimps == NULL) { - MT_lock_set(&pb->batIdxLock); - if (pb->tstrimps == NULL) { - Strimps *r; - BATiter bi; - BUN i; - oid x; - struct canditer ci; - uint64_t *dh; - - if ((r = STRMPcreateStrimpHeap(pb, s)) == NULL) { - MT_lock_unset(&pb->batIdxLock); - return GDK_FAIL; - } - dh = (uint64_t *)r->bitstrings_base; - - canditer_init(&ci, pb, NULL); - bi = bat_iterator(pb); - for (i = 0; i < ci.ncand; i++) { - x = canditer_next(&ci); - const char *cs = BUNtvar(bi, x); - if (!strNil(cs)) { - *dh++ = STRMPmakebitstring(cs, r); - assert((*(dh - 1) & ((uint64_t)0x1 << (STRIMP_PAIRS))) == 0); - } - else - *dh++ = (uint64_t)0x1 << (STRIMP_PAIRS); - } - bat_iterator_end(&bi); - - r->strimps.free += ci.ncand*sizeof(uint64_t); - pb->tstrimps = r; - persistStrimp(pb); - } - MT_lock_unset(&pb->batIdxLock); - } - */ - TRC_DEBUG(ACCELERATOR, "strimp creation took " LLFMT " usec\n", GDKusec()-t0); return GDK_SUCCEED; } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: strimps_update - Remove unneeded code
Changeset: 93fbe8b21383 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/93fbe8b21383 Modified Files: gdk/gdk_strimps.c Branch: strimps_update Log Message: Remove unneeded code diffs (138 lines): diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c --- a/gdk/gdk_strimps.c +++ b/gdk/gdk_strimps.c @@ -876,134 +876,6 @@ STRMPfree(BAT *b) /* Parallel creation. does not wok*/ #if 0 -/* Creates the heap for a string imprint. Returns NULL on failure. This - * follows closely the Heap creation for the order index. - */ -static Strimps * -STRMPcreateStrimpHeap(BAT *b, BAT *s) -{ - uint8_t *h1, *h2; - Strimps *r = NULL; - uint64_t descriptor; - size_t i; - uint16_t sz; - CharPair hpairs[STRIMP_HEADER_SIZE]; - const char *nme; - - MT_lock_set(&b->batIdxLock); - /* Make sure no other thread got here first */ -if ((r = b->tstrimps) == NULL) { - if (STRMPbuildHeader(b, s, hpairs)) { /* Find the header pairs, put -the result in hpairs */ - sz = 8 + STRIMP_HEADER_SIZE; /* add 8-bytes for the descriptor and - the pair sizes */ - for (i = 0; i < STRIMP_HEADER_SIZE; i++) { - sz += hpairs[i].psize; - } - - nme = GDKinmemory(b->theap->farmid) ? ":memory:" - : BBP_physical(b->batCacheid); - /* Allocate the strimps heap */ - if ((r = GDKzalloc(sizeof(Strimps))) == NULL || - (r->strimps.farmid = -BBPselectfarm(b->batRole, b->ttype, strimpheap)) < 0 || - strconcat_len(r->strimps.filename, sizeof(r->strimps.filename), - nme, ".tstrimps", - NULL) >= sizeof(r->strimps.filename) || - HEAPalloc(&r->strimps, BATcount(b) * sizeof(uint64_t) + sz, - sizeof(uint8_t), 0) != GDK_SUCCEED) { - GDKfree(r); - MT_lock_unset(&b->batIdxLock); - return NULL; - } - - descriptor = STRIMP_VERSION | ((uint64_t)STRIMP_HEADER_SIZE) << 8 | - ((uint64_t)sz) << 16; - - ((uint64_t *)r->strimps.base)[0] = descriptor; - r->sizes_base = h1 = (uint8_t *)r->strimps.base + 8; - r->pairs_base = h2 = (uint8_t *)h1 + STRIMP_HEADER_SIZE; - - for (i = 0; i < STRIMP_HEADER_SIZE; i++) { - uint8_t psize = hpairs[i].psize; - h1[i] = psize; - memcpy(h2, hpairs[i].pbytes, psize); - h2 += psize; - } - r->bitstrings_base = h2; - r->strimps.free = sz; - - // incref - b->tstrimps = r; - } - } - else - //incref - MT_lock_unset(&b->batIdxLock); - return r; -} - -/* Create */ -gdk_return -STRMPcreate(BAT *b, BAT *s) -{ - lng t0 = 0; - BATiter bi; - BUN i; - Strimps *h; - uint64_t *dh; - BAT *pb; - oid x; - struct canditer ci; - - TRC_DEBUG_IF(ACCELERATOR) t0 = GDKusec(); - if (b->ttype != TYPE_str) { - GDKerror("strimps only valid for strings\n"); - return GDK_FAIL; - } - - /* Disable this before merging to default */ - if (VIEWtparent(b)) { - pb = BBP_cache(VIEWtparent(b)); - assert(pb); - } else { - pb = b; - } - - if (BATcheckstrimps(pb)) - return GDK_SUCCEED; - - if ((h = STRMPcreateStrimpHeap(pb, s)) == NULL) { - return GDK_FAIL; - } - dh = (uint64_t *)h->bitstrings_base + b->hseqbase; - - canditer_init(&ci, b, s); - - bi = bat_iterator(b); - for (i = 0; i < ci.ncand; i++) { - x = canditer_next(&ci) - b->hseqbase; - const char *cs = BUNtvar(bi, x); - if (!strNil(cs)) - *dh++ = STRMPmakebitstring(cs, h); - else - *dh++ = 0; /* no pairs in nil values */ - } - bat_iterator_end(&bi); - - MT_lock_set(&b->batIdxLock); - h->strimps.free += b->batCount*sizeof(uint64_t); - MT_lock_unset(&b->batIdxLock); - - /* The thread that reaches this point last needs to write the strimp to disk. */ - if (STRIMP_COMPLETE(pb)) { - persistStrimp(pb); - } - - TRC_DEBUG(ACC
MonetDB: strimps_update - Better use of MT_thread_setalgorithm f...
Changeset: ce5dfdcb10b6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/ce5dfdcb10b6 Modified Files: gdk/gdk_strimps.c Branch: strimps_update Log Message: Better use of MT_thread_setalgorithm for strimps diffs (29 lines): diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c --- a/gdk/gdk_strimps.c +++ b/gdk/gdk_strimps.c @@ -409,6 +409,8 @@ BATcheckstrimps(BAT *b) const char *nme = BBP_physical(b->batCacheid); int fd; + MT_thread_setalgorithm("read strimp index from disk"); + b->tstrimps = NULL; if ((hp = GDKzalloc(sizeof(Strimps))) != NULL && (hp->strimps.farmid = BBPselectfarm(b->batRole, b->ttype, strimpheap)) >= 0) { @@ -741,7 +743,6 @@ STRMPcreate(BAT *b, BAT *s) struct canditer ci; uint64_t *dh; - MT_thread_setalgorithm("create strimp index"); TRC_DEBUG_IF(ACCELERATOR) t0 = GDKusec(); TRC_DEBUG(ACCELERATOR, "creating strimp"); if (ATOMstorage(b->ttype) != TYPE_str) { @@ -778,6 +779,8 @@ STRMPcreate(BAT *b, BAT *s) if (STRIMP_COMPLETE(pb)) { return GDK_SUCCEED; } + + MT_thread_setalgorithm("create strimp index"); r = pb->tstrimps; assert(r); dh = (uint64_t *)r->bitstrings_base + b->hseqbase; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: strimps_update - Better integration with the sql layer
Changeset: b499fdeaa15e for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/b499fdeaa15e Modified Files: gdk/gdk.h gdk/gdk_strimps.c monetdb5/modules/mal/pcre.c sql/backends/monet5/sql_cat.c Branch: strimps_update Log Message: Better integration with the sql layer When the statement CREATE IMPRINTS INDEX is issued for a string bat, the strimp is not created immediatelly. Instead a flag (the value 2 in the b->tstrimp pointer) is set and the next time a LIKE or NOT LIKE query is run on that bat, the strimp gets created in parallel. Remaining issues: - I need to find a way to drop the index on the SQL layer when the GDK layer removes the relevant data - For some reason the strimp is not used after its creation in the same session. After the server is restarted the strimp is used normally again. diffs (120 lines): diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -1847,6 +1847,7 @@ gdk_export gdk_return STRMPcreate(BAT *b gdk_export BAT *STRMPfilter(BAT *b, BAT *s, const char *q, bool keep_nils); gdk_export void STRMPdestroy(BAT *b); gdk_export bool BAThasstrimps(BAT *b); +gdk_export gdk_return BATsetstrimps(BAT *b); /* The ordered index structure */ diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c --- a/gdk/gdk_strimps.c +++ b/gdk/gdk_strimps.c @@ -466,11 +466,12 @@ BATcheckstrimps(BAT *b) } } + b->tstrimps = (Strimps *)2; GDKfree(hp); GDKclrerr();/* we're not currently interested in errors */ } - ret = b->tstrimps != NULL; + ret = b->tstrimps != NULL && b->tstrimps != (Strimps *)2; if (ret) { TRC_DEBUG(ACCELERATOR, "BATcheckstrimps(" ALGOBATFMT "): already has strimps, waited " LLFMT " usec\n", @@ -713,12 +714,33 @@ BAThasstrimps(BAT *b) } MT_lock_set(&pb->batIdxLock); - ret = BATcheckstrimps(pb); + ret = pb->tstrimps != NULL; MT_lock_unset(&pb->batIdxLock); return ret; } + +gdk_return +BATsetstrimps(BAT *b) +{ + BAT *pb; + if (VIEWtparent(b)) { + pb = BBP_cache(VIEWtparent(b)); + assert(pb); + } else { + pb = b; + } + + MT_lock_set(&pb->batIdxLock); + if (pb->tstrimps == NULL) { + pb->tstrimps = (Strimps *)2; + } + MT_lock_unset(&pb->batIdxLock); + + return GDK_SUCCEED; +} + /* This macro takes a bat and checks if the strimp construction has been * completed. It is completed when the strimp pointer is not null and it * is either 1 (i.e. it exists on disk) or the number of bitstrings @@ -757,8 +779,10 @@ STRMPcreate(BAT *b, BAT *s) pb = b; } - if (pb->tstrimps == NULL || pb->tstrimps == (Strimps*)1) { + if (pb->tstrimps == NULL || pb->tstrimps == (Strimps*)1 || pb->tstrimps == (Strimps*)2) { MT_lock_set(&pb->batIdxLock); + if (pb->tstrimps == (Strimps *)2) + pb->tstrimps = NULL; if (pb->tstrimps == NULL || pb->tstrimps == (Strimps*)1) { if (BATcheckstrimps(pb)) { MT_lock_unset(&b->batIdxLock); @@ -859,7 +883,7 @@ STRMPfree(BAT *b) if (b && b->tstrimps) { Strimps *s; MT_lock_set(&b->batIdxLock); - if ((s = b->tstrimps) != NULL && s != (Strimps *)1) { + if ((s = b->tstrimps) != NULL && s != (Strimps *)1 && s != (Strimps *)2) { if (GDKinmemory(s->strimps.farmid)) { b->tstrimps = NULL; STRMPdecref(s, s->strimps.parentid == b->batCacheid); diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c --- a/monetdb5/modules/mal/pcre.c +++ b/monetdb5/modules/mal/pcre.c @@ -1857,7 +1857,6 @@ PCRElikeselect(bat *ret, const bat *bid, bool with_strimps = false; bool with_strimps_anti = false; BUN p = 0, q = 0, rcnt = 0; - bool use_strimps = true; struct canditer ci; if ((b = BATdescriptor(*bid)) == NULL) { @@ -1887,7 +1886,7 @@ PCRElikeselect(bat *ret, const bat *bid, * taking extra care to not return NULLs. This currently means that we do not run strimps for NOT LIKE queries if * the BAT contains NULLs. */ - if (use_strimps) { + if (BAThasstrimps(b)) { if (STRMPcreate(b, NULL) == GDK_SUCCEED) { BAT *tmp_s = STRMPfilter(b, s, *pat, *anti); if (tmp_s) { diff --git a/sql/backends/monet5/sql_cat.c b/sql/backends/monet5/sql_cat.c --- a/sql/backends/monet5/sql_cat.c +++ b/sql/backends/monet5/sql_cat.c @@ -1283,9 +1283,9 @@ alter_table(Client cntxt, mvc *sql, char throw(SQL,"sql.alter_table",SQLSTATE(HY00
MonetDB: default - Allow use of functions deprectated by Visual ...
Changeset: 1e356b6e3738 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/1e356b6e3738 Modified Files: clients/odbc/samples/metadata.c Branch: default Log Message: Allow use of functions deprectated by Visual Studio. diffs (14 lines): diff --git a/clients/odbc/samples/metadata.c b/clients/odbc/samples/metadata.c --- a/clients/odbc/samples/metadata.c +++ b/clients/odbc/samples/metadata.c @@ -7,6 +7,10 @@ */ #ifdef _MSC_VER +/* Visual Studio 8 has deprecated lots of stuff: suppress warnings */ +#ifndef _CRT_SECURE_NO_DEPRECATE +#define _CRT_SECURE_NO_DEPRECATE 1 +#endif #include #endif #include ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: pax-log - Merge with default.
Changeset: becd4fe5fdc9 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/becd4fe5fdc9 Branch: pax-log Log Message: Merge with default. diffs (154 lines): diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1046,15 +1046,15 @@ static ATOMIC_FLAG mapi_initialized = AT return (e); \ } \ } while (0) -#define REALLOC(p, c) \ - do {\ - if (p) {\ - void *tmp = (p);\ - (p) = realloc((p), (c) * sizeof(*(p))); \ - if ((p) == NULL)\ - free(tmp); \ - } else \ - (p) = malloc((c) * sizeof(*(p))); \ +#define REALLOC(p, c) \ + do {\ + if (p) {\ + void *tmp = realloc((p), (c) * sizeof(*(p))); \ + if (tmp == NULL)\ + free(p);\ + (p) = tmp; \ + } else \ + (p) = malloc((c) * sizeof(*(p))); \ } while (0) /* @@ -3443,13 +3443,14 @@ mapi_prepare(Mapi mid, const char *cmd) do {\ /* note: k==strlen(hdl->query) */ \ if (k+len >= lim) { \ - char *q = hdl->query; \ lim = k + len + MAPIBLKSIZE;\ - hdl->query = realloc(hdl->query, lim); \ - if (hdl->query == NULL) { \ - free(q);\ + char *q = realloc(hdl->query, lim); \ + if (q == NULL) {\ + free(hdl->query); \ + hdl->query = NULL; \ return; \ } \ + hdl->query = q; \ } \ } while (0) @@ -3583,14 +3584,15 @@ mapi_param_store(MapiHdl hdl) val = mapi_quote(buf, 1); /* note: k==strlen(hdl->query) */ if (k + strlen(val) + 3 >= lim) { - char *q = hdl->query; lim = k + strlen(val) + 3 + MAPIBLKSIZE; - hdl->query = realloc(hdl->query, lim); - if (hdl->query == NULL) { - free(q); + char *q = realloc(hdl->query, lim); + if (q == NULL) { + free(hdl->query); + hdl->query = NULL; free(val); return; } + hdl->query = q; } snprintf(hdl->query + k, lim - k, "'%s'", val); free(val); @@ -3599,14 +3601,15 @@ mapi_param_store(MapiHdl hdl) val = mapi_quote((char *) src, hdl->params[i].sizeptr ? *hdl->params[i].sizeptr : -1); /* note: k==strlen(hdl->query) */ if (k + strlen(val) + 3 >= lim) { - char *q = hdl->query; lim = k + strlen(val) + 3 + MAPIBLKSIZE; - hdl->query = realloc(hdl->query, lim); - if (hdl->query == NULL) { - free(q); + char *q = realloc(hdl->query, lim); + if (q == NULL) { +
MonetDB: default - Remove debug prints.
Changeset: 84d7a2c5ab9b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/84d7a2c5ab9b Modified Files: gdk/gdk_heap.c Branch: default Log Message: Remove debug prints. diffs (30 lines): diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c --- a/gdk/gdk_heap.c +++ b/gdk/gdk_heap.c @@ -164,8 +164,6 @@ HEAPalloc(Heap *h, size_t nitems, size_t if (!GDKinmemory(h->farmid) && h->base == NULL) { char *nme; - if (h->size < (h->farmid == 0 ? GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient)) - fprintf(stderr, "#%s: emergency mmap %11zu %11zu %11zu\n", __func__, h->size, (size_t) GDKmem_cursize(), (size_t) GDKvm_cursize()); nme = GDKfilepath(h->farmid, BATDIR, h->filename, NULL); if (nme == NULL) return GDK_FAIL; @@ -274,8 +272,6 @@ HEAPextend(Heap *h, size_t size, bool ma /* too big: convert it to a disk-based temporary heap */ bool existing = false; - if (size < (h->farmid == 0 ? GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient)) - fprintf(stderr, "#%s: emergency mmap %11zu %11zu %11zu\n", __func__, h->size, (size_t) GDKmem_cursize(), (size_t) GDKvm_cursize()); assert(h->storage == STORE_MEM); assert(ext != NULL); /* if the heap file already exists, we want to switch @@ -765,8 +761,6 @@ HEAPload_intern(Heap *h, const char *nme h->storage = h->newstorage = h->size < (h->farmid == 0 ? GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient) && (allocated = GDKmem_cursize()) < GDK_mem_maxsize && h->size < ((GDK_mem_maxsize - allocated) >> 6) ? STORE_MEM : STORE_MMAP; - if (h->storage == STORE_MMAP && h->size < (h->farmid == 0 ? GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient)) - fprintf(stderr, "#%s: emergency mmap %11zu %11zu\n", __func__, h->size, (size_t) GDKmem_cursize()); } minsize = (h->size + GDK_mmap_pagesize - 1) & ~(GDK_mmap_pagesize - 1); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org