Changeset: 77eede2aee5c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/77eede2aee5c
Modified Files:
        sql/storage/bat/bat_storage.c
Branch: default
Log Message:

Merge with Aug2024 branch.


diffs (truncated from 812 to 300 lines):

diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -452,6 +452,45 @@ bailout:
        return false;
 }
 
+static bool
+has_check_constraint(Mapi mid)
+{
+       MapiHdl hdl;
+       bool ret;
+       static int answer = -1;
+
+       if (answer >= 0)
+               return answer;
+
+       if ((hdl = mapi_query(mid,
+                                                 "select id from sys.functions"
+                                                 " where schema_id = 2000"
+                                                 " and name = 
'check_constraint'")) == NULL ||
+           mapi_error(mid))
+               goto bailout;
+       ret = mapi_get_row_count(hdl) == 1;
+       while ((mapi_fetch_row(hdl)) != 0) {
+               if (mapi_error(mid))
+                       goto bailout;
+       }
+       if (mapi_error(mid))
+               goto bailout;
+       mapi_close_handle(hdl);
+       answer = ret;
+       return ret;
+
+bailout:
+       if (hdl) {
+               if (mapi_result_error(hdl))
+                       mapi_explain_result(hdl, stderr);
+               else
+                       mapi_explain_query(hdl, stderr);
+               mapi_close_handle(hdl);
+       } else
+               mapi_explain(mid, stderr);
+       return false;
+}
+
 static int
 dump_foreign_keys(Mapi mid, const char *schema, const char *tname, const char 
*tid, stream *sqlf)
 {
@@ -1114,6 +1153,7 @@ dump_column_definition(Mapi mid, stream 
        mapi_close_handle(hdl);
        hdl = NULL;
 
+       const char *cc = has_check_constraint(mid) ? "case when k.type = 4 then 
sys.check_constraint(s.name, k.name) else null end" : "cast(null as 
varchar(10))";
        if (tid)
                snprintf(query, maxquerylen,
                         "SELECT kc.name, "             /* 0 */
@@ -1121,13 +1161,13 @@ dump_column_definition(Mapi mid, stream 
                                "k.name, "                      /* 2 */
                                "kc.id, "                       /* 3 */
                                "k.type, "                      /* 4 */
-                           "case when k.type = 4 then 
sys.check_constraint(s.name, k.name) else null end " /* 5 */
+                           "%s " /* 5 */
                         "FROM sys.objects kc, "
                              "sys.keys k "
                         "WHERE kc.id = k.id "
                           "AND k.table_id = %s "
                           "AND k.type = 1 "
-                        "ORDER BY kc.id, kc.nr", tid);
+                        "ORDER BY kc.id, kc.nr", cc, tid);
        else
                snprintf(query, maxquerylen,
                         "SELECT kc.name, "             /* 0 */
@@ -1135,7 +1175,7 @@ dump_column_definition(Mapi mid, stream 
                                "k.name, "                      /* 2 */
                                "kc.id, "                       /* 3 */
                                "k.type, "                      /* 4 */
-                           "case when k.type = 4 then 
sys.check_constraint(s.name, k.name) else null end " /* 5 */
+                           "%s " /* 5 */
                         "FROM sys.objects kc, "
                              "sys.keys k, "
                              "sys.schemas s, "
@@ -1146,7 +1186,7 @@ dump_column_definition(Mapi mid, stream 
                           "AND t.schema_id = s.id "
                           "AND s.name = '%s' "
                           "AND t.name = '%s' "
-                        "ORDER BY kc.id, kc.nr", s, t);
+                        "ORDER BY kc.id, kc.nr", cc, s, t);
        if ((hdl = mapi_query(mid, query)) == NULL || mapi_error(mid))
                goto bailout;
        cnt = 0;
diff --git a/clients/mapilib/connect.c b/clients/mapilib/connect.c
--- a/clients/mapilib/connect.c
+++ b/clients/mapilib/connect.c
@@ -429,7 +429,7 @@ send_all_clientinfo(Mapi mid)
        size_t pos = 0, cap = 200;
 
        if (hostname[0])
-               reallocprintf(&buf, &pos, &cap, "ClientHostName=%s\n", 
hostname);
+               reallocprintf(&buf, &pos, &cap, "ClientHostname=%s\n", 
hostname);
        if (application_name[0])
                reallocprintf(&buf, &pos, &cap, "ApplicationName=%s\n", 
application_name);
        reallocprintf(&buf, &pos, &cap, "ClientLibrary=");
diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c
--- a/monetdb5/modules/atoms/str.c
+++ b/monetdb5/modules/atoms/str.c
@@ -2875,7 +2875,7 @@ ignorecase(const bat *ic_id, bool *icase
        if ((c = BATdescriptor(*ic_id)) == NULL)
                throw(MAL, fname, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
 
-       assert(BATcount(c) == 1);
+       assert(BATcount(c) >= 1);
 
        BATiter bi = bat_iterator(c);
        *icase = *(bit *) BUNtloc(bi, 0);
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
@@ -7101,13 +7101,13 @@ sql_update_aug2024(Client c, mvc *sql, s
                                                "create procedure 
sys.setclientinfo(property string, value string)\n"
                                                " external name 
clients.setinfo;\n"
                                                "grant execute on procedure 
sys.setclientinfo(string, string) to public;\n"
-                                               "create table 
sys.clientinfo_properties(prop string);\n"
+                                               "create table 
sys.clientinfo_properties(prop string, session_attr string);\n"
                                                "insert into 
sys.clientinfo_properties values\n"
-                                               " ('ClientHostname'),\n"
-                                               " ('ApplicationName'),\n"
-                                               " ('ClientLibrary'),\n"
-                                               " ('ClientRemark'),\n"
-                                               " ('ClientPid');\n"
+                                               " ('ClientHostname', 
'hostname'),\n"
+                                               " ('ApplicationName', 
'application'),\n"
+                                               " ('ClientLibrary', 
'client'),\n"
+                                               " ('ClientRemark', 'remark'),\n"
+                                               " ('ClientPid', 'clientpid');\n"
                                                "update sys.functions set 
system = true where schema_id = 2000 and name in ('setclientinfo', 
'sessions');\n"
                                                "update sys._tables set system 
= true where schema_id = 2000 and name in ('clientinfo_properties', 
'sessions');\n";
 
diff --git a/sql/scripts/22_clients.sql b/sql/scripts/22_clients.sql
--- a/sql/scripts/22_clients.sql
+++ b/sql/scripts/22_clients.sql
@@ -44,13 +44,13 @@ create view sys.sessions as select * fro
 create procedure sys.setclientinfo(property string, value string)
        external name clients.setinfo;
 grant execute on procedure sys.setclientinfo(string, string) to public;
-create table sys.clientinfo_properties(prop string);
+create table sys.clientinfo_properties(prop string, session_attr string);
 insert into sys.clientinfo_properties values
-       ('ClientHostname'),
-       ('ApplicationName'),
-       ('ClientLibrary'),
-       ('ClientRemark'),
-       ('ClientPid');
+       ('ClientHostname', 'hostname'),
+       ('ApplicationName', 'application'),
+       ('ClientLibrary', 'client'),
+       ('ClientRemark', 'remark'),
+       ('ClientPid', 'clientpid');
 
 -- routines to bring the system down quickly
 create procedure sys.shutdown(delay tinyint)
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -730,6 +730,18 @@ merge_updates( BAT *ui, BAT **UV, BAT *o
        int err = 0;
        BAT *uv = *UV;
        BUN cnt = BATcount(ui)+BATcount(oi);
+       BAT *ni = bat_new(TYPE_oid, cnt, SYSTRANS);
+       BAT *nv = uv?bat_new(uv->ttype, cnt, SYSTRANS):NULL;
+
+       if (!ni || (uv && !nv)) {
+               bat_destroy(ni);
+               bat_destroy(nv);
+               bat_destroy(ui);
+               bat_destroy(uv);
+               bat_destroy(oi);
+               bat_destroy(ov);
+               return NULL;
+       }
        BATiter uvi;
        BATiter ovi;
 
@@ -751,35 +763,6 @@ merge_updates( BAT *ui, BAT **UV, BAT *o
                uipt = uii.base;
        if (!BATtdensebi(&oii))
                oipt = oii.base;
-
-       if (uiseqb == oiseqb && uie == oie) { /* full overlap, no values */
-               if (uv) {
-                       bat_iterator_end(&uvi);
-                       bat_iterator_end(&ovi);
-               }
-               bat_iterator_end(&uii);
-               bat_iterator_end(&oii);
-               if (uv) {
-                       *UV = uv;
-               } else {
-                       bat_destroy(uv);
-               }
-               bat_destroy(oi);
-               bat_destroy(ov);
-               return ui;
-       }
-       BAT *ni = bat_new(TYPE_oid, cnt, SYSTRANS);
-       BAT *nv = uv?bat_new(uv->ttype, cnt, SYSTRANS):NULL;
-
-       if (!ni || (uv && !nv)) {
-               bat_destroy(ni);
-               bat_destroy(nv);
-               bat_destroy(ui);
-               bat_destroy(uv);
-               bat_destroy(oi);
-               bat_destroy(ov);
-               return NULL;
-       }
        while (uip < uie && oip < oie && !err) {
                oid uiid = (uipt)?uipt[uip]: uiseqb+uip;
                oid oiid = (oipt)?oipt[oip]: oiseqb+oip;
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
@@ -67,3 +67,4 @@ 7536-mclient-forgets-to-flush
 7538-reduce-cast
 7539-is-distinct-from
 7537-prepare_stmt_with_dropped_table
+7536-mclient-forgets-to-flush
diff --git 
a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
--- 
a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
+++ 
b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
@@ -1032,13 +1032,13 @@ create view sys.sessions as select * fro
 create procedure sys.setclientinfo(property string, value string)
  external name clients.setinfo;
 grant execute on procedure sys.setclientinfo(string, string) to public;
-create table sys.clientinfo_properties(prop string);
+create table sys.clientinfo_properties(prop string, session_attr string);
 insert into sys.clientinfo_properties values
- ('ClientHostname'),
- ('ApplicationName'),
- ('ClientLibrary'),
- ('ClientRemark'),
- ('ClientPid');
+ ('ClientHostname', 'hostname'),
+ ('ApplicationName', 'application'),
+ ('ClientLibrary', 'client'),
+ ('ClientRemark', 'remark'),
+ ('ClientPid', 'clientpid');
 update sys.functions set system = true where schema_id = 2000 and name in 
('setclientinfo', 'sessions');
 update sys._tables set system = true where schema_id = 2000 and name in 
('clientinfo_properties', 'sessions');
 
diff --git a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out 
b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
--- a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
+++ b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
@@ -1020,13 +1020,13 @@ create view sys.sessions as select * fro
 create procedure sys.setclientinfo(property string, value string)
  external name clients.setinfo;
 grant execute on procedure sys.setclientinfo(string, string) to public;
-create table sys.clientinfo_properties(prop string);
+create table sys.clientinfo_properties(prop string, session_attr string);
 insert into sys.clientinfo_properties values
- ('ClientHostname'),
- ('ApplicationName'),
- ('ClientLibrary'),
- ('ClientRemark'),
- ('ClientPid');
+ ('ClientHostname', 'hostname'),
+ ('ApplicationName', 'application'),
+ ('ClientLibrary', 'client'),
+ ('ClientRemark', 'remark'),
+ ('ClientPid', 'clientpid');
 update sys.functions set system = true where schema_id = 2000 and name in 
('setclientinfo', 'sessions');
 update sys._tables set system = true where schema_id = 2000 and name in 
('clientinfo_properties', 'sessions');
 
diff --git 
a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
@@ -1101,13 +1101,13 @@ create view sys.sessions as select * fro
 create procedure sys.setclientinfo(property string, value string)
  external name clients.setinfo;
 grant execute on procedure sys.setclientinfo(string, string) to public;
-create table sys.clientinfo_properties(prop string);
+create table sys.clientinfo_properties(prop string, session_attr string);
 insert into sys.clientinfo_properties values
- ('ClientHostname'),
- ('ApplicationName'),
- ('ClientLibrary'),
- ('ClientRemark'),
- ('ClientPid');
+ ('ClientHostname', 'hostname'),
+ ('ApplicationName', 'application'),
+ ('ClientLibrary', 'client'),
+ ('ClientRemark', 'remark'),
+ ('ClientPid', 'clientpid');
 update sys.functions set system = true where schema_id = 2000 and name in 
('setclientinfo', 'sessions');
 update sys._tables set system = true where schema_id = 2000 and name in 
('clientinfo_properties', 'sessions');
 
diff --git 
a/sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
@@ -1032,13 +1032,13 @@ create view sys.sessions as select * fro
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to