Changeset: e9aaee0d00a4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/e9aaee0d00a4 Removed Files: geom/monetdb5/geom_upgrade.c Modified Files: gdk/gdk_bat.c gdk/gdk_batop.c geom/monetdb5/CMakeLists.txt geom/monetdb5/geom.h Branch: geo-update Log Message:
Merge with default branch. diffs (truncated from 754 to 300 lines): diff --git a/clients/ChangeLog.Jun2023 b/clients/ChangeLog.Jun2023 --- a/clients/ChangeLog.Jun2023 +++ b/clients/ChangeLog.Jun2023 @@ -1,3 +1,10 @@ # ChangeLog file for clients # This file is updated with Maddlog +* Tue Jun 20 2023 Sjoerd Mullender <[email protected]> +- The COPY INTO from file ON CLIENT was extended to also look for a + relative path name relative to the file from which the query was read. + This is only possible if the name of the query file is known, so when + it is specified on the command line or read using the interactive + \< command. + diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -78,6 +78,7 @@ static char *encoding; #endif static bool errseen = false; static bool allow_remote = false; +static const char *curfile = NULL; #define setPrompt() snprintf(promptbuf, sizeof(promptbuf), "%.*s>", (int) sizeof(promptbuf) - 2, language) #define debugMode() (strncmp(promptbuf, "mdb", 3) == 0) @@ -2744,8 +2745,14 @@ doFile(Mapi mid, stream *fp, bool useins if (s) close_stream(s); mnstr_printf(stderr_stream, "Cannot open %s: %s\n", line, mnstr_peek_error(NULL)); - } else + } else { + const char *oldfile = curfile; + char *newfile = strdup(line); + curfile = newfile; doFile(mid, s, 0, 0, 0); + curfile = oldfile; + free(newfile); + } continue; } case '>': @@ -3033,8 +3040,25 @@ getfile(void *data, const char *filename } #endif } - if (f == NULL) - return (char*) mnstr_peek_error(NULL); + if (f == NULL) { + if (curfile != NULL) { + char *p = strrchr(curfile, '/'); +#ifdef _MSC_VER + char *q = strrchr(curfile, '\\'); + if (p == NULL || (q != NULL && q > p)) + p = q; +#endif + if (p != NULL) { + size_t x = (size_t) (p - curfile) + strlen(filename) + 2; + char *b = malloc(x); + snprintf(b, x, "%.*s/%s", (int) (p - curfile), curfile, filename); + f = binary ? open_rstream(b) : open_rastream(b); + free(b); + } + } + if (f == NULL) + return (char*) mnstr_peek_error(NULL); + } while (offset > 1) { s = mnstr_readline(f, buf, READSIZE); if (s < 0) { @@ -3528,7 +3552,7 @@ main(int argc, char **argv) c = 0; has_fileargs = optind != argc; - if (dbname == NULL && has_fileargs) { + if (dbname == NULL && has_fileargs && strcmp(argv[optind], "-") != 0) { s = open_rastream(argv[optind]); if (s == NULL || !isfile(getFile(s))) { mnstr_close(s); @@ -3538,6 +3562,8 @@ main(int argc, char **argv) dbname = strdup(argv[optind]); optind++; has_fileargs = optind != argc; + } else { + curfile = argv[optind]; } } @@ -3710,15 +3736,18 @@ main(int argc, char **argv) const char *arg = argv[optind]; if (s == NULL) { - if (strcmp(arg, "-") == 0) + if (strcmp(arg, "-") == 0) { s = stdin_rastream(); - else + } else { s = open_rastream(arg); + curfile = arg; + } } if (s == NULL) { mnstr_printf(stderr_stream, "%s: cannot open: %s\n", arg, mnstr_peek_error(NULL)); c |= 1; optind++; + curfile = NULL; continue; } // doFile closes 's'. diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -2722,7 +2722,7 @@ BATassertProps(BAT *b) } else { if (b->tvheap != NULL) { /* candidate list with exceptions */ - assert(b->batRole == TRANSIENT); + assert(b->batRole == TRANSIENT || b->batRole == SYSTRANS); assert(b->tvheap->free <= b->tvheap->size); assert(b->tvheap->free >= sizeof(ccand_t)); assert((negoid_cand(b) && ccand_free(b) % SIZEOF_OID == 0) || mask_cand(b)); diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -1410,6 +1410,7 @@ BATappend_or_update(BAT *b, BAT *p, cons } mskSetVal(b, updid, Tmskval(&ni, i)); } + bi = bat_iterator_nolock(b); } else if (autoincr) { if (pos < b->hseqbase || (!mayappend && pos + ni.count > hseqend)) { @@ -1438,6 +1439,7 @@ BATappend_or_update(BAT *b, BAT *p, cons bat_iterator_end(&ni); return GDK_FAIL; } + bi = bat_iterator_nolock(b); /* we copy all of n, so if there are nils in n we get * nils in b (and else we don't know) */ diff --git a/geom/monetdb5/CMakeLists.txt b/geom/monetdb5/CMakeLists.txt --- a/geom/monetdb5/CMakeLists.txt +++ b/geom/monetdb5/CMakeLists.txt @@ -27,7 +27,6 @@ if(GEOS_FOUND) geod.c geom_atoms.c geomBulk.c - geom_upgrade.c ${MONETDB_CURRENT_SQL_SOURCES} PUBLIC ${geomodule_public_headers}) diff --git a/geom/monetdb5/geom.h b/geom/monetdb5/geom.h --- a/geom/monetdb5/geom.h +++ b/geom/monetdb5/geom.h @@ -219,8 +219,6 @@ geom_export str wkbMBR_bat(bat* outBAT_i geom_export str wkbCoordinateFromWKB_bat(bat *outBAT_id, bat *inBAT_id, int* coordinateIdx); geom_export str wkbCoordinateFromMBR_bat(bat *outBAT_id, bat *inBAT_id, int* coordinateIdx); -geom_export str geom_sql_upgrade(int); - geom_export str wkbIntersectsJoinNoIndex(bat *lres_id, bat *rres_id, const bat *l_id, const bat *r_id, const bat *ls_id, const bat *rs_id, bit *nil_matches, lng *estimate, bit *anti); geom_export str wkbIntersectsSelectNoIndex(bat* outid, const bat *bid , const bat *sid, wkb **wkb_const, bit *anti); diff --git a/geom/monetdb5/geom_upgrade.c b/geom/monetdb5/geom_upgrade.c deleted file mode 100644 --- a/geom/monetdb5/geom_upgrade.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright 1997 - July 2008 CWI, August 2008 - 2023 MonetDB B.V. - */ - -/* - * @a Kostis Kyzirakos, Foteini Alvanaki - */ - - -#include "geom.h" -#include "gdk_logger.h" - -str -geom_sql_upgrade(int olddb) -{ - size_t bufsize = 4096000, pos = 0; - str buf; - - if ((buf = GDKmalloc(bufsize)) == NULL) - return NULL; - - /* drop old functions */ - if (olddb) { - pos += snprintf(buf + pos, bufsize - pos, - "drop function \"st_makeline\";\n" - "drop function \"st_intersects\";\n" - "drop function \"st_dwithin\";\n" - "drop function \"st_collect\";\n" - "drop aggregate \"st_collect\";\n"); - } - - /* create the new geometry types */ - pos += snprintf(buf + pos, bufsize - pos, - "CREATE FUNCTION ST_DistanceGeographic(geom1 Geometry, geom2 Geometry) RETURNS double EXTERNAL NAME geom.\"DistanceGeographic\";\n" - "GRANT EXECUTE ON FUNCTION ST_DistanceGeographic(Geometry, Geometry) TO PUBLIC;\n" - "CREATE FILTER FUNCTION ST_DWithinGeographic(geom1 Geometry, geom2 Geometry, distance double) EXTERNAL NAME geom.\"DWithinGeographic\";\n" - "GRANT EXECUTE ON FILTER ST_DWithinGeographic(Geometry, Geometry, double) TO PUBLIC;\n" - "CREATE FILTER FUNCTION ST_IntersectsGeographic(geom1 Geometry, geom2 Geometry) EXTERNAL NAME geom.\"IntersectsGeographic\";\n" - "GRANT EXECUTE ON FILTER ST_IntersectsGeographic(Geometry, Geometry) TO PUBLIC;\n" - "CREATE AGGREGATE ST_Collect(geom Geometry) RETURNS Geometry external name aggr.\"Collect\";\n" - "GRANT EXECUTE ON AGGREGATE ST_Collect(Geometry) TO PUBLIC;\n" - "CREATE FILTER FUNCTION ST_Intersects(geom1 Geometry, geom2 Geometry) EXTERNAL NAME rtree.\"Intersects\";\n" - "GRANT EXECUTE ON FILTER ST_Intersects(Geometry, Geometry) TO PUBLIC;\n" - "CREATE FILTER FUNCTION ST_Intersects_NoIndex(geom1 Geometry, geom2 Geometry) EXTERNAL NAME geom.\"Intersects_noindex\";\n" - "GRANT EXECUTE ON FILTER ST_Intersects_NoIndex(Geometry, Geometry) TO PUBLIC;\n" - "CREATE FILTER FUNCTION ST_DWithin(geom1 Geometry, geom2 Geometry, distance double) EXTERNAL NAME rtree.\"DWithin\";\n" - "GRANT EXECUTE ON FILTER ST_DWithin(Geometry, Geometry, double) TO PUBLIC;\n" - "CREATE FILTER FUNCTION ST_DWithin_NoIndex(geom1 Geometry, geom2 Geometry, distance double) EXTERNAL NAME geom.\"DWithin_noindex\";\n" - "GRANT EXECUTE ON FILTER ST_DWithin_NoIndex(Geometry, Geometry, double) TO PUBLIC;\n" - "CREATE AGGREGATE ST_MakeLine(geom Geometry) RETURNS Geometry external name aggr.\"MakeLine\";\n" - "GRANT EXECUTE ON AGGREGATE ST_MakeLine(Geometry) TO PUBLIC;\n" - "CREATE FUNCTION ST_Collect(geom1 Geometry, geom2 Geometry) RETURNS Geometry EXTERNAL NAME geom.\"Collect\";\n" - "GRANT EXECUTE ON FUNCTION ST_Collect(Geometry, Geometry) TO PUBLIC;\n"); - - pos += snprintf(buf + pos, bufsize - pos, - "update sys.functions set system = true where name in (" - "'ST_DistanceGeographic', 'ST_DWithinGeographic', 'ST_IntersectsGeographic', 'ST_Collect'," - "'ST_Intersects', 'ST_Intersects_NoIndex', 'ST_DWithin', 'ST_DWithin_NoIndex', 'ST_MakeLine') " - "and schema_id = (select id from sys.schemas where name = 'sys');\n"); - return buf; -} diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c --- a/monetdb5/mal/mal_profiler.c +++ b/monetdb5/mal/mal_profiler.c @@ -234,8 +234,8 @@ format_val2json(const ValPtr res) { char *buf = NULL; size_t sz = 0; - if (BATatoms[res->vtype].atomNull && - BATatoms[res->vtype].atomCmp(VALget(res), BATatoms[res->vtype].atomNull) == 0) + if (BATatoms[res->vtype].atomNull && (!VALget(res) || + BATatoms[res->vtype].atomCmp(VALget(res), BATatoms[res->vtype].atomNull) == 0)) return GDKstrdup("\"nil\""); bool use_external = true; diff --git a/monetdb5/optimizer/opt_emptybind.c b/monetdb5/optimizer/opt_emptybind.c --- a/monetdb5/optimizer/opt_emptybind.c +++ b/monetdb5/optimizer/opt_emptybind.c @@ -135,8 +135,9 @@ OPTemptybindImplementation(Client cntxt, q= updated[j]; if(q && getModuleId(q) == sqlRef && isUpdateInstruction(q)){ int c = getFunctionId(q) == claimRef; /* claim has 2 results */ - if ( strcmp(getVarConstant(mb,getArg(q,2+c)).val.sval, sch) == 0 && - strcmp(getVarConstant(mb,getArg(q,3+c)).val.sval, tbl) == 0 ){ + int cl = getFunctionId(q) == clear_tableRef; /* clear table has no mvc dependency */ + if ( strcmp(getVarConstant(mb,getArg(q,2-cl+c)).val.sval, sch) == 0 && + strcmp(getVarConstant(mb,getArg(q,3-cl+c)).val.sval, tbl) == 0 ){ empty[getArg(p,0)] = 0; if( p->retc == 2){ empty[getArg(p,1)] = 0; diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c --- a/sql/server/rel_optimizer.c +++ b/sql/server/rel_optimizer.c @@ -509,6 +509,32 @@ bind_merge_table_rewrite(visitor *v, glo return gp->needs_mergetable_rewrite ? rel_merge_table_rewrite : NULL; } +static sql_exp* +exp_is_predicate(visitor *v, sql_rel *d, sql_exp *e, int depth) +{ + (void)d; + (void)depth; + if (v->changes == -1) + return e; + if (e->type == e_cmp && !e->f && exp_refers(v->data, e->l)) { + if (e->semantics) + v->changes = -1; + else + v->changes = 1; + } + return e; +} + +static int +attr_is_predicate(mvc *sql, list *exps, sql_exp *a) +{ + visitor v = { .sql = sql, .data=a }; + + (void)exps_exp_visitor_topdown(&v, NULL, exps, 0, &exp_is_predicate, false); + if (v.changes == 1) + return 1; + return 0; +} static sql_rel * rel_setjoins_2_joingroupby_(visitor *v, sql_rel *rel) @@ -535,7 +561,7 @@ rel_setjoins_2_joingroupby_(visitor *v, _______________________________________________ checkin-list mailing list -- [email protected] To unsubscribe send an email to [email protected]
