Changeset: 0c5128a20442 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0c5128a20442
Modified Files:
        sql/server/sql_parser.y
        sql/storage/bat/bat_storage.c
        sql/storage/objectset.c
        sql/storage/store.c
Branch: iso
Log Message:

Merged with Jul2021


diffs (truncated from 1508 to 300 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -5752,7 +5752,7 @@ stdout of test 'MAL-signatures` in direc
 [ "batcalc",   "timestamp",    "pattern batcalc.timestamp(X_0:bat[:timestamp], 
X_1:bat[:oid], X_2:int):bat[:timestamp] ",      "timestamp_2time_timestamp;",   
""      ]
 [ "batcalc",   "uuid", "command batcalc.uuid(X_0:bat[:str], 
X_1:bat[:oid]):bat[:uuid] ",       "UUIDstr2uuid_bulk;",   ""      ]
 [ "batcalc",   "uuid", "command batcalc.uuid(X_0:bat[:uuid], 
X_1:bat[:oid]):bat[:uuid] ",      "UUIDuuid2uuid_bulk;",  ""      ]
-[ "batcalc",   "wkb",  "command batcalc.wkb(X_0:bat[:wkb], X_1:int, 
X_2:int):bat[:wkb] ",      "geom_2_geom_bat;",     ""      ]
+[ "batcalc",   "wkb",  "command batcalc.wkb(X_0:bat[:wkb], X_1:bat[:oid], 
X_2:int, X_3:int):bat[:wkb] ",       "geom_2_geom_bat;",     ""      ]
 [ "batcalc",   "xml",  "command batcalc.xml(X_0:bat[:str]):bat[:xml] ",        
"BATXMLstr2xml;",       ""      ]
 [ "batcalc",   "xor",  "pattern batcalc.xor(X_0:bat[:bit], 
X_1:bat[:bit]):bat[:bit] ", "CMDbatXOR;",   ""      ]
 [ "batcalc",   "xor",  "pattern batcalc.xor(X_0:bat[:bit], X_1:bat[:bit], 
X_2:bat[:oid], X_3:bat[:oid]):bat[:bit] ",   "CMDbatXOR;",   ""      ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128 
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -8276,7 +8276,7 @@ stdout of test 'MAL-signatures` in direc
 [ "batcalc",   "timestamp",    "pattern batcalc.timestamp(X_0:bat[:timestamp], 
X_1:bat[:oid], X_2:int):bat[:timestamp] ",      "timestamp_2time_timestamp;",   
""      ]
 [ "batcalc",   "uuid", "command batcalc.uuid(X_0:bat[:str], 
X_1:bat[:oid]):bat[:uuid] ",       "UUIDstr2uuid_bulk;",   ""      ]
 [ "batcalc",   "uuid", "command batcalc.uuid(X_0:bat[:uuid], 
X_1:bat[:oid]):bat[:uuid] ",      "UUIDuuid2uuid_bulk;",  ""      ]
-[ "batcalc",   "wkb",  "command batcalc.wkb(X_0:bat[:wkb], X_1:int, 
X_2:int):bat[:wkb] ",      "geom_2_geom_bat;",     ""      ]
+[ "batcalc",   "wkb",  "command batcalc.wkb(X_0:bat[:wkb], X_1:bat[:oid], 
X_2:int, X_3:int):bat[:wkb] ",       "geom_2_geom_bat;",     ""      ]
 [ "batcalc",   "xml",  "command batcalc.xml(X_0:bat[:str]):bat[:xml] ",        
"BATXMLstr2xml;",       ""      ]
 [ "batcalc",   "xor",  "pattern batcalc.xor(X_0:bat[:bit], 
X_1:bat[:bit]):bat[:bit] ", "CMDbatXOR;",   ""      ]
 [ "batcalc",   "xor",  "pattern batcalc.xor(X_0:bat[:bit], X_1:bat[:bit], 
X_2:bat[:oid], X_3:bat[:oid]):bat[:bit] ",   "CMDbatXOR;",   ""      ]
diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -328,7 +328,6 @@ VIEWreset(BAT *b)
                .parentid = b->batCacheid,
                .farmid = BBPselectfarm(b->batRole, b->ttype, offheap),
        };
-       ATOMIC_INIT(&tail->refs, 1);
        settailname(tail, nme, b->ttype, b->twidth);
        if (b->ttype && HEAPalloc(tail, cnt, Tsize(b), Tsize(b)) != 
GDK_SUCCEED) {
                GDKfree(tail);
@@ -348,7 +347,6 @@ VIEWreset(BAT *b)
                        .farmid = BBPselectfarm(b->batRole, b->ttype, varheap),
                        .parentid = b->batCacheid,
                };
-               ATOMIC_INIT(&th->refs, 1);
                strconcat_len(th->filename, sizeof(th->filename),
                              nme, ".theap", NULL);
                if (ATOMheap(b->ttype, th, cnt) != GDK_SUCCEED) {
@@ -358,7 +356,9 @@ VIEWreset(BAT *b)
                        BBPunfix(v->batCacheid);
                        return GDK_FAIL;
                }
+               ATOMIC_INIT(&th->refs, 1);
        }
+       ATOMIC_INIT(&tail->refs, 1);
 
        BAT bak = *b;           /* backup copy */
 
@@ -382,11 +382,9 @@ VIEWreset(BAT *b)
        if (BATappend2(b, v, NULL, false, false) != GDK_SUCCEED) {
                /* clean up the mess */
                if (th) {
-                       HEAPfree(th, true);
-                       GDKfree(th);
+                       HEAPdecref(th, true);
                }
-               HEAPfree(tail, true);
-               GDKfree(tail);
+               HEAPdecref(tail, true);
                *b = bak;
                BBPunfix(v->batCacheid);
                return GDK_FAIL;
diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c
--- a/gdk/gdk_analytic_func.c
+++ b/gdk/gdk_analytic_func.c
@@ -72,11 +72,13 @@ GDKrebuild_segment_tree(oid ncount, oid 
        do {                                                    \
                TPE *restrict rb = (TPE*)Tloc(r, 0);            \
                if (p) {                                                \
-                       for (; i < cnt; i++) {                  \
+                       while (i < cnt) {                       \
                                if (np[i])      {               \
 ntile##IMP##TPE: \
                                        NTILE_CALC(TPE, NEXT_VALUE, LNG_HGE, 
UPCAST, VALIDATION); \
                                } \
+                               if (!last) \
+                                       i++; \
                        }                               \
                }                               \
                if (!last) { \
@@ -1077,11 +1079,13 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p
        do {                                    \
                TPE *restrict bp = (TPE*)Tloc(b, 0), *restrict rb = 
(TPE*)Tloc(r, 0); \
                if (p) {                                        \
-                       for (; i < cnt; i++) {          \
+                       while (i < cnt) {               \
                                if (np[i])      {               \
 minmaxfixed##TPE##IMP: \
                                        
ANALYTICAL_MIN_MAX_CALC_FIXED_##IMP(TPE, MIN_MAX);      \
                                } \
+                               if (!last) \
+                                       i++; \
                        }                                               \
                }               \
                if (!last) { /* hack to reduce code explosion, there's no need 
to duplicate the code to iterate each partition */ \
@@ -1124,11 +1128,13 @@ minmaxfixed##TPE##IMP: \
                        break;                                                  
\
                default: {                                                      
\
                        if (p) {                                                
\
-                               for (; i < cnt; i++) {                  \
-                               if (np[i])      {               \
+                               while (i < cnt) {                       \
+                                       if (np[i])      {               \
 minmaxvarsized##IMP: \
-                                       
ANALYTICAL_MIN_MAX_CALC_OTHERS_##IMP(GT_LT);    \
-                               } \
+                                               
ANALYTICAL_MIN_MAX_CALC_OTHERS_##IMP(GT_LT);    \
+                                       } \
+                                       if (!last) \
+                                               i++; \
                                }                                               
\
                        }                                       \
                        if (!last) { \
@@ -1420,11 +1426,13 @@ ANALYTICAL_MIN_MAX(max, MAX, <)
        do {                                    \
                TPE *restrict bp = (TPE*) bheap; \
                if (p) {                                        \
-                       for (; i < cnt; i++) {          \
+                       while (i < cnt) {               \
                                if (np[i])      {               \
 count##TPE##IMP: \
                                        ANALYTICAL_COUNT_FIXED_##IMP(TPE); \
                                } \
+                               if (!last) \
+                                       i++; \
                        }                                               \
                }       \
                if (!last) { \
@@ -1467,12 +1475,14 @@ count##TPE##IMP: \
                        break;                                                  
\
                default: {                                                      
\
                        if (p) {                                                
\
-                               for (; i < cnt; i++) {                  \
+                               while (i < cnt) {                       \
                                        if (np[i])      {               \
 countothers##IMP: \
                                                ANALYTICAL_COUNT_OTHERS_##IMP;  
\
                                        } \
-                               }                                               
\
+                                       if (!last) \
+                                               i++; \
+                               }                       \
                        }       \
                        if (!last) { \
                                last = true; \
@@ -1667,11 +1677,13 @@ cleanup:
                TPE1 *restrict bp = (TPE1*)Tloc(b, 0);   \
                TPE2 *restrict rb = (TPE2*)Tloc(r, 0); \
                if (p) {                                        \
-                       for (; i < cnt; i++) {          \
+                       while (i < cnt) {               \
                                if (np[i])      {               \
 sum##TPE1##TPE2##IMP: \
                                        IMP(TPE1, TPE2);        \
                                } \
+                               if (!last) \
+                                       i++; \
                        }       \
                }       \
                if (!last) { \
@@ -2157,11 +2169,13 @@ nosupport:
                TPE1 *restrict bp = (TPE1*)Tloc(b, 0);   \
                TPE2 *restrict rb = (TPE2*)Tloc(r, 0); \
                if (p) {                                        \
-                       for (; i < cnt; i++) {          \
+                       while (i < cnt) {               \
                                if (np[i])      {               \
 prod##TPE1##TPE2##IMP: \
                                        IMP(TPE1, TPE2, TPE3_OR_REAL_IMP);      
\
                                } \
+                               if (!last) \
+                                       i++; \
                        }                                               \
                }       \
                if (!last) { \
@@ -2643,12 +2657,14 @@ avg_fp_deltas(dbl)
        do {                                            \
                TPE *restrict bp = (TPE*)Tloc(b, 0); \
                if (p) {                                        \
-                       for (; i < cnt; i++) {          \
+                       while (i < cnt) {               \
                                if (np[i])      {               \
 avg##TPE##IMP: \
                                        REAL_IMP(TPE, IMP);     \
                                } \
-                       }                                               \
+                               if (!last) \
+                                       i++; \
+                       }                               \
                }       \
                if (!last) { \
                        last = true; \
@@ -2899,11 +2915,13 @@ avg_int_deltas(lng)
        do {                                            \
                TPE *restrict bp = (TPE*)Tloc(b, 0), *restrict rb = (TPE *) 
Tloc(r, 0); \
                if (p) {                                        \
-                       for (; i < cnt; i++) {          \
+                       while (i < cnt) {               \
                                if (np[i])      {               \
 avg##TPE##IMP: \
                                        IMP(TPE); \
                                } \
+                               if (!last) \
+                                       i++; \
                        }                                               \
                }       \
                if (!last) { \
@@ -3142,12 +3160,14 @@ typedef struct stdev_var_deltas {
 #define ANALYTICAL_STATISTICS_PARTITIONS(TPE, SAMPLE, OP, IMP)         \
        do {                                            \
                if (p) {                                        \
-                       for (; i < cnt; i++) {          \
+                       while (i < cnt) {               \
                                if (np[i])      {               \
 statistics##TPE##IMP: \
                                        IMP(TPE, SAMPLE, OP);   \
                                } \
-                       }                                               \
+                               if (!last) \
+                                       i++; \
+                       }                       \
                }       \
                if (!last) { \
                        last = true; \
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -115,7 +115,6 @@ BATcreatedesc(oid hseq, int tt, bool hea
 
        if (heapnames) {
                assert(bn->theap != NULL);
-               ATOMIC_INIT(&bn->theap->refs, 1);
                bn->theap->parentid = bn->batCacheid;
                bn->theap->farmid = BBPselectfarm(role, bn->ttype, offheap);
 
@@ -135,6 +134,7 @@ BATcreatedesc(oid hseq, int tt, bool hea
                                      sizeof(bn->tvheap->filename),
                                      nme, ".theap", NULL);
                }
+               ATOMIC_INIT(&bn->theap->refs, 1);
        } else {
                assert(bn->theap == NULL);
        }
@@ -2366,7 +2366,6 @@ void
 BATassertProps(BAT *b)
 {
        unsigned bbpstatus;
-       BATiter bi = bat_iterator(b);
        BUN p, q;
        int (*cmpf)(const void *, const void *);
        int cmp;
@@ -2387,7 +2386,6 @@ BATassertProps(BAT *b)
               ((bbpstatus & BBPEXISTING) != 0) +
               ((bbpstatus & BBPNEW) != 0) <= 1);
 
-       assert(b != NULL);
        assert(b->ttype >= TYPE_void);
        assert(b->ttype < GDKatomcnt);
        assert(b->ttype != TYPE_bat);
@@ -2468,6 +2466,13 @@ BATassertProps(BAT *b)
                }
                return;
        }
+       /* do the rest on a view in case some other thread changes b */
+       BAT *v = VIEWcreate(b->hseqbase, b);
+       if (v == NULL)
+               return;
+       b = v;
+       BATiter bi = bat_iterator(b);
+
        if (BATtdense(b)) {
                assert(b->tseqbase + b->batCount <= GDK_oid_max);
                assert(b->ttype == TYPE_oid);
@@ -2480,6 +2485,7 @@ BATassertProps(BAT *b)
                        for (p = 1; p < q; p++)
                                assert(o[p - 1] + 1 == o[p]);
                }
+               BBPunfix(b->batCacheid);
                return;
        }
        assert(1 << b->tshift == b->twidth);
@@ -2524,6 +2530,7 @@ BATassertProps(BAT *b)
        if (!b->tkey && !b->tsorted && !b->trevsorted &&
            !b->tnonil && !b->tnil) {
                /* nothing more to prove */
+               BBPunfix(b->batCacheid);
                return;
        }
 
@@ -2682,4 +2689,5 @@ BATassertProps(BAT *b)
                assert(minval == NULL || seenmin);
                assert(!b->tnil || seennil);
        }
+       BBPunfix(b->batCacheid);
 }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to