mirror of
https://github.com/MariaDB/server.git
synced 2025-01-27 01:04:19 +01:00
9bfde897c3
This patch adds DEFAULT as a possible dynamic SQL parameter, e.g.: EXECUTE IMMEDIATE 'INSERT INTO t1 (column) VALUES(?)' USING DEFAULT; EXECUTE IMMEDIATE 'UPDATE t1 SET column=?' USING DEFAULT; and for similar PREPARE..EXECUTE queries. This is done for symmetry with the STMT_INDICATOR_DEFAULT indicator in the client-server PS protocol. The changes include: - Allowing DEFAULT as a possible option in execute USING clause (sql_yacc.yy) - Adding "virtual bool Item::save_in_param(THD *thd, Item_param *param)", because "normal" items (that have real values) and Item_default_value have now different actions when assigning itself as an Item_param value. - Fixing switch() statements in a few Item_param methods not to have "default", because it was easy to forget to add a new "case" when adding a new XXX_VALUE value into the enum Item_param::enum_item_param_state. This is important, as we'll be adding new values soon, e.g. for MDEV-11359. Removing "default" helped to find and report bugs MDEV-11361 and MDEV-11362, because DECIMAL_VALUE is obviously not properly handled in some cases.
101 lines
2.8 KiB
Text
101 lines
2.8 KiB
Text
# This test is to verify replication with PS
|
|
|
|
-- source include/not_embedded.inc
|
|
-- source include/have_binlog_format_statement.inc
|
|
|
|
disable_query_log;
|
|
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
|
|
enable_query_log;
|
|
|
|
-- disable_query_log
|
|
reset master; # get rid of previous tests binlog
|
|
-- enable_query_log
|
|
|
|
--disable_warnings
|
|
drop table if exists t1;
|
|
--enable_warnings
|
|
reset master;
|
|
|
|
#
|
|
# Bug #26842: master binary log contains invalid queries - replication fails
|
|
#
|
|
create table t1 (a int);
|
|
prepare s from "insert into t1 values (@a),(?)";
|
|
set @a=98; execute s using @a;
|
|
prepare s from "insert into t1 values (?)";
|
|
set @a=99; execute s using @a;
|
|
prepare s from "insert into t1 select 100 limit ?";
|
|
set @a=100; execute s using @a;
|
|
source include/show_binlog_events.inc;
|
|
drop table t1;
|
|
|
|
--echo #
|
|
--echo # MDEV-10709 Expressions as parameters to Dynamic SQL
|
|
--echo #
|
|
|
|
FLUSH LOGS;
|
|
SET TIMESTAMP=UNIX_TIMESTAMP('2001-01-02 10:20:30.123456');
|
|
CREATE TABLE t1 (a DECIMAL(30,8));
|
|
PREPARE stmt FROM 'INSERT INTO t1 VALUES (?)';
|
|
EXECUTE stmt USING 10;
|
|
EXECUTE stmt USING 11e0;
|
|
EXECUTE stmt USING 12.1;
|
|
EXECUTE stmt USING '13';
|
|
EXECUTE stmt USING CURRENT_DATE;
|
|
EXECUTE stmt USING MAKETIME(10,20,30);
|
|
EXECUTE stmt USING CURRENT_TIME;
|
|
EXECUTE stmt USING CURRENT_TIME(3);
|
|
EXECUTE stmt USING CURRENT_TIME(6);
|
|
EXECUTE stmt USING CURRENT_TIMESTAMP;
|
|
EXECUTE stmt USING CURRENT_TIMESTAMP(3);
|
|
EXECUTE stmt USING CURRENT_TIMESTAMP(6);
|
|
SELECT * FROM t1;
|
|
--let $binlog_file = LAST
|
|
source include/show_binlog_events.inc;
|
|
DROP TABLE t1;
|
|
SET TIMESTAMP=DEFAULT;
|
|
|
|
--echo #
|
|
--echo # MDEV-10585 EXECUTE IMMEDIATE statement
|
|
--echo #
|
|
|
|
FLUSH LOGS;
|
|
CREATE TABLE t1 (a INT);
|
|
EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES (101)';
|
|
SET @a=102;
|
|
EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES (?)' USING @a;
|
|
SET @a=103;
|
|
SET @stmt='INSERT INTO t1 VALUES (?)';
|
|
EXECUTE IMMEDIATE @stmt USING @a;
|
|
--let $binlog_file = LAST
|
|
source include/show_binlog_events.inc;
|
|
DROP TABLE t1;
|
|
|
|
--echo #
|
|
--echo # MDEV-11360 Dynamic SQL: DEFAULT as a bind parameter
|
|
--echo #
|
|
|
|
FLUSH LOGS;
|
|
CREATE TABLE t1 (a INT DEFAULT 10);
|
|
EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES (Default)';
|
|
--echo # The output of this query in 'Note' is a syntactically incorrect query.
|
|
--echo # But as it's never logged, it's ok. It should be human readable only.
|
|
EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT ?' USING Default;
|
|
EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES (?)' USING Default;
|
|
|
|
DELIMITER $$;
|
|
CREATE PROCEDURE p1 ()
|
|
BEGIN
|
|
INSERT INTO t1 VALUES (Default);
|
|
# EXPLAIN should not be logged
|
|
EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT ?' USING Default;
|
|
EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES (?)' USING Default;
|
|
END;
|
|
$$
|
|
DELIMITER ;$$
|
|
CALL p1;
|
|
DROP PROCEDURE p1;
|
|
DROP TABLE t1;
|
|
|
|
--let $binlog_file = LAST
|
|
source include/show_binlog_events.inc;
|