MonetDB: default - Merge with Dec2023 branch.
Changeset: 086054b9400a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/086054b9400a Modified Files: gdk/gdk_bat.c gdk/gdk_bbp.c sql/backends/monet5/rel_bin.c Branch: default Log Message: Merge with Dec2023 branch. diffs (103 lines): diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -2550,6 +2550,7 @@ BATmode(BAT *b, bool transient) BATiter bi = bat_iterator(b); bool mustrelease = false; + bool mustretain = false; bat bid = b->batCacheid; if (transient != bi.transient) { @@ -2564,16 +2565,20 @@ BATmode(BAT *b, bool transient) } } - /* persistent BATs get a logical reference */ + /* we need to delay the calls to BBPretain and +* BBPrelease until after we have released our reference +* to the heaps (i.e. until after bat_iterator_end), +* because in either case, BBPfree can be called (either +* directly here or in BBPtrim) which waits for the heap +* reference to come down. BBPretain calls incref which +* waits until the trim that is waiting for us is done, +* so that causes deadlock, and BBPrelease can call +* BBPfree which causes deadlock with a single thread */ if (!transient) { - BBPretain(bid); + /* persistent BATs get a logical reference */ + mustretain = true; } else if (!bi.transient) { - /* we need to delay the release because if there -* is no fix and the bat is loaded, BBPrelease -* can call BBPfree which calls BATfree which -* may hang while waiting for the heap reference -* that we have because of the BAT iterator to -* come down, in other words, deadlock */ + /* transient BATs loose their logical reference */ mustrelease = true; } MT_lock_set(&GDKswapLock(bid)); @@ -2605,8 +2610,10 @@ BATmode(BAT *b, bool transient) MT_lock_unset(&GDKswapLock(bid)); } bat_iterator_end(&bi); - /* release after bat_iterator_end because of refs to heaps */ - if (mustrelease) + /* retain/release after bat_iterator_end because of refs to heaps */ + if (mustretain) + BBPretain(bid); + else if (mustrelease) BBPrelease(bid); return GDK_SUCCEED; } diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -4073,6 +4073,7 @@ BBPsync(int cnt, bat *restrict subcommit /* move any tail/theap files we find for this bat that * are in the BACKUP directory to the SUBCOMMIT * directory */ + assert(b->ttype > 0); /* no unknown types allowed */ char fname[16]; /* plenty big enough */ if (snprintf(fname, sizeof(fname), "%o", (unsigned) bid) < 16) { /* the snprintf never fails, any of the diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c --- a/sql/backends/monet5/rel_bin.c +++ b/sql/backends/monet5/rel_bin.c @@ -6661,7 +6661,15 @@ static stmt * rel2bin_merge(backend *be, sql_rel *rel, list *refs) { mvc *sql = be->mvc; - sql_rel *join = rel->l, *r = rel->r; + sql_rel *join; + + if (is_project(((sql_rel*)rel->l)->op)) { + join = ((sql_rel*)rel->l)->l; + } else { + join = rel->l; + } + + sql_rel *r = rel->r; stmt *join_st, *bt_stmt, *target_stmt, *jl, *jr, *ld, *rd = NULL, *ns; list *slist = sa_list(sql->sa); diff --git a/sql/test/BugTracker-2024/Tests/merge-into-gh-7503.test b/sql/test/BugTracker-2024/Tests/merge-into-gh-7503.test new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2024/Tests/merge-into-gh-7503.test @@ -0,0 +1,14 @@ +statement ok +CREATE TABLE logs(id int, activity varchar(255) NOT NULL) + +statement ok +CREATE TABLE stats(activity varchar(255) NOT NULL, absolute_reworks int) + +statement ok +WITH rework_stats AS (SELECT activity, count(*) AS frequency FROM (SELECT activity,count(*) AS reworks FROM logs GROUP BY activity HAVING count(*) > 1) AS case_reworks GROUP BY activity) MERGE INTO stats USING rework_stats on rework_stats.activity = stats.activity WHEN MATCHED THEN UPDATE SET absolute_reworks = rework_stats.frequency + +statement ok +DROP TABLE logs + +statement ok +DROP TABLE stats ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Approve header change.
Changeset: 960be3294ecb for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/960be3294ecb Modified Files: sql/test/emptydb/Tests/check.stable.out.int128 Branch: default Log Message: Approve header change. diffs (14 lines): diff --git a/sql/test/emptydb/Tests/check.stable.out.int128 b/sql/test/emptydb/Tests/check.stable.out.int128 --- a/sql/test/emptydb/Tests/check.stable.out.int128 +++ b/sql/test/emptydb/Tests/check.stable.out.int128 @@ -7068,8 +7068,8 @@ select 'null in fkeys.delete_action', de % %14, table_id, id, table_id, type, name, rkey, update_action_id, update_action, delete_action_id, delete_action # name % varchar, int,int,int,int,varchar,int, smallint, varchar,smallint, varchar # type % 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0 # length -% .%14,.fkeys, .fkeys, .fkeys, .fkeys, .fkeys, .fkeys, .fkeys, sys.fkeys, .fkeys, sys.fkeys # table_name -% %14, type, id, table_id, type, name, rkey, update_action_id, update_action, delete_action_id, delete_action # name +% .%15,.fkeys, .fkeys, .fkeys, .fkeys, .fkeys, .fkeys, .fkeys, .fkeys, .fkeys, .fkeys # table_name +% %15, type, id, table_id, type, name, rkey, update_action_id, update_action, delete_action_id, delete_action # name % varchar, int,int,int,int,varchar,int, smallint, varchar,smallint, varchar # type % 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0 # length % .%14,.fkeys, .fkeys, .fkeys, .fkeys, .fkeys, .fkeys, .fkeys, sys.fkeys, .fkeys, sys.fkeys # table_name ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Dec2023 - fixed #7506 , properly give an error on incor...
Changeset: 1ca42bba0338 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/1ca42bba0338 Added Files: sql/test/BugTracker-2024/Tests/field-arg-error-Bug-7506.test Modified Files: sql/server/rel_select.c sql/test/BugTracker-2024/Tests/All Branch: Dec2023 Log Message: fixed #7506 , properly give an error on incorrect inputs for the field function. diffs (27 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 @@ -3534,6 +3534,8 @@ rel_nop(sql_query *query, sql_rel **rel, char *sname = qname_schema(l->data.lval); if (!sname && strcmp(fname, "field") == 0) { /* map into join */ + if (err) + return NULL; sql_exp *le = exps->h->data; set_freevar(le, 1); list_remove_data(exps, NULL, le); diff --git a/sql/test/BugTracker-2024/Tests/All b/sql/test/BugTracker-2024/Tests/All --- a/sql/test/BugTracker-2024/Tests/All +++ b/sql/test/BugTracker-2024/Tests/All @@ -51,3 +51,4 @@ sql_init_subtype-Bug-7487 orderby-max-over-rows-Bug-7488 rel2bin_select-Bug-7496 multicolumn_IN_value_list-Bug-7497 +field-arg-error-Bug-7506 diff --git a/sql/test/BugTracker-2024/Tests/field-arg-error-Bug-7506.test b/sql/test/BugTracker-2024/Tests/field-arg-error-Bug-7506.test new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2024/Tests/field-arg-error-Bug-7506.test @@ -0,0 +1,2 @@ +statement error +SELECT FIELD(x, '', '', '', '', '', '', '', '', '', '', '', '', '') ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Dec2023 - merged
Changeset: 473617d38f50 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/473617d38f50 Branch: Dec2023 Log Message: merged diffs (39 lines): diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c --- a/sql/backends/monet5/rel_bin.c +++ b/sql/backends/monet5/rel_bin.c @@ -6658,7 +6658,15 @@ static stmt * rel2bin_merge(backend *be, sql_rel *rel, list *refs) { mvc *sql = be->mvc; - sql_rel *join = rel->l, *r = rel->r; + sql_rel *join; + + if (is_project(((sql_rel*)rel->l)->op)) { + join = ((sql_rel*)rel->l)->l; + } else { + join = rel->l; + } + + sql_rel *r = rel->r; stmt *join_st, *bt_stmt, *target_stmt, *jl, *jr, *ld, *rd = NULL, *ns; list *slist = sa_list(sql->sa); diff --git a/sql/test/BugTracker-2024/Tests/merge-into-gh-7503.test b/sql/test/BugTracker-2024/Tests/merge-into-gh-7503.test new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2024/Tests/merge-into-gh-7503.test @@ -0,0 +1,14 @@ +statement ok +CREATE TABLE logs(id int, activity varchar(255) NOT NULL) + +statement ok +CREATE TABLE stats(activity varchar(255) NOT NULL, absolute_reworks int) + +statement ok +WITH rework_stats AS (SELECT activity, count(*) AS frequency FROM (SELECT activity,count(*) AS reworks FROM logs GROUP BY activity HAVING count(*) > 1) AS case_reworks GROUP BY activity) MERGE INTO stats USING rework_stats on rework_stats.activity = stats.activity WHEN MATCHED THEN UPDATE SET absolute_reworks = rework_stats.frequency + +statement ok +DROP TABLE logs + +statement ok +DROP TABLE stats ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Dec2023 - Only execuyte hg/git when we found the program.
Changeset: 5270722c3891 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/5270722c3891 Modified Files: common/utils/GenerateVersionHeader.cmake Branch: Dec2023 Log Message: Only execuyte hg/git when we found the program. diffs (54 lines): diff --git a/common/utils/GenerateVersionHeader.cmake b/common/utils/GenerateVersionHeader.cmake --- a/common/utils/GenerateVersionHeader.cmake +++ b/common/utils/GenerateVersionHeader.cmake @@ -18,34 +18,34 @@ elseif(EXISTS "${DIR}/.hg") find_package(Hg) if(HG_FOUND) message("hg found: ${HG_EXECUTABLE}") +execute_process(COMMAND "${HG_EXECUTABLE}" "id" "-i" WORKING_DIRECTORY "${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}") +else() + message(WARNING "Failed to find mercurial ID") + set(MERCURIAL_ID "Unknown") +endif() else() message(WARNING "Failed to find mercurial") set(MERCURIAL_ID "Unknown") endif() - execute_process(COMMAND "${HG_EXECUTABLE}" "id" "-i" WORKING_DIRECTORY "${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}") - else() -message(WARNING "Failed to find mercurial ID") -set(MERCURIAL_ID "Unknown") - endif() elseif(EXISTS "${DIR}/.git") find_package(Git) if(GIT_FOUND) message("git found: ${GIT_EXECUTABLE}") +execute_process(COMMAND "${GIT_EXECUTABLE}" "rev-parse" "--short" "HEAD" WORKING_DIRECTORY "${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}") +else() + message(WARNING "Failed to find git ID") + set(MERCURIAL_ID "Unknown") +endif() else() message(WARNING "Failed to find git") set(MERCURIAL_ID "Unknown") endif() - execute_process(COMMAND "${GIT_EXECUTABLE}" "rev-parse" "--short" "HEAD" WORKING_DIRECTORY "${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}") - else() -message(WARNING "Failed to find git ID") -set(MERCURIAL_ID "Unknown") - endif() else() set(MERCURIAL_ID "Unknown") endif() ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: Dec2023 - Forgot to call mnstr_init() in mapi_settings()
Changeset: caee5e7096d0 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/caee5e7096d0 Modified Files: clients/mapilib/mapi.c Branch: Dec2023 Log Message: Forgot to call mnstr_init() in mapi_settings() diffs (39 lines): diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1779,6 +1779,11 @@ mapi_new(msettings *settings) Mapi mid; static ATOMIC_TYPE index = ATOMIC_VAR_INIT(0); + if (!ATOMIC_TAS(&mapi_initialized)) { + if (mnstr_init() < 0) + return NULL; + } + mid = malloc(sizeof(*mid)); if (mid == NULL) return NULL; @@ -1887,11 +1892,6 @@ mapi_mapiuri(const char *url, const char { Mapi mid; - if (!ATOMIC_TAS(&mapi_initialized)) { - if (mnstr_init() < 0) - return NULL; - } - mid = mapi_new(NULL); if (mid == NULL) return NULL; @@ -1946,11 +1946,6 @@ mapi_mapi(const char *host, int port, co { Mapi mid; - if (!ATOMIC_TAS(&mapi_initialized)) { - if (mnstr_init() < 0) - return NULL; - } - mid = mapi_new(NULL); if (mid == NULL) return NULL; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - Merge 'Dec2023' into 'default'
Changeset: d80b9d68be25 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/d80b9d68be25 Modified Files: clients/mapilib/mapi.c sql/server/rel_select.c sql/test/BugTracker-2024/Tests/All Branch: default Log Message: Merge 'Dec2023' into 'default' diffs (120 lines): diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1777,6 +1777,11 @@ mapi_new(msettings *settings) Mapi mid; static ATOMIC_TYPE index = ATOMIC_VAR_INIT(0); + if (!ATOMIC_TAS(&mapi_initialized)) { + if (mnstr_init() < 0) + return NULL; + } + mid = malloc(sizeof(*mid)); if (mid == NULL) return NULL; @@ -1885,11 +1890,6 @@ mapi_mapiuri(const char *url, const char { Mapi mid; - if (!ATOMIC_TAS(&mapi_initialized)) { - if (mnstr_init() < 0) - return NULL; - } - mid = mapi_new(NULL); if (mid == NULL) return NULL; @@ -1944,11 +1944,6 @@ mapi_mapi(const char *host, int port, co { Mapi mid; - if (!ATOMIC_TAS(&mapi_initialized)) { - if (mnstr_init() < 0) - return NULL; - } - mid = mapi_new(NULL); if (mid == NULL) return NULL; diff --git a/common/utils/GenerateVersionHeader.cmake b/common/utils/GenerateVersionHeader.cmake --- a/common/utils/GenerateVersionHeader.cmake +++ b/common/utils/GenerateVersionHeader.cmake @@ -18,34 +18,34 @@ elseif(EXISTS "${DIR}/.hg") find_package(Hg) if(HG_FOUND) message("hg found: ${HG_EXECUTABLE}") +execute_process(COMMAND "${HG_EXECUTABLE}" "id" "-i" WORKING_DIRECTORY "${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}") +else() + message(WARNING "Failed to find mercurial ID") + set(MERCURIAL_ID "Unknown") +endif() else() message(WARNING "Failed to find mercurial") set(MERCURIAL_ID "Unknown") endif() - execute_process(COMMAND "${HG_EXECUTABLE}" "id" "-i" WORKING_DIRECTORY "${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}") - else() -message(WARNING "Failed to find mercurial ID") -set(MERCURIAL_ID "Unknown") - endif() elseif(EXISTS "${DIR}/.git") find_package(Git) if(GIT_FOUND) message("git found: ${GIT_EXECUTABLE}") +execute_process(COMMAND "${GIT_EXECUTABLE}" "rev-parse" "--short" "HEAD" WORKING_DIRECTORY "${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}") +else() + message(WARNING "Failed to find git ID") + set(MERCURIAL_ID "Unknown") +endif() else() message(WARNING "Failed to find git") set(MERCURIAL_ID "Unknown") endif() - execute_process(COMMAND "${GIT_EXECUTABLE}" "rev-parse" "--short" "HEAD" WORKING_DIRECTORY "${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}") - else() -message(WARNING "Failed to find git ID") -set(MERCURIAL_ID "Unknown") - endif() else() set(MERCURIAL_ID "Unknown") endif() 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 @@ -3221,6 +3221,8 @@ rel_nop(sql_query *query, sql_rel **rel, char *sname = qname_schema(l->data.lval); if (!sname && strcmp(fname, "field") == 0) { /* map into join */ + if (err) + return NULL; sql_exp *le = exps->h->data; set_freevar(le, 1); list_remove_data(exps, NULL, le); diff --git a/sql/test/BugTracker-2024/Tests/All b/sql/test/BugTracker-2024/Tests/All --- a/sql/test/BugTracker-2024/Tests/All +++ b/sql/test/BugTracker-2024/Tests/All @@ -53,3 +53,4 @@ sql_init_subtype-Bug-7487 orderby-max-over-rows-Bug-7488 rel2bin_select-Bug-7496 multicolumn_IN_value_list-Bug-7497 +field-arg-error-Bug-7506 diff --git a/sql/test/BugTracker-2024/Tests/field-arg-error-Bug-7506.test b/sql/test/BugTracker-2024/Tests/field-arg-error-Bug-7506.test new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2024/Tests/field-arg-error-Bug-7506.test @@ -0,0 +1,2 @@ +statement error +SELECT FIELD(x, '', '', '', '', '', '', '', '', '', '', '', '', '') ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: odbc-tls - Fix name in error message
Changeset: e8ac27646b2d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/e8ac27646b2d Modified Files: clients/mapilib/msettings.c Branch: odbc-tls Log Message: Fix name in error message diffs (12 lines): diff --git a/clients/mapilib/msettings.c b/clients/mapilib/msettings.c --- a/clients/mapilib/msettings.c +++ b/clients/mapilib/msettings.c @@ -25,7 +25,7 @@ #include #endif -#define FATAL() do { fprintf(stderr, "\n\n abort in params.c: %s\n\n", __func__); abort(); } while (0) +#define FATAL() do { fprintf(stderr, "\n\n abort in msettings.c: %s\n\n", __func__); abort(); } while (0) int msetting_parse_bool(const char *text) { ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: odbc-tls - Crude hack to differentiate malloc failures ...
Changeset: bf0453acb4fe for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/bf0453acb4fe Modified Files: clients/Tests/exports.stable.out clients/mapilib/msettings.c clients/mapilib/msettings.h Branch: odbc-tls Log Message: Crude hack to differentiate malloc failures from other failures diffs (60 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 @@ -751,6 +751,7 @@ enum msetting_tls_verify msettings_conne const char *msettings_connect_unix(const msettings *mp); msettings *msettings_create(void); msettings *msettings_destroy(msettings *mp); +bool msettings_malloc_failed(msettings_error err); bool msettings_parse_url(msettings *mp, const char *url, char **error_buffer); bool msettings_validate(msettings *mp, char **errmsg); const char *wsaerror(int); diff --git a/clients/mapilib/msettings.c b/clients/mapilib/msettings.c --- a/clients/mapilib/msettings.c +++ b/clients/mapilib/msettings.c @@ -27,6 +27,16 @@ #define FATAL() do { fprintf(stderr, "\n\n abort in msettings.c: %s\n\n", __func__); abort(); } while (0) +static const char * const MALLOC_FAILED = "malloc failed"; + +bool +msettings_malloc_failed(msettings_error err) +{ + return ((const char*)err == (const char*)MALLOC_FAILED); +} + + + int msetting_parse_bool(const char *text) { static struct { const char *word; bool value; } variants[] = { @@ -347,7 +357,7 @@ msetting_set_string(msettings *mp, mparm char *v = strdup(value); if (!v) - return "malloc failed"; + return MALLOC_FAILED; if (p->must_free) free(p->str); p->str = v; @@ -506,7 +516,7 @@ msetting_set_ignored(msettings *mp, cons free(my_key); free(my_value); free(new_unknowns); - return "malloc failed while setting ignored parameter"; + return MALLOC_FAILED; } new_unknowns[2 * n] = my_key; diff --git a/clients/mapilib/msettings.h b/clients/mapilib/msettings.h --- a/clients/mapilib/msettings.h +++ b/clients/mapilib/msettings.h @@ -107,6 +107,7 @@ typedef struct msettings msettings; /* NULL means OK. non-NULL is error message. Valid until next call. Do not free. */ typedef const char *msettings_error; +mapi_export bool msettings_malloc_failed(msettings_error err); /* returns NULL if could not allocate */ mapi_export msettings *msettings_create(void); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: odbc-tls - Add error buffer to struct msettings
Changeset: ae9f83be9aba for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/ae9f83be9aba Modified Files: clients/examples/C/testsfile.c clients/mapilib/msettings.c clients/mapilib/parseurl.c Branch: odbc-tls Log Message: Add error buffer to struct msettings diffs (118 lines): diff --git a/clients/examples/C/testsfile.c b/clients/examples/C/testsfile.c --- a/clients/examples/C/testsfile.c +++ b/clients/examples/C/testsfile.c @@ -85,7 +85,7 @@ handle_set_command(const char *location, { msettings_error msg = msetting_set_named(mp, true, key, value); if (msg) { - fprintf(stderr, "%s: cannot set '%s': %s\n", location, key, msg); + fprintf(stderr, "%s: %s\n", location, msg); return false; } return true; diff --git a/clients/mapilib/msettings.c b/clients/mapilib/msettings.c --- a/clients/mapilib/msettings.c +++ b/clients/mapilib/msettings.c @@ -213,6 +213,7 @@ struct msettings { char *unix_sock_name_buffer; char certhash_digits_buffer[64 + 2 + 1]; // fit more than required plus trailing '\0' bool validated; + char error_message[256]; }; static @@ -321,6 +322,20 @@ msettings_destroy(msettings *mp) return NULL; } +static const char *format_error(msettings *mp, const char *fmt, ...) + __attribute__((__format__(__printf__, 2, 3))); + +static const char * +format_error(msettings *mp, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vsnprintf(mp->error_message, sizeof(mp->error_message), fmt, ap); + va_end(ap); + + return mp->error_message; +} + const char* msetting_string(const msettings *mp, mparm parm) { @@ -457,15 +472,15 @@ msetting_parse(msettings *mp, mparm parm case MPCLASS_BOOL: b = msetting_parse_bool(text); if (b < 0) - return "invalid boolean value"; + return format_error(mp, "%s: invalid boolean value", mparm_name(parm)); return msetting_set_bool(mp, parm, b); case MPCLASS_LONG: if (text[0] == '\0') - return "integer parameter cannot be empty string"; + return format_error(mp, "%s: integer parameter cannot be empty string", mparm_name(parm)); char *end; long l = strtol(text, &end, 10); if (*end != '\0') - return "invalid integer"; + return format_error(mp, "%s: invalid integer", mparm_name(parm)); return msetting_set_long(mp, parm, l); case MPCLASS_STRING: return msetting_set_string(mp, parm, text); @@ -533,13 +548,13 @@ msetting_set_named(msettings *mp, bool a { mparm parm = mparm_parse(key); if (parm == MP_UNKNOWN) - return "unknown parameter"; + return format_error(mp, "%s: unknown parameter", key); if (parm == MP_IGNORE) return msetting_set_ignored(mp, key, value); if (!allow_core && mparm_is_core(parm)) - return "parameter not allowed here"; + return format_error(mp, "%s: parameter not allowed here", mparm_name(parm)); return msetting_parse(mp, parm, value); } @@ -572,7 +587,7 @@ validate_certhash(msettings *mp) if (strncmp(certhash, "sha256:", 7) == 0) { certhash += 7; } else { - return "expected certhash to start with 'sha256:'"; + return "certhash: expected to start with 'sha256:'"; } size_t i = 0; diff --git a/clients/mapilib/parseurl.c b/clients/mapilib/parseurl.c --- a/clients/mapilib/parseurl.c +++ b/clients/mapilib/parseurl.c @@ -230,7 +230,7 @@ store(msettings *mp, scanner *sc, mparm { msettings_error msg = msetting_parse(mp, parm, value); if (msg) - return complain(sc, "cannot set %s to '%s': %s",mparm_name(parm), value, msg); + return complain(sc, "%s: %s", msg, value); else return true; } @@ -358,7 +358,7 @@ parse_modern(msettings *mp, scanner *sc) msettings_error msg = msetting_set_named(mp, false, key, value); if (msg) - return complain(sc, "%s: %s", key, msg); + return complain(sc, "%s", msg); } while (sc->c == '&'); } @@ -388,7 +388,7 @@ parse_classic_query_parameters(msettings case MP_LANGUAGE: msg = msetting_set_string(mp, parm, value); if (msg) - return complain(sc, "parameter '%s': %s", key, msg); +
MonetDB: odbc-tls - Refactor MNDBConnect
Changeset: b588a6977aae for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/b588a6977aae Modified Files: clients/odbc/driver/SQLConnect.c Branch: odbc-tls Log Message: Refactor MNDBConnect One change in behavior: in the old code, the dbname precedence was: 1. 'dbname' parameter 2. existing database name 3. database name from data source That seemed odd, so now it's 1. 'dbname' parameter 2. database name from data source 3. existing database name diffs (truncated from 367 to 300 lines): diff --git a/clients/odbc/driver/SQLConnect.c b/clients/odbc/driver/SQLConnect.c --- a/clients/odbc/driver/SQLConnect.c +++ b/clients/odbc/driver/SQLConnect.c @@ -82,6 +82,59 @@ get_serverinfo(ODBCDbc *dbc) mapi_close_handle(hdl); } +// Return a newly allocated NUL-terminated config value from either the argument +// or the data source. Return 'default_value' if no value can be found, NULL on +// allocation error. +// +// If non-NULL, parameter 'argument' points to an argument that may or may not +// be NUL-terminated. The length parameter 'argument_len' can either be the +// length of the argument or one of the following special values: +// +//SQL_NULL_DATA: consider the argument NULL +//SQL_NTS: the argument is actually NUL-terminated +// +// Parameters 'dsn' and 'entry', if not NULL and not empty, indicate which data +// source field to look up in "odbc.ini". +static char* +getConfig( + const void *argument, ssize_t argument_len, + const char *dsn, const char *entry, + const char *default_value) +{ + if (argument != NULL && argument_len != SQL_NULL_DATA) { + // argument is present.. + if (argument_len == SQL_NTS) { + // .. and it's already NUL-terminated + return strdup((const char*)argument); + } else { + // .. but we need to create a NUL-terminated copy + char *value = malloc(argument_len + 1); + if (value == NULL) + return NULL; + memmove(value, argument, argument_len); + value[argument_len] = '\0'; + return value; + } + } else if (dsn && *dsn && entry && *entry) { + // look up in the data source + size_t size = 1024; // should be plenty + char *buffer = malloc(size); + if (buffer == NULL) + return NULL; + int n = SQLGetPrivateProfileString(dsn, entry, "", buffer, size, "odbc.ini"); + if (n > 0) { + // found some + return buffer; + } else { + // found none + free(buffer); + return strdup(default_value); + } + } else { + return strdup(default_value); + } +} + SQLRETURN MNDBConnect(ODBCDbc *dbc, const SQLCHAR *ServerName, @@ -95,38 +148,37 @@ MNDBConnect(ODBCDbc *dbc, const char *dbname, int mapToLongVarchar) { - SQLRETURN rc = SQL_SUCCESS; + // These will be passed to addDbcError if you 'goto failure'. + // If unset, 'goto failure' will assume an allocation error. + const char *error_state = NULL; + const char *error_explanation = NULL; + + // These will be free'd / destroyed at the 'end' label at the bottom of this function char *dsn = NULL; - char uid[32]; - char pwd[32]; - char buf[256]; - char db[32]; - int n; - Mapi mid; + char *uid = NULL; + char *pwd = NULL; + char *db = NULL; + char *hostdup = NULL; + char *portdup = NULL; + Mapi mid = NULL; + + // These do not need to be free'd + const char *mapiport_env; /* check connection state, should not be connected */ if (dbc->Connected) { - /* Connection name in use */ - addDbcError(dbc, "08002", NULL, 0); - return SQL_ERROR; + error_state = "08002"; + goto failure; } - /* convert input string parameters to normal null terminated C strings */ - fixODBCstring(ServerName, NameLength1, SQLSMALLINT, - addDbcError, dbc, return SQL_ERROR); - if (NameLength1 > 0) { - dsn = dupODBCstring(ServerName, (size_t) NameLength1); - if (dsn == NULL) { - /* Memory allocation error */ - addDbcError(dbc, "HY001", NULL, 0); - return SQL_ERROR; - } - } + dsn = getConfig(ServerName, NameLength1, NULL, NULL, ""); + if (dsn == NULL) + goto failure; #ifdef ODBCDEBUG if ((ODBCdebug == NULL || *ODBCdebug == 0) && dsn && *dsn) {
MonetDB: odbc-tls - Exit ODBCtester early if connect failed
Changeset: 6196bbd604f7 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/6196bbd604f7 Modified Files: clients/odbc/tests/ODBCtester.c Branch: odbc-tls Log Message: Exit ODBCtester early if connect failed diffs (23 lines): diff --git a/clients/odbc/tests/ODBCtester.c b/clients/odbc/tests/ODBCtester.c --- a/clients/odbc/tests/ODBCtester.c +++ b/clients/odbc/tests/ODBCtester.c @@ -232,7 +232,7 @@ main(int argc, char **argv) } ret = SQLAllocHandle(SQL_HANDLE_ENV, NULL, &env); - if (ret != SQL_SUCCESS) { + if (!SQL_SUCCEEDED(ret)) { fprintf(stderr, "Cannot allocate ODBC environment handle!\n"); exit(1); } @@ -245,6 +245,10 @@ main(int argc, char **argv) ret = SQLConnect(dbc, (SQLCHAR *) dsn, SQL_NTS, (SQLCHAR *) user, SQL_NTS, (SQLCHAR *) pass, SQL_NTS); check(ret, SQL_HANDLE_DBC, dbc, "SQLConnect"); + if (!SQL_SUCCEEDED(ret)) { + fprintf(stderr, "Cannot connect!\n"); + exit(1); + } ret = SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt); check(ret, SQL_HANDLE_DBC, dbc, "SQLAllocHandle (STMT)"); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: odbc-tls - Add reallocprintf and vreallocprintf to mstr...
Changeset: a5d5e4043704 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/a5d5e4043704 Modified Files: clients/mapilib/msettings.c common/utils/mstring.h Branch: odbc-tls Log Message: Add reallocprintf and vreallocprintf to mstring.h diffs (118 lines): diff --git a/clients/mapilib/msettings.c b/clients/mapilib/msettings.c --- a/clients/mapilib/msettings.c +++ b/clients/mapilib/msettings.c @@ -59,22 +59,19 @@ char* allocprintf(const char *fmt, ...) char * allocprintf(const char *fmt, ...) { - size_t buflen = 80; - while (1) { - char *buf = malloc(buflen); - if (buf == NULL) - return NULL; - va_list ap; - va_start(ap, fmt); - int n = vsnprintf(buf, buflen, fmt, ap); - va_end(ap); - if (n >= 0 && (size_t)n < buflen) - return buf; - free(buf); - if (n < 0) - return NULL; - buflen = n + 1; - } + va_list ap; + char *buf = NULL; + size_t pos = 0, cap = 0; + int n; + + va_start(ap, fmt); + n = vreallocprintf(&buf, &pos, &cap, fmt, ap); + va_end(ap); + + if (n >= 0) + return buf; + free(buf); + return NULL; } diff --git a/common/utils/mstring.h b/common/utils/mstring.h --- a/common/utils/mstring.h +++ b/common/utils/mstring.h @@ -155,6 +155,75 @@ checkUTF8(const char *v) return true; } +static inline int vreallocprintf(char **buf, size_t *pos, size_t *size, const char *fmt, va_list ap) + __attribute__((__format__(__printf__, 4, 0))); + +static inline int +vreallocprintf(char **buf, size_t *pos, size_t *capacity, const char *fmt, va_list args) +{ + va_list ap; + + assert(*pos <= *capacity); + assert(*buf == NULL || *capacity > 0); + + size_t need_at_least = strlen(fmt); + need_at_least += 1; // trailing NUL + need_at_least += 80; // some space for the items + while (1) { + // Common cases: + // 1. buf=NULL, pos=cap=0: allocate reasonable amount + // 2. buf=NULL, pos=0, cap=something: start with allocating cap + // 3. buf not NULL, cap=something: allocate larger cap + if (*buf == NULL || need_at_least > *capacity - *pos) { + size_t cap1 = *pos + need_at_least; + size_t cap2 = *capacity; + if (*buf) + cap2 += cap2 / 2; + size_t new_cap = cap1 > cap2 ? cap1 : cap2; + char *new_buf = realloc(*buf, new_cap); + if (new_buf == 0) + return -1; + *buf = new_buf; + *capacity = new_cap; + } + assert(*buf); + assert(need_at_least <= *capacity - *pos); + char *output = &(*buf)[*pos]; + size_t avail = *capacity - *pos; + assert(avail >= 1); + + va_copy(ap, args); + int n = vsnprintf(output, avail, fmt, ap); + va_end(ap); + + if (n < 0) + return n; + size_t needed = (size_t)n; + if (needed <= avail - 1) { + // it wanted to print n chars and it could + *pos += needed; + return n; + } + need_at_least = needed + 1; + } +} + +static inline int reallocprintf(char **buf, size_t *pos, size_t *size, const char *fmt, ...) + __attribute__((__format__(__printf__, 4, 5))); + +static inline int +reallocprintf(char **buf, size_t *pos, size_t *capacity, const char *fmt, ...) +{ + int n; + va_list ap; + va_start(ap, fmt); + n = vreallocprintf(buf, pos, capacity, fmt, ap); + va_end(ap); + return n; +} + + + #ifndef __GNUC__ #undef __builtin_expect #endif ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: odbc-tls - msetting_as_string should take a const msett...
Changeset: 99b31d4ec55d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/99b31d4ec55d Modified Files: clients/mapilib/msettings.h Branch: odbc-tls Log Message: msetting_as_string should take a const msetting* diffs (12 lines): diff --git a/clients/mapilib/msettings.h b/clients/mapilib/msettings.h --- a/clients/mapilib/msettings.h +++ b/clients/mapilib/msettings.h @@ -131,7 +131,7 @@ msettings_error msetting_set_bool(msetti /* parse into the appropriate type, or format into newly malloc'ed string (NULL means malloc failed) */ msettings_error msetting_parse(msettings *mp, mparm parm, const char *text); -char *msetting_as_string(msettings *mp, mparm parm); +char *msetting_as_string(const msettings *mp, mparm parm); /* store ignored parameter */ msettings_error msetting_set_ignored(msettings *mp, const char *key, const char *value); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: odbc-tls - Add mparm_enumerate api
Changeset: 263ce7e8a816 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/263ce7e8a816 Modified Files: clients/mapilib/msettings.c clients/mapilib/msettings.h Branch: odbc-tls Log Message: Add mparm_enumerate api diffs (56 lines): diff --git a/clients/mapilib/msettings.c b/clients/mapilib/msettings.c --- a/clients/mapilib/msettings.c +++ b/clients/mapilib/msettings.c @@ -13,6 +13,7 @@ #include "monetdb_config.h" #include "msettings.h" +#include "mstring.h" #include #include @@ -118,6 +119,15 @@ mparm_parse(const char *name) return strchr(name, '_') ? MP_IGNORE : MP_UNKNOWN; } +mparm +mparm_enumerate(int i) +{ + int n = sizeof(by_name) / sizeof(by_name[0]); + if (i < 0 || i >= n) + return MP_UNKNOWN; + return by_name[i].parm; +} + const char * mparm_name(mparm parm) { @@ -488,7 +498,7 @@ msetting_parse(msettings *mp, mparm parm } char * -msetting_as_string(msettings *mp, mparm parm) +msetting_as_string(const msettings *mp, mparm parm) { bool b; long l; @@ -496,7 +506,7 @@ msetting_as_string(msettings *mp, mparm switch (mparm_classify(parm)) { case MPCLASS_BOOL: b = msetting_bool(mp, parm); - return strdup(b ? "true" : " false"); + return strdup(b ? "true" : "false"); case MPCLASS_LONG: l = msetting_long(mp, parm); int n = 40; diff --git a/clients/mapilib/msettings.h b/clients/mapilib/msettings.h --- a/clients/mapilib/msettings.h +++ b/clients/mapilib/msettings.h @@ -92,6 +92,7 @@ mparm_classify(mparm parm) /* returns NULL if not found, pointer to mparm if found */ mapi_export mparm mparm_parse(const char *name); const char *mparm_name(mparm parm); +mparm mparm_enumerate(int i); bool mparm_is_core(mparm parm); ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: odbc-tls - Switch MNDBConnect to use msettings
Changeset: 2b2900109cef for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/2b2900109cef Modified Files: clients/odbc/driver/SQLConnect.c Branch: odbc-tls Log Message: Switch MNDBConnect to use msettings diffs (87 lines): diff --git a/clients/odbc/driver/SQLConnect.c b/clients/odbc/driver/SQLConnect.c --- a/clients/odbc/driver/SQLConnect.c +++ b/clients/odbc/driver/SQLConnect.c @@ -33,6 +33,8 @@ #include "ODBCDbc.h" #include "ODBCUtil.h" #include +#include "msettings.h" +#include "mstring.h" #ifdef HAVE_ODBCINST_H #include @@ -160,7 +162,9 @@ MNDBConnect(ODBCDbc *dbc, char *db = NULL; char *hostdup = NULL; char *portdup = NULL; + char *logbuf = NULL; Mapi mid = NULL; + msettings *settings = NULL; // These do not need to be free'd const char *mapiport_env; @@ -265,15 +269,50 @@ MNDBConnect(ODBCDbc *dbc, if (hostdup == NULL) goto failure; + settings = msettings_create(); + if (false + || (error_explanation = msetting_set_string(settings, MP_DATABASE, db)) + || (error_explanation = msetting_set_string(settings, MP_HOST, hostdup)) + || (error_explanation = msetting_set_long(settings, MP_PORT, port)) + || (error_explanation = msetting_set_string(settings, MP_USER, uid)) + || (error_explanation = msetting_set_string(settings, MP_PASSWORD, pwd)) + ) { + if (msettings_malloc_failed(error_explanation)) + error_explanation = NULL; // it's a malloc failure + else + error_state = "HY009"; // it's otherwise invalid + goto failure; + } #ifdef ODBCDEBUG - ODBCLOG("SQLConnect: DSN=%s UID=%s PWD=%s host=%s port=%d database=%s\n", - dsn, uid, pwd, hostdup, port, db); + { + size_t pos = 0; + size_t cap = 1024; + reallocprintf(&logbuf, &pos, &cap, "SQLConnect: DSN=%s", dsn); + mparm parm; + for (int i = 0; (parm = mparm_enumerate(i)) != MP_UNKNOWN ; i++) { + if (parm == MP_TABLE || parm == MP_TABLESCHEMA) + continue; + char *value = msetting_as_string(settings, parm); + char *default_value = msetting_as_string(msettings_default, parm); + if (!value || !default_value) + goto failure; + if (mparm_is_core(parm) || strcmp(value, default_value) != 0) { + reallocprintf(&logbuf, &pos, &cap, ", %s=%s", mparm_name(parm), value); + } + free(value); + free(default_value); + } + if (pos > cap) + goto failure; + ODBCLOG("%s\n", logbuf); + } #endif // Create mid and execute a bunch of commands before checking for errors. - mid = mapi_mapi(hostdup, port, uid, pwd, "sql", db); + mid = mapi_settings(settings); if (mid) { + settings = NULL; // it has moved into 'mid' and must not be freed. mapi_setAutocommit(mid, dbc->sql_attr_autocommit == SQL_AUTOCOMMIT_ON); mapi_set_size_header(mid, true); mapi_reconnect(mid); @@ -320,8 +359,10 @@ end: free(db); free(hostdup); free(portdup); + free(logbuf); if (mid) mapi_destroy(mid); + msettings_destroy(settings); return error_state == NULL ? SQL_SUCCESS : SQL_ERROR; } ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: odbc-tls - Support more data source fields
Changeset: e72cafcd67ad for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/e72cafcd67ad Modified Files: clients/odbc/driver/SQLConnect.c Branch: odbc-tls Log Message: Support more data source fields In particular, Encrypt Server Certificate Server Certificate Hash Client Key Client Certificate Unix Socket Autocommit Schema Time Zone Reply Size diffs (70 lines): diff --git a/clients/odbc/driver/SQLConnect.c b/clients/odbc/driver/SQLConnect.c --- a/clients/odbc/driver/SQLConnect.c +++ b/clients/odbc/driver/SQLConnect.c @@ -137,6 +137,33 @@ getConfig( } } +// Helper function for use in MNDBConnect. +// Try to set the setting from a data source field, return false on error. +static bool +ds_setting(msettings *settings, const char *dsn, const char **err_state, const char **explanation, mparm parm, const char *entry) +{ + assert(*err_state == NULL); + assert(*explanation == NULL); + + char *value = getConfig(NULL, 0, dsn, entry, ""); + if (value == NULL) + return false; // allocation failed + if (*value == '\0') { + free(value); + return true; // nothing to do + } + + msettings_error err = msetting_parse(settings, parm, value); + free(value); + if (!err) + return true; + if (!msettings_malloc_failed(err)) { + *err_state = "HY009"; // invalid argument + *explanation = err; + } + return false; +} + SQLRETURN MNDBConnect(ODBCDbc *dbc, const SQLCHAR *ServerName, @@ -270,6 +297,7 @@ MNDBConnect(ODBCDbc *dbc, goto failure; settings = msettings_create(); + // Move the currently known parameters into the settings object. if (false || (error_explanation = msetting_set_string(settings, MP_DATABASE, db)) || (error_explanation = msetting_set_string(settings, MP_HOST, hostdup)) @@ -284,6 +312,24 @@ MNDBConnect(ODBCDbc *dbc, goto failure; } + // The other parameters can only be set from the data source. + // We have made a helper function for that. + if (false + || !ds_setting(settings, dsn, &error_state, &error_explanation, MP_SOCK, "Unix Socket") + || !ds_setting(settings, dsn, &error_state, &error_explanation, MP_TLS, "Encrypt") + || !ds_setting(settings, dsn, &error_state, &error_explanation, MP_CERT, "Server Certificate") + || !ds_setting(settings, dsn, &error_state, &error_explanation, MP_CERTHASH, "Server Certificate Hash") + || !ds_setting(settings, dsn, &error_state, &error_explanation, MP_CLIENTKEY, "Client Key") + || !ds_setting(settings, dsn, &error_state, &error_explanation, MP_CLIENTCERT, "Client Certificate") + || !ds_setting(settings, dsn, &error_state, &error_explanation, MP_AUTOCOMMIT, "Autocommit") + || !ds_setting(settings, dsn, &error_state, &error_explanation, MP_SCHEMA, "Schema") + || !ds_setting(settings, dsn, &error_state, &error_explanation, MP_TIMEZONE, "Time Zone") + || !ds_setting(settings, dsn, &error_state, &error_explanation, MP_REPLYSIZE, "Reply Size") + + ) { + goto failure; + } + #ifdef ODBCDEBUG { size_t pos = 0; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org
MonetDB: default - add support for multi col in statements, fixe...
Changeset: d7fec2bf7345 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/d7fec2bf7345 Modified Files: sql/backends/monet5/rel_bin.c sql/server/rel_exp.c sql/server/rel_select.c sql/server/rel_unnest.c sql/server/sql_parser.y sql/test/SQLancer/Tests/sqlancer22.test sql/test/subquery/Tests/subquery3.test sql/test/subquery/Tests/subquery4.test Branch: default Log Message: add support for multi col in statements, fixes #7497 diffs (truncated from 513 to 300 lines): diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c --- a/sql/backends/monet5/rel_bin.c +++ b/sql/backends/monet5/rel_bin.c @@ -446,8 +446,65 @@ subrel_project(backend *be, stmt *s, lis } static stmt * +handle_in_tuple_exps(backend *be, sql_exp *ce, list *nl, stmt *left, stmt *right, stmt *grp, stmt *ext, stmt *cnt, stmt *sel, bool in, int depth, int reduce, int push) +{ + mvc *sql = be->mvc; + stmt *s = NULL; + + list *lvals = ce->f, *lstmts = sa_list(sql->sa); + for(node *n = lvals->h; n; n = n->next) { + sql_exp *ce = n->data; + stmt *c = exp_bin(be, ce, left, right, grp, ext, cnt, NULL, depth+1, 0, push); + + if (c && reduce && c->nrcols == 0) + c = stmt_const(be, bin_find_smallest_column(be, left), c); + if(!c) + return NULL; + lstmts = append(lstmts, c); + } + + sql_subtype *bt = sql_bind_localtype("bit"); + sql_subfunc *and = sql_bind_func(sql, "sys", "and", bt, bt, F_FUNC, true, true); + sql_subfunc *or = sql_bind_func(sql, "sys", "or", bt, bt, F_FUNC, true, true); + for (node *n = nl->h; n; n = n->next) { + sql_exp *e = n->data; + list *vals = e->f; + stmt *cursel = NULL; + + for (node *m = vals->h, *o = lstmts->h; m && o; m = m->next, o = o->next) { + stmt *c = o->data; + sql_subfunc *cmp = (in) + ?sql_bind_func(sql, "sys", "=", tail_type(c), tail_type(c), F_FUNC, true, true) + :sql_bind_func(sql, "sys", "<>", tail_type(c), tail_type(c), F_FUNC, true, true); + sql_exp *e = m->data; + + stmt *i = exp_bin(be, e, left, right, grp, ext, cnt, NULL, depth+1, 0, push); + if(!i) + return NULL; + + i = stmt_binop(be, c, i, NULL, cmp); + if (cursel) + cursel = stmt_binop(be, cursel, i, NULL, in?and:or); + else + cursel = i; + } + if (s) + s = stmt_binop(be, s, cursel, NULL, in?or:and); + else + s = cursel; + } + if (sel && !(depth || !reduce)) + s = stmt_uselect(be, + s->nrcols == 0?stmt_const(be, bin_find_smallest_column(be, left), s): s, + stmt_bool(be, 1), cmp_equal, sel, 0, 0); + return s; +} + +static stmt * handle_in_exps(backend *be, sql_exp *ce, list *nl, stmt *left, stmt *right, stmt *grp, stmt *ext, stmt *cnt, stmt *sel, bool in, int depth, int reduce, int push) { + if (ce && is_values(ce)) + return handle_in_tuple_exps(be, ce, nl, left, right, grp, ext, cnt, sel, in, depth, reduce, push); mvc *sql = be->mvc; node *n; stmt *s = NULL, *c = exp_bin(be, ce, left, right, grp, ext, cnt, NULL, depth+1, 0, push); diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c --- a/sql/server/rel_exp.c +++ b/sql/server/rel_exp.c @@ -2036,7 +2036,7 @@ exp_is_atom( sql_exp *e ) switch (e->type) { case e_atom: if (e->f) /* values list */ - return 0; + return exps_are_atoms(e->f); return 1; case e_convert: return exp_is_atom(e->l); 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 @@ -823,45 +823,84 @@ exp_tuples_set_supertype(mvc *sql, list for (node *m = vals->h; m; m = m->next) { sql_exp *tuple = m->data; - sql_rel *tuple_relation = exp_rel_get_rel(sql->sa, tuple); - - for(n = tuple_relation->exps->h, i = 0; n; n = n->next, i++) { - sql_subtype *tpe; - sql_exp *e = n->data; - - if (has_type[i] && e->type == e_atom && !e->l && !e->r && !e->f && !e->tpe.type) { - if (set_type_param(sql, types+i, e->flag) == 0) - e->tpe = types[i]; - else + if (is_values(tuple)) { +
MonetDB: default - enable test
Changeset: 85aaf41e2e88 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/85aaf41e2e88 Modified Files: sql/test/BugTracker-2024/Tests/multicolumn_IN_value_list-Bug-7497.test Branch: default Log Message: enable test diffs (11 lines): diff --git a/sql/test/BugTracker-2024/Tests/multicolumn_IN_value_list-Bug-7497.test b/sql/test/BugTracker-2024/Tests/multicolumn_IN_value_list-Bug-7497.test --- a/sql/test/BugTracker-2024/Tests/multicolumn_IN_value_list-Bug-7497.test +++ b/sql/test/BugTracker-2024/Tests/multicolumn_IN_value_list-Bug-7497.test @@ -10,7 +10,6 @@ CREATE TABLE s (s1 INT, s2 INT, s3 INT); statement ok INSERT INTO s VALUES (41, 44, 10), (42, 44, 20), (34, 44, 30), (41, 45, 40), (34, 45, 50), (34, 44, 60), (42, 44, 70), (42, 44, 80); -skipif knownfail query III nosort SELECT * FROM s WHERE (s1, s2) IN ((42,44), (41,45), (43,42)) ORDER BY s3; ___ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org