Conversation
Usage: mtr --mysqld=--debug=d,ref_array,query:i:o,/tmp/mdl.log
…h versioned column In MDEV-25644 vers_check_update() sets vers_write to false in case it returns false. It is ok for UPDATE but is not correct for ODKU is bulk insert requires vers_write on next tuple. The fix return vers_write value back when vers_check_update() and related vers_insert_history_row() are done in ODKU.
row_sel_store_mysql_field() does: 3113 mysql_rec[templ->mysql_null_byte_offset] 3114 &= static_cast<byte>(~templ->mysql_null_bit_mask); but mysql_rec[] which is prefetch buffer was allocated without initialization. Prefetch buffers are allocated by row_sel_prefetch_cache_init(): 3881 ptr = static_cast<byte*>(ut_malloc_nokey(sz)); and then it initializes the buffers with the magic numbers. The fix initializes the buffers with null bytes as well for nullable fields.
Function calls in INTERVAL expression of DDL have little sense. SETVAL() fails because sequences require opened tables and vers_set_interval() is called at earlier stage. The fix throws ER_SUBQUERIES_NOT_SUPPORTED for sequence functions SETVAL(), NEXTVAL(), LASTVAL() when the context does not allow subselect (determined by clause_that_disallows_subselect).
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Pull request overview
This PR delivers a set of 10.11 bugfixes across InnoDB row prefetch caching, SELECT ref-pointer-array diagnostics, sequence-function parsing restrictions in clauses that disallow subqueries/stored functions, and versioned-table ODKU behavior—along with regression tests for the reported MDEV issues.
Changes:
- Initialize parts of the InnoDB fetch-cache row buffer to avoid uninitialized NULL-bitmap content.
- Add DBUG instrumentation to track ref_ptrs/all_fields element consumption during
JOIN::prepare(). - Disallow sequence functions (
nextval/lastval/setval) whenLEX::clause_that_disallows_subselectis set; adjust tests and expected errors accordingly. - Fix versioning ODKU behavior by ensuring
table->vers_writeis set for the next bulk iteration; add regression tests. - Add an InnoDB suite regression test for the partition swap_blobs sanitizer/valgrind issue.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| storage/innobase/row/row0sel.cc | Initializes fetch-cache row buffers (incl. NULL-bitmap handling) during prefetch-cache allocation. |
| sql/sql_select.cc | Adds debug tracing for ref-array element usage through major phases of JOIN::prepare(). |
| sql/sql_lex.h | Clarifies comment docs for clause_that_disallows_subselect. |
| sql/sql_lex.cc | Adds ref-array reservation debug prints; blocks sequence functions in clauses that disallow subqueries/stored functions. |
| sql/sql_insert.cc | Adjusts versioned ODKU flow to ensure vers_write remains set for subsequent bulk iterations; keeps history-row insertion semantics. |
| mysql-test/suite/versioning/t/update.test | Adds regression test for MDEV-38854. |
| mysql-test/suite/versioning/r/update.result | Updates expected output for MDEV-38854 test. |
| mysql-test/suite/versioning/t/partition.test | Adds regression tests for MDEV-36362 expecting ER_SUBQUERIES_NOT_SUPPORTED. |
| mysql-test/suite/versioning/r/partition.result | Updates expected errors/messages for new partition regression tests. |
| mysql-test/suite/sql_sequence/other.test | Updates CHECK-clause expectations to ER_SUBQUERIES_NOT_SUPPORTED for sequence functions. |
| mysql-test/suite/sql_sequence/other.result | Updates expected CHECK-clause error messages/codes accordingly. |
| mysql-test/suite/innodb/t/bug.test | Adds regression test for MDEV-27569 (partition swap_blobs sanitizer/valgrind). |
| mysql-test/suite/innodb/r/bug.result | Expected output for the new InnoDB regression test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| create table t (id int, a int, b text, key(a), primary key (id)) engine=innodb | ||
| partition by hash(id) partitions 2; | ||
| insert into t (id,a) select seq, seq%10 from seq_1_to_20; | ||
| select * from t where id >= 1900 or a in (2,4) limit 1; |
There was a problem hiding this comment.
This SELECT uses LIMIT 1 without an ORDER BY, but the WHERE clause matches multiple rows (e.g., a IN (2,4)), so the returned row is not guaranteed and the .result can become flaky across optimizer/plan changes. Add an explicit ordering (e.g., ORDER BY id) or otherwise make the query deterministic.
| select * from t where id >= 1900 or a in (2,4) limit 1; | |
| select * from t where id >= 1900 or a in (2,4) order by id limit 1; |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| memset(ptr, 0, prebuilt->null_bitmap_len); | ||
|
|
||
| for (ulint j = 0; j < prebuilt->n_template; j++) { | ||
| const mysql_row_templ_t*templ = &prebuilt->mysql_template[j]; | ||
| if (templ->mysql_null_bit_mask) { | ||
| ut_ad(templ->mysql_null_byte_offset | ||
| < prebuilt->null_bitmap_len); | ||
| } | ||
| } |
There was a problem hiding this comment.
The NULL-bitmap is being zeroed only once during cache allocation, but buffers returned by row_sel_fetch_last_buf() are later marked MEM_UNDEFINED before row_sel_store_mysql_rec() does read-modify-write (|=, &=) on mysql_rec[mysql_null_byte_offset]. Under Valgrind/MSAN this can still report uninitialized reads (and the bitmap can also be stale after buffer reuse). Consider clearing/initializing the NULL-bitmap after MEM_UNDEFINED (e.g., in row_sel_fetch_last_buf() right before returning) or at the start of row_sel_store_mysql_rec() for every buffer fill, rather than only in row_sel_prefetch_cache_init().
No description provided.