Changeset: aa7b64d05255 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=aa7b64d05255
Modified Files:
sql/backends/monet5/generator/Tests/generator00.sql
sql/backends/monet5/generator/Tests/generator00.stable.out
sql/backends/monet5/sql_scenario.c
sql/storage/bat/bat_logger.c
sql/storage/store.c
Branch: default
Log Message:
Merge with Oct2014 branch.
diffs (201 lines):
diff --git a/sql/backends/monet5/generator/Tests/generator00.sql
b/sql/backends/monet5/generator/Tests/generator00.sql
--- a/sql/backends/monet5/generator/Tests/generator00.sql
+++ b/sql/backends/monet5/generator/Tests/generator00.sql
@@ -8,6 +8,8 @@ select * from generate_series(0,10,2) wh
select * from generate_series(0,10,2) where value =4;
+select * from generate_series(0,10,2) where value <>4;
+
select * from generate_series(0,10,2) as v where value <7 and value >3;
select * from generate_series(0,10,2) as v where value <7 and value >3 and
value <=6 and value >=4;
@@ -22,6 +24,8 @@ select * from generate_series(10,0,-2) w
select * from generate_series(10,0,-2) where value = 6;
+select * from generate_series(10,0,-2) where value <> 6;
+
select * from generate_series(10,0,-2) as v where value <7 and value >3;
select * from generate_series(10,0,-2) as v where value <7 and value >3 and
value <=6 and value >=4;
diff --git a/sql/backends/monet5/generator/Tests/generator00.stable.out
b/sql/backends/monet5/generator/Tests/generator00.stable.out
--- a/sql/backends/monet5/generator/Tests/generator00.stable.out
+++ b/sql/backends/monet5/generator/Tests/generator00.stable.out
@@ -101,6 +101,15 @@ Ready.
% tinyint # type
% 1 # length
[ 4 ]
+#select * from generate_series(0,10,2) where value <>4;
+% . # table_name
+% value # name
+% tinyint # type
+% 1 # length
+[ 0 ]
+[ 2 ]
+[ 6 ]
+[ 8 ]
#select * from generate_series(0,10,2) as v where value <7 and value >3;
% .v # table_name
% value # name
@@ -164,6 +173,14 @@ Ready.
% tinyint # type
% 1 # length
[ 6 ]
+#select * from generate_series(10,0,-2) where value <> 6;
+% . # table_name
+% value # name
+% tinyint # type
+% 1 # length
+[ 8 ]
+[ 4 ]
+[ 2 ]
#select * from generate_series(10,0,-2) as v where value <7 and value >3;
% .v # table_name
% value # name
diff --git a/sql/backends/monet5/sql_scenario.c
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -856,9 +856,9 @@ external name sql.analyze;\n");
}
static str
-sql_update_default(Client c)
+sql_update_oct2014(Client c)
{
- size_t bufsize = 8192, pos = 0;
+ size_t bufsize = 8192*2, pos = 0;
char *buf = GDKmalloc(bufsize), *err = NULL;
mvc *sql = ((backend*) c->sqlcontext)->mvc;
ValRecord *schvar = stack_get_var(sql, "current_schema");
@@ -875,13 +875,17 @@ sql_update_default(Client c)
pos += snprintf(buf + pos, bufsize - pos, "delete from _columns where
table_id not in (select id from _tables);\n");
/* add new columns */
- pos += snprintf(buf + pos, bufsize - pos, "insert into _columns values(
(select max(id)+1 from _columns), 'system', 'boolean', 1, 0, (select id from
_tables where name = 'schemas'), NULL, true, 4, NULL);\n");
- pos += snprintf(buf + pos, bufsize - pos, "insert into _columns values(
(select max(id)+1 from _columns), 'varres', 'boolean', 1, 0, (select id from
_tables where name = 'functions'), NULL, true, 7, NULL);\n");
- pos += snprintf(buf + pos, bufsize - pos, "insert into _columns values(
(select max(id)+1 from _columns), 'vararg', 'boolean', 1, 0, (select id from
_tables where name = 'functions'), NULL, true, 8, NULL);\n");
- pos += snprintf(buf + pos, bufsize - pos, "insert into _columns values(
(select max(id)+1 from _columns), 'inout', 'tinyint', 8, 0, (select id from
_tables where name = 'args'), NULL, true, 6, NULL);\n");
+ pos += snprintf(buf + pos, bufsize - pos, "insert into _columns values(
(select max(id)+1 from _columns), 'system', 'boolean', 1, 0, (select _tables.id
from _tables join schemas on _tables.schema_id=schemas.id where
schemas.name='sys' and _tables.name='schemas'), NULL, true, 4, NULL);\n");
+ pos += snprintf(buf + pos, bufsize - pos, "insert into _columns values(
(select max(id)+1 from _columns), 'varres', 'boolean', 1, 0, (select _tables.id
from _tables join schemas on _tables.schema_id=schemas.id where
schemas.name='sys' and _tables.name='functions'), NULL, true, 7, NULL);\n");
+ pos += snprintf(buf + pos, bufsize - pos, "insert into _columns values(
(select max(id)+1 from _columns), 'vararg', 'boolean', 1, 0, (select _tables.id
from _tables join schemas on _tables.schema_id=schemas.id where
schemas.name='sys' and _tables.name='functions'), NULL, true, 8, NULL);\n");
+ pos += snprintf(buf + pos, bufsize - pos, "insert into _columns values(
(select max(id)+1 from _columns), 'inout', 'tinyint', 8, 0, (select _tables.id
from _tables join schemas on _tables.schema_id=schemas.id where
schemas.name='sys' and _tables.name='args'), NULL, true, 6, NULL);\n");
+ pos += snprintf(buf + pos, bufsize - pos, "insert into _columns values(
(select max(id)+1 from _columns), 'language', 'int', 32, 0, (select _tables.id
from _tables join schemas on _tables.schema_id=schemas.id where
schemas.name='sys' and _tables.name='functions'), NULL, true, 9, NULL);\n");
+ pos += snprintf(buf + pos, bufsize - pos, "delete from _columns where
table_id in (select _tables.id from _tables join schemas on
_tables.schema_id=schemas.id where schemas.name='sys' and
_tables.name='functions') and name='sql';\n");
+
/* correct column numbers */
- pos += snprintf(buf + pos, bufsize - pos, "update _columns set
number='9' where name = 'schema_id' and table_id in (select id from _tables
where name = 'functions');\n");
- pos += snprintf(buf + pos, bufsize - pos, "update _columns set
number='7' where name = 'number' and table_id in (select id from _tables where
name = 'args');\n");
+ pos += snprintf(buf + pos, bufsize - pos, "update _columns set
number='9' where name = 'schema_id' and table_id in (select _tables.id from
_tables join schemas on _tables.schema_id=schemas.id where schemas.name='sys'
and _tables.name='functions');\n");
+ pos += snprintf(buf + pos, bufsize - pos, "update _columns set
number='7' where name = 'number' and table_id in (select _tables.id from
_tables join schemas on _tables.schema_id=schemas.id where schemas.name='sys'
and _tables.name='args');\n");
+ pos += snprintf(buf + pos, bufsize - pos, "update _columns set
number='4' where name = 'language' and table_id in (select _tables.id from
_tables join schemas on _tables.schema_id=schemas.id where schemas.name='sys'
and _tables.name='functions');\n");
/* remove table return types (#..), ie tt_generated from
* _tables/_columns */
@@ -1011,7 +1015,7 @@ create aggregate json.tojsonarray( x dou
" I.sorted"
" from sys.storagemodelinput I;"
" end;\n");
- pos += snprintf(buf + pos, bufsize - pos,
+ pos += snprintf(buf + pos, bufsize - pos,
"create view sys.tablestoragemodel"
" as select \"schema\",\"table\",max(count) as \"count\","
" sum(columnsize) as columnsize,"
@@ -1246,7 +1250,7 @@ SQLinitClient(Client c)
* update */
sql_find_subtype(&tp, "clob", 0, 0);
if (!sql_bind_func(m->sa, mvc_bind_schema(m, "sys"), "md5",
&tp, NULL, F_FUNC)) {
- if ((err = sql_update_default(c)) !=NULL) {
+ if ((err = sql_update_oct2014(c)) !=NULL) {
fprintf(stderr, "!%s\n", err);
GDKfree(err);
}
diff --git a/sql/storage/bat/bat_logger.c b/sql/storage/bat/bat_logger.c
--- a/sql/storage/bat/bat_logger.c
+++ b/sql/storage/bat/bat_logger.c
@@ -81,7 +81,7 @@ bl_postversion( void *lg)
(void)lg;
if (catalog_version == CATALOG_FEB2013) {
/* we need to add the new schemas.system column */
- BAT *b, *b1, *b2;
+ BAT *b, *b1, *b2, *b3;
BATiter bi;
char *s = "sys", n[64];
BUN p,q;
@@ -131,30 +131,51 @@ bl_postversion( void *lg)
bat_destroy(b1);
/* add functions.vararg/varres */
- b = temp_descriptor(logger_find_bat(lg, N(n, NULL, s,
"functions_name")));
+ b = temp_descriptor(logger_find_bat(lg, N(n, NULL, s,
"functions_sql")));
+
if (!b)
return;
bi = bat_iterator(b);
b1 = BATnew(TYPE_void, TYPE_bit, BATcount(b), PERSISTENT);
b2 = BATnew(TYPE_void, TYPE_bit, BATcount(b), PERSISTENT);
- if (!b1 || !b2)
+ b3 = BATnew(TYPE_void, TYPE_int, BATcount(b), PERSISTENT);
+
+ if (!b1 || !b2 || !b3)
return;
BATseqbase(b1, b->hseqbase);
BATseqbase(b2, b->hseqbase);
+ BATseqbase(b3, b->hseqbase);
+
/* default to no variaable arguments and results */
for(p=BUNfirst(b), q=BUNlast(b); p<q; p++) {
bit v = FALSE;
+ int type;
/* TODO how about import ! */
BUNappend(b1, &v, TRUE);
BUNappend(b2, &v, TRUE);
+
+ /* this should be value of functions_sql + 1*/
+ type = *(bit*) BUNtloc(bi,p) + 1;
+ BUNappend(b3, &type, TRUE);
+
}
b1 = BATsetaccess(b1, BAT_READ);
b2 = BATsetaccess(b2, BAT_READ);
+ b3 = BATsetaccess(b3, BAT_READ);
+
logger_add_bat(lg, b1, N(n, NULL, s, "functions_vararg"));
logger_add_bat(lg, b2, N(n, NULL, s, "functions_varres"));
+ logger_add_bat(lg, b3, N(n, NULL, s, "functions_language"));
+
bat_destroy(b);
+
+ /* delete functions.sql */
+ logger_del_bat(lg, b->batCacheid);
+
bat_destroy(b1);
bat_destroy(b2);
+ bat_destroy(b3);
+
/* TODO rename columns.storage_type -> storage */
}
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -1080,6 +1080,7 @@ static void
insert_aggrs(sql_trans *tr, sql_table *sysfunc, sql_table *sysarg)
{
int zero = 0;
+ int lang = FUNC_LANG_INT;
bit F = FALSE;
node *n = NULL;
@@ -1092,9 +1093,9 @@ insert_aggrs(sql_trans *tr, sql_table *s
int number = 0;
if (aggr->s)
- table_funcs.table_insert(tr, sysfunc, &aggr->base.id,
aggr->base.name, aggr->imp, aggr->mod, &F, &aggr->type, &F, &aggr->varres,
&aggr->vararg, &aggr->s->base.id);
+ table_funcs.table_insert(tr, sysfunc, &aggr->base.id,
aggr->base.name, aggr->imp, aggr->mod, &lang, &aggr->type, &F, &aggr->varres,
&aggr->vararg, &aggr->s->base.id);
else
- table_funcs.table_insert(tr, sysfunc, &aggr->base.id,
aggr->base.name, aggr->imp, aggr->mod, &F, &aggr->type, &F, &aggr->varres,
&aggr->vararg, &zero);
+ table_funcs.table_insert(tr, sysfunc, &aggr->base.id,
aggr->base.name, aggr->imp, aggr->mod, &lang, &aggr->type, &F, &aggr->varres,
&aggr->vararg, &zero);
res = aggr->res->h->data;
id = next_oid();
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list