Changeset: 9b5802d75eba for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9b5802d75eba
Modified Files:
gdk/gdk_atoms.c
gdk/gdk_storage.c
monetdb5/mal/mal_profiler.c
monetdb5/modules/atoms/str.c
monetdb5/modules/mal/manifold.c
sql/backends/monet5/sql_upgrades.c
sql/server/rel_exp.c
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: default
Log Message:
Merge with Jul2017 branch.
diffs (truncated from 20918 to 300 lines):
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -1076,6 +1076,7 @@ strHash(const char *s)
void
strCleanHash(Heap *h, int rebuild)
{
+ char oldhash[GDK_STRHASHSIZE];
size_t pad, pos;
const size_t extralen = h->hashash ? EXTRALEN : 0;
stridx_t *bucket;
@@ -1085,6 +1086,8 @@ strCleanHash(Heap *h, int rebuild)
(void) rebuild;
if (!h->cleanhash)
return;
+ /* copy old hash table so we can check whether we changed it */
+ memcpy(oldhash, h->base, sizeof(oldhash));
h->cleanhash = 0;
/* rebuild hash table for double elimination
*
@@ -1127,6 +1130,8 @@ strCleanHash(Heap *h, int rebuild)
}
}
#endif
+ /* only set dirty flag if the hash table actually changed */
+ h->dirty |= memcmp(oldhash, h->base, sizeof(oldhash)) != 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
@@ -26,16 +26,65 @@
static str
sql_update_hugeint(Client c, mvc *sql)
{
- size_t bufsize = 8192, pos = 0;
- // FIXME unchecked_malloc GDKmalloc can return NULL
+ size_t bufsize = 1000000, pos = 0;
char *buf = GDKmalloc(bufsize), *err = NULL;
char *schema = stack_get_string(sql, "current_schema");
+ node *n;
+ sql_schema *s;
- if( buf== NULL)
+ if (buf == NULL)
throw(SQL, "sql_update_hugeint", MAL_MALLOC_FAIL);
+ s = mvc_bind_schema(sql, "sys");
+
pos += snprintf(buf + pos, bufsize - pos, "set schema \"sys\";\n");
+ pos += snprintf(buf + pos, bufsize - pos, "delete from sys.functions
where id < 2000;\n");
+ pos += snprintf(buf + pos, bufsize - pos, "delete from sys.args where
func_id not in (select id from sys.functions);\n");
+ for (n = funcs->h; n; n = n->next) {
+ sql_func *f = n->data;
+ int number = 0;
+ sql_arg *a;
+ node *m;
+
+ if (f->base.id >= 2000)
+ continue;
+
+ pos += snprintf(buf + pos, bufsize - pos, "insert into
sys.functions values (%d, '%s', '%s', '%s', %d, %d, %s, %s, %s, %d);\n",
f->base.id, f->base.name, f->imp, f->mod, FUNC_LANG_INT, f->type,
f->side_effect ? "true" : "false", f->varres ? "true" : "false", f->vararg ?
"true" : "false", f->s ? f->s->base.id : s->base.id);
+ if (f->res) {
+ for (m = f->res->h; m; m = m->next, number++) {
+ a = m->data;
+ pos += snprintf(buf + pos, bufsize - pos,
"insert into sys.args values (%d, %d, 'res_%d', '%s', %u, %u, %d, %d);\n",
store_next_oid(), f->base.id, number, a->type.type->sqlname, a->type.digits,
a->type.scale, a->inout, number);
+ }
+ }
+ for (m = f->ops->h; m; m = m->next, number++) {
+ a = m->data;
+ if (a->name)
+ pos += snprintf(buf + pos, bufsize - pos,
"insert into sys.args values (%d, %d, '%s', '%s', %u, %u, %d, %d);\n",
store_next_oid(), f->base.id, a->name, a->type.type->sqlname, a->type.digits,
a->type.scale, a->inout, number);
+ else
+ pos += snprintf(buf + pos, bufsize - pos,
"insert into sys.args values (%d, %d, 'arg_%d', '%s', %u, %u, %d, %d);\n",
store_next_oid(), f->base.id, number, a->type.type->sqlname, a->type.digits,
a->type.scale, a->inout, number);
+ }
+ }
+ for (n = aggrs->h; n; n = n->next) {
+ sql_func *aggr = n->data;
+ sql_arg *arg;
+
+ if (aggr->base.id >= 2000)
+ continue;
+
+ pos += snprintf(buf + pos, bufsize - pos, "insert into
sys.functions values (%d, '%s', '%s', '%s', %d, %d, false, %s, %s, %d);\n",
aggr->base.id, aggr->base.name, aggr->imp, aggr->mod, FUNC_LANG_INT,
aggr->type, aggr->varres ? "true" : "false", aggr->vararg ? "true" : "false",
aggr->s ? aggr->s->base.id : s->base.id);
+ arg = aggr->res->h->data;
+ pos += snprintf(buf + pos, bufsize - pos, "insert into sys.args
values (%d, %d, 'res', '%s', %u, %u, %d, 0);\n", store_next_oid(),
aggr->base.id, arg->type.type->sqlname, arg->type.digits, arg->type.scale,
arg->inout);
+ if (aggr->ops->h) {
+ arg = aggr->ops->h->data;
+
+ pos += snprintf(buf + pos, bufsize - pos, "insert into
sys.args values (%d, %d, 'arg', '%s', %u, %u, %d, 1);\n", store_next_oid(),
aggr->base.id, arg->type.type->sqlname, arg->type.digits, arg->type.scale,
arg->inout);
+ }
+ }
+ pos += snprintf(buf + pos, bufsize - pos, "insert into
sys.systemfunctions (select id from sys.functions where id < 2000 and id not in
(select function_id from sys.systemfunctions));\n");
+ pos += snprintf(buf + pos, bufsize - pos, "delete from
sys.systemfunctions where function_id not in (select id from
sys.functions);\n");
+
+
pos += snprintf(buf + pos, bufsize - pos,
"create function fuse(one bigint, two bigint)\n"
"returns hugeint\n"
@@ -98,7 +147,7 @@ sql_update_hugeint(Client c, mvc *sql)
t = n->data;
if (t->base.id < 2000 &&
strcmp(t->base.name, "hge") == 0)
- pos += snprintf(buf + pos, bufsize - pos,
"insert into sys.types values (%d, '%s', '%s', %u, %u, %d, %d, %d);\n",
t->base.id, t->base.name, t->sqlname, t->digits, t->scale, t->radix, t->eclass,
t->s ? t->s->base.id : 0);
+ pos += snprintf(buf + pos, bufsize - pos,
"insert into sys.types values (%d, '%s', '%s', %u, %u, %d, %d, %d);\n",
t->base.id, t->base.name, t->sqlname, t->digits, t->scale, t->radix, t->eclass,
t->s ? t->s->base.id : s->base.id);
}
}
@@ -113,7 +162,17 @@ sql_update_hugeint(Client c, mvc *sql)
}
}
- if (schema)
+ pos += snprintf(buf + pos, bufsize - pos,
+ "grant execute on aggregate sys.stddev_samp(hugeint) to
public;\n"
+ "grant execute on aggregate sys.stddev_pop(hugeint) to
public;\n"
+ "grant execute on aggregate sys.var_samp(hugeint) to
public;\n"
+ "grant execute on aggregate sys.var_pop(hugeint) to
public;\n"
+ "grant execute on aggregate sys.median(hugeint) to
public;\n"
+ "grant execute on aggregate sys.quantile(hugeint,
double) to public;\n"
+ "grant execute on aggregate sys.corr(hugeint, hugeint)
to public;\n"
+ "grant execute on function json.filter(json, hugeint)
to public;\n");
+
+ if (schema)
pos += snprintf(buf + pos, bufsize - pos, "set schema
\"%s\";\n", schema);
assert(pos < bufsize);
@@ -128,14 +187,13 @@ static str
sql_update_epoch(Client c, mvc *m)
{
size_t bufsize = 1000, pos = 0;
- // FIXME unchecked_malloc GDKmalloc can return NULL
char *buf = GDKmalloc(bufsize), *err = NULL;
char *schema = stack_get_string(m, "current_schema");
sql_subtype tp;
int n = 0;
sql_schema *s = mvc_bind_schema(m, "sys");
- if( buf== NULL)
+ if (buf == NULL)
throw(SQL, "sql_update_epoch", MAL_MALLOC_FAIL);
pos += snprintf(buf + pos, bufsize - pos, "set schema \"sys\";\n");
@@ -182,13 +240,12 @@ static str
sql_update_jun2016(Client c, mvc *sql)
{
size_t bufsize = 1000000, pos = 0;
- // FIXME unchecked_malloc GDKmalloc can return NULL
char *buf = GDKmalloc(bufsize), *err = NULL;
char *schema = stack_get_string(sql, "current_schema");
node *n;
sql_schema *s;
- if( buf== NULL)
+ if (buf == NULL)
throw(SQL, "sql_update_jun2016", MAL_MALLOC_FAIL);
s = mvc_bind_schema(sql, "sys");
pos += snprintf(buf + pos, bufsize - pos, "set schema \"sys\";\n");
@@ -468,7 +525,6 @@ sql_update_geom(Client c, mvc *sql, int
if (geomupgrade == NULL)
throw(SQL, "sql_update_geom", MAL_MALLOC_FAIL);
bufsize = strlen(geomupgrade) + 512;
- // FIXME unchecked_malloc GDKmalloc can return NULL
buf = GDKmalloc(bufsize);
if (buf == NULL) {
GDKfree(geomupgrade);
@@ -503,12 +559,11 @@ static str
sql_update_dec2016(Client c, mvc *sql)
{
size_t bufsize = 12240, pos = 0;
- // FIXME unchecked_malloc GDKmalloc can return NULL
char *buf = GDKmalloc(bufsize), *err = NULL;
char *schema = stack_get_string(sql, "current_schema");
sql_schema *s;
- if( buf== NULL)
+ if (buf == NULL)
throw(SQL, "sql_update_dec2016", MAL_MALLOC_FAIL);
s = mvc_bind_schema(sql, "sys");
pos += snprintf(buf + pos, bufsize - pos, "set schema \"sys\";\n");
@@ -769,13 +824,12 @@ static str
sql_update_nowrd(Client c, mvc *sql)
{
size_t bufsize = 10240, pos = 0;
- // FIXME unchecked_malloc GDKmalloc can return NULL
char *buf = GDKmalloc(bufsize), *err = NULL;
char *schema = stack_get_string(sql, "current_schema");
sql_schema *s;
- if( buf== NULL)
+ if (buf == NULL)
throw(SQL, "sql_update_nowrd", MAL_MALLOC_FAIL);
s = mvc_bind_schema(sql, "sys");
pos += snprintf(buf + pos, bufsize - pos, "set schema \"sys\";\n");
@@ -928,11 +982,10 @@ static str
sql_update_geom_jun2016_sp2(Client c, mvc *sql)
{
size_t bufsize = 1000000, pos = 0;
- // FIXME unchecked_malloc GDKmalloc can return NULL
char *buf = GDKmalloc(bufsize), *err = NULL;
char *schema = stack_get_string(sql, "current_schema");
- if( buf== NULL)
+ if (buf == NULL)
throw(SQL, "sql_update_geom_jun2016", MAL_MALLOC_FAIL);
pos += snprintf(buf + pos, bufsize - pos, "set schema \"sys\";\n");
@@ -1076,11 +1129,10 @@ static str
sql_update_jun2016_sp2(Client c, mvc *sql)
{
size_t bufsize = 1000000, pos = 0;
- // FIXME unchecked_malloc GDKmalloc can return NULL
char *buf = GDKmalloc(bufsize), *err = NULL;
char *schema = stack_get_string(sql, "current_schema");
- if( buf== NULL)
+ if (buf == NULL)
throw(SQL, "sql_update_june2016_sp", MAL_MALLOC_FAIL);
pos += snprintf(buf + pos, bufsize - pos, "set schema \"sys\";\n");
@@ -1228,13 +1280,12 @@ static str
sql_update_dec2016_sp2(Client c, mvc *sql)
{
size_t bufsize = 2048, pos = 0;
- // FIXME unchecked_malloc GDKmalloc can return NULL
char *buf = GDKmalloc(bufsize), *err = NULL;
char *schema = stack_get_string(sql, "current_schema");
res_table *output;
BAT *b;
- if( buf== NULL)
+ if (buf == NULL)
throw(SQL, "sql_update_dec2016_sp2", MAL_MALLOC_FAIL);
pos += snprintf(buf + pos, bufsize - pos, "select id from sys.types
where sqlname = 'decimal' and digits = %d;\n",
#ifdef HAVE_HGE
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
@@ -26,6 +26,5141 @@ stdout of test 'upgrade` in directory 's
Ready.
Running database upgrade commands:
set schema "sys";
+delete from sys.functions where id < 2000;
+delete from sys.args where func_id not in (select id from sys.functions);
+insert into sys.functions values (32, 'mbr_overlap', 'mbrOverlaps', 'geom', 0,
1, false, false, false, 2000);
+insert into sys.args values (11356, 32, 'res_0', 'boolean', 1, 0, 0, 0);
+insert into sys.args values (11357, 32, 'arg_1', 'geometry', 0, 0, 1, 1);
+insert into sys.args values (11358, 32, 'arg_2', 'geometry', 0, 0, 1, 2);
+insert into sys.functions values (33, 'mbr_overlap', 'mbrOverlaps', 'geom', 0,
1, false, false, false, 2000);
+insert into sys.args values (11359, 33, 'res_0', 'boolean', 1, 0, 0, 0);
+insert into sys.args values (11360, 33, 'arg_1', 'mbr', 0, 0, 1, 1);
+insert into sys.args values (11361, 33, 'arg_2', 'mbr', 0, 0, 1, 2);
+insert into sys.functions values (34, 'mbr_above', 'mbrAbove', 'geom', 0, 1,
false, false, false, 2000);
+insert into sys.args values (11362, 34, 'res_0', 'boolean', 1, 0, 0, 0);
+insert into sys.args values (11363, 34, 'arg_1', 'geometry', 0, 0, 1, 1);
+insert into sys.args values (11364, 34, 'arg_2', 'geometry', 0, 0, 1, 2);
+insert into sys.functions values (35, 'mbr_above', 'mbrAbove', 'geom', 0, 1,
false, false, false, 2000);
+insert into sys.args values (11365, 35, 'res_0', 'boolean', 1, 0, 0, 0);
+insert into sys.args values (11366, 35, 'arg_1', 'mbr', 0, 0, 1, 1);
+insert into sys.args values (11367, 35, 'arg_2', 'mbr', 0, 0, 1, 2);
+insert into sys.functions values (36, 'mbr_below', 'mbrBelow', 'geom', 0, 1,
false, false, false, 2000);
+insert into sys.args values (11368, 36, 'res_0', 'boolean', 1, 0, 0, 0);
+insert into sys.args values (11369, 36, 'arg_1', 'geometry', 0, 0, 1, 1);
+insert into sys.args values (11370, 36, 'arg_2', 'geometry', 0, 0, 1, 2);
+insert into sys.functions values (37, 'mbr_below', 'mbrBelow', 'geom', 0, 1,
false, false, false, 2000);
+insert into sys.args values (11371, 37, 'res_0', 'boolean', 1, 0, 0, 0);
+insert into sys.args values (11372, 37, 'arg_1', 'mbr', 0, 0, 1, 1);
+insert into sys.args values (11373, 37, 'arg_2', 'mbr', 0, 0, 1, 2);
+insert into sys.functions values (38, 'mbr_right', 'mbrRight', 'geom', 0, 1,
false, false, false, 2000);
+insert into sys.args values (11374, 38, 'res_0', 'boolean', 1, 0, 0, 0);
+insert into sys.args values (11375, 38, 'arg_1', 'geometry', 0, 0, 1, 1);
+insert into sys.args values (11376, 38, 'arg_2', 'geometry', 0, 0, 1, 2);
+insert into sys.functions values (39, 'mbr_right', 'mbrRight', 'geom', 0, 1,
false, false, false, 2000);
+insert into sys.args values (11377, 39, 'res_0', 'boolean', 1, 0, 0, 0);
+insert into sys.args values (11378, 39, 'arg_1', 'mbr', 0, 0, 1, 1);
+insert into sys.args values (11379, 39, 'arg_2', 'mbr', 0, 0, 1, 2);
+insert into sys.functions values (40, 'mbr_left', 'mbrLeft', 'geom', 0, 1,
false, false, false, 2000);
+insert into sys.args values (11380, 40, 'res_0', 'boolean', 1, 0, 0, 0);
+insert into sys.args values (11381, 40, 'arg_1', 'geometry', 0, 0, 1, 1);
+insert into sys.args values (11382, 40, 'arg_2', 'geometry', 0, 0, 1, 2);
+insert into sys.functions values (41, 'mbr_left', 'mbrLeft', 'geom', 0, 1,
false, false, false, 2000);
+insert into sys.args values (11383, 41, 'res_0', 'boolean', 1, 0, 0, 0);
+insert into sys.args values (11384, 41, 'arg_1', 'mbr', 0, 0, 1, 1);
+insert into sys.args values (11385, 41, 'arg_2', 'mbr', 0, 0, 1, 2);
+insert into sys.functions values (42, 'mbr_overlap_or_above',
'mbrOverlapOrAbove', 'geom', 0, 1, false, false, false, 2000);
+insert into sys.args values (11386, 42, 'res_0', 'boolean', 1, 0, 0, 0);
+insert into sys.args values (11387, 42, 'arg_1', 'geometry', 0, 0, 1, 1);
+insert into sys.args values (11388, 42, 'arg_2', 'geometry', 0, 0, 1, 2);
+insert into sys.functions values (43, 'mbr_overlap_or_above',
'mbrOverlapOrAbove', 'geom', 0, 1, false, false, false, 2000);
+insert into sys.args values (11389, 43, 'res_0', 'boolean', 1, 0, 0, 0);
+insert into sys.args values (11390, 43, 'arg_1', 'mbr', 0, 0, 1, 1);
+insert into sys.args values (11391, 43, 'arg_2', 'mbr', 0, 0, 1, 2);
+insert into sys.functions values (44, 'mbr_overlap_or_below',
'mbrOverlapOrBelow', 'geom', 0, 1, false, false, false, 2000);
+insert into sys.args values (11392, 44, 'res_0', 'boolean', 1, 0, 0, 0);
+insert into sys.args values (11393, 44, 'arg_1', 'geometry', 0, 0, 1, 1);
+insert into sys.args values (11394, 44, 'arg_2', 'geometry', 0, 0, 1, 2);
+insert into sys.functions values (45, 'mbr_overlap_or_below',
'mbrOverlapOrBelow', 'geom', 0, 1, false, false, false, 2000);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list