Include routines in backups
authorJamie Cameron <jcameron@webmin.com>
Wed, 6 May 2009 17:27:18 +0000 (17:27 +0000)
committerJamie Cameron <jcameron@webmin.com>
Wed, 6 May 2009 17:27:18 +0000 (17:27 +0000)
mysql/CHANGELOG
mysql/mysql-lib.pl

index 5d4ed54..569994d 100644 (file)
@@ -83,3 +83,5 @@ Use DBI for listing databases and tables, to reduce dependency on the un-reliabl
 Fixed the input for setting the default value for fields.
 ---- Changes since 1.470 ----
 Added code to detect a password in /root/.my.cnf which overrides the MYSQL_PWD variable, and thus causes login failures.
+---- Changes since 1.480 ----
+MySQL stored procedures are now included in backups, where supported.
index 218e784..e062c1d 100644 (file)
@@ -600,6 +600,14 @@ else {
        }
 }
 
+# supports_routines()
+# Returns 1 if mysqldump supports routines
+sub supports_routines
+{
+local $out = &backquote_command("$config{'mysqldump'} --help 2>&1 </dev/null");
+return $out =~ /--routines/ ? 1 : 0;
+}
+
 # supports_views()
 # Returns 1 if this MySQL install supports views
 sub supports_views
@@ -1314,8 +1322,9 @@ local $charsetsql = $charset ?
 local $compatiblesql = @$compatible ?
        "--compatible=".join(",", @$compatible) : "";
 local $quotingsql = &supports_quoting() ? "--quote-names" : "";
+local $routinessql = &supports_routines() ? "--routines" : "";
 local $tablessql = join(" ", map { quotemeta($_) } @$tables);
-local $cmd = "$config{'mysqldump'} $authstr $dropsql $wheresql $charsetsql $compatiblesql $quotingsql ".quotemeta($db)." $tablessql 2>&1 $writer";
+local $cmd = "$config{'mysqldump'} $authstr $dropsql $wheresql $charsetsql $compatiblesql $quotingsql $routinessql ".quotemeta($db)." $tablessql 2>&1 $writer";
 if ($user && $user ne "root") {
        $cmd = &command_as_user($user, undef, $cmd);
        }