Changeset: c14db874309b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c14db874309b
Branch: check
Log Message:

merge with default


diffs (288 lines):

diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -48,7 +48,12 @@ jobs:
           ref: ${{ github.ref }}
 
       - name: install pymonetdb cryptography
-        run: pip3 install pymonetdb cryptography
+        run: pip3 install --user --upgrade pymonetdb cryptography
+        if: runner.os != 'macOS'
+
+      - name: install pymonetdb cryptography
+        run: pip3 install --user --break-system-packages --upgrade pymonetdb 
cryptography
+        if: runner.os == 'macOS'
 
       - name: make MonetDB on linux
         run: |
@@ -83,7 +88,23 @@ jobs:
             -DBISON_EXECUTABLE=/usr/local/opt/bison/bin/bison \
             -DCMAKE_SUMMARY=ON
           make install -j3
-        if: runner.os == 'macOS'
+        if: runner.os == 'macOS' && runner.arch == 'x64'
+
+      - name: make MonetDB on macos
+        run: |
+          mkdir build
+          cd build 
+          cmake .. \
+            -DCMAKE_INSTALL_PREFIX=$HOME/MDB \
+            -DPY3INTEGRATION=OFF \
+            -DRINTEGRATION=OFF  \
+            -DCMAKE_BUILD_TYPE=Release \
+            -DASSERT=OFF \
+            -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
+            -DBISON_EXECUTABLE=/opt/homebrew/opt/bison/bin/bison \
+            -DCMAKE_SUMMARY=ON
+          make install -j3
+        if: runner.os == 'macOS' && runner.arch == 'arm64'
 
       - name: choco packages
         run: |
diff --git a/clients/odbc/driver/SQLConnect.c b/clients/odbc/driver/SQLConnect.c
--- a/clients/odbc/driver/SQLConnect.c
+++ b/clients/odbc/driver/SQLConnect.c
@@ -251,7 +251,7 @@ MNDBConnect(ODBCDbc *dbc,
        }
        if (mid == NULL || mapi_error(mid)) {
                /* Client unable to establish connection */
-               addDbcError(dbc, "08001", NULL, 0);
+               addDbcError(dbc, "08001", mid ? mapi_error_str(mid) : NULL, 0);
                rc = SQL_ERROR;
                /* clean up */
                if (mid)
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -4065,6 +4065,33 @@ BBPsync(int cnt, bat *restrict subcommit
                        if (lock)
                                MT_lock_set(&GDKswapLock(bid));
                }
+               if (subcommit) {
+                       /* move any tail/theap files we find for this bat that
+                        * are in the BACKUP directory to the SUBCOMMIT
+                        * directory */
+                       char fname[16]; /* plenty big enough */
+                       if (snprintf(fname, sizeof(fname), "%o", i) < 16) {
+                               /* the snprintf never fails, any of the
+                                * below may fail */
+                               if (GDKmove(0, BAKDIR, fname, "tail", SUBDIR, 
fname, "tail", false) == GDK_SUCCEED)
+                                       TRC_DEBUG(BAT_, "moved %s.tail from %s 
to %s\n",
+                                                 fname, BAKDIR, SUBDIR);
+                               if (GDKmove(0, BAKDIR, fname, "tail1", SUBDIR, 
fname, "tail1", false) == GDK_SUCCEED)
+                                       TRC_DEBUG(BAT_, "moved %s.tail1 from %s 
to %s\n",
+                                                 fname, BAKDIR, SUBDIR);
+                               if (GDKmove(0, BAKDIR, fname, "tail2", SUBDIR, 
fname, "tail2", false) == GDK_SUCCEED)
+                                       TRC_DEBUG(BAT_, "moved %s.tail2 from %s 
to %s\n",
+                                                 fname, BAKDIR, SUBDIR);
+#if SIZEOF_VAR_T == 8
+                               if (GDKmove(0, BAKDIR, fname, "tail4", SUBDIR, 
fname, "tail4", false) == GDK_SUCCEED)
+                                       TRC_DEBUG(BAT_, "moved %s.tail4 from %s 
to %s\n",
+                                                 fname, BAKDIR, SUBDIR);
+#endif
+                               if (GDKmove(0, BAKDIR, fname, "theap", SUBDIR, 
fname, "theap", false) == GDK_SUCCEED)
+                                       TRC_DEBUG(BAT_, "moved %s.theap from %s 
to %s\n",
+                                                 fname, BAKDIR, SUBDIR);
+                       }
+               }
                BAT *b = dirty_bat(&i, subcommit != NULL);
                if (i <= 0)
                        ret = GDK_FAIL;
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
@@ -733,6 +733,7 @@ single_replace(pcre *pcre_code, pcre_ext
        int offset = 0;
        int len_result = 0;
        int addlen;
+       int empty_match_correction = 0;
        char *tmp;
 
        do {
@@ -740,7 +741,12 @@ single_replace(pcre *pcre_code, pcre_ext
                                                  exec_options, ovector, 
ovecsize);
                if (j <= 0)
                        break;
-               addlen = ovector[0] - offset + (nbackrefs == 0 ? 
len_replacement : 0);
+
+               empty_match_correction = ovector[0] == ovector[1] ? 1 : 0;
+
+               // calculate the length of the string that will be appended to 
result
+               addlen = ovector[0] - offset
+                               + (nbackrefs == 0 ? len_replacement : 0) + 
empty_match_correction;
                if (len_result + addlen >= *max_result) {
                        tmp = GDKrealloc(result, len_result + addlen + 1);
                        if (tmp == NULL) {
@@ -750,11 +756,13 @@ single_replace(pcre *pcre_code, pcre_ext
                        result = tmp;
                        *max_result = len_result + addlen + 1;
                }
+               // append to the result the parts of the original string that 
are left unchanged
                if (ovector[0] > offset) {
                        strncpy(result + len_result, origin_str + offset,
                                        ovector[0] - offset);
                        len_result += ovector[0] - offset;
                }
+               // append to the result the replacement of the matched string
                if (nbackrefs == 0) {
                        strncpy(result + len_result, replacement, 
len_replacement);
                        len_result += len_replacement;
@@ -807,8 +815,18 @@ single_replace(pcre *pcre_code, pcre_ext
                                len_result += addlen;
                        }
                }
-               offset = ovector[1];
-       } while (offset < len_origin_str && global);
+               // In case of an empty match just advance the offset by 1
+               offset = ovector[1] + empty_match_correction;
+               // and copy the character that we just advanced over
+               if (empty_match_correction) {
+                       strncpy(result + len_result, origin_str + ovector[1], 
1);
+                       ++len_result;
+               }
+               // before we loop around check with the offset - 1 if we had an 
empty match
+               // since we manually advanced the offset by one. otherwise we 
gonna skip a
+               // replacement at the end of the string
+       } while ((offset - empty_match_correction) < len_origin_str && global);
+
        if (offset < len_origin_str) {
                addlen = len_origin_str - offset;
                if (len_result + addlen >= *max_result) {
diff --git a/monetdb5/modules/mal/tablet.c b/monetdb5/modules/mal/tablet.c
--- a/monetdb5/modules/mal/tablet.c
+++ b/monetdb5/modules/mal/tablet.c
@@ -1945,8 +1945,7 @@ SQLload_file(Client cntxt, Tablet *as, b
        return BUN_NONE;
 }
 
-/* return the latest reject table, to be on the safe side we should
- * actually create copies within a critical section. Ignored for now. */
+/* return the latest reject table */
 str
 COPYrejects(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
@@ -1958,10 +1957,27 @@ COPYrejects(Client cntxt, MalBlkPtr mb, 
        create_rejects_table(cntxt);
        if (cntxt->error_row == NULL)
                throw(MAL, "sql.rejects", "No reject table available");
-       BBPretain(*row = cntxt->error_row->batCacheid);
-       BBPretain(*fld = cntxt->error_fld->batCacheid);
-       BBPretain(*msg = cntxt->error_msg->batCacheid);
-       BBPretain(*inp = cntxt->error_input->batCacheid);
+       MT_lock_set(&errorlock);
+       BAT *bn1 = COLcopy(cntxt->error_row, cntxt->error_row->ttype, true, 
TRANSIENT);
+       BAT *bn2 = COLcopy(cntxt->error_fld, cntxt->error_fld->ttype, true, 
TRANSIENT);
+       BAT *bn3 = COLcopy(cntxt->error_msg, cntxt->error_msg->ttype, true, 
TRANSIENT);
+       BAT *bn4 = COLcopy(cntxt->error_input, cntxt->error_input->ttype, true, 
TRANSIENT);
+       MT_lock_unset(&errorlock);
+       if (bn1 == NULL || bn2 == NULL || bn3 == NULL || bn4 == NULL) {
+               BBPreclaim(bn1);
+               BBPreclaim(bn2);
+               BBPreclaim(bn3);
+               BBPreclaim(bn4);
+               throw(MAL, "sql.rejects", GDK_EXCEPTION);
+       }
+       *row = bn1->batCacheid;
+       *fld = bn2->batCacheid;
+       *msg = bn3->batCacheid;
+       *inp = bn4->batCacheid;
+       BBPkeepref(bn1);
+       BBPkeepref(bn2);
+       BBPkeepref(bn3);
+       BBPkeepref(bn4);
        (void) mb;
        return MAL_SUCCEED;
 }
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -4472,7 +4472,7 @@ tc_gc_col( sql_store Store, sql_change *
                        return LOG_OK; /* cannot cleanup yet */
 
                // d is oldest reachable delta
-               if (d->next) // Unreachable can immediately be destroyed.
+               if (d->cs.merged && d->next) // Unreachable can immediately be 
destroyed.
                        destroy_delta(d->next, true);
 
                d->next = NULL;
@@ -4512,7 +4512,7 @@ tc_gc_upd_col( sql_store Store, sql_chan
                        return LOG_OK; /* cannot cleanup yet */
 
                // d is oldest reachable delta
-               if (d->next) // Unreachable can immediately be destroyed.
+               if (d->cs.merged && d->next) // Unreachable can immediately be 
destroyed.
                        destroy_delta(d->next, true);
 
                d->next = NULL;
@@ -4552,7 +4552,7 @@ tc_gc_idx( sql_store Store, sql_change *
                        return LOG_OK; /* cannot cleanup yet */
 
                // d is oldest reachable delta
-               if (d->next) // Unreachable can immediately be destroyed.
+               if (d->cs.merged && d->next) // Unreachable can immediately be 
destroyed.
                        destroy_delta(d->next, true);
 
                d->next = NULL;
@@ -4592,7 +4592,7 @@ tc_gc_upd_idx( sql_store Store, sql_chan
                        return LOG_OK; /* cannot cleanup yet */
 
                // d is oldest reachable delta
-               if (d->next) // Unreachable can immediately be destroyed.
+               if (d->cs.merged && d->next) // Unreachable can immediately be 
destroyed.
                        destroy_delta(d->next, true);
 
                d->next = NULL;
diff --git a/sql/test/Tests/regexp.test b/sql/test/Tests/regexp.test
--- a/sql/test/Tests/regexp.test
+++ b/sql/test/Tests/regexp.test
@@ -54,9 +54,36 @@ select regexp_replace('foo', 'f o o', 'X
 ----
 foo
 
-# regex option - not extended
+# regex option - extended
 query T rowsort
 select regexp_replace('foo', 'f o o', 'XYZ', 'x')
 ----
 XYZ
 
+# regex option - not emtpy match
+query T rowsort
+select regexp_replace('foobar', 'k?', 'XY')
+----
+foobar
+
+# regex option - emtpy match
+query T rowsort
+select regexp_replace('foobar', 'k?', '-', 'e')
+----
+-f-o-o-b-a-r-
+
+# regex option - empty match w alternative v1
+query T rowsort
+select regexp_replace('abc', 'b|k?', '-', 'e')
+----
+-a--c-
+
+# regex option - empty match w alternative v2
+# even though you would expect -a--c- the pcre lib does not return 
+# the longest match for this particular pattern in offset 1 ('b') but 
+# an empty string match ¯\_(ツ)_/¯ 
+query T rowsort
+select regexp_replace('abc', 'k?|b', '-', 'e')
+----
+-a-b-c-
+
diff --git 
a/sql/test/concurrent/Tests/crash_on_concurrent_use.SF-1411926.SQL.py 
b/sql/test/concurrent/Tests/crash_on_concurrent_use.SF-1411926.SQL.py
--- a/sql/test/concurrent/Tests/crash_on_concurrent_use.SF-1411926.SQL.py
+++ b/sql/test/concurrent/Tests/crash_on_concurrent_use.SF-1411926.SQL.py
@@ -1,7 +1,7 @@
 import pymonetdb, sys, threading, os
 
 query = '''
-select count(*) from tables;
+--select count(*) from tables;
 create table t1(i int);
 insert into t1 values(1);
 insert into t1 values(2);
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to