
starting the test for backup

DROP DATABASE IF EXISTS bup_sp;
CREATE DATABASE bup_sp;
USE bup_sp;
*******Creating table******
CREATE TABLE bup_sp.country(
ccode CHAR(10),
city VARCHAR(10)
) ENGINE=MYISAM;
*********loading data*********
INSERT INTO bup_sp.country VALUES
('IND','chennai'),('US','sfo'),('US','austin'),
('IND','Bomb'),('US','Richmond'),('IND','hyd');
SELECT * FROM bup_sp.country ORDER BY ccode, city;
ccode	city
IND	Bomb
IND	chennai
IND	hyd
US	austin
US	Richmond
US	sfo
CREATE PROCEDURE countryinfo (IN loc CHAR(5))
BEGIN
SELECT * FROM country WHERE ccode=loc;
END;
||
CREATE PROCEDURE dorepeat(p1 INT)
BEGIN
SET @x = 0;
REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;
END ;||
CALL countryinfo('US');
ccode	city
US	sfo
US	austin
US	Richmond
CALL countryinfo('IND');
ccode	city
IND	chennai
IND	Bomb
IND	hyd
CALL dorepeat(1000);
SELECT @x;
@x
1001
showing objects and create statements.
SHOW CREATE PROCEDURE countryinfo;;
Procedure	countryinfo
sql_mode	
Create Procedure	CREATE DEFINER=`root`@`localhost` PROCEDURE `countryinfo`(IN loc CHAR(5))
BEGIN
SELECT * FROM country WHERE ccode=loc;
END
character_set_client	latin1
collation_connection	latin1_swedish_ci
Database Collation	latin1_swedish_ci
SHOW CREATE TABLE country;;
Table	country
Create Table	CREATE TABLE `country` (
  `ccode` char(10) DEFAULT NULL,
  `city` varchar(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SHOW PROCEDURE STATUS WHERE Db <> 'mtr';;
Db	bup_sp
Name	countryinfo
Type	PROCEDURE
Definer	#
Modified	#
Created	#
Security_type	#
Comment	
character_set_client	latin1
collation_connection	latin1_swedish_ci
Database Collation	latin1_swedish_ci
Db	bup_sp
Name	dorepeat
Type	PROCEDURE
Definer	#
Modified	#
Created	#
Security_type	#
Comment	
character_set_client	latin1
collation_connection	latin1_swedish_ci
Database Collation	latin1_swedish_ci
backup data

BACKUP DATABASE bup_sp TO 'bup_sp.bak';
backup_id
#
dropping  database.
DROP DATABASE bup_sp;

RESTORE FROM 'bup_sp.bak';
backup_id
#
showing objects and create statements
SHOW CREATE PROCEDURE countryinfo;;
Procedure	countryinfo
sql_mode	
Create Procedure	CREATE DEFINER=`root`@`localhost` PROCEDURE `countryinfo`(IN loc CHAR(5))
BEGIN
SELECT * FROM country WHERE ccode=loc;
END
character_set_client	latin1
collation_connection	latin1_swedish_ci
Database Collation	latin1_swedish_ci
SHOW CREATE TABLE country;;
Table	country
Create Table	CREATE TABLE `country` (
  `ccode` char(10) DEFAULT NULL,
  `city` varchar(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SHOW PROCEDURE STATUS WHERE Db <> 'mtr';;
Db	bup_sp
Name	countryinfo
Type	PROCEDURE
Definer	#
Modified	#
Created	#
Security_type	#
Comment	
character_set_client	latin1
collation_connection	latin1_swedish_ci
Database Collation	latin1_swedish_ci
Db	bup_sp
Name	dorepeat
Type	PROCEDURE
Definer	#
Modified	#
Created	#
Security_type	#
Comment	
character_set_client	latin1
collation_connection	latin1_swedish_ci
Database Collation	latin1_swedish_ci
INSERT INTO bup_sp.country VALUES
('US','boston'),('IND','jaipur'),('US','natick');
SELECT * FROM bup_sp.country ORDER BY  ccode, city;
ccode	city
IND	Bomb
IND	chennai
IND	hyd
IND	jaipur
US	austin
US	boston
US	natick
US	Richmond
US	sfo
CALL countryinfo('IND');
ccode	city
IND	chennai
IND	Bomb
IND	hyd
IND	jaipur
CALL countryinfo('US');
ccode	city
US	sfo
US	austin
US	Richmond
US	boston
US	natick
CALL dorepeat(99);
SELECT @x;
@x
100

***  DROP bup_sp DATABASE ****

DROP DATABASE bup_sp;

Starting regression test for 34868 - Backup: restore failure if two procedures

Create database and procedures
DROP DATABASE IF EXISTS bup_proc;
CREATE DATABASE bup_proc;
USE bup_proc;
CREATE PROCEDURE p1() SET @a=5;
CREATE PROCEDURE p2() SET @a=100;

Check that procedures are there before the backup
CALL p1();
SELECT @a;
@a
5
CALL p2();
SELECT @a;
@a
100

Backup and restore
BACKUP DATABASE bup_proc to 'bup_proc.bak';
backup_id
#
DROP DATABASE bup_proc;
RESTORE FROM 'bup_proc.bak';
backup_id
#

Check that procedures are there after the restore
CALL p1();
SELECT @a;
@a
5
CALL p2();
SELECT @a;
@a
100

Cleaning up
DROP DATABASE bup_proc;
