1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#
# WL#14722 Support IF NOT EXISTS clause
# in CREATE PROCEDURE/FUNCTION/TRIGGER
#
include/master-slave.inc
Warnings:
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
Note #### Storing MySQL user name or password information in the connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA Syntax' in the MySQL Manual for more information.
[connection master]
# Create objects on source
[On Source]
CREATE TABLE t1 (a INT);
CREATE PROCEDURE IF NOT EXISTS sp1() BEGIN END;
CREATE FUNCTION IF NOT EXISTS sf1() RETURNS INT DETERMINISTIC return 0;
CREATE FUNCTION IF NOT EXISTS metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
CREATE TRIGGER IF NOT EXISTS trg1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN END;
# Check if objects are created on replica
[On Replica]
include/sync_slave_sql_with_master.inc
SELECT routine_name FROM information_schema.routines WHERE routine_schema = "test";
ROUTINE_NAME
sf1
sp1
SELECT name FROM mysql.func WHERE name = 'metaphon';
name
metaphon
SELECT trigger_name FROM information_schema.triggers WHERE trigger_schema = "test";
TRIGGER_NAME
trg1
# Drop objects on replica
DROP PROCEDURE sp1;
DROP FUNCTION sf1;
DROP FUNCTION metaphon;
DROP TRIGGER trg1;
# Create objects with IF NOT EXISTS claus when objects already exist on source.
# These statements should re-create objects on replica
[On Source]
CREATE PROCEDURE IF NOT EXISTS sp1() BEGIN END;
Warnings:
Note 1304 PROCEDURE sp1 already exists
CREATE FUNCTION IF NOT EXISTS sf1() RETURNS INT DETERMINISTIC return 0;
Warnings:
Note 1304 FUNCTION sf1 already exists
CREATE FUNCTION IF NOT EXISTS metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
Warnings:
Note 1125 Function 'metaphon' already exists
CREATE TRIGGER IF NOT EXISTS trg1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN END;
Warnings:
Note 4099 Trigger 'trg1' already exists on the table 'test'.'t1'.
# Check if objects are re-created on replica
[On Replica]
include/sync_slave_sql_with_master.inc
SELECT routine_name FROM information_schema.routines WHERE routine_schema = "test";
ROUTINE_NAME
sf1
sp1
SELECT name FROM mysql.func WHERE name = 'metaphon';
name
metaphon
SELECT trigger_name FROM information_schema.triggers WHERE trigger_schema = "test";
TRIGGER_NAME
trg1
# Cleanup
[On Source]
DROP PROCEDURE sp1;
DROP FUNCTION sf1;
DROP FUNCTION metaphon;
DROP TRIGGER trg1;
DROP TABLE t1;
include/sync_slave_sql_with_master.inc
include/rpl_end.inc
|