Changeset: 2c5e19efb983 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2c5e19efb983
Modified Files:
gdk/gdk_select.c
monetdb5/mal/mal_client.c
monetdb5/modules/mal/tablet.c
sql/backends/monet5/generator/generator.c
sql/test/BugTracker-2026/Tests/All
Branch: default
Log Message:
Merge with Dec2025 branch.
diffs (truncated from 319 to 300 lines):
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -1399,6 +1399,7 @@ BATselect(BAT *b, BAT *s, const void *tl
oid vwl = 0, vwh = 0;
lng vwo = 0;
Heap *oidxh = NULL;
+ BAT *view = NULL;
const char *algo;
enum range_comp_t range;
const bool notnull = BATgetprop(b, GDK_NOT_NULL) != NULL;
@@ -1757,7 +1758,6 @@ BATselect(BAT *b, BAT *s, const void *tl
!bi.sorted &&
!bi.revsorted &&
ci.tpe == cand_dense) {
- BAT *view = NULL;
(void) BATcheckorderidx(b);
MT_lock_set(&b->batIdxLock);
if ((oidxh = b->torderidx) != NULL)
@@ -1774,15 +1774,10 @@ BATselect(BAT *b, BAT *s, const void *tl
MT_lock_unset(&pb->batIdxLock);
}
if (oidxh) {
- /* Is query selective enough to use the ordered
- * index? Finding the boundaries is 2*log(n)
- * where n is the size of the bat, sorting is
- * N*log(N) where N is the number of results.
- * If the sum is less than n (cost of scan),
- * it's cheaper. However, to find out how large
- * N is, we'd have to do the two boundary
- * searches. If we do that, we might as well do
- * it all. */
+ /* Find the boundaries in the ordered index. Once
+ * we know how many values are in the range we
+ * decide whether using the index is actually
+ * cheaper than a scan (see below). */
if (view) {
bat_iterator_end(&bi);
bi = bat_iterator(b);
@@ -1888,6 +1883,26 @@ BATselect(BAT *b, BAT *s, const void *tl
high = ORDERfndfirst(b, oidxh, th);
}
}
+ /* Now that we know the size of the range in the ordered
+ * index, check whether using the index is actually
+ * cheaper than a scan. Building the result from the
+ * index requires copying the matching OIDs and sorting
+ * them, which costs about N*log(N) for N results, whereas
+ * a scan costs about the number of candidates. For broad
+ * ranges the scan is much cheaper (and avoids sorting a
+ * large result). */
+ if (oidxh != NULL && high > low &&
+ (double) (high - low) * (log2((double) (high - low)) + 1.0)
>= (double) ci.ncand) {
+ HEAPdecref(oidxh, false);
+ oidxh = NULL;
+ if (view) {
+ b = view;
+ bat_iterator_end(&bi);
+ bi = bat_iterator(b);
+ poidx = false;
+ }
+ goto use_scan;
+ }
if (anti) {
assert(oidxh == NULL);
if (bi.sorted) {
@@ -1973,6 +1988,7 @@ BATselect(BAT *b, BAT *s, const void *tl
return bn;
}
+ use_scan:
assert(oidxh == NULL);
/* upper limit for result size */
maximum = ci.ncand;
diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -620,11 +620,20 @@ MCsetClientInfo(Client c, const char *pr
}
break;
case 'P':
- if (strcasecmp(property, "ClientPid") == 0 && value !=
NULL) {
- char *end;
- long n = strtol(value, &end, 10);
- if (*value && !*end)
- c->client_pid = n;
+ if (strcasecmp(property, "ClientPid") == 0) {
+ if (value == NULL) {
+ c->client_pid = 0;
+ } else {
+ char *end;
+ long n = strtol(value, &end, 10);
+ if (*value && !*end)
+ c->client_pid = n;
+ else {
+ // Can't parse the value as an
integer. To keep setting
+ // client info infallible we
just set it to NULL.
+ c->client_pid = 0;
+ }
+ }
}
break;
default:
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
@@ -873,7 +873,7 @@ SQLinsert_val(READERtask *task, int col,
}
}
- lng row = task->cnt + idx + 1;
+ lng row = task->startlineno[task->cur][idx];
if (adt == NULL) {
if (task->rowerror) {
err = SQLload_error(task, idx, task->as->nr_attrs);
@@ -1441,6 +1441,7 @@ SQLproducer(void *p)
rowno++;
if (task->skip > 0) {
task->skip--;
+ startlineno = lineno;
} else {
if (cnt < task->maxrow) {
task->startlineno[cur][task->top[cur]] = startlineno;
diff --git a/sql/backends/monet5/generator/generator.c
b/sql/backends/monet5/generator/generator.c
--- a/sql/backends/monet5/generator/generator.c
+++ b/sql/backends/monet5/generator/generator.c
@@ -274,13 +274,15 @@ VLTgenerator_table_(BAT **result, Client
f = *getArgReference_TYPE(stk, pci, 1, date);
l = *getArgReference_TYPE(stk, pci, 2, date);
s = *getArgReference_lng(stk, pci, 3);
- s /= 24*60*60*1000;
if (s == 0 ||
(s > 0 && ret.val.btval > 0) ||
(s < 0 && ret.val.btval < 0) ||
is_date_nil(f) || is_date_nil(l))
throw(MAL, "generator.table",
SQLSTATE(42000) "Illegal generator
range");
+ s /= 24*60*60*1000;
+ if (s > (lng) GDK_int_max)
+ s = (lng) GDK_int_max;
/* check if s is really in nr of days or usecs */
n = (BUN) (date_diff(l, f) / s) + 1; /* n maybe too
large now */
bn = COLnew(0, TYPE_date, n + 1, TRANSIENT);
@@ -288,11 +290,11 @@ VLTgenerator_table_(BAT **result, Client
throw(MAL, "generator.table", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
v = (date *) Tloc(bn, 0);
if (s < 0) {
- for (; !is_date_nil(f) && f > l; f =
date_add_day(f, s)) {
+ for (; !is_date_nil(f) && f > l; f =
date_add_day(f, (int) s)) {
*v++ = f;
}
} else {
- for (; !is_date_nil(f) && f < l; f =
date_add_day(f, s)) {
+ for (; !is_date_nil(f) && f < l; f =
date_add_day(f, (int) s)) {
*v++ = f;
}
}
diff --git
a/sql/test/BugTracker-2026/Tests/8093-best-effort-offset-row-numbers.test
b/sql/test/BugTracker-2026/Tests/8093-best-effort-offset-row-numbers.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2026/Tests/8093-best-effort-offset-row-numbers.test
@@ -0,0 +1,37 @@
+statement ok
+CALL sys.clearrejects();
+
+statement ok
+DROP TABLE IF EXISTS t; CREATE TABLE t(i INT);
+
+statement ok
+COPY 3 RECORDS INTO t FROM STDIN BEST EFFORT;
+<COPY_INTO_DATA>
+10
+20
+not_an_integer
+
+# the error is at row three of the input
+query I
+SELECT rowid FROM sys.rejects;
+----
+3
+
+statement ok
+CALL sys.clearrejects();
+
+# now skip the a row
+statement ok
+COPY 1 OFFSET 3 RECORDS INTO t FROM STDIN BEST EFFORT;
+<COPY_INTO_DATA>
+10
+20
+not_an_integer
+
+
+# the error should still be at row 3
+query I
+SELECT rowid FROM sys.rejects;
+----
+3
+
diff --git a/sql/test/BugTracker-2026/Tests/8102-broad-range-orderidx.test
b/sql/test/BugTracker-2026/Tests/8102-broad-range-orderidx.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2026/Tests/8102-broad-range-orderidx.test
@@ -0,0 +1,42 @@
+statement ok
+CREATE TABLE t8102 (v BIGINT)
+
+statement ok
+INSERT INTO t8102 SELECT value + 1000 FROM sys.generate_series(0, 1000)
+
+statement ok
+INSERT INTO t8102 SELECT value FROM sys.generate_series(0, 1000)
+
+statement ok
+CREATE ORDERED INDEX t8102_v_oidx ON t8102(v)
+
+# A broad range over a column that has an ordered index must return the
+# same result as the equivalent scan without the ordered index.
+query I
+SELECT COUNT(*) FROM t8102 WHERE v < 1000
+----
+1000
+
+query I
+SELECT COUNT(*) FROM t8102 WHERE NOT (v >= 1000)
+----
+1000
+
+query I
+SELECT COUNT(*) FROM t8102 WHERE v >= 1000
+----
+1000
+
+# Narrow ranges should still be handled correctly as well.
+query I
+SELECT COUNT(*) FROM t8102 WHERE v < 10
+----
+10
+
+query I
+SELECT COUNT(*) FROM t8102 WHERE v >= 1990
+----
+10
+
+statement ok
+DROP TABLE t8102
diff --git a/sql/test/BugTracker-2026/Tests/8115-set-clientpid-null.test
b/sql/test/BugTracker-2026/Tests/8115-set-clientpid-null.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2026/Tests/8115-set-clientpid-null.test
@@ -0,0 +1,25 @@
+
+
+# pymonetdb sets the client id
+query I ok
+SELECT clientpid > 0 FROM sessions WHERE sessionid = current_sessionid();
+----
+1
+
+# we can override it
+statement ok
+CALL sys.setclientinfo('ClientPid', 12345)
+
+query I ok
+SELECT clientpid FROM sessions WHERE sessionid = current_sessionid();
+----
+12345
+
+# we can also set it to NULL
+statement ok
+CALL sys.setclientinfo('ClientPid', NULL)
+
+query I ok
+SELECT clientpid FROM sessions WHERE sessionid = current_sessionid();
+----
+NULL
diff --git a/sql/test/BugTracker-2026/Tests/All
b/sql/test/BugTracker-2026/Tests/All
--- a/sql/test/BugTracker-2026/Tests/All
+++ b/sql/test/BugTracker-2026/Tests/All
@@ -213,19 +213,19 @@ KNOWNFAIL?8010-first_value-last_value-pa
8036-alter+insert-in-trans
8037-alter-table-decimal
8031-simplify-count-too-simple
+8045-query-timeout-without-session-timeout
8046-simplify-fk-join-bug
8048-group-filter-function-match
8049-alter-add-column-default-dependencies
-8045-query-timeout-without-session-timeout
8054-correlated-not-notequal
8055-interval-day-overflow
8056-date-generator
8057-drop-function-check-update
8059-aggr-on-pipeline-local-string-col-causes-nulls
+8061-session-authorization-current-user
8062-groupby-inet6
8064-explain-show-details-pkey
8065-unnamed-fkeys-same-column
-8061-session-authorization-current-user
8066-semijoin-pushdown-after-join-order
8066-semijoin-reducing-nested-select
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]