Set sql_mode='' before SHOW CREATE TABLE--don't bother with replacing certain values. Move and rewrite tests to ansi_quotes.t.

This commit is contained in:
Daniel Nichter
2012-11-01 11:31:31 -06:00
parent 2bcc380c68
commit 949cf31037
6 changed files with 149 additions and 206 deletions

View File

@@ -56,25 +56,21 @@ sub get_create_table {
my $q = $self->{Quoter};
# To ensure a consistent output, we save the current (old) SQL mode,
# then set it to the new SQL mode that what we need. When done, even
# if an error occurs, we restore the old SQL mode.
# We don't want ANSI_QUOTES on here, nor any of the modes that
# implicitly turn that on.
my $replace = q{@@SQL_MODE};
# The others automatically turn on ANSI_QUOTES
for my $mode ( qw(ANSI_QUOTES ANSI DB2 MAXDB MSSQL ORACLE POSTGRESQL) ) {
$replace = "REPLACE($replace, '$mode', '')"
}
$replace = qq{REPLACE($replace, ',,', ',')};
# then set it to the new SQL mode that what we need, which is the
# default sql_mode=''. When done, even if an error occurs, we restore
# the old SQL mode. The main thing is that we do not want ANSI_QUOTES
# because there's code all throughout the tools that expect backtick `
# quoted idents, not double-quote " quoted idents. For example:
# https://bugs.launchpad.net/percona-toolkit/+bug/1058285
my $new_sql_mode
= '/*!40101 SET @OLD_SQL_MODE := @@SQL_MODE, '
. '@@SQL_MODE := ' . $replace . ', '
. '@OLD_QUOTE := @@SQL_QUOTE_SHOW_CREATE, '
. '@@SQL_QUOTE_SHOW_CREATE := 1 */';
= q{/*!40101 SET @OLD_SQL_MODE := @@SQL_MODE, }
. q{@@SQL_MODE := '', }
. q{@OLD_QUOTE := @@SQL_QUOTE_SHOW_CREATE, }
. q{@@SQL_QUOTE_SHOW_CREATE := 1 */};
my $old_sql_mode = '/*!40101 SET @@SQL_MODE := @OLD_SQL_MODE, '
. '@@SQL_QUOTE_SHOW_CREATE := @OLD_QUOTE */';
my $old_sql_mode
= q{/*!40101 SET @@SQL_MODE := @OLD_SQL_MODE, }
. q{@@SQL_QUOTE_SHOW_CREATE := @OLD_QUOTE */};
# Set new SQL mode.
PTDEBUG && _d($new_sql_mode);