mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-21 18:24:38 +00:00
Merge branch '3.x' into HEAD
This commit is contained in:
@@ -94,14 +94,16 @@ sub get_create_table {
|
||||
if ( my $e = $EVAL_ERROR ) {
|
||||
# Restore old SQL mode.
|
||||
PTDEBUG && _d($old_sql_mode);
|
||||
$dbh->do($old_sql_mode);
|
||||
eval { $dbh->do($old_sql_mode); };
|
||||
PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);
|
||||
|
||||
die $e;
|
||||
}
|
||||
|
||||
# Restore old SQL mode.
|
||||
PTDEBUG && _d($old_sql_mode);
|
||||
$dbh->do($old_sql_mode);
|
||||
eval { $dbh->do($old_sql_mode); };
|
||||
PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);
|
||||
|
||||
# SHOW CREATE TABLE has at least 2 columns like:
|
||||
# mysql> show create table city\G
|
||||
@@ -109,7 +111,7 @@ sub get_create_table {
|
||||
# Table: city
|
||||
# Create Table: CREATE TABLE `city` (
|
||||
# `city_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
|
||||
# ...
|
||||
# ...
|
||||
# We want the second column.
|
||||
my ($key) = grep { m/create (?:table|view)/i } keys %$href;
|
||||
if ( !$key ) {
|
||||
@@ -149,7 +151,7 @@ sub parse {
|
||||
|
||||
my $engine = $self->get_engine($ddl);
|
||||
|
||||
my @defs = $ddl =~ m/^(\s+`.*?),?$/gm;
|
||||
my @defs = $ddl =~ m/(?:(?<=,\n)|(?<=\(\n))(\s+`(?:.|\n)+?`.+?),?\n/g;
|
||||
my @cols = map { $_ =~ m/`([^`]+)`/ } @defs;
|
||||
PTDEBUG && _d('Table cols:', join(', ', map { "`$_`" } @cols));
|
||||
|
||||
@@ -219,9 +221,9 @@ sub parse {
|
||||
sub remove_quoted_text {
|
||||
my ($string) = @_;
|
||||
$string =~ s/\\['"]//g;
|
||||
$string =~ s/`[^`]*?`//g;
|
||||
$string =~ s/"[^"]*?"//g;
|
||||
$string =~ s/'[^']*?'//g;
|
||||
$string =~ s/`[^`]*?`//g;
|
||||
$string =~ s/"[^"]*?"//g;
|
||||
$string =~ s/'[^']*?'//g;
|
||||
return $string;
|
||||
}
|
||||
|
||||
@@ -411,8 +413,7 @@ sub get_keys {
|
||||
my $clustered_key = undef;
|
||||
|
||||
KEY:
|
||||
foreach my $key ( $ddl =~ m/^ ((?:[A-Z]+ )?KEY .*)$/gm ) {
|
||||
|
||||
foreach my $key ( $ddl =~ m/^ ((?:[A-Z]+ )?KEY [\s\S]*?\),?.*)$/gm ) {
|
||||
# If you want foreign keys, use get_fks() below.
|
||||
next KEY if $key =~ m/FOREIGN/;
|
||||
|
||||
@@ -429,7 +430,7 @@ sub get_keys {
|
||||
}
|
||||
|
||||
# Determine index type
|
||||
my ( $type, $cols ) = $key =~ m/(?:USING (\w+))? \((.+)\)/;
|
||||
my ( $type, $cols ) = $key =~ m/(?:USING (\w+))? \(([\s\S]+)\)/;
|
||||
my ( $special ) = $key =~ m/(FULLTEXT|SPATIAL)/;
|
||||
$type = $type || $special || 'BTREE';
|
||||
my ($name) = $key =~ m/(PRIMARY|`[^`]*`)/;
|
||||
|
Reference in New Issue
Block a user