mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-04-26 01:02:25 +08:00
Handle IF [NOT] EXITS for ddl statements in distill.
This commit is contained in:
@@ -298,6 +298,8 @@ sub distill_verbs {
|
||||
eval $QueryParser::tbl_ident;
|
||||
my ( $dds ) = $query =~ /^\s*($QueryParser::data_def_stmts)\b/i;
|
||||
if ( $dds) {
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/821690
|
||||
$query =~ s/\s+IF(?:\s+NOT)?\s+EXISTS/ /i;
|
||||
my ( $obj ) = $query =~ m/$dds.+(DATABASE|TABLE)\b/i;
|
||||
$obj = uc $obj if $obj;
|
||||
PTDEBUG && _d('Data def statment:', $dds, 'obj:', $obj);
|
||||
|
||||
@@ -1440,6 +1440,20 @@ is(
|
||||
"distill REPLACE without INTO (bug 984053)"
|
||||
);
|
||||
|
||||
# IF EXISTS
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/821690
|
||||
is(
|
||||
$qr->distill("DROP TABLE IF EXISTS foo"),
|
||||
"DROP TABLE foo",
|
||||
"distill DROP TABLE IF EXISTS foo (bug 821690)"
|
||||
);
|
||||
|
||||
is(
|
||||
$qr->distill("CREATE TABLE IF NOT EXISTS foo"),
|
||||
"CREATE TABLE foo",
|
||||
"distill CREATE TABLE IF NOT EXISTS foo",
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
|
||||
Reference in New Issue
Block a user