Changeset: c29deea983ac for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/c29deea983ac Modified Files: gdk/gdk_private.h gdk/gdk_system_private.h sql/backends/monet5/sql_upgrades.c sql/common/sql_types.c sql/server/rel_schema.c sql/server/rel_select.c sql/server/sql_parser.y sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128 sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128 sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128 sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128 sql/test/testdb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128 sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out.int128 sql/test/testdb-previous-upgrade-hge/Tests/upgrade.stable.out.int128 sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out.int128 testing/Mtest.py.in Branch: default Log Message:
Merge with Aug2024 branch. diffs (truncated from 718 to 300 lines): diff --git a/ChangeLog.Aug2024 b/ChangeLog.Aug2024 --- a/ChangeLog.Aug2024 +++ b/ChangeLog.Aug2024 @@ -1,3 +1,10 @@ # ChangeLog file for devel # This file is updated with Maddlog +* Thu Oct 17 2024 Niels Nes <[email protected]> +- Changed generic Decimal handling (ie without digits/scale), old cased + mapped always into dec(18,3) now this is only done in case of create of + a column. In other cases the coercion to the correct decimal type is + based on the input data type. For *api (LANG*PY/C(pp)/R) we no longer + allow generic decimal type in the function definitions. + diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h --- a/gdk/gdk_private.h +++ b/gdk/gdk_private.h @@ -164,9 +164,6 @@ gdk_return GDKtracer_init(const char *db __attribute__((__visibility__("hidden"))); gdk_return GDKunlink(int farmid, const char *dir, const char *nme, const char *extension) __attribute__((__visibility__("hidden"))); -#define GDKwarning(...) \ - GDKtracer_log(__FILE__, __func__, __LINE__, M_WARNING, \ - GDK, NULL, __VA_ARGS__) lng getBBPlogno(void) __attribute__((__visibility__("hidden"))); BUN HASHappend(BAT *b, BUN i, const void *v) diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c --- a/gdk/gdk_system.c +++ b/gdk/gdk_system.c @@ -1115,7 +1115,7 @@ MT_kill_threads(void) for (struct mtthread *t = mtthreads; t; t = t->next) { if (t == self) continue; - TRC_INFO(GDK, "Killing thread %s\n", t->threadname); + GDKwarning("Killing thread %s\n", t->threadname); killed |= MT_kill_thread(t); } thread_unlock(); diff --git a/gdk/gdk_system_private.h b/gdk/gdk_system_private.h --- a/gdk/gdk_system_private.h +++ b/gdk/gdk_system_private.h @@ -38,6 +38,9 @@ bool MT_thread_override_limits(void) SetLastError(0); \ } while (0) #endif +#define GDKwarning(...) \ + GDKtracer_log(__FILE__, __func__, __LINE__, M_WARNING, \ + GDK, NULL, __VA_ARGS__) struct freebats { bat freebats; diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c --- a/monetdb5/mal/mal.c +++ b/monetdb5/mal/mal.c @@ -164,7 +164,7 @@ mal_reset(void) void mal_exit(int status) { + mal_reset(); printf("# mserver5 exiting\n"); - mal_reset(); exit(status); /* properly end GDK */ } diff --git a/sql/ChangeLog.Aug2024 b/sql/ChangeLog.Aug2024 --- a/sql/ChangeLog.Aug2024 +++ b/sql/ChangeLog.Aug2024 @@ -1,6 +1,11 @@ # ChangeLog file for sql # This file is updated with Maddlog +* Thu Oct 17 2024 Sjoerd Mullender <[email protected]> +- When for whatever reason the upgrade code produces an error, we now + exit the server. Before the server would limp on with what is basically + a broken database. + * Thu Sep 26 2024 Martin van Dinther <[email protected]> - Improved the violation message of CHECK constraints when violated. It now includes the schema name of the constraint and the check clause. diff --git a/sql/backends/monet5/UDF/capi/Tests/capi11.test b/sql/backends/monet5/UDF/capi/Tests/capi11.test --- a/sql/backends/monet5/UDF/capi/Tests/capi11.test +++ b/sql/backends/monet5/UDF/capi/Tests/capi11.test @@ -1,7 +1,4 @@ -statement ok -START TRANSACTION - -statement ok +statement error 42000!CREATE FUNCTION: the function 'capi11' uses a generic DECIMAL type, UDFs require precision and scale CREATE FUNCTION capi11(inp DECIMAL) RETURNS DECIMAL(11,1) LANGUAGE C { size_t i; result->initialize(result, inp.count); @@ -14,6 +11,33 @@ CREATE FUNCTION capi11(inp DECIMAL) RETU } } +statement error 42000!CREATE FUNCTION: the function '_dbl2dec' returns a generic DECIMAL type, UDFs require precision and scale +CREATE FUNCTION _dbl2dec(inp DOUBLE) RETURNS DECIMAL LANGUAGE C { + size_t i; + result->initialize(result, inp.count); + for(i = 0; i < inp.count; i++) { + result->data[i] = inp.data[i] * result->scale; + } +} + + +statement ok +START TRANSACTION + +statement ok +CREATE FUNCTION capi11(inp DECIMAL(18,3)) RETURNS DECIMAL(11,1) LANGUAGE C { + size_t i; + result->initialize(result, inp.count); + for(i = 0; i < inp.count; i++) { + if (inp.data[i] == inp.null_value) { + result->data[i] = result->null_value; + } else { + result->data[i] = (inp.data[i] / inp.scale) * result->scale; + } + } +} + + statement ok CREATE TABLE decimals(d DECIMAL(18,3)) @@ -32,7 +56,7 @@ statement ok DROP FUNCTION capi11 statement ok -CREATE FUNCTION _dec2dbl(inp DECIMAL) RETURNS DOUBLE LANGUAGE C { +CREATE FUNCTION _dec2dbl(inp DECIMAL(18,3)) RETURNS DOUBLE LANGUAGE C { size_t i; result->initialize(result, inp.count); for(i = 0; i < inp.count; i++) { @@ -59,7 +83,7 @@ statement ok DROP FUNCTION _dec2dbl statement ok -CREATE FUNCTION _dbl2dec(inp DOUBLE) RETURNS DECIMAL LANGUAGE C { +CREATE FUNCTION _dbl2dec(inp DOUBLE) RETURNS DECIMAL(18,3) LANGUAGE C { size_t i; result->initialize(result, inp.count); for(i = 0; i < inp.count; i++) { diff --git a/sql/backends/monet5/UDF/pyapi3/Tests/pyapi3_18.test b/sql/backends/monet5/UDF/pyapi3/Tests/pyapi3_18.test --- a/sql/backends/monet5/UDF/pyapi3/Tests/pyapi3_18.test +++ b/sql/backends/monet5/UDF/pyapi3/Tests/pyapi3_18.test @@ -1,3 +1,15 @@ +statement error 42000!CREATE FUNCTION: the function 'pyapi_decimal' uses a generic DECIMAL type, UDFs require precision and scale +CREATE FUNCTION pyapi_decimal(d DECIMAL) RETURNS DOUBLE LANGUAGE PYTHON { return d; } + +statement error 42000!CREATE UNION FUNCTION: the function 'pyapi_ret_decimal' returns a generic DECIMAL type, UDFs require precision and scale +CREATE FUNCTION pyapi_ret_decimal() RETURNS TABLE(d DECIMAL) +LANGUAGE PYTHON +{ + result = dict() + result['d'] = 100.33 + return result +} + statement ok START TRANSACTION @@ -65,7 +77,7 @@ statement ok rowcount 1 INSERT INTO decimal_table VALUES (123.4567) statement ok -CREATE FUNCTION pyapi_decimal(d DECIMAL) RETURNS DOUBLE LANGUAGE PYTHON { return d; } +CREATE FUNCTION pyapi_decimal(d DECIMAL(18, 3)) RETURNS DOUBLE LANGUAGE PYTHON { return d; } query R rowsort SELECT pyapi_decimal(d) FROM decimal_table @@ -118,7 +130,7 @@ SELECT * FROM pyapi_ret_timestamp() 2000-01-01 12:00:00.000001 statement ok -CREATE FUNCTION pyapi_ret_decimal() RETURNS TABLE(d DECIMAL) +CREATE FUNCTION pyapi_ret_decimal() RETURNS TABLE(d DECIMAL(18, 3)) LANGUAGE PYTHON { result = dict() @@ -144,14 +156,14 @@ statement ok DROP FUNCTION pyapi_ret_decimal statement ok -CREATE FUNCTION pyapi_ret_decimal() RETURNS TABLE(d DECIMAL) +CREATE FUNCTION pyapi_ret_decimal() RETURNS TABLE(d DECIMAL(18, 3)) LANGUAGE PYTHON { return numpy.arange(100001) # return 100k decimal values } statement ok -CREATE FUNCTION pyapi_inp_decimal(d DECIMAL) RETURNS DOUBLE +CREATE FUNCTION pyapi_inp_decimal(d DECIMAL(18, 3)) RETURNS DOUBLE LANGUAGE PYTHON { return numpy.mean(d) # average 100k decimal values diff --git a/sql/backends/monet5/UDF/pyapi3/Tests/pyapi3_19.test b/sql/backends/monet5/UDF/pyapi3/Tests/pyapi3_19.test --- a/sql/backends/monet5/UDF/pyapi3/Tests/pyapi3_19.test +++ b/sql/backends/monet5/UDF/pyapi3/Tests/pyapi3_19.test @@ -121,7 +121,7 @@ statement ok START TRANSACTION statement ok -CREATE FUNCTION pyapi19_create_table() returns table (i integer, j integer, k double, l float, m smallint, n bigint, o STRING, p DECIMAL) LANGUAGE P +CREATE FUNCTION pyapi19_create_table() returns table (i integer, j integer, k double, l float, m smallint, n bigint, o STRING, p DECIMAL(18, 3)) LANGUAGE P { result = dict(); result['i'] = numpy.arange(100000, 0, -1); @@ -136,7 +136,7 @@ CREATE FUNCTION pyapi19_create_table() r } statement ok -CREATE FUNCTION pyapi19_load_table() returns table (i integer, j integer, k double, l float, m smallint, n bigint, o STRING, p DECIMAL) LANGUAGE PYTHON_MAP +CREATE FUNCTION pyapi19_load_table() returns table (i integer, j integer, k double, l float, m smallint, n bigint, o STRING, p DECIMAL(18, 3)) LANGUAGE PYTHON_MAP { res = _conn.execute('SELECT * FROM pyapi19_integers;') return res 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 @@ -3747,10 +3747,10 @@ sql_update_aug2024(Client c, mvc *sql, s "update sys.args set type_digits = 63 where type = 'bigint' and type_digits <> 63;\n" "update sys.args set type_digits = 127 where type = 'hugeint' and type_digits <> 127;\n" "update sys.args set type = 'varchar' where type in ('clob', 'char');\n" - "drop aggregate median(decimal);\n" - "drop aggregate median_avg(decimal);\n" - "drop aggregate quantile(decimal, double);\n" - "drop aggregate quantile_avg(decimal, double);\n" + "drop aggregate median(decimal(18,3));\n" + "drop aggregate median_avg(decimal(18,3));\n" + "drop aggregate quantile(decimal(18,3), double);\n" + "drop aggregate quantile_avg(decimal(18,3), double);\n" "create aggregate median(val DECIMAL(2)) returns DECIMAL(2)\n" " external name \"aggr\".\"median\";\n" "GRANT EXECUTE ON AGGREGATE median(DECIMAL(2)) TO PUBLIC;\n" @@ -4444,7 +4444,6 @@ SQLupgrades(Client c, mvc *m) sql_schema *s = mvc_bind_schema(m, "sys"); if ((err = check_sys_tables(c, m, s)) != NULL) { - TRC_CRITICAL(SQL_PARSER, "%s\n", err); goto handle_error; } @@ -4455,54 +4454,44 @@ SQLupgrades(Client c, mvc *m) m->session->status = 0; /* if the function was not found clean the error */ m->errstr[0] = '\0'; if ((err = sql_update_hugeint(c, m)) != NULL) { - TRC_CRITICAL(SQL_PARSER, "%s\n", err); goto handle_error; } } #endif if ((err = sql_update_jan2022(c, m)) != NULL) { - TRC_CRITICAL(SQL_PARSER, "%s\n", err); goto handle_error; } if ((err = sql_update_sep2022(c, m, s)) != NULL) { - TRC_CRITICAL(SQL_PARSER, "%s\n", err); goto handle_error; } if ((err = sql_update_jun2023(c, m, s)) != NULL) { - TRC_CRITICAL(SQL_PARSER, "%s\n", err); goto handle_error; } if ((err = sql_update_dec2023_geom(c, m, s)) != NULL) { - TRC_CRITICAL(SQL_PARSER, "%s\n", err); goto handle_error; } if ((err = sql_update_jun2023_sp3(c, m, s)) != NULL) { - TRC_CRITICAL(SQL_PARSER, "%s\n", err); goto handle_error; } if ((err = sql_update_dec2023(c, m, s)) != NULL) { - TRC_CRITICAL(SQL_PARSER, "%s\n", err); goto handle_error; } if ((err = sql_update_dec2023_sp1(c, m, s)) != NULL) { - TRC_CRITICAL(SQL_PARSER, "%s\n", err); goto handle_error; } if ((err = sql_update_dec2023_sp4(c, m, s)) != NULL) { - TRC_CRITICAL(SQL_PARSER, "%s\n", err); goto handle_error; } if ((err = sql_update_aug2024(c, m, s)) != NULL) { - TRC_CRITICAL(SQL_PARSER, "%s\n", err); goto handle_error; } @@ -4514,6 +4503,7 @@ SQLupgrades(Client c, mvc *m) _______________________________________________ checkin-list mailing list -- [email protected] To unsubscribe send an email to [email protected]
