Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass --column-statistics=0 to mysqldump command #105

Merged
merged 2 commits into from Jul 31, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/DB_Command.php
Expand Up @@ -474,7 +474,15 @@ public function export( $args, $assoc_args ) {
$assoc_args['result-file'] = $result_file;
}

$command = '/usr/bin/env mysqldump --no-defaults %s';
$mysqldump_version = exec( "/usr/bin/env mysqldump --version --no-defaults" );
$mysqldump_version = preg_replace( "/^.+([0-9]+\.[0-9]+\.[0-9]+)(.+)$/", "$1", $mysqldump_version );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test does not take MariaDB into account.

Here's a version string from MariaDB from my current local setup:

$ /usr/bin/env mysqldump --version --no-defaults
mysqldump  Ver 10.16 Distrib 10.2.14-MariaDB, for osx10.13 (x86_64)

So you not only need to check the version, but also whether you actually are using MySQL, not some variant.


if ( version_compare( $mysqldump_version, '8.0', '>=' ) ) {
$command = '/usr/bin/env mysqldump --no-defaults --column-statistics=0 %s';
} else {
$command = '/usr/bin/env mysqldump --no-defaults %s';
}

$command_esc_args = array( DB_NAME );

if ( isset( $assoc_args['tables'] ) ) {
Expand Down