summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2019-05-04 17:04:55 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2019-05-04 17:04:55 +0200
commit8cbb14ef5d180687f131bc44a4e8fc84083d033c (patch)
tree091f11e2d20f95656a7b12294782eb0488fd4fcc /client
parent4345868382ca3525de5eb432302b6b9b957b47c1 (diff)
parentb85aa20065504bdda4bc03c2bd7eb7de38865c5d (diff)
downloadmariadb-git-8cbb14ef5d180687f131bc44a4e8fc84083d033c.tar.gz
Merge branch '10.1' into 10.2
Diffstat (limited to 'client')
-rw-r--r--client/mysql_plugin.c8
-rw-r--r--client/mysqldump.c63
2 files changed, 35 insertions, 36 deletions
diff --git a/client/mysql_plugin.c b/client/mysql_plugin.c
index 9cf4cd957fd..b2fd03cec91 100644
--- a/client/mysql_plugin.c
+++ b/client/mysql_plugin.c
@@ -322,7 +322,7 @@ static int get_default_values()
int ret= 0;
FILE *file= 0;
- bzero(tool_path, FN_REFLEN);
+ memset(tool_path, 0, FN_REFLEN);
if ((error= find_tool("my_print_defaults" FN_EXEEXT, tool_path)))
goto exit;
else
@@ -335,9 +335,9 @@ static int get_default_values()
char *format_str= 0;
if (has_spaces(tool_path) || has_spaces(defaults_file))
- format_str = "\"%s mysqld > %s\"";
+ format_str = "\"%s --mysqld > %s\"";
else
- format_str = "%s mysqld > %s";
+ format_str = "%s --mysqld > %s";
snprintf(defaults_cmd, sizeof(defaults_cmd), format_str,
add_quotes(tool_path), add_quotes(defaults_file));
@@ -348,7 +348,7 @@ static int get_default_values()
}
#else
snprintf(defaults_cmd, sizeof(defaults_cmd),
- "%s mysqld > %s", tool_path, defaults_file);
+ "%s --mysqld > %s", tool_path, defaults_file);
#endif
/* Execute the command */
diff --git a/client/mysqldump.c b/client/mysqldump.c
index f64acb044f5..6b46980ccd2 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -3268,7 +3268,7 @@ static void dump_trigger_old(FILE *sql_file, MYSQL_RES *show_triggers_rs,
char name_buff[NAME_LEN * 4 + 3];
const char *xml_msg= "\nWarning! mysqldump being run against old server "
- "that does not\nsupport 'SHOW CREATE TRIGGERS' "
+ "that does not\nsupport 'SHOW CREATE TRIGGER' "
"statement. Skipping..\n";
DBUG_ENTER("dump_trigger_old");
@@ -3427,12 +3427,14 @@ static int dump_triggers_for_table(char *table_name, char *db_name)
char db_cl_name[MY_CS_NAME_SIZE];
int ret= TRUE;
+ /* Servers below 5.1.21 do not support SHOW CREATE TRIGGER */
+ const int use_show_create_trigger= mysql_get_server_version(mysql) >= 50121;
DBUG_ENTER("dump_triggers_for_table");
DBUG_PRINT("enter", ("db: %s, table_name: %s", db_name, table_name));
- if (path && !(sql_file= open_sql_file_for_table(table_name,
- O_WRONLY | O_APPEND)))
+ if (path &&
+ !(sql_file= open_sql_file_for_table(table_name, O_WRONLY | O_APPEND)))
DBUG_RETURN(1);
/* Do not use ANSI_QUOTES on triggers in dump */
@@ -3448,11 +3450,15 @@ static int dump_triggers_for_table(char *table_name, char *db_name)
/* Get list of triggers. */
- my_snprintf(query_buff, sizeof(query_buff),
- "SELECT TRIGGER_NAME FROM INFORMATION_SCHEMA.TRIGGERS "
- "WHERE EVENT_OBJECT_SCHEMA = DATABASE() AND "
- "EVENT_OBJECT_TABLE = %s",
- quote_for_equal(table_name, name_buff));
+ if (use_show_create_trigger)
+ my_snprintf(query_buff, sizeof(query_buff),
+ "SELECT TRIGGER_NAME FROM INFORMATION_SCHEMA.TRIGGERS "
+ "WHERE EVENT_OBJECT_SCHEMA = DATABASE() AND "
+ "EVENT_OBJECT_TABLE = %s",
+ quote_for_equal(table_name, name_buff));
+ else
+ my_snprintf(query_buff, sizeof(query_buff), "SHOW TRIGGERS LIKE %s",
+ quote_for_like(table_name, name_buff));
if (mysql_query_with_error_report(mysql, &show_triggers_rs, query_buff))
goto done;
@@ -3468,35 +3474,28 @@ static int dump_triggers_for_table(char *table_name, char *db_name)
while ((row= mysql_fetch_row(show_triggers_rs)))
{
-
- my_snprintf(query_buff, sizeof (query_buff),
- "SHOW CREATE TRIGGER %s",
- quote_name(row[0], name_buff, TRUE));
-
- if (mysql_query(mysql, query_buff))
+ if (use_show_create_trigger)
{
- /*
- mysqldump is being run against old server, that does not support
- SHOW CREATE TRIGGER statement. We should use SHOW TRIGGERS output.
+ MYSQL_RES *show_create_trigger_rs;
- NOTE: the dump may be incorrect, as old SHOW TRIGGERS does not
- provide all the necessary information to restore trigger properly.
- */
+ my_snprintf(query_buff, sizeof (query_buff), "SHOW CREATE TRIGGER %s",
+ quote_name(row[0], name_buff, TRUE));
- dump_trigger_old(sql_file, show_triggers_rs, &row, table_name);
- }
- else
- {
- MYSQL_RES *show_create_trigger_rs= mysql_store_result(mysql);
-
- int error= (!show_create_trigger_rs ||
- dump_trigger(sql_file, show_create_trigger_rs, db_name,
- db_cl_name));
- mysql_free_result(show_create_trigger_rs);
- if (error)
+ if (mysql_query_with_error_report(mysql, &show_create_trigger_rs,
+ query_buff))
goto done;
+ else
+ {
+ int error= (!show_create_trigger_rs ||
+ dump_trigger(sql_file, show_create_trigger_rs, db_name,
+ db_cl_name));
+ mysql_free_result(show_create_trigger_rs);
+ if (error)
+ goto done;
+ }
}
-
+ else
+ dump_trigger_old(sql_file, show_triggers_rs, &row, table_name);
}
if (opt_xml)