mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.1-new-rpl
into mysql.com:/nfsdisk1/lars/MERGE/mysql-5.1-merge mysql-test/t/disabled.def: Auto merged sql/item_sum.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_yacc.yy: Auto merged include/my_base.h: Manual merge main->rpl 5.1 mysql-test/t/innodb.test: Manual merge main->rpl 5.1
This commit is contained in:
@ -13,52 +13,63 @@ drop table if exists t1,t2;
|
||||
# first, we need a table to record something from an event
|
||||
|
||||
eval CREATE TABLE `t1` (
|
||||
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id` INT(10) UNSIGNED NOT NULL,
|
||||
`c` VARCHAR(50) NOT NULL,
|
||||
`ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=$engine_type DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO t1 (c) VALUES ('manually');
|
||||
INSERT INTO t1 (id, c) VALUES (1, 'manually');
|
||||
|
||||
# then, we create the event
|
||||
CREATE EVENT test.justonce ON SCHEDULE AT NOW() + INTERVAL 2 SECOND DO INSERT INTO t1
|
||||
(c) VALUES ('from justonce');
|
||||
# We create the event so that it inserts exactly 1 row in the table
|
||||
# A recuring event is used so that we can be sure the event will
|
||||
# fire regardless of timing delays on the server. Otherwise, it is
|
||||
# possible for the event to timeout before it has inserted a row.
|
||||
--echo "Creating event test.justonce on the master"
|
||||
CREATE EVENT test.justonce ON SCHEDULE EVERY 2 SECOND DO
|
||||
INSERT IGNORE INTO t1 (id, c) VALUES (2, 'from justonce');
|
||||
|
||||
# Show the event is alive and present on master
|
||||
--echo "Checking event is active on master"
|
||||
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'justonce';
|
||||
|
||||
# wait 3 seconds, so the event can trigger
|
||||
--real_sleep 3
|
||||
let $wait_condition=
|
||||
SELECT count(*) = 1 FROM t1 WHERE c = 'from justonce';
|
||||
--source include/wait_condition.inc
|
||||
# Wait until event has fired. We know this because t1 will contain
|
||||
# the row from the event.
|
||||
let $wait_condition=
|
||||
SELECT COUNT(*) = 1 FROM t1 WHERE c = 'from justonce';
|
||||
--source include/wait_condition.inc
|
||||
|
||||
# check that table t1 contains something
|
||||
--echo "in the master"
|
||||
--echo "Checking event data on the master"
|
||||
--enable_info
|
||||
--replace_column 3 TIMESTAMP
|
||||
SELECT * FROM t1 WHERE c = 'from justonce' OR c = 'manually' ORDER BY id;
|
||||
SELECT * FROM t1 ORDER BY id;
|
||||
--disable_info
|
||||
|
||||
sync_slave_with_master;
|
||||
|
||||
--echo "in the slave"
|
||||
--echo "Checking event data on the slave"
|
||||
--enable_info
|
||||
--replace_column 3 TIMESTAMP
|
||||
SELECT * FROM t1 WHERE c = 'from justonce' OR c = 'manually' ORDER BY id;
|
||||
SELECT * FROM t1 ORDER BY id;
|
||||
--disable_info
|
||||
|
||||
--echo "Checking event is inactive on slave"
|
||||
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'justonce';
|
||||
|
||||
# Create an event on the slave and check to see what the originator is.
|
||||
--echo "Dropping event test.slave_once on the slave"
|
||||
--disable_warnings
|
||||
DROP EVENT IF EXISTS test.slave_once;
|
||||
--enable_warnings
|
||||
|
||||
CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE DO
|
||||
INSERT INTO t1(c) VALUES ('from slave_once');
|
||||
INSERT IGNORE INTO t1(id, c) VALUES (3, 'from slave_once');
|
||||
|
||||
--echo "Checking event status on the slave for originator value = slave's server_id"
|
||||
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_once';
|
||||
|
||||
--echo "Dropping event test.slave_once on the slave"
|
||||
--disable_warnings
|
||||
DROP EVENT IF EXISTS test.slave_once;
|
||||
--enable_warnings
|
||||
@ -66,57 +77,74 @@ DROP EVENT IF EXISTS test.slave_once;
|
||||
connection master;
|
||||
|
||||
# BUG#20384 - disable events on slave
|
||||
--echo "Dropping event test.justonce on the master"
|
||||
--disable_warnings
|
||||
DROP EVENT IF EXISTS test.justonce;
|
||||
--enable_warnings
|
||||
|
||||
--echo "Creating event test.er on the master"
|
||||
CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND DO
|
||||
INSERT INTO t1(c) VALUES ('from er');
|
||||
INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er');
|
||||
|
||||
--echo "Checking event status on the master"
|
||||
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er';
|
||||
|
||||
sync_slave_with_master;
|
||||
|
||||
--echo "in the slave"
|
||||
--echo "Checking event status on the slave"
|
||||
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er';
|
||||
|
||||
connection master;
|
||||
--echo "in the master"
|
||||
ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND DO INSERT into t1(c) VALUES ('from alter er');
|
||||
--echo "Altering event test.er on the master"
|
||||
ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND DO
|
||||
INSERT IGNORE INTO t1(id, c) VALUES (5, 'from alter er');
|
||||
|
||||
--echo "Checking event status on the master"
|
||||
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er';
|
||||
|
||||
sync_slave_with_master;
|
||||
|
||||
--echo "in the slave"
|
||||
--echo "Checking event status on the slave"
|
||||
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er';
|
||||
|
||||
connection master;
|
||||
--echo "in the master"
|
||||
--echo "Dropping event test.er on the master"
|
||||
DROP EVENT test.er;
|
||||
|
||||
--echo "Checking event status on the master"
|
||||
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test';
|
||||
|
||||
--disable_info
|
||||
|
||||
sync_slave_with_master;
|
||||
|
||||
--echo "in the slave"
|
||||
--echo "Checking event status on the slave"
|
||||
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test';
|
||||
|
||||
# test the DISABLE ON SLAVE for setting event SLAVESIDE_DISABLED as status
|
||||
# on CREATE EVENT
|
||||
|
||||
CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND
|
||||
DO INSERT INTO t1(c) VALUES ('from slave_terminate');
|
||||
--echo "Creating event test.slave_terminate on the slave"
|
||||
CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND DO
|
||||
INSERT IGNORE INTO t1(id, c) VALUES (6, 'from slave_terminate');
|
||||
|
||||
--echo "Checking event status on the slave"
|
||||
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_terminate';
|
||||
|
||||
--echo "Dropping event test.slave_terminate on the slave"
|
||||
DROP EVENT test.slave_terminate;
|
||||
|
||||
CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND
|
||||
DISABLE ON SLAVE DO INSERT INTO t1(c) VALUES ('from slave_terminate');
|
||||
--echo "Creating event test.slave_terminate with DISABLE ON SLAVE on the slave"
|
||||
CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND DISABLE ON SLAVE DO
|
||||
INSERT IGNORE INTO t1(c) VALUES (7, 'from slave_terminate');
|
||||
|
||||
--echo "Checking event status on the slave"
|
||||
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_terminate';
|
||||
|
||||
--echo "Dropping event test.slave_terminate on the slave"
|
||||
DROP EVENT test.slave_terminate;
|
||||
|
||||
--echo "in the master"
|
||||
--echo "Cleanup"
|
||||
connection master;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
13
mysql-test/include/select_ndb_apply_status.inc
Normal file
13
mysql-test/include/select_ndb_apply_status.inc
Normal file
@ -0,0 +1,13 @@
|
||||
##################################################
|
||||
# Author: Jeb
|
||||
# Date: 2007/04
|
||||
# Purpose: To select out log name, start and end
|
||||
# positions from ndb_apply_status table
|
||||
##################################################
|
||||
--replace_column 1 <log_name> 2 <start_pos> 3 <end_pos>
|
||||
select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
|
||||
from mysql.ndb_apply_status;
|
||||
--let $start_pos = `select @start_pos`
|
||||
--let $end_pos = `select @end_pos`
|
||||
--let $log_name = `select @log_name`
|
||||
|
13
mysql-test/include/show_binlog_using_logname.inc
Normal file
13
mysql-test/include/show_binlog_using_logname.inc
Normal file
@ -0,0 +1,13 @@
|
||||
########################################################
|
||||
# Author: Jeb
|
||||
# Date: 2007/04
|
||||
# Purpose: To select out 1 row from offset 1
|
||||
# from the start position in the binlog whose
|
||||
# name is = log_name
|
||||
########################################################
|
||||
|
||||
--replace_result $start_pos <start_pos> $end_pos <end_pos>
|
||||
--replace_column 2 #
|
||||
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
|
||||
--eval show binlog events in '$log_name' from $start_pos limit $off_set,1
|
||||
|
155
mysql-test/include/tpcb.inc
Normal file
155
mysql-test/include/tpcb.inc
Normal file
@ -0,0 +1,155 @@
|
||||
##################################################
|
||||
# Author: Jeb
|
||||
# Date: 2007/04
|
||||
# Purpose: To create a tpcb database, tables and
|
||||
# stored procedures to load the database
|
||||
# and run transactions against the DB
|
||||
##################################################
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS tpcb;
|
||||
--enable_warnings
|
||||
CREATE DATABASE tpcb;
|
||||
|
||||
--echo
|
||||
CREATE TABLE tpcb.account (id INT, bid INT, balance DECIMAL(10,2),
|
||||
filler CHAR(255), PRIMARY KEY(id));
|
||||
--echo
|
||||
CREATE TABLE tpcb.branch (bid INT, balance DECIMAL(10,2), filler VARCHAR(255),
|
||||
PRIMARY KEY(bid));
|
||||
--echo
|
||||
CREATE TABLE tpcb.teller (tid INT, balance DECIMAL(10,2), filler VARCHAR(255),
|
||||
PRIMARY KEY(tid));
|
||||
--echo
|
||||
CREATE TABLE tpcb.history (id MEDIUMINT NOT NULL AUTO_INCREMENT,aid INT,
|
||||
tid INT, bid INT, amount DECIMAL(10,2),
|
||||
tdate DATETIME, teller CHAR(20), uuidf LONGBLOB,
|
||||
filler CHAR(80),PRIMARY KEY (id));
|
||||
|
||||
--echo
|
||||
--echo --- Create stored procedures & functions ---
|
||||
--echo
|
||||
|
||||
--disable_query_log
|
||||
delimiter |;
|
||||
CREATE PROCEDURE tpcb.load()
|
||||
BEGIN
|
||||
DECLARE acct INT DEFAULT 100;
|
||||
DECLARE brch INT DEFAULT 10;
|
||||
DECLARE tell INT DEFAULT 100;
|
||||
DECLARE tmp INT DEFAULT 10;
|
||||
WHILE brch > 0 DO
|
||||
SET tmp = 100;
|
||||
WHILE tmp > 0 DO
|
||||
INSERT INTO tpcb.account VALUES (acct, brch, 0.0, "FRESH ACCOUNT");
|
||||
SET acct = acct - 1;
|
||||
SET tmp = tmp -1;
|
||||
END WHILE;
|
||||
INSERT INTO tpcb.branch VALUES (brch, 0.0, "FRESH BRANCH");
|
||||
SET brch = brch - 1;
|
||||
END WHILE;
|
||||
WHILE tell > 0 DO
|
||||
INSERT INTO tpcb.teller VALUES (tell, 0.0, "FRESH TELLER");
|
||||
SET tell = tell - 1;
|
||||
END WHILE;
|
||||
END|
|
||||
|
||||
CREATE FUNCTION tpcb.account_id () RETURNS INT
|
||||
BEGIN
|
||||
DECLARE num INT;
|
||||
DECLARE ran INT;
|
||||
SELECT RAND() * 10 INTO ran;
|
||||
IF (ran < 5)
|
||||
THEN
|
||||
SELECT RAND() * 10 INTO num;
|
||||
ELSE
|
||||
SELECT RAND() * 100 INTO num;
|
||||
END IF;
|
||||
IF (num < 1)
|
||||
THEN
|
||||
RETURN 1;
|
||||
END IF;
|
||||
RETURN num;
|
||||
END|
|
||||
|
||||
CREATE FUNCTION tpcb.teller_id () RETURNS INT
|
||||
BEGIN
|
||||
DECLARE num INT;
|
||||
DECLARE ran INT;
|
||||
SELECT RAND() * 10 INTO ran;
|
||||
IF (ran < 5)
|
||||
THEN
|
||||
SELECT RAND() * 10 INTO num;
|
||||
ELSE
|
||||
SELECT RAND() * 100 INTO num;
|
||||
END IF;
|
||||
IF (num < 1)
|
||||
THEN
|
||||
RETURN 1;
|
||||
END IF;
|
||||
RETURN num;
|
||||
END|
|
||||
|
||||
CREATE PROCEDURE tpcb.trans(in format varchar(3))
|
||||
BEGIN
|
||||
DECLARE acct INT DEFAULT 0;
|
||||
DECLARE brch INT DEFAULT 0;
|
||||
DECLARE tell INT DEFAULT 0;
|
||||
DECLARE bal DECIMAL(10,2) DEFAULT 0.0;
|
||||
DECLARE amount DECIMAL(10,2) DEFAULT 1.00;
|
||||
DECLARE test INT DEFAULT 0;
|
||||
DECLARE bbal DECIMAL(10,2) DEFAULT 0.0;
|
||||
DECLARE tbal DECIMAL(10,2) DEFAULT 0.0;
|
||||
DECLARE local_uuid VARCHAR(255);
|
||||
DECLARE local_user VARCHAR(255);
|
||||
DECLARE local_time TIMESTAMP;
|
||||
|
||||
SELECT RAND() * 10 INTO test;
|
||||
SELECT tpcb.account_id() INTO acct;
|
||||
SELECT tpcb.teller_id() INTO tell;
|
||||
|
||||
SELECT account.balance INTO bal FROM tpcb.account WHERE id = acct;
|
||||
SELECT account.bid INTO brch FROM tpcb.account WHERE id = acct;
|
||||
SELECT teller.balance INTO tbal FROM tpcb.teller WHERE tid = tell;
|
||||
SELECT branch.balance INTO bbal FROM tpcb.branch WHERE bid = brch;
|
||||
|
||||
IF (test < 5)
|
||||
THEN
|
||||
SET bal = bal + amount;
|
||||
SET bbal = bbal + amount;
|
||||
SET tbal = tbal + amount;
|
||||
UPDATE tpcb.account SET balance = bal, filler = 'account updated'
|
||||
WHERE id = acct;
|
||||
UPDATE tpcb.branch SET balance = bbal, filler = 'branch updated'
|
||||
WHERE bid = brch;
|
||||
UPDATE tpcb.teller SET balance = tbal, filler = 'teller updated'
|
||||
WHERE tid = tell;
|
||||
ELSE
|
||||
SET bal = bal - amount;
|
||||
SET bbal = bbal - amount;
|
||||
SET tbal = tbal - amount;
|
||||
UPDATE tpcb.account SET balance = bal, filler = 'account updated'
|
||||
WHERE id = acct;
|
||||
UPDATE tpcb.branch SET balance = bbal, filler = 'branch updated'
|
||||
WHERE bid = brch;
|
||||
UPDATE tpcb.teller SET balance = tbal, filler = 'teller updated'
|
||||
WHERE tid = tell;
|
||||
END IF;
|
||||
|
||||
IF (format = 'SBR')
|
||||
THEN
|
||||
SET local_uuid=UUID();
|
||||
SET local_user=USER();
|
||||
SET local_time= NOW();
|
||||
INSERT INTO tpcb.history VALUES(NULL,acct,tell,brch,amount, local_time,local_user,
|
||||
local_uuid,'completed trans');
|
||||
ELSE
|
||||
INSERT INTO tpcb.history VALUES(NULL,acct,tell,brch,amount, NOW(), USER(),
|
||||
UUID(),'completed trans');
|
||||
END IF;
|
||||
END|
|
||||
delimiter ;|
|
||||
--enable_query_log
|
||||
--echo
|
||||
--echo *** Stored Procedures Created ***
|
||||
--echo
|
||||
|
166
mysql-test/include/tpcb_disk_data.inc
Normal file
166
mysql-test/include/tpcb_disk_data.inc
Normal file
@ -0,0 +1,166 @@
|
||||
##################################################
|
||||
# Author: Jeb
|
||||
# Date: 2007/05
|
||||
# Purpose: To create a tpcb database using Disk Data,
|
||||
# tables and stored procedures to load the database
|
||||
# and run transactions against the DB
|
||||
##################################################
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS tpcb;
|
||||
--enable_warnings
|
||||
CREATE DATABASE tpcb;
|
||||
|
||||
--echo
|
||||
eval CREATE TABLE tpcb.account
|
||||
(id INT, bid INT, balance DECIMAL(10,2),
|
||||
filler CHAR(255), PRIMARY KEY(id))
|
||||
TABLESPACE $table_space STORAGE DISK
|
||||
ENGINE=$engine_type;
|
||||
--echo
|
||||
eval CREATE TABLE tpcb.branch
|
||||
(bid INT, balance DECIMAL(10,2), filler VARCHAR(255),
|
||||
PRIMARY KEY(bid))TABLESPACE $table_space STORAGE DISK
|
||||
ENGINE=$engine_type;
|
||||
--echo
|
||||
eval CREATE TABLE tpcb.teller
|
||||
(tid INT, balance DECIMAL(10,2), filler VARCHAR(255),
|
||||
PRIMARY KEY(tid)) TABLESPACE $table_space STORAGE DISK
|
||||
ENGINE=$engine_type;
|
||||
|
||||
--echo
|
||||
eval CREATE TABLE tpcb.history
|
||||
(id MEDIUMINT NOT NULL AUTO_INCREMENT,aid INT,
|
||||
tid INT, bid INT, amount DECIMAL(10,2),
|
||||
tdate DATETIME, teller CHAR(20), uuidf LONGBLOB,
|
||||
filler CHAR(80),PRIMARY KEY (id))
|
||||
TABLESPACE $table_space STORAGE DISK
|
||||
ENGINE=$engine_type;
|
||||
|
||||
--echo
|
||||
--echo --- Create stored procedures & functions ---
|
||||
--echo
|
||||
|
||||
--disable_query_log
|
||||
delimiter |;
|
||||
CREATE PROCEDURE tpcb.load()
|
||||
BEGIN
|
||||
DECLARE acct INT DEFAULT 100;
|
||||
DECLARE brch INT DEFAULT 10;
|
||||
DECLARE tell INT DEFAULT 100;
|
||||
DECLARE tmp INT DEFAULT 10;
|
||||
WHILE brch > 0 DO
|
||||
SET tmp = 100;
|
||||
WHILE tmp > 0 DO
|
||||
INSERT INTO tpcb.account VALUES (acct, brch, 0.0, "FRESH ACCOUNT");
|
||||
SET acct = acct - 1;
|
||||
SET tmp = tmp -1;
|
||||
END WHILE;
|
||||
INSERT INTO tpcb.branch VALUES (brch, 0.0, "FRESH BRANCH");
|
||||
SET brch = brch - 1;
|
||||
END WHILE;
|
||||
WHILE tell > 0 DO
|
||||
INSERT INTO tpcb.teller VALUES (tell, 0.0, "FRESH TELLER");
|
||||
SET tell = tell - 1;
|
||||
END WHILE;
|
||||
END|
|
||||
|
||||
CREATE FUNCTION tpcb.account_id () RETURNS INT
|
||||
BEGIN
|
||||
DECLARE num INT;
|
||||
DECLARE ran INT;
|
||||
SELECT RAND() * 10 INTO ran;
|
||||
IF (ran < 5)
|
||||
THEN
|
||||
SELECT RAND() * 10 INTO num;
|
||||
ELSE
|
||||
SELECT RAND() * 100 INTO num;
|
||||
END IF;
|
||||
IF (num < 1)
|
||||
THEN
|
||||
RETURN 1;
|
||||
END IF;
|
||||
RETURN num;
|
||||
END|
|
||||
|
||||
CREATE FUNCTION tpcb.teller_id () RETURNS INT
|
||||
BEGIN
|
||||
DECLARE num INT;
|
||||
DECLARE ran INT;
|
||||
SELECT RAND() * 10 INTO ran;
|
||||
IF (ran < 5)
|
||||
THEN
|
||||
SELECT RAND() * 10 INTO num;
|
||||
ELSE
|
||||
SELECT RAND() * 100 INTO num;
|
||||
END IF;
|
||||
IF (num < 1)
|
||||
THEN
|
||||
RETURN 1;
|
||||
END IF;
|
||||
RETURN num;
|
||||
END|
|
||||
|
||||
CREATE PROCEDURE tpcb.trans(in format varchar(3))
|
||||
BEGIN
|
||||
DECLARE acct INT DEFAULT 0;
|
||||
DECLARE brch INT DEFAULT 0;
|
||||
DECLARE tell INT DEFAULT 0;
|
||||
DECLARE bal DECIMAL(10,2) DEFAULT 0.0;
|
||||
DECLARE amount DECIMAL(10,2) DEFAULT 1.00;
|
||||
DECLARE test INT DEFAULT 0;
|
||||
DECLARE bbal DECIMAL(10,2) DEFAULT 0.0;
|
||||
DECLARE tbal DECIMAL(10,2) DEFAULT 0.0;
|
||||
DECLARE local_uuid VARCHAR(255);
|
||||
DECLARE local_user VARCHAR(255);
|
||||
DECLARE local_time TIMESTAMP;
|
||||
|
||||
SELECT RAND() * 10 INTO test;
|
||||
SELECT tpcb.account_id() INTO acct;
|
||||
SELECT tpcb.teller_id() INTO tell;
|
||||
|
||||
SELECT account.balance INTO bal FROM tpcb.account WHERE id = acct;
|
||||
SELECT account.bid INTO brch FROM tpcb.account WHERE id = acct;
|
||||
SELECT teller.balance INTO tbal FROM tpcb.teller WHERE tid = tell;
|
||||
SELECT branch.balance INTO bbal FROM tpcb.branch WHERE bid = brch;
|
||||
|
||||
IF (test < 5)
|
||||
THEN
|
||||
SET bal = bal + amount;
|
||||
SET bbal = bbal + amount;
|
||||
SET tbal = tbal + amount;
|
||||
UPDATE tpcb.account SET balance = bal, filler = 'account updated'
|
||||
WHERE id = acct;
|
||||
UPDATE tpcb.branch SET balance = bbal, filler = 'branch updated'
|
||||
WHERE bid = brch;
|
||||
UPDATE tpcb.teller SET balance = tbal, filler = 'teller updated'
|
||||
WHERE tid = tell;
|
||||
ELSE
|
||||
SET bal = bal - amount;
|
||||
SET bbal = bbal - amount;
|
||||
SET tbal = tbal - amount;
|
||||
UPDATE tpcb.account SET balance = bal, filler = 'account updated'
|
||||
WHERE id = acct;
|
||||
UPDATE tpcb.branch SET balance = bbal, filler = 'branch updated'
|
||||
WHERE bid = brch;
|
||||
UPDATE tpcb.teller SET balance = tbal, filler = 'teller updated'
|
||||
WHERE tid = tell;
|
||||
END IF;
|
||||
|
||||
IF (format = 'SBR')
|
||||
THEN
|
||||
SET local_uuid=UUID();
|
||||
SET local_user=USER();
|
||||
SET local_time= NOW();
|
||||
INSERT INTO tpcb.history VALUES(NULL,acct,tell,brch,amount, local_time,local_user,
|
||||
local_uuid,'completed trans');
|
||||
ELSE
|
||||
INSERT INTO tpcb.history VALUES(NULL,acct,tell,brch,amount, NOW(), USER(),
|
||||
UUID(),'completed trans');
|
||||
END IF;
|
||||
END|
|
||||
delimiter ;|
|
||||
--enable_query_log
|
||||
--echo
|
||||
--echo *** Stored Procedures Created ***
|
||||
--echo
|
||||
|
Reference in New Issue
Block a user