Skip to content

Commit

Permalink
Merge pull request ifsnop#178 from mark-careplanner/master
Browse files Browse the repository at this point in the history
Adding create function metadata to create_function()
  • Loading branch information
ifsnop authored Oct 29, 2019
2 parents 0ca7b7f + 6b846a1 commit b6919ef
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/Ifsnop/Mysqldump/Mysqldump.php
Original file line number Diff line number Diff line change
Expand Up @@ -1973,6 +1973,9 @@ public function create_function($row)
"Please check 'https://bugs.mysql.com/bug.php?id=14564'");
}
$functionStmt = $row['Create Function'];
$characterSetClient = $row['character_set_client'];
$collationConnection = $row['collation_connection'];
$sqlMode = $row['sql_mode'];
if ( $this->dumpSettings['skip-definer'] ) {
if ($functionStmtReplaced = preg_replace(
'/^(CREATE)\s+('.self::DEFINER_RE.')?\s+(FUNCTION\s.*)$/s',
Expand All @@ -1987,11 +1990,24 @@ public function create_function($row)
$ret .= "/*!50003 DROP FUNCTION IF EXISTS `".
$row['Function']."` */;".PHP_EOL.
"/*!40101 SET @saved_cs_client = @@character_set_client */;".PHP_EOL.
"/*!40101 SET character_set_client = ".$this->dumpSettings['default-character-set']." */;".PHP_EOL.
"/*!50003 SET @saved_cs_results = @@character_set_results */ ;".PHP_EOL.
"/*!50003 SET @saved_col_connection = @@collation_connection */ ;".PHP_EOL.
"/*!40101 SET character_set_client = ".$characterSetClient." */;".PHP_EOL.
"/*!40101 SET character_set_results = ".$characterSetClient." */;".PHP_EOL.
"/*!50003 SET collation_connection = ".$collationConnection." */ ;".PHP_EOL.
"/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;".PHP_EOL.
"/*!50003 SET sql_mode = '".$sqlMode."' */ ;;".PHP_EOL.
"/*!50003 SET @saved_time_zone = @@time_zone */ ;;".PHP_EOL.
"/*!50003 SET time_zone = 'SYSTEM' */ ;;".PHP_EOL.
"DELIMITER ;;".PHP_EOL.
$functionStmt." ;;".PHP_EOL.
"DELIMITER ;".PHP_EOL.
"/*!40101 SET character_set_client = @saved_cs_client */;".PHP_EOL.PHP_EOL;
"/*!50003 SET sql_mode = @saved_sql_mode */ ;".PHP_EOL.
"/*!50003 SET character_set_client = @saved_cs_client */ ;".PHP_EOL.
"/*!50003 SET character_set_results = @saved_cs_results */ ;".PHP_EOL.
"/*!50003 SET collation_connection = @saved_col_connection */ ;".PHP_EOL.
"/*!50106 SET TIME_ZONE= @saved_time_zone */ ;".PHP_EOL.PHP_EOL;


return $ret;
}
Expand Down

0 comments on commit b6919ef

Please sign in to comment.