Fix for customer issue 26211 ($avg_rate might be zero), plus a fix for bug 1058285 (also related to 26211), and an emergent part of 821722: Several sql_modes implicitly turn on ANSI_QUOTES

This commit is contained in:
Brian Fraser
2012-10-17 15:52:15 -03:00
parent df2278b95c
commit 2bcc380c68
4 changed files with 199 additions and 7 deletions

View File

@@ -58,9 +58,18 @@ sub get_create_table {
# 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, ',,', ',')};
my $new_sql_mode
= '/*!40101 SET @OLD_SQL_MODE := @@SQL_MODE, '
. q{@@SQL_MODE := REPLACE(REPLACE(@@SQL_MODE, 'ANSI_QUOTES', ''), ',,', ','), }
. '@@SQL_MODE := ' . $replace . ', '
. '@OLD_QUOTE := @@SQL_QUOTE_SHOW_CREATE, '
. '@@SQL_QUOTE_SHOW_CREATE := 1 */';