mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Bug#16461: connection_id() does not work properly inside trigger
CONNECTION_ID() was implemented as a constant Item, i.e. an instance of Item_static_int_func class holding value computed at creation time. Since Items are created on parsing, and trigger statements are parsed on table open, the first connection to open a particular table would effectively set its own CONNECTION_ID() inside trigger statements for that table. Re-implement CONNECTION_ID() as a class derived from Item_int_func, and compute connection_id on every call to fix_fields().
This commit is contained in:
@ -952,3 +952,16 @@ load data infile '../std_data_ln/words.dat' into table t1 (a) set b:= f1();
|
||||
drop table t1;
|
||||
drop function f1;
|
||||
drop function f2;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (
|
||||
conn_id INT,
|
||||
trigger_conn_id INT
|
||||
);
|
||||
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
|
||||
SET NEW.trigger_conn_id = CONNECTION_ID();
|
||||
INSERT INTO t1 (conn_id, trigger_conn_id) VALUES (CONNECTION_ID(), -1);
|
||||
INSERT INTO t1 (conn_id, trigger_conn_id) VALUES (CONNECTION_ID(), -1);
|
||||
SELECT * FROM t1 WHERE conn_id != trigger_conn_id;
|
||||
conn_id trigger_conn_id
|
||||
DROP TRIGGER t1_bi;
|
||||
DROP TABLE t1;
|
||||
|
Reference in New Issue
Block a user