summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2012-01-16 20:16:35 +0100
committerSergei Golubchik <sergii@pisem.net>2012-01-16 20:16:35 +0100
commit38e3ae155db08ab2e9e5c267f05f89bec0542b33 (patch)
tree7289bbef1ba3f495aa5c7cdb7d0a3f993a5bbc80 /client
parentc56483d972d023105fbcb0f47af0042ee092657c (diff)
parented1ba992c1d3c3ecbe6a2769c51ceb5d27606d3b (diff)
downloadmariadb-git-38e3ae155db08ab2e9e5c267f05f89bec0542b33.tar.gz
mysql-5.5 merge
Diffstat (limited to 'client')
-rw-r--r--client/mysql_plugin.c15
-rw-r--r--client/mysql_upgrade.c5
-rw-r--r--client/mysqldump.c43
-rw-r--r--client/mysqltest.cc95
4 files changed, 108 insertions, 50 deletions
diff --git a/client/mysql_plugin.c b/client/mysql_plugin.c
index 825c962c486..fb2a031bb8e 100644
--- a/client/mysql_plugin.c
+++ b/client/mysql_plugin.c
@@ -929,19 +929,19 @@ static int check_access()
opt_datadir);
goto exit;
}
- if ((error= my_access(opt_plugin_ini, F_OK)))
+ if (opt_plugin_ini && (error= my_access(opt_plugin_ini, F_OK)))
{
fprintf(stderr, "ERROR: Cannot access plugin config file at '%s'.\n",
opt_plugin_ini);
goto exit;
}
- if ((error= my_access(opt_mysqld, F_OK)))
+ if (opt_mysqld && (error= my_access(opt_mysqld, F_OK)))
{
fprintf(stderr, "ERROR: Cannot access mysqld path '%s'.\n",
opt_mysqld);
goto exit;
}
- if ((error= my_access(opt_my_print_defaults, F_OK)))
+ if (opt_my_print_defaults && (error= my_access(opt_my_print_defaults, F_OK)))
{
fprintf(stderr, "ERROR: Cannot access my-print-defaults path '%s'.\n",
opt_my_print_defaults);
@@ -967,7 +967,7 @@ static int find_tool(const char *tool_name, char *tool_path)
int i= 0;
const char *paths[]= {
- opt_basedir, opt_mysqld, opt_my_print_defaults, "/usr",
+ opt_mysqld, opt_basedir, opt_my_print_defaults, "/usr",
"/usr/local/mysql", "/usr/sbin", "/usr/share", "/extra", "/extra/debug",
"/extra/release", "/bin", "/usr/bin", "/mysql/bin"
};
@@ -1081,7 +1081,7 @@ static int build_bootstrap_file(char *operation, char *bootstrap)
else
{
fprintf(file,
- "DELETE FROM mysql.plugin WHERE name = '%s';", plugin_data.name);
+ "DELETE FROM mysql.plugin WHERE dl = '%s';", plugin_data.so_name);
if (opt_verbose)
{
printf("# Disabling %s...\n", plugin_data.name);
@@ -1124,7 +1124,7 @@ static int dump_bootstrap_file(char *bootstrap_file)
error= 1;
goto exit;
}
- printf("# Query: %s", query_str);
+ printf("# Query: %s\n", query_str);
exit:
if (file)
@@ -1160,7 +1160,6 @@ static int bootstrap_server(char *server_path, char *bootstrap_file)
{
char bootstrap_cmd[FN_REFLEN];
int error= 0;
- int ret= 0;
#ifdef __WIN__
char *format_str= 0;
@@ -1196,7 +1195,7 @@ static int bootstrap_server(char *server_path, char *bootstrap_file)
if (error)
fprintf(stderr,
"ERROR: Unexpected result from bootstrap. Error code: %d.\n",
- ret);
+ error);
return error;
}
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index e2c2d881654..23c969face4 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -303,10 +303,9 @@ get_one_option(int optid, const struct my_option *opt,
opt_verbose= 0;
add_option= 0;
break;
- case 's':
- add_option= 0;
- break;
case 'f': /* --force */
+ case 's': /* --upgrade-system-tables */
+ case OPT_WRITE_BINLOG: /* --write-binlog */
add_option= FALSE;
break;
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 2b6fc597dbb..b8d74858925 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -564,6 +564,8 @@ static void verbose_msg(const char *fmt, ...)
vfprintf(stderr, fmt, args);
va_end(args);
+ fflush(stderr);
+
DBUG_VOID_RETURN;
}
@@ -4131,6 +4133,8 @@ static int dump_all_tables_in_db(char *database)
if (mysql_refresh(mysql, REFRESH_LOG))
DB_error(mysql, "when doing refresh");
/* We shall continue here, if --force was given */
+ else
+ verbose_msg("-- dump_all_tables_in_db : logs flushed successfully!\n");
}
while ((table= getTableName(0)))
{
@@ -4231,6 +4235,8 @@ static my_bool dump_all_views_in_db(char *database)
if (mysql_refresh(mysql, REFRESH_LOG))
DB_error(mysql, "when doing refresh");
/* We shall continue here, if --force was given */
+ else
+ verbose_msg("-- dump_all_views_in_db : logs flushed successfully!\n");
}
while ((table= getTableName(0)))
{
@@ -4369,6 +4375,8 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
DB_error(mysql, "when doing refresh");
}
/* We shall countinue here, if --force was given */
+ else
+ verbose_msg("-- dump_selected_tables : logs flushed successfully!\n");
}
if (opt_xml)
print_xml_tag(md_result_file, "", "\n", "database", "name=", db, NullS);
@@ -4675,6 +4683,7 @@ static int purge_bin_logs_to(MYSQL *mysql_con, char* log_name)
static int start_transaction(MYSQL *mysql_con)
{
+ verbose_msg("-- Starting transaction...\n");
/*
We use BEGIN for old servers. --single-transaction --master-data will fail
on old servers, but that's ok as it was already silently broken (it didn't
@@ -5284,25 +5293,39 @@ int main(int argc, char **argv)
consistent_binlog_pos= check_consistent_binlog_pos(NULL, NULL);
}
- if ((opt_lock_all_tables || (opt_master_data && !consistent_binlog_pos)) &&
+ if ((opt_lock_all_tables || (opt_master_data && !consistent_binlog_pos) ||
+ (opt_single_transaction && flush_logs)) &&
do_flush_tables_read_lock(mysql))
goto err;
- if (opt_single_transaction && start_transaction(mysql))
- goto err;
- if (opt_delete_master_logs)
+
+ /*
+ Flush logs before starting transaction since
+ this causes implicit commit starting mysql-5.5.
+ */
+ if (opt_lock_all_tables || opt_master_data ||
+ (opt_single_transaction && flush_logs) ||
+ opt_delete_master_logs)
{
- if (mysql_refresh(mysql, REFRESH_LOG) ||
- get_bin_log_name(mysql, bin_log_name, sizeof(bin_log_name)))
- goto err;
+ if (flush_logs || opt_delete_master_logs)
+ {
+ if (mysql_refresh(mysql, REFRESH_LOG))
+ goto err;
+ verbose_msg("-- main : logs flushed successfully!\n");
+ }
+
+ /* Not anymore! That would not be sensible. */
flush_logs= 0;
}
- if (opt_lock_all_tables || opt_master_data)
+
+ if (opt_delete_master_logs)
{
- if (flush_logs && mysql_refresh(mysql, REFRESH_LOG))
+ if (get_bin_log_name(mysql, bin_log_name, sizeof(bin_log_name)))
goto err;
- flush_logs= 0; /* not anymore; that would not be sensible */
}
+ if (opt_single_transaction && start_transaction(mysql))
+ goto err;
+
/* Add 'STOP SLAVE to beginning of dump */
if (opt_slave_apply && add_stop_slave())
goto err;
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index c1ff504bb2a..0e79f57e6a3 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -310,6 +310,7 @@ struct st_connection
pthread_mutex_t result_mutex;
pthread_cond_t result_cond;
int query_done;
+ my_bool has_thread;
#endif /*EMBEDDED_LIBRARY*/
};
@@ -525,6 +526,31 @@ struct st_command *curr_command= 0;
char builtin_echo[FN_REFLEN];
+struct st_replace_regex
+{
+DYNAMIC_ARRAY regex_arr; /* stores a list of st_regex subsitutions */
+
+/*
+Temporary storage areas for substitutions. To reduce unnessary copying
+and memory freeing/allocation, we pre-allocate two buffers, and alternate
+their use, one for input/one for output, the roles changing on the next
+st_regex substition. At the end of substitutions buf points to the
+one containing the final result.
+*/
+char* buf;
+char* even_buf;
+char* odd_buf;
+int even_buf_len;
+int odd_buf_len;
+};
+
+struct st_replace_regex *glob_replace_regex= 0;
+
+struct st_replace;
+struct st_replace *glob_replace= 0;
+void replace_strings_append(struct st_replace *rep, DYNAMIC_STRING* ds,
+const char *from, int len);
+
static void cleanup_and_exit(int exit_code) __attribute__((noreturn));
void die(const char *fmt, ...)
@@ -554,6 +580,7 @@ void str_to_file2(const char *fname, char *str, int size, my_bool append);
void fix_win_paths(const char *val, int len);
const char *get_errname_from_code (uint error_code);
+int multi_reg_replace(struct st_replace_regex* r,char* val);
#ifdef __WIN__
void free_tmp_sh_file();
@@ -2514,7 +2541,23 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
if (row[i])
{
/* Add column to tab separated string */
- dynstr_append_mem(&result, row[i], lengths[i]);
+ char *val= row[i];
+ int len= lengths[i];
+
+ if (glob_replace_regex)
+ {
+ /* Regex replace */
+ if (!multi_reg_replace(glob_replace_regex, (char*)val))
+ {
+ val= glob_replace_regex->buf;
+ len= strlen(val);
+ }
+ }
+
+ if (glob_replace)
+ replace_strings_append(glob_replace, &result, val, len);
+ else
+ dynstr_append_mem(&result, val, len);
}
dynstr_append_mem(&result, "\t", 1);
}
@@ -3443,8 +3486,9 @@ void do_copy_file(struct st_command *command)
' ');
DBUG_PRINT("info", ("Copy %s to %s", ds_from_file.str, ds_to_file.str));
+ /* MY_HOLD_ORIGINAL_MODES prevents attempts to chown the file */
error= (my_copy(ds_from_file.str, ds_to_file.str,
- MYF(MY_DONT_OVERWRITE_FILE | MY_WME)) != 0);
+ MYF(MY_DONT_OVERWRITE_FILE | MY_WME | MY_HOLD_ORIGINAL_MODES)) != 0);
handle_command_error(command, error, my_errno);
dynstr_free(&ds_from_file);
dynstr_free(&ds_to_file);
@@ -4940,6 +4984,7 @@ void do_get_errcodes(struct st_command *command)
struct st_match_err *to= saved_expected_errors.err;
char *p= command->first_argument;
uint count= 0;
+ char *next;
DBUG_ENTER("do_get_errcodes");
@@ -4959,6 +5004,17 @@ void do_get_errcodes(struct st_command *command)
while (*end && *end != ',' && *end != ' ')
end++;
+ next=end;
+
+ /* code to handle variables passed to mysqltest */
+ if( *p == '$')
+ {
+ const char* fin;
+ VAR *var = var_get(p,&fin,0,0);
+ p=var->str_val;
+ end=p+var->str_val_len;
+ }
+
if (*p == 'S')
{
char *to_ptr= to->code.sqlstate;
@@ -5033,7 +5089,7 @@ void do_get_errcodes(struct st_command *command)
die("Too many errorcodes specified");
/* Set pointer to the end of the last error code */
- p= end;
+ p= next;
/* Find next ',' */
while (*p && *p != ',')
@@ -9273,16 +9329,11 @@ typedef struct st_pointer_array { /* when using array-strings */
uint array_allocs,max_count,length,max_length;
} POINTER_ARRAY;
-struct st_replace;
struct st_replace *init_replace(char * *from, char * *to, uint count,
char * word_end_chars);
int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name);
-void replace_strings_append(struct st_replace *rep, DYNAMIC_STRING* ds,
- const char *from, int len);
void free_pointer_array(POINTER_ARRAY *pa);
-struct st_replace *glob_replace;
-
/*
Get arguments for replace. The syntax is:
replace from to [from to ...]
@@ -9426,26 +9477,6 @@ struct st_regex
int icase; /* true if the match is case insensitive */
};
-struct st_replace_regex
-{
- DYNAMIC_ARRAY regex_arr; /* stores a list of st_regex subsitutions */
-
- /*
- Temporary storage areas for substitutions. To reduce unnessary copying
- and memory freeing/allocation, we pre-allocate two buffers, and alternate
- their use, one for input/one for output, the roles changing on the next
- st_regex substition. At the end of substitutions buf points to the
- one containing the final result.
- */
- char* buf;
- char* even_buf;
- char* odd_buf;
- int even_buf_len;
- int odd_buf_len;
-};
-
-struct st_replace_regex *glob_replace_regex= 0;
-
int reg_replace(char** buf_p, int* buf_len_p, char *pattern, char *replace,
char *string, int icase);
@@ -9644,7 +9675,13 @@ void do_get_replace_regex(struct st_command *command)
{
char *expr= command->first_argument;
free_replace_regex();
- if (!(glob_replace_regex=init_replace_regex(expr)))
+ /* Allow variable for the *entire* list of replacements */
+ if (*expr == '$')
+ {
+ VAR *val= var_get(expr, NULL, 0, 1);
+ expr= val ? val->str_val : NULL;
+ }
+ if (expr && *expr && !(glob_replace_regex=init_replace_regex(expr)))
die("Could not init replace_regex");
command->last_argument= command->end;
}