mirror of
https://github.com/MariaDB/server.git
synced 2025-09-02 09:41:40 +03:00
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/my/mysql-5.0 client/mysql.cc: Auto merged client/mysql_upgrade.c: Auto merged client/mysqltest.c: Auto merged extra/yassl/include/yassl_imp.hpp: Auto merged extra/yassl/include/yassl_int.hpp: Auto merged extra/yassl/taocrypt/include/algebra.hpp: Auto merged extra/yassl/taocrypt/include/des.hpp: Auto merged extra/yassl/taocrypt/include/modes.hpp: Auto merged extra/yassl/taocrypt/src/aes.cpp: Auto merged extra/yassl/taocrypt/src/algebra.cpp: Auto merged extra/yassl/taocrypt/test/test.cpp: Auto merged include/my_sys.h: Auto merged libmysql/libmysql.c: Auto merged libmysqld/lib_sql.cc: Auto merged myisam/mi_open.c: Auto merged myisam/myisampack.c: Auto merged mysql-test/r/mysqltest.result: Auto merged mysql-test/t/mysqltest.test: Auto merged ndb/src/common/util/File.cpp: Auto merged ndb/src/common/util/socket_io.cpp: Auto merged ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: Auto merged ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Auto merged ndb/src/kernel/blocks/dbdih/Dbdih.hpp: Auto merged ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Auto merged ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Auto merged ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Auto merged ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Auto merged ndb/src/mgmsrv/Services.cpp: Auto merged ndb/tools/ndb_config.cpp: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/handler.cc: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_func.cc: Auto merged sql/item_strfunc.cc: Auto merged sql/item_subselect.h: Auto merged sql/item_sum.cc: Auto merged sql/item_timefunc.cc: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/opt_range.cc: Auto merged sql/set_var.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_load.cc: Auto merged sql-common/my_time.c: Auto merged sql/sql_string.h: Auto merged sql/sql_table.cc: Auto merged sql/sql_trigger.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.cc: Auto merged strings/strtod.c: Auto merged tests/mysql_client_test.c: Auto merged extra/yassl/taocrypt/include/rsa.hpp: manual merge mysql-test/t/mysql.test: manual merge sql/sql_parse.cc: manual merge
This commit is contained in:
@@ -85,10 +85,10 @@ enum {
|
||||
};
|
||||
|
||||
static int record= 0, opt_sleep= -1;
|
||||
static char *db= 0, *pass= 0;
|
||||
const char *user= 0, *host= 0, *unix_sock= 0, *opt_basedir= "./";
|
||||
static char *opt_db= 0, *opt_pass= 0;
|
||||
const char *opt_user= 0, *opt_host= 0, *unix_sock= 0, *opt_basedir= "./";
|
||||
const char *opt_include= 0, *opt_charsets_dir;
|
||||
static int port= 0;
|
||||
static int opt_port= 0;
|
||||
static int opt_max_connect_retries;
|
||||
static my_bool opt_compress= 0, silent= 0, verbose= 0;
|
||||
static my_bool tty_password= 0;
|
||||
@@ -610,15 +610,14 @@ void check_command_args(struct st_command *command,
|
||||
int i;
|
||||
const char *ptr= arguments;
|
||||
const char *start;
|
||||
|
||||
DBUG_ENTER("check_command_args");
|
||||
DBUG_PRINT("enter", ("num_args: %d", num_args));
|
||||
|
||||
for (i= 0; i < num_args; i++)
|
||||
{
|
||||
const struct command_arg *arg= &args[i];
|
||||
|
||||
switch (arg->type)
|
||||
{
|
||||
switch (arg->type) {
|
||||
/* A string */
|
||||
case ARG_STRING:
|
||||
/* Skip leading spaces */
|
||||
@@ -769,7 +768,7 @@ void free_used_memory()
|
||||
dynstr_free(&ds_progress);
|
||||
dynstr_free(&ds_warning_messages);
|
||||
free_all_replace();
|
||||
my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(opt_pass,MYF(MY_ALLOW_ZERO_PTR));
|
||||
free_defaults(default_argv);
|
||||
free_re();
|
||||
#ifdef __WIN__
|
||||
@@ -1297,7 +1296,7 @@ void var_set_errno(int sql_errno)
|
||||
|
||||
void var_query_set(VAR *var, const char *query, const char** query_end)
|
||||
{
|
||||
char* end = (char*)((query_end && *query_end) ?
|
||||
char *end = (char*)((query_end && *query_end) ?
|
||||
*query_end : query + strlen(query));
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
@@ -1328,7 +1327,6 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
|
||||
DYNAMIC_STRING result;
|
||||
uint i;
|
||||
ulong *lengths;
|
||||
char *end;
|
||||
#ifdef NOT_YET
|
||||
MYSQL_FIELD *fields= mysql_fetch_fields(res);
|
||||
#endif
|
||||
@@ -2113,6 +2111,7 @@ void do_perl(struct st_command *command)
|
||||
int do_echo(struct st_command *command)
|
||||
{
|
||||
DYNAMIC_STRING ds_echo;
|
||||
DBUG_ENTER("do_echo");
|
||||
|
||||
init_dynamic_string(&ds_echo, "", command->query_len, 256);
|
||||
do_eval(&ds_echo, command->first_argument, command->end, FALSE);
|
||||
@@ -2120,7 +2119,7 @@ int do_echo(struct st_command *command)
|
||||
dynstr_append_mem(&ds_res, "\n", 1);
|
||||
dynstr_free(&ds_echo);
|
||||
command->last_argument= command->end;
|
||||
return(0);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -2416,7 +2415,6 @@ void do_let(struct st_command *command)
|
||||
char *p= command->first_argument;
|
||||
char *var_name, *var_name_end;
|
||||
DYNAMIC_STRING let_rhs_expr;
|
||||
|
||||
DBUG_ENTER("do_let");
|
||||
|
||||
init_dynamic_string(&let_rhs_expr, "", 512, 2048);
|
||||
@@ -3087,7 +3085,7 @@ int connect_n_handle_errors(struct st_command *command,
|
||||
|
||||
void do_connect(struct st_command *command)
|
||||
{
|
||||
int con_port= port;
|
||||
int con_port= opt_port;
|
||||
char *con_options;
|
||||
bool con_ssl= 0, con_compress= 0;
|
||||
char *ptr;
|
||||
@@ -3223,13 +3221,12 @@ void do_connect(struct st_command *command)
|
||||
|
||||
/* Use default db name */
|
||||
if (ds_database.length == 0)
|
||||
dynstr_set(&ds_database, db);
|
||||
dynstr_set(&ds_database, opt_db);
|
||||
|
||||
/* Special database to allow one to connect without a database name */
|
||||
if (ds_database.length && !strcmp(ds_database.str,"*NO-ONE*"))
|
||||
dynstr_set(&ds_database, "");
|
||||
|
||||
|
||||
if (connect_n_handle_errors(command, &next_con->mysql,
|
||||
ds_host.str,ds_user.str,
|
||||
ds_password.str, ds_database.str,
|
||||
@@ -3653,7 +3650,7 @@ int read_line(char *buf, int size)
|
||||
void convert_to_format_v1(char* query)
|
||||
{
|
||||
int last_c_was_quote= 0;
|
||||
char *p= query, *write= query;
|
||||
char *p= query, *to= query;
|
||||
char *end= strend(query);
|
||||
char last_c;
|
||||
|
||||
@@ -3661,7 +3658,7 @@ void convert_to_format_v1(char* query)
|
||||
{
|
||||
if (*p == '\n' && !last_c_was_quote)
|
||||
{
|
||||
*write++ = *p++; /* Save the newline */
|
||||
*to++ = *p++; /* Save the newline */
|
||||
|
||||
/* Skip any spaces on next line */
|
||||
while (*p && my_isspace(charset_info, *p))
|
||||
@@ -3672,19 +3669,19 @@ void convert_to_format_v1(char* query)
|
||||
else if (*p == '\'' || *p == '"' || *p == '`')
|
||||
{
|
||||
last_c= *p;
|
||||
*write++ = *p++;
|
||||
*to++ = *p++;
|
||||
|
||||
/* Copy anything until the next quote of same type */
|
||||
while (*p && *p != last_c)
|
||||
*write++ = *p++;
|
||||
*to++ = *p++;
|
||||
|
||||
*write++ = *p++;
|
||||
*to++ = *p++;
|
||||
|
||||
last_c_was_quote= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*write++ = *p++;
|
||||
*to++ = *p++;
|
||||
last_c_was_quote= 0;
|
||||
}
|
||||
}
|
||||
@@ -3802,19 +3799,17 @@ void check_eol_junk(const char *eol)
|
||||
Create a command from a set of lines
|
||||
|
||||
SYNOPSIS
|
||||
read_command()
|
||||
command_ptr pointer where to return the new query
|
||||
read_command()
|
||||
command_ptr pointer where to return the new query
|
||||
|
||||
DESCRIPTION
|
||||
Converts lines returned by read_line into a command, this involves
|
||||
parsing the first word in the read line to find the command type.
|
||||
|
||||
Converts lines returned by read_line into a command, this involves
|
||||
parsing the first word in the read line to find the command type.
|
||||
|
||||
A -- comment may contain a valid query as the first word after the
|
||||
comment start. Thus it's always checked to see if that is the case.
|
||||
The advantage with this approach is to be able to execute commands
|
||||
terminated by new line '\n' regardless how many "delimiter" it contain.
|
||||
|
||||
*/
|
||||
|
||||
#define MAX_QUERY (256*1024) /* 256K -- a test in sp-big is >128K */
|
||||
@@ -3900,7 +3895,7 @@ static struct my_option my_long_options[] =
|
||||
{"cursor-protocol", OPT_CURSOR_PROTOCOL, "Use cursors for prepared statements.",
|
||||
(gptr*) &cursor_protocol, (gptr*) &cursor_protocol, 0,
|
||||
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"database", 'D', "Database to use.", (gptr*) &db, (gptr*) &db, 0,
|
||||
{"database", 'D', "Database to use.", (gptr*) &opt_db, (gptr*) &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",
|
||||
@@ -3909,7 +3904,7 @@ 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*) &host, (gptr*) &host, 0,
|
||||
{"host", 'h', "Connect to host.", (gptr*) &opt_host, (gptr*) &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},
|
||||
@@ -3923,8 +3918,8 @@ static struct my_option my_long_options[] =
|
||||
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},
|
||||
{"port", 'P', "Port number to use for connection.", (gptr*) &port,
|
||||
(gptr*) &port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_port,
|
||||
(gptr*) &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,
|
||||
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
@@ -3960,8 +3955,8 @@ 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*) &user, (gptr*) &user, 0, GET_STR,
|
||||
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"user", 'u', "User for login.", (gptr*) &opt_user, (gptr*) &opt_user, 0,
|
||||
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"verbose", 'v', "Write more.", (gptr*) &verbose, (gptr*) &verbose, 0,
|
||||
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"version", 'V', "Output version information and exit.",
|
||||
@@ -4088,8 +4083,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
case 'p':
|
||||
if (argument)
|
||||
{
|
||||
my_free(pass, MYF(MY_ALLOW_ZERO_PTR));
|
||||
pass= my_strdup(argument, MYF(MY_FAE));
|
||||
my_free(opt_pass, MYF(MY_ALLOW_ZERO_PTR));
|
||||
opt_pass= my_strdup(argument, MYF(MY_FAE));
|
||||
while (*argument) *argument++= 'x'; /* Destroy argument */
|
||||
tty_password= 0;
|
||||
}
|
||||
@@ -4126,7 +4121,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
exit(0);
|
||||
case '?':
|
||||
usage();
|
||||
exit(1);
|
||||
exit(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -4146,9 +4141,9 @@ int parse_args(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
if (argc == 1)
|
||||
db= *argv;
|
||||
opt_db= *argv;
|
||||
if (tty_password)
|
||||
pass=get_tty_password(NullS);
|
||||
opt_pass= get_tty_password(NullS); /* purify tested */
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -4431,13 +4426,13 @@ void append_result(DYNAMIC_STRING *ds, MYSQL_RES *res)
|
||||
void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
|
||||
MYSQL_FIELD *fields, uint num_fields)
|
||||
{
|
||||
MYSQL_BIND *bind;
|
||||
MYSQL_BIND *my_bind;
|
||||
my_bool *is_null;
|
||||
ulong *length;
|
||||
uint i;
|
||||
|
||||
/* Allocate array with bind structs, lengths and NULL flags */
|
||||
bind= (MYSQL_BIND*) my_malloc(num_fields * sizeof(MYSQL_BIND),
|
||||
my_bind= (MYSQL_BIND*) my_malloc(num_fields * sizeof(MYSQL_BIND),
|
||||
MYF(MY_WME | MY_FAE | MY_ZEROFILL));
|
||||
length= (ulong*) my_malloc(num_fields * sizeof(ulong),
|
||||
MYF(MY_WME | MY_FAE));
|
||||
@@ -4448,25 +4443,25 @@ void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
|
||||
for (i= 0; i < num_fields; i++)
|
||||
{
|
||||
uint max_length= fields[i].max_length + 1;
|
||||
bind[i].buffer_type= MYSQL_TYPE_STRING;
|
||||
bind[i].buffer= (char *)my_malloc(max_length, MYF(MY_WME | MY_FAE));
|
||||
bind[i].buffer_length= max_length;
|
||||
bind[i].is_null= &is_null[i];
|
||||
bind[i].length= &length[i];
|
||||
my_bind[i].buffer_type= MYSQL_TYPE_STRING;
|
||||
my_bind[i].buffer= (char *)my_malloc(max_length, MYF(MY_WME | MY_FAE));
|
||||
my_bind[i].buffer_length= max_length;
|
||||
my_bind[i].is_null= &is_null[i];
|
||||
my_bind[i].length= &length[i];
|
||||
|
||||
DBUG_PRINT("bind", ("col[%d]: buffer_type: %d, buffer_length: %lu",
|
||||
i, bind[i].buffer_type, bind[i].buffer_length));
|
||||
i, my_bind[i].buffer_type, my_bind[i].buffer_length));
|
||||
}
|
||||
|
||||
if (mysql_stmt_bind_result(stmt, bind))
|
||||
if (mysql_stmt_bind_result(stmt, my_bind))
|
||||
die("mysql_stmt_bind_result failed: %d: %s",
|
||||
mysql_stmt_errno(stmt), mysql_stmt_error(stmt));
|
||||
|
||||
while (mysql_stmt_fetch(stmt) == 0)
|
||||
{
|
||||
for (i= 0; i < num_fields; i++)
|
||||
append_field(ds, i, &fields[i], (const char *) bind[i].buffer,
|
||||
*bind[i].length, *bind[i].is_null);
|
||||
append_field(ds, i, &fields[i], (const char *) my_bind[i].buffer,
|
||||
*my_bind[i].length, *my_bind[i].is_null);
|
||||
if (!display_result_vertically)
|
||||
dynstr_append_mem(ds, "\n", 1);
|
||||
}
|
||||
@@ -4478,10 +4473,10 @@ void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
|
||||
for (i= 0; i < num_fields; i++)
|
||||
{
|
||||
/* Free data for output */
|
||||
my_free((gptr)bind[i].buffer, MYF(MY_WME | MY_FAE));
|
||||
my_free((gptr)my_bind[i].buffer, MYF(MY_WME | MY_FAE));
|
||||
}
|
||||
/* Free array with bind structs, lengths and NULL flags */
|
||||
my_free((gptr)bind , MYF(MY_WME | MY_FAE));
|
||||
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));
|
||||
}
|
||||
@@ -4618,17 +4613,14 @@ int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql)
|
||||
/*
|
||||
Run query using MySQL C API
|
||||
|
||||
SYNPOSIS
|
||||
run_query_normal
|
||||
mysql - mysql handle
|
||||
command - currrent command pointer
|
||||
flags -flags indicating wheter to SEND and/or REAP
|
||||
query - query string to execute
|
||||
query_len - length query string to execute
|
||||
ds - output buffer wherte to store result form query
|
||||
|
||||
RETURN VALUE
|
||||
error - function will not return
|
||||
SYNOPSIS
|
||||
run_query_normal()
|
||||
mysql mysql handle
|
||||
command current command pointer
|
||||
flags flags indicating if we should SEND and/or REAP
|
||||
query query string to execute
|
||||
query_len length query string to execute
|
||||
ds output buffer where to store result form query
|
||||
*/
|
||||
|
||||
void run_query_normal(struct st_connection *cn, struct st_command *command,
|
||||
@@ -5146,15 +5138,14 @@ int util_query(MYSQL* org_mysql, const char* query){
|
||||
/*
|
||||
Run query
|
||||
|
||||
SYNPOSIS
|
||||
run_query()
|
||||
mysql mysql handle
|
||||
command currrent command pointer
|
||||
|
||||
flags control the phased/stages of query execution to be performed
|
||||
if QUERY_SEND_FLAG bit is on, the query will be sent. If QUERY_REAP_FLAG
|
||||
is on the result will be read - for regular query, both bits must be on
|
||||
|
||||
SYNPOSIS
|
||||
run_query
|
||||
mysql - mysql handle
|
||||
command - currrent command pointer
|
||||
|
||||
*/
|
||||
|
||||
void run_query(struct st_connection *cn, struct st_command *command, int flags)
|
||||
@@ -5169,6 +5160,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
|
||||
my_bool view_created= 0, sp_created= 0;
|
||||
my_bool complete_query= ((flags & QUERY_SEND_FLAG) &&
|
||||
(flags & QUERY_REAP_FLAG));
|
||||
DBUG_ENTER("run_query");
|
||||
|
||||
init_dynamic_string(&ds_warnings, NULL, 0, 256);
|
||||
|
||||
@@ -5334,7 +5326,6 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
|
||||
|
||||
if (command->require_file[0])
|
||||
{
|
||||
|
||||
/* A result file was specified for _this_ query
|
||||
and the output should be checked against an already
|
||||
existing file which has been specified using --require or --result
|
||||
@@ -5347,6 +5338,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
|
||||
dynstr_free(&ds_result);
|
||||
if (command->type == Q_EVAL)
|
||||
dynstr_free(&eval_query);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
@@ -5674,8 +5666,8 @@ int main(int argc, char **argv)
|
||||
if (!(cur_con->name = my_strdup("default", MYF(MY_WME))))
|
||||
die("Out of memory");
|
||||
|
||||
safe_connect(&cur_con->mysql, cur_con->name, host, user, pass,
|
||||
db, port, unix_sock);
|
||||
safe_connect(&cur_con->mysql, cur_con->name, opt_host, opt_user, opt_pass,
|
||||
opt_db, opt_port, unix_sock);
|
||||
|
||||
/* Use all time until exit if no explicit 'start_timer' */
|
||||
timer_start= timer_now();
|
||||
@@ -6038,8 +6030,6 @@ int main(int argc, char **argv)
|
||||
if (result_file_name && ds_warning_messages.length)
|
||||
dump_warning_messages();
|
||||
|
||||
dynstr_free(&ds_res);
|
||||
|
||||
timer_output();
|
||||
free_used_memory();
|
||||
my_end(MY_CHECK_ERROR);
|
||||
|
Reference in New Issue
Block a user