1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Bug#14463669 FAILURE TO CORRECTLY PARSE ROUTINES IN

MYSQLDUMP OUTPUT

Problem: mysqldump when used with option --routines, dumps
         all the routines of the specified database into
         output. The statements in this output are written
         in such a way that they are version safe using C
         style version commenting (of the format
         /*!<version num> <sql statement>*/). If a semicolon
         is present right before closing of the comment in
         dump output, it results in a syntax error while
         importing.


Solution: Version comments for dumped routines are
          specifically to protect the ones older than 5.0.
          When the import is done on 5.0 or later versions,
          entire create statement gets executed as all the
          check conditions at the beginning of the comments
          are cleared. Since the trade off is between the
          performance of newer versions which are more in
          use and protection of very old versions which are
          no longer supported, it is proposed that these
          comments be removed altogether to maintain
          stability of the versions supported.
This commit is contained in:
Vamsikrishna Bhagi
2012-11-19 21:41:35 +05:30
parent 64e6119956
commit f1e9b7219c
2 changed files with 14 additions and 27 deletions

View File

@ -2240,7 +2240,6 @@ static uint dump_routines_for_db(char *db)
const char *routine_type[]= {"FUNCTION", "PROCEDURE"};
char db_name_buff[NAME_LEN*2+3], name_buff[NAME_LEN*2+3];
char *routine_name;
char *query_str;
int i;
FILE *sql_file= md_result_file;
MYSQL_RES *routine_res, *routine_list_res;
@ -2334,17 +2333,6 @@ static uint dump_routines_for_db(char *db)
fprintf(sql_file, "/*!50003 DROP %s IF EXISTS %s */;\n",
routine_type[i], routine_name);
query_str= cover_definer_clause(row[2], strlen(row[2]),
C_STRING_WITH_LEN("50020"),
C_STRING_WITH_LEN("50003"),
C_STRING_WITH_LEN(" FUNCTION"));
if (!query_str)
query_str= cover_definer_clause(row[2], strlen(row[2]),
C_STRING_WITH_LEN("50020"),
C_STRING_WITH_LEN("50003"),
C_STRING_WITH_LEN(" PROCEDURE"));
if (mysql_num_fields(routine_res) >= 6)
{
if (switch_db_collation(sql_file, db_name_buff, ";",
@ -2382,9 +2370,9 @@ static uint dump_routines_for_db(char *db)
fprintf(sql_file,
"DELIMITER ;;\n"
"/*!50003 %s */;;\n"
"%s ;;\n"
"DELIMITER ;\n",
(const char *) (query_str != NULL ? query_str : row[2]));
(const char *) row[2]);
restore_sql_mode(sql_file, ";");
@ -2399,7 +2387,6 @@ static uint dump_routines_for_db(char *db)
}
}
my_free(query_str);
}
} /* end of routine printing */
mysql_free_result(routine_res);