Changeset: e878cbdff338 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e878cbdff338
Modified Files:
        sql/storage/bat/bat_storage.c
Branch: default
Log Message:

Merged with Jan2022


diffs (truncated from 4336 to 300 lines):

diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -1506,46 +1506,55 @@ describe_sequence(Mapi mid, const char *
                goto bailout;
 
        snprintf(query, maxquerylen,
-               "SELECT s.name, "                                               
                        /* 0 */
-                      "seq.name, "                                             
                        /* 1 */
-                      "peak_next_value_for(s.name, seq.name), "        /* 2 */
-                      "seq.\"minvalue\", "                                     
                /* 3 */
-                      "seq.\"maxvalue\", "                                     
                /* 4 */
-                      "seq.\"increment\", "                                    
        /* 5 */
-                      "seq.\"cycle\", "                                        
                /* 6 */
-                      "seq.\"cacheinc\", "                                     
                /* 7 */
-                      "rem.\"remark\" "                                        
                /* 8 */
-               "FROM sys.sequences seq LEFT OUTER JOIN sys.comments rem ON 
seq.id = rem.id, "
-                    "sys.schemas s "
-               "WHERE s.id = seq.schema_id "
-                 "AND s.name = '%s' "
-                 "AND seq.name = '%s' "
-               "ORDER BY s.name, seq.name",
+                        "SELECT c.remark, q.* "
+                          "FROM sys.sequences seq LEFT OUTER JOIN sys.comments 
c ON seq.id = c.id, "
+                               "sys.schemas s, "
+                               "sys.describe_sequences q "
+                         "WHERE s.id = seq.schema_id "
+                           "AND s.name = '%s' "   /* schema name */
+                           "AND seq.name = '%s' " /* sequence name */
+                           "AND q.sch = '%s' "    /* schema name */
+                           "AND q.seq = '%s' "    /* sequence name */
+                         "ORDER BY q.sch, q.seq",
+               schema, tname,
                schema, tname);
 
        if ((hdl = mapi_query(mid, query)) == NULL || mapi_error(mid))
                goto bailout;
 
        while (mapi_fetch_row(hdl) != 0) {
-               const char *schema = mapi_fetch_field(hdl, 0);
-               const char *name = mapi_fetch_field(hdl, 1);
-               const char *start = mapi_fetch_field(hdl, 2);
-               const char *minvalue = mapi_fetch_field(hdl, 3);
-               const char *maxvalue = mapi_fetch_field(hdl, 4);
-               const char *increment = mapi_fetch_field(hdl, 5);
-               const char *cycle = mapi_fetch_field(hdl, 6);
-               const char *cacheinc = mapi_fetch_field(hdl, 7);
-               const char *remark = mapi_fetch_field(hdl, 8);
+               const char *remark = mapi_fetch_field(hdl, 0);
+               const char *schema = mapi_fetch_field(hdl, 1);          /* sch 
*/
+               const char *name = mapi_fetch_field(hdl, 2);            /* seq 
*/
+               const char *restart = mapi_fetch_field(hdl, 4);         /* rs */
+               const char *minvalue;
+               const char *maxvalue;
+               const char *increment = mapi_fetch_field(hdl, 7);       /* inc 
*/
+               const char *cacheinc = mapi_fetch_field(hdl, 8);        /* 
cache */
+               const char *cycle = mapi_fetch_field(hdl, 9);           /* 
cycle */
 
+               if (mapi_get_field_count(hdl) > 10) {
+                       /* new version (Jan2022) of sys.describe_sequences */
+                       minvalue = mapi_fetch_field(hdl, 12);                   
/* rmi */
+                       maxvalue = mapi_fetch_field(hdl, 13);                   
/* rma */
+               } else {
+                       /* old version (pre Jan2022) of sys.describe_sequences 
*/
+                       minvalue = mapi_fetch_field(hdl, 5);                    
/* minvalue */
+                       maxvalue = mapi_fetch_field(hdl, 6);                    
/* maxvalue */
+                       if (strcmp(minvalue, "0") == 0)
+                               minvalue = NULL;
+                       if (strcmp(maxvalue, "0") == 0)
+                               maxvalue = NULL;
+               }
                mnstr_printf(toConsole, "CREATE SEQUENCE ");
                dquoted_print(toConsole, schema, ".");
                dquoted_print(toConsole, name, NULL);
-               mnstr_printf(toConsole, " START WITH %s", start);
+               mnstr_printf(toConsole, " START WITH %s", restart);
                if (strcmp(increment, "1") != 0)
                        mnstr_printf(toConsole, " INCREMENT BY %s", increment);
-               if (strcmp(minvalue, "0") != 0)
+               if (minvalue)
                        mnstr_printf(toConsole, " MINVALUE %s", minvalue);
-               if (strcmp(maxvalue, "0") != 0)
+               if (maxvalue)
                        mnstr_printf(toConsole, " MAXVALUE %s", maxvalue);
                if (strcmp(cacheinc, "1") != 0)
                        mnstr_printf(toConsole, " CACHE %s", cacheinc);
@@ -2389,16 +2398,7 @@ dump_database(Mapi mid, stream *toConsol
                "WHERE sch.id = seq.schema_id "
                "ORDER BY sch.name, seq.name";
        const char *sequences2 =
-               "SELECT "
-                    "sch, "
-                    "seq, "
-                    "rs, "
-                    "rmi, "
-                    "rma, "
-                    "inc, "
-                    "cycle "
-               "FROM sys.describe_sequences "
-               "ORDER BY sch, seq";
+               "SELECT * FROM sys.describe_sequences ORDER BY sch, seq";
        /* we must dump tables, views, functions/procedures and triggers in 
order of creation since they can refer to each other */
        const char *tables_views_functions_triggers =
                "with vft (sname, name, id, query, remark, type) AS ("
@@ -2862,19 +2862,31 @@ dump_database(Mapi mid, stream *toConsol
                        goto bailout;
 
                while (mapi_fetch_row(hdl) != 0) {
-                       const char *schema = mapi_fetch_field(hdl, 0);
-                       const char *name = mapi_fetch_field(hdl, 1);
-                       const char *restart = mapi_fetch_field(hdl, 2);
-                       const char *minvalue = mapi_fetch_field(hdl, 3);
-                       const char *maxvalue = mapi_fetch_field(hdl, 4);
-                       const char *increment = mapi_fetch_field(hdl, 5);
-                       const char *cycle = mapi_fetch_field(hdl, 6);
+                       const char *schema = mapi_fetch_field(hdl, 0);          
/* sch */
+                       const char *name = mapi_fetch_field(hdl, 1);            
/* seq */
+                       const char *restart = mapi_fetch_field(hdl, 3);         
/* rs */
+                       const char *minvalue;
+                       const char *maxvalue;
+                       const char *increment = mapi_fetch_field(hdl, 6);       
/* inc */
+                       const char *cycle = mapi_fetch_field(hdl, 8);           
/* cycle */
+
+                       if (mapi_get_field_count(hdl) > 9) {
+                               /* new version (Jan2022) of 
sys.describe_sequences */
+                               minvalue = mapi_fetch_field(hdl, 11);           
        /* rmi */
+                               maxvalue = mapi_fetch_field(hdl, 12);           
        /* rma */
+                       } else {
+                               /* old version (pre Jan2022) of 
sys.describe_sequences */
+                               minvalue = mapi_fetch_field(hdl, 4);            
        /* minvalue */
+                               maxvalue = mapi_fetch_field(hdl, 5);            
        /* maxvalue */
+                               if (strcmp(minvalue, "0") == 0)
+                                       minvalue = NULL;
+                               if (strcmp(maxvalue, "0") == 0)
+                                       maxvalue = NULL;
+                       }
 
                        if (sname != NULL && strcmp(schema, sname) != 0)
                                continue;
 
-                       // sleep(7);
-
                        mnstr_printf(toConsole,
                                     "ALTER SEQUENCE ");
                        dquoted_print(toConsole, schema, ".");
diff --git a/cmake/monetdb-defines.cmake b/cmake/monetdb-defines.cmake
--- a/cmake/monetdb-defines.cmake
+++ b/cmake/monetdb-defines.cmake
@@ -303,7 +303,7 @@ macro(monetdb_configure_misc)
   endif()
 
   # Used for installing testing python module (don't pass a location, else we 
need to strip this again)
-  execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" "import 
distutils.sysconfig; print(distutils.sysconfig.get_python_lib(0,0,''))"
+  execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" "import sysconfig; 
print(sysconfig.get_path('purelib', vars={'base': ''})[1:])"
     RESULT_VARIABLE PY3_LIBDIR_CODE
     OUTPUT_VARIABLE PYTHON3_SITEDIR
     OUTPUT_STRIP_TRAILING_WHITESPACE)
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -821,12 +821,19 @@ COLcopy(BAT *b, int tt, bool writable, r
                } else if (BATatoms[tt].atomFix) {
                        /* oops, we need to fix/unfix atoms */
                        slowcopy = true;
-               } else if (bi.h && bi.h->parentid != b->batCacheid) {
-                       /* extra checks needed for views */
-                       if (BATcapacity(BBP_cache(bi.h->parentid)) > bi.count + 
bi.count)
-                               /* reduced slice view: do not copy too
-                                * much garbage */
-                               slowcopy = true;
+               } else if (bi.h && bi.h->parentid != b->batCacheid &&
+                          BATcapacity(BBP_cache(bi.h->parentid)) > bi.count + 
bi.count) {
+                       /* reduced slice view: do not copy too much
+                        * garbage */
+                       slowcopy = true;
+               } else if (bi.vh && bi.vh->parentid != b->batCacheid &&
+                          BATcount(BBP_cache(bi.vh->parentid)) > bi.count + 
bi.count) {
+                       /* reduced vheap view: do not copy too much
+                        * garbage; this really is a heuristic since the
+                        * vheap could be used completely, even if the
+                        * offset heap is only (less than) half the size
+                        * of the parent's offset heap */
+                       slowcopy = true;
                }
 
                bn = COLnew2(b->hseqbase, tt, bi.count, role, bi.width);
diff --git a/sql/backends/monet5/rel_predicates.c 
b/sql/backends/monet5/rel_predicates.c
--- a/sql/backends/monet5/rel_predicates.c
+++ b/sql/backends/monet5/rel_predicates.c
@@ -16,7 +16,7 @@
 static sql_column *
 bt_find_column( sql_rel *rel, char *tname, char *name)
 {
-       if (!rel || !rel->exps || !rel->l)
+       if (!rel || list_empty(rel->exps) || !rel->l)
                return NULL;
        sql_exp *ne = NULL;
        sql_table *t = rel->l;
@@ -43,48 +43,57 @@ rel_find_predicates(visitor *v, sql_rel 
        if (is_basetable(rel->op)) {
                sql_table *t = rel->l;
 
-               if (!t || !rel->exps || isNew(t) || !isGlobal(t) || 
isGlobalTemp(t))
+               if (!t || list_empty(rel->exps) || isNew(t) || !isGlobal(t) || 
isGlobalTemp(t))
                        return rel;
                sql_rel *parent = v->parent;
 
                /* select with basetable */
                if (is_select(parent->op)) {
                        /* add predicates */
-                       for (node *n = parent->exps->h; n && !needall; n = 
n->next) {
-                               sql_exp *e = n->data, *r = e->r, *r2 = e->f;
-                               sql_column *c = NULL;
+                       if (list_empty(parent->exps)) {
+                               needall = true;
+                       } else {
+                               for (node *n = parent->exps->h; n && !needall; 
n = n->next) {
+                                       sql_exp *e = n->data, *r = e->r, *r2 = 
e->f;
+                                       sql_column *c = NULL;
+
+                                       if (!is_compare(e->type) || 
!is_theta_exp(e->flag) || r->type != e_atom || !r->l || (r2 && (r2->type != 
e_atom || !r2->l)) || is_symmetric(e) || !(c = exp_find_column(rel, e->l)))
+                                               needall = true;
+                               }
+                               if (!needall) {
+                                       for (node *n = parent->exps->h; n; n = 
n->next) {
+                                               sql_exp *e = n->data, *r = 
e->r, *r2 = e->f;
+                                               sql_column *c = 
exp_find_column(rel, e->l);
 
-                               if (!is_compare(e->type) || 
!is_theta_exp(e->flag) || r->type != e_atom || !r->l || (r2 && (r2->type != 
e_atom || !r2->l)) || is_symmetric(e) || !(c = exp_find_column(rel, e->l))) {
-                                       needall = true;
-                               } else if (isNew(c)) {
-                                       continue;
-                               } else {
-                                       atom *e1 = r && r->l ? atom_copy(NULL, 
r->l) : NULL, *e2 = r2 && r2->l ? atom_copy(NULL, r2->l) : NULL;
+                                               if (isNew(c))
+                                                       continue;
+                                               atom *e1 = r && r->l ? 
atom_copy(NULL, r->l) : NULL, *e2 = r2 && r2->l ? atom_copy(NULL, r2->l) : NULL;
 
-                                       if ((r && r->l && !e1) || (r2 && r2->l 
&& !e2)) {
-                                               if (e1) {
-                                                       VALclear(&e1->data);
-                                                       _DELETE(e1);
+                                               if ((r && r->l && !e1) || (r2 
&& r2->l && !e2)) {
+                                                       if (e1) {
+                                                               
VALclear(&e1->data);
+                                                               _DELETE(e1);
+                                                       }
+                                                       if (e2) {
+                                                               
VALclear(&e2->data);
+                                                               _DELETE(e2);
+                                                       }
+                                                       return 
sql_error(v->sql, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
                                                }
-                                               if (e2) {
-                                                       VALclear(&e2->data);
-                                                       _DELETE(e2);
+
+                                               if 
(sql_trans_add_predicate(v->sql->session->tr, c, e->flag, e1, e2, is_anti(e), 
is_semantics(e)) != LOG_OK) {
+                                                       if (e1) {
+                                                               
VALclear(&e1->data);
+                                                               _DELETE(e1);
+                                                       }
+                                                       if (e2) {
+                                                               
VALclear(&e2->data);
+                                                               _DELETE(e2);
+                                                       }
+                                                       return 
sql_error(v->sql, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
                                                }
-                                               return sql_error(v->sql, 10, 
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+                                               v->changes++;
                                        }
-
-                                       if 
(sql_trans_add_predicate(v->sql->session->tr, c, e->flag, e1, e2, is_anti(e), 
is_semantics(e)) != LOG_OK) {
-                                               if (e1) {
-                                                       VALclear(&e1->data);
-                                                       _DELETE(e1);
-                                               }
-                                               if (e2) {
-                                                       VALclear(&e2->data);
-                                                       _DELETE(e2);
-                                               }
-                                               return sql_error(v->sql, 10, 
SQLSTATE(HY013) MAL_MALLOC_FAIL);
-                                       }
-                                       v->changes++;
                                }
                        }
                }
@@ -93,7 +102,7 @@ rel_find_predicates(visitor *v, sql_rel 
                        /* any other case, add all predicates */
                        sql_table *t = rel->l;
 
-                       if (!t || !rel->exps || isNew(t) || !isGlobal(t) || 
isGlobalTemp(t))
+                       if (!t || list_empty(rel->exps) || isNew(t) || 
!isGlobal(t) || isGlobalTemp(t))
                                return rel;
                        for (node *n = rel->exps->h; n; n = n->next) {
                                sql_exp *e = n->data;
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
@@ -2774,27 +2774,7 @@ sql_update_jul2021(Client c, mvc *sql, c
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to