mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 13:02:28 +01:00
452860dfde
If the expression for a virtual column of table contained datetime comparison then the execution of the second query that used this virtual column caused a crash. It happened because the execution of the first query that used this virtual column inserted a cached item into the expression tree. The cached tree was allocated in the statement memory while the expression tree was allocated in the table memory. Now the cached items that are inserted into expressions for virtual columns with datetime comparisons are always allocated in the same mem_root as the expressions for virtual columns. So now the inserted cached items are valid for any queries that use these virtual columns.
69 lines
1.5 KiB
Text
69 lines
1.5 KiB
Text
--disable_warnings
|
|
drop table if exists t1,t2;
|
|
--enable_warnings
|
|
|
|
#
|
|
# Bug#601164: DELETE/UPDATE with ORDER BY index and LIMIT
|
|
#
|
|
|
|
create table t1 (a int, b int, v int as (a+1), index idx(b));
|
|
insert into t1(a, b) values
|
|
(4, 40), (3, 30), (5, 50), (7, 70), (8, 80), (2, 20), (1, 10);
|
|
|
|
select * from t1 order by b;
|
|
|
|
delete from t1 where v > 6 order by b limit 1;
|
|
select * from t1 order by b;
|
|
|
|
update t1 set a=v order by b limit 1;
|
|
select * from t1 order by b;
|
|
|
|
drop table t1;
|
|
|
|
#
|
|
# Bug#604549: Expression for virtual column returns row
|
|
#
|
|
|
|
-- error ER_ROW_EXPR_FOR_VCOL
|
|
CREATE TABLE t1 (
|
|
a int NOT NULL DEFAULT '0',
|
|
v double AS ((1, a)) VIRTUAL
|
|
);
|
|
|
|
#
|
|
# Bug#603654: Virtual column in ORDER BY, no other references of table columns
|
|
#
|
|
|
|
CREATE TABLE t1 (
|
|
a CHAR(255) BINARY NOT NULL DEFAULT 0,
|
|
b CHAR(255) BINARY NOT NULL DEFAULT 0,
|
|
v CHAR(255) BINARY AS (CONCAT(a,b)) VIRTUAL );
|
|
INSERT INTO t1(a,b) VALUES ('4','7'), ('4','6');
|
|
SELECT 1 AS C FROM t1 ORDER BY v;
|
|
|
|
DROP TABLE t1;
|
|
|
|
#
|
|
# Bug#604503: Virtual column expression with datetime comparison
|
|
#
|
|
|
|
CREATE TABLE t1 (
|
|
a datetime NOT NULL DEFAULT '2000-01-01',
|
|
v boolean AS (a < '2001-01-01')
|
|
);
|
|
INSERT INTO t1(a) VALUES ('2002-02-15');
|
|
INSERT INTO t1(a) VALUES ('2000-10-15');
|
|
|
|
SELECT a, v FROM t1;
|
|
SELECT a, v FROM t1;
|
|
|
|
CREATE TABLE t2 (
|
|
a datetime NOT NULL DEFAULT '2000-01-01',
|
|
v boolean AS (a < '2001-01-01') PERSISTENT
|
|
);
|
|
INSERT INTO t2(a) VALUES ('2002-02-15');
|
|
INSERT INTO t2(a) VALUES ('2000-10-15');
|
|
|
|
SELECT * FROM t2;
|
|
|
|
DROP TABLE t1, t2;
|