Changeset: 18eda0b8321b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/18eda0b8321b
Modified Files:
        gdk/gdk_logger.c
        sql/backends/monet5/sql_upgrades.c
Branch: insertonly
Log Message:

merged default


diffs (truncated from 1222 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -812,3 +812,4 @@ 573511e0e7bf2f7ab11f00b45711aab5f1aff6f2
 ce63ebe9a78c52ef0cbe8fd6f2159d2637f0387c Jun2023_7
 1efa83c6409769d13b2ee30e497d5f7ab42fa955 Jun2023_9
 6f88424ebfd9d82c072cf21d89070e04321983da Jun2023_11
+6f88424ebfd9d82c072cf21d89070e04321983da Jun2023_SP2_release
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1484,6 +1484,8 @@ BBPtrim(bool aggressive)
        if (!aggressive)
                flag |= BBPHOT;
        for (bat bid = 1, nbat = (bat) ATOMIC_GET(&BBPsize); bid < nbat; bid++) 
{
+               if (GDKexiting())
+                       return changed;
                /* don't do this during a (sub)commit */
                BBPtmlock();
                MT_lock_set(&GDKswapLock(bid));
diff --git a/gdk/gdk_tm.c b/gdk/gdk_tm.c
--- a/gdk/gdk_tm.c
+++ b/gdk/gdk_tm.c
@@ -61,6 +61,10 @@ epilogue(int cnt, bat *subcommit, bool l
                BAT *b;
 
                if (BBP_status(bid) & BBPPERSISTENT) {
+                       /* first turn off BBPNEW, then turn on
+                        * BBPEXISTING so that concurrent BATassertProps
+                        * doesn't fail */
+                       BBP_status_off(bid, BBPNEW);
                        BBP_status_on(bid, BBPEXISTING);
                } else if (BBP_status(bid) & BBPDELETED) {
                        /* check mmap modes of bats that are now
diff --git a/monetdb5/modules/atoms/Tests/json01.maltest 
b/monetdb5/modules/atoms/Tests/json01.maltest
--- a/monetdb5/modules/atoms/Tests/json01.maltest
+++ b/monetdb5/modules/atoms/Tests/json01.maltest
@@ -56,7 +56,7 @@ f:= json.filter(b,"f1[1]")
 query T rowsort
 io.print(f)
 ----
-"3"
+"[]"
 
 statement ok
 f:= json.filter(b,"f1[2]")
@@ -72,7 +72,7 @@ f:= json.filter(b,"*")
 query T rowsort
 io.print(f)
 ----
-"[1,2,3]"
+"[3,2]"
 
 statement ok
 b:= json.new("{\"f1\":{\"f12\":3},\"f2\":[2,3,4]}")
diff --git a/monetdb5/modules/atoms/Tests/json02.maltest 
b/monetdb5/modules/atoms/Tests/json02.maltest
--- a/monetdb5/modules/atoms/Tests/json02.maltest
+++ b/monetdb5/modules/atoms/Tests/json02.maltest
@@ -57,8 +57,6 @@ 0
 f1
 1
 f2
-2
-f1
 
 statement ok
 ff:= json.values(b)
@@ -67,11 +65,9 @@ query IT rowsort
 io.print(ff)
 ----
 0
-1
+3
 1
 2
-2
-3
 
 statement ok
 b:= json.new("{\"f1\":{\"f12\":3},\"f2\":[2,3,4]}")
diff --git a/monetdb5/modules/atoms/Tests/json05.maltest 
b/monetdb5/modules/atoms/Tests/json05.maltest
--- a/monetdb5/modules/atoms/Tests/json05.maltest
+++ b/monetdb5/modules/atoms/Tests/json05.maltest
@@ -28,7 +28,7 @@ p:= json.filter(js,"..author")
 query T rowsort
 io.print(p)
 ----
-"[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]"
+"[\"J. R. R. Tolkien\"]"
 
 statement ok
 p:= json.filter(js,"..category")
@@ -36,7 +36,7 @@ p:= json.filter(js,"..category")
 query T rowsort
 io.print(p)
 ----
-"[\"reference\",\"fiction\",\"fiction\",\"fiction\"]"
+"[\"fiction\"]"
 
 statement ok
 p:= json.filter(js,"[0].book[0]")
@@ -44,7 +44,7 @@ p:= json.filter(js,"[0].book[0]")
 query T rowsort
 io.print(p)
 ----
-"{ \"category\": \"reference\", \"author\": \"Nigel Rees\", \"title\": 
\"Sayings of the Century\", \"price\": 8.95 }"
+"{ \"category\": \"fiction\", \"author\": \"J. R. R. Tolkien\", \"title\": 
\"The Lord of the Rings\", \"isbn\": \"0-395-19395-8\", \"price\": 22.99 }"
 
 statement ok
 p:= json.filter(js,"[0].book[1]")
@@ -52,7 +52,7 @@ p:= json.filter(js,"[0].book[1]")
 query T rowsort
 io.print(p)
 ----
-"{ \"category\": \"fiction\", \"author\": \"Evelyn Waugh\", \"title\": \"Sword 
of Honour\", \"price\": 12.99 }"
+"[]"
 
 statement ok
 p:= json.filter(js,"[0].book[2]")
@@ -60,7 +60,7 @@ p:= json.filter(js,"[0].book[2]")
 query T rowsort
 io.print(p)
 ----
-"{ \"category\": \"fiction\", \"author\": \"Herman Melville\", \"title\": 
\"Moby Dick\", \"isbn\": \"0-553-21311-3\", \"price\": 8.99 }"
+"[]"
 
 statement ok
 p:= json.filter(js,"[0].book[3]")
@@ -68,7 +68,7 @@ p:= json.filter(js,"[0].book[3]")
 query T rowsort
 io.print(p)
 ----
-"{ \"category\": \"fiction\", \"author\": \"J. R. R. Tolkien\", \"title\": 
\"The Lord of the Rings\", \"isbn\": \"0-395-19395-8\", \"price\": 22.99 }"
+"[]"
 
 statement ok
 p:= json.filter(js,"[0].book..category")
diff --git a/monetdb5/modules/atoms/Tests/json08.maltest 
b/monetdb5/modules/atoms/Tests/json08.maltest
--- a/monetdb5/modules/atoms/Tests/json08.maltest
+++ b/monetdb5/modules/atoms/Tests/json08.maltest
@@ -78,7 +78,7 @@ 1
 2
 1
 3
-1
+3
 4
 {"f12":3}
 
diff --git a/monetdb5/modules/atoms/Tests/json10.maltest 
b/monetdb5/modules/atoms/Tests/json10.maltest
--- a/monetdb5/modules/atoms/Tests/json10.maltest
+++ b/monetdb5/modules/atoms/Tests/json10.maltest
@@ -51,7 +51,7 @@ f:= json.text(b)
 query T rowsort
 io.print(f)
 ----
-"1 world 3"
+"3 world"
 
 statement ok
 b:= json.new("{\"f1\":{\"f12\":3},\"f2\":[2,3,4], \"f3\":true}")
diff --git a/monetdb5/modules/atoms/Tests/json11.maltest 
b/monetdb5/modules/atoms/Tests/json11.maltest
--- a/monetdb5/modules/atoms/Tests/json11.maltest
+++ b/monetdb5/modules/atoms/Tests/json11.maltest
@@ -51,7 +51,7 @@ f:= json.text(b,",")
 query T rowsort
 io.print(f)
 ----
-"1,2,3"
+"3,2"
 
 statement ok
 b:= json.new("{\"f1\":{\"f12\":3},\"f2\":[2,3,4], \"f3\":true}")
diff --git a/monetdb5/modules/atoms/Tests/json13.maltest 
b/monetdb5/modules/atoms/Tests/json13.maltest
--- a/monetdb5/modules/atoms/Tests/json13.maltest
+++ b/monetdb5/modules/atoms/Tests/json13.maltest
@@ -53,7 +53,7 @@ p:= json.filter(js,".store.*")
 query T rowsort
 io.print(p)
 ----
-"[{ \"category\": \"reference\", \"author\": \"Nigel Rees\", \"title\": 
\"Sayings of the Century\", \"price\": 8.95 }, { \"category\": \"fiction\", 
\"author\": \"Evelyn Waugh\", \"title\": \"Sword of Honour\", \"price\": 12.99 
}, { \"category\": \"fiction\", \"author\": \"Herman Melville\", \"title\": 
\"Moby Dick\", \"isbn\": \"0-553-21311-3\", \"price\": 8.99 }, { \"category\": 
\"fiction\", \"author\": \"J. R. R. Tolkien\", \"title\": \"The Lord of the 
Rings\", \"isbn\": \"0-395-19395-8\", \"price\": 22.99 },{ \"color\": \"red\", 
\"price\": 19.95 }]"
+"[[ { \"category\": \"reference\", \"author\": \"Nigel Rees\", \"title\": 
\"Sayings of the Century\", \"price\": 8.95 }, { \"category\": \"fiction\", 
\"author\": \"Evelyn Waugh\", \"title\": \"Sword of Honour\", \"price\": 12.99 
}, { \"category\": \"fiction\", \"author\": \"Herman Melville\", \"title\": 
\"Moby Dick\", \"isbn\": \"0-553-21311-3\", \"price\": 8.99 }, { \"category\": 
\"fiction\", \"author\": \"J. R. R. Tolkien\", \"title\": \"The Lord of the 
Rings\", \"isbn\": \"0-395-19395-8\", \"price\": 22.99 } ],{ \"color\": 
\"red\", \"price\": 19.95 }]"
 
 statement ok
 p:= json.filter(js,".store..price")
@@ -93,5 +93,5 @@ p:= json.filter(js,"$")
 query T rowsort
 io.print(p)
 ----
-"[{ \"store\": { \"book\": [ { \"category\": \"reference\", \"author\": 
\"Nigel Rees\", \"title\": \"Sayings of the Century\", \"price\": 8.95 }, { 
\"category\": \"fiction\", \"author\": \"Evelyn Waugh\", \"title\": \"Sword of 
Honour\", \"price\": 12.99 }, { \"category\": \"fiction\", \"author\": \"Herman 
Melville\", \"title\": \"Moby Dick\", \"isbn\": \"0-553-21311-3\", \"price\": 
8.99 }, { \"category\": \"fiction\", \"author\": \"J. R. R. Tolkien\", 
\"title\": \"The Lord of the Rings\", \"isbn\": \"0-395-19395-8\", \"price\": 
22.99 } ], \"bicycle\": { \"color\": \"red\", \"price\": 19.95 } } }]"
+"{ \"store\": { \"book\": [ { \"category\": \"reference\", \"author\": \"Nigel 
Rees\", \"title\": \"Sayings of the Century\", \"price\": 8.95 }, { 
\"category\": \"fiction\", \"author\": \"Evelyn Waugh\", \"title\": \"Sword of 
Honour\", \"price\": 12.99 }, { \"category\": \"fiction\", \"author\": \"Herman 
Melville\", \"title\": \"Moby Dick\", \"isbn\": \"0-553-21311-3\", \"price\": 
8.99 }, { \"category\": \"fiction\", \"author\": \"J. R. R. Tolkien\", 
\"title\": \"The Lord of the Rings\", \"isbn\": \"0-395-19395-8\", \"price\": 
22.99 } ], \"bicycle\": { \"color\": \"red\", \"price\": 19.95 } } }"
 
diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c
--- a/monetdb5/modules/atoms/json.c
+++ b/monetdb5/modules/atoms/json.c
@@ -637,6 +637,7 @@ JSONgetValue(JSON *jt, int idx)
        return s;
 }
 
+/* eats res and r */
 static str
 JSONglue(str res, str r, char sep)
 {
@@ -743,8 +744,9 @@ JSONmatch(JSON *jt, int ji, pattern *ter
                                                r = JSONgetValue(jt, 
jt->elm[i].child);
                                                if (r == NULL)
                                                        r = (str) -1;
-                                       } else
+                                       } else {
                                                r = JSONmatch(jt, 
jt->elm[i].child, terms, ti + 1, terms[ti].index == INT_MAX);
+                                       }
                                        if (r == (str) -1 || r == (str) -2) {
                                                GDKfree(res);
                                                return r;
@@ -754,7 +756,7 @@ JSONmatch(JSON *jt, int ji, pattern *ter
                                        } else {  // Keep the last matching 
value
                                                if (res)
                                                        GDKfree(res);
-                                               res = GDKstrdup(r);
+                                               res = r;
                                        }
                                }
                                cnt++;
@@ -845,9 +847,9 @@ JSONfilterInternal(json *ret, json *js, 
                // pattern contains the .. operator
                if (terms[i].token == ANY_STEP ||
                        // pattern contains the [*] operator
-                       (terms[i].token == CHILD_STEP && terms[i].index == 
INT_MAX && terms[i].name == NULL)) {
+                       (terms[i].token == CHILD_STEP && terms[i].index == 
INT_MAX && terms[i].name == NULL) ||
+                       (terms[i].token == CHILD_STEP && terms[i].index == 
INT_MAX && *terms[i].name == '*')) {
 
-               /* if (terms[i].make_array) { */
                        return_array = true;
                        break;
                }
@@ -1058,6 +1060,7 @@ JSONtoken(JSON *jt, const char *j, const
        str msg;
        int nxt, idx = JSONnew(jt);
        const char *string_start = j;
+       int pidx;
 
        if (jt->error)
                return idx;
@@ -1095,12 +1098,36 @@ JSONtoken(JSON *jt, const char *j, const
                        int chld = JSONtoken(jt, j, next);
                        if (jt->error)
                                return idx;
-                       jt->elm[nxt].child = chld;
-                       jt->elm[nxt].value++;
-                       jt->elm[nxt].valuelen -= 2;
-                       JSONappend(jt, idx, nxt);
-                       if (jt->error)
-                               return idx;
+
+                       /* Search for a duplicate key */
+                       for(pidx = jt->elm[idx].next; pidx != 0; pidx = 
jt->elm[pidx].next) {
+                               if (jt->elm[pidx].kind == JSON_ELEMENT &&
+                                       jt->elm[pidx].valuelen == 
jt->elm[nxt].valuelen - 2 &&
+                                       strncmp(jt->elm[pidx].value, 
jt->elm[nxt].value + 1,
+                                                       jt->elm[nxt].valuelen) 
== 0) {
+                                       break;
+                               }
+                       }
+
+                       /* Duplicate found: Change the value of the previous 
key. */
+                       if (pidx > 0) {
+                               jt->elm[pidx].child = chld;
+                               /* Note that we do not call JSONappend here.
+                                *
+                                * Normally we would de-allocate the old child 
value and the new key,
+                                * but since we are using an arena provided by 
JSONnew, we don't need to.
+                                * This might get expensive for big objects 
with lagre values for
+                                * repeated keys.
+                                */
+
+                       } else {
+                               jt->elm[nxt].child = chld;
+                               jt->elm[nxt].value++;
+                               jt->elm[nxt].valuelen -= 2;
+                               JSONappend(jt, idx, nxt);
+                               if (jt->error)
+                                       return idx;
+                       }
                        j = *next;
                        skipblancs(j);
                        if (*j == '}')
diff --git a/monetdb5/optimizer/opt_evaluate.c 
b/monetdb5/optimizer/opt_evaluate.c
--- a/monetdb5/optimizer/opt_evaluate.c
+++ b/monetdb5/optimizer/opt_evaluate.c
@@ -138,12 +138,12 @@ OPTevaluateImplementation(Client cntxt, 
 
        assigned = (int *) GDKzalloc(sizeof(int) * mb->vtop);
        if (assigned == NULL)
-               throw(MAL, "optimzier.evaluate", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
+               throw(MAL, "optimizer.evaluate", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
 
        alias = (int *) GDKzalloc(mb->vsize * sizeof(int) * 2); /* we introduce 
more */
        if (alias == NULL) {
                GDKfree(assigned);
-               throw(MAL, "optimzier.evaluate", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to