MonetDB: default - Two fixes: 1. I forgot to project the candida...
Changeset: e33f3c268802 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e33f3c268802 Modified Files: sql/backends/monet5/sql_upgrades.c sql/storage/bat/bat_logger.c Branch: default Log Message: Two fixes: 1. I forgot to project the candidates before applying the update (this fixes the failing upgrade chain tests I think) 2. Function sys.queue upgrade had the wrong MAL module in the upgrade diffs (32 lines): diff --git a/sql/backends/monet5/sql_upgrades.c b/sql/backends/monet5/sql_upgrades.c --- a/sql/backends/monet5/sql_upgrades.c +++ b/sql/backends/monet5/sql_upgrades.c @@ -2303,7 +2303,7 @@ sql_update_jun2020(Client c, mvc *sql, c "\"progress\" int,\n" "\"workers\" int,\n" "\"memory\" int)\n" - " external name sql.sysmon_queue;\n" + " external name sysmon.queue;\n" "grant execute on function sys.queue to public;\n" "create view sys.queue as select * from sys.queue();\n" "grant select on sys.queue to public;\n" diff --git a/sql/storage/bat/bat_logger.c b/sql/storage/bat/bat_logger.c --- a/sql/storage/bat/bat_logger.c +++ b/sql/storage/bat/bat_logger.c @@ -953,8 +953,15 @@ bl_postversion(void *lg) return GDK_FAIL; } + BAT *cands_project = BATproject(cands3, func_mod); + if (cands_project == NULL) { + bat_destroy(func_mod); + bat_destroy(cands3); + return GDK_FAIL; + } const char *right_module = "aggr"; /* set module to 'aggr' */ - BAT *update_bat = BATconstant(0, TYPE_str, right_module, 4, TRANSIENT); + BAT *update_bat = BATconstant(cands_project->hseqbase, TYPE_str, right_module, 4, TRANSIENT); + bat_destroy(cands_project); if (update_bat == NULL) { bat_destroy(func_mod); bat_destroy(cands3); ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - Merged with Jun2020
Changeset: 436fdf28d606 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=436fdf28d606 Added Files: sql/test/json/Tests/jsonkeyarray.Bug-6858.stable.err sql/test/json/Tests/jsonkeyarray.Bug-6858.stable.out Modified Files: common/stream/stream.c geom/monetdb5/geom.c monetdb5/modules/atoms/json.c monetdb5/modules/kernel/batmmath.c monetdb5/modules/kernel/mmath.c sql/backends/monet5/sql.h sql/server/rel_optimizer.c sql/server/rel_select.c Branch: default Log Message: Merged with Jun2020 diffs (239 lines): diff --git a/common/stream/stream.c b/common/stream/stream.c --- a/common/stream/stream.c +++ b/common/stream/stream.c @@ -2187,7 +2187,7 @@ write_callback(char *buffer, size_t size size_t maxsize; maxsize = (c->usesize + size + BLOCK_CURL - 1) & ~(BLOCK_CURL - 1); - b = realloc(c->buffer, c->maxsize); + b = realloc(c->buffer, maxsize); if (b == NULL) return 0; /* indicate failure to library */ c->buffer = b; diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c --- a/geom/monetdb5/geom.c +++ b/geom/monetdb5/geom.c @@ -50,18 +50,20 @@ wkbNULLcopy(void) static inline void degrees2radians(double *x, double *y, double *z) { - *x *= M_PI / 180.0; - *y *= M_PI / 180.0; - *z *= M_PI / 180.0; + double val = M_PI / 180.0; + *x *= val; + *y *= val; + *z *= val; } /** convert radians to degrees */ static inline void radians2degrees(double *x, double *y, double *z) { - *x *= 180.0 / M_PI; - *y *= 180.0 / M_PI; - *z *= 180.0 / M_PI; + double val = 180.0 / M_PI; + *x *= val; + *y *= val; + *z *= val; } static str diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c --- a/monetdb5/modules/atoms/json.c +++ b/monetdb5/modules/atoms/json.c @@ -1554,6 +1554,13 @@ JSONkeyArray(json *ret, json *js) } if (jt->elm[i].valuelen) strncpy(r, jt->elm[i].value - 1, jt->elm[i].valuelen + 2); + else { + r = GDKstrdup("\"\""); + if(r == NULL) { + JSONfree(jt); + goto memfail; + } + } result = JSONglue(result, r, ','); if (result == NULL) { JSONfree(jt); diff --git a/monetdb5/modules/kernel/batmmath.c b/monetdb5/modules/kernel/batmmath.c --- a/monetdb5/modules/kernel/batmmath.c +++ b/monetdb5/modules/kernel/batmmath.c @@ -450,25 +450,25 @@ CMDscience_bat_##FUNC(Client cntxt, MalB static double radians(double x) { - return x * 3.14159265358979323846 / 180.0; + return x * (3.14159265358979323846 / 180.0); } static float radiansf(float x) { - return (float) (x * 3.14159265358979323846 / 180.0); + return (float) (x * (3.14159265358979323846 / 180.0)); } static double degrees(double x) { - return x * 180.0 / 3.14159265358979323846; + return x * (180.0 / 3.14159265358979323846); } static float degreesf(float x) { - return (float) (x * 180.0 / 3.14159265358979323846); + return (float) (x * (180.0 / 3.14159265358979323846)); } mal_export str CMDscience_bat_asin(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); diff --git a/monetdb5/modules/kernel/mmath.c b/monetdb5/modules/kernel/mmath.c --- a/monetdb5/modules/kernel/mmath.c +++ b/monetdb5/modules/kernel/mmath.c @@ -32,8 +32,8 @@ #endif #define cot(x) (1 / tan(x)) -#define radians(x) ((x) * 3.14159265358979323846 / 180.0) -#define degrees(x) ((x) * 180.0 / 3.14159265358979323846) +#define radians(x) ((x) * (3.14159265358979323846 / 180.0)) +#define degrees(x) ((x) * (180.0 / 3.14159265358979323846)) double logbs(double x, double base) diff --git a/sql/backends/monet5/sql.h b/sql/backends/monet5/sql.h --- a/sql/backends/monet5/sql.h +++ b/sql/backends/monet5/sql.h @@ -269,8 +269,8 @@ sql5_export str dbl_round_wrap(dbl *res, sql5_export str dbl_bat_round_wrap(bat *res, const bat *v, const bte *r); sql5_export str dbl_trunc_wrap(dbl *res, const dbl *v, const int *r); -#define radians(x) ((x) * 3.14159265358979323846 /180.0 ) -#define degrees(x) ((x) * 180.0/3.14159265358979323846 ) +#define radians(x) ((x) * (3.14159265358979323846 / 180.0)) +#define degrees(x) ((x) * (180.0 / 3.14159265358979323846)) sql5_export str SQLcst_alpha_cst(dbl *res, const dbl *decl, const dbl *theta); sql5_export str SQLbat_alpha_cst(bat *res, const bat *decl, const dbl *theta); diff --git a/sql/se
MonetDB: Jun2020 - Isolate number constants from the input, so c...
Changeset: e8d3e508fc4d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e8d3e508fc4d Modified Files: geom/monetdb5/geom.c monetdb5/modules/kernel/batmmath.c monetdb5/modules/kernel/mmath.c sql/backends/monet5/sql.h Branch: Jun2020 Log Message: Isolate number constants from the input, so compilers can optimize trival math expressions diffs (91 lines): diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c --- a/geom/monetdb5/geom.c +++ b/geom/monetdb5/geom.c @@ -48,18 +48,20 @@ wkbNULLcopy(void) static inline void degrees2radians(double *x, double *y, double *z) { - *x *= M_PI / 180.0; - *y *= M_PI / 180.0; - *z *= M_PI / 180.0; + double val = M_PI / 180.0; + *x *= val; + *y *= val; + *z *= val; } /** convert radians to degrees */ static inline void radians2degrees(double *x, double *y, double *z) { - *x *= 180.0 / M_PI; - *y *= 180.0 / M_PI; - *z *= 180.0 / M_PI; + double val = 180.0 / M_PI; + *x *= val; + *y *= val; + *z *= val; } static str diff --git a/monetdb5/modules/kernel/batmmath.c b/monetdb5/modules/kernel/batmmath.c --- a/monetdb5/modules/kernel/batmmath.c +++ b/monetdb5/modules/kernel/batmmath.c @@ -450,25 +450,25 @@ CMDscience_bat_##FUNC(Client cntxt, MalB static double radians(double x) { - return x * 3.14159265358979323846 / 180.0; + return x * (3.14159265358979323846 / 180.0); } static float radiansf(float x) { - return (float) (x * 3.14159265358979323846 / 180.0); + return (float) (x * (3.14159265358979323846 / 180.0)); } static double degrees(double x) { - return x * 180.0 / 3.14159265358979323846; + return x * (180.0 / 3.14159265358979323846); } static float degreesf(float x) { - return (float) (x * 180.0 / 3.14159265358979323846); + return (float) (x * (180.0 / 3.14159265358979323846)); } mal_export str CMDscience_bat_asin(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); diff --git a/monetdb5/modules/kernel/mmath.c b/monetdb5/modules/kernel/mmath.c --- a/monetdb5/modules/kernel/mmath.c +++ b/monetdb5/modules/kernel/mmath.c @@ -32,8 +32,8 @@ #endif #define cot(x) (1 / tan(x)) -#define radians(x) ((x) * 3.14159265358979323846 / 180.0) -#define degrees(x) ((x) * 180.0 / 3.14159265358979323846) +#define radians(x) ((x) * (3.14159265358979323846 / 180.0)) +#define degrees(x) ((x) * (180.0 / 3.14159265358979323846)) double logbs(double x, double base) diff --git a/sql/backends/monet5/sql.h b/sql/backends/monet5/sql.h --- a/sql/backends/monet5/sql.h +++ b/sql/backends/monet5/sql.h @@ -270,8 +270,8 @@ sql5_export str dbl_round_wrap(dbl *res, sql5_export str dbl_bat_round_wrap(bat *res, const bat *v, const bte *r); sql5_export str dbl_trunc_wrap(dbl *res, const dbl *v, const int *r); -#define radians(x) ((x) * 3.14159265358979323846 /180.0 ) -#define degrees(x) ((x) * 180.0/3.14159265358979323846 ) +#define radians(x) ((x) * (3.14159265358979323846 / 180.0)) +#define degrees(x) ((x) * (180.0 / 3.14159265358979323846)) sql5_export str SQLcst_alpha_cst(dbl *res, const dbl *decl, const dbl *theta); sql5_export str SQLbat_alpha_cst(bat *res, const bat *decl, const dbl *theta); ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - Fix example_append
Changeset: 7e1d517924cb for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7e1d517924cb Modified Files: ctest/tools/monetdbe/example_append.c Branch: default Log Message: Fix example_append diffs (21 lines): diff --git a/ctest/tools/monetdbe/example_append.c b/ctest/tools/monetdbe/example_append.c --- a/ctest/tools/monetdbe/example_append.c +++ b/ctest/tools/monetdbe/example_append.c @@ -39,7 +39,7 @@ main(void) if ((err = monetdbe_query(mdbe, "SELECT * FROM test; ", &result, NULL)) != NULL) error(err) fprintf(stdout, "Query result with %zu cols and %"PRId64" rows\n", result->ncols, result->nrows); - monetdbe_column* rcol[result->ncols]; + monetdbe_column* rcol[6]; for (int64_t r = 0; r < result->nrows; r++) { for (size_t c = 0; c < result->ncols; c++) { if ((err = monetdbe_result_fetch(result, rcol+c, c)) != NULL) @@ -116,7 +116,7 @@ main(void) } printf("\n"); } - if ((err = monetdbe_append(mdbe, "sys", "test", rcol, result->ncols)) != NULL) + if ((err = monetdbe_append(mdbe, "sys", "test", rcol, 6)) != NULL) error(err) /* we can now cleanup the previous query */ if ((err = monetdbe_cleanup_result(mdbe, result)) != NULL) ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - small improvement of result set (ie keep nr_r...
Changeset: 88c3392da908 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=88c3392da908 Modified Files: ctest/tools/monetdbe/example_decimals.c sql/backends/monet5/sql_result.c sql/include/sql_catalog.h sql/storage/bat/res_table.c Branch: default Log Message: small improvement of result set (ie keep nr_rows) diffs (150 lines): diff --git a/ctest/tools/monetdbe/example_decimals.c b/ctest/tools/monetdbe/example_decimals.c --- a/ctest/tools/monetdbe/example_decimals.c +++ b/ctest/tools/monetdbe/example_decimals.c @@ -60,7 +60,10 @@ main(void) if (col->data[r] == col->null_value) { printf("NULL"); } else { - printf("%d", col->data[r]); + if (col->scale) + printf("%d.%02d", col->data[r]/(int)col->scale, col->data[r]%(int)col->scale); + else + printf("%d", col->data[r]); } break; } @@ -78,7 +81,10 @@ main(void) if (col->data[r] == col->null_value) { printf("NULL"); } else { - printf("%" PRId64, col->data[r]); + if (col->scale) + printf("%" PRId64 ".%03" PRId64, col->data[r]/(int64_t)col->scale, col->data[r]%(int64_t)col->scale); + else + printf("%" PRId64, col->data[r]); } break; } diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c --- a/sql/backends/monet5/sql_result.c +++ b/sql/backends/monet5/sql_result.c @@ -2150,7 +2150,6 @@ mvc_export_head_prot10(backend *b, strea size_t i = 0; BUN count = 0; res_table *t = res_tables_find(m->results, res_id); - BAT *order = NULL; int fres = 0; if (!t || !s) { @@ -2160,11 +2159,7 @@ mvc_export_head_prot10(backend *b, strea /* tuple count */ if (only_header) { if (t->order) { - order = BBPquickdesc(t->order, false); - if (!order) - return -1; - - count = BATcount(order); + count = t->nr_rows; } else count = 1; } @@ -2312,7 +2307,6 @@ mvc_export_head(backend *b, stream *s, i int i, res = 0; BUN count = 0; res_table *t = res_tables_find(m->results, res_id); - BAT *order = NULL; if (!s || !t) return 0; @@ -2334,13 +2328,10 @@ mvc_export_head(backend *b, stream *s, i /* tuple count */ if (only_header) { if (t->order) { - order = BBPquickdesc(t->order, false); - if (!order) - return -1; - - count = BATcount(order); - } else + count = t->nr_rows; + } else { count = 1; + } } m->rowcnt = count; sqlvar_set_number(find_global_var(m, mvc_bind_schema(m, "sys"), "rowcnt"), m->rowcnt); @@ -2467,7 +2458,7 @@ mvc_export_file(backend *b, stream *s, r order = BATdescriptor(t->order); if (!order) return -1; - count = BATcount(order); + count = t->nr_rows; res = mvc_export_table(b, s, t, order, 0, count, "", t->tsep, t->rsep, t->ssep, t->ns); BBPunfix(order->batCacheid); @@ -2514,8 +2505,8 @@ mvc_export_result(backend *b, stream *s, return -1; count = m->reply_size; - if (m->reply_size != -2 && (count <= 0 || count >= BATcount(order))) { - count = BATcount(order); + if (m->reply_size != -2 && (count <= 0 || count >= t->nr_rows)) { + count = t->nr_rows; clean = 1; } if (json) { @@ -2565,11 +2556,11 @@ mvc_export_chunk(backend *b, stream *s, return -1; cnt = nr; if (cnt == 0) - cnt = BATcount(order); - if (offset >= BATcount(order)) + cnt = t->nr_rows; + if (offset >= t->nr_rows) cnt = 0; - if (cnt == BUN_NONE ||
MonetDB: default - Added bat logger upgrade for MAL module fix f...
Changeset: bd2f79d1241e for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bd2f79d1241e Modified Files: clients/Tests/MAL-signatures.stable.out clients/Tests/MAL-signatures.stable.out.int128 sql/backends/monet5/sql.c sql/backends/monet5/sql.mal sql/common/sql_types.c sql/storage/bat/bat_logger.c sql/test/emptydb/Tests/check.stable.out sql/test/emptydb/Tests/check.stable.out.32bit sql/test/emptydb/Tests/check.stable.out.int128 Branch: default Log Message: Added bat logger upgrade for MAL module fix for SQL aggregates all, null, zero_or_one and not_unique from sql to aggr. Also approved output diffs (300 lines): diff --git a/clients/Tests/MAL-signatures.stable.out b/clients/Tests/MAL-signatures.stable.out --- a/clients/Tests/MAL-signatures.stable.out +++ b/clients/Tests/MAL-signatures.stable.out @@ -140,6 +140,7 @@ stdout of test 'MAL-signatures` in direc [ "aggr", "min", "command aggr.min(X_1:bat[:any_2], X_2:bit):any_2 ", "ALGminany_skipnil;", "" ] [ "aggr", "not_anyequal", "pattern aggr.not_anyequal(X_1:any_1, X_2:any_1):bit ", "CMDvarNE;","" ] [ "aggr", "not_exist","pattern aggr.not_exist(X_1:any_1):bit ", "SQLnot_exist;","" ] +[ "aggr", "not_unique", "command aggr.not_unique(X_1:bat[:oid]):bit ", "not_unique;", "" ] [ "aggr", "null", "command aggr.null(X_1:bat[:any_1]):bit ", "SQLnil;", "" ] [ "aggr", "prod", "command aggr.prod(X_1:bat[:bte], X_2:bat[:oid], X_3:bat[:any_1]):bat[:bte] ", "AGGRprod3_bte;", "" ] [ "aggr", "prod", "command aggr.prod(X_1:bat[:dbl], X_2:bat[:oid], X_3:bat[:any_1]):bat[:dbl] ", "AGGRprod3_dbl;", "" ] @@ -10125,7 +10126,6 @@ stdout of test 'MAL-signatures` in direc [ "sql", "ms_trunc", "command sql.ms_trunc(X_1:flt, X_2:int):flt ", "flt_trunc_wrap;", "" ] [ "sql", "mvc", "pattern sql.mvc():int ", "SQLmvc;", "" ] [ "sql", "next_value", "unsafe pattern sql.next_value(X_1:str, X_2:str):lng ", "mvc_next_value;", "" ] -[ "sql", "not_unique", "command sql.not_unique(X_1:bat[:oid]):bit ", "not_unique;", "" ] [ "sql", "nth_value","pattern sql.nth_value(X_1:any_1, X_2:any_2, X_3:lng, X_4:lng):any_1 ", "SQLnth_value;","" ] [ "sql", "ntile","pattern sql.ntile(X_1:any_1, X_2:any_2, X_3:any_3, X_4:any_4):any_2 ", "SQLntile;","" ] [ "sql", "optimizer_updates","pattern sql.optimizer_updates():void ","SQLoptimizersUpdate;", "" ] diff --git a/clients/Tests/MAL-signatures.stable.out.int128 b/clients/Tests/MAL-signatures.stable.out.int128 --- a/clients/Tests/MAL-signatures.stable.out.int128 +++ b/clients/Tests/MAL-signatures.stable.out.int128 @@ -149,6 +149,7 @@ stdout of test 'MAL-signatures` in direc [ "aggr", "min", "command aggr.min(X_1:bat[:any_2], X_2:bit):any_2 ", "ALGminany_skipnil;", "" ] [ "aggr", "not_anyequal", "pattern aggr.not_anyequal(X_1:any_1, X_2:any_1):bit ", "CMDvarNE;","" ] [ "aggr", "not_exist","pattern aggr.not_exist(X_1:any_1):bit ", "SQLnot_exist;","" ] +[ "aggr", "not_unique", "command aggr.not_unique(X_1:bat[:oid]):bit ", "not_unique;", "" ] [ "aggr", "null", "command aggr.null(X_1:bat[:any_1]):bit ", "SQLnil;", "" ] [ "aggr", "prod", "command aggr.prod(X_1:bat[:bte], X_2:bat[:oid], X_3:bat[:any_1]):bat[:bte] ", "AGGRprod3_bte;", "" ] [ "aggr", "prod", "command aggr.prod(X_1:bat[:dbl], X_2:bat[:oid], X_3:bat[:any_1]):bat[:dbl] ", "AGGRprod3_dbl;", "" ] @@ -13483,7 +13484,6 @@ stdout of test 'MAL-signatures` in direc [ "sql", "ms_trunc", "command sql.ms_trunc(X_1:flt, X_2:int):flt ", "flt_trunc_wrap;", "" ] [ "sql", "mvc", "pattern sql.mvc():int ", "SQLmvc;", "" ] [ "sql", "next_value", "unsafe pattern sql.next_value(X_1:str, X_2:str):lng ", "mvc_next_value;", "" ] -[ "sql", "not_unique", "command sql.not_unique(X_1:bat[:oid]):bit ", "not_unique;", "" ] [ "sql", "nth_value","pattern sql.nth_value(X_1:any_1, X_2:any_2, X_3:lng, X_4:lng):any_1 ", "SQLnth_value;","" ] [ "sql", "ntile","pattern sql.ntile(X_1:any_1, X_2:any_2, X_3:any_3, X_4:any_4):any_2 ", "SQLntile;","" ] [ "sql", "optimizer_updates","pattern sql.optimizer_updates():void ","SQLoptimizersUpdate;", "" ] 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 @@ -5916,7 +5916,7 @@ static mel_func sql_init_funcs[] = { //we use bat.single now //pattern("sql", "single", CMDBATsingle, false, "", args(1,2, batargany("",2),argany("x",2))), pattern("sql
MonetDB: default - fix compilation using clang
Changeset: c71ea4121be8 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c71ea4121be8 Modified Files: cmake/monetdb-findpackages.cmake tools/monetdbe/monetdbe.c tools/monetdbe/monetdbe_mapi.h Branch: default Log Message: fix compilation using clang diffs (92 lines): diff --git a/cmake/monetdb-findpackages.cmake b/cmake/monetdb-findpackages.cmake --- a/cmake/monetdb-findpackages.cmake +++ b/cmake/monetdb-findpackages.cmake @@ -34,7 +34,7 @@ if(WITH_PCRE) find_package(PCRE) endif() -if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" AND ${CMAKE_SYSTEM_VERSION} VERSION_LESS "19.0.0") +if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" AND ${CMAKE_HOST_SYSTEM_VERSION} VERSION_LESS "19.0.0") find_package(CommonCrypto) else() find_package(OpenSSL) diff --git a/tools/monetdbe/monetdbe.c b/tools/monetdbe/monetdbe.c --- a/tools/monetdbe/monetdbe.c +++ b/tools/monetdbe/monetdbe.c @@ -313,16 +313,8 @@ monetdbe_query_internal(monetdbe_databas if (m->results) { res_internal->res.ncols = (size_t) m->results->nr_cols; res_internal->monetdbe_resultset = m->results; - if (m->results->nr_cols > 0 && m->results->order) { - BAT* bb = BATdescriptor(m->results->order); - m->results = NULL; - if (!bb) { - mdbe->msg = createException(MAL, "monetdbe.monetdbe_query_internal", RUNTIME_OBJECT_MISSING); - goto cleanup; - } - res_internal->res.nrows = BATcount(bb); - BBPunfix(bb->batCacheid); - } + if (m->results->nr_cols > 0) + res_internal->res.nrows = m->results->nr_rows; m->results = NULL; res_internal->converted_columns = GDKzalloc(sizeof(monetdbe_column*) * res_internal->res.ncols); if (!res_internal->converted_columns) { @@ -794,16 +786,8 @@ monetdbe_execute(monetdbe_statement *stm if (m->results) { res_internal->res.ncols = (size_t) m->results->nr_cols; res_internal->monetdbe_resultset = m->results; - if (m->results->nr_cols > 0 && m->results->order) { - BAT* bb = BATdescriptor(m->results->order); - m->results = NULL; - if (!bb) { - mdbe->msg = createException(MAL, "monetdbe.monetdbe_query_internal", RUNTIME_OBJECT_MISSING); - goto cleanup; - } - res_internal->res.nrows = BATcount(bb); - BBPunfix(bb->batCacheid); - } + if (m->results->nr_cols > 0) + res_internal->res.nrows = m->results->nr_rows; m->results = NULL; res_internal->converted_columns = GDKzalloc(sizeof(monetdbe_column*) * res_internal->res.ncols); if (!res_internal->converted_columns) { @@ -1007,9 +991,9 @@ GENERATE_BASE_HEADERS(monetdbe_data_time mdbe->msg = createException(MAL, "monetdbe.monetdbe_result_fetch", MAL_MALLOC_FAIL); \ goto cleanup; \ } \ - bat_data->type = monetdbe_##tpe; \ + bat_data->type = monetdbe_##tpe; \ bat_data->is_null = tpe##_is_null; \ - bat_data->scale = pow(10, sqltpe->scale); \ + if (sqltpe->type->radix == 10) bat_data->scale = pow(10, sqltpe->scale); \ column_result = (monetdbe_column*) bat_data; #define GENERATE_BAT_INPUT(b, tpe, tpe_name, mtype) \ diff --git a/tools/monetdbe/monetdbe_mapi.h b/tools/monetdbe/monetdbe_mapi.h --- a/tools/monetdbe/monetdbe_mapi.h +++ b/tools/monetdbe/monetdbe_mapi.h @@ -9,12 +9,12 @@ #include #include -typedef struct MapiStruct { +struct MapiStruct { monetdbe_database mdbe; char *msg; -} *Mapi; +}; -typedef struct MapiStatement { +struct MapiStatement { Mapi mid; char *query; monetdbe_result *result; @@ -22,6 +22,6 @@ typedef struct MapiStatement { monetdbe_cnt current_row; monetdbe_cnt affected_rows; char *msg; -} *MapiHdl; +}; #endif // MONETDBE_MAPI_H_ ___ checkin-list mailing
MonetDB: Jun2020 - Fix memory corruption bug in curl stream
Changeset: e4fa47b03033 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e4fa47b03033 Modified Files: common/stream/stream.c Branch: Jun2020 Log Message: Fix memory corruption bug in curl stream diffs (12 lines): diff --git a/common/stream/stream.c b/common/stream/stream.c --- a/common/stream/stream.c +++ b/common/stream/stream.c @@ -2183,7 +2183,7 @@ write_callback(char *buffer, size_t size size_t maxsize; maxsize = (c->usesize + size + BLOCK_CURL - 1) & ~(BLOCK_CURL - 1); - b = realloc(c->buffer, c->maxsize); + b = realloc(c->buffer, maxsize); if (b == NULL) return 0; /* indicate failure to library */ c->buffer = b; ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - monetdbe_append fixes - updated test
Changeset: 637252a7de5e for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=637252a7de5e Modified Files: ctest/tools/monetdbe/example_append.c tools/monetdbe/monetdbe.c Branch: default Log Message: monetdbe_append fixes - updated test diffs (275 lines): diff --git a/ctest/tools/monetdbe/example_append.c b/ctest/tools/monetdbe/example_append.c --- a/ctest/tools/monetdbe/example_append.c +++ b/ctest/tools/monetdbe/example_append.c @@ -13,6 +13,11 @@ #define error(msg) {fprintf(stderr, "Failure: %s\n", msg); return -1;} +#define date_eq(d1, d2) (d1.year == d2.year && d1.month == d2.month && d1.day == d2.day) +#define time_eq(t1, t2) (t1.hours == t2.hours && t1.minutes == t2.minutes && t1.seconds == t2.seconds && t1.ms == t2.ms) + +static char hexit[] = "0123456789ABCDEF"; + int main(void) { @@ -23,15 +28,18 @@ main(void) // second argument is a string for the db directory or NULL for in-memory mode if (monetdbe_open(&mdbe, NULL, NULL)) error("Failed to open database") - if ((err = monetdbe_query(mdbe, "CREATE TABLE test (x integer, y string)", NULL, NULL)) != NULL) + if ((err = monetdbe_query(mdbe, "CREATE TABLE test (x integer, y string, ts timestamp, dt date, t time, b blob)", NULL, NULL)) != NULL) error(err) - if ((err = monetdbe_query(mdbe, "INSERT INTO test VALUES (42, 'Hello'), (NULL, 'World')", NULL, NULL)) != NULL) + if ((err = monetdbe_query(mdbe, "INSERT INTO test VALUES (42, 'Hello', '2020-01-02 10:20:30', '2020-01-02', '10:20:30', '01020308'), \ + (NULL, 'World', NULL, NULL, NULL, NULL),\ + (NULL, 'Foo', NULL, NULL, NULL, NULL), \ + (43, 'Bar', '2021-02-03 11:21:31', '2021-02-03', '11:21:31', '01020306')", NULL, NULL)) != NULL) error(err) - if ((err = monetdbe_query(mdbe, "SELECT x, y FROM test; ", &result, NULL)) != NULL) + if ((err = monetdbe_query(mdbe, "SELECT * FROM test; ", &result, NULL)) != NULL) error(err) fprintf(stdout, "Query result with %zu cols and %"PRId64" rows\n", result->ncols, result->nrows); - monetdbe_column* rcol[2]; + monetdbe_column* rcol[result->ncols]; for (int64_t r = 0; r < result->nrows; r++) { for (size_t c = 0; c < result->ncols; c++) { if ((err = monetdbe_result_fetch(result, rcol+c, c)) != NULL) @@ -55,6 +63,48 @@ main(void) } break; } + case monetdbe_date: { + monetdbe_column_date * col = (monetdbe_column_date *) rcol[c]; + if (date_eq(col->data[r], col->null_value)) { + printf("NULL"); + } else { + printf("%d-%d-%d", col->data[r].year, col->data[r].month, col->data[r].day); + } + break; + } + case monetdbe_time: { + monetdbe_column_time * col = (monetdbe_column_time *) rcol[c]; + if (time_eq(col->data[r], col->null_value)) { + printf("NULL"); + } else { + printf("%d:%d:%d.%d", col->data[r].hours, col->data[r].minutes, col->data[r].seconds, col->data[r].ms); + } + break; + } + case monetdbe_timestamp: { + monetdbe_column_timestamp * col = (monetdbe_column_timestamp *) rcol[c]; + if (date_eq(col->data[r].date, col->null_value.date) && time_eq(col->data[r].time, col->null_value.time)) { + printf("NULL"); + } else { + printf("%d-%d-%d ", col->data[r].date.year, col->data[r].date.month, col->data[r].date.day); + printf("%d:%d:%d.%d", col->data[r].time.hours, col->data[r].time.minutes, col->data[r].time.seconds, col->data[r].time.ms); + } +
MonetDB: default - Added bulk implementation for SQLany_cmp and ...
Changeset: 7b74b87164c6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7b74b87164c6 Modified Files: clients/Tests/MAL-signatures.stable.out clients/Tests/MAL-signatures.stable.out.int128 sql/backends/monet5/sql.c sql/backends/monet5/sql_subquery.c sql/backends/monet5/sql_subquery.h sql/backends/monet5/sql_subquery.mal sql/common/sql_types.c Branch: default Log Message: Added bulk implementation for SQLany_cmp and SQLall_cmp. Also changed MAL module of sql.zero_or_one, sql.all and sql.null to aggr, because in fact they are aggregates and we don't wanna confuse MAL optimizers diffs (truncated from 724 to 300 lines): diff --git a/clients/Tests/MAL-signatures.stable.out b/clients/Tests/MAL-signatures.stable.out --- a/clients/Tests/MAL-signatures.stable.out +++ b/clients/Tests/MAL-signatures.stable.out @@ -65,6 +65,7 @@ stdout of test 'MAL-signatures` in direc % module, function, signature, address,comment # name % clob,clob, clob, clob, clob # type % 12, 28, 313,42, 0 # length +[ "aggr", "all", "command aggr.all(X_1:bat[:any_1]):any_1 ", "SQLall;", "" ] [ "aggr", "allnotequal", "command aggr.allnotequal(X_1:bat[:any_1], X_2:bat[:any_1]):bit ", "SQLallnotequal;", "" ] [ "aggr", "anyequal", "pattern aggr.anyequal(X_1:any_1, X_2:any_1):bit ", "CMDvarEQ;","" ] [ "aggr", "anyequal", "command aggr.anyequal(X_1:bat[:any_1], X_2:bat[:any_1]):bit ", "SQLanyequal;", "" ] @@ -139,6 +140,7 @@ stdout of test 'MAL-signatures` in direc [ "aggr", "min", "command aggr.min(X_1:bat[:any_2], X_2:bit):any_2 ", "ALGminany_skipnil;", "" ] [ "aggr", "not_anyequal", "pattern aggr.not_anyequal(X_1:any_1, X_2:any_1):bit ", "CMDvarNE;","" ] [ "aggr", "not_exist","pattern aggr.not_exist(X_1:any_1):bit ", "SQLnot_exist;","" ] +[ "aggr", "null", "command aggr.null(X_1:bat[:any_1]):bit ", "SQLnil;", "" ] [ "aggr", "prod", "command aggr.prod(X_1:bat[:bte], X_2:bat[:oid], X_3:bat[:any_1]):bat[:bte] ", "AGGRprod3_bte;", "" ] [ "aggr", "prod", "command aggr.prod(X_1:bat[:dbl], X_2:bat[:oid], X_3:bat[:any_1]):bat[:dbl] ", "AGGRprod3_dbl;", "" ] [ "aggr", "prod", "command aggr.prod(X_1:bat[:flt], X_2:bat[:oid], X_3:bat[:any_1]):bat[:dbl] ", "AGGRprod3_dbl;", "" ] @@ -246,6 +248,8 @@ stdout of test 'MAL-signatures` in direc [ "aggr", "str_group_concat", "pattern aggr.str_group_concat(X_1:bat[:str], X_2:bat[:str], X_3:bat[:oid], X_4:bit):str ", "CMDBATstr_group_concat;", "" ] [ "aggr", "str_group_concat", "pattern aggr.str_group_concat(X_1:bat[:str], X_2:bat[:str], X_3:bit):str ", "CMDBATstr_group_concat;", "" ] [ "aggr", "str_group_concat", "pattern aggr.str_group_concat(X_1:bat[:str], X_2:bit):str ", "CMDBATstr_group_concat;", "" ] +[ "aggr", "suball", "pattern aggr.suball(X_1:bat[:any_1], X_2:bat[:oid], X_3:bat[:oid], X_4:bat[:oid], X_5:bit):bat[:any_1] ", "SQLall_grp;", "" ] +[ "aggr", "suball", "pattern aggr.suball(X_1:bat[:any_1], X_2:bat[:oid], X_3:bat[:oid], X_4:bit):bat[:any_1] ", "SQLall_grp;", "" ] [ "aggr", "suballnotequal", "pattern aggr.suballnotequal(X_1:bat[:any_1], X_2:bat[:any_1], X_3:bat[:oid], X_4:bat[:oid], X_5:bat[:oid], X_6:bat[:oid], X_7:bit):bat[:bit] ", "SQLallnotequal_grp2;", "" ] [ "aggr", "suballnotequal", "pattern aggr.suballnotequal(X_1:bat[:any_1], X_2:bat[:any_1], X_3:bat[:oid], X_4:bat[:oid], X_5:bat[:oid], X_6:bit):bat[:bit] ", "SQLallnotequal_grp2;", "" ] [ "aggr", "suballnotequal", "pattern aggr.suballnotequal(X_1:bat[:any_1], X_2:bat[:any_1], X_3:bat[:oid], X_4:bat[:oid], X_5:bat[:oid], X_6:bit):bat[:bit] ", "SQLallnotequal_grp;", "" ] @@ -360,6 +364,8 @@ stdout of test 'MAL-signatures` in direc [ "aggr", "submin", "command aggr.submin(X_1:bat[:any_1], X_2:bat[:oid], X_3:bat[:any_2], X_4:bat[:oid], X_5:bit):bat[:any_1] ", "AGGRsubmincand_val;", "" ] [ "aggr", "subnot_exist", "pattern aggr.subnot_exist(X_1:bat[:any], X_2:bat[:oid], X_3:bat[:oid], X_4:bat[:oid], X_5:bit):bat[:bit] ", "SQLsubnot_exist;", "" ] [ "aggr", "subnot_exist", "pattern aggr.subnot_exist(X_1:bat[:any], X_2:bat[:oid], X_3:bat[:oid], X_4:bit):bat[:bit] ", "SQLsubnot_exist;", "" ] +[ "aggr", "subnull", "pattern aggr.subnull(X_1:bat[:any_1], X_2:bat[:oid], X_3:bat[:oid], X_4:bat[:oid], X_5:bit):bat[:bit] ", "SQLnil_grp;", "" ] +[ "aggr", "subnull", "pattern aggr.subnull(X_1:bat[:any_1], X_2:bat[:oid], X_3:bat[:oid], X_4:bit):bat[:bit] ", "SQLnil_grp;", "" ] [ "aggr", "subpro
MonetDB: Jun2020 - Add test results for Bug 6858
Changeset: 1ba2ed8873df for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1ba2ed8873df Added Files: sql/test/json/Tests/jsonkeyarray.Bug-6858.stable.err sql/test/json/Tests/jsonkeyarray.Bug-6858.stable.out Branch: Jun2020 Log Message: Add test results for Bug 6858 diffs (88 lines): diff --git a/sql/test/json/Tests/jsonkeyarray.Bug-6858.stable.err b/sql/test/json/Tests/jsonkeyarray.Bug-6858.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/json/Tests/jsonkeyarray.Bug-6858.stable.err @@ -0,0 +1,12 @@ +stderr of test 'jsonkeyarray.Bug-6858` in directory 'sql/test/json` itself: + + +# 14:15:50 > +# 14:15:50 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-240899" "--port=36049" +# 14:15:50 > + + +# 14:15:50 > +# 14:15:50 > "Done." +# 14:15:50 > + diff --git a/sql/test/json/Tests/jsonkeyarray.Bug-6858.stable.out b/sql/test/json/Tests/jsonkeyarray.Bug-6858.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/json/Tests/jsonkeyarray.Bug-6858.stable.out @@ -0,0 +1,66 @@ +stdout of test 'jsonkeyarray.Bug-6858` in directory 'sql/test/json` itself: + + +# 14:15:50 > +# 14:15:50 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-240899" "--port=36049" +# 14:15:50 > + +#select json.keyarray(json '{ "":0 }'); +% .%2 # table_name +% %2 # name +% json # type +% 4 # length +[ "[\"\"]" ] +#select json.isvalid(json '{ "":0 }'); +% .%2 # table_name +% %2 # name +% boolean # type +% 5 # length +[ true ] +#select json.isobject(json '{ "":0 }'); +% .%2 # table_name +% %2 # name +% boolean # type +% 5 # length +[ true ] +#select json.keyarray(json '{ "":"" }'); +% .%2 # table_name +% %2 # name +% json # type +% 4 # length +[ "[\"\"]" ] +#select json.isvalid(json '{ "":"" }'); +% .%2 # table_name +% %2 # name +% boolean # type +% 5 # length +[ true ] +#select json.isobject(json '{ "":"" }'); +% .%2 # table_name +% %2 # name +% boolean # type +% 5 # length +[ true ] +#select json.keyarray(json '{ "a":0 }'); +% .%2 # table_name +% %2 # name +% json # type +% 5 # length +[ "[\"a\"]"] +#select json.isvalid(json '{ "a":0 }'); +% .%2 # table_name +% %2 # name +% boolean # type +% 5 # length +[ true ] +#select json.isobject(json '{ "a":0 }'); +% .%2 # table_name +% %2 # name +% boolean # type +% 5 # length +[ true ] + +# 14:15:50 > +# 14:15:50 > "Done." +# 14:15:50 > + ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - Handle empty strings correctly in JSONkeyArray
Changeset: e5f5ab2d3769 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e5f5ab2d3769 Modified Files: monetdb5/modules/atoms/json.c Branch: Jun2020 Log Message: Handle empty strings correctly in JSONkeyArray This fixes Bug 6858 diffs (17 lines): diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c --- a/monetdb5/modules/atoms/json.c +++ b/monetdb5/modules/atoms/json.c @@ -1518,6 +1518,13 @@ JSONkeyArray(json *ret, json *js) } if (jt->elm[i].valuelen) strncpy(r, jt->elm[i].value - 1, jt->elm[i].valuelen + 2); + else { + r = GDKstrdup("\"\""); + if(r == NULL) { + JSONfree(jt); + goto memfail; + } + } result = JSONglue(result, r, ','); if (result == NULL) { JSONfree(jt); ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - Missing have_hge check
Changeset: 4337427c196a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4337427c196a Modified Files: sql/server/rel_select.c Branch: Jun2020 Log Message: Missing have_hge check diffs (20 lines): diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -3748,14 +3748,14 @@ static sql_exp * else if (list_length(l) <= 63) tpe = sql_bind_localtype("lng"); #ifdef HAVE_HGE - else if (list_length(l) <= 127) + else if (have_hge && list_length(l) <= 127) tpe = sql_bind_localtype("hge"); #endif else return sql_error(sql, 02, SQLSTATE(42000) "SELECT: GROUPING the number of grouping columns is larger" " than the maximum number of representable bits from this server (%d > %d)", list_length(l), #ifdef HAVE_HGE -127 + have_hge ? 127 : 63 #else 63 #endif ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - Cleanup, move subquery aggregation implementa...
Changeset: 30a0486ffcdc for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=30a0486ffcdc Added Files: gdk/gdk_subquery.c gdk/gdk_subquery.h Modified Files: clients/Tests/exports.stable.out gdk/CMakeLists.txt sql/backends/monet5/sql_subquery.c Branch: default Log Message: Cleanup, move subquery aggregation implementations to the GDK. Initializing group candidates is GDK specific, also it was not clean to throw a GDK error in the MAL layer. diffs (truncated from 2568 to 300 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -16,6 +16,11 @@ size_t ATOMlen(int id, const void *v); str ATOMname(int id); void *ATOMnil(int id) __attribute__((__malloc__)); int ATOMprint(int id, const void *val, stream *fd); +BAT *BATall_grp(BAT *l, BAT *g, BAT *e, BAT *s); +BAT *BATallnotequal_grp(BAT *l, BAT *r, BAT *g, BAT *e, BAT *s); +BAT *BATallnotequal_grp2(BAT *l, BAT *r, BAT *rid, BAT *g, BAT *e, BAT *s); +BAT *BATanyequal_grp(BAT *l, BAT *r, BAT *g, BAT *e, BAT *s); +BAT *BATanyequal_grp2(BAT *l, BAT *r, BAT *rid, BAT *g, BAT *e, BAT *s); gdk_return BATappend(BAT *b, BAT *n, BAT *s, bool force) __attribute__((__warn_unused_result__)); void BATassertProps(BAT *b); atomDesc BATatoms[]; @@ -162,6 +167,7 @@ void *BATmin_skipnil(BAT *b, void *aggr, gdk_return BATmode(BAT *b, bool transient); void BATmsync(BAT *b); gdk_return BATnegcands(BAT *cands, BAT *odels); +BAT *BATnil_grp(BAT *l, BAT *g, BAT *e, BAT *s); bool BATordered(BAT *b); bool BATordered_rev(BAT *b); gdk_return BATorderidx(BAT *b, bool stable); @@ -187,6 +193,8 @@ BAT *BATslice(BAT *b, BUN low, BUN high) gdk_return BATsort(BAT **sorted, BAT **order, BAT **groups, BAT *b, BAT *o, BAT *g, bool reverse, bool nilslast, bool stable) __attribute__((__warn_unused_result__)); gdk_return BATstr_group_concat(ValPtr res, BAT *b, BAT *s, BAT *sep, bool skip_nils, bool abort_on_error, bool nil_if_empty, const char *restrict separator); gdk_return BATsubcross(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT *sr, bool max_one) __attribute__((__warn_unused_result__)); +BAT *BATsubexist(BAT *l, BAT *g, BAT *e, BAT *s); +BAT *BATsubnot_exist(BAT *l, BAT *g, BAT *e, BAT *s); gdk_return BATsum(void *res, int tp, BAT *b, BAT *s, bool skip_nils, bool abort_on_error, bool nil_if_empty); gdk_return BATthetajoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT *sr, int op, bool nil_matches, BUN estimate) __attribute__((__warn_unused_result__)); BAT *BATthetaselect(BAT *b, BAT *s, const void *val, const char *op); diff --git a/gdk/CMakeLists.txt b/gdk/CMakeLists.txt --- a/gdk/CMakeLists.txt +++ b/gdk/CMakeLists.txt @@ -73,6 +73,7 @@ target_sources(gdk gdk_unique.c gdk_interprocess.c gdk_interprocess.h gdk_firstn.c + gdk_subquery.c gdk_subquery.h gdk_analytic_bounds.c gdk_analytic_func.c gdk_analytic.h diff --git a/gdk/gdk_subquery.c b/gdk/gdk_subquery.c new file mode 100644 --- /dev/null +++ b/gdk/gdk_subquery.c @@ -0,0 +1,990 @@ +/* + * 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 - 2020 MonetDB B.V. + */ + +#include "monetdb_config.h" +#include "gdk.h" +#include "gdk_subquery.h" +#include "gdk_private.h" +#include "gdk_calc_private.h" + +#define SQLall_grp_imp(TYPE) \ + do {\ + const TYPE *restrict vals = (const TYPE *) Tloc(l, 0); \ + TYPE *restrict rp = (TYPE *) Tloc(res, 0); \ + while (ncand > 0) { \ + ncand--;\ + i = canditer_next(&ci) - l->hseqbase; \ + if (gids == NULL || \ + (gids[i] >= min && gids[i] <= max)) { \ + if (gids) \ + gid = gids[i] - min;\ + else\ + gid = (oid) i; \ + if (oids[gid] != (BUN_NONE - 1)) { \ + if (oids[gid] == BUN_NONE) { \ + if (!is_##TYPE##_nil(vals[i])) \ + oids[gid] = i; \ + } else { \ + if (vals[oids[gid]] != vals[i] && !is_##TYPE##_nil(vals[i])) \ + oids[gid] = BUN_NONE - 1; \ +