Changeset: 05d4dcc27b5c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/05d4dcc27b5c
Branch: default
Log Message:

merged with jan2022


diffs (truncated from 802 to 300 lines):

diff --git a/gdk/CMakeLists.txt b/gdk/CMakeLists.txt
--- a/gdk/CMakeLists.txt
+++ b/gdk/CMakeLists.txt
@@ -18,6 +18,7 @@ set(gdk_public_headers
   $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/gdk_utils.h>
   $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/gdk_cand.h>
   $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/gdk_calc.h>
+  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/gdk_strimps.h>
   $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/gdk_time.h>
   $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb/gdk.h>
   $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb/gdk_system.h>
@@ -30,6 +31,7 @@ set(gdk_public_headers
   $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb/gdk_utils.h>
   $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb/gdk_calc.h>
   $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb/gdk_cand.h>
+  $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb/gdk_strimps.h>
   $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb/gdk_time.h>)
 
 add_library(bat SHARED)
@@ -81,7 +83,7 @@ target_sources(bat
   gdk_analytic_func.c
   gdk_analytic.h
   gdk_tracer.c gdk_tracer.h
-  gdk_strimps.c gdk_strimps.h
+  gdk_strimps.c
   PUBLIC
   ${gdk_public_headers})
 
diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -1868,10 +1868,9 @@ PCRElikeselect(bat *ret, const bat *bid,
 {
        BAT *b, *s = NULL, *bn = NULL;
        str msg = MAL_SUCCEED;
-       char *ppat = NULL, buf[64];
-       const char *with_strimps = "";
+       char *ppat = NULL;
        bool use_re = false, use_strcmp = false, empty = false;
-       bool use_strimps = !GDKgetenv_istext("gdk_use_strimps", "no");
+       bool use_strimps = !GDKgetenv_istext("gdk_use_strimps", "no"), 
with_strimps = false;
 
        if ((b = BATdescriptor(*bid)) == NULL) {
                msg = createException(MAL, "algebra.likeselect", 
SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
@@ -1900,15 +1899,16 @@ PCRElikeselect(bat *ret, const bat *bid,
                        if (s)
                                BBPunfix(s->batCacheid);
                        s = tmp_s;
-                       with_strimps = " with strimps";
+                       with_strimps = true;
                } else { /* If we cannot create the strimp just continue 
normally */
                        GDKclrerr();
                }
        }
 
-       snprintf(buf, sizeof(buf), "%s%s", empty ? "pcrelike: trivially empty" 
: use_strcmp ? "pcrelike: pattern matching using strcmp" :
-                        use_re ? "pcrelike: pattern matching using RE" : 
"pcrelike: pattern matching using pcre", with_strimps);
-       MT_thread_setalgorithm(buf);
+       MT_thread_setalgorithm(empty ? "pcrelike: trivially empty" :
+               use_strcmp ? (with_strimps ? "pcrelike: pattern matching using 
strcmp with strimps" : "pcrelike: pattern matching using strcmp") :
+               use_re ? (with_strimps ? "pcrelike: pattern matching using RE 
with strimps" : "pcrelike: pattern matching using RE") :
+               (with_strimps ? "pcrelike: pattern matching using pcre with 
strimps" : "pcrelike: pattern matching using pcre"));
 
        if (empty) {
                if (!(bn = BATdense(0, 0, 0)))
diff --git a/monetdb5/optimizer/opt_for.c b/monetdb5/optimizer/opt_for.c
--- a/monetdb5/optimizer/opt_for.c
+++ b/monetdb5/optimizer/opt_for.c
@@ -117,7 +117,7 @@ OPTforImplementation(Client cntxt, MalBl
                                        freeInstruction(p);
                                        done = 1;
                                        break;
-                               } else if (isSelect(p)) {
+                               //} else if (isSelect(p)) {
                                } else// if (isSelect(p)) {
                                        if (getFunctionId(p) == thetaselectRef) 
{
                                                /* pos = thetaselect(col, cand, 
l, ...) with col = for.decompress(o, minval)
diff --git a/monetdb5/optimizer/opt_strimps.c b/monetdb5/optimizer/opt_strimps.c
--- a/monetdb5/optimizer/opt_strimps.c
+++ b/monetdb5/optimizer/opt_strimps.c
@@ -27,8 +27,6 @@ OPTstrimpsImplementation(Client cntxt, M
        bool needed = false;
        // int mvcvar = -1;
        InstrPtr p, q, *old = mb->stmt;
-       char buf[256];
-       lng usec = GDKusec();
        str msg = MAL_SUCCEED;
        int res;
 
@@ -94,20 +92,17 @@ OPTstrimpsImplementation(Client cntxt, M
                        freeInstruction(old[i]);
        GDKfree(old);
 
-    /* Defense line against incorrect plans */
-    if (actions){
-        msg = chkTypes(cntxt->usermodule, mb, FALSE);
-       if (!msg)
-               msg = chkFlow(mb);
-       if (!msg)
-               msg = chkDeclarations(mb);
-    }
-    /* keep all actions taken as a post block comment */
+       /* Defense line against incorrect plans */
+       if (actions){
+               msg = chkTypes(cntxt->usermodule, mb, FALSE);
+               if (!msg)
+                       msg = chkFlow(mb);
+               if (!msg)
+                       msg = chkDeclarations(mb);
+       }
+       /* keep all actions taken as a post block comment */
 bailout:
-       usec = GDKusec()- usec;
-       snprintf(buf,256,"%-20s actions=%2d time=" LLFMT " 
usec","strimps",actions,usec);
-       newComment(mb,buf);
-       if( actions > 0)
-               addtoMalBlkHistory(mb);
+       /* keep actions taken as a fake argument*/
+       (void) pushInt(mb, pci, actions);
        return msg;
 }
diff --git a/sql/server/rel_rel.c b/sql/server/rel_rel.c
--- a/sql/server/rel_rel.c
+++ b/sql/server/rel_rel.c
@@ -179,7 +179,8 @@ rel_copy(mvc *sql, sql_rel *i, int deep)
                rel_base_copy(sql, i, rel);
                break;
        case op_table:
-               rel->l = i->l;
+               if ((IS_TABLE_PROD_FUNC(i->flag) || i->flag == 
TABLE_FROM_RELATION) && i->l)
+                       rel->l = rel_copy(sql, i->l, deep);
                rel->r = i->r;
                break;
        case op_project:
@@ -195,7 +196,7 @@ rel_copy(mvc *sql, sql_rel *i, int deep)
                }
                break;
        case op_ddl:
-               if (rel->flag == ddl_output || rel->flag == ddl_create_seq || 
rel->flag == ddl_alter_seq || rel->flag == ddl_alter_table || rel->flag == 
ddl_create_table || rel->flag == ddl_create_view) {
+               if (i->flag == ddl_output || i->flag == ddl_create_seq || 
i->flag == ddl_alter_seq || i->flag == ddl_alter_table || i->flag == 
ddl_create_table || i->flag == ddl_create_view) {
                        if (i->l)
                                rel->l = rel_copy(sql, i->l, deep);
                } else if (rel->flag == ddl_list || rel->flag == ddl_exception) 
{
@@ -212,10 +213,6 @@ rel_copy(mvc *sql, sql_rel *i, int deep)
                if (i->l)
                        rel->l = rel_copy(sql, i->l, deep);
                break;
-       case op_insert:
-       case op_update:
-       case op_delete:
-
        case op_join:
        case op_left:
        case op_right:
@@ -226,6 +223,10 @@ rel_copy(mvc *sql, sql_rel *i, int deep)
        case op_union:
        case op_inter:
        case op_except:
+
+       case op_insert:
+       case op_update:
+       case op_delete:
        case op_merge:
                if (i->l)
                        rel->l = rel_copy(sql, i->l, deep);
diff --git a/sql/server/rel_sequence.c b/sql/server/rel_sequence.c
--- a/sql/server/rel_sequence.c
+++ b/sql/server/rel_sequence.c
@@ -77,12 +77,16 @@ rel_create_seq(
        sql_subtype *tpe,
        lng start,
        lng inc,
-       lng min,
-       lng max,
+       symbol* s_min,
+       symbol* s_max,
        lng cache,
        bit cycle,
        bit bedropped)
 {
+       bit nomin = s_min && s_min ->type == type_int ? 1: 0;
+       bit nomax = s_max && s_max ->type == type_int ? 1: 0;
+       lng min = s_min ? s_min->data.l_val : lng_nil;
+       lng max = s_max ? s_max->data.l_val : lng_nil;
        sql_rel *res = NULL;
        sql_sequence *seq = NULL;
        char *sname = qname_schema(qname);
@@ -102,11 +106,13 @@ rel_create_seq(
 
        /* generate defaults */
        if (is_lng_nil(inc)) inc = 1;
-       if (is_lng_nil(start)) start = !is_lng_nil(min) ? min : inc > 0 ? 1 : 
-1; /* if start value not set, set it to the minimum if available */
+       if (nomin) min = GDK_lng_min;
+       if (nomax) max = GDK_lng_max;
        if (is_lng_nil(min)) min = inc > 0 ? 0 : GDK_lng_min;
        if (is_lng_nil(max)) max = inc > 0 ? GDK_lng_max : 0;
+       if (is_lng_nil(start)) {if (inc > 0) start = nomin ? 1 : min ? min : 1; 
else if (inc < 0) start = nomax ? -1 : max ? max : -1;}
        if (is_lng_nil(cache)) cache = 1;
-       if (is_bit_nil(cycle)) cycle = 1;
+       if (is_bit_nil(cycle)) cycle = 0;
 
        if (inc == 0)
                return sql_error(sql, 02, SQLSTATE(42000) "CREATE SEQUENCE: 
INCREMENT cannot be 0");
@@ -151,7 +157,8 @@ list_create_seq(
 {
        dnode *n;
        sql_subtype *t = NULL;
-       lng start = lng_nil, inc = lng_nil, min = lng_nil, max = lng_nil, cache 
= lng_nil;
+       lng start = lng_nil, inc = lng_nil, cache = lng_nil;
+       symbol* min = NULL,* max = NULL;
        unsigned int used = 0;
        bit cycle = 0;
 
@@ -199,17 +206,25 @@ list_create_seq(
                                if ((used&(1<<SEQ_MIN)))
                                        return sql_error(sql, 02, 
SQLSTATE(3F000) "CREATE SEQUENCE: MINVALUE or NO MINVALUE should be passed as 
most once");
                                used |= (1<<SEQ_MIN);
-                               if (is_lng_nil(s->data.l_val))
-                                       return sql_error(sql, 02, 
SQLSTATE(42000) "CREATE SEQUENCE: MINVALUE must not be null");
-                               min = s->data.l_val;
+                               if (s->type == type_lng) {
+                                        if (is_lng_nil(s->data.l_val))
+                                               return sql_error(sql, 02, 
SQLSTATE(42000) "CREATE SEQUENCE: MINVALUE must not be null");
+                               }
+                               assert(s->type == type_lng || (s->type == 
type_int && is_int_nil(s->data.i_val)));
+                               // int_nil signals NO MINVALUE
+                               min = s;
                                break;
                        case SQL_MAXVALUE:
                                if ((used&(1<<SEQ_MAX)))
                                        return sql_error(sql, 02, 
SQLSTATE(3F000) "CREATE SEQUENCE: MAXVALUE or NO MAXVALUE should be passed as 
most once");
                                used |= (1<<SEQ_MAX);
-                               if (is_lng_nil(s->data.l_val))
-                                       return sql_error(sql, 02, 
SQLSTATE(42000) "CREATE SEQUENCE: MAXVALUE must be non-NULL");
-                               max = s->data.l_val;
+                               if (s->type == type_lng) {
+                                        if (is_lng_nil(s->data.l_val))
+                                               return sql_error(sql, 02, 
SQLSTATE(42000) "CREATE SEQUENCE: MAXVALUE must not be null");
+                               }
+                               assert(s->type == type_lng || (s->type == 
type_int && is_int_nil(s->data.i_val)));
+                               // int_nil signals NO MAXVALUE
+                               max = s;
                                break;
                        case SQL_CYCLE:
                                if ((used&(1<<SEQ_CYCLE)))
@@ -240,11 +255,15 @@ rel_alter_seq(
                sql_subtype *tpe,
                dlist* start_list,
                lng inc,
-               lng min,
-               lng max,
+               symbol* s_min,
+               symbol* s_max,
                lng cache,
                bit cycle)
 {
+       bit nomin = s_min && s_min ->type == type_int ? 1: 0;
+       bit nomax = s_max && s_max ->type == type_int ? 1: 0;
+       lng min = s_min ? s_min->data.l_val : lng_nil;
+       lng max = s_max ? s_max->data.l_val : lng_nil;
        mvc *sql = query->sql;
        char *sname = qname_schema(qname);
        char *name = qname_schema_object(qname);
@@ -263,6 +282,8 @@ rel_alter_seq(
 
        /* if not being modified, use existing values */
        if (is_lng_nil(inc)) inc = seq->increment;
+       if (nomin) min = GDK_lng_min;
+       if (nomax) max = GDK_lng_max;
        if (is_lng_nil(min)) min = seq->minvalue;
        if (is_lng_nil(max)) max = seq->maxvalue;
        if (is_lng_nil(cache)) cache = seq->cacheinc;
@@ -316,7 +337,8 @@ list_alter_seq(
        mvc *sql = query->sql;
        dnode *n;
        sql_subtype* t = NULL;
-       lng inc = lng_nil, min = lng_nil, max = lng_nil, cache = lng_nil;
+       lng inc = lng_nil, cache = lng_nil;
+       symbol* min = NULL,* max = NULL;
        dlist *start = NULL;
        unsigned int used = 0;
        bit cycle = 0;
@@ -352,17 +374,25 @@ list_alter_seq(
                        if ((used&(1<<SEQ_MIN)))
                                return sql_error(sql, 02, SQLSTATE(3F000) 
"ALTER SEQUENCE: MINVALUE or NO MINVALUE should be passed as most once");
                        used |= (1<<SEQ_MIN);
-                       if (is_lng_nil(s->data.l_val))
-                               return sql_error(sql, 02, SQLSTATE(42000) 
"ALTER SEQUENCE: MINVALUE must be non-NULL");
-                       min = s->data.l_val;
+                       if (s->type == type_lng) {
+                               if (is_lng_nil(s->data.l_val))
+                                       return sql_error(sql, 02, 
SQLSTATE(42000) "ALTER SEQUENCE: MINVALUE must not be null");
+                       }
+                       assert(s->type == type_lng || (s->type == type_int && 
is_int_nil(s->data.i_val)));
+                       min = s;
+                       // int_nil signals NO MINVALUE
                        break;
                case SQL_MAXVALUE:
                        if ((used&(1<<SEQ_MAX)))
                                return sql_error(sql, 02, SQLSTATE(3F000) 
"ALTER SEQUENCE: MAXVALUE or NO MAXVALUE should be passed as most once");
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to