summaryrefslogtreecommitdiff
path: root/client/mysqltest.c
diff options
context:
space:
mode:
Diffstat (limited to 'client/mysqltest.c')
-rw-r--r--client/mysqltest.c412
1 files changed, 221 insertions, 191 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c
index a75debd2ca5..a86bc3e7c3a 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -31,20 +31,14 @@
Holyfoot
*/
-#define MTEST_VERSION "3.2"
+#define MTEST_VERSION "3.3"
-#include <my_global.h>
-#include <mysql_embed.h>
-#include <my_sys.h>
-#include <m_string.h>
-#include <mysql.h>
+#include "client_priv.h"
#include <mysql_version.h>
#include <mysqld_error.h>
-#include <errmsg.h>
#include <m_ctype.h>
#include <my_dir.h>
#include <hash.h>
-#include <my_getopt.h>
#include <stdarg.h>
#include <violite.h>
#include "my_regex.h" /* Our own version of regex */
@@ -56,14 +50,6 @@
#endif
-#ifndef WEXITSTATUS
-# ifdef __WIN__
-# define WEXITSTATUS(stat_val) (stat_val)
-# else
-# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
-# endif
-#endif
-
/* Use cygwin for --exec and --system before 5.0 */
#if MYSQL_VERSION_ID < 50000
#define USE_CYGWIN
@@ -79,11 +65,9 @@
#define QUERY_REAP_FLAG 2
enum {
- OPT_SKIP_SAFEMALLOC=256, OPT_SSL_SSL, OPT_SSL_KEY, OPT_SSL_CERT,
- OPT_SSL_CA, OPT_SSL_CAPATH, OPT_SSL_CIPHER, OPT_PS_PROTOCOL,
- OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
- OPT_SSL_VERIFY_SERVER_CERT, OPT_MAX_CONNECT_RETRIES,
- OPT_MARK_PROGRESS, OPT_CHARSETS_DIR, OPT_LOG_DIR, OPT_TAIL_LINES
+ OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION,
+ OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
+ OPT_MAX_CONNECT_RETRIES, OPT_MARK_PROGRESS, OPT_LOG_DIR, OPT_TAIL_LINES
};
static int record= 0, opt_sleep= -1;
@@ -94,6 +78,7 @@ const char *opt_include= 0, *opt_charsets_dir;
static int opt_port= 0;
static int opt_max_connect_retries;
static my_bool opt_compress= 0, silent= 0, verbose= 0;
+static my_bool debug_info_flag= 0, debug_check_flag= 0;
static my_bool tty_password= 0;
static my_bool opt_mark_progress= 0;
static my_bool ps_protocol= 0, ps_protocol_enabled= 0;
@@ -114,6 +99,7 @@ static const char *load_default_groups[]= { "mysqltest", "client", 0 };
static char line_buffer[MAX_DELIMITER_LENGTH], *line_buffer_pos= line_buffer;
static uint start_lineno= 0; /* Start line of current command */
+static uint my_end_arg= 0;
/* Number of lines of the result to include in failure report */
static uint opt_tail_lines= 0;
@@ -929,7 +915,7 @@ void close_files()
DBUG_PRINT("info", ("closing file: %s", cur_file->file_name));
my_fclose(cur_file->file, MYF(0));
}
- my_free((gptr)cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR));
+ my_free((uchar*) cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR));
cur_file->file_name= 0;
}
DBUG_VOID_RETURN;
@@ -948,8 +934,8 @@ void free_used_memory()
for (i= 0 ; i < q_lines.elements ; i++)
{
struct st_command **q= dynamic_element(&q_lines, i, struct st_command**);
- my_free((gptr) (*q)->query_buf,MYF(MY_ALLOW_ZERO_PTR));
- my_free((gptr) (*q),MYF(0));
+ my_free((*q)->query_buf,MYF(MY_ALLOW_ZERO_PTR));
+ my_free((*q),MYF(0));
}
for (i= 0; i < 10; i++)
{
@@ -983,12 +969,10 @@ void free_used_memory()
static void cleanup_and_exit(int exit_code)
{
free_used_memory();
- my_end(MY_CHECK_ERROR);
+ my_end(my_end_arg);
- if (!silent)
- {
- switch (exit_code)
- {
+ if (!silent) {
+ switch (exit_code) {
case 1:
printf("not ok\n");
break;
@@ -1210,7 +1194,7 @@ void cat_file(DYNAMIC_STRING* ds, const char* filename)
if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0)
die("Failed to open file '%s'", filename);
- while((len= my_read(fd, (byte*)&buff,
+ while((len= my_read(fd, (uchar*)&buff,
sizeof(buff), MYF(0))) > 0)
{
char *p= buff, *start= buff;
@@ -1450,10 +1434,10 @@ int compare_files2(File fd, const char* filename2)
my_close(fd, MYF(0));
die("Failed to open second file: '%s'", filename2);
}
- while((len= my_read(fd, (byte*)&buff,
+ while((len= my_read(fd, (uchar*)&buff,
sizeof(buff), MYF(0))) > 0)
{
- if ((len2= my_read(fd2, (byte*)&buff2,
+ if ((len2= my_read(fd2, (uchar*)&buff2,
sizeof(buff2), MYF(0))) < len)
{
/* File 2 was smaller */
@@ -1473,7 +1457,7 @@ int compare_files2(File fd, const char* filename2)
break;
}
}
- if (!error && my_read(fd2, (byte*)&buff2,
+ if (!error && my_read(fd2, (uchar*)&buff2,
sizeof(buff2), MYF(0)) > 0)
{
/* File 1 was smaller */
@@ -1542,7 +1526,7 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname)
die("Failed to create temporary file for ds");
/* Write ds to temporary file and set file pos to beginning*/
- if (my_write(fd, ds->str, ds->length,
+ if (my_write(fd, (uchar *) ds->str, ds->length,
MYF(MY_FNABP | MY_WME)) ||
my_seek(fd, 0, SEEK_SET, MYF(0)) == MY_FILEPOS_ERROR)
{
@@ -1585,8 +1569,7 @@ void check_result(DYNAMIC_STRING* ds)
if (access(result_file_name, F_OK) != 0)
die("The specified result file does not exist: '%s'", result_file_name);
- switch (dyn_string_cmp(ds, result_file_name))
- {
+ switch (dyn_string_cmp(ds, result_file_name)) {
case RESULT_OK:
break; /* ok */
case RESULT_LENGTH_MISMATCH:
@@ -1599,7 +1582,8 @@ void check_result(DYNAMIC_STRING* ds)
and then show the diff
*/
char reject_file[FN_REFLEN];
- dirname_part(reject_file, result_file_name);
+ size_t reject_length;
+ dirname_part(reject_file, result_file_name, &reject_length);
if (access(reject_file, W_OK) == 0)
{
@@ -1702,13 +1686,13 @@ static void strip_parentheses(struct st_command *command)
}
-static byte *get_var_key(const byte* var, uint* len,
- my_bool __attribute__((unused)) t)
+static uchar *get_var_key(const uchar* var, size_t *len,
+ my_bool __attribute__((unused)) t)
{
register char* key;
key = ((VAR*)var)->name;
*len = ((VAR*)var)->name_len;
- return (byte*)key;
+ return (uchar*)key;
}
@@ -1752,7 +1736,7 @@ void var_free(void *v)
{
my_free(((VAR*) v)->str_val, MYF(MY_WME));
if (((VAR*)v)->alloced)
- my_free((char*) v, MYF(MY_WME));
+ my_free(v, MYF(MY_WME));
}
@@ -1764,7 +1748,7 @@ VAR* var_from_env(const char *name, const char *def_val)
tmp = def_val;
v = var_init(0, name, strlen(name), tmp, strlen(tmp));
- my_hash_insert(&var_hash, (byte*)v);
+ my_hash_insert(&var_hash, (uchar*)v);
return v;
}
@@ -1797,7 +1781,8 @@ VAR* var_get(const char *var_name, const char **var_name_end, my_bool raw,
if (length >= MAX_VAR_NAME_LENGTH)
die("Too long variable name: %s", save_var_name);
- if (!(v = (VAR*) hash_search(&var_hash, save_var_name, length)))
+ if (!(v = (VAR*) hash_search(&var_hash, (const uchar*) save_var_name,
+ length)))
{
char buff[MAX_VAR_NAME_LENGTH+1];
strmake(buff, save_var_name, length);
@@ -1828,10 +1813,10 @@ err:
VAR *var_obtain(const char *name, int len)
{
VAR* v;
- if ((v = (VAR*)hash_search(&var_hash, name, len)))
+ if ((v = (VAR*)hash_search(&var_hash, (const uchar *) name, len)))
return v;
v = var_init(0, name, len, "", 0);
- my_hash_insert(&var_hash, (byte*)v);
+ my_hash_insert(&var_hash, (uchar*)v);
return v;
}
@@ -1883,7 +1868,7 @@ void var_set(const char *var_name, const char *var_name_end,
if (!(v->env_s= my_strdup(buf, MYF(MY_WME))))
die("Out of memory");
putenv(v->env_s);
- my_free((gptr)old_env_s, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(old_env_s, MYF(MY_ALLOW_ZERO_PTR));
}
DBUG_VOID_RETURN;
}
@@ -1913,6 +1898,18 @@ void var_set_errno(int sql_errno)
var_set_int("$mysql_errno", sql_errno);
}
+
+/*
+ Update $mysql_get_server_version variable with version
+ of the currently connected server
+*/
+
+void var_set_mysql_get_server_version(MYSQL* mysql)
+{
+ var_set_int("$mysql_get_server_version", mysql_get_server_version(mysql));
+}
+
+
/*
Set variable from the result of a query
@@ -2032,7 +2029,7 @@ void var_set_query_get_value(struct st_command *command, VAR *var)
const struct command_arg query_get_value_args[] = {
"query", ARG_STRING, TRUE, &ds_query, "Query to run",
"column name", ARG_STRING, TRUE, &ds_col, "Name of column",
- "row number", ARG_STRING, TRUE, &ds_row, "Number for row",
+ "row number", ARG_STRING, TRUE, &ds_row, "Number for row"
};
DBUG_ENTER("var_set_query_get_value");
@@ -2222,7 +2219,7 @@ int open_file(const char *name)
if (!(cur_file->file = my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0))))
{
cur_file--;
- die("Could not open file '%s'", buff);
+ die("Could not open '%s' for reading", buff);
}
cur_file->file_name= my_strdup(buff, MYF(MY_FAE));
cur_file->lineno=1;
@@ -2248,7 +2245,7 @@ void do_source(struct st_command *command)
{
static DYNAMIC_STRING ds_filename;
const struct command_arg source_args[] = {
- "filename", ARG_STRING, TRUE, &ds_filename, "File to source"
+ { "filename", ARG_STRING, TRUE, &ds_filename, "File to source" }
};
DBUG_ENTER("do_source");
@@ -2315,9 +2312,10 @@ FILE* my_popen(DYNAMIC_STRING *ds_cmd, const char *mode)
static void init_builtin_echo(void)
{
#ifdef __WIN__
+ size_t echo_length;
/* Look for "echo.exe" in same dir as mysqltest was started from */
- dirname_part(builtin_echo, my_progname);
+ dirname_part(builtin_echo, my_progname, &echo_length);
fn_format(builtin_echo, ".\\echo.exe",
builtin_echo, "", MYF(MY_REPLACE_DIR));
@@ -2434,7 +2432,10 @@ void do_exec(struct st_command *command)
command->first_argument, ds_cmd.str));
if (!(res_file= my_popen(&ds_cmd, "r")) && command->abort_on_error)
+ {
+ dynstr_free(&ds_cmd);
die("popen(\"%s\", \"r\") failed", command->first_argument);
+ }
while (fgets(buf, sizeof(buf), res_file))
{
@@ -2458,6 +2459,7 @@ void do_exec(struct st_command *command)
{
log_msg("exec of '%s' failed, error: %d, status: %d, errno: %d",
ds_cmd.str, error, status, errno);
+ dynstr_free(&ds_cmd);
die("command \"%s\" failed", command->first_argument);
}
@@ -2476,8 +2478,11 @@ void do_exec(struct st_command *command)
}
}
if (!ok)
+ {
+ dynstr_free(&ds_cmd);
die("command \"%s\" failed with wrong error: %d",
command->first_argument, status);
+ }
}
else if (command->expected_errors.err[0].type == ERR_ERRNO &&
command->expected_errors.err[0].code.errnum != 0)
@@ -2485,6 +2490,7 @@ void do_exec(struct st_command *command)
/* Error code we wanted was != 0, i.e. not an expected success */
log_msg("exec of '%s failed, error: %d, errno: %d",
ds_cmd.str, error, errno);
+ dynstr_free(&ds_cmd);
die("command \"%s\" succeeded - should have failed with errno %d...",
command->first_argument, command->expected_errors.err[0].code.errnum);
}
@@ -2634,7 +2640,7 @@ void do_remove_file(struct st_command *command)
int error;
static DYNAMIC_STRING ds_filename;
const struct command_arg rm_args[] = {
- "filename", ARG_STRING, TRUE, &ds_filename, "File to delete"
+ { "filename", ARG_STRING, TRUE, &ds_filename, "File to delete" }
};
DBUG_ENTER("do_remove_file");
@@ -2668,8 +2674,8 @@ void do_copy_file(struct st_command *command)
static DYNAMIC_STRING ds_from_file;
static DYNAMIC_STRING ds_to_file;
const struct command_arg copy_file_args[] = {
- "from_file", ARG_STRING, TRUE, &ds_from_file, "Filename to copy from",
- "to_file", ARG_STRING, TRUE, &ds_to_file, "Filename to copy to"
+ { "from_file", ARG_STRING, TRUE, &ds_from_file, "Filename to copy from" },
+ { "to_file", ARG_STRING, TRUE, &ds_to_file, "Filename to copy to" }
};
DBUG_ENTER("do_copy_file");
@@ -2705,8 +2711,8 @@ void do_chmod_file(struct st_command *command)
static DYNAMIC_STRING ds_mode;
static DYNAMIC_STRING ds_file;
const struct command_arg chmod_file_args[] = {
- "mode", ARG_STRING, TRUE, &ds_mode, "Mode of file(octal) ex. 0660",
- "filename", ARG_STRING, TRUE, &ds_file, "Filename of file to modify"
+ { "mode", ARG_STRING, TRUE, &ds_mode, "Mode of file(octal) ex. 0660"},
+ { "filename", ARG_STRING, TRUE, &ds_file, "Filename of file to modify" }
};
DBUG_ENTER("do_chmod_file");
@@ -2743,7 +2749,7 @@ void do_file_exist(struct st_command *command)
int error;
static DYNAMIC_STRING ds_filename;
const struct command_arg file_exist_args[] = {
- "filename", ARG_STRING, TRUE, &ds_filename, "File to check if it exist"
+ { "filename", ARG_STRING, TRUE, &ds_filename, "File to check if it exist" }
};
DBUG_ENTER("do_file_exist");
@@ -2850,8 +2856,8 @@ void read_until_delimiter(DYNAMIC_STRING *ds,
{
char c;
DBUG_ENTER("read_until_delimiter");
- DBUG_PRINT("enter", ("delimiter: %s, length: %d",
- ds_delimiter->str, ds_delimiter->length));
+ DBUG_PRINT("enter", ("delimiter: %s, length: %u",
+ ds_delimiter->str, (uint) ds_delimiter->length));
if (ds_delimiter->length > MAX_DELIMITER_LENGTH)
die("Max delimiter length(%d) exceeded", MAX_DELIMITER_LENGTH);
@@ -2900,8 +2906,8 @@ void do_write_file_command(struct st_command *command, my_bool append)
static DYNAMIC_STRING ds_filename;
static DYNAMIC_STRING ds_delimiter;
const struct command_arg write_file_args[] = {
- "filename", ARG_STRING, TRUE, &ds_filename, "File to write to",
- "delimiter", ARG_STRING, FALSE, &ds_delimiter, "Delimiter to read until"
+ { "filename", ARG_STRING, TRUE, &ds_filename, "File to write to" },
+ { "delimiter", ARG_STRING, FALSE, &ds_delimiter, "Delimiter to read until" }
};
DBUG_ENTER("do_write_file");
@@ -3012,7 +3018,7 @@ void do_cat_file(struct st_command *command)
{
static DYNAMIC_STRING ds_filename;
const struct command_arg cat_file_args[] = {
- "filename", ARG_STRING, TRUE, &ds_filename, "File to read from"
+ { "filename", ARG_STRING, TRUE, &ds_filename, "File to read from" }
};
DBUG_ENTER("do_cat_file");
@@ -3049,8 +3055,8 @@ void do_diff_files(struct st_command *command)
static DYNAMIC_STRING ds_filename;
static DYNAMIC_STRING ds_filename2;
const struct command_arg diff_file_args[] = {
- "file1", ARG_STRING, TRUE, &ds_filename, "First file to diff",
- "file2", ARG_STRING, TRUE, &ds_filename2, "Second file to diff"
+ { "file1", ARG_STRING, TRUE, &ds_filename, "First file to diff" },
+ { "file2", ARG_STRING, TRUE, &ds_filename2, "Second file to diff" }
};
DBUG_ENTER("do_diff_files");
@@ -3120,7 +3126,7 @@ void do_send_quit(struct st_command *command)
if (!(con= find_connection_by_name(name)))
die("connection '%s' not found in connection pool", name);
- simple_command(&con->mysql,COM_QUIT,NullS,0,1);
+ simple_command(&con->mysql,COM_QUIT,0,0,1);
DBUG_VOID_RETURN;
}
@@ -3218,7 +3224,7 @@ void do_perl(struct st_command *command)
static DYNAMIC_STRING ds_script;
static DYNAMIC_STRING ds_delimiter;
const struct command_arg perl_args[] = {
- "delimiter", ARG_STRING, FALSE, &ds_delimiter, "Delimiter to read until"
+ { "delimiter", ARG_STRING, FALSE, &ds_delimiter, "Delimiter to read until" }
};
DBUG_ENTER("do_perl");
@@ -3371,13 +3377,17 @@ wait_for_position:
if (!(res= mysql_store_result(mysql)))
die("mysql_store_result() returned NULL for '%s'", query_buf);
if (!(row= mysql_fetch_row(res)))
+ {
+ mysql_free_result(res);
die("empty result in %s", query_buf);
+ }
if (!row[0])
{
/*
It may be that the slave SQL thread has not started yet, though START
SLAVE has been issued ?
*/
+ mysql_free_result(res);
if (tries++ == 30)
{
show_query(mysql, "SHOW MASTER STATUS");
@@ -3385,7 +3395,6 @@ wait_for_position:
die("could not sync with master ('%s' returned NULL)", query_buf);
}
sleep(1); /* So at most we will wait 30 seconds and make 31 tries */
- mysql_free_result(res);
goto wait_for_position;
}
mysql_free_result(res);
@@ -3426,6 +3435,7 @@ int do_save_master_pos()
MYSQL *mysql = &cur_con->mysql;
const char *query;
int rpl_parse;
+ DBUG_ENTER("do_save_master_pos");
rpl_parse = mysql_rpl_parse_enabled(mysql);
mysql_disable_rpl_parse(mysql);
@@ -3450,7 +3460,7 @@ int do_save_master_pos()
if (have_ndbcluster)
{
- ulonglong start_epoch= 0, applied_epoch= 0,
+ ulonglong start_epoch= 0, handled_epoch= 0,
latest_epoch=0, latest_trans_epoch=0,
latest_handled_binlog_epoch= 0, latest_received_binlog_epoch= 0,
latest_applied_binlog_epoch= 0;
@@ -3553,9 +3563,9 @@ int do_save_master_pos()
if (!row)
die("result does not contain '%s' in '%s'",
binlog, query);
- if (latest_applied_binlog_epoch > applied_epoch)
+ if (latest_handled_binlog_epoch > handled_epoch)
count= 0;
- applied_epoch= latest_applied_binlog_epoch;
+ handled_epoch= latest_handled_binlog_epoch;
count++;
if (latest_handled_binlog_epoch >= start_epoch)
do_continue= 0;
@@ -3583,7 +3593,7 @@ int do_save_master_pos()
if (rpl_parse)
mysql_enable_rpl_parse(mysql);
- return 0;
+ DBUG_RETURN(0);
}
@@ -4024,11 +4034,15 @@ void set_reconnect(MYSQL* mysql, int val)
int select_connection_name(const char *name)
{
- DBUG_ENTER("select_connection2");
+ DBUG_ENTER("select_connection_name");
DBUG_PRINT("enter",("name: '%s'", name));
if (!(cur_con= find_connection_by_name(name)))
die("connection '%s' not found in connection pool", name);
+
+ /* Update $mysql_get_server_version to that of current connection */
+ var_set_mysql_get_server_version(&cur_con->mysql);
+
DBUG_RETURN(0);
}
@@ -4047,7 +4061,7 @@ int select_connection(struct st_command *command)
if (*p)
*p++= 0;
command->last_argument= p;
- return select_connection_name(name);
+ DBUG_RETURN(select_connection_name(name));
}
@@ -4241,11 +4255,13 @@ int connect_n_handle_errors(struct st_command *command,
if (!mysql_real_connect(con, host, user, pass, db, port, sock ? sock: 0,
CLIENT_MULTI_STATEMENTS))
{
+ var_set_errno(mysql_errno(con));
handle_error(command, mysql_errno(con), mysql_error(con),
mysql_sqlstate(con), ds);
return 0; /* Not connected */
}
+ var_set_errno(0);
handle_no_error(command);
return 1; /* Connected */
}
@@ -4280,7 +4296,7 @@ void do_connect(struct st_command *command)
{
int con_port= opt_port;
char *con_options;
- bool con_ssl= 0, con_compress= 0;
+ my_bool con_ssl= 0, con_compress= 0;
struct st_connection* con_slot;
static DYNAMIC_STRING ds_connection_name;
@@ -4292,18 +4308,14 @@ void do_connect(struct st_command *command)
static DYNAMIC_STRING ds_sock;
static DYNAMIC_STRING ds_options;
const struct command_arg connect_args[] = {
- "connection name", ARG_STRING, TRUE, &ds_connection_name,
- "Name of the connection",
- "host", ARG_STRING, TRUE, &ds_host, "Host to connect to",
- "user", ARG_STRING, FALSE, &ds_user, "User to connect as",
- "passsword", ARG_STRING, FALSE, &ds_password,
- "Password used when connecting",
- "database", ARG_STRING, FALSE, &ds_database,
- "Dtabase to select after connect",
- "port", ARG_STRING, FALSE, &ds_port, "Port to connect to",
- "socket", ARG_STRING, FALSE, &ds_sock, "Socket to connect with",
- "options", ARG_STRING, FALSE, &ds_options,
- "Options to use while connecting"
+ { "connection name", ARG_STRING, TRUE, &ds_connection_name, "Name of the connection" },
+ { "host", ARG_STRING, TRUE, &ds_host, "Host to connect to" },
+ { "user", ARG_STRING, FALSE, &ds_user, "User to connect as" },
+ { "passsword", ARG_STRING, FALSE, &ds_password, "Password used when connecting" },
+ { "database", ARG_STRING, FALSE, &ds_database, "Database to select after connect" },
+ { "port", ARG_STRING, FALSE, &ds_port, "Port to connect to" },
+ { "socket", ARG_STRING, FALSE, &ds_sock, "Socket to connect with" },
+ { "options", ARG_STRING, FALSE, &ds_options, "Options to use while connecting" }
};
DBUG_ENTER("do_connect");
@@ -4430,6 +4442,9 @@ void do_connect(struct st_command *command)
next_con++; /* if we used the next_con slot, advance the pointer */
}
+ /* Update $mysql_get_server_version to that of current connection */
+ var_set_mysql_get_server_version(&cur_con->mysql);
+
dynstr_free(&ds_connection_name);
dynstr_free(&ds_host);
dynstr_free(&ds_user);
@@ -4661,7 +4676,7 @@ int read_line(char *buf, int size)
my_fclose(cur_file->file, MYF(0));
cur_file->file= 0;
}
- my_free((gptr)cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR));
+ my_free((uchar*) cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR));
cur_file->file_name= 0;
if (cur_file == file_stack)
{
@@ -5014,13 +5029,13 @@ int read_command(struct st_command** command_ptr)
if (parser.current_line < parser.read_lines)
{
- get_dynamic(&q_lines, (gptr) command_ptr, parser.current_line) ;
+ get_dynamic(&q_lines, (uchar*) command_ptr, parser.current_line) ;
DBUG_RETURN(0);
}
if (!(*command_ptr= command=
(struct st_command*) my_malloc(sizeof(*command),
MYF(MY_WME|MY_ZEROFILL))) ||
- insert_dynamic(&q_lines, (gptr) &command))
+ insert_dynamic(&q_lines, (uchar*) &command))
die(NullS);
command->type= Q_UNKNOWN;
@@ -5075,18 +5090,18 @@ static struct my_option my_long_options[] =
{
{"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG,
0, 0, 0, 0, 0, 0},
- {"basedir", 'b', "Basedir for tests.", (gptr*) &opt_basedir,
- (gptr*) &opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"basedir", 'b', "Basedir for tests.", (uchar**) &opt_basedir,
+ (uchar**) &opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"character-sets-dir", OPT_CHARSETS_DIR,
- "Directory where character sets are.", (gptr*) &opt_charsets_dir,
- (gptr*) &opt_charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ "Directory where character sets are.", (uchar**) &opt_charsets_dir,
+ (uchar**) &opt_charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"compress", 'C', "Use the compressed server/client protocol.",
- (gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
+ (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0},
{"cursor-protocol", OPT_CURSOR_PROTOCOL, "Use cursors for prepared statements.",
- (gptr*) &cursor_protocol, (gptr*) &cursor_protocol, 0,
+ (uchar**) &cursor_protocol, (uchar**) &cursor_protocol, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"database", 'D', "Database to use.", (gptr*) &opt_db, (gptr*) &opt_db, 0,
+ {"database", 'D', "Database to use.", (uchar**) &opt_db, (uchar**) &opt_db, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#ifdef DBUG_OFF
{"debug", '#', "This is a non-debug version. Catch this and exit",
@@ -5095,19 +5110,25 @@ static struct my_option my_long_options[] =
{"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif
- {"host", 'h', "Connect to host.", (gptr*) &opt_host, (gptr*) &opt_host, 0,
+ {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.",
+ (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0,
+ GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
+ (uchar**) &debug_info_flag, (uchar**) &debug_info_flag,
+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"host", 'h', "Connect to host.", (uchar**) &opt_host, (uchar**) &opt_host, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- {"include", 'i', "Include SQL before each test case.", (gptr*) &opt_include,
- (gptr*) &opt_include, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- {"logdir", OPT_LOG_DIR, "Directory for log files", (gptr*) &opt_logdir,
- (gptr*) &opt_logdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"include", 'i', "Include SQL before each test case.", (uchar**) &opt_include,
+ (uchar**) &opt_include, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"logdir", OPT_LOG_DIR, "Directory for log files", (uchar**) &opt_logdir,
+ (uchar**) &opt_logdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"mark-progress", OPT_MARK_PROGRESS,
"Write linenumber and elapsed time to <testname>.progress ",
- (gptr*) &opt_mark_progress, (gptr*) &opt_mark_progress, 0,
+ (uchar**) &opt_mark_progress, (uchar**) &opt_mark_progress, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"max-connect-retries", OPT_MAX_CONNECT_RETRIES,
"Max number of connection attempts when connecting to server",
- (gptr*) &opt_max_connect_retries, (gptr*) &opt_max_connect_retries, 0,
+ (uchar**) &opt_max_connect_retries, (uchar**) &opt_max_connect_retries, 0,
GET_INT, REQUIRED_ARG, 500, 1, 10000, 0, 0, 0},
{"password", 'p', "Password to use when connecting to server.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
@@ -5117,39 +5138,39 @@ static struct my_option my_long_options[] =
"/etc/services, "
#endif
"built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").",
- (gptr*) &opt_port,
- (gptr*) &opt_port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ (uchar**) &opt_port,
+ (uchar**) &opt_port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"ps-protocol", OPT_PS_PROTOCOL, "Use prepared statements protocol for communication",
- (gptr*) &ps_protocol, (gptr*) &ps_protocol, 0,
+ (uchar**) &ps_protocol, (uchar**) &ps_protocol, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"quiet", 's', "Suppress all normal output.", (gptr*) &silent,
- (gptr*) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"quiet", 's', "Suppress all normal output.", (uchar**) &silent,
+ (uchar**) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"record", 'r', "Record output of test_file into result file.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"result-file", 'R', "Read/Store result from/in this file.",
- (gptr*) &result_file_name, (gptr*) &result_file_name, 0,
+ (uchar**) &result_file_name, (uchar**) &result_file_name, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"server-arg", 'A', "Send option value to embedded server as a parameter.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"server-file", 'F', "Read embedded server arguments from file.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"silent", 's', "Suppress all normal output. Synonym for --quiet.",
- (gptr*) &silent, (gptr*) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ (uchar**) &silent, (uchar**) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"skip-safemalloc", OPT_SKIP_SAFEMALLOC,
"Don't use the memory allocation checking.", 0, 0, 0, GET_NO_ARG, NO_ARG,
0, 0, 0, 0, 0, 0},
{"sleep", 'T', "Sleep always this many seconds on sleep commands.",
- (gptr*) &opt_sleep, (gptr*) &opt_sleep, 0, GET_INT, REQUIRED_ARG, -1, -1, 0,
+ (uchar**) &opt_sleep, (uchar**) &opt_sleep, 0, GET_INT, REQUIRED_ARG, -1, -1, 0,
0, 0, 0},
{"socket", 'S', "Socket file to use for connection.",
- (gptr*) &unix_sock, (gptr*) &unix_sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
+ (uchar**) &unix_sock, (uchar**) &unix_sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
0, 0, 0},
{"sp-protocol", OPT_SP_PROTOCOL, "Use stored procedures for select",
- (gptr*) &sp_protocol, (gptr*) &sp_protocol, 0,
+ (uchar**) &sp_protocol, (uchar**) &sp_protocol, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"tail-lines", OPT_TAIL_LINES,
"Number of lines of the resul to include in a failure report",
- (gptr*) &opt_tail_lines, (gptr*) &opt_tail_lines, 0,
+ (uchar**) &opt_tail_lines, (uchar**) &opt_tail_lines, 0,
GET_INT, REQUIRED_ARG, 0, 0, 10000, 0, 0, 0},
#include "sslopt-longopts.h"
{"test-file", 'x', "Read test from/in this file (default stdin).",
@@ -5158,14 +5179,14 @@ static struct my_option my_long_options[] =
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"tmpdir", 't', "Temporary directory where sockets are put.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- {"user", 'u', "User for login.", (gptr*) &opt_user, (gptr*) &opt_user, 0,
+ {"user", 'u', "User for login.", (uchar**) &opt_user, (uchar**) &opt_user, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- {"verbose", 'v', "Write more.", (gptr*) &verbose, (gptr*) &verbose, 0,
+ {"verbose", 'v', "Write more.", (uchar**) &verbose, (uchar**) &verbose, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"view-protocol", OPT_VIEW_PROTOCOL, "Use views for select",
- (gptr*) &view_protocol, (gptr*) &view_protocol, 0,
+ (uchar**) &view_protocol, (uchar**) &view_protocol, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@@ -5248,6 +5269,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case '#':
#ifndef DBUG_OFF
DBUG_PUSH(argument ? argument : "d:t:S:i:O,/tmp/mysqltest.trace");
+ debug_check_flag= 1;
#endif
break;
case 'r':
@@ -5265,7 +5287,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
DBUG_ASSERT(cur_file == file_stack && cur_file->file == 0);
if (!(cur_file->file=
my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0))))
- die("Could not open %s: errno = %d", buff, errno);
+ die("Could not open '%s' for reading: errno = %d", buff, errno);
cur_file->file_name= my_strdup(buff, MYF(MY_FAE));
cur_file->lineno= 1;
break;
@@ -5347,6 +5369,10 @@ int parse_args(int argc, char **argv)
opt_db= *argv;
if (tty_password)
opt_pass= get_tty_password(NullS); /* purify tested */
+ if (debug_info_flag)
+ my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
+ if (debug_check_flag)
+ my_end_arg= MY_CHECK_ERROR;
return 0;
}
@@ -5378,10 +5404,10 @@ void str_to_file2(const char *fname, char *str, int size, my_bool append)
flags|= O_TRUNC;
if ((fd= my_open(buff, flags,
MYF(MY_WME | MY_FFNF))) < 0)
- die("Could not open %s: errno = %d", buff, errno);
+ die("Could not open '%s' for writing: errno = %d", buff, errno);
if (append && my_seek(fd, 0, SEEK_END, MYF(0)) == MY_FILEPOS_ERROR)
- die("Could not find end of file %s: errno = %d", buff, errno);
- if (my_write(fd, (byte*)str, size, MYF(MY_WME|MY_FNABP)))
+ die("Could not find end of file '%s': errno = %d", buff, errno);
+ if (my_write(fd, (uchar*)str, size, MYF(MY_WME|MY_FNABP)))
die("write failed");
my_close(fd, MYF(0));
}
@@ -5493,7 +5519,7 @@ void init_win_path_patterns()
continue;
}
- if (insert_dynamic(&patterns, (gptr) &p))
+ if (insert_dynamic(&patterns, (uchar*) &p))
die(NullS);
DBUG_PRINT("info", ("p: %s", p));
@@ -5513,7 +5539,7 @@ void free_win_path_patterns()
for (i=0 ; i < patterns.elements ; i++)
{
const char** pattern= dynamic_element(&patterns, i, const char**);
- my_free((gptr) *pattern, MYF(0));
+ my_free((char*) *pattern, MYF(0));
}
delete_dynamic(&patterns);
}
@@ -5569,7 +5595,7 @@ void fix_win_paths(const char *val, int len)
*/
void append_field(DYNAMIC_STRING *ds, uint col_idx, MYSQL_FIELD* field,
- const char* val, ulonglong len, bool is_null)
+ const char* val, ulonglong len, my_bool is_null)
{
if (col_idx < max_replace_column && replace_column[col_idx])
{
@@ -5695,12 +5721,12 @@ void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
for (i= 0; i < num_fields; i++)
{
/* Free data for output */
- my_free((gptr)my_bind[i].buffer, MYF(MY_WME | MY_FAE));
+ my_free(my_bind[i].buffer, MYF(MY_WME | MY_FAE));
}
/* Free array with bind structs, lengths and NULL flags */
- my_free((gptr)my_bind , MYF(MY_WME | MY_FAE));
- my_free((gptr)length , MYF(MY_WME | MY_FAE));
- my_free((gptr)is_null , MYF(MY_WME | MY_FAE));
+ my_free(my_bind , MYF(MY_WME | MY_FAE));
+ my_free(length , MYF(MY_WME | MY_FAE));
+ my_free(is_null , MYF(MY_WME | MY_FAE));
}
@@ -5990,11 +6016,8 @@ end:
ds - dynamic string which is used for output buffer
NOTE
- If there is an unexpected error this function will abort mysqltest
- immediately.
-
- RETURN VALUE
- error - function will not return
+ If there is an unexpected error this function will abort mysqltest
+ immediately.
*/
void handle_error(struct st_command *command,
@@ -6348,6 +6371,8 @@ int util_query(MYSQL* org_mysql, const char* query){
if (!(mysql= mysql_init(mysql)))
die("Failed in mysql_init()");
+ /* enable local infile, in non-binary builds often disabled by default */
+ mysql_options(mysql, MYSQL_OPT_LOCAL_INFILE, 0);
safe_connect(mysql, "util", org_mysql->host, org_mysql->user,
org_mysql->passwd, org_mysql->db, org_mysql->port,
org_mysql->unix_socket);
@@ -6941,6 +6966,9 @@ int main(int argc, char **argv)
*/
var_set_errno(-1);
+ /* Update $mysql_get_server_version to that of current connection */
+ var_set_mysql_get_server_version(&cur_con->mysql);
+
if (opt_include)
{
open_file(opt_include);
@@ -7345,7 +7373,7 @@ void timer_output(void)
ulonglong timer_now(void)
{
- return my_getsystime() / 10000;
+ return my_micro_time() / 1000;
}
@@ -7413,15 +7441,15 @@ void free_replace_column()
typedef struct st_pointer_array { /* when using array-strings */
TYPELIB typelib; /* Pointer to strings */
- byte *str; /* Strings is here */
+ uchar *str; /* Strings is here */
int7 *flag; /* Flag about each var. */
uint array_allocs,max_count,length,max_length;
} POINTER_ARRAY;
struct st_replace;
-struct st_replace *init_replace(my_string *from, my_string *to, uint count,
- my_string word_end_chars);
-int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name);
+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);
@@ -7485,7 +7513,7 @@ void free_replace()
DBUG_ENTER("free_replace");
if (glob_replace)
{
- my_free((char*) glob_replace,MYF(0));
+ my_free(glob_replace,MYF(0));
glob_replace=0;
}
DBUG_VOID_RETURN;
@@ -7493,12 +7521,12 @@ void free_replace()
typedef struct st_replace {
- bool found;
+ my_bool found;
struct st_replace *next[256];
} REPLACE;
typedef struct st_replace_found {
- bool found;
+ my_bool found;
char *replace_string;
uint to_offset;
int from_offset;
@@ -7696,7 +7724,7 @@ struct st_replace_regex* init_replace_regex(char* expr)
reg.icase= 1;
/* done parsing the statement, now place it in regex_arr */
- if (insert_dynamic(&res->regex_arr,(gptr) &reg))
+ if (insert_dynamic(&res->regex_arr,(uchar*) &reg))
die("Out of memory");
}
res->odd_buf_len= res->even_buf_len= 8192;
@@ -7707,7 +7735,7 @@ struct st_replace_regex* init_replace_regex(char* expr)
return res;
err:
- my_free((gptr)res,0);
+ my_free(res,0);
die("Error parsing replace_regex \"%s\"", expr);
return 0;
}
@@ -7748,7 +7776,7 @@ int multi_reg_replace(struct st_replace_regex* r,char* val)
struct st_regex re;
char* save_out_buf= out_buf;
- get_dynamic(&r->regex_arr,(gptr)&re,i);
+ get_dynamic(&r->regex_arr,(uchar*)&re,i);
if (!reg_replace(&out_buf, buf_len_p, re.pattern, re.replace,
in_buf, re.icase))
@@ -7801,7 +7829,7 @@ void free_replace_regex()
delete_dynamic(&glob_replace_regex->regex_arr);
my_free(glob_replace_regex->even_buf,MYF(MY_ALLOW_ZERO_PTR));
my_free(glob_replace_regex->odd_buf,MYF(MY_ALLOW_ZERO_PTR));
- my_free((char*) glob_replace_regex,MYF(0));
+ my_free(glob_replace_regex,MYF(0));
glob_replace_regex=0;
}
}
@@ -7996,7 +8024,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
str_p= str_end;
}
}
- my_free((gptr)subs, MYF(0));
+ my_free(subs, MYF(0));
my_regfree(&r);
*res_p= 0;
*buf_p= buf;
@@ -8056,13 +8084,13 @@ int get_next_bit(REP_SET *set,uint lastpos);
int find_set(REP_SETS *sets,REP_SET *find);
int find_found(FOUND_SET *found_set,uint table_offset,
int found_offset);
-uint start_at_word(my_string pos);
-uint end_of_word(my_string pos);
+uint start_at_word(char * pos);
+uint end_of_word(char * pos);
static uint found_sets=0;
-uint replace_len(my_string str)
+uint replace_len(char * str)
{
uint len=0;
while (*str)
@@ -8077,8 +8105,8 @@ uint replace_len(my_string str)
/* Init a replace structure for further calls */
-REPLACE *init_replace(my_string *from, my_string *to,uint count,
- my_string word_end_chars)
+REPLACE *init_replace(char * *from, char * *to,uint count,
+ char * word_end_chars)
{
static const int SPACE_CHAR= 256;
static const int START_OF_LINE= 257;
@@ -8087,7 +8115,7 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count,
uint i,j,states,set_nr,len,result_len,max_length,found_end,bits_set,bit_nr;
int used_sets,chr,default_state;
char used_chars[LAST_CHAR_CODE],is_word_end[256];
- my_string pos,to_pos,*to_array;
+ char * pos, *to_pos, **to_array;
REP_SETS sets;
REP_SET *set,*start_states,*word_states,*new_set;
FOLLOWS *follow,*follow_ptr;
@@ -8103,7 +8131,6 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count,
if (!len)
{
errno=EINVAL;
- my_message(0,"No to-string for last from-string",MYF(ME_BELL));
DBUG_RETURN(0);
}
states+=len+1;
@@ -8132,7 +8159,7 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count,
if (!(follow=(FOLLOWS*) my_malloc((states+2)*sizeof(FOLLOWS),MYF(MY_WME))))
{
free_sets(&sets);
- my_free((gptr) found_set,MYF(0));
+ my_free(found_set,MYF(0));
DBUG_RETURN(0);
}
@@ -8323,12 +8350,12 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count,
if ((replace=(REPLACE*) my_malloc(sizeof(REPLACE)*(sets.count)+
sizeof(REPLACE_STRING)*(found_sets+1)+
- sizeof(my_string)*count+result_len,
+ sizeof(char *)*count+result_len,
MYF(MY_WME | MY_ZEROFILL))))
{
rep_str=(REPLACE_STRING*) (replace+sets.count);
- to_array=(my_string*) (rep_str+found_sets+1);
- to_pos=(my_string) (to_array+count);
+ to_array= (char **) (rep_str+found_sets+1);
+ to_pos=(char *) (to_array+count);
for (i=0 ; i < count ; i++)
{
to_array[i]=to_pos;
@@ -8339,7 +8366,8 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count,
for (i=1 ; i <= found_sets ; i++)
{
pos=from[found_set[i-1].table_offset];
- rep_str[i].found= !bcmp(pos,"\\^",3) ? 2 : 1;
+ rep_str[i].found= !bcmp((const uchar*) pos,
+ (const uchar*) "\\^", 3) ? 2 : 1;
rep_str[i].replace_string=to_array[found_set[i-1].table_offset];
rep_str[i].to_offset=found_set[i-1].found_offset-start_at_word(pos);
rep_str[i].from_offset=found_set[i-1].found_offset-replace_len(pos)+
@@ -8354,9 +8382,9 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count,
replace[i].next[j]=(REPLACE*) (rep_str+(-sets.set[i].next[j]-1));
}
}
- my_free((gptr) follow,MYF(0));
+ my_free(follow,MYF(0));
free_sets(&sets);
- my_free((gptr) found_set,MYF(0));
+ my_free(found_set,MYF(0));
DBUG_PRINT("exit",("Replace table has %d states",sets.count));
DBUG_RETURN(replace);
}
@@ -8372,7 +8400,7 @@ int init_sets(REP_SETS *sets,uint states)
if (!(sets->bit_buffer=(uint*) my_malloc(sizeof(uint)*sets->size_of_bits*
SET_MALLOC_HUNC,MYF(MY_WME))))
{
- my_free((gptr) sets->set,MYF(0));
+ my_free(sets->set,MYF(0));
return 1;
}
return 0;
@@ -8404,13 +8432,13 @@ REP_SET *make_new_set(REP_SETS *sets)
return set;
}
count=sets->count+sets->invisible+SET_MALLOC_HUNC;
- if (!(set=(REP_SET*) my_realloc((gptr) sets->set_buffer,
+ if (!(set=(REP_SET*) my_realloc((uchar*) sets->set_buffer,
sizeof(REP_SET)*count,
MYF(MY_WME))))
return 0;
sets->set_buffer=set;
sets->set=set+sets->invisible;
- if (!(bit_buffer=(uint*) my_realloc((gptr) sets->bit_buffer,
+ if (!(bit_buffer=(uint*) my_realloc((uchar*) sets->bit_buffer,
(sizeof(uint)*sets->size_of_bits)*count,
MYF(MY_WME))))
return 0;
@@ -8433,8 +8461,8 @@ void free_last_set(REP_SETS *sets)
void free_sets(REP_SETS *sets)
{
- my_free((gptr)sets->set_buffer,MYF(0));
- my_free((gptr)sets->bit_buffer,MYF(0));
+ my_free(sets->set_buffer,MYF(0));
+ my_free(sets->bit_buffer,MYF(0));
return;
}
@@ -8461,13 +8489,13 @@ void or_bits(REP_SET *to,REP_SET *from)
void copy_bits(REP_SET *to,REP_SET *from)
{
- memcpy((byte*) to->bits,(byte*) from->bits,
+ memcpy((uchar*) to->bits,(uchar*) from->bits,
(size_t) (sizeof(uint) * to->size_of_bits));
}
int cmp_bits(REP_SET *set1,REP_SET *set2)
{
- return bcmp((byte*) set1->bits,(byte*) set2->bits,
+ return bcmp((uchar*) set1->bits,(uchar*) set2->bits,
sizeof(uint) * set1->size_of_bits);
}
@@ -8535,17 +8563,19 @@ int find_found(FOUND_SET *found_set,uint table_offset, int found_offset)
/* Return 1 if regexp starts with \b or ends with \b*/
-uint start_at_word(my_string pos)
+uint start_at_word(char * pos)
{
- return (((!bcmp(pos,"\\b",2) && pos[2]) || !bcmp(pos,"\\^",2)) ? 1 : 0);
+ return (((!bcmp((const uchar*) pos, (const uchar*) "\\b",2) && pos[2]) ||
+ !bcmp((const uchar*) pos, (const uchar*) "\\^", 2)) ? 1 : 0);
}
-uint end_of_word(my_string pos)
+uint end_of_word(char * pos)
{
- my_string end=strend(pos);
- return ((end > pos+2 && !bcmp(end-2,"\\b",2)) ||
- (end >= pos+2 && !bcmp(end-2,"\\$",2))) ?
- 1 : 0;
+ char * end=strend(pos);
+ return ((end > pos+2 && !bcmp((const uchar*) end-2,
+ (const uchar*) "\\b", 2)) ||
+ (end >= pos+2 && !bcmp((const uchar*) end-2,
+ (const uchar*) "\\$",2))) ? 1 : 0;
}
/****************************************************************************
@@ -8555,10 +8585,10 @@ uint end_of_word(my_string pos)
#define PC_MALLOC 256 /* Bytes for pointers */
#define PS_MALLOC 512 /* Bytes for data */
-int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name)
+int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name)
{
uint i,length,old_count;
- byte *new_pos;
+ uchar *new_pos;
const char **new_array;
DBUG_ENTER("insert_pointer_name");
@@ -8566,16 +8596,16 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name)
{
if (!(pa->typelib.type_names=(const char **)
my_malloc(((PC_MALLOC-MALLOC_OVERHEAD)/
- (sizeof(my_string)+sizeof(*pa->flag))*
- (sizeof(my_string)+sizeof(*pa->flag))),MYF(MY_WME))))
+ (sizeof(char *)+sizeof(*pa->flag))*
+ (sizeof(char *)+sizeof(*pa->flag))),MYF(MY_WME))))
DBUG_RETURN(-1);
- if (!(pa->str= (byte*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD),
+ if (!(pa->str= (uchar*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD),
MYF(MY_WME))))
{
- my_free((gptr) pa->typelib.type_names,MYF(0));
+ my_free((char*) pa->typelib.type_names,MYF(0));
DBUG_RETURN (-1);
}
- pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(byte*)+
+ pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(uchar*)+
sizeof(*pa->flag));
pa->flag= (int7*) (pa->typelib.type_names+pa->max_count);
pa->length=0;
@@ -8585,7 +8615,7 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name)
length=(uint) strlen(name)+1;
if (pa->length+length >= pa->max_length)
{
- if (!(new_pos= (byte*) my_realloc((gptr) pa->str,
+ if (!(new_pos= (uchar*) my_realloc((uchar*) pa->str,
(uint) (pa->max_length+PS_MALLOC),
MYF(MY_WME))))
DBUG_RETURN(1);
@@ -8604,23 +8634,23 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name)
int len;
pa->array_allocs++;
len=(PC_MALLOC*pa->array_allocs - MALLOC_OVERHEAD);
- if (!(new_array=(const char **) my_realloc((gptr) pa->typelib.type_names,
+ if (!(new_array=(const char **) my_realloc((uchar*) pa->typelib.type_names,
(uint) len/
- (sizeof(byte*)+sizeof(*pa->flag))*
- (sizeof(byte*)+sizeof(*pa->flag)),
+ (sizeof(uchar*)+sizeof(*pa->flag))*
+ (sizeof(uchar*)+sizeof(*pa->flag)),
MYF(MY_WME))))
DBUG_RETURN(1);
pa->typelib.type_names=new_array;
old_count=pa->max_count;
- pa->max_count=len/(sizeof(byte*) + sizeof(*pa->flag));
+ pa->max_count=len/(sizeof(uchar*) + sizeof(*pa->flag));
pa->flag= (int7*) (pa->typelib.type_names+pa->max_count);
- memcpy((byte*) pa->flag,(my_string) (pa->typelib.type_names+old_count),
+ memcpy((uchar*) pa->flag,(char *) (pa->typelib.type_names+old_count),
old_count*sizeof(*pa->flag));
}
pa->flag[pa->typelib.count]=0; /* Reset flag */
- pa->typelib.type_names[pa->typelib.count++]= pa->str+pa->length;
+ pa->typelib.type_names[pa->typelib.count++]= (char*) pa->str+pa->length;
pa->typelib.type_names[pa->typelib.count]= NullS; /* Put end-mark */
- VOID(strmov(pa->str+pa->length,name));
+ VOID(strmov((char*) pa->str+pa->length,name));
pa->length+=length;
DBUG_RETURN(0);
} /* insert_pointer_name */
@@ -8633,9 +8663,9 @@ void free_pointer_array(POINTER_ARRAY *pa)
if (pa->typelib.count)
{
pa->typelib.count=0;
- my_free((gptr) pa->typelib.type_names,MYF(0));
+ my_free((char*) pa->typelib.type_names,MYF(0));
pa->typelib.type_names=0;
- my_free((gptr) pa->str,MYF(0));
+ my_free(pa->str,MYF(0));
}
} /* free_pointer_array */
@@ -8732,7 +8762,7 @@ void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING *ds_input)
*line_end= 0;
/* Insert pointer to the line in array */
- if (insert_dynamic(&lines, (gptr) &start))
+ if (insert_dynamic(&lines, (uchar*) &start))
die("Out of memory inserting lines to sort");
start= line_end+1;