~pbms-core/pbms/5.11-beta

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
78
79
80
--TEST--
mysqldump with BLOBs
--SKIPIF--
<?php if (!extension_loaded("PBMS")) print "skip"; ?>
--POST--
--GET--
--FILE--
<?php 

	include "pbms_utils.php";

	pbms_connect($host, $port, $database)
		or pbms_error_and_die("Could not connect\n");
		
	print "Connected successfully\n";
	
	$mysql = mysql_connect()
		or mysql_error_and_die("Could not connect\n");

	mysql_query("Drop database $database;");
		
	init_php_test_database($mysql, $engine, $database);

	mysql_query("Use $database;")
		or mysql_error_and_die("Use $database; failed\n");
	
	mysql_query("Delete from test1; ")
		or mysql_error_and_die("Delete from test1; Failed: \n" );

	load_backup_test_data();
	
	// make sure that the system table pbms_dump has been found
	// by MySQL or else it will not be backed up.
	mysql_query("select count(*) from pbms_dump where false;")
		or mysql_error_and_die("select count(*) from pbms_dump where false;");	
	
	print "Executing: mysqldump -u root --hex-blob $database > dumptest.sql\n";
	system("$mysqlServerInst/bin/mysqldump -u root --hex-blob $database > dumptest.sql");
//die("Stop here.\n");

	// Drop the table before droping the database just to test
	// that the transaction logging handles this correctly since it
	// will probably still have unprocessed transaction records for  the
	// database being dropped.
	mysql_query("Drop table test1; ")
		or mysql_error_and_die("Drop table test1; Failed: \n" );

	mysql_query("Drop database $database;")
		or mysql_error_and_die("Drop database $database failed\n");
		
	init_php_test_database($mysql, $engine, $database);
	
	// create database php_test
	//update php_test.pbms_variable set Value = 'true' where Name = 'Restoring-Dump' 
	// mysql -u root -D php_test -e 'source dumptest.sql;'
	mysql_query("update pbms_variable set Value = 'true' where Name = 'Restoring-Dump' ")
		or mysql_error_and_die("Query Failed: update pbms_variable set Value = 'true' where Name = 'Restoring-Dump'\n");

	print "Executing: mysql -u root -D $database -e 'source dumptest.sql;'\n";
	system("$mysqlServerInst/bin/mysql -u root -D $database -e 'source dumptest.sql;'");

	mysql_query("update pbms_variable set Value = 'false' where Name = 'Restoring-Dump' ")
		or mysql_error_and_die("Query Failed: update pbms_variable set Value = 'false' where Name = 'Restoring-Dump' \n");
	
	print "Verifying backup\n";
	verify_backup_test_data();
	
	print "mysqldump with BLOBs done.\n";
		
	// Closing connection
	pbms_close();
	mysql_close($mysql);
?>
--EXPECT--
Connected successfully
Executing: mysqldump -u root --hex-blob PHP_TEST > dumptest.sql
Executing: mysql -u root -D PHP_TEST -e 'source dumptest.sql;'
Verifying backup
mysqldump with BLOBs done.