Changeset: c59cf5099b33 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c59cf5099b33
Modified Files:
gdk/gdk_calc.c
sql/backends/monet5/sql_upgrades.c
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.ppc64.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.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.32bit
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.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.32bit
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.32bit
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: default
Log Message:
Merge with Jul2021 branch.
diffs (truncated from 31361 to 300 lines):
diff --git a/ctest/tools/monetdbe/cmocka_test.c
b/ctest/tools/monetdbe/cmocka_test.c
--- a/ctest/tools/monetdbe/cmocka_test.c
+++ b/ctest/tools/monetdbe/cmocka_test.c
@@ -14,23 +14,23 @@
#include "cmocka.h"
#include "test_helper.h"
-#define error(msg) {fprintf(stderr, "Failure: %s\n", msg); return -1;}
+#define error(msg) do{fprintf(stderr, "Failure: %s\n", msg); return
-1;}while(0)
static int setup(void **state) {
monetdbe_database mdbe = NULL;
if (monetdbe_open(&mdbe, NULL, NULL))
- error("Failed to open database")
+ error("Failed to open database");
*state = mdbe;
- return 0;
+ return 0;
}
static int teardown(void **state) {
monetdbe_database mdbe = *state;
if (monetdbe_close(mdbe))
- error("Failed to close database")
- return 0;
+ error("Failed to close database");
+ return 0;
}
static void create_table_test(void **state) {
@@ -47,12 +47,12 @@ static void populate_table_test(void **s
char* err;
err = monetdbe_query(mdbe,
- "INSERT INTO test VALUES "
- "(4, 40, 400, 'aaa', x'aaaaaa', '2020-06-17', '12:00:00',
'2020-06-17 12:00:00'),"
- "(6, 60, 600, 'ccc', x'cccccc', '2022-06-17', '14:00:00',
'2022-06-17 14:00:00'),"
- "(5, 50, 500, 'bbb', x'bbbbbb', '2021-06-17', '13:00:00',
'2021-06-17 13:00:00'),"
- "(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
- NULL, NULL);
+ "INSERT INTO test VALUES "
+ "(4, 40, 400, 'aaa', x'aaaaaa', '2020-06-17',
'12:00:00', '2020-06-17 12:00:00'),"
+ "(6, 60, 600, 'ccc', x'cccccc', '2022-06-17',
'14:00:00', '2022-06-17 14:00:00'),"
+ "(5, 50, 500, 'bbb', x'bbbbbb', '2021-06-17',
'13:00:00', '2021-06-17 13:00:00'),"
+ "(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
+ NULL, NULL);
assert_null(err);
}
diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -4428,9 +4428,9 @@ BATcalcadd(BAT *b1, BAT *b2, BAT *s1, BA
/* if both inputs are sorted the same way, and no overflow
* occurred (we only know for sure if abort_on_error is set),
* the result is also sorted */
- bn->tsorted = (abort_on_error && b1->tsorted & b2->tsorted && nils == 0)
+ bn->tsorted = (abort_on_error && b1->tsorted && b2->tsorted && nils ==
0)
|| ncand <= 1 || nils == ncand;
- bn->trevsorted = (abort_on_error && b1->trevsorted & b2->trevsorted &&
nils == 0)
+ bn->trevsorted = (abort_on_error && b1->trevsorted && b2->trevsorted &&
nils == 0)
|| ncand <= 1 || nils == ncand;
bn->tkey = ncand <= 1;
bn->tnil = nils != 0;
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
@@ -546,35 +546,54 @@ static char *RAPIinstalladdons(void) {
static str
empty_return(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, size_t retcols, oid
seqbase)
{
+ str msg = MAL_SUCCEED;
+ void **res = GDKzalloc(retcols * sizeof(void*));
+
+ if (!res) {
+ msg = createException(MAL, "pyapi3.eval", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ goto bailout;
+ }
+
for (size_t i = 0; i < retcols; i++) {
if (isaBatType(getArgType(mb, pci, i))) {
BAT *b = COLnew(seqbase, getBatType(getArgType(mb, pci,
i)), 0, TRANSIENT);
if (!b) {
- for (size_t j = 0; j < i; j++) {
- if (isaBatType(getArgType(mb, pci, j)))
-
BBPunfix(*getArgReference_bat(stk, pci, j));
- else
-
VALclear(&stk->stk[pci->argv[j]]);
- }
- return createException(MAL, "rapi.eval",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ msg = createException(MAL, "pyapi3.eval",
GDK_EXCEPTION);
+ goto bailout;
}
- *getArgReference_bat(stk, pci, i) = b->batCacheid;
- BBPkeepref(b->batCacheid);
+ ((BAT**)res)[i] = b;
} else { // single value return, only for non-grouped
aggregations
// return NULL to conform to SQL aggregates
int tpe = getArgType(mb, pci, i);
if (!VALinit(&stk->stk[pci->argv[i]], tpe,
ATOMnilptr(tpe))) {
- for (size_t j = 0; j < i; j++) {
- if (isaBatType(getArgType(mb, pci, j)))
-
BBPunfix(*getArgReference_bat(stk, pci, j));
- else
-
VALclear(&stk->stk[pci->argv[j]]);
+ msg = createException(MAL, "pyapi3.eval",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ goto bailout;
+ }
+ ((ValPtr*)res)[i] = &stk->stk[pci->argv[i]];
+ }
+ }
+
+bailout:
+ if (res) {
+ for (size_t i = 0; i < retcols; i++) {
+ if (isaBatType(getArgType(mb, pci, i))) {
+ BAT *b = ((BAT**)res)[i];
+
+ if (b && msg) {
+ BBPreclaim(b);
+ } else if (b) {
+ BBPkeepref(*getArgReference_bat(stk,
pci, i) = b->batCacheid);
}
- return createException(MAL, "rapi.eval",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ } else if (msg) {
+ ValPtr pt = ((ValPtr*)res)[i];
+
+ if (pt)
+ VALclear(pt);
}
}
+ GDKfree(res);
}
- return MAL_SUCCEED;
+ return msg;
}
static str RAPIeval(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci,
bit grouped) {
diff --git a/monetdb5/modules/kernel/algebra.c
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -793,8 +793,9 @@ ALGcrossproduct(bat *l, bat *r, const ba
BAT *sl = NULL, *sr = NULL;
gdk_return ret;
- if ((L = BATdescriptor(*left)) == NULL ||
- (R = BATdescriptor(*right)) == NULL) {
+ L = BATdescriptor(*left);
+ R = BATdescriptor(*right);
+ if (L == NULL || R == NULL) {
if (L)
BBPunfix(L->batCacheid);
if (R)
diff --git a/sql/backends/monet5/UDF/capi/capi.c
b/sql/backends/monet5/UDF/capi/capi.c
--- a/sql/backends/monet5/UDF/capi/capi.c
+++ b/sql/backends/monet5/UDF/capi/capi.c
@@ -382,35 +382,54 @@ static char valid_path_characters[] = "a
static str
empty_return(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, size_t retcols, oid
seqbase)
{
+ str msg = MAL_SUCCEED;
+ void **res = GDKzalloc(retcols * sizeof(void*));
+
+ if (!res) {
+ msg = createException(MAL, "pyapi3.eval", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ goto bailout;
+ }
+
for (size_t i = 0; i < retcols; i++) {
if (isaBatType(getArgType(mb, pci, i))) {
BAT *b = COLnew(seqbase, getBatType(getArgType(mb, pci,
i)), 0, TRANSIENT);
if (!b) {
- for (size_t j = 0; j < i; j++) {
- if (isaBatType(getArgType(mb, pci, j)))
-
BBPunfix(*getArgReference_bat(stk, pci, j));
- else
-
VALclear(&stk->stk[pci->argv[j]]);
- }
- return createException(MAL, "cudf.eval",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ msg = createException(MAL, "pyapi3.eval",
GDK_EXCEPTION);
+ goto bailout;
}
- *getArgReference_bat(stk, pci, i) = b->batCacheid;
- BBPkeepref(b->batCacheid);
+ ((BAT**)res)[i] = b;
} else { // single value return, only for non-grouped
aggregations
// return NULL to conform to SQL aggregates
int tpe = getArgType(mb, pci, i);
if (!VALinit(&stk->stk[pci->argv[i]], tpe,
ATOMnilptr(tpe))) {
- for (size_t j = 0; j < i; j++) {
- if (isaBatType(getArgType(mb, pci, j)))
-
BBPunfix(*getArgReference_bat(stk, pci, j));
- else
-
VALclear(&stk->stk[pci->argv[j]]);
+ msg = createException(MAL, "pyapi3.eval",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ goto bailout;
+ }
+ ((ValPtr*)res)[i] = &stk->stk[pci->argv[i]];
+ }
+ }
+
+bailout:
+ if (res) {
+ for (size_t i = 0; i < retcols; i++) {
+ if (isaBatType(getArgType(mb, pci, i))) {
+ BAT *b = ((BAT**)res)[i];
+
+ if (b && msg) {
+ BBPreclaim(b);
+ } else if (b) {
+ BBPkeepref(*getArgReference_bat(stk,
pci, i) = b->batCacheid);
}
- return createException(MAL, "cudf.eval",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ } else if (msg) {
+ ValPtr pt = ((ValPtr*)res)[i];
+
+ if (pt)
+ VALclear(pt);
}
}
+ GDKfree(res);
}
- return MAL_SUCCEED;
+ return msg;
}
static str CUDFeval(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci,
diff --git a/sql/backends/monet5/UDF/pyapi3/pyapi3.c
b/sql/backends/monet5/UDF/pyapi3/pyapi3.c
--- a/sql/backends/monet5/UDF/pyapi3/pyapi3.c
+++ b/sql/backends/monet5/UDF/pyapi3/pyapi3.c
@@ -1636,37 +1636,56 @@ wrapup:
}
static str CreateEmptyReturn(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci,
- size_t retcols, oid
seqbase)
+ size_t retcols, oid
seqbase)
{
+ str msg = MAL_SUCCEED;
+ void **res = GDKzalloc(retcols * sizeof(void*));
+
+ if (!res) {
+ msg = createException(MAL, "pyapi3.eval", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ goto bailout;
+ }
+
for (size_t i = 0; i < retcols; i++) {
if (isaBatType(getArgType(mb, pci, i))) {
BAT *b = COLnew(seqbase, getBatType(getArgType(mb, pci,
i)), 0, TRANSIENT);
if (!b) {
- for (size_t j = 0; j < i; j++) {
- if (isaBatType(getArgType(mb, pci, j)))
-
BBPunfix(*getArgReference_bat(stk, pci, j));
- else
-
VALclear(&stk->stk[pci->argv[j]]);
- }
- return createException(MAL, "pyapi3.eval",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ msg = createException(MAL, "pyapi3.eval",
GDK_EXCEPTION);
+ goto bailout;
}
- *getArgReference_bat(stk, pci, i) = b->batCacheid;
- BBPkeepref(b->batCacheid);
+ ((BAT**)res)[i] = b;
} else { // single value return, only for non-grouped
aggregations
// return NULL to conform to SQL aggregates
int tpe = getArgType(mb, pci, i);
if (!VALinit(&stk->stk[pci->argv[i]], tpe,
ATOMnilptr(tpe))) {
- for (size_t j = 0; j < i; j++) {
- if (isaBatType(getArgType(mb, pci, j)))
-
BBPunfix(*getArgReference_bat(stk, pci, j));
- else
-
VALclear(&stk->stk[pci->argv[j]]);
+ msg = createException(MAL, "pyapi3.eval",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ goto bailout;
+ }
+ ((ValPtr*)res)[i] = &stk->stk[pci->argv[i]];
+ }
+ }
+
+bailout:
+ if (res) {
+ for (size_t i = 0; i < retcols; i++) {
+ if (isaBatType(getArgType(mb, pci, i))) {
+ BAT *b = ((BAT**)res)[i];
+
+ if (b && msg) {
+ BBPreclaim(b);
+ } else if (b) {
+ BBPkeepref(*getArgReference_bat(stk,
pci, i) = b->batCacheid);
}
- return createException(MAL, "pyapi3.eval",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ } else if (msg) {
+ ValPtr pt = ((ValPtr*)res)[i];
+
+ if (pt)
+ VALclear(pt);
}
}
+ GDKfree(res);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list