Skip to content

Commit

Permalink
don't break compatibility with old no-data trigger and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ifsnop committed Oct 13, 2016
1 parent a4ea014 commit c225512
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 36 deletions.
7 changes: 5 additions & 2 deletions src/Ifsnop/Mysqldump/Mysqldump.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,14 @@ private function exportTables()
continue;
}
$this->getTableStructure($table);
if ( true === $this->dumpSettings['no-data']
if ( false === $this->dumpSettings['no-data'] ) { // don't break compatibility with old trigger
$this->listValues($table);
} else if ( true === $this->dumpSettings['no-data']
|| $this->matches($table, $this->dumpSettings['no-data']) ) {
continue;
} else {
$this->listValues($table);
}
$this->listValues($table);
}
}

Expand Down
16 changes: 16 additions & 0 deletions tests/create_users.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

mysql -e "CREATE USER 'travis'@'%';"
mysql -e "CREATE DATABASE test001;"
mysql -e "CREATE DATABASE test002;"
mysql -e "CREATE DATABASE test005;"
mysql -e "CREATE DATABASE test006a;"
mysql -e "CREATE DATABASE test006b;"
mysql -e "GRANT ALL PRIVILEGES ON test001.* TO 'travis'@'%' WITH GRANT OPTION;"
mysql -e "GRANT ALL PRIVILEGES ON test002.* TO 'travis'@'%' WITH GRANT OPTION;"
mysql -e "GRANT ALL PRIVILEGES ON test005.* TO 'travis'@'%' WITH GRANT OPTION;"
mysql -e "GRANT ALL PRIVILEGES ON test006a.* TO 'travis'@'%' WITH GRANT OPTION;"
mysql -e "GRANT ALL PRIVILEGES ON test006b.* TO 'travis'@'%' WITH GRANT OPTION;"
mysql -e "GRANT SUPER,LOCK TABLES ON *.* TO 'travis'@'%';"
mysql -e "GRANT SELECT ON mysql.proc to 'travis'@'%';"
mysql -e "FLUSH PRIVILEGES;"
11 changes: 11 additions & 0 deletions tests/delete_users.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

mysql -e "DROP DATABASE test001;"
mysql -e "DROP DATABASE test002;"
mysql -e "DROP DATABASE test005;"
mysql -e "DROP DATABASE test006a;"
mysql -e "DROP DATABASE test006b;"

mysql -e "DROP USER 'travis'";

mysql -e "FLUSH PRIVILEGES;"
47 changes: 17 additions & 30 deletions tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

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
mysql -utravis -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
mysql -utravis --default-character-set=utf8mb4 -B -e "CHECKSUM TABLE test${i}" test002 | grep -v -i checksum
done
}

function checksum_test005() {
for i in 000; do
mysql -B -e "CHECKSUM TABLE test${i}" test001 | grep -v -i checksum
mysql -utravis -B -e "CHECKSUM TABLE test${i}" test001 | grep -v -i checksum
done
}

Expand All @@ -24,38 +24,22 @@ done

index=0

mysql -e "CREATE USER 'travis'@'localhost' IDENTIFIED BY '';" 2> /dev/null
mysql -e "CREATE DATABASE test001;" 2> /dev/null
mysql -e "CREATE DATABASE test002;" 2> /dev/null
mysql -e "CREATE DATABASE test005;" 2> /dev/null
mysql -e "CREATE DATABASE test006a;" 2> /dev/null
mysql -e "CREATE DATABASE test006b;" 2> /dev/null
mysql -e "GRANT ALL PRIVILEGES ON test001.* TO 'travis'@'localhost';" 2> /dev/null
mysql -e "GRANT SELECT ON mysql.proc to 'travis'@'localhost';" 2> /dev/null
mysql -e "GRANT ALL PRIVILEGES ON test002.* TO 'travis'@'localhost';" 2> /dev/null
mysql -e "GRANT ALL PRIVILEGES ON test005.* TO 'travis'@'localhost';" 2> /dev/null
mysql -e "GRANT ALL PRIVILEGES ON test006a.* TO 'travis'@'localhost';" 2> /dev/null
mysql -e "GRANT ALL PRIVILEGES ON test00ba.* TO 'travis'@'localhost';" 2> /dev/null
mysql -e "FLUSH PRIVILEGES;" 2> /dev/null

mysql -uroot < test001.src.sql; ret[((index++))]=$?
mysql -uroot --default-character-set=utf8mb4 < test002.src.sql; ret[((index++))]=$?
mysql -uroot < test005.src.sql; ret[((index++))]=$?
mysql -uroot < test006.src.sql; ret[((index++))]=$?

mysql -utravis < test001.src.sql; ret[((index++))]=$?
mysql -utravis --default-character-set=utf8mb4 < test002.src.sql; ret[((index++))]=$?
mysql -utravis < test005.src.sql; ret[((index++))]=$?
mysql -utravis < test006.src.sql; ret[((index++))]=$?
checksum_test001 > test001.src.checksum
checksum_test002 > test002.src.checksum
checksum_test005 > test005.src.checksum

mysqldump -uroot test001 \
mysqldump -utravis test001 \
--no-autocommit \
--extended-insert=false \
--hex-blob=true \
--routines=true \
> mysqldump_test001.sql
ret[((index++))]=$?

mysqldump -uroot test002 \
mysqldump -utravis test002 \
--no-autocommit \
--extended-insert=false \
--complete-insert=true \
Expand All @@ -64,7 +48,7 @@ mysqldump -uroot test002 \
> mysqldump_test002.sql
ret[((index++))]=$?

mysqldump -uroot test005 \
mysqldump -utravis test005 \
--no-autocommit \
--extended-insert=false \
--hex-blob=true \
Expand All @@ -74,14 +58,14 @@ ret[((index++))]=$?
php test.php
ret[((index++))]=$?

mysql -uroot test001 < mysqldump-php_test001.sql
mysql -utravis test001 < mysqldump-php_test001.sql
ret[((index++))]=$?
mysql -uroot test002 < mysqldump-php_test002.sql
mysql -utravis test002 < mysqldump-php_test002.sql
ret[((index++))]=$?
mysql -uroot test005 < mysqldump-php_test005.sql
mysql -utravis test005 < mysqldump-php_test005.sql
ret[((index++))]=$?

mysql -uroot test006b < mysqldump-php_test006.sql
mysql -utravis test006b < mysqldump-php_test006.sql
ret[((index++))]=$?

checksum_test001 > mysqldump-php_test001.checksum
Expand Down Expand Up @@ -125,6 +109,9 @@ echo "Done $index tests"

total=0
for i in $(seq 0 20) ; do
if [[ ${ret[$i]} -ne 0 ]]; then
echo "test $i returned ${ret[$i]}"
fi
total=$((${ret[$i]} + $total))
done

Expand Down
4 changes: 2 additions & 2 deletions tests/test001.src.sql
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ INSERT INTO `test033` VALUES (1,'test test test');


DROP VIEW IF EXISTS `test100`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `test100` AS select `test000`.`id` AS `id`,`test000`.`col01` AS `col01`,`test000`.`col02` AS `col02`,`test000`.`col03` AS `col03`,`test000`.`col10` AS `col10`,`test000`.`col11` AS `col11`,`test000`.`col15` AS `col15`,`test000`.`col27` AS `col27` from `test000`;
CREATE ALGORITHM=UNDEFINED DEFINER=`travis`@`localhost` SQL SECURITY DEFINER VIEW `test100` AS select `test000`.`id` AS `id`,`test000`.`col01` AS `col01`,`test000`.`col02` AS `col02`,`test000`.`col03` AS `col03`,`test000`.`col10` AS `col10`,`test000`.`col11` AS `col11`,`test000`.`col15` AS `col15`,`test000`.`col27` AS `col27` from `test000`;

DROP VIEW IF EXISTS `test127`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `test127` AS select `test027`.`id` AS `id`,`test027`.`col` AS `col` from `test027`;
CREATE ALGORITHM=UNDEFINED DEFINER=`travis`@`localhost` SQL SECURITY DEFINER VIEW `test127` AS select `test027`.`id` AS `id`,`test027`.`col` AS `col` from `test027`;


DROP TABLE IF EXISTS `test200`;
Expand Down
4 changes: 2 additions & 2 deletions tests/test006.src.sql
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ CREATE TABLE IF NOT EXISTS `view_of_my_table` (
--
DROP TABLE IF EXISTS `my_view`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `my_view` AS select `view_of_my_table`.`id` AS `id`,`view_of_my_table`.`name` AS `name`,`view_of_my_table`.`lastname` AS `lastname`,`view_of_my_table`.`username` AS `username` from `view_of_my_table`;
CREATE ALGORITHM=UNDEFINED DEFINER=`travis`@`localhost` SQL SECURITY DEFINER VIEW `my_view` AS select `view_of_my_table`.`id` AS `id`,`view_of_my_table`.`name` AS `name`,`view_of_my_table`.`lastname` AS `lastname`,`view_of_my_table`.`username` AS `username` from `view_of_my_table`;

-- --------------------------------------------------------

Expand All @@ -81,7 +81,7 @@ CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW
--
DROP TABLE IF EXISTS `view_of_my_table`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_of_my_table` AS select `my_table`.`id` AS `id`,`my_table`.`name` AS `name`,`my_table`.`lastname` AS `lastname`,`my_table`.`username` AS `username` from `my_table`;
CREATE ALGORITHM=UNDEFINED DEFINER=`travis`@`localhost` SQL SECURITY DEFINER VIEW `view_of_my_table` AS select `my_table`.`id` AS `id`,`my_table`.`name` AS `name`,`my_table`.`lastname` AS `lastname`,`my_table`.`username` AS `username` from `my_table`;

--
-- Índices para tablas volcadas
Expand Down

0 comments on commit c225512

Please sign in to comment.