Changeset: 71134493516b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/71134493516b
Modified Files:
cmake/monetdb-functions.cmake
Branch: default
Log Message:
Merge with Jul2021 branch.
diffs (truncated from 506 to 300 lines):
diff --git a/cmake/monetdb-functions.cmake b/cmake/monetdb-functions.cmake
--- a/cmake/monetdb-functions.cmake
+++ b/cmake/monetdb-functions.cmake
@@ -9,40 +9,50 @@
function(monetdb_hg_revision)
# Get the current version control revision
if(EXISTS "${CMAKE_SOURCE_DIR}/.hg_archival.txt")
- execute_process(COMMAND "sed" "-n" "s/^node:
\\([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]\\).*/\\1/p"
".hg_archival.txt" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" RESULT_VARIABLE
HG_RETURN_CODE
- OUTPUT_VARIABLE HG_OUPUT_RES OUTPUT_STRIP_TRAILING_WHITESPACE)
- if(HG_RETURN_CODE EQUAL 0 AND HG_OUPUT_RES)
- set(MERCURIAL_ID "${HG_OUPUT_RES}" PARENT_SCOPE)
+ file(READ "${CMAKE_SOURCE_DIR}/.hg_archival.txt" HG_ARCHIVAL)
+ if(HG_ARCHIVAL MATCHES ".*node:.*")
+ string(REGEX REPLACE ".*node:
([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]).*"
"\\1" HG_NODE "${HG_ARCHIVAL}")
+ if(HG_ARCHIVAL MATCHES ".*local:.*")
+ string(REGEX REPLACE ".*local: ([0-9][0-9]*).*" "\\1" HG_LOCAL
"${HG_ARCHIVAL}")
+ set(MERCURIAL_ID "${HG_NODE} ${HG_LOCAL}" PARENT_SCOPE)
+ else()
+ set(MERCURIAL_ID "${HG_NODE}" PARENT_SCOPE)
+ endif()
else()
- message(FATAL_ERROR "Failed to find mercurial ID")
+ message(WARNING "Failed to find mercurial ID")
+ set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
endif()
elseif(EXISTS "${CMAKE_SOURCE_DIR}/.hg")
find_package(Hg)
if(HG_FOUND)
message("hg found: ${HG_EXECUTABLE}")
else()
- message(FATAL_ERROR "Failed to find mercurial")
+ message(WARNING "Failed to find mercurial")
+ set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
endif()
execute_process(COMMAND "${HG_EXECUTABLE}" "id" "-i" WORKING_DIRECTORY
"${CMAKE_SOURCE_DIR}" RESULT_VARIABLE HG_RETURN_CODE
OUTPUT_VARIABLE HG_OUPUT_RES OUTPUT_STRIP_TRAILING_WHITESPACE)
if(HG_RETURN_CODE EQUAL 0 AND HG_OUPUT_RES)
set(MERCURIAL_ID "${HG_OUPUT_RES}" PARENT_SCOPE)
else()
- message(FATAL_ERROR "Failed to find mercurial ID")
+ message(WARNING "Failed to find mercurial ID")
+ set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
endif()
elseif(EXISTS "${CMAKE_SOURCE_DIR}/.git")
find_package(Git)
if(GIT_FOUND)
message("git found: ${GIT_EXECUTABLE}")
else()
- message(FATAL_ERROR "Failed to find git")
+ message(WARNING "Failed to find git")
+ set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
endif()
execute_process(COMMAND "${GIT_EXECUTABLE}" "rev-parse" "--short" "HEAD"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE GIT_RETURN_CODE OUTPUT_VARIABLE GIT_OUPUT_RES
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(GIT_RETURN_CODE EQUAL 0 AND GIT_OUPUT_RES)
set(MERCURIAL_ID "${GIT_OUPUT_RES}" PARENT_SCOPE)
else()
- message(FATAL_ERROR "Failed to find git ID")
+ message(WARNING "Failed to find git ID")
+ set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
endif()
else()
set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
diff --git a/cmake/monetdb-toolchain.cmake b/cmake/monetdb-toolchain.cmake
--- a/cmake/monetdb-toolchain.cmake
+++ b/cmake/monetdb-toolchain.cmake
@@ -20,7 +20,11 @@ function(monetdb_default_compiler_option
add_compile_options("-fsanitize=address")
add_compile_options("-fno-omit-frame-pointer")
add_compile_definitions(SANITIZER)
- add_link_options("-fsanitize=address")
+ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13.0")
+ add_link_options("-fsanitize=address")
+ else()
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address" PARENT_SCOPE)
+ endif()
else()
message(FATAL_ERROR "Sanitizer only supported with GCC")
endif()
diff --git a/sql/backends/monet5/sql_gencode.c
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -326,7 +326,8 @@ static int
const char *local_tbl = prp->value;
node *n;
int i, q, v, res = 0, added_to_cache = 0, *lret, *rret;
- char *lname;
+ size_t len = 1024, nr;
+ char *lname, *buf;
sql_rel *r = rel;
if (local_tbl == NULL) {
@@ -386,9 +387,7 @@ static int
/* ops */
if (call && call->type == st_list) {
- node *n;
-
- for (n = call->op4.lval->h; n; n = n->next) {
+ for (node *n = call->op4.lval->h; n; n = n->next) {
stmt *op = n->data;
sql_subtype *t = tail_type(op);
int type = t->type->localtype;
@@ -413,15 +412,17 @@ static int
}
/* declare return variables */
- for (i = 0, n = r->exps->h; n; n = n->next, i++) {
- sql_exp *e = n->data;
- int type = exp_subtype(e)->type->localtype;
+ if (!list_empty(r->exps)) {
+ for (i = 0, n = r->exps->h; n; n = n->next, i++) {
+ sql_exp *e = n->data;
+ int type = exp_subtype(e)->type->localtype;
- type = newBatType(type);
- p = newFcnCall(curBlk, batRef, newRef);
- p = pushType(curBlk, p, getBatType(type));
- setArgType(curBlk, p, 0, type);
- lret[i] = getArg(p, 0);
+ type = newBatType(type);
+ p = newFcnCall(curBlk, batRef, newRef);
+ p = pushType(curBlk, p, getBatType(type));
+ setArgType(curBlk, p, 0, type);
+ lret[i] = getArg(p, 0);
+ }
}
/* q := remote.connect("schema.table", "msql"); */
@@ -451,99 +452,96 @@ static int
o = pushStr(curBlk, o, lname);
p = pushArgument(curBlk, p, getArg(o,0));
- {
- int len = 1024, nr = 0;
- char *s, *buf = GDKmalloc(len);
- if (!buf) {
+ if (!(buf = rel2str(m, rel))) {
GDKfree(lname);
sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
return -1;
}
- s = rel2str(m, rel);
- if (!s) {
- GDKfree(lname);
- GDKfree(buf);
- sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
- return -1;
- }
o = newFcnCall(curBlk, remoteRef, putRef);
o = pushArgument(curBlk, o, q);
- o = pushStr(curBlk, o, s); /* relational plan */
+ o = pushStr(curBlk, o, buf); /* relational plan */
p = pushArgument(curBlk, p, getArg(o,0));
- free(s);
-
- s = "";
- if (call && call->type == st_list) { /* Send existing variables in the
plan */
- node *n;
-
- buf[0] = 0;
- for (n = call->op4.lval->h; n; n = n->next) {
- stmt *op = n->data;
- sql_subtype *t = tail_type(op);
- const char *nme =
(op->op3)?op->op3->op4.aval->data.val.sval:op->cname;
+ free(buf);
- if ((nr + 100) > len) {
- char *tmp = GDKrealloc(buf, len*=2);
- if (tmp == NULL) {
- GDKfree(buf);
- buf = NULL;
- break;
- }
- buf = tmp;
- }
-
- nr += snprintf(buf+nr, len-nr, "%s %s(%u,%u)%c", nme,
t->type->base.name, t->digits, t->scale, n->next?',':' ');
- }
- s = buf;
- }
- if (buf) {
- o = newFcnCall(curBlk, remoteRef, putRef);
- o = pushArgument(curBlk, o, q);
- o = pushStr(curBlk, o, s); /* signature */
- p = pushArgument(curBlk, p, getArg(o,0));
- } else {
+ if (!(buf = GDKmalloc(len))) {
GDKfree(lname);
sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
return -1;
}
buf[0] = 0;
- nr = 0;
- for (n = r->exps->h; n; n = n->next) { /* Send SQL types of the
projection's expressions */
- sql_exp *e = n->data;
- sql_subtype *t = exp_subtype(e);
- str next = sql_subtype_string(m->ta, t);
+ if (call && call->type == st_list) { /* Send existing variables in the
plan */
+ char dbuf[32], sbuf[32];
+
+ nr = 0;
+ for (node *n = call->op4.lval->h; n; n = n->next) {
+ stmt *op = n->data;
+ sql_subtype *t = tail_type(op);
+ const char *nme =
(op->op3)?op->op3->op4.aval->data.val.sval:op->cname;
- if (!next) {
- GDKfree(buf);
- buf = NULL;
- break;
- }
- if ((nr + 100) > len) {
- char *tmp = GDKrealloc(buf, len*=2);
- if (tmp == NULL) {
- GDKfree(buf);
- buf = NULL;
- break;
+ sprintf(dbuf, "%u", t->digits);
+ sprintf(sbuf, "%u", t->scale);
+ size_t nlen = strlen(nme) + strlen(t->type->base.name)
+ strlen(dbuf) + strlen(sbuf) + 6;
+
+ if ((nr + nlen) > len) {
+ len = (len + nlen) * 2;
+ char *tmp = GDKrealloc(buf, len);
+ if (tmp == NULL) {
+ GDKfree(lname);
+ GDKfree(buf);
+ sql_error(m, 001, SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ return -1;
+ }
+ buf = tmp;
}
- buf = tmp;
+
+ nr += snprintf(buf+nr, len-nr, "%s %s(%s,%s)%c", nme,
t->type->base.name, dbuf, sbuf, n->next?',':' ');
}
-
- nr += snprintf(buf+nr, len-nr, "%s%s", next, n->next?"%":"");
}
- sa_reset(m->ta);
- if (buf) {
- o = newFcnCall(curBlk, remoteRef, putRef);
- o = pushArgument(curBlk, o, q);
- o = pushStr(curBlk, o, s); /* SQL types as a single string
*/
- p = pushArgument(curBlk, p, getArg(o,0));
- GDKfree(buf);
- } else {
- GDKfree(lname);
- sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
- return -1;
+ o = newFcnCall(curBlk, remoteRef, putRef);
+ o = pushArgument(curBlk, o, q);
+ o = pushStr(curBlk, o, buf); /* signature */
+ p = pushArgument(curBlk, p, getArg(o,0));
+
+ buf[0] = 0;
+ if (!list_empty(r->exps)) {
+ nr = 0;
+ for (n = r->exps->h; n; n = n->next) { /* Send SQL types of the
projection's expressions */
+ sql_exp *e = n->data;
+ sql_subtype *t = exp_subtype(e);
+ str next = sql_subtype_string(m->ta, t);
+
+ if (!next) {
+ GDKfree(lname);
+ GDKfree(buf);
+ sa_reset(m->ta);
+ sql_error(m, 001, SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ return -1;
+ }
+
+ size_t nlen = strlen(next) + 2;
+ if ((nr + nlen) > len) {
+ len = (len + nlen) * 2;
+ char *tmp = GDKrealloc(buf, len);
+ if (tmp == NULL) {
+ GDKfree(lname);
+ GDKfree(buf);
+ sa_reset(m->ta);
+ sql_error(m, 001, SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ return -1;
+ }
+ buf = tmp;
+ }
+
+ nr += snprintf(buf+nr, len-nr, "%s%s", next,
n->next?"%":"");
+ }
+ sa_reset(m->ta);
}
- }
+ o = newFcnCall(curBlk, remoteRef, putRef);
+ o = pushArgument(curBlk, o, q);
+ o = pushStr(curBlk, o, buf); /* SQL types as a single string */
+ GDKfree(buf);
+ p = pushArgument(curBlk, p, getArg(o,0));
pushInstruction(curBlk, p);
char *mal_session_uuid, *err = NULL;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list