Changeset: a542fb1a85cb for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a542fb1a85cb
Modified Files:
        sql/backends/monet5/sql_upgrades.c
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade/Tests/upgrade.stable.out
        sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: default
Log Message:

Database upgrade.


diffs (truncated from 326 to 300 lines):

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
@@ -1320,6 +1320,8 @@ from sys.storagemodel() group by \"schem
 \tsorted boolean);\n");
 
        /* 15_querylog update the querylog table definition */
+       pos += snprintf(buf+pos, bufsize - pos, "drop view 
sys.querylog_history;\n");
+       pos += snprintf(buf+pos, bufsize - pos, "drop view 
sys.querylog_calls;\n");
        pos += snprintf(buf+pos, bufsize - pos, "drop function 
sys.querylog_calls;\n");
        pos += snprintf(buf+pos, bufsize - pos, "create function 
sys.querylog_calls()\
 \treturns table(\
@@ -1333,9 +1335,15 @@ from sys.storagemodel() group by \"schem
 \t    cpu int,\n\
 \t    io int \n\
 \t) external name sql.querylog_calls;\n");
+       pos += snprintf(buf+pos, bufsize - pos, "create view sys.querylog_calls 
as select * from sys.querylog_calls();\n");
+       pos += snprintf(buf+pos, bufsize - pos, "create view 
sys.querylog_history as\n\
+select qd.*, ql.\"start\",ql.\"stop\", ql.arguments, ql.tuples, ql.run, 
ql.ship, ql.cpu, ql.io\n\
+from sys.querylog_catalog() qd, sys.querylog_calls() ql\n\
+where qd.id = ql.id and qd.owner = user;\n");
 
 
        /* 16_tracelog update the tracelog table definition */
+       pos += snprintf(buf+pos, bufsize - pos, "drop view sys.tracelog;\n");
        pos += snprintf(buf+pos, bufsize - pos, "drop function 
sys.tracelog;\n");
        pos += snprintf(buf+pos, bufsize - pos, "create function 
sys.tracelog()\n\
 \treturns table (\n\
@@ -1353,10 +1361,12 @@ from sys.storagemodel() group by \"schem
 \tnvcsw bigint,  \n\
 \tstmt string         \n\
 \t) external name sql.dump_trace;\n");
+       pos += snprintf(buf+pos, bufsize - pos, "create view sys.tracelog as 
select * from sys.tracelog();\n");
 
 
-       pos += snprintf(buf + pos, bufsize - pos, "insert into 
sys.systemfunctions (select id from sys.functions where name in ('like', 
'ilike', 'columnsize', 'imprintsize', 'storagemodel') and schema_id = (select 
id from sys.schemas where name = 'sys') and id not in (select function_id from 
sys.systemfunctions));\n");
-       pos += snprintf(buf + pos, bufsize - pos, "update sys._tables set 
system = true where name in ('statistics', 'storagemodel', 'tablestoragemodel', 
'querylog_calls','tracelog') and schema_id = (select id from sys.schemas where 
name = 'sys');\n");
+       pos += snprintf(buf + pos, bufsize - pos, "insert into 
sys.systemfunctions (select id from sys.functions where name in ('like', 
'ilike', 'columnsize', 'imprintsize', 'storagemodel', 'querylog_calls', 
'tracelog') and schema_id = (select id from sys.schemas where name = 'sys') and 
id not in (select function_id from sys.systemfunctions));\n");
+       pos += snprintf(buf + pos, bufsize - pos, "delete from systemfunctions 
where function_id not in (select id from functions);\n");
+       pos += snprintf(buf + pos, bufsize - pos, "update sys._tables set 
system = true where name in ('statistics', 'storagemodel', 'tablestoragemodel', 
'querylog_calls', 'querylog_history', 'tracelog') and schema_id = (select id 
from sys.schemas where name = 'sys');\n");
 
        {
                char *msg;
@@ -1376,6 +1386,12 @@ from sys.storagemodel() group by \"schem
                                        t->system = 0;
                                if ((t = mvc_bind_table(sql, s, "statistics")) 
!= NULL)
                                        t->system = 0;
+                               if ((t = mvc_bind_table(sql, s, 
"querylog_calls")) != NULL)
+                                       t->system = 0;
+                               if ((t = mvc_bind_table(sql, s, 
"querylog_history")) != NULL)
+                                       t->system = 0;
+                               if ((t = mvc_bind_table(sql, s, "tracelog")) != 
NULL)
+                                       t->system = 0;
                        }
                }
        }
diff --git a/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out 
b/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
--- a/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
+++ b/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
@@ -124,8 +124,48 @@ create table sys.statistics(
        minval string,
        maxval string,
        sorted boolean);
-insert into sys.systemfunctions (select id from sys.functions where name in 
('like', 'ilike', 'columnsize', 'imprintsize', 'storagemodel') and schema_id = 
(select id from sys.schemas where name = 'sys') and id not in (select 
function_id from sys.systemfunctions));
-update sys._tables set system = true where name in ('statistics', 
'storagemodel', 'tablestoragemodel') and schema_id = (select id from 
sys.schemas where name = 'sys');
+drop view sys.querylog_history;
+drop view sys.querylog_calls;
+drop function sys.querylog_calls;
+create function sys.querylog_calls()   returns table(      id oid,
+           "start" timestamp,
+           "stop" timestamp,
+           arguments string,
+           tuples wrd,
+           run bigint,
+           ship bigint,
+           cpu int,
+           io int 
+       ) external name sql.querylog_calls;
+create view sys.querylog_calls as select * from sys.querylog_calls();
+create view sys.querylog_history as
+select qd.*, ql."start",ql."stop", ql.arguments, ql.tuples, ql.run, ql.ship, 
ql.cpu, ql.io
+from sys.querylog_catalog() qd, sys.querylog_calls() ql
+where qd.id = ql.id and qd.owner = user;
+drop view sys.tracelog;
+drop function sys.tracelog;
+create function sys.tracelog()
+       returns table (
+       event integer,      
+       clk varchar(20),    
+       pc varchar(50),     
+       thread int,         
+       ticks bigint,       
+       rrsMB bigint,       
+       vmMB bigint,        
+       reads bigint,       
+       writes bigint,  
+       minflt bigint,  
+       majflt bigint,  
+       nvcsw bigint,  
+       stmt string         
+       ) external name sql.dump_trace;
+create view sys.tracelog as select * from sys.tracelog();
+insert into sys.systemfunctions (select id from sys.functions where name in 
('like', 'ilike', 'columnsize', 'imprintsize', 'storagemodel', 
'querylog_calls', 'tracelog') and schema_id = (select id from sys.schemas where 
name = 'sys') and id not in (select function_id from sys.systemfunctions));
+delete from systemfunctions where function_id not in (select id from 
functions);
+update sys._tables set system = true where name in ('statistics', 
'storagemodel', 'tablestoragemodel', 'querylog_calls', 'querylog_history', 
'tracelog') and schema_id = (select id from sys.schemas where name = 'sys');
+drop procedure sys.cluster1;
+drop procedure sys.cluster2;
 set schema "testschema";
 
 # 09:43:35 >  
diff --git a/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128 
b/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
--- a/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
+++ b/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
@@ -21,6 +21,15 @@ stdout of test 'upgrade` in directory 's
 Ready.
 Running database upgrade commands:
 set schema "sys";
+CREATE FUNCTION "left_shift"(i1 inet, i2 inet) RETURNS boolean EXTERNAL NAME 
inet."<<";
+CREATE FUNCTION "right_shift"(i1 inet, i2 inet) RETURNS boolean EXTERNAL NAME 
inet.">>";
+CREATE FUNCTION "left_shift_assign"(i1 inet, i2 inet) RETURNS boolean EXTERNAL 
NAME inet."<<=";
+CREATE FUNCTION "right_shift_assign"(i1 inet, i2 inet) RETURNS boolean 
EXTERNAL NAME inet.">>=";
+insert into sys.systemfunctions (select id from sys.functions where name in 
('left_shift', 'right_shift', 'left_shift_assign', 'right_shift_assign') and 
schema_id = (select id from sys.schemas where name = 'sys') and id not in 
(select function_id from sys.systemfunctions));
+set schema "testschema";
+
+Running database upgrade commands:
+set schema "sys";
 create function sys.fuse(one bigint, two bigint)
 returns hugeint
 external name udf.fuse;
@@ -66,8 +75,8 @@ from sys.storagemodel() group by "schema
 insert into sys.systemfunctions (select id from sys.functions where name in 
('fuse', 'generate_series', 'stddev_samp', 'stddev_pop', 'var_samp', 'var_pop', 
'median', 'quantile', 'corr') and schema_id = (select id from sys.schemas where 
name = 'sys') and id not in (select function_id from sys.systemfunctions));
 insert into sys.systemfunctions (select id from sys.functions where name = 
'filter' and schema_id = (select id from sys.schemas where name = 'json') and 
id not in (select function_id from sys.systemfunctions));
 update sys._tables set system = true where name = 'tablestoragemodel' and 
schema_id = (select id from sys.schemas where name = 'sys');
-insert into sys.types values(7243, 'hge', 'hugeint', 128, 1, 2, 6, 0);
-insert into sys.types values(7244, 'hge', 'decimal', 39, 1, 10, 8, 0);
+insert into sys.types values(7284, 'hge', 'hugeint', 128, 1, 2, 6, 0);
+insert into sys.types values(7285, 'hge', 'decimal', 39, 1, 10, 8, 0);
 update sys.types set digits = 18 where systemname = 'lng' and sqlname = 
'decimal';
 set schema "testschema";
 
@@ -167,8 +176,48 @@ create table sys.statistics(
        minval string,
        maxval string,
        sorted boolean);
-insert into sys.systemfunctions (select id from sys.functions where name in 
('like', 'ilike', 'columnsize', 'imprintsize', 'storagemodel') and schema_id = 
(select id from sys.schemas where name = 'sys') and id not in (select 
function_id from sys.systemfunctions));
-update sys._tables set system = true where name in ('statistics', 
'storagemodel', 'tablestoragemodel') and schema_id = (select id from 
sys.schemas where name = 'sys');
+drop view sys.querylog_history;
+drop view sys.querylog_calls;
+drop function sys.querylog_calls;
+create function sys.querylog_calls()   returns table(      id oid,
+           "start" timestamp,
+           "stop" timestamp,
+           arguments string,
+           tuples wrd,
+           run bigint,
+           ship bigint,
+           cpu int,
+           io int 
+       ) external name sql.querylog_calls;
+create view sys.querylog_calls as select * from sys.querylog_calls();
+create view sys.querylog_history as
+select qd.*, ql."start",ql."stop", ql.arguments, ql.tuples, ql.run, ql.ship, 
ql.cpu, ql.io
+from sys.querylog_catalog() qd, sys.querylog_calls() ql
+where qd.id = ql.id and qd.owner = user;
+drop view sys.tracelog;
+drop function sys.tracelog;
+create function sys.tracelog()
+       returns table (
+       event integer,      
+       clk varchar(20),    
+       pc varchar(50),     
+       thread int,         
+       ticks bigint,       
+       rrsMB bigint,       
+       vmMB bigint,        
+       reads bigint,       
+       writes bigint,  
+       minflt bigint,  
+       majflt bigint,  
+       nvcsw bigint,  
+       stmt string         
+       ) external name sql.dump_trace;
+create view sys.tracelog as select * from sys.tracelog();
+insert into sys.systemfunctions (select id from sys.functions where name in 
('like', 'ilike', 'columnsize', 'imprintsize', 'storagemodel', 
'querylog_calls', 'tracelog') and schema_id = (select id from sys.schemas where 
name = 'sys') and id not in (select function_id from sys.systemfunctions));
+delete from systemfunctions where function_id not in (select id from 
functions);
+update sys._tables set system = true where name in ('statistics', 
'storagemodel', 'tablestoragemodel', 'querylog_calls', 'querylog_history', 
'tracelog') and schema_id = (select id from sys.schemas where name = 'sys');
+drop procedure sys.cluster1;
+drop procedure sys.cluster2;
 set schema "testschema";
 
 #Interpreting bte as bit.
diff --git a/sql/test/testdb-upgrade/Tests/upgrade.stable.out 
b/sql/test/testdb-upgrade/Tests/upgrade.stable.out
--- a/sql/test/testdb-upgrade/Tests/upgrade.stable.out
+++ b/sql/test/testdb-upgrade/Tests/upgrade.stable.out
@@ -112,8 +112,48 @@ create table sys.statistics(
        minval string,
        maxval string,
        sorted boolean);
-insert into sys.systemfunctions (select id from sys.functions where name in 
('like', 'ilike', 'columnsize', 'imprintsize', 'storagemodel') and schema_id = 
(select id from sys.schemas where name = 'sys') and id not in (select 
function_id from sys.systemfunctions));
-update sys._tables set system = true where name in ('statistics', 
'storagemodel', 'tablestoragemodel') and schema_id = (select id from 
sys.schemas where name = 'sys');
+drop view sys.querylog_history;
+drop view sys.querylog_calls;
+drop function sys.querylog_calls;
+create function sys.querylog_calls()   returns table(      id oid,
+           "start" timestamp,
+           "stop" timestamp,
+           arguments string,
+           tuples wrd,
+           run bigint,
+           ship bigint,
+           cpu int,
+           io int 
+       ) external name sql.querylog_calls;
+create view sys.querylog_calls as select * from sys.querylog_calls();
+create view sys.querylog_history as
+select qd.*, ql."start",ql."stop", ql.arguments, ql.tuples, ql.run, ql.ship, 
ql.cpu, ql.io
+from sys.querylog_catalog() qd, sys.querylog_calls() ql
+where qd.id = ql.id and qd.owner = user;
+drop view sys.tracelog;
+drop function sys.tracelog;
+create function sys.tracelog()
+       returns table (
+       event integer,      
+       clk varchar(20),    
+       pc varchar(50),     
+       thread int,         
+       ticks bigint,       
+       rrsMB bigint,       
+       vmMB bigint,        
+       reads bigint,       
+       writes bigint,  
+       minflt bigint,  
+       majflt bigint,  
+       nvcsw bigint,  
+       stmt string         
+       ) external name sql.dump_trace;
+create view sys.tracelog as select * from sys.tracelog();
+insert into sys.systemfunctions (select id from sys.functions where name in 
('like', 'ilike', 'columnsize', 'imprintsize', 'storagemodel', 
'querylog_calls', 'tracelog') and schema_id = (select id from sys.schemas where 
name = 'sys') and id not in (select function_id from sys.systemfunctions));
+delete from systemfunctions where function_id not in (select id from 
functions);
+update sys._tables set system = true where name in ('statistics', 
'storagemodel', 'tablestoragemodel', 'querylog_calls', 'querylog_history', 
'tracelog') and schema_id = (select id from sys.schemas where name = 'sys');
+drop procedure sys.cluster1;
+drop procedure sys.cluster2;
 set schema "testschema";
 
 
diff --git a/sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128 
b/sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
--- a/sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
+++ b/sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
@@ -18,6 +18,15 @@ stdout of test 'upgrade` in directory 's
 Ready.
 Running database upgrade commands:
 set schema "sys";
+CREATE FUNCTION "left_shift"(i1 inet, i2 inet) RETURNS boolean EXTERNAL NAME 
inet."<<";
+CREATE FUNCTION "right_shift"(i1 inet, i2 inet) RETURNS boolean EXTERNAL NAME 
inet.">>";
+CREATE FUNCTION "left_shift_assign"(i1 inet, i2 inet) RETURNS boolean EXTERNAL 
NAME inet."<<=";
+CREATE FUNCTION "right_shift_assign"(i1 inet, i2 inet) RETURNS boolean 
EXTERNAL NAME inet.">>=";
+insert into sys.systemfunctions (select id from sys.functions where name in 
('left_shift', 'right_shift', 'left_shift_assign', 'right_shift_assign') and 
schema_id = (select id from sys.schemas where name = 'sys') and id not in 
(select function_id from sys.systemfunctions));
+set schema "testschema";
+
+Running database upgrade commands:
+set schema "sys";
 create function sys.fuse(one bigint, two bigint)
 returns hugeint
 external name udf.fuse;
@@ -63,8 +72,8 @@ from sys.storagemodel() group by "schema
 insert into sys.systemfunctions (select id from sys.functions where name in 
('fuse', 'generate_series', 'stddev_samp', 'stddev_pop', 'var_samp', 'var_pop', 
'median', 'quantile', 'corr') and schema_id = (select id from sys.schemas where 
name = 'sys') and id not in (select function_id from sys.systemfunctions));
 insert into sys.systemfunctions (select id from sys.functions where name = 
'filter' and schema_id = (select id from sys.schemas where name = 'json') and 
id not in (select function_id from sys.systemfunctions));
 update sys._tables set system = true where name = 'tablestoragemodel' and 
schema_id = (select id from sys.schemas where name = 'sys');
-insert into sys.types values(6831, 'hge', 'hugeint', 128, 1, 2, 6, 0);
-insert into sys.types values(6832, 'hge', 'decimal', 39, 1, 10, 8, 0);
+insert into sys.types values(6872, 'hge', 'hugeint', 128, 1, 2, 6, 0);
+insert into sys.types values(6873, 'hge', 'decimal', 39, 1, 10, 8, 0);
 update sys.types set digits = 18 where systemname = 'lng' and sqlname = 
'decimal';
 set schema "testschema";
 
@@ -164,8 +173,48 @@ create table sys.statistics(
        minval string,
        maxval string,
        sorted boolean);
-insert into sys.systemfunctions (select id from sys.functions where name in 
('like', 'ilike', 'columnsize', 'imprintsize', 'storagemodel') and schema_id = 
(select id from sys.schemas where name = 'sys') and id not in (select 
function_id from sys.systemfunctions));
-update sys._tables set system = true where name in ('statistics', 
'storagemodel', 'tablestoragemodel') and schema_id = (select id from 
sys.schemas where name = 'sys');
+drop view sys.querylog_history;
+drop view sys.querylog_calls;
+drop function sys.querylog_calls;
+create function sys.querylog_calls()   returns table(      id oid,
+           "start" timestamp,
+           "stop" timestamp,
+           arguments string,
+           tuples wrd,
+           run bigint,
+           ship bigint,
+           cpu int,
+           io int 
+       ) external name sql.querylog_calls;
+create view sys.querylog_calls as select * from sys.querylog_calls();
+create view sys.querylog_history as
+select qd.*, ql."start",ql."stop", ql.arguments, ql.tuples, ql.run, ql.ship, 
ql.cpu, ql.io
+from sys.querylog_catalog() qd, sys.querylog_calls() ql
+where qd.id = ql.id and qd.owner = user;
+drop view sys.tracelog;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to