mirror of
https://github.com/MariaDB/server.git
synced 2025-08-16 18:19:41 +00:00
MDEV-35330: Assertion marked_for_read()
failed in VSec9::VSec9 | Item_func_from_unixtime::get_date
Problem: When a parameter in a prepared UPDATE statement uses DEFAULT value for a column (e.g., `EXECUTE IMMEDIATE 'UPDATE t SET b=?' USING DEFAULT`), and that column's default is derived from an expression or a function referencing another column (e.g., `FROM_UNIXTIME(a)`), the server fails to correctly mark the dependent column (`a`) for reading. This happened because the server failed to associate the `Item_param` (representing the `?` parameter) with its target field (`b`), leaving `Item_param::m_associated_field` uninitialized. This prevented the correct code path for evaluating the `DEFAULT` value, leading to the dependent column not being marked for read. When the column's value was later accessed, an assertion failed, causing a crash. Fix: In the prepare stage of the UPDATE statement, associate each value with the target field, causing the server to take the correct code path (`Item_param::assign_default`) for evaluating DEFAULT values and marking dependent column for reading beforehand. Only tests are included as it is a duplicate of MDEV-36870.
This commit is contained in:
@ -5995,3 +5995,55 @@ DROP VIEW t1;
|
||||
#
|
||||
# End of 10.4 tests
|
||||
#
|
||||
#
|
||||
# MDEV-35330: Assertion `marked_for_read()` failed in VSec9::VSec9 | Item_func_from_unixtime::get_date
|
||||
#
|
||||
CREATE TABLE t (a INT,b TIMESTAMP DEFAULT FROM_UNIXTIME(a));
|
||||
INSERT INTO t VALUES (1,'2025-07-18 18:37:10');
|
||||
SELECT * FROM t;
|
||||
a b
|
||||
1 2025-07-18 18:37:10
|
||||
EXECUTE IMMEDIATE 'UPDATE t SET b=?' USING DEFAULT;
|
||||
SELECT * FROM t;
|
||||
a b
|
||||
1 1970-01-01 09:00:01
|
||||
DROP TABLE t;
|
||||
CREATE TABLE t (a INT, b INT DEFAULT (a+5));
|
||||
INSERT INTO t values (1,2), (2,DEFAULT);
|
||||
EXECUTE IMMEDIATE 'INSERT INTO t VALUES (3,4), (4,?)' USING DEFAULT;
|
||||
SELECT * FROM t;
|
||||
a b
|
||||
1 2
|
||||
2 7
|
||||
3 4
|
||||
4 9
|
||||
EXECUTE IMMEDIATE 'UPDATE t SET b=?' USING DEFAULT;
|
||||
SELECT * FROM t;
|
||||
a b
|
||||
1 6
|
||||
2 7
|
||||
3 8
|
||||
4 9
|
||||
DROP TABLE t;
|
||||
CREATE TABLE t (a INT,b TIMESTAMP DEFAULT FROM_UNIXTIME(a));
|
||||
INSERT INTO t VALUES (1,'2025-07-18 18:37:10');
|
||||
SELECT * FROM t;
|
||||
a b
|
||||
1 2025-07-18 18:37:10
|
||||
PREPARE s FROM 'UPDATE t SET b=?';
|
||||
EXECUTE s USING DEFAULT;
|
||||
SELECT * FROM t;
|
||||
a b
|
||||
1 1970-01-01 09:00:01
|
||||
DROP TABLE t;
|
||||
CREATE TABLE t (a INT, b TIMESTAMP DEFAULT FROM_UNIXTIME(a), c INT DEFAULT (a+5));
|
||||
INSERT INTO t VALUES (1,'2025-07-18 18:37:10',3);
|
||||
SELECT * FROM t;
|
||||
a b c
|
||||
1 2025-07-18 18:37:10 3
|
||||
EXECUTE IMMEDIATE 'UPDATE t SET b=?, c=?' USING DEFAULT, DEFAULT;
|
||||
SELECT * FROM t;
|
||||
a b c
|
||||
1 1970-01-01 09:00:01 6
|
||||
DROP TABLE t;
|
||||
# End of 10.6 tests
|
||||
|
@ -5447,3 +5447,54 @@ DROP VIEW t1;
|
||||
--echo #
|
||||
--echo # End of 10.4 tests
|
||||
--echo #
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-35330: Assertion `marked_for_read()` failed in VSec9::VSec9 | Item_func_from_unixtime::get_date
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t (a INT,b TIMESTAMP DEFAULT FROM_UNIXTIME(a));
|
||||
INSERT INTO t VALUES (1,'2025-07-18 18:37:10');
|
||||
|
||||
SELECT * FROM t;
|
||||
|
||||
EXECUTE IMMEDIATE 'UPDATE t SET b=?' USING DEFAULT;
|
||||
|
||||
SELECT * FROM t;
|
||||
|
||||
DROP TABLE t;
|
||||
|
||||
CREATE TABLE t (a INT, b INT DEFAULT (a+5));
|
||||
INSERT INTO t values (1,2), (2,DEFAULT);
|
||||
EXECUTE IMMEDIATE 'INSERT INTO t VALUES (3,4), (4,?)' USING DEFAULT;
|
||||
|
||||
SELECT * FROM t;
|
||||
|
||||
EXECUTE IMMEDIATE 'UPDATE t SET b=?' USING DEFAULT;
|
||||
|
||||
SELECT * FROM t;
|
||||
|
||||
DROP TABLE t;
|
||||
|
||||
CREATE TABLE t (a INT,b TIMESTAMP DEFAULT FROM_UNIXTIME(a));
|
||||
INSERT INTO t VALUES (1,'2025-07-18 18:37:10');
|
||||
|
||||
SELECT * FROM t;
|
||||
|
||||
PREPARE s FROM 'UPDATE t SET b=?';
|
||||
EXECUTE s USING DEFAULT;
|
||||
|
||||
SELECT * FROM t;
|
||||
|
||||
DROP TABLE t;
|
||||
|
||||
CREATE TABLE t (a INT, b TIMESTAMP DEFAULT FROM_UNIXTIME(a), c INT DEFAULT (a+5));
|
||||
INSERT INTO t VALUES (1,'2025-07-18 18:37:10',3);
|
||||
|
||||
SELECT * FROM t;
|
||||
|
||||
EXECUTE IMMEDIATE 'UPDATE t SET b=?, c=?' USING DEFAULT, DEFAULT;
|
||||
|
||||
SELECT * FROM t;
|
||||
|
||||
DROP TABLE t;
|
||||
--echo # End of 10.6 tests
|
||||
|
Reference in New Issue
Block a user