forked from ifsnop/mysqldump-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for utf8mb4 character sets. Closes ifsnop#73
- Loading branch information
Showing
6 changed files
with
114 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,87 @@ | ||
#!/bin/bash | ||
|
||
function checksum() { | ||
function checksum_test001() { | ||
for i in 000 001 002 003 010 011 015 027 029 033 200; do | ||
mysql -B -e "CHECKSUM TABLE test${i}" test001 | grep -v -i checksum | ||
done | ||
} | ||
|
||
function checksum_test002() { | ||
for i in 201; do | ||
mysql --default-character-set=utf8mb4 -B -e "CHECKSUM TABLE test${i}" test002 | grep -v -i checksum | ||
done | ||
} | ||
|
||
for i in $(seq 0 20) ; do | ||
ret[i]=0 | ||
ret[$i]=0 | ||
done | ||
|
||
mysql -uroot < original.sql | ||
ret[0]=$? | ||
mysql -e "CREATE USER 'travis'@'localhost' IDENTIFIED BY '';" 2> /dev/null | ||
mysql -e "GRANT ALL PRIVILEGES ON test001.* TO 'travis'@'localhost';" 2> /dev/null | ||
mysql -e "GRANT ALL PRIVILEGES ON test002.* TO 'travis'@'localhost';" 2> /dev/null | ||
|
||
mysql -uroot < test001.src.sql; ret[0]=$? | ||
|
||
mysql -uroot --default-character-set=utf8mb4 < test002.src.sql; ret[1]=$? | ||
|
||
checksum > original.checksum | ||
checksum_test001 > test001.src.checksum | ||
checksum_test002 > test002.src.checksum | ||
|
||
mysqldump -uroot test001 \ | ||
--no-autocommit \ | ||
--extended-insert=false \ | ||
--hex-blob=true \ | ||
> mysqldump.sql | ||
ret[1]=$? | ||
|
||
php test.php | ||
> mysqldump_test001.sql | ||
ret[2]=$? | ||
|
||
mysql -uroot test001 < mysqldump-php.sql | ||
mysqldump -uroot test002 \ | ||
--no-autocommit \ | ||
--extended-insert=false \ | ||
--hex-blob=true \ | ||
--default-character-set=utf8mb4 \ | ||
> mysqldump_test002.sql | ||
ret[3]=$? | ||
|
||
checksum > mysqldump-php.checksum | ||
|
||
cat original.sql | grep ^INSERT > original.filtered.sql | ||
cat mysqldump.sql | grep ^INSERT > mysqldump.filtered.sql | ||
cat mysqldump-php.sql | grep ^INSERT > mysqldump-php.filtered.sql | ||
|
||
diff original.filtered.sql mysqldump.filtered.sql | ||
php test.php | ||
ret[4]=$? | ||
|
||
diff original.filtered.sql mysqldump-php.filtered.sql | ||
mysql -uroot test001 < mysqldump-php_test001.sql | ||
ret[5]=$? | ||
|
||
diff original.checksum mysqldump-php.checksum | ||
mysql -uroot test002 < mysqldump-php_test002.sql | ||
ret[6]=$? | ||
|
||
rm original.checksum | ||
rm mysqldump-php.checksum | ||
rm original.filtered.sql | ||
rm mysqldump.filtered.sql | ||
rm mysqldump-php.filtered.sql | ||
rm mysqldump-php.sql | ||
rm mysqldump.sql | ||
checksum_test001 > mysqldump-php_test001.checksum | ||
checksum_test002 > mysqldump-php_test002.checksum | ||
|
||
cat test001.src.sql | grep ^INSERT > test001.filtered.sql | ||
cat test002.src.sql | grep ^INSERT > test002.filtered.sql | ||
cat mysqldump_test001.sql | grep ^INSERT > mysqldump_test001.filtered.sql | ||
cat mysqldump_test002.sql | grep ^INSERT > mysqldump_test002.filtered.sql | ||
cat mysqldump-php_test001.sql | grep ^INSERT > mysqldump-php_test001.filtered.sql | ||
cat mysqldump-php_test002.sql | grep ^INSERT > mysqldump-php_test002.filtered.sql | ||
|
||
diff test001.filtered.sql mysqldump_test001.filtered.sql | ||
ret[7]=$? | ||
diff test002.filtered.sql mysqldump_test002.filtered.sql | ||
ret[8]=$? | ||
|
||
diff test001.filtered.sql mysqldump-php_test001.filtered.sql | ||
ret[9]=$? | ||
diff test002.filtered.sql mysqldump-php_test002.filtered.sql | ||
ret[10]=$? | ||
|
||
diff test001.src.checksum mysqldump-php_test001.checksum | ||
ret[11]=$? | ||
diff test002.src.checksum mysqldump-php_test002.checksum | ||
ret[12]=$? | ||
|
||
rm *.checksum 2> /dev/null | ||
rm *.filtered.sql 2> /dev/null | ||
rm mysqldump* 2> /dev/null | ||
|
||
total=0 | ||
for i in $(seq 0 20) ; do | ||
total=(${ret[i]} + $total) | ||
total=$((${ret[$i]} + $total)) | ||
done | ||
|
||
exit $total |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
DROP DATABASE IF EXISTS `test002`; | ||
CREATE DATABASE `test002`; | ||
USE `test002`; | ||
|
||
DROP TABLE IF EXISTS `test201`; | ||
CREATE TABLE `test201` ( | ||
`col` text COLLATE utf8mb4_unicode_ci | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; | ||
|
||
INSERT INTO `test201` VALUES ('áéíóú'); | ||
INSERT INTO `test201` VALUES ('🎲'); | ||
INSERT INTO `test201` VALUES ('🎭'); | ||
INSERT INTO `test201` VALUES ('💩'); |