Changeset: 2bee31da79bc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2bee31da79bc
Added Files:
        sql/test/BugTracker-2026/Tests/8093-best-effort-offset-row-numbers.test
Modified Files:
        monetdb5/modules/mal/tablet.c
        sql/test/BugTracker-2026/Tests/All
Branch: Dec2025
Log Message:

Fix error line numbers in COPY statements with an OFFSET (#8093)

If something like COPY 1 OFFSET 3 RECORDS ... BEST EFFORT encountered
invalid values, the reported line numbers did not take the OFFSET
into account.

The fix has two parts:

1) On the SQLconsumer() side, instead of computing the row number
ourselves we extract it from the 'startlineno' array that the
SQLproducer() side keeps track of.

2) On the SQLProducer() side, we increment startlineno also for skipped
rows, not just for parsed rows.

Fixes #8093.


diffs (73 lines):

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
@@ -880,7 +880,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);
@@ -1448,6 +1448,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/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/All 
b/sql/test/BugTracker-2026/Tests/All
--- a/sql/test/BugTracker-2026/Tests/All
+++ b/sql/test/BugTracker-2026/Tests/All
@@ -210,6 +210,7 @@ KNOWNFAIL?8030-inner-join-group-by-bug
 8036-alter+insert-in-trans
 8037-alter-table-decimal
 8031-simplify-count-too-simple
+8093-best-effort-offset-row-numbers
 8100-error-overflow
 8107-select-generate-date
 8113-dict-compress
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to