Changeset: 47cdf56a0478 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/47cdf56a0478
Modified Files:
        sql/backends/monet5/sql_upgrades.c
        sql/server/rel_unnest.c
Branch: privfuncs
Log Message:

Merged with default (another conflict generated)


diffs (truncated from 3040 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
@@ -298,6 +298,24 @@ sql_update_hugeint(Client c, mvc *sql)
 }
 #endif
 
+#ifdef HAVE_SHP
+static str
+sql_update_shp(Client c)
+{
+       const char *query = "create procedure SHPattach(fname string) external 
name shp.attach;\ncreate procedure SHPload(fid integer) external name 
shp.import;\ncreate procedure SHPload(fid integer, filter geometry) external 
name shp.import;\nupdate sys.functions set system = true where schema_id = 2000 
and name in ('shpattach', 'shpload');\n";
+       printf("Running database upgrade commands:\n%s\n", query);
+       return SQLstatementIntern(c, query, "update", true, false, NULL);
+}
+#endif
+
+static str
+sql_update_generator(Client c)
+{
+       const char *query = "update sys.args set name = 'limit' where name = 
'last' and func_id in (select id from sys.functions where schema_id = 2000 and 
name = 'generate_series' and func like '% last %');\n"
+               "update sys.functions set func = replace(func, ' last ', ' 
\"limit\" ') where schema_id = 2000 and name = 'generate_series' and func like 
'% last %';\n";
+       return SQLstatementIntern(c, query, "update", true, false, NULL);
+}
+
 static str
 sql_drop_functions_dependencies_Xs_on_Ys(Client c)
 {
@@ -4597,6 +4615,27 @@ SQLupgrades(Client c, mvc *m)
        }
 #endif
 
+#ifdef HAVE_SHP
+       if (backend_has_module(&(int){0}, "shp")) {
+               sql_find_subtype(&tp, "varchar", 0, 0);
+               if (!sql_bind_func(m, s->base.name, "shpattach", &tp, NULL, 
F_PROC, true)) {
+                       m->session->status = 0; /* if the function was not 
found clean the error */
+                       m->errstr[0] = '\0';
+                       if ((err = sql_update_shp(c)) != NULL) {
+                               TRC_CRITICAL(SQL_PARSER, "%s\n", err);
+                               freeException(err);
+                               return -1;
+                       }
+               }
+       }
+#endif
+
+       if ((err = sql_update_generator(c)) != NULL) {
+               TRC_CRITICAL(SQL_PARSER, "%s\n", err);
+               freeException(err);
+               return -1;
+       }
+
        f = sql_bind_func_(m, s->base.name, "env", NULL, F_UNION, true);
        m->session->status = 0; /* if the function was not found clean the 
error */
        m->errstr[0] = '\0';
diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c
--- a/sql/server/rel_unnest.c
+++ b/sql/server/rel_unnest.c
@@ -1841,75 +1841,6 @@ rewrite_empty_project(visitor *v, sql_re
 }
 
 #define is_anyequal(sf) (strcmp((sf)->func->base.name, "sql_anyequal") == 0)
-#define is_not_anyequal(sf) (strcmp((sf)->func->base.name, "sql_not_anyequal") 
== 0)
-
-#define ANYEQUAL 1
-#define NOT_ANYEQUAL 2
-static int exps_have_anyequal(list *exps, int any_or_not_anyequal);
-
-static int
-exp_has_anyequal(sql_exp *e, int any_or_not_anyequal)
-{
-       if (!e)
-               return 0;
-       switch(e->type){
-       case e_func:
-       case e_aggr: {
-               list *args = e->l;
-               sql_subfunc *f = e->f;
-
-               if (f && f->func && (any_or_not_anyequal&NOT_ANYEQUAL) && 
is_not_anyequal(f) && exps_have_rel_exp(args))
-                       return 1;
-               if (f && f->func && (any_or_not_anyequal&ANYEQUAL) && 
is_anyequal(f) && exps_have_rel_exp(args))
-                       return 1;
-               return exps_have_anyequal(e->l, any_or_not_anyequal);
-       }
-       case e_cmp:
-               if (e->flag == cmp_or || e->flag == cmp_filter)
-                       return (exps_have_anyequal(e->l, any_or_not_anyequal) 
|| exps_have_anyequal(e->r, any_or_not_anyequal));
-               if (e->flag == cmp_in || e->flag == cmp_notin)
-                       return (exp_has_anyequal(e->l, any_or_not_anyequal) || 
exps_have_anyequal(e->r, any_or_not_anyequal));
-               return (exp_has_anyequal(e->l, any_or_not_anyequal) || 
exp_has_anyequal(e->r, any_or_not_anyequal) ||
-                               (e->f && exp_has_anyequal(e->f, 
any_or_not_anyequal)));
-       case e_convert:
-               return exp_has_anyequal(e->l, any_or_not_anyequal);
-       case e_atom:
-               return (e->f && exp_has_anyequal(e->f, any_or_not_anyequal));
-       case e_psm:
-       case e_column:
-               return 0;
-       }
-       return 0;
-}
-
-static int
-exps_have_anyequal(list *exps, int any_or_not_anyequal)
-{
-       if (list_empty(exps))
-               return 0;
-       for(node *n=exps->h; n; n=n->next) {
-               sql_exp *e = n->data;
-
-               if (exp_has_anyequal(e, any_or_not_anyequal))
-                       return 1;
-       }
-       return 0;
-}
-
-/* introduce extra selects for (not) anyequal + subquery */
-static sql_rel *
-not_anyequal_helper(visitor *v, sql_rel *rel)
-{
-       if (is_innerjoin(rel->op) && exps_have_anyequal(rel->exps, 
NOT_ANYEQUAL)) {
-               sql_rel *nrel = rel_select(v->sql->sa, rel, NULL);
-               nrel->exps = rel->exps;
-               set_processed(nrel);
-               rel->exps = NULL;
-               rel = nrel;
-               v->changes++;
-       }
-       return rel;
-}
 
 /*
  * For decimals and intervals we need to adjust the scale for some operations.
@@ -3932,7 +3863,6 @@ rel_unnest(mvc *sql, sql_rel *rel)
 
        rel = rel_exp_visitor_bottomup(&v, rel, &rel_simplify_exp_and_rank, 
false);
        rel = rel_visitor_bottomup(&v, rel, &rel_unnest_simplify);
-       rel = rel_visitor_bottomup(&v, rel, &not_anyequal_helper);
 
        rel = rel_exp_visitor_bottomup(&v, rel, &rewrite_complex, true);
        rel = rel_exp_visitor_bottomup(&v, rel, &rewrite_ifthenelse, false);    
/* add isnull handling */
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
@@ -3980,6 +3980,12 @@ insert into sys.functions values (1055, 
 insert into sys.functions values (1056, 'sys_update_tables', 'update_tables', 
'sql', 0, 2, true, false, false, 2000, true, true);
 
 Running database upgrade commands:
+create procedure SHPattach(fname string) external name shp.attach;
+create procedure SHPload(fid integer) external name shp.import;
+create procedure SHPload(fid integer, filter geometry) external name 
shp.import;
+update sys.functions set system = true where schema_id = 2000 and name in 
('shpattach', 'shpload');
+
+Running database upgrade commands:
 update sys.args set type = 'decimal', type_digits = 18, type_scale = 3 where 
func_id in (select id from sys.functions where name = 'epoch_ms' and schema_id 
= 2000) and number = 0 and type = 'bigint';
 drop view sys.tracelog;
 drop function sys.tracelog();
diff --git 
a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.ppc64.int128
 
b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.ppc64.int128
--- 
a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.ppc64.int128
+++ 
b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.ppc64.int128
@@ -3980,6 +3980,12 @@ insert into sys.functions values (1055, 
 insert into sys.functions values (1056, 'sys_update_tables', 'update_tables', 
'sql', 0, 2, true, false, false, 2000, true, true);
 
 Running database upgrade commands:
+create procedure SHPattach(fname string) external name shp.attach;
+create procedure SHPload(fid integer) external name shp.import;
+create procedure SHPload(fid integer, filter geometry) external name 
shp.import;
+update sys.functions set system = true where schema_id = 2000 and name in 
('shpattach', 'shpload');
+
+Running database upgrade commands:
 update sys.args set type = 'decimal', type_digits = 18, type_scale = 3 where 
func_id in (select id from sys.functions where name = 'epoch_ms' and schema_id 
= 2000) and number = 0 and type = 'bigint';
 drop view sys.tracelog;
 drop function sys.tracelog();
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
@@ -3408,6 +3408,12 @@ insert into sys.functions values (910, '
 insert into sys.functions values (911, 'sys_update_tables', 'update_tables', 
'sql', 0, 2, true, false, false, 2000, true, true);
 
 Running database upgrade commands:
+create procedure SHPattach(fname string) external name shp.attach;
+create procedure SHPload(fid integer) external name shp.import;
+create procedure SHPload(fid integer, filter geometry) external name 
shp.import;
+update sys.functions set system = true where schema_id = 2000 and name in 
('shpattach', 'shpload');
+
+Running database upgrade commands:
 update sys.args set type = 'decimal', type_digits = 18, type_scale = 3 where 
func_id in (select id from sys.functions where name = 'epoch_ms' and schema_id 
= 2000) and number = 0 and type = 'bigint';
 drop view sys.tracelog;
 drop function sys.tracelog();
diff --git 
a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.32bit 
b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.32bit
--- a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.32bit
+++ b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.32bit
@@ -3408,6 +3408,12 @@ insert into sys.functions values (910, '
 insert into sys.functions values (911, 'sys_update_tables', 'update_tables', 
'sql', 0, 2, true, false, false, 2000, true, true);
 
 Running database upgrade commands:
+create procedure SHPattach(fname string) external name shp.attach;
+create procedure SHPload(fid integer) external name shp.import;
+create procedure SHPload(fid integer, filter geometry) external name 
shp.import;
+update sys.functions set system = true where schema_id = 2000 and name in 
('shpattach', 'shpload');
+
+Running database upgrade commands:
 update sys.args set type = 'decimal', type_digits = 18, type_scale = 3 where 
func_id in (select id from sys.functions where name = 'epoch_ms' and schema_id 
= 2000) and number = 0 and type = 'bigint';
 drop view sys.tracelog;
 drop function sys.tracelog();
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
@@ -4049,6 +4049,12 @@ update sys.functions set system = true w
 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:
+create procedure SHPattach(fname string) external name shp.attach;
+create procedure SHPload(fid integer) external name shp.import;
+create procedure SHPload(fid integer, filter geometry) external name 
shp.import;
+update sys.functions set system = true where schema_id = 2000 and name in 
('shpattach', 'shpload');
+
+Running database upgrade commands:
 update sys.args set type = 'decimal', type_digits = 18, type_scale = 3 where 
func_id in (select id from sys.functions where name = 'epoch_ms' and schema_id 
= 2000) and number = 0 and type = 'bigint';
 drop view sys.tracelog;
 drop function sys.tracelog();
diff --git 
a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.ppc64 
b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.ppc64
--- a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.ppc64
+++ b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.ppc64
@@ -3408,6 +3408,12 @@ insert into sys.functions values (910, '
 insert into sys.functions values (911, 'sys_update_tables', 'update_tables', 
'sql', 0, 2, true, false, false, 2000, true, true);
 
 Running database upgrade commands:
+create procedure SHPattach(fname string) external name shp.attach;
+create procedure SHPload(fid integer) external name shp.import;
+create procedure SHPload(fid integer, filter geometry) external name 
shp.import;
+update sys.functions set system = true where schema_id = 2000 and name in 
('shpattach', 'shpload');
+
+Running database upgrade commands:
 update sys.args set type = 'decimal', type_digits = 18, type_scale = 3 where 
func_id in (select id from sys.functions where name = 'epoch_ms' and schema_id 
= 2000) and number = 0 and type = 'bigint';
 drop view sys.tracelog;
 drop function sys.tracelog();
diff --git 
a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128 
b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
--- 
a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
+++ 
b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
@@ -4049,6 +4049,12 @@ update sys.functions set system = true w
 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:
+create procedure SHPattach(fname string) external name shp.attach;
+create procedure SHPload(fid integer) external name shp.import;
+create procedure SHPload(fid integer, filter geometry) external name 
shp.import;
+update sys.functions set system = true where schema_id = 2000 and name in 
('shpattach', 'shpload');
+
+Running database upgrade commands:
 update sys.args set type = 'decimal', type_digits = 18, type_scale = 3 where 
func_id in (select id from sys.functions where name = 'epoch_ms' and schema_id 
= 2000) and number = 0 and type = 'bigint';
 drop view sys.tracelog;
 drop function sys.tracelog();
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
@@ -3979,3 +3979,9 @@ insert into sys.args values (51444, 1054
 insert into sys.functions values (1055, 'sys_update_schemas', 
'update_schemas', 'sql', 0, 2, true, false, false, 2000, true, true);
 insert into sys.functions values (1056, 'sys_update_tables', 'update_tables', 
'sql', 0, 2, true, false, false, 2000, true, true);
 
+Running database upgrade commands:
+create procedure SHPattach(fname string) external name shp.attach;
+create procedure SHPload(fid integer) external name shp.import;
+create procedure SHPload(fid integer, filter geometry) external name 
shp.import;
+update sys.functions set system = true where schema_id = 2000 and name in 
('shpattach', 'shpload');
+
diff --git 
a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.ppc64.int128 
b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.ppc64.int128
--- a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.ppc64.int128
+++ b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.ppc64.int128
@@ -3979,3 +3979,9 @@ insert into sys.args values (51439, 1054
 insert into sys.functions values (1055, 'sys_update_schemas', 
'update_schemas', 'sql', 0, 2, true, false, false, 2000, true, true);
 insert into sys.functions values (1056, 'sys_update_tables', 'update_tables', 
'sql', 0, 2, true, false, false, 2000, true, true);
 
+Running database upgrade commands:
+create procedure SHPattach(fname string) external name shp.attach;
+create procedure SHPload(fid integer) external name shp.import;
+create procedure SHPload(fid integer, filter geometry) external name 
shp.import;
+update sys.functions set system = true where schema_id = 2000 and name in 
('shpattach', 'shpload');
+
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
@@ -3407,3 +3407,9 @@ insert into sys.args values (45292, 909,
 insert into sys.functions values (910, 'sys_update_schemas', 'update_schemas', 
'sql', 0, 2, true, false, false, 2000, true, true);
 insert into sys.functions values (911, 'sys_update_tables', 'update_tables', 
'sql', 0, 2, true, false, false, 2000, true, true);
 
+Running database upgrade commands:
+create procedure SHPattach(fname string) external name shp.attach;
+create procedure SHPload(fid integer) external name shp.import;
+create procedure SHPload(fid integer, filter geometry) external name 
shp.import;
+update sys.functions set system = true where schema_id = 2000 and name in 
('shpattach', 'shpload');
+
diff --git a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit 
b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit
--- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit
+++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit
@@ -3407,3 +3407,9 @@ insert into sys.args values (45292, 909,
 insert into sys.functions values (910, 'sys_update_schemas', 'update_schemas', 
'sql', 0, 2, true, false, false, 2000, true, true);
 insert into sys.functions values (911, 'sys_update_tables', 'update_tables', 
'sql', 0, 2, true, false, false, 2000, true, true);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to