Commit bdae7b9b authored by unknown's avatar unknown

BUG#12870 (CREATE PROCEDURE followed by ROLLBACK is not replicated)

Fixed by making CREATE/ALTER/DROP PROCEDURE cause implicit commit.


mysql-test/r/rpl_ddl.result:
  Updated results to include testing of implicit commit for
  create/alter/drop procedure
mysql-test/t/rpl_ddl.test:
  BUG#12870 test implicit commit for create/alter/drop procedure.
sql/sql_parse.cc:
  CREATE/ALTER/DROP PROCEDURE/SPFUNCTION now causes implicit commit.
parent b5e15568
......@@ -1072,6 +1072,188 @@ Database (mysqltest3)
mysqltest3
-------- switch to master -------
######## CREATE PROCEDURE p1() READS SQL DATA SELECT "this is p1" ########
-------- switch to master -------
INSERT INTO t1 SET f1= 15 + 1;
SELECT MAX(f1) FROM t1;
MAX(f1)
16
-------- switch to slave --------
SELECT MAX(f1) FROM t1;
MAX(f1)
15
-------- switch to master -------
CREATE PROCEDURE p1() READS SQL DATA SELECT "this is p1";
SELECT MAX(f1) FROM t1;
MAX(f1)
16
-------- switch to slave --------
SELECT MAX(f1) FROM t1;
MAX(f1)
16
-------- switch to master -------
ROLLBACK;
SELECT MAX(f1) FROM t1;
MAX(f1)
16
TEST-INFO: MASTER: The INSERT is committed (Succeeded)
-------- switch to slave --------
SELECT MAX(f1) FROM t1;
MAX(f1)
16
TEST-INFO: SLAVE: The INSERT is committed (Succeeded)
-------- switch to master -------
flush logs;
-------- switch to slave --------
flush logs;
-------- switch to master -------
SHOW PROCEDURE STATUS LIKE 'p1';
Db mysqltest1
Name p1
Type PROCEDURE
Definer root@localhost
Modified #
Created #
Security_type DEFINER
Comment
-------- switch to slave -------
SHOW PROCEDURE STATUS LIKE 'p1';
Db mysqltest1
Name p1
Type PROCEDURE
Definer @
Modified #
Created #
Security_type DEFINER
Comment
######## ALTER PROCEDURE p1 COMMENT "I have been altered" ########
-------- switch to master -------
INSERT INTO t1 SET f1= 16 + 1;
SELECT MAX(f1) FROM t1;
MAX(f1)
17
-------- switch to slave --------
SELECT MAX(f1) FROM t1;
MAX(f1)
16
-------- switch to master -------
ALTER PROCEDURE p1 COMMENT "I have been altered";
SELECT MAX(f1) FROM t1;
MAX(f1)
17
-------- switch to slave --------
SELECT MAX(f1) FROM t1;
MAX(f1)
17
-------- switch to master -------
ROLLBACK;
SELECT MAX(f1) FROM t1;
MAX(f1)
17
TEST-INFO: MASTER: The INSERT is committed (Succeeded)
-------- switch to slave --------
SELECT MAX(f1) FROM t1;
MAX(f1)
17
TEST-INFO: SLAVE: The INSERT is committed (Succeeded)
-------- switch to master -------
flush logs;
-------- switch to slave --------
flush logs;
-------- switch to master -------
SHOW PROCEDURE STATUS LIKE 'p1';
Db mysqltest1
Name p1
Type PROCEDURE
Definer root@localhost
Modified #
Created #
Security_type DEFINER
Comment I have been altered
-------- switch to slave -------
SHOW PROCEDURE STATUS LIKE 'p1';
Db mysqltest1
Name p1
Type PROCEDURE
Definer @
Modified #
Created #
Security_type DEFINER
Comment I have been altered
######## DROP PROCEDURE p1 ########
-------- switch to master -------
INSERT INTO t1 SET f1= 17 + 1;
SELECT MAX(f1) FROM t1;
MAX(f1)
18
-------- switch to slave --------
SELECT MAX(f1) FROM t1;
MAX(f1)
17
-------- switch to master -------
DROP PROCEDURE p1;
SELECT MAX(f1) FROM t1;
MAX(f1)
18
-------- switch to slave --------
SELECT MAX(f1) FROM t1;
MAX(f1)
18
-------- switch to master -------
ROLLBACK;
SELECT MAX(f1) FROM t1;
MAX(f1)
18
TEST-INFO: MASTER: The INSERT is committed (Succeeded)
-------- switch to slave --------
SELECT MAX(f1) FROM t1;
MAX(f1)
18
TEST-INFO: SLAVE: The INSERT is committed (Succeeded)
-------- switch to master -------
flush logs;
-------- switch to slave --------
flush logs;
-------- switch to master -------
SHOW PROCEDURE STATUS LIKE 'p1';
-------- switch to slave -------
SHOW PROCEDURE STATUS LIKE 'p1';
DROP DATABASE IF EXISTS mysqltest1;
DROP DATABASE IF EXISTS mysqltest2;
DROP DATABASE IF EXISTS mysqltest3;
......@@ -340,6 +340,57 @@ connection master;
SELECT '-------- switch to master -------' as "";
--enable_query_log
# End of 4.1 tests
###############################################################
# Cases with stored procedures
###############################################################
let $my_stmt= CREATE PROCEDURE p1() READS SQL DATA SELECT "this is p1";
let $my_master_commit= true;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc
--vertical_results
--replace_column 5 # 6 #
SHOW PROCEDURE STATUS LIKE 'p1';
--disable_query_log
SELECT '-------- switch to slave -------' as "";
--enable_query_log
connection slave;
--replace_column 5 # 6 #
SHOW PROCEDURE STATUS LIKE 'p1';
connection master;
--horizontal_results
let $my_stmt= ALTER PROCEDURE p1 COMMENT "I have been altered";
let $my_master_commit= true;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc
--vertical_results
--replace_column 5 # 6 #
SHOW PROCEDURE STATUS LIKE 'p1';
--disable_query_log
SELECT '-------- switch to slave -------' as "";
--enable_query_log
connection slave;
--replace_column 5 # 6 #
SHOW PROCEDURE STATUS LIKE 'p1';
connection master;
--horizontal_results
let $my_stmt= DROP PROCEDURE p1;
let $my_master_commit= true;
let $my_slave_commit= true;
--source include/rpl_stmt_seq.inc
--vertical_results
SHOW PROCEDURE STATUS LIKE 'p1';
--disable_query_log
SELECT '-------- switch to slave -------' as "";
--enable_query_log
connection slave;
SHOW PROCEDURE STATUS LIKE 'p1';
connection master;
--horizontal_results
###############################################################
# Cleanup
###############################################################
......@@ -349,4 +400,4 @@ DROP DATABASE IF EXISTS mysqltest2;
DROP DATABASE IF EXISTS mysqltest3;
--enable_warnings
# End of 4.1 tests
......@@ -4017,6 +4017,9 @@ end_with_restore_list:
goto error;
}
if (end_active_trans(thd))
goto error;
if (!lex->sphead->m_db.str || !lex->sphead->m_db.str[0])
{
lex->sphead->m_db.length= strlen(thd->db);
......@@ -4271,6 +4274,9 @@ end_with_restore_list:
sp->m_name.str,
lex->sql_command == SQLCOM_ALTER_PROCEDURE, 0))
goto error;
if (end_active_trans(thd))
goto error;
memcpy(&lex->sp_chistics, &chistics, sizeof(lex->sp_chistics));
if (!trust_routine_creators && mysql_bin_log.is_open() &&
!sp->m_chistics->detistic &&
......@@ -4330,6 +4336,9 @@ end_with_restore_list:
if (check_routine_access(thd, ALTER_PROC_ACL, db, name,
lex->sql_command == SQLCOM_DROP_PROCEDURE, 0))
goto error;
if (end_active_trans(thd))
goto error;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (sp_automatic_privileges && !opt_noacl &&
sp_revoke_privileges(thd, db, name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment