Changeset: b4dd0e325beb for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b4dd0e325beb
Branch: client_interrupts
Log Message:
Merge with default branch.
diffs (truncated from 522 to 300 lines):
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -3428,13 +3428,11 @@ log_printinfo(logger *lg)
printf("number of flushers: %d\n", (int) ATOMIC_GET(&lg->nr_flushers));
printf("number of catalog entries "BUNFMT", of which "BUNFMT"
deleted\n",
lg->catalog_bid->batCount, lg->dcatalog->batCount);
- int npend = 0;
for (logged_range *p = lg->pending; p; p = p->next) {
char buf[32];
if (p->output_log == NULL ||
snprintf(buf, sizeof(buf), ", file size %"PRIu64,
(uint64_t) getfilepos(getFile(lg->current->output_log))) >= (int) sizeof(buf))
buf[0] = 0;
printf("pending range "ULLFMT": drops %"PRIu64", last_ts
%"PRIu64", flushed_ts %"PRIu64", refcount %"PRIu64"%s%s\n", p->id, (uint64_t)
ATOMIC_GET(&p->drops), (uint64_t) ATOMIC_GET(&p->last_ts), (uint64_t)
ATOMIC_GET(&p->flushed_ts), (uint64_t) ATOMIC_GET(&p->refcount), buf, p ==
lg->current ? " (current)" : "");
- npend++;
}
}
diff --git a/monetdb5/modules/mal/txtsim.c b/monetdb5/modules/mal/txtsim.c
--- a/monetdb5/modules/mal/txtsim.c
+++ b/monetdb5/modules/mal/txtsim.c
@@ -450,10 +450,16 @@ typedef struct {
static inline int
popcount64(uint64_t x)
{
+#if defined(__GNUC__)
+ return (uint32_t) __builtin_popcountll(x);
+#elif defined(_MSC_VER)
+ return (uint32_t) __popcnt64(x);
+#else
x = (x & 0x5555555555555555ULL) + ((x >> 1) & 0x5555555555555555ULL);
x = (x & 0x3333333333333333ULL) + ((x >> 2) & 0x3333333333333333ULL);
x = (x & 0x0F0F0F0F0F0F0F0FULL) + ((x >> 4) & 0x0F0F0F0F0F0F0F0FULL);
return (x * 0x0101010101010101ULL) >> 56;
+#endif
}
static int
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
@@ -6561,6 +6561,39 @@ sql_update_dec2023(Client c, mvc *sql, s
return err;
}
+static str
+sql_update_dec2023_sp1(Client c, mvc *sql, sql_schema *s)
+{
+ char *err;
+ res_table *output;
+ BAT *b;
+
+ (void) sql;
+ (void) s;
+
+ /* json.isvalid(json) has been fixed to return NULL on NULL input */
+ err = SQLstatementIntern(c, "SELECT f.id FROM sys.functions f WHERE
f.name = 'isvalid' AND f.schema_id = (SELECT s.id FROM sys.schemas s WHERE
s.name = 'json') AND EXISTS (SELECT * FROM sys.args a WHERE a.func_id = f.id
AND a.number = 1 AND a.type = 'json') AND f.func LIKE '%begin return
true%';\n", "update", true, false, &output);
+ if (err)
+ return err;
+ b = BATdescriptor(output->cols[0].b);
+ if (b) {
+ if (BATcount(b) > 0) {
+ const char *query = "drop function
json.isvalid(json);\n"
+ "create function json.isvalid(js json)\n"
+ "returns bool begin return case when js is NULL
then NULL else true end; end;\n"
+ "GRANT EXECUTE ON FUNCTION json.isvalid(json)
TO PUBLIC;\n"
+ "update sys.functions set system = true where
system <> true and name = 'isvalid' and schema_id = (select id from sys.schemas
where name = 'json');\n";
+ assert(BATcount(b) == 1);
+ printf("Running database upgrade commands:\n%s\n",
query);
+ fflush(stdout);
+ err = SQLstatementIntern(c, query, "update", true,
false, NULL);
+ }
+ BBPunfix(b->batCacheid);
+ }
+ res_table_destroy(output);
+ return err;
+}
+
int
SQLupgrades(Client c, mvc *m)
{
@@ -6739,15 +6772,19 @@ SQLupgrades(Client c, mvc *m)
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_jun2023_sp3(c, m, s)) != NULL) {
+ if ((err = sql_update_dec2023_sp1(c, m, s)) != NULL) {
TRC_CRITICAL(SQL_PARSER, "%s\n", err);
- freeException(err);
- return -1;
+ goto handle_error;
}
return 0;
diff --git a/sql/scripts/40_json.sql b/sql/scripts/40_json.sql
--- a/sql/scripts/40_json.sql
+++ b/sql/scripts/40_json.sql
@@ -50,7 +50,7 @@ returns bool external name json.isvalid;
GRANT EXECUTE ON FUNCTION json.isvalid(string) TO PUBLIC;
create function json.isvalid(js json)
-returns bool begin return true; end;
+returns bool begin return case when js is NULL then NULL else true end; end;
GRANT EXECUTE ON FUNCTION json.isvalid(json) TO PUBLIC;
create function json.isobject(js json)
diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c
--- a/sql/server/rel_optimize_proj.c
+++ b/sql/server/rel_optimize_proj.c
@@ -2935,7 +2935,7 @@ rel_groupjoin(visitor *v, sql_rel *rel)
}
}
if (nr == list_length(gbes)) {
- printf("#group by converted\n");
+ // printf("#group by converted\n");
j = rel_dup(j);
j->attr = rel->exps;
v->changes++;
diff --git a/sql/server/rel_optimize_sel.c b/sql/server/rel_optimize_sel.c
--- a/sql/server/rel_optimize_sel.c
+++ b/sql/server/rel_optimize_sel.c
@@ -3000,7 +3000,7 @@ rel_simplify_project_fk_join(mvc *sql, s
if (!list_empty(r->attr)) {
nr = rel_groupby(sql, nr, NULL);
if (nr) {
- printf("# introduced groupby \n");
+ // printf("# introduced groupby \n");
nr->r = append(sa_list(sql->sa), le);
nr->exps = r->attr;
}
@@ -3636,7 +3636,7 @@ rel_select_leftgroup_2_semi(visitor *v,
sql_exp *a = attrs->h->data;
if (exps_find_exp(l->attr, e->l) && exp_is_true(e->r)
&& e->flag == cmp_equal /*&& exp_is_true(a)*/) {
- printf("# optimize select leftgroup -> semi\n");
+ // printf("# optimize select leftgroup ->
semi\n");
if (!list_empty(l->exps)) {
for(node *m = l->exps->h; m; m =
m->next) {
sql_exp *j = m->data;
diff --git a/sql/test/SQLancer/Tests/sqlancer17.test
b/sql/test/SQLancer/Tests/sqlancer17.test
--- a/sql/test/SQLancer/Tests/sqlancer17.test
+++ b/sql/test/SQLancer/Tests/sqlancer17.test
@@ -363,7 +363,7 @@ create or replace view v30(vc0) as (sele
query I nosort
select json."isvalid"(CAST(v30.vc0 AS JSON)) FROM v30
----
-1
+NULL
statement ok
ROLLBACK
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
@@ -603,3 +603,10 @@ GRANT EXECUTE ON FUNCTION sys.persist_un
UPDATE sys.functions SET system = true WHERE system <> true AND
name = 'persist_unlogged' AND schema_id = 2000 AND type = 5 AND language = 1;
+Running database upgrade commands:
+drop function json.isvalid(json);
+create function json.isvalid(js json)
+returns bool begin return case when js is NULL then NULL else true end; end;
+GRANT EXECUTE ON FUNCTION json.isvalid(json) TO PUBLIC;
+update sys.functions set system = true where system <> true and name =
'isvalid' and schema_id = (select id from sys.schemas where name = 'json');
+
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
@@ -603,3 +603,10 @@ GRANT EXECUTE ON FUNCTION sys.persist_un
UPDATE sys.functions SET system = true WHERE system <> true AND
name = 'persist_unlogged' AND schema_id = 2000 AND type = 5 AND language = 1;
+Running database upgrade commands:
+drop function json.isvalid(json);
+create function json.isvalid(js json)
+returns bool begin return case when js is NULL then NULL else true end; end;
+GRANT EXECUTE ON FUNCTION json.isvalid(json) TO PUBLIC;
+update sys.functions set system = true where system <> true and name =
'isvalid' and schema_id = (select id from sys.schemas where name = 'json');
+
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
@@ -672,3 +672,10 @@ GRANT EXECUTE ON FUNCTION sys.persist_un
UPDATE sys.functions SET system = true WHERE system <> true AND
name = 'persist_unlogged' AND schema_id = 2000 AND type = 5 AND language = 1;
+Running database upgrade commands:
+drop function json.isvalid(json);
+create function json.isvalid(js json)
+returns bool begin return case when js is NULL then NULL else true end; end;
+GRANT EXECUTE ON FUNCTION json.isvalid(json) TO PUBLIC;
+update sys.functions set system = true where system <> true and name =
'isvalid' and schema_id = (select id from sys.schemas where name = 'json');
+
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
@@ -603,3 +603,10 @@ GRANT EXECUTE ON FUNCTION sys.persist_un
UPDATE sys.functions SET system = true WHERE system <> true AND
name = 'persist_unlogged' AND schema_id = 2000 AND type = 5 AND language = 1;
+Running database upgrade commands:
+drop function json.isvalid(json);
+create function json.isvalid(js json)
+returns bool begin return case when js is NULL then NULL else true end; end;
+GRANT EXECUTE ON FUNCTION json.isvalid(json) TO PUBLIC;
+update sys.functions set system = true where system <> true and name =
'isvalid' and schema_id = (select id from sys.schemas where name = 'json');
+
diff --git a/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out
b/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out
--- a/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out
+++ b/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out
@@ -603,3 +603,10 @@ GRANT EXECUTE ON FUNCTION sys.persist_un
UPDATE sys.functions SET system = true WHERE system <> true AND
name = 'persist_unlogged' AND schema_id = 2000 AND type = 5 AND language = 1;
+Running database upgrade commands:
+drop function json.isvalid(json);
+create function json.isvalid(js json)
+returns bool begin return case when js is NULL then NULL else true end; end;
+GRANT EXECUTE ON FUNCTION json.isvalid(json) TO PUBLIC;
+update sys.functions set system = true where system <> true and name =
'isvalid' and schema_id = (select id from sys.schemas where name = 'json');
+
diff --git a/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128
b/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128
@@ -672,3 +672,10 @@ GRANT EXECUTE ON FUNCTION sys.persist_un
UPDATE sys.functions SET system = true WHERE system <> true AND
name = 'persist_unlogged' AND schema_id = 2000 AND type = 5 AND language = 1;
+Running database upgrade commands:
+drop function json.isvalid(json);
+create function json.isvalid(js json)
+returns bool begin return case when js is NULL then NULL else true end; end;
+GRANT EXECUTE ON FUNCTION json.isvalid(json) TO PUBLIC;
+update sys.functions set system = true where system <> true and name =
'isvalid' and schema_id = (select id from sys.schemas where name = 'json');
+
diff --git a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
@@ -0,0 +1,7 @@
+Running database upgrade commands:
+drop function json.isvalid(json);
+create function json.isvalid(js json)
+returns bool begin return case when js is NULL then NULL else true end; end;
+GRANT EXECUTE ON FUNCTION json.isvalid(json) TO PUBLIC;
+update sys.functions set system = true where system <> true and name =
'isvalid' and schema_id = (select id from sys.schemas where name = 'json');
+
diff --git a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
--- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
+++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
@@ -0,0 +1,7 @@
+Running database upgrade commands:
+drop function json.isvalid(json);
+create function json.isvalid(js json)
+returns bool begin return case when js is NULL then NULL else true end; end;
+GRANT EXECUTE ON FUNCTION json.isvalid(json) TO PUBLIC;
+update sys.functions set system = true where system <> true and name =
'isvalid' and schema_id = (select id from sys.schemas where name = 'json');
+
diff --git a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
@@ -69,3 +69,10 @@ update sys.functions set system = true w
update sys.functions set system = true where system <> true and name in
('stddev_samp', 'stddev_pop', 'var_samp', 'covar_samp', 'var_pop', 'covar_pop',
'corr') and schema_id = (select id from sys.schemas where name = 'sys') and
type = 6;
update sys.functions set system = true where system <> true and name =
'filter' and schema_id = (select id from sys.schemas where name = 'json') and
type = 1;
+Running database upgrade commands:
+drop function json.isvalid(json);
+create function json.isvalid(js json)
+returns bool begin return case when js is NULL then NULL else true end; end;
+GRANT EXECUTE ON FUNCTION json.isvalid(json) TO PUBLIC;
+update sys.functions set system = true where system <> true and name =
'isvalid' and schema_id = (select id from sys.schemas where name = 'json');
+
diff --git
a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
--- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
+++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
@@ -69,3 +69,10 @@ update sys.functions set system = true w
update sys.functions set system = true where system <> true and name in
('stddev_samp', 'stddev_pop', 'var_samp', 'covar_samp', 'var_pop', 'covar_pop',
'corr') and schema_id = (select id from sys.schemas where name = 'sys') and
type = 6;
update sys.functions set system = true where system <> true and name =
'filter' and schema_id = (select id from sys.schemas where name = 'json') and
type = 1;
+Running database upgrade commands:
+drop function json.isvalid(json);
+create function json.isvalid(js json)
+returns bool begin return case when js is NULL then NULL else true end; end;
+GRANT EXECUTE ON FUNCTION json.isvalid(json) TO PUBLIC;
+update sys.functions set system = true where system <> true and name =
'isvalid' and schema_id = (select id from sys.schemas where name = 'json');
+
diff --git a/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
b/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
@@ -0,0 +1,7 @@
+Running database upgrade commands:
+drop function json.isvalid(json);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]