Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0

into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint


BitKeeper/etc/ignore:
  auto-union
client/mysqltest.c:
  Auto merged
extra/comp_err.c:
  Auto merged
include/my_time.h:
  Auto merged
mysql-test/r/innodb.result:
  Auto merged
mysql-test/r/mysqltest.result:
  Auto merged
mysql-test/r/type_blob.result:
  Auto merged
mysql-test/t/mysqltest.test:
  Auto merged
sql/item.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_cmpfunc.h:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/log.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.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/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/tztime.cc:
  Auto merged
client/mysql_upgrade.c:
  Manual merge
mysql-test/mysql-test-run.pl:
  Manual merge
mysql-test/r/ctype_cp932.result:
  Manual merge
mysql-test/r/mysqlbinlog.result:
  Manual merge
mysql-test/t/ctype_cp932.test:
  Manual merge
mysql-test/t/mysql.test:
  Manual merge
mysql-test/t/mysqlbinlog.test:
  Manual merge
This commit is contained in:
unknown 2007-03-01 18:12:56 +01:00
commit 4a9edcc32c
355 changed files with 6707 additions and 4144 deletions

View File

@ -49,11 +49,14 @@ SSL_LIBRARY=--with-yassl
# If you are not using codefusion add "-Wpointer-arith" to WARNINGS
# The following warning flag will give too many warnings:
# -Wshadow -Wunused -Winline (The later isn't usable in C++ as
# -Wunused -Winline (The later isn't usable in C++ as
# __attribute()__ doesn't work with gnu C++)
global_warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings"
#debug_extra_warnings="-Wuninitialized"
global_warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Wunused-function -Wunused-label -Wunused-value -Wunused-variable"
#
# For more warnings, uncomment the following line
# global_warnings="$global_warnings -Wshadow"
c_warnings="$global_warnings -Wunused"
cxx_warnings="$global_warnings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor"
base_max_configs="--with-innodb --with-ndbcluster --with-archive-storage-engine --with-big-tables --with-blackhole-storage-engine --with-federated-storage-engine --with-csv-storage-engine $SSL_LIBRARY"

View File

@ -14,7 +14,9 @@ export LDFLAGS="-fprofile-arcs -ftest-coverage"
# The -fprofile-arcs and -ftest-coverage options cause GCC to instrument the
# code with profiling information used by gcov.
# the -DDISABLE_TAO_ASM is needed to avoid build failures in Yassl.
extra_flags="$pentium_cflags -fprofile-arcs -ftest-coverage -DDISABLE_TAO_ASM"
extra_flags="$pentium_cflags -fprofile-arcs -ftest-coverage -DDISABLE_TAO_ASM $debug_cflags $max_cflags -DMYSQL_SERVER_SUFFIX=-gcov"
c_warnings="$c_warnings $debug_extra_warnings"
cxx_warnings="$cxx_warnings $debug_extra_warnings"
extra_configs="$pentium_configs $debug_configs --disable-shared $static_link"
extra_configs="$extra_configs $max_configs"

View File

@ -131,7 +131,7 @@ typedef enum enum_info_type INFO_TYPE;
static MYSQL mysql; /* The connection */
static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0,
connected=0,opt_raw_data=0,unbuffered=0,output_tables=0,
rehash=1,skip_updates=0,safe_updates=0,one_database=0,
opt_rehash=1,skip_updates=0,safe_updates=0,one_database=0,
opt_compress=0, using_opt_local_infile=0,
vertical=0, line_numbers=1, column_names=1,opt_html=0,
opt_xml=0,opt_nopager=1, opt_outfile=0, named_cmds= 0,
@ -585,7 +585,8 @@ static struct my_option my_long_options[] =
#endif
{"auto-rehash", OPT_AUTO_REHASH,
"Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash.",
(gptr*) &rehash, (gptr*) &rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
(gptr*) &opt_rehash, (gptr*) &opt_rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0,
0, 0},
{"no-auto-rehash", 'A',
"No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
@ -888,7 +889,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
}
break;
case 'A':
rehash= 0;
opt_rehash= 0;
break;
case 'N':
column_names= 0;
@ -1768,15 +1769,17 @@ char *rindex(const char *s,int c)
static int reconnect(void)
{
/* purecov: begin tested */
if (opt_reconnect)
{
put_info("No connection. Trying to reconnect...",INFO_INFO);
(void) com_connect((String *) 0, 0);
if (rehash)
if (opt_rehash)
com_rehash(NULL, NULL);
}
if (!connected)
return put_info("Can't connect to the server\n",INFO_ERROR);
/* purecov: end */
return 0;
}
@ -2941,7 +2944,7 @@ static int
com_connect(String *buffer, char *line)
{
char *tmp, buff[256];
bool save_rehash= rehash;
bool save_rehash= opt_rehash;
int error;
bzero(buff, sizeof(buff));
@ -2965,13 +2968,16 @@ com_connect(String *buffer, char *line)
}
}
else
rehash= 0; // Quick re-connect
{
/* Quick re-connect */
opt_rehash= 0; /* purecov: tested */
}
buffer->length(0); // command used
}
else
rehash= 0;
opt_rehash= 0;
error=sql_connect(current_host,current_db,current_user,opt_password,0);
rehash= save_rehash;
opt_rehash= save_rehash;
if (connected)
{
@ -3133,7 +3139,7 @@ com_use(String *buffer __attribute__((unused)), char *line)
current_db=my_strdup(tmp,MYF(MY_WME));
#ifdef HAVE_READLINE
if (select_db > 1)
build_completion_hash(rehash, 1);
build_completion_hash(opt_rehash, 1);
#endif
}
@ -3287,7 +3293,7 @@ sql_real_connect(char *host,char *database,char *user,char *password,
mysql.reconnect= 1;
#endif
#ifdef HAVE_READLINE
build_completion_hash(rehash, 1);
build_completion_hash(opt_rehash, 1);
#endif
return 0;
}
@ -3332,8 +3338,8 @@ static int
com_status(String *buffer __attribute__((unused)),
char *line __attribute__((unused)))
{
const char *status;
char buff[22];
const char *status_str;
char buff[40];
ulonglong id;
MYSQL_RES *result;
LINT_INIT(result);
@ -3359,9 +3365,9 @@ com_status(String *buffer __attribute__((unused)),
mysql_free_result(result);
}
#ifdef HAVE_OPENSSL
if ((status= mysql_get_ssl_cipher(&mysql)))
if ((status_str= mysql_get_ssl_cipher(&mysql)))
tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n",
status);
status_str);
else
#endif /* HAVE_OPENSSL */
tee_puts("SSL:\t\t\tNot in use", stdout);
@ -3420,23 +3426,20 @@ com_status(String *buffer __attribute__((unused)),
tee_fprintf(stdout, "Protocol:\t\tCompressed\n");
#endif
if ((status=mysql_stat(&mysql)) && !mysql_error(&mysql)[0])
if ((status_str= mysql_stat(&mysql)) && !mysql_error(&mysql)[0])
{
ulong sec;
char buff[40];
const char *pos= strchr(status,' ');
const char *pos= strchr(status_str,' ');
/* print label */
tee_fprintf(stdout, "%.*s\t\t\t", (int) (pos-status), status);
if ((status=str2int(pos,10,0,LONG_MAX,(long*) &sec)))
tee_fprintf(stdout, "%.*s\t\t\t", (int) (pos-status_str), status_str);
if ((status_str= str2int(pos,10,0,LONG_MAX,(long*) &sec)))
{
nice_time((double) sec,buff,0);
tee_puts(buff, stdout); /* print nice time */
while (*status == ' ') status++; /* to next info */
}
if (status)
{
while (*status_str == ' ')
status_str++; /* to next info */
tee_putc('\n', stdout);
tee_puts(status, stdout);
tee_puts(status_str, stdout);
}
}
if (safe_updates)
@ -3456,7 +3459,7 @@ select_limit, max_join_size);
}
static const char *
server_version_string(MYSQL *mysql)
server_version_string(MYSQL *con)
{
static char buf[MAX_SERVER_VERSION_LENGTH] = "";
@ -3466,11 +3469,11 @@ server_version_string(MYSQL *mysql)
char *bufp = buf;
MYSQL_RES *result;
bufp = strnmov(buf, mysql_get_server_info(mysql), sizeof buf);
bufp= strnmov(buf, mysql_get_server_info(con), sizeof buf);
/* "limit 1" is protection against SQL_SELECT_LIMIT=0 */
if (!mysql_query(mysql, "select @@version_comment limit 1") &&
(result = mysql_use_result(mysql)))
if (!mysql_query(con, "select @@version_comment limit 1") &&
(result = mysql_use_result(con)))
{
MYSQL_ROW cur = mysql_fetch_row(result);
if (cur && cur[0])
@ -3560,10 +3563,10 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate)
static int
put_error(MYSQL *mysql)
put_error(MYSQL *con)
{
return put_info(mysql_error(mysql), INFO_ERROR, mysql_errno(mysql),
mysql_sqlstate(mysql));
return put_info(mysql_error(con), INFO_ERROR, mysql_errno(con),
mysql_sqlstate(con));
}
@ -3822,8 +3825,6 @@ static const char* construct_prompt()
break;
case 'D':
char* dateTime;
time_t lclock;
lclock = time(NULL);
dateTime = ctime(&lclock);
processed_prompt.append(strtok(dateTime,"\n"));
break;

View File

@ -173,7 +173,7 @@ void set_extra_default(int id, const struct my_option *opt)
}
d= (extra_default_t *)my_malloc(sizeof(extra_default_t),
MYF(MY_FAE|MY_ZEROFILL));
MYF(MY_FAE | MY_ZEROFILL));
d->id= id;
d->name= opt->name;
d->n_len= strlen(opt->name);
@ -463,8 +463,9 @@ int main(int argc, char **argv)
char *forced_defaults_file;
char *forced_extra_defaults;
char *local_defaults_group_suffix;
int no_defaults;
char path[FN_REFLEN], upgrade_defaults_path[FN_REFLEN];
DYNAMIC_STRING cmdline;
MY_INIT(argv[0]);
@ -473,6 +474,10 @@ int main(int argc, char **argv)
#endif
/* Check if we are forced to use specific defaults */
no_defaults= 0;
if (argc >= 2 && !strcmp(argv[1],"--no-defaults"))
no_defaults= 1;
get_defaults_options(argc, argv,
&forced_defaults_file, &forced_extra_defaults,
&local_defaults_group_suffix);
@ -586,7 +591,9 @@ int main(int argc, char **argv)
instruct mysqlcheck to only read options from that file
*/
dynstr_append(&cmdline, " ");
dynstr_append_os_quoted(&cmdline, "--defaults-file=",
dynstr_append_os_quoted(&cmdline,
(no_defaults ? "--defaults-file=" :
"--defaults-extra-file="),
upgrade_defaults_path, NullS);
dynstr_append(&cmdline, " ");
dynstr_append_os_quoted(&cmdline, "--check-upgrade", NullS);
@ -661,7 +668,9 @@ fix_priv_tables:
instruct mysql to only read options from that file
*/
dynstr_append(&cmdline, " ");
dynstr_append_os_quoted(&cmdline, "--defaults-file=",
dynstr_append_os_quoted(&cmdline,
(no_defaults ? "--defaults-file=" :
"--defaults-extra-file="),
upgrade_defaults_path, NullS);
dynstr_append(&cmdline, " ");
dynstr_append_os_quoted(&cmdline, "--force", NullS);

View File

@ -91,15 +91,14 @@ static bool stop_passed= 0;
This is because the event will be created (alloced) in read_log_event()
(which returns a pointer) in check_header().
*/
Format_description_log_event* description_event;
Format_description_log_event* glob_description_event;
static int dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
const char* logname);
static int dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
const char* logname);
static int dump_log_entries(const char* logname);
static int dump_remote_file(NET* net, const char* fname);
static void die(const char* fmt, ...);
static void die(const char* fmt, ...) __attribute__ ((__noreturn__));
static MYSQL* safe_connect();
@ -560,7 +559,7 @@ int process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
ce->print(result_file, print_event_info, TRUE);
// If this binlog is not 3.23 ; why this test??
if (description_event->binlog_version >= 3)
if (glob_description_event->binlog_version >= 3)
{
if (load_processor.process(ce))
break; // Error
@ -595,9 +594,9 @@ Create_file event for file_id: %u\n",exv->file_id);
break;
}
case FORMAT_DESCRIPTION_EVENT:
delete description_event;
description_event= (Format_description_log_event*) ev;
print_event_info->common_header_len= description_event->common_header_len;
delete glob_description_event;
glob_description_event= (Format_description_log_event*) ev;
print_event_info->common_header_len= glob_description_event->common_header_len;
ev->print(result_file, print_event_info);
/*
We don't want this event to be deleted now, so let's hide it (I
@ -803,7 +802,7 @@ static void die(const char* fmt, ...)
static void print_version()
{
printf("%s Ver 3.1 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
printf("%s Ver 3.2 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
NETWARE_SET_SCREEN_MODE(1);
}
@ -974,7 +973,7 @@ static int dump_log_entries(const char* logname)
This is not as smart as check_header() (used for local log); it will not work
for a binlog which mixes format. TODO: fix this.
*/
static int check_master_version(MYSQL* mysql,
static int check_master_version(MYSQL *mysql_arg,
Format_description_log_event
**description_event)
{
@ -982,26 +981,31 @@ static int check_master_version(MYSQL* mysql,
MYSQL_ROW row;
const char* version;
if (mysql_query(mysql, "SELECT VERSION()") ||
!(res = mysql_store_result(mysql)))
if (mysql_query(mysql_arg, "SELECT VERSION()") ||
!(res = mysql_store_result(mysql_arg)))
{
/* purecov: begin inspected */
char errmsg[256];
strmake(errmsg, mysql_error(mysql), sizeof(errmsg)-1);
mysql_close(mysql);
strmake(errmsg, mysql_error(mysql_arg), sizeof(errmsg)-1);
mysql_close(mysql_arg);
die("Error checking master version: %s", errmsg);
/* purecov: end */
}
if (!(row = mysql_fetch_row(res)))
{
/* purecov: begin inspected */
mysql_free_result(res);
mysql_close(mysql);
die("Master returned no rows for SELECT VERSION()");
return 1;
/* purecov: end */
}
if (!(version = row[0]))
{
/* purecov: begin inspected */
mysql_free_result(res);
mysql_close(mysql);
mysql_close(mysql_arg);
die("Master reported NULL for the version");
/* purecov: end */
}
switch (*version) {
@ -1020,11 +1024,11 @@ static int check_master_version(MYSQL* mysql,
*description_event= new Format_description_log_event(3);
break;
default:
sql_print_error("Master reported unrecognized MySQL version '%s'",
version);
/* purecov: begin inspected */
mysql_free_result(res);
mysql_close(mysql);
return 1;
mysql_close(mysql_arg);
die("Master reported unrecognized MySQL version '%s'", version);
/* purecov: end */
}
mysql_free_result(res);
return 0;
@ -1052,12 +1056,12 @@ static int dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
mysql= safe_connect();
net= &mysql->net;
if (check_master_version(mysql, &description_event))
if (check_master_version(mysql, &glob_description_event))
{
fprintf(stderr, "Could not find server version");
DBUG_RETURN(1);
}
if (!description_event || !description_event->is_valid())
if (!glob_description_event || !glob_description_event->is_valid())
{
fprintf(stderr, "Invalid Format_description log event; \
could be out of memory");
@ -1107,7 +1111,7 @@ could be out of memory");
len, net->read_pos[5]));
if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 ,
len - 1, &error_msg,
description_event)))
glob_description_event)))
{
fprintf(stderr, "Could not construct log event object\n");
error= 1;
@ -1115,7 +1119,7 @@ could be out of memory");
}
Log_event_type type= ev->get_type_code();
if (description_event->binlog_version >= 3 ||
if (glob_description_event->binlog_version >= 3 ||
(type != LOAD_EVENT && type != CREATE_FILE_EVENT))
{
/*
@ -1321,7 +1325,7 @@ static int dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
my_close(fd, MYF(MY_WME));
return 1;
}
check_header(file, &description_event);
check_header(file, &glob_description_event);
}
else // reading from stdin;
{
@ -1347,7 +1351,7 @@ static int dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
if (init_io_cache(file, fileno(stdin), 0, READ_CACHE, (my_off_t) 0,
0, MYF(MY_WME | MY_NABP | MY_DONT_CHECK_FILESIZE)))
return 1;
check_header(file, &description_event);
check_header(file, &glob_description_event);
if (start_position)
{
/* skip 'start_position' characters from stdin */
@ -1365,7 +1369,7 @@ static int dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
}
}
if (!description_event || !description_event->is_valid())
if (!glob_description_event || !glob_description_event->is_valid())
die("Invalid Format_description log event; could be out of memory");
if (!start_position && my_b_read(file, tmp_buff, BIN_LOG_HEADER_SIZE))
@ -1378,14 +1382,14 @@ static int dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
char llbuff[21];
my_off_t old_off = my_b_tell(file);
Log_event* ev = Log_event::read_log_event(file, description_event);
Log_event* ev = Log_event::read_log_event(file, glob_description_event);
if (!ev)
{
/*
if binlog wasn't closed properly ("in use" flag is set) don't complain
about a corruption, but treat it as EOF and move to the next binlog.
*/
if (description_event->flags & LOG_EVENT_BINLOG_IN_USE_F)
if (glob_description_event->flags & LOG_EVENT_BINLOG_IN_USE_F)
file->error= 0;
else if (file->error)
{
@ -1410,7 +1414,7 @@ end:
if (fd >= 0)
my_close(fd, MYF(MY_WME));
end_io_cache(file);
delete description_event;
delete glob_description_event;
return error;
}

View File

@ -111,7 +111,7 @@ static char compatible_mode_normal_str[255];
static ulong opt_compatible_mode= 0;
#define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL 1
#define MYSQL_OPT_MASTER_DATA_COMMENTED_SQL 2
static uint opt_mysql_port= 0, err_len= 0, opt_master_data;
static uint opt_mysql_port= 0, opt_master_data;
static my_string opt_mysql_unix_port=0;
static int first_error=0;
static DYNAMIC_STRING extended_row;
@ -723,6 +723,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *end= compatible_mode_normal_str;
int i;
ulong mode;
uint err_len;
opt_quoted= 1;
opt_set_charset= 0;
@ -860,11 +861,11 @@ static int get_options(int *argc, char ***argv)
/*
** DB_error -- prints mysql error message and exits the program.
*/
static void DB_error(MYSQL *mysql, const char *when)
static void DB_error(MYSQL *mysql_arg, const char *when)
{
DBUG_ENTER("DB_error");
fprintf(stderr, "%s: Got error: %d: %s %s\n", my_progname,
mysql_errno(mysql), mysql_error(mysql), when);
mysql_errno(mysql_arg), mysql_error(mysql_arg), when);
fflush(stderr);
safe_exit(EX_MYSQLERR);
DBUG_VOID_RETURN;
@ -1192,7 +1193,7 @@ static void print_quoted_xml(FILE *xml_file, const char *str, ulong len)
..., attribute_name_n, attribute_value_n, NullS)
xml_file - output file
sbeg - line beginning
send - line ending
line_end - line ending
tag_name - XML tag name.
first_attribute_name - tag and first attribute
first_attribute_value - (Implied) value of first attribute
@ -1212,7 +1213,8 @@ static void print_quoted_xml(FILE *xml_file, const char *str, ulong len)
All attribute_value arguments will be quoted before output.
*/
static void print_xml_tag(FILE * xml_file, const char* sbeg, const char* send,
static void print_xml_tag(FILE * xml_file, const char* sbeg,
const char* line_end,
const char* tag_name,
const char* first_attribute_name, ...)
{
@ -1242,7 +1244,7 @@ static void print_xml_tag(FILE * xml_file, const char* sbeg, const char* send,
va_end(arg_list);
fputc('>', xml_file);
fputs(send, xml_file);
fputs(line_end, xml_file);
check_io(xml_file);
}
@ -1256,7 +1258,7 @@ static void print_xml_tag(FILE * xml_file, const char* sbeg, const char* send,
sbeg - line beginning
stag_atr - tag and attribute
sval - value of attribute
send - line ending
line_end - line ending
DESCRIPTION
Print tag with one attribute to the xml_file. Format is:
@ -1268,7 +1270,7 @@ static void print_xml_tag(FILE * xml_file, const char* sbeg, const char* send,
static void print_xml_null_tag(FILE * xml_file, const char* sbeg,
const char* stag_atr, const char* sval,
const char* send)
const char* line_end)
{
fputs(sbeg, xml_file);
fputs("<", xml_file);
@ -1276,7 +1278,7 @@ static void print_xml_null_tag(FILE * xml_file, const char* sbeg,
fputs("\"", xml_file);
print_quoted_xml(xml_file, sval, strlen(sval));
fputs("\" xsi:nil=\"true\" />", xml_file);
fputs(send, xml_file);
fputs(line_end, xml_file);
check_io(xml_file);
}
@ -2014,7 +2016,8 @@ continue_xml:
*/
static void dump_triggers_for_table(char *table, char *db)
static void dump_triggers_for_table(char *table,
char *db __attribute__((unused)))
{
char *result_table;
char name_buff[NAME_LEN*4+3], table_buff[NAME_LEN*2+3];
@ -2023,7 +2026,6 @@ static void dump_triggers_for_table(char *table, char *db)
FILE *sql_file= md_result_file;
MYSQL_RES *result;
MYSQL_ROW row;
DBUG_ENTER("dump_triggers_for_table");
DBUG_PRINT("enter", ("db: %s, table: %s", db, table));

View File

@ -89,10 +89,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;
@ -623,15 +623,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 */
@ -796,7 +795,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__
@ -1345,7 +1344,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;
@ -1376,7 +1375,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
@ -1973,7 +1971,7 @@ void do_copy_file(struct st_command *command)
void do_chmod_file(struct st_command *command)
{
ulong mode= 0;
long mode= 0;
static DYNAMIC_STRING ds_mode;
static DYNAMIC_STRING ds_file;
const struct command_arg chmod_file_args[] = {
@ -2425,6 +2423,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);
@ -2432,7 +2431,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);
}
@ -2728,7 +2727,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);
@ -3408,7 +3406,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;
@ -3544,13 +3542,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,
@ -3974,7 +3971,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;
@ -3982,7 +3979,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))
@ -3993,19 +3990,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;
}
}
@ -4123,19 +4120,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 */
@ -4221,7 +4216,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",
@ -4230,7 +4225,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},
@ -4244,8 +4239,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},
@ -4281,8 +4276,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.",
@ -4409,8 +4404,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;
}
@ -4447,7 +4442,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
exit(0);
case '?':
usage();
exit(1);
exit(0);
}
return 0;
}
@ -4467,9 +4462,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;
}
@ -4772,13 +4767,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));
@ -4789,25 +4784,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);
}
@ -4819,10 +4814,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));
}
@ -4959,17 +4954,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,
@ -5495,15 +5487,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)
@ -5518,6 +5509,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);
@ -5683,7 +5675,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
@ -5696,6 +5687,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;
}
/****************************************************************************/
@ -6025,8 +6017,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();
@ -6396,8 +6388,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);
@ -6608,7 +6598,8 @@ typedef struct st_replace_found {
void replace_strings_append(REPLACE *rep, DYNAMIC_STRING* ds,
const char *str, int len)
const char *str,
int len __attribute__((unused)))
{
reg1 REPLACE *rep_pos;
reg2 REPLACE_STRING *rep_str;
@ -6999,7 +6990,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
we need at least what we have so far in the buffer + the part
before this match
*/
need_buf_len= (res_p - buf) + subs[0].rm_so;
need_buf_len= (res_p - buf) + (int) subs[0].rm_so;
/* on this pass, calculate the memory for the result buffer */
while (expr_p < replace_end)
@ -7009,17 +7000,17 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
if (c == '\\' && expr_p + 1 < replace_end)
{
back_ref_num= expr_p[1] - '0';
back_ref_num= (int) (expr_p[1] - '0');
}
/* found a valid back_ref (eg. \1)*/
if (back_ref_num >= 0 && back_ref_num <= (int)r.re_nsub)
{
int start_off,end_off;
regoff_t start_off, end_off;
if ((start_off=subs[back_ref_num].rm_so) > -1 &&
(end_off=subs[back_ref_num].rm_eo) > -1)
{
need_buf_len += (end_off - start_off);
need_buf_len += (int) (end_off - start_off);
}
expr_p += 2;
}
@ -7039,7 +7030,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
/* copy the pre-match part */
if (subs[0].rm_so)
{
memcpy(res_p, str_p, subs[0].rm_so);
memcpy(res_p, str_p, (size_t) subs[0].rm_so);
res_p+= subs[0].rm_so;
}
@ -7058,11 +7049,11 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
if (back_ref_num >= 0 && back_ref_num <= (int)r.re_nsub)
{
int start_off,end_off;
regoff_t start_off, end_off;
if ((start_off=subs[back_ref_num].rm_so) > -1 &&
(end_off=subs[back_ref_num].rm_eo) > -1)
{
int block_len= end_off - start_off;
int block_len= (int) (end_off - start_off);
memcpy(res_p,str_p + start_off, block_len);
res_p += block_len;
}

View File

@ -247,6 +247,10 @@ bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *cs)
0 No conversion needed
1 Either character set conversion or adding leading zeros
(e.g. for UCS-2) must be done
NOTE
to_cs may be NULL for "no conversion" if the system variable
character_set_results is NULL.
*/
bool String::needs_conversion(uint32 arg_length,
@ -255,7 +259,8 @@ bool String::needs_conversion(uint32 arg_length,
uint32 *offset)
{
*offset= 0;
if ((to_cs == &my_charset_bin) ||
if (!to_cs ||
(to_cs == &my_charset_bin) ||
(to_cs == from_cs) ||
my_charset_same(from_cs, to_cs) ||
((from_cs == &my_charset_bin) &&
@ -612,27 +617,26 @@ skip:
}
/*
** replace substring with string
** If wrong parameter or not enough memory, do nothing
Replace substring with string
If wrong parameter or not enough memory, do nothing
*/
bool String::replace(uint32 offset,uint32 arg_length,const String &to)
{
return replace(offset,arg_length,to.ptr(),to.length());
}
bool String::replace(uint32 offset,uint32 arg_length,
const char *to,uint32 length)
const char *to, uint32 to_length)
{
long diff = (long) length-(long) arg_length;
long diff = (long) to_length-(long) arg_length;
if (offset+arg_length <= str_length)
{
if (diff < 0)
{
if (length)
memcpy(Ptr+offset,to,length);
bmove(Ptr+offset+length,Ptr+offset+arg_length,
if (to_length)
memcpy(Ptr+offset,to,to_length);
bmove(Ptr+offset+to_length,Ptr+offset+arg_length,
str_length-offset-arg_length);
}
else
@ -644,8 +648,8 @@ bool String::replace(uint32 offset,uint32 arg_length,
bmove_upp(Ptr+str_length+diff,Ptr+str_length,
str_length-offset-arg_length);
}
if (length)
memcpy(Ptr+offset,to,length);
if (to_length)
memcpy(Ptr+offset,to,to_length);
}
str_length+=(uint32) diff;
}
@ -818,8 +822,18 @@ copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
from++;
wc= '?';
}
else if (cnvres > MY_CS_TOOSMALL)
{
/*
A correct multibyte sequence detected
But it doesn't have Unicode mapping.
*/
error_count++;
from+= (-cnvres);
wc= '?';
}
else
break; // Impossible char.
break; // Not enough characters
outp:
if ((cnvres= (*wc_mb)(to_cs, wc, (uchar*) to, to_end)) > 0)
@ -847,22 +861,22 @@ void String::print(String *str)
switch (c)
{
case '\\':
str->append("\\\\", 2);
str->append(STRING_WITH_LEN("\\\\"));
break;
case '\0':
str->append("\\0", 2);
str->append(STRING_WITH_LEN("\\0"));
break;
case '\'':
str->append("\\'", 2);
str->append(STRING_WITH_LEN("\\'"));
break;
case '\n':
str->append("\\n", 2);
str->append(STRING_WITH_LEN("\\n"));
break;
case '\r':
str->append("\\r", 2);
str->append(STRING_WITH_LEN("\\r"));
break;
case 26: //Ctrl-Z
str->append("\\z", 2);
str->append(STRING_WITH_LEN("\\z"));
break;
default:
str->append(c);

View File

@ -23,6 +23,8 @@
#define NOT_FIXED_DEC 31
#endif
#define STRING_WITH_LEN(X) ((const char*) X), ((uint) (sizeof(X) - 1))
class String;
int sortcmp(const String *a,const String *b, CHARSET_INFO *cs);
String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
@ -76,13 +78,15 @@ public:
{ /* never called */ }
~String() { free(); }
inline void set_charset(CHARSET_INFO *charset) { str_charset= charset; }
inline void set_charset(CHARSET_INFO *charset_arg)
{ str_charset= charset_arg; }
inline CHARSET_INFO *charset() const { return str_charset; }
inline uint32 length() const { return str_length;}
inline uint32 alloced_length() const { return Alloced_length;}
inline char& operator [] (uint32 i) const { return Ptr[i]; }
inline void length(uint32 len) { str_length=len ; }
inline bool is_empty() { return (str_length == 0); }
inline void mark_as_const() { Alloced_length= 0;}
inline const char *ptr() const { return Ptr; }
inline char *c_ptr()
{

View File

@ -426,7 +426,7 @@ rl_redisplay ()
#if defined (HANDLE_MULTIBYTE)
wchar_t wc;
size_t wc_bytes;
int wc_width;
int wc_width= 0;
mbstate_t ps;
int _rl_wrapped_multicolumn = 0;
#endif

View File

@ -560,12 +560,12 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
int c, l;
int chr, l;
l = _rl_find_prev_mbchar (string, i, MB_FIND_ANY);
c = string[l];
chr = string[l];
/* XXX - original patch had i - 1 ??? If i == 0 it would fail. */
if (i && (c == '\'' || c == '"'))
quoted_search_delimiter = c;
if (i && (chr == '\'' || chr == '"'))
quoted_search_delimiter = chr;
}
else
#endif /* HANDLE_MULTIBYTE */

View File

@ -529,17 +529,17 @@ _rl_read_mbchar (mbchar, size)
may be FIRST. Used by the search functions, among others. Very similar
to _rl_read_mbchar. */
int
_rl_read_mbstring (first, mb, mblen)
_rl_read_mbstring (first, mb, mb_len)
int first;
char *mb;
int mblen;
int mb_len;
{
int i, c;
mbstate_t ps;
c = first;
memset (mb, 0, mblen);
for (i = 0; i < mblen; i++)
memset (mb, 0, mb_len);
for (i = 0; i < mb_len; i++)
{
mb[i] = (char)c;
memset (&ps, 0, sizeof (mbstate_t));

View File

@ -1002,12 +1002,12 @@ _rl_rubout_char (count, key)
}
else
{
int orig_point;
int orig_point2;
orig_point = rl_point;
orig_point2 = rl_point;
rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO);
c = rl_line_buffer[rl_point];
rl_delete_text (rl_point, orig_point);
rl_delete_text (rl_point, orig_point2);
}
#endif /* HANDLE_MULTIBYTE */

View File

@ -672,7 +672,7 @@ _rl_vi_change_mbchar_case (count)
{
wchar_t wc;
char mb[MB_LEN_MAX+1];
int mblen;
int local_mblen;
mbstate_t ps;
memset (&ps, 0, sizeof (mbstate_t));
@ -695,9 +695,9 @@ _rl_vi_change_mbchar_case (count)
/* Vi is kind of strange here. */
if (wc)
{
mblen = wcrtomb (mb, wc, &ps);
if (mblen >= 0)
mb[mblen] = '\0';
local_mblen = wcrtomb (mb, wc, &ps);
if (local_mblen >= 0)
mb[local_mblen] = '\0';
rl_begin_undo_group ();
rl_delete (1, 0);
rl_insert_text (mb);

View File

@ -39,8 +39,7 @@
/* **************************************************************** */
static void
memory_error_and_abort (fname)
char *fname;
memory_error_and_abort(const char *fname)
{
fprintf (stderr, "%s: out of virtual memory\n", fname);
exit (2);
@ -57,7 +56,7 @@ xmalloc (bytes)
temp = malloc (bytes);
if (temp == 0)
memory_error_and_abort ("xmalloc");
memory_error_and_abort("xmalloc");
return (temp);
}
@ -71,7 +70,7 @@ xrealloc (pointer, bytes)
temp = pointer ? realloc (pointer, bytes) : malloc (bytes);
if (temp == 0)
memory_error_and_abort ("xrealloc");
memory_error_and_abort("xrealloc");
return (temp);
}

View File

@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc)
AC_CANONICAL_SYSTEM
# The Docs Makefile.am parses this line!
# remember to also change ndb version below and update version.c in ndb
AM_INIT_AUTOMAKE(mysql, 5.0.36)
AM_INIT_AUTOMAKE(mysql, 5.0.38)
AM_CONFIG_HEADER(config.h)
PROTOCOL_VERSION=10
@ -23,7 +23,7 @@ NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0
# ndb version
NDB_VERSION_MAJOR=5
NDB_VERSION_MINOR=0
NDB_VERSION_BUILD=36
NDB_VERSION_BUILD=38
NDB_VERSION_STATUS=""
# Set all version vars based on $VERSION. How do we do this more elegant ?
@ -1090,7 +1090,7 @@ case $SYSTEM_TYPE in
*darwin6*)
if test "$ac_cv_prog_gcc" = "yes"
then
FLAGS="-D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DHAVE_BROKEN_REALPATH"
FLAGS="-D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DHAVE_BROKEN_REALPATH -DDONT_DECLARE_CXA_PURE_VIRTUAL "
CFLAGS="$CFLAGS $FLAGS"
CXXFLAGS="$CXXFLAGS $FLAGS"
MAX_C_OPTIMIZE="-O"

View File

@ -309,7 +309,7 @@ FILE *inf;
unsigned long fn_ssz;
unsigned long lastuse;
unsigned int pos;
unsigned long time;
unsigned long local_time;
unsigned int oldpos;
unsigned long oldtime;
unsigned long oldchild;
@ -335,15 +335,15 @@ FILE *inf;
*/
while (pop (&oldpos, &oldtime, &oldchild)) {
DBUG_PRINT ("popped", ("%lu %lu", oldtime, oldchild));
time = fn_time - oldtime;
local_time = fn_time - oldtime;
t = top ();
t -> children += time;
t -> children += local_time;
DBUG_PRINT ("update", ("%s", modules[t -> pos].name));
DBUG_PRINT ("update", ("%lu", t -> children));
time -= oldchild;
modules[oldpos].m_time += time;
local_time -= oldchild;
modules[oldpos].m_time += local_time;
modules[oldpos].m_calls++;
tot_time += time;
tot_time += local_time;
tot_calls++;
if (pos == oldpos) {
goto next_line; /* Should be a break2 */
@ -355,11 +355,11 @@ FILE *inf;
* it so that it works the next time too.
*/
t = top ();
time = fn_time - t -> time - t -> children;
local_time = fn_time - t -> time - t -> children;
t -> time = fn_time; t -> children = 0;
modules[pos].m_time += time;
modules[pos].m_time += local_time;
modules[pos].m_calls++;
tot_time += time;
tot_time += local_time;
tot_calls++;
break;
case 'S':
@ -405,13 +405,13 @@ FILE *inf;
* time of fn_time.
*/
while (pop (&oldpos,&oldtime,&oldchild)) {
time = fn_time - oldtime;
local_time = fn_time - oldtime;
t = top ();
t -> children += time;
time -= oldchild;
modules[oldpos].m_time += time;
t -> children += local_time;
local_time -= oldchild;
modules[oldpos].m_time += local_time;
modules[oldpos].m_calls++;
tot_time += time;
tot_time += local_time;
tot_calls++;
}
DBUG_VOID_RETURN;
@ -472,17 +472,17 @@ unsigned long int *called, *timed;
{
char *name = m -> name;
register unsigned int calls = m -> m_calls;
register unsigned long time = m -> m_time;
register unsigned long local_time = m -> m_time;
register unsigned long stkuse = m -> m_stkuse;
unsigned int import;
double per_time = 0.0;
double per_calls = 0.0;
double ms_per_call, ftime;
double ms_per_call, local_ftime;
DBUG_ENTER ("out_item");
if (tot_time > 0) {
per_time = (double) (time * 100) / (double) tot_time;
per_time = (double) (local_time * 100) / (double) tot_time;
}
if (tot_calls > 0) {
per_calls = (double) (calls * 100) / (double) tot_calls;
@ -491,18 +491,18 @@ unsigned long int *called, *timed;
if (verbose) {
fprintf (outf, "%6d\t%10.2f\t%11ld\t%10.2f %10d\t%-15s\n",
calls, per_calls, time, per_time, import, name);
calls, per_calls, local_time, per_time, import, name);
} else {
ms_per_call = time;
ms_per_call = local_time;
ms_per_call /= calls;
ftime = time;
ftime /= 1000;
local_ftime = local_time;
local_ftime /= 1000;
fprintf(outf, "%8.2f%8.3f%8u%8.3f%8.2f%8u%8lu %-s\n",
per_time, ftime, calls, ms_per_call, per_calls, import,
per_time, local_ftime, calls, ms_per_call, per_calls, import,
stkuse, name);
}
*called = calls;
*timed = time;
*timed = local_time;
DBUG_VOID_RETURN;
}
@ -517,7 +517,7 @@ FILE *outf;
register unsigned int root;
register unsigned long int *s_calls, *s_time;
{
unsigned long int calls, time;
unsigned long int calls, local_time;
DBUG_ENTER ("out_body");
DBUG_PRINT ("out_body", ("%lu,%lu",*s_calls,*s_time));
@ -526,10 +526,10 @@ register unsigned long int *s_calls, *s_time;
} else {
while (root != MAXPROCS) {
out_body (outf, s_table[root].lchild,s_calls,s_time);
out_item (outf, &modules[s_table[root].pos],&calls,&time);
DBUG_PRINT ("out_body", ("-- %lu -- %lu --", calls, time));
out_item (outf, &modules[s_table[root].pos],&calls,&local_time);
DBUG_PRINT ("out_body", ("-- %lu -- %lu --", calls, local_time));
*s_calls += calls;
*s_time += time;
*s_time += local_time;
root = s_table[root].rchild;
}
DBUG_PRINT ("out_body", ("%lu,%lu", *s_calls, *s_time));

View File

@ -41,7 +41,9 @@ static char *NAMEFILE= (char*) "mysqld_ername.h";
static char *STATEFILE= (char*) "sql_state.h";
static char *TXTFILE= (char*) "../sql/share/errmsg.txt";
static char *DATADIRECTORY= (char*) "../sql/share/";
#ifndef DBUG_OFF
static char *default_dbug_option= (char*) "d:t:O,/tmp/comp_err.trace";
#endif
/* Header for errmsg.sys files */
uchar file_head[]= { 254, 254, 2, 1 };
@ -404,6 +406,8 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
int rcount= 0;
DBUG_ENTER("parse_input_file");
*top_error= 0;
*top_lang= 0;
if (!(file= my_fopen(file_name, O_RDONLY | O_SHARE, MYF(MY_WME))))
DBUG_RETURN(0);

View File

@ -48,15 +48,16 @@ static struct my_option my_long_options[] =
0, 0, 0, 0, 0, 0},
{"defaults-extra-file", 'e',
"Read this file after the global /etc config file and before the config file in the users home directory.",
(gptr*) &defaults_extra_file, (gptr*) &defaults_extra_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
(gptr*) &my_defaults_extra_file, (gptr*) &my_defaults_extra_file, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"defaults-group-suffix", 'g',
"In addition to the given groups, read also groups with this suffix",
(gptr*) &defaults_group_suffix, (gptr*) &defaults_group_suffix,
(gptr*) &my_defaults_group_suffix, (gptr*) &my_defaults_group_suffix,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"extra-file", 'e',
"Synonym for --defaults-extra-file.",
(gptr*) &defaults_extra_file, (gptr*) &defaults_extra_file, 0, GET_STR,
(gptr*) &my_defaults_extra_file,
(gptr*) &my_defaults_extra_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"no-defaults", 'n', "Return an empty string (useful for scripts).",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},

View File

@ -49,11 +49,13 @@ const uint AUTO = 0xFEEDBEEF;
// Checking Policy should implement a check function that tests whether the
// index is within the size limit of the array
struct Check {
Check() {}
void check(uint i, uint limit);
};
struct NoCheck {
NoCheck() {}
void check(uint, uint);
};
@ -191,6 +193,7 @@ inline void checked_delete(T* p)
// sets pointer to zero so safe for std conatiners
struct del_ptr_zero
{
del_ptr_zero() {}
template <typename T>
void operator()(T*& p) const
{

View File

@ -42,6 +42,7 @@ namespace yaSSL {
// Digest policy should implement a get_digest, update, and get sizes for pad
// and digest
struct Digest : public virtual_base {
Digest() {}
virtual void get_digest(byte*) = 0;
virtual void get_digest(byte*, const byte*, unsigned int) = 0;
virtual void update(const byte*, unsigned int) = 0;
@ -53,6 +54,7 @@ struct Digest : public virtual_base {
// For use with NULL Digests
struct NO_MAC : public Digest {
NO_MAC() {}
void get_digest(byte*);
void get_digest(byte*, const byte*, unsigned int);
void update(const byte*, unsigned int);
@ -177,6 +179,7 @@ private:
// BulkCipher policy should implement encrypt, decrypt, get block size,
// and set keys for encrypt and decrypt
struct BulkCipher : public virtual_base {
BulkCipher() {}
virtual void encrypt(byte*, const byte*, unsigned int) = 0;
virtual void decrypt(byte*, const byte*, unsigned int) = 0;
virtual void set_encryptKey(const byte*, const byte* = 0) = 0;
@ -190,6 +193,7 @@ struct BulkCipher : public virtual_base {
// For use with NULL Ciphers
struct NO_Cipher : public BulkCipher {
NO_Cipher() {}
void encrypt(byte*, const byte*, unsigned int) {}
void decrypt(byte*, const byte*, unsigned int) {}
void set_encryptKey(const byte*, const byte*) {}
@ -311,12 +315,14 @@ struct Auth : public virtual_base {
virtual bool verify(const byte*, unsigned int, const byte*,
unsigned int) = 0;
virtual uint get_signatureLength() const = 0;
Auth() {}
virtual ~Auth() {}
};
// For use with NULL Authentication schemes
struct NO_Auth : public Auth {
NO_Auth() {}
void sign(byte*, const byte*, unsigned int, const RandomPool&) {}
bool verify(const byte*, unsigned int, const byte*, unsigned int)
{ return true; }

View File

@ -33,7 +33,6 @@
#include "opensslv.h" /* for version number */
#include "rsa.h"
#define YASSL_VERSION "1.5.8"
@ -190,11 +189,16 @@ enum { /* ERR Constants */
EVP_R_BAD_DECRYPT = 2
};
#ifdef WIN
typedef SOCKET socket_t;
#else
typedef int socket_t;
#endif
SSL_CTX* SSL_CTX_new(SSL_METHOD*);
SSL* SSL_new(SSL_CTX*);
int SSL_set_fd (SSL*, int);
int SSL_set_fd (SSL*, socket_t);
int SSL_connect(SSL*);
int SSL_write(SSL*, const void*, int);
int SSL_read(SSL*, void*, int);

View File

@ -38,16 +38,14 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
#include "openssl/ssl.h" /* for socket_t */
namespace yaSSL {
typedef unsigned int uint;
#ifdef _WIN32
typedef SOCKET socket_t;
#else
typedef int socket_t;
#ifndef _WIN32
const socket_t INVALID_SOCKET = -1;
const int SD_RECEIVE = 0;
const int SD_SEND = 1;

View File

@ -64,6 +64,7 @@ struct RecordLayerHeader {
// base for all messages
struct Message : public virtual_base {
Message() {}
virtual input_buffer& set(input_buffer&) =0;
virtual output_buffer& get(output_buffer&) const =0;
@ -177,6 +178,7 @@ private:
class HandShakeBase : public virtual_base {
int length_;
public:
HandShakeBase() {}
int get_length() const;
void set_length(int);
@ -194,6 +196,7 @@ public:
struct HelloRequest : public HandShakeBase {
HelloRequest() {}
input_buffer& set(input_buffer& in);
output_buffer& get(output_buffer& out) const;
@ -327,6 +330,7 @@ private:
struct ServerKeyBase : public virtual_base {
ServerKeyBase() {}
virtual ~ServerKeyBase() {}
virtual void build(SSL&) {}
virtual void read(SSL&, input_buffer&) {}
@ -337,15 +341,21 @@ struct ServerKeyBase : public virtual_base {
// Server random number for FORTEZZA KEA
struct Fortezza_Server : public ServerKeyBase {
Fortezza_Server() {}
opaque r_s_[FORTEZZA_MAX];
};
struct SignatureBase : public virtual_base {
SignatureBase() {}
virtual ~SignatureBase() {}
};
struct anonymous_sa : public SignatureBase {};
struct anonymous_sa : public SignatureBase
{
public:
anonymous_sa() {}
};
struct Hashes {
@ -355,11 +365,13 @@ struct Hashes {
struct rsa_sa : public SignatureBase {
rsa_sa() {}
Hashes hashes_;
};
struct dsa_sa : public SignatureBase {
dsa_sa() {}
uint8 sha_[SHA_LEN];
};
@ -387,6 +399,7 @@ private:
// Server's RSA exchange
struct RSA_Server : public ServerKeyBase {
RSA_Server() {}
ServerRSAParams params_;
opaque* signature_; // signed rsa_sa hashes
};
@ -461,6 +474,7 @@ struct PreMasterSecret {
struct ClientKeyBase : public virtual_base {
ClientKeyBase() {}
virtual ~ClientKeyBase() {}
virtual void build(SSL&) {}
virtual void read(SSL&, input_buffer&) {}
@ -491,6 +505,7 @@ private:
// Fortezza Key Parameters from page 29
// hard code lengths cause only used here
struct FortezzaKeys : public ClientKeyBase {
FortezzaKeys() {}
opaque y_c_ [128]; // client's Yc, public value
opaque r_c_ [128]; // client's Rc
opaque y_signature_ [40]; // DSS signed public key

View File

@ -228,6 +228,7 @@ struct BIGNUM {
TaoCrypt::Integer), we need to explicitly state the namespace
here to let gcc 2.96 deduce the correct type.
*/
BIGNUM() {}
yaSSL::Integer int_;
void assign(const byte* b, uint s) { int_.assign(b,s); }
};

View File

@ -550,6 +550,7 @@ void RandomPool::Fill(opaque* dst, uint sz) const
// Implementation of DSS Authentication
struct DSS::DSSImpl {
DSSImpl() {}
void SetPublic (const byte*, unsigned int);
void SetPrivate(const byte*, unsigned int);
TaoCrypt::DSA_PublicKey publicKey_;
@ -622,6 +623,7 @@ bool DSS::verify(const byte* sha_digest, unsigned int /* shaSz */,
// Implementation of RSA key interface
struct RSA::RSAImpl {
RSAImpl() {}
void SetPublic (const byte*, unsigned int);
void SetPrivate(const byte*, unsigned int);
TaoCrypt::RSA_PublicKey publicKey_;

View File

@ -229,7 +229,7 @@ void SSL_free(SSL* ssl)
}
int SSL_set_fd(SSL* ssl, int fd)
int SSL_set_fd(SSL* ssl, socket_t fd)
{
ssl->useSocket().set_fd(fd);
return SSL_SUCCESS;
@ -950,7 +950,7 @@ void ERR_print_errors_fp(FILE* /*fp*/)
char* ERR_error_string(unsigned long errNumber, char* buffer)
{
static char* msg = "Please supply a buffer for error string";
static char* msg = (char*) "Please supply a buffer for error string";
if (buffer) {
SetErrorString(YasslError(errNumber), buffer);

View File

@ -65,7 +65,7 @@ int main(int argc, char** argv)
const int megs = 5; // how much to test
const byte key[] =
const byte global_key[] =
{
0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
0xfe,0xde,0xba,0x98,0x76,0x54,0x32,0x10,
@ -81,19 +81,19 @@ const byte iv[] =
};
byte plain [1024*1024];
byte cipher[1024*1024];
byte global_plain [1024*1024];
byte global_cipher[1024*1024];
void bench_des()
{
DES_EDE3_CBC_Encryption enc;
enc.SetKey(key, 16, iv);
enc.SetKey(global_key, 16, iv);
double start = current_time();
for(int i = 0; i < megs; i++)
enc.Process(plain, cipher, sizeof(plain));
enc.Process(global_plain, global_cipher, sizeof(global_plain));
double total = current_time() - start;
@ -107,12 +107,12 @@ void bench_des()
void bench_aes(bool show)
{
AES_CBC_Encryption enc;
enc.SetKey(key, 16, iv);
enc.SetKey(global_key, 16, iv);
double start = current_time();
for(int i = 0; i < megs; i++)
enc.Process(plain, cipher, sizeof(plain));
enc.Process(global_plain, global_cipher, sizeof(global_plain));
double total = current_time() - start;
@ -127,12 +127,12 @@ void bench_aes(bool show)
void bench_twofish()
{
Twofish_CBC_Encryption enc;
enc.SetKey(key, 16, iv);
enc.SetKey(global_key, 16, iv);
double start = current_time();
for(int i = 0; i < megs; i++)
enc.Process(plain, cipher, sizeof(plain));
enc.Process(global_plain, global_cipher, sizeof(global_plain));
double total = current_time() - start;
@ -147,12 +147,12 @@ void bench_twofish()
void bench_blowfish()
{
Blowfish_CBC_Encryption enc;
enc.SetKey(key, 16, iv);
enc.SetKey(global_key, 16, iv);
double start = current_time();
for(int i = 0; i < megs; i++)
enc.Process(plain, cipher, sizeof(plain));
enc.Process(global_plain, global_cipher, sizeof(global_plain));
double total = current_time() - start;
@ -166,12 +166,12 @@ void bench_blowfish()
void bench_arc4()
{
ARC4 enc;
enc.SetKey(key, 16);
enc.SetKey(global_key, 16);
double start = current_time();
for(int i = 0; i < megs; i++)
enc.Process(cipher, plain, sizeof(plain));
enc.Process(global_cipher, global_plain, sizeof(global_plain));
double total = current_time() - start;
@ -191,7 +191,7 @@ void bench_md5()
for(int i = 0; i < megs; i++)
hash.Update(plain, sizeof(plain));
hash.Update(global_plain, sizeof(global_plain));
hash.Final(digest);
@ -213,7 +213,7 @@ void bench_sha()
for(int i = 0; i < megs; i++)
hash.Update(plain, sizeof(plain));
hash.Update(global_plain, sizeof(global_plain));
hash.Final(digest);
@ -241,7 +241,7 @@ void bench_ripemd()
for(int i = 0; i < megs; i++)
hash.Update(plain, sizeof(plain));
hash.Update(global_plain, sizeof(global_plain));
hash.Final(digest);

View File

@ -40,6 +40,7 @@ class TAOCRYPT_NO_VTABLE AbstractGroup : public virtual_base
public:
typedef Integer Element;
AbstractGroup() {}
virtual ~AbstractGroup() {}
virtual bool Equal(const Element &a, const Element &b) const =0;
@ -94,6 +95,7 @@ private:
class MultiplicativeGroupT : public AbstractGroup
{
public:
MultiplicativeGroupT() {}
const AbstractRing& GetRing() const
{return *m_pRing;}
@ -145,6 +147,7 @@ class TAOCRYPT_NO_VTABLE AbstractEuclideanDomain
: public AbstractRing
{
public:
AbstractEuclideanDomain() {}
typedef Integer Element;
virtual void DivisionAlgorithm(Element &r, Element &q, const Element &a,

View File

@ -41,6 +41,7 @@ enum { DES_BLOCK_SIZE = 8, DES_KEY_SIZE = 32 };
class BasicDES {
public:
BasicDES() {}
void SetKey(const byte*, word32, CipherDir dir);
void RawProcessBlock(word32&, word32&) const;
protected:

View File

@ -31,6 +31,7 @@ namespace TaoCrypt {
// HASH
class HASH : public virtual_base {
public:
HASH() {}
virtual ~HASH() {}
virtual void Update(const byte*, word32) = 0;

View File

@ -109,11 +109,11 @@ void HMAC<T>::KeyInnerHash()
// Update
template <class T>
void HMAC<T>::Update(const byte* msg, word32 length)
void HMAC<T>::Update(const byte* msg_arg, word32 length)
{
if (!innerHashKeyed_)
KeyInnerHash();
mac_.Update(msg, length);
mac_.Update(msg_arg, length);
}

View File

@ -37,8 +37,8 @@ public:
typedef int RandomizationParameter;
typedef Integer Element;
ModularArithmetic(const Integer &modulus = Integer::One())
: modulus(modulus), result((word)0, modulus.reg_.size()) {}
ModularArithmetic(const Integer &modulus_arg = Integer::One())
: modulus(modulus_arg), result((word)0, modulus_arg.reg_.size()) {}
ModularArithmetic(const ModularArithmetic &ma)
: AbstractRing(),

View File

@ -42,8 +42,8 @@ public:
{ cipher_.Process(c, p, sz); }
void SetKey(const byte* k, word32 sz)
{ cipher_.SetKey(k, sz, DIR); }
void SetKey(const byte* k, word32 sz, const byte* iv)
{ cipher_.SetKey(k, sz, DIR); cipher_.SetIV(iv); }
void SetKey(const byte* k, word32 sz, const byte* iv_arg)
{ cipher_.SetKey(k, sz, DIR); cipher_.SetIV(iv_arg); }
private:
T cipher_;

View File

@ -131,6 +131,7 @@ private:
// block type 2 padding
class RSA_BlockType2 {
public:
RSA_BlockType2() {}
void Pad(const byte*, word32, byte*, word32,
RandomNumberGenerator&) const;
word32 UnPad(const byte*, word32, byte*) const;
@ -140,6 +141,7 @@ public:
// block type 1 padding
class RSA_BlockType1 {
public:
RSA_BlockType1() {}
void Pad(const byte*, word32, byte*, word32,
RandomNumberGenerator&) const;
word32 UnPad(const byte*, word32, byte*) const;
@ -174,25 +176,27 @@ public:
// Public Encrypt
template<class Pad>
void RSA_Encryptor<Pad>::Encrypt(const byte* plain, word32 sz, byte* cipher,
RandomNumberGenerator& rng)
void RSA_Encryptor<Pad>::Encrypt(const byte* plain_arg, word32 sz,
byte* cipher_arg,
RandomNumberGenerator& rng_arg)
{
PK_Lengths lengths(key_.GetModulus());
assert(sz <= lengths.FixedMaxPlaintextLength());
ByteBlock paddedBlock(lengths.PaddedBlockByteLength());
padding_.Pad(plain, sz, paddedBlock.get_buffer(),
lengths.PaddedBlockBitLength(), rng);
padding_.Pad(plain_arg, sz, paddedBlock.get_buffer(),
lengths.PaddedBlockBitLength(), rng_arg);
key_.ApplyFunction(Integer(paddedBlock.get_buffer(), paddedBlock.size())).
Encode(cipher, lengths.FixedCiphertextLength());
Encode(cipher_arg, lengths.FixedCiphertextLength());
}
// Private Decrypt
template<class Pad>
word32 RSA_Decryptor<Pad>::Decrypt(const byte* cipher, word32 sz, byte* plain,
RandomNumberGenerator& rng)
word32 RSA_Decryptor<Pad>::Decrypt(const byte* cipher_arg, word32 sz,
byte* plain_arg,
RandomNumberGenerator& rng_arg)
{
PK_Lengths lengths(key_.GetModulus());
assert(sz == lengths.FixedCiphertextLength());
@ -201,29 +205,29 @@ word32 RSA_Decryptor<Pad>::Decrypt(const byte* cipher, word32 sz, byte* plain,
return 0;
ByteBlock paddedBlock(lengths.PaddedBlockByteLength());
Integer x = key_.CalculateInverse(rng, Integer(cipher,
Integer x = key_.CalculateInverse(rng_arg, Integer(cipher_arg,
lengths.FixedCiphertextLength()).Ref());
if (x.ByteCount() > paddedBlock.size())
x = Integer::Zero(); // don't return false, prevents timing attack
x.Encode(paddedBlock.get_buffer(), paddedBlock.size());
return padding_.UnPad(paddedBlock.get_buffer(),
lengths.PaddedBlockBitLength(), plain);
lengths.PaddedBlockBitLength(), plain_arg);
}
// Private SSL type (block 1) Encrypt
template<class Pad>
void RSA_Decryptor<Pad>::SSL_Sign(const byte* message, word32 sz, byte* sig,
RandomNumberGenerator& rng)
RandomNumberGenerator& rng_arg)
{
RSA_PublicKey inverse;
inverse.Initialize(key_.GetModulus(), key_.GetPrivateExponent());
RSA_Encryptor<RSA_BlockType1> enc(inverse); // SSL Type
enc.Encrypt(message, sz, sig, rng);
enc.Encrypt(message, sz, sig, rng_arg);
}
word32 SSL_Decrypt(const RSA_PublicKey& key, const byte* sig, byte* plain);
word32 SSL_Decrypt(const RSA_PublicKey& key, const byte* sig, byte* plain_arg);
// Public SSL type (block 1) Decrypt
@ -231,11 +235,11 @@ template<class Pad>
bool RSA_Encryptor<Pad>::SSL_Verify(const byte* message, word32 sz,
const byte* sig)
{
ByteBlock plain(PK_Lengths(key_.GetModulus()).FixedMaxPlaintextLength());
if (SSL_Decrypt(key_, sig, plain.get_buffer()) != sz)
ByteBlock local_plain(PK_Lengths(key_.GetModulus()).FixedMaxPlaintextLength());
if (SSL_Decrypt(key_, sig, local_plain.get_buffer()) != sz)
return false; // not right justified or bad padding
if ( (memcmp(plain.get_buffer(), message, sz)) == 0)
if ( (memcmp(local_plain.get_buffer(), message, sz)) == 0)
return true;
return false;
}

View File

@ -62,7 +62,11 @@ MK_FUNDAMENTAL_TYPE(unsigned long)
MK_FUNDAMENTAL_TYPE(float)
MK_FUNDAMENTAL_TYPE( double)
MK_FUNDAMENTAL_TYPE(long double)
#ifdef LONG_DOUBLE_IS_DISTINCT_TYPE
// Don't define by default as this gives warnings on power mac
MK_FUNDAMENTAL_TYPE(long double)
#endif
#if defined(WORD64_AVAILABLE) && defined(WORD64_IS_DISTINCT_TYPE)
MK_FUNDAMENTAL_TYPE(word64)

View File

@ -231,7 +231,7 @@ void list<T>::push_front(T t)
template<typename T>
void list<T>::pop_front()
{
node* front = head_;
node* local_front = head_;
if (head_ == 0)
return;
@ -241,8 +241,8 @@ void list<T>::pop_front()
head_ = head_->next_;
head_->prev_ = 0;
}
destroy(front);
FreeMemory(front);
destroy(local_front);
FreeMemory(local_front);
--sz_;
}
@ -303,13 +303,13 @@ T list<T>::back() const
template<typename T>
typename list<T>::node* list<T>::look_up(T t)
{
node* list = head_;
node* local_list = head_;
if (list == 0) return 0;
if (local_list == 0) return 0;
for (; list; list = list->next_)
if (list->value_ == t)
return list;
for (; local_list; local_list = local_list->next_)
if (local_list->value_ == t)
return local_list;
return 0;
}

View File

@ -90,13 +90,14 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
rounds_ = keylen/4 + 6;
word32 temp, *rk = key_;
unsigned int i=0;
GetUserKey(BigEndianOrder, rk, keylen/4, userKey, keylen);
switch(keylen)
{
case 16:
{
unsigned int i=0;
while (true)
{
temp = rk[3];
@ -114,8 +115,10 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
rk += 4;
}
break;
}
case 24:
{
unsigned int i=0;
while (true) // for (;;) here triggers a bug in VC60 SP4 w/ Pro Pack
{
temp = rk[ 5];
@ -136,7 +139,10 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
}
break;
}
case 32:
{
unsigned int i=0;
while (true)
{
temp = rk[ 7];
@ -165,6 +171,7 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
}
break;
}
}
if (dir_ == DECRYPTION)
{

View File

@ -186,10 +186,10 @@ Integer AbstractGroup::CascadeScalarMultiply(const Element &x,
struct WindowSlider
{
WindowSlider(const Integer &exp, bool fastNegate,
WindowSlider(const Integer &exp_arg, bool fastNegate_arg,
unsigned int windowSizeIn=0)
: exp(exp), windowModulus(Integer::One()), windowSize(windowSizeIn),
windowBegin(0), fastNegate(fastNegate), firstTime(true),
: exp(exp_arg), windowModulus(Integer::One()), windowSize(windowSizeIn),
windowBegin(0), fastNegate(fastNegate_arg), firstTime(true),
finished(false)
{
if (windowSize == 0)

View File

@ -737,17 +737,17 @@ void CertDecoder::GetName(NameType nt)
email = true;
source_.advance(oidSz + 1);
word32 length = GetLength(source_);
word32 length2 = GetLength(source_);
if (email) {
memcpy(&ptr[idx], "/emailAddress=", 14);
idx += 14;
memcpy(&ptr[idx], source_.get_current(), length);
idx += length;
memcpy(&ptr[idx], source_.get_current(), length2);
idx += length2;
}
source_.advance(length);
source_.advance(length2);
}
}
ptr[idx++] = 0;

View File

@ -3390,7 +3390,7 @@ void Integer::DivideByPowerOf2(Integer &r, Integer &q, const Integer &a,
CopyWords(r.reg_.get_buffer(), a.reg_.get_buffer(), wordCount);
SetWords(r.reg_+wordCount, 0, r.reg_.size()-wordCount);
if (n % WORD_BITS != 0)
r.reg_[wordCount-1] %= (1 << (n % WORD_BITS));
r.reg_[wordCount-1] %= ((word) 1 << (n % WORD_BITS));
}
else
{

View File

@ -139,20 +139,20 @@ const byte msgTmp[] = { // "now is the time for all " w/o trailing 0
0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20
};
byte* msg = 0; // for block cipher input
byte* plain = 0; // for cipher decrypt comparison
byte* cipher = 0; // block output
byte* global_msg = 0; // for block cipher input
byte* global_plain = 0; // for cipher decrypt comparison
byte* global_cipher = 0; // block output
void taocrypt_test(void* args)
{
((func_args*)args)->return_code = -1; // error state
msg = NEW_TC byte[24];
plain = NEW_TC byte[24];
cipher = NEW_TC byte[24];
global_msg = NEW_TC byte[24];
global_plain = NEW_TC byte[24];
global_cipher = NEW_TC byte[24];
memcpy(msg, msgTmp, 24);
memcpy(global_msg, msgTmp, 24);
int ret = 0;
if ( (ret = sha_test()) )
@ -237,9 +237,9 @@ void taocrypt_test(void* args)
printf( "PKCS12 test passed!\n");
*/
tcArrayDelete(cipher);
tcArrayDelete(plain);
tcArrayDelete(msg);
tcArrayDelete(global_cipher);
tcArrayDelete(global_plain);
tcArrayDelete(global_msg);
((func_args*)args)->return_code = ret;
}
@ -606,11 +606,11 @@ int des_test()
const byte iv[] = { 0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef };
enc.SetKey(key, sizeof(key));
enc.Process(cipher, msg, sz);
enc.Process(global_cipher, global_msg, sz);
dec.SetKey(key, sizeof(key));
dec.Process(plain, cipher, sz);
dec.Process(global_plain, global_cipher, sz);
if (memcmp(plain, msg, sz))
if (memcmp(global_plain, global_msg, sz))
return -50;
const byte verify1[] =
@ -620,7 +620,7 @@ int des_test()
0x89,0x3d,0x51,0xec,0x4b,0x56,0x3b,0x53
};
if (memcmp(cipher, verify1, sz))
if (memcmp(global_cipher, verify1, sz))
return -51;
// CBC mode
@ -628,11 +628,11 @@ int des_test()
DES_CBC_Decryption dec2;
enc2.SetKey(key, sizeof(key), iv);
enc2.Process(cipher, msg, sz);
enc2.Process(global_cipher, global_msg, sz);
dec2.SetKey(key, sizeof(key), iv);
dec2.Process(plain, cipher, sz);
dec2.Process(global_plain, global_cipher, sz);
if (memcmp(plain, msg, sz))
if (memcmp(global_plain, global_msg, sz))
return -52;
const byte verify2[] =
@ -642,7 +642,7 @@ int des_test()
0x15,0x85,0xb3,0x22,0x4b,0x86,0x2b,0x4b
};
if (memcmp(cipher, verify2, sz))
if (memcmp(global_cipher, verify2, sz))
return -53;
// EDE3 CBC mode
@ -664,11 +664,11 @@ int des_test()
};
enc3.SetKey(key3, sizeof(key3), iv3);
enc3.Process(cipher, msg, sz);
enc3.Process(global_cipher, global_msg, sz);
dec3.SetKey(key3, sizeof(key3), iv3);
dec3.Process(plain, cipher, sz);
dec3.Process(global_plain, global_cipher, sz);
if (memcmp(plain, msg, sz))
if (memcmp(global_plain, global_msg, sz))
return -54;
const byte verify3[] =
@ -678,7 +678,7 @@ int des_test()
0x18,0xbc,0xbb,0x6d,0xd2,0xb1,0x16,0xda
};
if (memcmp(cipher, verify3, sz))
if (memcmp(global_cipher, verify3, sz))
return -55;
return 0;
@ -697,10 +697,10 @@ int aes_test()
enc.SetKey(key, bs, iv);
dec.SetKey(key, bs, iv);
enc.Process(cipher, msg, bs);
dec.Process(plain, cipher, bs);
enc.Process(global_cipher, global_msg, bs);
dec.Process(global_plain, global_cipher, bs);
if (memcmp(plain, msg, bs))
if (memcmp(global_plain, global_msg, bs))
return -60;
const byte verify[] =
@ -709,7 +709,7 @@ int aes_test()
0x2c,0xcc,0x9d,0x46,0x77,0xa2,0x33,0xcb
};
if (memcmp(cipher, verify, bs))
if (memcmp(global_cipher, verify, bs))
return -61;
AES_ECB_Encryption enc2;
@ -718,10 +718,10 @@ int aes_test()
enc2.SetKey(key, bs, iv);
dec2.SetKey(key, bs, iv);
enc2.Process(cipher, msg, bs);
dec2.Process(plain, cipher, bs);
enc2.Process(global_cipher, global_msg, bs);
dec2.Process(global_plain, global_cipher, bs);
if (memcmp(plain, msg, bs))
if (memcmp(global_plain, global_msg, bs))
return -62;
const byte verify2[] =
@ -730,7 +730,7 @@ int aes_test()
0xc8,0x8c,0x33,0x3b,0xb5,0x8f,0x85,0xd1
};
if (memcmp(cipher, verify2, bs))
if (memcmp(global_cipher, verify2, bs))
return -63;
return 0;
@ -749,10 +749,10 @@ int twofish_test()
enc.SetKey(key, bs, iv);
dec.SetKey(key, bs, iv);
enc.Process(cipher, msg, bs);
dec.Process(plain, cipher, bs);
enc.Process(global_cipher, global_msg, bs);
dec.Process(global_plain, global_cipher, bs);
if (memcmp(plain, msg, bs))
if (memcmp(global_plain, global_msg, bs))
return -60;
const byte verify[] =
@ -761,7 +761,7 @@ int twofish_test()
0x21,0x03,0x58,0x79,0x5F,0x02,0x27,0x2C
};
if (memcmp(cipher, verify, bs))
if (memcmp(global_cipher, verify, bs))
return -61;
Twofish_ECB_Encryption enc2;
@ -770,10 +770,10 @@ int twofish_test()
enc2.SetKey(key, bs, iv);
dec2.SetKey(key, bs, iv);
enc2.Process(cipher, msg, bs);
dec2.Process(plain, cipher, bs);
enc2.Process(global_cipher, global_msg, bs);
dec2.Process(global_plain, global_cipher, bs);
if (memcmp(plain, msg, bs))
if (memcmp(global_plain, global_msg, bs))
return -62;
const byte verify2[] =
@ -782,7 +782,7 @@ int twofish_test()
0xC4,0xCD,0x6B,0x91,0x14,0xC5,0x3A,0x09
};
if (memcmp(cipher, verify2, bs))
if (memcmp(global_cipher, verify2, bs))
return -63;
return 0;
@ -801,10 +801,10 @@ int blowfish_test()
enc.SetKey(key, 16, iv);
dec.SetKey(key, 16, iv);
enc.Process(cipher, msg, bs * 2);
dec.Process(plain, cipher, bs * 2);
enc.Process(global_cipher, global_msg, bs * 2);
dec.Process(global_plain, global_cipher, bs * 2);
if (memcmp(plain, msg, bs))
if (memcmp(global_plain, global_msg, bs))
return -60;
const byte verify[] =
@ -813,7 +813,7 @@ int blowfish_test()
0xBC,0xD9,0x08,0xC4,0x94,0x6C,0x89,0xA3
};
if (memcmp(cipher, verify, bs))
if (memcmp(global_cipher, verify, bs))
return -61;
Blowfish_ECB_Encryption enc2;
@ -822,10 +822,10 @@ int blowfish_test()
enc2.SetKey(key, 16, iv);
dec2.SetKey(key, 16, iv);
enc2.Process(cipher, msg, bs * 2);
dec2.Process(plain, cipher, bs * 2);
enc2.Process(global_cipher, global_msg, bs * 2);
dec2.Process(global_plain, global_cipher, bs * 2);
if (memcmp(plain, msg, bs))
if (memcmp(global_plain, global_msg, bs))
return -62;
const byte verify2[] =
@ -834,7 +834,7 @@ int blowfish_test()
0x8F,0xCE,0x39,0x32,0xDE,0xD7,0xBC,0x5B
};
if (memcmp(cipher, verify2, bs))
if (memcmp(global_cipher, verify2, bs))
return -63;
return 0;

View File

@ -86,8 +86,8 @@ int main(int argc, char** argv)
// input output compare
byte input[TaoCrypt::MD5::DIGEST_SIZE];
byte output[TaoCrypt::MD5::DIGEST_SIZE];
file_test("input", input);
file_test("output", output);
file_test((char*) "input", input);
file_test((char*) "output", output);
assert(memcmp(input, output, sizeof(input)) == 0);
printf("\nAll tests passed!\n");
@ -141,16 +141,17 @@ int test_openSSL_des()
/* test des encrypt/decrypt */
char data[] = "this is my data ";
int dataSz = strlen(data);
DES_key_schedule key[3];
DES_key_schedule local_key[3];
byte iv[8];
EVP_BytesToKey(EVP_des_ede3_cbc(), EVP_md5(), NULL, (byte*)data, dataSz, 1,
(byte*)key, iv);
(byte*)local_key, iv);
byte cipher[16];
DES_ede3_cbc_encrypt((byte*)data, cipher, dataSz, &key[0], &key[1],
&key[2], &iv, true);
DES_ede3_cbc_encrypt((byte*)data, cipher, dataSz,
&local_key[0], &local_key[1],
&local_key[2], &iv, true);
byte plain[16];
DES_ede3_cbc_encrypt(cipher, plain, 16, &key[0], &key[1], &key[2],
&iv, false);
DES_ede3_cbc_encrypt(cipher, plain, 16, &local_key[0], &local_key[1],
&local_key[2], &iv, false);
return 0;
}

View File

@ -68,7 +68,7 @@ int heap_write(HP_INFO *info, const byte *record)
err:
if (my_errno == HA_ERR_FOUND_DUPP_KEY)
DBUG_PRINT("info",("Duplicate key: %d", keydef - share->keydef));
DBUG_PRINT("info",("Duplicate key: %d", (int) (keydef - share->keydef)));
info->errkey= keydef - share->keydef;
/*
We don't need to delete non-inserted key from rb-tree. Also, if

View File

@ -90,7 +90,7 @@ typedef struct
{
uint beg;
uint end;
uint mblen;
uint mb_len;
} my_match_t;
enum my_lex_states

View File

@ -74,6 +74,7 @@ extern void _db_unlock_file(void);
#define DBUG_ASSERT(A) assert(A)
#define DBUG_EXECUTE_IF(keyword,a1) \
{if (_db_on_) {if (_db_strict_keyword_ (keyword)) { a1 }}}
#define IF_DBUG(A) A
#else /* No debugger */
#define DBUG_ENTER(a1)
@ -98,6 +99,7 @@ extern void _db_unlock_file(void);
#define DBUG_OUTPUT(A)
#define DBUG_ASSERT(A) {}
#define DBUG_LEAVE
#define IF_DBUG(A)
#endif
#ifdef __cplusplus
}

View File

@ -540,7 +540,7 @@ typedef unsigned short ushort;
duplicate declaration of __cxa_pure_virtual, solved by declaring it a
weak symbol.
*/
#ifdef USE_MYSYS_NEW
#if defined(USE_MYSYS_NEW) && ! defined(DONT_DECLARE_CXA_PURE_VIRTUAL)
C_MODE_START
int __cxa_pure_virtual () __attribute__ ((weak));
C_MODE_END
@ -846,6 +846,21 @@ typedef long long my_ptrdiff_t;
#define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size)
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B))
/*
Custom version of standard offsetof() macro which can be used to get
offsets of members in class for non-POD types (according to the current
version of C++ standard offsetof() macro can't be used in such cases and
attempt to do so causes warnings to be emitted, OTOH in many cases it is
still OK to assume that all instances of the class has the same offsets
for the same members).
This is temporary solution which should be removed once File_parser class
and related routines are refactored.
*/
#define my_offsetof(TYPE, MEMBER) \
((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
#define NullS (char *) 0
/* Nowdays we do not support MessyDos */
#ifndef NEAR
@ -1078,7 +1093,7 @@ typedef char bool; /* Ordinary boolean values 0 1 */
*/
#define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF)
#endif
#define uint4korr(A) (*((unsigned long *) (A)))
#define uint4korr(A) (*((uint32 *) (A)))
#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[2])) << 16) +\

View File

@ -370,14 +370,14 @@ int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */
we want to make sure that no such flags are set.
*/
#if defined(HAVE_SIGACTION) && !defined(my_sigset)
#define my_sigset(A,B) do { struct sigaction s; sigset_t set; int rc; \
DBUG_ASSERT((A) != 0); \
sigemptyset(&set); \
s.sa_handler = (B); \
s.sa_mask = set; \
s.sa_flags = 0; \
rc= sigaction((A), &s, (struct sigaction *) NULL);\
DBUG_ASSERT(rc == 0); \
#define my_sigset(A,B) do { struct sigaction l_s; sigset_t l_set; int l_rc; \
DBUG_ASSERT((A) != 0); \
sigemptyset(&l_set); \
l_s.sa_handler = (B); \
l_s.sa_mask = l_set; \
l_s.sa_flags = 0; \
l_rc= sigaction((A), &l_s, (struct sigaction *) NULL);\
DBUG_ASSERT(l_rc == 0); \
} while (0)
#elif defined(HAVE_SIGSET) && !defined(my_sigset)
#define my_sigset(A,B) sigset((A),(B))

View File

@ -260,9 +260,10 @@ extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io,
NEAR my_disable_flush_key_blocks, NEAR my_disable_symlinks;
extern char wild_many,wild_one,wild_prefix;
extern const char *charsets_dir;
extern char *defaults_extra_file;
extern const char *defaults_group_suffix;
extern const char *defaults_file;
/* from default.c */
extern char *my_defaults_extra_file;
extern const char *my_defaults_group_suffix;
extern const char *my_defaults_file;
extern my_bool timed_mutexes;

View File

@ -79,16 +79,16 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
uint flags, int *was_cut);
longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res,
uint flags, int *was_cut);
ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *time);
ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *time);
ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *time);
ulonglong TIME_to_ulonglong(const MYSQL_TIME *time);
ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *);
ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *);
ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *);
ulonglong TIME_to_ulonglong(const MYSQL_TIME *);
my_bool str_to_time(const char *str,uint length, MYSQL_TIME *l_time,
int *warning);
int check_time_range(struct st_mysql_time *time, int *warning);
int check_time_range(struct st_mysql_time *, int *warning);
long calc_daynr(uint year,uint month,uint day);
uint calc_days_in_year(uint year);

View File

@ -87,6 +87,7 @@ extern char *mysql_unix_port;
#define IS_NUM(t) ((t) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR || (t) == FIELD_TYPE_NEWDECIMAL)
#define IS_NUM_FIELD(f) ((f)->flags & NUM_FLAG)
#define INTERNAL_NUM_FIELD(f) (((f)->type <= FIELD_TYPE_INT24 && ((f)->type != FIELD_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == FIELD_TYPE_YEAR)
#define IS_LONGDATA(t) ((t) >= MYSQL_TYPE_TINY_BLOB && (t) <= MYSQL_TYPE_STRING)
typedef struct st_mysql_field {
@ -783,7 +784,7 @@ int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query,
unsigned long length);
int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt);
int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt);
int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind,
int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind_arg,
unsigned int column,
unsigned long offset);
int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt);

View File

@ -388,8 +388,8 @@ ut_bit_set_nth(
ut_ad(TRUE == 1);
if (val) {
return((1 << n) | a);
return(((ulint) 1 << n) | a);
} else {
return(~(1 << n) & a);
return(~((ulint) 1 << n) & a);
}
}

View File

@ -170,5 +170,5 @@ ut_2_exp(
/* out: 2 to power n */
ulint n) /* in: number */
{
return(1 << n);
return((ulint) 1 << n);
}

View File

@ -1730,7 +1730,7 @@ static int stmt_read_row_no_result_set(MYSQL_STMT *stmt, unsigned char **row);
STMT_ATTR_UPDATE_MAX_LENGTH attribute is set.
*/
static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data);
static my_bool setup_one_fetch_function(MYSQL_BIND *bind, MYSQL_FIELD *field);
static my_bool setup_one_fetch_function(MYSQL_BIND *, MYSQL_FIELD *field);
/* Auxilary function used to reset statement handle. */
@ -2174,7 +2174,7 @@ static void update_stmt_fields(MYSQL_STMT *stmt)
MYSQL_FIELD *field= stmt->mysql->fields;
MYSQL_FIELD *field_end= field + stmt->field_count;
MYSQL_FIELD *stmt_field= stmt->fields;
MYSQL_BIND *bind= stmt->bind_result_done ? stmt->bind : 0;
MYSQL_BIND *my_bind= stmt->bind_result_done ? stmt->bind : 0;
DBUG_ASSERT(stmt->field_count == stmt->mysql->field_count);
@ -2185,10 +2185,10 @@ static void update_stmt_fields(MYSQL_STMT *stmt)
stmt_field->type = field->type;
stmt_field->flags = field->flags;
stmt_field->decimals = field->decimals;
if (bind)
if (my_bind)
{
/* Ignore return value: it should be 0 if bind_result succeeded. */
(void) setup_one_fetch_function(bind++, stmt_field);
(void) setup_one_fetch_function(my_bind++, stmt_field);
}
}
}
@ -3014,7 +3014,7 @@ static my_bool int_is_null_false= 0;
mysql_stmt_bind_param()
stmt statement handle
The statement must be prepared with mysql_stmt_prepare().
bind Array of mysql_stmt_param_count() bind parameters.
my_bind Array of mysql_stmt_param_count() bind parameters.
This function doesn't check that size of this argument
is >= mysql_stmt_field_count(): it's user's responsibility.
@ -3089,65 +3089,66 @@ static my_bool int_is_null_false= 0;
to point to the buffer of given type. Finally, additional actions
may be taken for some types or use cases:
Binding integer types.
For integer types you might also need to set MYSQL_BIND::is_unsigned
member. Set it to TRUE when binding unsigned char, unsigned short,
unsigned int, unsigned long, unsigned long long.
Binding integer types.
For integer types you might also need to set MYSQL_BIND::is_unsigned
member. Set it to TRUE when binding unsigned char, unsigned short,
unsigned int, unsigned long, unsigned long long.
Binding floating point types.
For floating point types you just need to set
MYSQL_BIND::buffer_type and MYSQL_BIND::buffer. The rest of the
members should be zero-initialized.
Binding floating point types.
For floating point types you just need to set
MYSQL_BIND::buffer_type and MYSQL_BIND::buffer. The rest of the
members should be zero-initialized.
Binding NULLs.
You might have a column always NULL, never NULL, or sometimes NULL.
For an always NULL column set MYSQL_BIND::buffer_type to
MYSQL_TYPE_NULL. The rest of the members just need to be
zero-initialized. For never NULL columns set MYSQL_BIND::is_null to
0, or this has already been done if you zero-initialized the entire
structure. If you set MYSQL_TYPE::is_null to point to an
application buffer of type 'my_bool', then this buffer will be
checked on each execution: this way you can set the buffer to TRUE,
or any non-0 value for NULLs, and to FALSE or 0 for not NULL data.
Binding NULLs.
You might have a column always NULL, never NULL, or sometimes
NULL. For an always NULL column set MYSQL_BIND::buffer_type to
MYSQL_TYPE_NULL. The rest of the members just need to be
zero-initialized. For never NULL columns set
MYSQL_BIND::is_null to 0, or this has already been done if you
zero-initialized the entire structure. If you set
MYSQL_TYPE::is_null to point to an application buffer of type
'my_bool', then this buffer will be checked on each execution:
this way you can set the buffer to TRUE, or any non-0 value for
NULLs, and to FALSE or 0 for not NULL data.
Binding text strings and sequences of bytes.
For strings, in addition to MYSQL_BIND::buffer_type and
MYSQL_BIND::buffer you need to set MYSQL_BIND::length or
MYSQL_BIND::buffer_length.
If 'length' is set, 'buffer_length' is ignored. 'buffer_length'
member should be used when size of string doesn't change between
executions. If you want to vary buffer length for each value, set
'length' to point to an application buffer of type 'unsigned long'
and set this long to length of the string before each
mysql_stmt_execute().
Binding text strings and sequences of bytes.
For strings, in addition to MYSQL_BIND::buffer_type and
MYSQL_BIND::buffer you need to set MYSQL_BIND::length or
MYSQL_BIND::buffer_length. If 'length' is set, 'buffer_length'
is ignored. 'buffer_length' member should be used when size of
string doesn't change between executions. If you want to vary
buffer length for each value, set 'length' to point to an
application buffer of type 'unsigned long' and set this long to
length of the string before each mysql_stmt_execute().
Binding dates and times.
For binding dates and times prepared statements API provides clients
with MYSQL_TIME structure. A pointer to instance of this structure
should be assigned to MYSQL_BIND::buffer whenever MYSQL_TYPE_TIME,
MYSQL_TYPE_DATE, MYSQL_TYPE_DATETIME typecodes are used. When
typecode is MYSQL_TYPE_TIME, only members 'hour', 'minute', 'second'
and 'neg' (is time offset negative) are used. These members only
will be sent to the server.
MYSQL_TYPE_DATE implies use of 'year', 'month', 'day', 'neg'.
MYSQL_TYPE_DATETIME utilizes both parts of MYSQL_TIME structure.
You don't have to set MYSQL_TIME::time_type member: it's not used
when sending data to the server, typecode information is enough.
'second_part' member can hold microsecond precision of time value,
but now it's only supported on protocol level: you can't store
microsecond in a column, or use in temporal calculations. However,
if you send a time value with microsecond part for 'SELECT ?',
statement, you'll get it back unchanged from the server.
Binding dates and times.
For binding dates and times prepared statements API provides
clients with MYSQL_TIME structure. A pointer to instance of this
structure should be assigned to MYSQL_BIND::buffer whenever
MYSQL_TYPE_TIME, MYSQL_TYPE_DATE, MYSQL_TYPE_DATETIME typecodes
are used. When typecode is MYSQL_TYPE_TIME, only members
'hour', 'minute', 'second' and 'neg' (is time offset negative)
are used. These members only will be sent to the server.
MYSQL_TYPE_DATE implies use of 'year', 'month', 'day', 'neg'.
MYSQL_TYPE_DATETIME utilizes both parts of MYSQL_TIME structure.
You don't have to set MYSQL_TIME::time_type member: it's not
used when sending data to the server, typecode information is
enough. 'second_part' member can hold microsecond precision of
time value, but now it's only supported on protocol level: you
can't store microsecond in a column, or use in temporal
calculations. However, if you send a time value with microsecond
part for 'SELECT ?', statement, you'll get it back unchanged
from the server.
Data conversion.
If conversion from host language type to data representation,
corresponding to SQL type, is required it's done on the server.
Data truncation is possible when conversion is lossy. For example,
if you supply MYSQL_TYPE_DATETIME value out of valid SQL type
TIMESTAMP range, the same conversion will be applied as if this
value would have been sent as string in the old protocol.
TODO: document how the server will behave in case of truncation/data
loss.
Data conversion.
If conversion from host language type to data representation,
corresponding to SQL type, is required it's done on the server.
Data truncation is possible when conversion is lossy. For
example, if you supply MYSQL_TYPE_DATETIME value out of valid
SQL type TIMESTAMP range, the same conversion will be applied as
if this value would have been sent as string in the old
protocol. TODO: document how the server will behave in case of
truncation/data loss.
After variables were bound, you can repeatedly set/change their
values and mysql_stmt_execute() the statement.
@ -3175,7 +3176,7 @@ static my_bool int_is_null_false= 0;
1 error, can be retrieved with mysql_stmt_error.
*/
my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *bind)
my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *my_bind)
{
uint count=0;
MYSQL_BIND *param, *end;
@ -3192,7 +3193,7 @@ my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *bind)
}
/* Allocated on prepare */
memcpy((char*) stmt->params, (char*) bind,
memcpy((char*) stmt->params, (char*) my_bind,
sizeof(MYSQL_BIND) * stmt->param_count);
for (param= stmt->params, end= param+stmt->param_count;
@ -3355,8 +3356,7 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number,
}
param= stmt->params+param_number;
if (param->buffer_type < MYSQL_TYPE_TINY_BLOB ||
param->buffer_type > MYSQL_TYPE_STRING)
if (!IS_LONGDATA(param->buffer_type))
{
/* Long data handling should be used only for string/binary types */
strmov(stmt->sqlstate, unknown_sqlstate);
@ -3520,7 +3520,7 @@ static void fetch_string_with_conversion(MYSQL_BIND *param, char *value,
This function should support all target buffer types: the rest
of conversion functions can delegate conversion to it.
*/
switch(param->buffer_type) {
switch (param->buffer_type) {
case MYSQL_TYPE_NULL: /* do nothing */
break;
case MYSQL_TYPE_TINY:
@ -3862,32 +3862,32 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
static void fetch_datetime_with_conversion(MYSQL_BIND *param,
MYSQL_FIELD *field,
MYSQL_TIME *time)
MYSQL_TIME *my_time)
{
switch (param->buffer_type) {
case MYSQL_TYPE_NULL: /* do nothing */
break;
case MYSQL_TYPE_DATE:
*(MYSQL_TIME *)(param->buffer)= *time;
*param->error= time->time_type != MYSQL_TIMESTAMP_DATE;
*(MYSQL_TIME *)(param->buffer)= *my_time;
*param->error= my_time->time_type != MYSQL_TIMESTAMP_DATE;
break;
case MYSQL_TYPE_TIME:
*(MYSQL_TIME *)(param->buffer)= *time;
*param->error= time->time_type != MYSQL_TIMESTAMP_TIME;
*(MYSQL_TIME *)(param->buffer)= *my_time;
*param->error= my_time->time_type != MYSQL_TIMESTAMP_TIME;
break;
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_TIMESTAMP:
*(MYSQL_TIME *)(param->buffer)= *time;
*(MYSQL_TIME *)(param->buffer)= *my_time;
/* No error: time and date are compatible with datetime */
break;
case MYSQL_TYPE_YEAR:
shortstore(param->buffer, time->year);
shortstore(param->buffer, my_time->year);
*param->error= 1;
break;
case MYSQL_TYPE_FLOAT:
case MYSQL_TYPE_DOUBLE:
{
ulonglong value= TIME_to_ulonglong(time);
ulonglong value= TIME_to_ulonglong(my_time);
fetch_float_with_conversion(param, field,
ulonglong2double(value), DBL_DIG);
break;
@ -3898,7 +3898,7 @@ static void fetch_datetime_with_conversion(MYSQL_BIND *param,
case MYSQL_TYPE_LONG:
case MYSQL_TYPE_LONGLONG:
{
longlong value= (longlong) TIME_to_ulonglong(time);
longlong value= (longlong) TIME_to_ulonglong(my_time);
fetch_long_with_conversion(param, field, value, TRUE);
break;
}
@ -3909,7 +3909,7 @@ static void fetch_datetime_with_conversion(MYSQL_BIND *param,
fetch_string_with_conversion:
*/
char buff[MAX_DATE_STRING_REP_LENGTH];
uint length= my_TIME_to_str(time, buff);
uint length= my_TIME_to_str(my_time, buff);
/* Resort to string conversion */
fetch_string_with_conversion(param, (char *)buff, length);
break;
@ -4275,6 +4275,8 @@ static my_bool is_binary_compatible(enum enum_field_types type1,
static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field)
{
DBUG_ENTER("setup_one_fetch_function");
/* Setup data copy functions for the different supported types */
switch (param->buffer_type) {
case MYSQL_TYPE_NULL: /* for dummy binds */
@ -4339,7 +4341,9 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field)
param->fetch_result= fetch_result_str;
break;
default:
return TRUE;
DBUG_PRINT("error", ("Unknown param->buffer_type: %u",
(uint) param->buffer_type));
DBUG_RETURN(TRUE);
}
if (! is_binary_compatible(param->buffer_type, field->type))
param->fetch_result= fetch_result_with_conversion;
@ -4408,9 +4412,10 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field)
param->skip_result= skip_result_string;
break;
default:
return TRUE;
DBUG_PRINT("error", ("Unknown field->type: %u", (uint) field->type));
DBUG_RETURN(TRUE);
}
return FALSE;
DBUG_RETURN(FALSE);
}
@ -4418,7 +4423,7 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field)
Setup the bind buffers for resultset processing
*/
my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *my_bind)
{
MYSQL_BIND *param, *end;
MYSQL_FIELD *field;
@ -4442,8 +4447,9 @@ my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
is called from mysql_stmt_store_result.
*/
if (stmt->bind != bind)
memcpy((char*) stmt->bind, (char*) bind, sizeof(MYSQL_BIND) * bind_count);
if (stmt->bind != my_bind)
memcpy((char*) stmt->bind, (char*) my_bind,
sizeof(MYSQL_BIND) * bind_count);
for (param= stmt->bind, end= param + bind_count, field= stmt->fields ;
param < end ;
@ -4490,7 +4496,7 @@ my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
static int stmt_fetch_row(MYSQL_STMT *stmt, uchar *row)
{
MYSQL_BIND *bind, *end;
MYSQL_BIND *my_bind, *end;
MYSQL_FIELD *field;
uchar *null_ptr, bit;
int truncation_count= 0;
@ -4512,11 +4518,12 @@ static int stmt_fetch_row(MYSQL_STMT *stmt, uchar *row)
bit= 4; /* first 2 bits are reserved */
/* Copy complete row to application buffers */
for (bind= stmt->bind, end= bind + stmt->field_count, field= stmt->fields ;
bind < end ;
bind++, field++)
for (my_bind= stmt->bind, end= my_bind + stmt->field_count,
field= stmt->fields ;
my_bind < end ;
my_bind++, field++)
{
*bind->error= 0;
*my_bind->error= 0;
if (*null_ptr & bit)
{
/*
@ -4526,15 +4533,15 @@ static int stmt_fetch_row(MYSQL_STMT *stmt, uchar *row)
mysql_stmt_fetch_column, and in this case nullness of column will be
lost. See mysql_stmt_fetch_column for details.
*/
bind->row_ptr= NULL;
*bind->is_null= 1;
my_bind->row_ptr= NULL;
*my_bind->is_null= 1;
}
else
{
*bind->is_null= 0;
bind->row_ptr= row;
(*bind->fetch_result)(bind, field, &row);
truncation_count+= *bind->error;
*my_bind->is_null= 0;
my_bind->row_ptr= row;
(*my_bind->fetch_result)(my_bind, field, &row);
truncation_count+= *my_bind->error;
}
if (!((bit<<=1) & 255))
{
@ -4591,7 +4598,7 @@ int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt)
SYNOPSIS
mysql_stmt_fetch_column()
stmt Prepared statement handler
bind Where data should be placed. Should be filled in as
my_bind Where data should be placed. Should be filled in as
when calling mysql_stmt_bind_result()
column Column to fetch (first column is 0)
ulong offset Offset in result data (to fetch blob in pieces)
@ -4601,7 +4608,7 @@ int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt)
1 error
*/
int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind,
int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *my_bind,
uint column, ulong offset)
{
MYSQL_BIND *param= stmt->bind+column;
@ -4618,26 +4625,26 @@ int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind,
DBUG_RETURN(1);
}
if (!bind->error)
bind->error= &bind->error_value;
*bind->error= 0;
if (!my_bind->error)
my_bind->error= &my_bind->error_value;
*my_bind->error= 0;
if (param->row_ptr)
{
MYSQL_FIELD *field= stmt->fields+column;
uchar *row= param->row_ptr;
bind->offset= offset;
if (bind->is_null)
*bind->is_null= 0;
if (bind->length) /* Set the length if non char/binary types */
*bind->length= *param->length;
my_bind->offset= offset;
if (my_bind->is_null)
*my_bind->is_null= 0;
if (my_bind->length) /* Set the length if non char/binary types */
*my_bind->length= *param->length;
else
bind->length= &param->length_value; /* Needed for fetch_result() */
fetch_result_with_conversion(bind, field, &row);
my_bind->length= &param->length_value; /* Needed for fetch_result() */
fetch_result_with_conversion(my_bind, field, &row);
}
else
{
if (bind->is_null)
*bind->is_null= 1;
if (my_bind->is_null)
*my_bind->is_null= 1;
}
DBUG_RETURN(0);
}
@ -4709,7 +4716,7 @@ err:
static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data)
{
MYSQL_BIND *bind, *end;
MYSQL_BIND *my_bind, *end;
MYSQL_FIELD *field;
uchar *null_ptr, bit;
uchar *row= (uchar*) data->data;
@ -4722,12 +4729,12 @@ static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data)
bit= 4; /* first 2 bits are reserved */
/* Go through all fields and calculate metadata */
for (bind= stmt->bind, end= bind + stmt->field_count, field= stmt->fields ;
bind < end ;
bind++, field++)
for (my_bind= stmt->bind, end= my_bind + stmt->field_count, field= stmt->fields ;
my_bind < end ;
my_bind++, field++)
{
if (!(*null_ptr & bit))
(*bind->skip_result)(bind, field, &row);
(*my_bind->skip_result)(my_bind, field, &row);
DBUG_ASSERT(row <= row_end);
if (!((bit<<=1) & 255))
{
@ -4791,16 +4798,17 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
We must initalize the bind structure to be able to calculate
max_length
*/
MYSQL_BIND *bind, *end;
MYSQL_BIND *my_bind, *end;
MYSQL_FIELD *field;
bzero((char*) stmt->bind, sizeof(*stmt->bind)* stmt->field_count);
for (bind= stmt->bind, end= bind + stmt->field_count, field= stmt->fields;
bind < end ;
bind++, field++)
for (my_bind= stmt->bind, end= my_bind + stmt->field_count,
field= stmt->fields;
my_bind < end ;
my_bind++, field++)
{
bind->buffer_type= MYSQL_TYPE_NULL;
bind->buffer_length=1;
my_bind->buffer_type= MYSQL_TYPE_NULL;
my_bind->buffer_length=1;
}
if (mysql_stmt_bind_result(stmt, stmt->bind))

View File

@ -1,5 +1,4 @@
LIBRARY LIBMYSQL
DESCRIPTION 'MySQL 5.0 Client Library'
VERSION 6.0
EXPORTS
_dig_vec_lower

View File

@ -1052,7 +1052,7 @@ void Protocol_simple::prepare_for_resend()
data->embedded_info->prev_ptr= &cur->next;
next_field=cur->data;
next_mysql_field= data->embedded_info->fields_list;
err:
DBUG_VOID_RETURN;
}

View File

@ -490,7 +490,7 @@ static void _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_
FT_SEG_ITERATOR ftsi;
FTB_EXPR *ftbe;
float weight=ftbw->weight;
int yn=ftbw->flags, ythresh, mode=(ftsi_orig != 0);
int yn_flag= ftbw->flags, ythresh, mode=(ftsi_orig != 0);
my_off_t curdoc=ftbw->docid[mode];
for (ftbe=ftbw->up; ftbe; ftbe=ftbe->up)
@ -504,13 +504,13 @@ static void _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_
}
if (ftbe->nos)
break;
if (yn & FTB_FLAG_YES)
if (yn_flag & FTB_FLAG_YES)
{
weight /= ftbe->ythresh;
ftbe->cur_weight += weight;
if ((int) ++ftbe->yesses == ythresh)
{
yn=ftbe->flags;
yn_flag=ftbe->flags;
weight=ftbe->cur_weight*ftbe->weight;
if (mode && ftbe->phrase)
{
@ -531,14 +531,14 @@ static void _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_
break;
}
else
if (yn & FTB_FLAG_NO)
if (yn_flag & FTB_FLAG_NO)
{
/*
NOTE: special sort function of queue assures that all
(yn & FTB_FLAG_NO) != 0
(yn_flag & FTB_FLAG_NO) != 0
events for every particular subexpression will
"auto-magically" happen BEFORE all the
(yn & FTB_FLAG_YES) != 0 events. So no
(yn_flag & FTB_FLAG_YES) != 0 events. So no
already matched expression can become not-matched again.
*/
++ftbe->nos;
@ -551,8 +551,8 @@ static void _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_
ftbe->cur_weight += weight;
if ((int) ftbe->yesses < ythresh)
break;
if (!(yn & FTB_FLAG_WONLY))
yn= ((int) ftbe->yesses++ == ythresh) ? ftbe->flags : FTB_FLAG_WONLY ;
if (!(yn_flag & FTB_FLAG_WONLY))
yn_flag= ((int) ftbe->yesses++ == ythresh) ? ftbe->flags : FTB_FLAG_WONLY ;
weight*= ftbe->weight;
}
}

View File

@ -364,11 +364,11 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
}
else
{
uint j;
uint k;
share->keyinfo[i].seg=pos;
for (j=0; j < FT_SEGS; j++)
for (k=0; k < FT_SEGS; k++)
{
*pos=ft_keysegs[j];
*pos= ft_keysegs[k];
pos[0].language= pos[-1].language;
if (!(pos[0].charset= pos[-1].charset))
{

View File

@ -564,7 +564,7 @@ static void fill_quick_table(uint16 *table, uint bits, uint max_bits,
*/
value|= (max_bits - bits) << 8 | IS_CHAR;
for (end= table + (1 << bits); table < end; table++)
for (end= table + ((uint) 1 << bits); table < end; table++)
{
*table= (uint16) value;
}

View File

@ -470,9 +470,9 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page,
else
{
/* We have to compare k and vseg as if they were space extended */
uchar *end= k+ (cmplen - len);
for ( ; k < end && *k == ' '; k++) ;
if (k == end)
uchar *k_end= k+ (cmplen - len);
for ( ; k < k_end && *k == ' '; k++) ;
if (k == k_end)
goto cmp_rest; /* should never happen */
if (*k < (uchar) ' ')
{
@ -484,15 +484,15 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page,
}
else if (len > cmplen)
{
uchar *end;
uchar *vseg_end;
if ((nextflag & SEARCH_PREFIX) && key_len_left == 0)
goto fix_flag;
/* We have to compare k and vseg as if they were space extended */
for (end=vseg + (len-cmplen) ;
vseg < end && *vseg == (uchar) ' ';
for (vseg_end= vseg + (len-cmplen) ;
vseg < vseg_end && *vseg == (uchar) ' ';
vseg++, matched++) ;
DBUG_ASSERT(vseg < end);
DBUG_ASSERT(vseg < vseg_end);
if (*vseg > (uchar) ' ')
{

View File

@ -56,7 +56,7 @@ my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, byte *record,
if (_mi_search_next(info,info->s->keyinfo+def->key, info->lastkey,
MI_UNIQUE_HASH_LENGTH, SEARCH_BIGGER,
info->s->state.key_root[def->key]) ||
bcmp(info->lastkey, key_buff, MI_UNIQUE_HASH_LENGTH))
bcmp((char*) info->lastkey, (char*) key_buff, MI_UNIQUE_HASH_LENGTH))
{
info->page_changed=1; /* Can't optimize read next */
info->lastpos=lastpos;

View File

@ -720,6 +720,7 @@ get_one_option(int optid,
case 2:
method_conv= MI_STATS_METHOD_IGNORE_NULLS;
break;
default: assert(0); /* Impossible */
}
check_param.stats_method= method_conv;
break;

View File

@ -2689,8 +2689,9 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts)
}
case FIELD_VARCHAR:
{
uint pack_length= HA_VARCHAR_PACKLENGTH(count->field_length-1);
ulong col_length= (pack_length == 1 ? (uint) *(uchar*) start_pos :
uint var_pack_length= HA_VARCHAR_PACKLENGTH(count->field_length-1);
ulong col_length= (var_pack_length == 1 ?
(uint) *(uchar*) start_pos :
uint2korr(start_pos));
/* Empty varchar are encoded with a single 1 bit. */
if (!col_length)
@ -2700,7 +2701,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts)
}
else
{
byte *end=start_pos+pack_length+col_length;
byte *end= start_pos + var_pack_length + col_length;
DBUG_PRINT("fields", ("FIELD_VARCHAR not empty, bits: 1"));
write_bits(0,1);
/* Write the varchar length. */
@ -2708,7 +2709,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts)
col_length, count->length_bits));
write_bits(col_length,count->length_bits);
/* Encode the varchar bytes. */
for (start_pos+=pack_length ; start_pos < end ; start_pos++)
for (start_pos+= var_pack_length ; start_pos < end ; start_pos++)
{
DBUG_PRINT("fields",
("value: 0x%02x code: 0x%s bits: %2u bin: %s",

View File

@ -626,8 +626,6 @@ static int rtree_insert_level(MI_INFO *info, uint keynr, uchar *key,
if ((old_root = info->s->state.key_root[keynr]) == HA_OFFSET_ERROR)
{
int res;
if ((old_root = _mi_new(info, keyinfo, DFLT_INIT_HITS)) == HA_OFFSET_ERROR)
return -1;
info->buff_used = 1;
@ -913,7 +911,6 @@ int rtree_delete(MI_INFO *info, uint keynr, uchar *key, uint key_length)
for (i = 0; i < ReinsertList.n_pages; ++i)
{
uchar *page_buf;
uint nod_flag;
uchar *k;
uchar *last;

View File

@ -220,9 +220,9 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
if (my_b_inited(&tempfile_for_exceptions))
{
MI_INFO *index=info->sort_info->info;
MI_INFO *idx=info->sort_info->info;
uint keyno=info->key;
uint key_length, ref_length=index->s->rec_reflength;
uint key_length, ref_length=idx->s->rec_reflength;
if (!no_messages)
printf(" - Adding exceptions\n"); /* purecov: tested */
@ -235,7 +235,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
&& !my_b_read(&tempfile_for_exceptions,(byte*)sort_keys,
(uint) key_length))
{
if (_mi_ck_write(index,keyno,(uchar*) sort_keys,key_length-ref_length))
if (_mi_ck_write(idx,keyno,(uchar*) sort_keys,key_length-ref_length))
goto err;
}
}

View File

@ -236,8 +236,10 @@ sub mtr_report_stats ($) {
"the documentation at\n",
"http://www.mysql.com/doc/en/MySQL_test_suite.html\n";
}
print
"The servers were restarted $tot_restarts times\n";
if (!$::opt_extern)
{
print "The servers where restarted $tot_restarts times\n";
}
if ( $::opt_timer )
{

View File

@ -702,7 +702,9 @@ sub command_line_setup () {
"$glob_basedir/client",
"$glob_basedir/bin");
$exe_mysqld= mtr_exe_exists (vs_config_dirs('sql', 'mysqld'),
if (!$opt_extern)
{
$exe_mysqld= mtr_exe_exists (vs_config_dirs('sql', 'mysqld'),
"$glob_basedir/sql/mysqld",
"$path_client_bindir/mysqld-max-nt",
"$path_client_bindir/mysqld-max",
@ -714,8 +716,16 @@ sub command_line_setup () {
"$glob_basedir/bin/mysqld",
"$glob_basedir/sbin/mysqld");
# Use the mysqld found above to find out what features are available
collect_mysqld_features();
# Use the mysqld found above to find out what features are available
collect_mysqld_features();
}
else
{
$mysqld_variables{'port'}= 3306;
$mysqld_variables{'master-port'}= 3306;
$opt_skip_ndbcluster= 1;
$opt_skip_im= 1;
}
if ( $opt_comment )
{
@ -752,7 +762,7 @@ sub command_line_setup () {
# --------------------------------------------------------------------------
# NOTE if the default binlog format is changed, this has to be changed
$used_binlog_format= "stmt";
if ( $mysql_version_id >= 50100 )
if (!$opt_extern && $mysql_version_id >= 50100 )
{
$used_binlog_format= "mixed"; # Default value for binlog format
@ -838,19 +848,20 @@ sub command_line_setup () {
# --------------------------------------------------------------------------
# Check im suport
# --------------------------------------------------------------------------
if ( $mysql_version_id < 50000 )
if (!$opt_extern)
{
# Instance manager is not supported until 5.0
$opt_skip_im= 1;
if ( $mysql_version_id < 50000 ) {
# Instance manager is not supported until 5.0
$opt_skip_im= 1;
}
if ( $glob_win32 ) {
mtr_report("Disable Instance manager - not supported on Windows");
$opt_skip_im= 1;
}
}
if ( $glob_win32 )
{
mtr_report("Disable Instance manager - not supported on Windows");
$opt_skip_im= 1;
}
# --------------------------------------------------------------------------
# Record flag
# --------------------------------------------------------------------------
@ -1214,7 +1225,7 @@ sub command_line_setup () {
$opt_skip_rpl= 1;
# Setup master->[0] with the settings for the extern server
$master->[0]->{'path_sock'}= $opt_socket if $opt_socket;
$master->[0]->{'path_sock'}= $opt_socket ? $opt_socket : "/tmp/mysql.sock";
mtr_report("Using extern server at '$master->[0]->{path_sock}'");
}
else
@ -1480,60 +1491,58 @@ sub executable_setup () {
$exe_mysqlbinlog= mtr_exe_exists("$path_client_bindir/mysqlbinlog");
$exe_mysqladmin= mtr_exe_exists("$path_client_bindir/mysqladmin");
$exe_mysql= mtr_exe_exists("$path_client_bindir/mysql");
if ( $mysql_version_id >= 50100 )
{
$exe_mysqlslap= mtr_exe_exists("$path_client_bindir/mysqlslap");
}
if ( $mysql_version_id >= 50000 and !$glob_use_embedded_server )
{
$exe_mysql_upgrade= mtr_exe_exists("$path_client_bindir/mysql_upgrade")
}
else
{
$exe_mysql_upgrade= "";
}
if ( ! $glob_win32 )
if (!$opt_extern)
{
# Look for mysql_fix_system_table script
$exe_mysql_fix_system_tables=
mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables",
"$path_client_bindir/mysql_fix_privilege_tables");
}
# Look for SQL scripts directory
$path_sql_dir= mtr_path_exists("$glob_basedir/share",
"$glob_basedir/scripts");
# Look for mysql_fix_privilege_tables.sql script
$file_mysql_fix_privilege_tables=
mtr_file_exists("$path_sql_dir/mysql_fix_privilege_tables.sql");
if ( ! $opt_skip_ndbcluster and executable_setup_ndb())
{
mtr_warning("Could not find all required ndb binaries, " .
"all ndb tests will fail, use --skip-ndbcluster to " .
"skip testing it.");
foreach my $cluster (@{$clusters})
{
$cluster->{"executable_setup_failed"}= 1;
if ( $mysql_version_id >= 50100 ) {
$exe_mysqlslap= mtr_exe_exists("$path_client_bindir/mysqlslap");
}
if ( $mysql_version_id >= 50000 and !$glob_use_embedded_server ) {
$exe_mysql_upgrade= mtr_exe_exists("$path_client_bindir/mysql_upgrade")
} else {
$exe_mysql_upgrade= "";
}
}
if ( ! $opt_skip_im and executable_setup_im())
{
mtr_warning("Could not find all required instance manager binaries, " .
"all im tests will fail, use --skip-im to " .
"continue without instance manager");
$instance_manager->{"executable_setup_failed"}= 1;
}
if ( ! $glob_win32 ) {
# Look for mysql_fix_system_table script
$exe_mysql_fix_system_tables=
mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables",
"$path_client_bindir/mysql_fix_privilege_tables");
}
# Look for the udf_example library
$lib_udf_example=
mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'),
"$glob_basedir/sql/.libs/udf_example.so",);
# Look for mysql_fix_privilege_tables.sql script
$file_mysql_fix_privilege_tables=
mtr_file_exists("$glob_basedir/scripts/mysql_fix_privilege_tables.sql",
"$glob_basedir/share/mysql_fix_privilege_tables.sql");
if ( ! $opt_skip_ndbcluster and executable_setup_ndb()) {
mtr_warning("Could not find all required ndb binaries, " .
"all ndb tests will fail, use --skip-ndbcluster to " .
"skip testing it.");
foreach my $cluster (@{$clusters}) {
$cluster->{"executable_setup_failed"}= 1;
}
}
if ( ! $opt_skip_im and executable_setup_im()) {
mtr_warning("Could not find all required instance manager binaries, " .
"all im tests will fail, use --skip-im to " .
"continue without instance manager");
$instance_manager->{"executable_setup_failed"}= 1;
}
# Look for the udf_example library
$lib_udf_example=
mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'),
"$glob_basedir/sql/.libs/udf_example.so",);
}
# Look for mysqltest executable
if ( $glob_use_embedded_server )
@ -1601,7 +1610,7 @@ sub mysql_client_test_arguments()
mtr_add_arg($args, "--port=$master->[0]->{'port'}");
mtr_add_arg($args, "--socket=$master->[0]->{'path_sock'}");
if ( $mysql_version_id >= 50000 )
if ( $opt_extern || $mysql_version_id >= 50000 )
{
mtr_add_arg($args, "--vardir=$opt_vardir")
}
@ -1712,7 +1721,7 @@ sub environment_setup () {
}
$ENV{'LD_LIBRARY_PATH'}= join(":", @ld_library_paths,
$ENV{'LD_LIBRARY_PATHS'} ?
$ENV{'LD_LIBRARY_PATH'} ?
split(':', $ENV{'LD_LIBRARY_PATH'}) : ());
mtr_debug("LD_LIBRARY_PATH: $ENV{'LD_LIBRARY_PATH'}");
@ -1897,7 +1906,7 @@ sub environment_setup () {
my $cmdline_mysqlbinlog=
mtr_native_path($exe_mysqlbinlog) .
" --no-defaults --local-load=$opt_tmpdir";
if ( $mysql_version_id >= 50000 )
if (!$opt_extern && $mysql_version_id >= 50000 )
{
$cmdline_mysqlbinlog .=" --character-sets-dir=$path_charsetsdir";
}
@ -1929,7 +1938,7 @@ sub environment_setup () {
# ----------------------------------------------------
# Setup env so childs can execute mysql_upgrade
# ----------------------------------------------------
if ( $mysql_version_id >= 50000 )
if ( !$opt_extern && $mysql_version_id >= 50000 )
{
$ENV{'MYSQL_UPGRADE'}= mysql_upgrade_arguments();
}
@ -1937,7 +1946,7 @@ sub environment_setup () {
# ----------------------------------------------------
# Setup env so childs can execute mysql_fix_system_tables
# ----------------------------------------------------
if ( ! $glob_win32 )
if ( !$opt_extern && ! $glob_win32 )
{
my $cmdline_mysql_fix_system_tables=
"$exe_mysql_fix_system_tables --no-defaults --host=localhost " .
@ -1948,7 +1957,10 @@ sub environment_setup () {
$ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables;
}
$ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}= $file_mysql_fix_privilege_tables;
if (!$opt_extern)
{
$ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}= $file_mysql_fix_privilege_tables;
}
# ----------------------------------------------------
# Setup env so childs can execute my_print_defaults
@ -2262,7 +2274,10 @@ sub check_ssl_support ($) {
if ($opt_skip_ssl || $opt_extern)
{
mtr_report("Skipping SSL");
if (!$opt_extern)
{
mtr_report("Skipping SSL");
}
$opt_ssl_supported= 0;
$opt_ssl= 0;
return;
@ -2337,9 +2352,12 @@ sub vs_config_dirs ($$) {
sub check_ndbcluster_support ($) {
my $mysqld_variables= shift;
if ($opt_skip_ndbcluster)
if ($opt_skip_ndbcluster || $opt_extern)
{
mtr_report("Skipping ndbcluster");
if (!$opt_extern)
{
mtr_report("Skipping ndbcluster");
}
$opt_skip_ndbcluster_slave= 1;
return;
}
@ -2755,7 +2773,10 @@ sub initialize_servers () {
}
else
{
mtr_report("No need to create '$opt_vardir' it already exists");
if ($opt_verbose)
{
mtr_report("No need to create '$opt_vardir' it already exists");
}
}
}
else
@ -3157,17 +3178,17 @@ sub do_before_run_mysqltest($)
unlink("$result_dir/$tname.log");
unlink("$result_dir/$tname.warnings");
if ( $mysql_version_id < 50000 )
if (!$opt_extern)
{
# Set environment variable NDB_STATUS_OK to 1
# if script decided to run mysqltest cluster _is_ installed ok
$ENV{'NDB_STATUS_OK'} = "1";
}
elsif ( $mysql_version_id < 50100 )
{
# Set environment variable NDB_STATUS_OK to YES
# if script decided to run mysqltest cluster _is_ installed ok
$ENV{'NDB_STATUS_OK'} = "YES";
if ( $mysql_version_id < 50000 ) {
# Set environment variable NDB_STATUS_OK to 1
# if script decided to run mysqltest cluster _is_ installed ok
$ENV{'NDB_STATUS_OK'} = "1";
} elsif ( $mysql_version_id < 50100 ) {
# Set environment variable NDB_STATUS_OK to YES
# if script decided to run mysqltest cluster _is_ installed ok
$ENV{'NDB_STATUS_OK'} = "YES";
}
}
}
@ -4949,10 +4970,10 @@ sub usage ($) {
if ( $message )
{
print STDERR "$message \n";
print STDERR "$message\n";
}
print STDERR <<HERE;
print <<HERE;
$0 [ OPTIONS ] [ TESTCASE ]

View File

@ -0,0 +1,43 @@
[ndbd default]
NoOfReplicas= 1
MaxNoOfConcurrentTransactions= 64
MaxNoOfConcurrentOperations= CHOOSE_MaxNoOfConcurrentOperations
DataMemory= CHOOSE_DataMemory
IndexMemory= CHOOSE_IndexMemory
Diskless= CHOOSE_Diskless
TimeBetweenWatchDogCheck= 30000
DataDir= CHOOSE_FILESYSTEM
MaxNoOfOrderedIndexes= CHOOSE_MaxNoOfOrderedIndexes
MaxNoOfAttributes= CHOOSE_MaxNoOfAttributes
TimeBetweenGlobalCheckpoints= 500
NoOfFragmentLogFiles= 3
#
# Increase deadlock-timeout to cater for slow test-machines
# (possibly running several tests in parallell)
#
#TransactionDeadlockDetectionTimeout= 7500
[ndbd]
HostName= CHOOSE_HOSTNAME_1 # hostname is a valid network adress
[ndb_mgmd]
HostName= CHOOSE_HOSTNAME_1 # hostname is a valid network adress
DataDir= CHOOSE_FILESYSTEM #
PortNumber= CHOOSE_PORT_MGM
[mysqld]
[mysqld]
[mysqld]
[mysqld]
[mysqld]
[mysqld]
[mysqld]
[mysqld]

View File

@ -1,5 +1,6 @@
[ndbd default]
NoOfReplicas= 2
MaxNoOfConcurrentTransactions= 64
MaxNoOfConcurrentOperations= CHOOSE_MaxNoOfConcurrentOperations
DataMemory= CHOOSE_DataMemory
IndexMemory= CHOOSE_IndexMemory
@ -7,6 +8,15 @@ Diskless= CHOOSE_Diskless
TimeBetweenWatchDogCheck= 30000
DataDir= CHOOSE_FILESYSTEM
MaxNoOfOrderedIndexes= CHOOSE_MaxNoOfOrderedIndexes
MaxNoOfAttributes= CHOOSE_MaxNoOfAttributes
TimeBetweenGlobalCheckpoints= 500
NoOfFragmentLogFiles= 3
#
# Increase deadlock-timeout to cater for slow test-machines
# (possibly running several tests in parallell)
#
#TransactionDeadlockDetectionTimeout= 7500
[ndbd]
HostName= CHOOSE_HOSTNAME_1 # hostname is a valid network adress

View File

@ -0,0 +1,52 @@
[ndbd default]
NoOfReplicas= 2
MaxNoOfConcurrentTransactions= 64
MaxNoOfConcurrentOperations= CHOOSE_MaxNoOfConcurrentOperations
DataMemory= CHOOSE_DataMemory
IndexMemory= CHOOSE_IndexMemory
Diskless= CHOOSE_Diskless
TimeBetweenWatchDogCheck= 30000
DataDir= CHOOSE_FILESYSTEM
MaxNoOfOrderedIndexes= CHOOSE_MaxNoOfOrderedIndexes
MaxNoOfAttributes= CHOOSE_MaxNoOfAttributes
TimeBetweenGlobalCheckpoints= 500
NoOfFragmentLogFiles= 3
#
# Increase deadlock-timeout to cater for slow test-machines
# (possibly running several tests in parallell)
#
#TransactionDeadlockDetectionTimeout= 7500
[ndbd]
HostName= CHOOSE_HOSTNAME_1 # hostname is a valid network adress
[ndbd]
HostName= CHOOSE_HOSTNAME_2 # hostname is a valid network adress
[ndbd]
HostName= CHOOSE_HOSTNAME_3 # hostname is a valid network adress
[ndbd]
HostName= CHOOSE_HOSTNAME_4 # hostname is a valid network adress
[ndb_mgmd]
HostName= CHOOSE_HOSTNAME_1 # hostname is a valid network adress
DataDir= CHOOSE_FILESYSTEM #
PortNumber= CHOOSE_PORT_MGM
[mysqld]
[mysqld]
[mysqld]
[mysqld]
[mysqld]
[mysqld]
[mysqld]
[mysqld]

View File

@ -63,12 +63,17 @@ stop_ndb=
initial_ndb=
status_ndb=
ndb_diskless=0
ndbd_nodes=2
relative_config_data_dir=
opt_core=
ndb_no_ord=512
ndb_no_attr=2048
ndb_con_op=105000
ndb_dmem=80M
ndb_imem=24M
VERBOSE=100
NDB_MGM_EXTRA_OPTS=
NDB_MGMD_EXTRA_OPTS=
NDBD_EXTRA_OPTS=
@ -89,6 +94,9 @@ while test $# -gt 0; do
--debug*)
flags_ndb="$flags_ndb $1"
;;
--ndbd-nodes=*)
ndbd_nodes=`echo "$1" | sed -e "s;--ndbd-nodes=;;"`
;;
--status)
status_ndb=1
;;
@ -104,6 +112,9 @@ while test $# -gt 0; do
--data-dir=*)
fsdir=`echo "$1" | sed -e "s;--data-dir=;;"`
;;
--relative-config-data-dir)
relative_config_data_dir=1
;;
--port=*)
port=`echo "$1" | sed -e "s;--port=;;"`
;;
@ -122,6 +133,12 @@ while test $# -gt 0; do
--character-sets-dir=*)
CHARSETSDIR=`echo "$1" | sed -e "s;--character-sets-dir=;;"`
;;
--core)
opt_core="--core"
;;
--verbose=*)
VERBOSE=`echo "$1" | sed -e "s;--verbose=;;"`
;;
-- ) shift; break ;;
--* ) $ECHO "Unrecognized option: $1"; exit 1 ;;
* ) break ;;
@ -130,9 +147,10 @@ while test $# -gt 0; do
done
fs_ndb="$fsdir/ndbcluster-$port"
config_ini=ndb/ndb_config_${ndbd_nodes}_node.ini
NDB_HOME=
if [ ! -x "$fsdir" ]; then
if [ ! -d "$fsdir" ]; then
echo "$fsdir missing"
exit 1
fi
@ -148,11 +166,15 @@ if [ ! -x "$exec_waiter" ]; then
echo "$exec_waiter missing"
exit 1
fi
if [ ! -f "$config_ini" ]; then
echo "$config_ini missing, unsupported number of nodes"
exit 1
fi
exec_mgmtclient="$exec_mgmtclient --no-defaults $NDB_MGM_EXTRA_OPTS"
exec_mgmtsrvr="$exec_mgmtsrvr --no-defaults $NDB_MGMD_EXTRA_OPTS"
exec_ndb="$exec_ndb --no-defaults $NDBD_EXTRA_OPTS --character-sets-dir=$CHARSETSDIR"
exec_waiter="$exec_waiter --no-defaults"
exec_mgmtclient="$exec_mgmtclient --no-defaults $opt_core $NDB_MGM_EXTRA_OPTS"
exec_mgmtsrvr="$exec_mgmtsrvr --no-defaults $opt_core $NDB_MGMD_EXTRA_OPTS"
exec_ndb="$exec_ndb --no-defaults $opt_core $NDBD_EXTRA_OPTS --character-sets-dir=$CHARSETSDIR"
exec_waiter="$exec_waiter --no-defaults $opt_core"
ndb_host="localhost"
ndb_mgmd_port=$port
@ -196,18 +218,24 @@ fi
# Start management server as deamon
# Edit file system path and ports in config file
if [ $relative_config_data_dir ] ; then
config_fs_ndb="."
else
config_fs_ndb=$fs_ndb
fi
if [ $initial_ndb ] ; then
rm -f $fs_ndb/ndb_* 2>&1 | cat > /dev/null
rm -rf $fs_ndb/ndb_* 2>&1 | cat > /dev/null
sed \
-e s,"CHOOSE_MaxNoOfAttributes","$ndb_no_attr",g \
-e s,"CHOOSE_MaxNoOfOrderedIndexes","$ndb_no_ord",g \
-e s,"CHOOSE_MaxNoOfConcurrentOperations","$ndb_con_op",g \
-e s,"CHOOSE_DataMemory","$ndb_dmem",g \
-e s,"CHOOSE_IndexMemory","$ndb_imem",g \
-e s,"CHOOSE_Diskless","$ndb_diskless",g \
-e s,"CHOOSE_HOSTNAME_".*,"$ndb_host",g \
-e s,"CHOOSE_FILESYSTEM","$fs_ndb",g \
-e s,"CHOOSE_FILESYSTEM","$config_fs_ndb",g \
-e s,"CHOOSE_PORT_MGM","$ndb_mgmd_port",g \
< ndb/ndb_config_2_node.ini \
< "$config_ini" \
> "$fs_ndb/config.ini"
fi
@ -218,7 +246,7 @@ if ( cd "$fs_ndb" ; $exec_mgmtsrvr -f config.ini ) ; then :; else
echo "Unable to start $exec_mgmtsrvr from `pwd`"
exit 1
fi
if sleep_until_file_created $fs_ndb/ndb_3.pid 120
if sleep_until_file_created $fs_ndb/ndb_`expr $ndbd_nodes + 1`.pid 120
then :; else
exit 1
fi
@ -226,38 +254,43 @@ cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile"
# Start database node
echo "Starting ndbd"
( cd "$fs_ndb" ; $exec_ndb $flags_ndb & )
if sleep_until_file_created $fs_ndb/ndb_1.pid 120
then :; else
stop_default_ndbcluster
exit 1
fi
cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile"
# Start database node
echo "Starting ndbd"
( cd "$fs_ndb" ; $exec_ndb $flags_ndb & )
if sleep_until_file_created $fs_ndb/ndb_2.pid 120
then :; else
stop_default_ndbcluster
exit 1
fi
cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile"
id=1
while [ $id -le $ndbd_nodes ]
do
if [ `expr $VERBOSE \> 1` = 1 ] ; then
echo "Starting ndbd $id($ndbd_nodes)"
fi
( cd "$fs_ndb" ; $exec_ndb $flags_ndb & )
if sleep_until_file_created $fs_ndb/ndb_${id}.pid 120
then :; else
stop_default_ndbcluster
exit 1
fi
cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile"
id=`expr $id + 1`
done
# test if Ndb Cluster starts properly
echo "Waiting for NDB data nodes to start..."
if ( $exec_waiter ) | grep "NDBT_ProgramExit: 0 - OK" > /dev/null 2>&1; then :; else
echo "Ndbcluster startup failed"
if [ `expr $VERBOSE \> 1` = 1 ] ; then
echo "Waiting for NDB data nodes to start..."
fi
if ( $exec_waiter ) | grep "NDBT_ProgramExit: 0 - OK" > /dev/null 2>&1 ; then :; else
if [ `expr $VERBOSE \> 0` = 1 ] ; then
echo "Ndbcluster startup failed"
fi
stop_default_ndbcluster
exit 1
fi
if [ `expr $VERBOSE \> 1` = 1 ] ; then
echo "Ok"
fi
cat `find "$fs_ndb" -name 'ndb_*.pid'` > $fs_ndb/$pidfile
status_ndbcluster
if [ `expr $VERBOSE \> 2` = 1 ] ; then
status_ndbcluster
fi
}
status_ndbcluster() {

View File

@ -1442,7 +1442,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref c c 11 const # Using where
explain select count(*) from t1 where t='a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range t t 13 NULL # Using where
1 SIMPLE t1 ref t t 13 const # Using where
explain select count(*) from t1 where v like 'a%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 13 NULL # Using where

View File

@ -123,3 +123,14 @@ master-bin.000001 # Query 1 # use `test`; create table t3 like t1
master-bin.000001 # Query 1 # use `test`; insert into t1 select * from t3
master-bin.000001 # Query 1 # use `test`; replace into t1 select * from t3
drop table t1,t2,t3;
CREATE TABLE t1(a INT, b INT) ENGINE=BLACKHOLE;
DELETE FROM t1 WHERE a=10;
ALTER TABLE t1 ADD INDEX(a);
DELETE FROM t1 WHERE a=10;
ALTER TABLE t1 DROP INDEX a;
ALTER TABLE t1 ADD UNIQUE INDEX(a);
DELETE FROM t1 WHERE a=10;
ALTER TABLE t1 DROP INDEX a;
ALTER TABLE t1 ADD PRIMARY KEY(a);
DELETE FROM t1 WHERE a=10;
DROP TABLE t1;

View File

@ -11363,3 +11363,15 @@ c_cp932
繧ス
set names utf8;
create table t1 (a text) default character set cp932;
insert into t1 values (_utf8 0xE38182);
show warnings;
Level Code Message
select * from t1;
a
select hex(a) from t1;
hex(a)
82A0
drop table t1;

View File

@ -8,9 +8,9 @@ SET @var1= x'8300';
EXECUTE stmt1 USING @var1;
SHOW BINLOG EVENTS FROM 98;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 98 Query 1 185 use `test`; CREATE TABLE t1(f1 blob)
master-bin.000001 185 User var 1 224 @`var1`=_binary 0x8300 COLLATE binary
master-bin.000001 224 Query 1 317 use `test`; INSERT INTO t1 VALUES(@'var1')
master-bin.000001 98 Query 1 188 use `test`; CREATE TABLE t1(f1 blob)
master-bin.000001 188 User var 1 227 @`var1`=_binary 0x8300 COLLATE binary
master-bin.000001 227 Query 1 323 use `test`; INSERT INTO t1 VALUES(@'var1')
SELECT HEX(f1) FROM t1;
HEX(f1)
8300
@ -30,17 +30,17 @@ HEX(s1) HEX(s2) d
466F6F2773206120426172 ED40ED41ED42 47.93
DROP PROCEDURE bug18293|
DROP TABLE t4|
SHOW BINLOG EVENTS FROM 393|
SHOW BINLOG EVENTS FROM 402|
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 393 Query 1 556 use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1,
master-bin.000001 402 Query 1 568 use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1,
s2 CHAR(50) CHARACTER SET cp932,
d DECIMAL(10,2))
master-bin.000001 556 Query 1 801 use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE bug18293 (IN ins1 CHAR(50),
master-bin.000001 568 Query 1 816 use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE bug18293 (IN ins1 CHAR(50),
IN ins2 CHAR(50) CHARACTER SET cp932,
IN ind DECIMAL(10,2))
BEGIN
INSERT INTO t4 VALUES (ins1, ins2, ind);
END
master-bin.000001 801 Query 1 1017 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93))
master-bin.000001 1017 Query 1 1103 use `test`; DROP PROCEDURE bug18293
master-bin.000001 1103 Query 1 1179 use `test`; DROP TABLE t4
master-bin.000001 816 Query 1 1035 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93))
master-bin.000001 1035 Query 1 1124 use `test`; DROP PROCEDURE bug18293
master-bin.000001 1124 Query 1 1203 use `test`; DROP TABLE t4

View File

@ -8,9 +8,9 @@ SET @var1= x'8300';
EXECUTE stmt1 USING @var1;
SHOW BINLOG EVENTS FROM 98;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 98 Query 1 185 use `test`; CREATE TABLE t1(f1 blob)
master-bin.000001 185 User var 1 224 @`var1`=_binary 0x8300 COLLATE binary
master-bin.000001 224 Query 1 317 use `test`; INSERT INTO t1 VALUES(@'var1')
master-bin.000001 98 Query 1 188 use `test`; CREATE TABLE t1(f1 blob)
master-bin.000001 188 User var 1 227 @`var1`=_binary 0x8300 COLLATE binary
master-bin.000001 227 Query 1 323 use `test`; INSERT INTO t1 VALUES(@'var1')
SELECT HEX(f1) FROM t1;
HEX(f1)
8300

View File

@ -98,7 +98,7 @@ concat('|', text1, '|')
|teststring |
explain select concat('|', text1, '|') from t1 where text1='teststring ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range key1 key1 22 NULL 2 Using where
1 SIMPLE t1 ref key1 key1 22 const 2 Using where
select concat('|', text1, '|') from t1 where text1 like 'teststring_%';
concat('|', text1, '|')
|teststring |

View File

@ -2,11 +2,11 @@ drop table if exists t1;
create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb;
select * from t1;
c1 c2 stamp
replace delayed into t1 (c1, c2) values ( "text1","11"),( "text2","12");
replace delayed into t1 (c1, c2) values ( "text1","11");
ERROR HY000: Table storage engine for 't1' doesn't have this option
select * from t1;
c1 c2 stamp
replace delayed into t1 (c1, c2) values ( "text1","12"),( "text2","13"),( "text3","14", "a" ),( "text4","15", "b" );
replace delayed into t1 (c1, c2) values ( "text1","12");
ERROR HY000: Table storage engine for 't1' doesn't have this option
select * from t1;
c1 c2 stamp

View File

@ -1991,7 +1991,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref c c 11 const # Using where; Using index
explain select count(*) from t1 where t='a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range t t 13 NULL # Using where
1 SIMPLE t1 ref t t 13 const # Using where
explain select count(*) from t1 where v like 'a%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 13 NULL # Using where; Using index

View File

@ -731,3 +731,16 @@ select @@identity;
@@identity
0
drop table t1;
CREATE TABLE t1 (f1 INT, f2 INT );
CREATE TABLE t2 (f1 INT PRIMARY KEY, f2 INT);
INSERT INTO t1 VALUES (1,1),(2,2),(10,10);
INSERT INTO t2 (f1, f2) SELECT f1, f2 FROM t1;
INSERT INTO t2 (f1, f2)
SELECT f1, f1 FROM t2 src WHERE f1 < 2
ON DUPLICATE KEY UPDATE f1 = 100 + src.f1;
SELECT * FROM t2;
f1 f2
101 1
2 2
10 10
DROP TABLE t1, t2;

View File

@ -219,3 +219,20 @@ SELECT * FROM t1;
a b
45 2
DROP TABLE t1;
CREATE TABLE t1 (i INT PRIMARY KEY, j INT);
INSERT INTO t1 SELECT 1, j;
ERROR 42S22: Unknown column 'j' in 'field list'
DROP TABLE t1;
CREATE TABLE t1 (i INT PRIMARY KEY, j INT);
CREATE TABLE t2 (a INT, b INT);
CREATE TABLE t3 (a INT, c INT);
INSERT INTO t1 SELECT 1, a FROM t2 NATURAL JOIN t3
ON DUPLICATE KEY UPDATE j= a;
DROP TABLE t1,t2,t3;
CREATE TABLE t1 (i INT PRIMARY KEY, j INT);
CREATE TABLE t2 (a INT);
INSERT INTO t1 VALUES (1, 1);
INSERT INTO t2 VALUES (1), (3);
INSERT INTO t1 SELECT 1, COUNT(*) FROM t2 ON DUPLICATE KEY UPDATE j= a;
ERROR 42S22: Unknown column 'a' in 'field list'
DROP TABLE t1,t2;

View File

@ -16,3 +16,16 @@ select events.binlog from events;
binlog
1
drop table events;
create table t1 (connection int, b int);
create procedure p1()
begin
declare connection int;
select max(t1.connection) into connection from t1;
select concat("max=",connection) 'p1';
end|
insert into t1 (connection) values (1);
call p1();
p1
max=1
drop procedure p1;
drop table t1;

View File

@ -1071,7 +1071,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref c c 11 const # Using where; Using index
explain select count(*) from t1 where t='a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range t t 13 NULL # Using where
1 SIMPLE t1 ref t t 13 const # Using where
explain select count(*) from t1 where v like 'a%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 13 NULL # Using where; Using index

View File

@ -1,5 +1,5 @@
set timestamp=1000000000;
drop table if exists t1,t2;
drop table if exists t1,t2,t3,t4,t5,t03,t04;
create table t1 (word varchar(20));
create table t2 (id int auto_increment not null primary key);
insert into t1 values ("abirvalg");
@ -23,7 +23,7 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq
SET @@session.sql_mode=0/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
drop table if exists t1,t2/*!*/;
drop table if exists t1,t2,t3,t4,t5,t03,t04/*!*/;
SET TIMESTAMP=1000000000/*!*/;
create table t1 (word varchar(20))/*!*/;
SET TIMESTAMP=1000000000/*!*/;
@ -100,7 +100,7 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq
SET @@session.sql_mode=0/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
drop table if exists t1,t2/*!*/;
drop table if exists t1,t2,t3,t4,t5,t03,t04/*!*/;
SET TIMESTAMP=1000000000/*!*/;
create table t1 (word varchar(20))/*!*/;
SET TIMESTAMP=1000000000/*!*/;
@ -192,13 +192,14 @@ DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
drop table t1,t2;
flush logs;
select * from t5 /* must be (1),(1) */;
a
1
1
drop table t5;
flush logs;
drop table if exists t5;
create table t5 (c1 int, c2 varchar(128) character set latin1 not null);
insert into t5 values (1, date_format('2001-01-01','%W'));
set lc_time_names=de_DE;
@ -217,6 +218,7 @@ c1 c2
1 Monday
2 Montag
3 Monday
drop table t5;
drop procedure if exists p1;
flush logs;
create procedure p1()
@ -231,6 +233,7 @@ call p1();
drop procedure p1;
call p1();
ERROR 42000: PROCEDURE test.p1 does not exist
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
@ -251,6 +254,63 @@ ROLLBACK /* added by mysqlbinlog */;
call p1();
1
1
drop procedure p1;
flush logs;
create table t1 (a varchar(64) character set utf8);
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set character_set_database=koi8r;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set character_set_database=latin1;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set character_set_database=koi8r;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set character_set_database=latin1;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8r;
select hex(a) from t1;
hex(a)
C3BF
D0AA
C3BF
C3BF
D0AA
C3BF
D0AA
drop table t1;
flush logs;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
use test/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
create table t1 (a varchar(64) character set utf8)/*!*/;
SET TIMESTAMP=1000000000/*!*/;
load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-6-0' INTO table t1/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.collation_database=7/*!*/;
load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-7-0' INTO table t1/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-8-0' INTO table t1/*!*/;
SET TIMESTAMP=1000000000/*!*/;
load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-9-0' INTO table t1/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.collation_database=7/*!*/;
load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-a-0' INTO table t1/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-b-0' INTO table t1/*!*/;
SET TIMESTAMP=1000000000/*!*/;
load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-c-0' INTO table t1 character set koi8r/*!*/;
SET TIMESTAMP=1000000000/*!*/;
drop table t1/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
drop table t1, t2, t5;
End of 5.0 tests

View File

@ -1,3 +1,6 @@
DROP TABLE IF EXISTS t1;
drop view if exists v1;
drop database if exists client_test_db;
mysql.columns_priv OK
mysql.db OK
mysql.func OK

View File

@ -421,6 +421,8 @@ mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 7: Con
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 3: connection 'test_con1' not found in connection pool
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 2: Connection test_con1 already exists
connect(localhost,root,,test,MASTER_PORT,MASTER_SOCKET);
show tables;
ERROR 3D000: No database selected
Output from mysqltest-x.inc
Output from mysqltest-x.inc
Output from mysqltest-x.inc

View File

@ -121,7 +121,7 @@ select * from t1 where x = 1 for update;
x y z
1 one 1
select * from t1 where x = 2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
Got one of the listed errors
rollback;
commit;
begin;

View File

@ -0,0 +1,31 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
CREATE TABLE t1 (id INT primary key auto_increment, name VARCHAR(64));
truncate table t1;
insert delayed into t1 values(10, "my name");
insert delayed into t1 values(10, "is Bond"), (20, "James Bond");
ERROR 23000: Duplicate entry '10' for key 1
flush table t1;
select * from t1;
id name
10 my name
select * from t1;
id name
10 my name
delete from t1 where id!=10;
insert delayed into t1 values(20, "is Bond"), (10, "James Bond");
ERROR 23000: Duplicate entry '10' for key 1
flush table t1;
select * from t1;
id name
10 my name
20 is Bond
select * from t1;
id name
10 my name
20 is Bond
drop table t1;

View File

@ -234,6 +234,64 @@ n b
2 100
3 350
drop table t1;
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT,
UNIQUE(b));
INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10;
SELECT * FROM t1;
a b
1 10
2 2
SELECT * FROM t1;
a b
1 10
2 2
drop table t1;
CREATE TABLE t1 (
id bigint(20) unsigned NOT NULL auto_increment,
field_1 int(10) unsigned NOT NULL,
field_2 varchar(255) NOT NULL,
field_3 varchar(255) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY field_1 (field_1, field_2)
);
CREATE TABLE t2 (
field_a int(10) unsigned NOT NULL,
field_b varchar(255) NOT NULL,
field_c varchar(255) NOT NULL
);
INSERT INTO t2 (field_a, field_b, field_c) VALUES (1, 'a', '1a');
INSERT INTO t2 (field_a, field_b, field_c) VALUES (2, 'b', '2b');
INSERT INTO t2 (field_a, field_b, field_c) VALUES (3, 'c', '3c');
INSERT INTO t2 (field_a, field_b, field_c) VALUES (4, 'd', '4d');
INSERT INTO t2 (field_a, field_b, field_c) VALUES (5, 'e', '5e');
INSERT INTO t1 (field_1, field_2, field_3)
SELECT t2.field_a, t2.field_b, t2.field_c
FROM t2
ON DUPLICATE KEY UPDATE
t1.field_3 = t2.field_c;
INSERT INTO t2 (field_a, field_b, field_c) VALUES (6, 'f', '6f');
INSERT INTO t1 (field_1, field_2, field_3)
SELECT t2.field_a, t2.field_b, t2.field_c
FROM t2
ON DUPLICATE KEY UPDATE
t1.field_3 = t2.field_c;
SELECT * FROM t1;
id field_1 field_2 field_3
1 1 a 1a
2 2 b 2b
3 3 c 3c
4 4 d 4d
5 5 e 5e
6 6 f 6f
SELECT * FROM t1;
id field_1 field_2 field_3
1 1 a 1a
2 2 b 2b
3 3 c 3c
4 4 d 4d
5 5 e 5e
6 6 f 6f
drop table t1, t2;
DROP PROCEDURE IF EXISTS p1;
DROP TABLE IF EXISTS t1, t2;
SELECT LAST_INSERT_ID(0);

View File

@ -0,0 +1,133 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT,
UNIQUE(b));
INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10;
SELECT * FROM t1;
a b
1 10
2 2
show slave status;;
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
Master_Port #
Connect_Retry 1
Master_Log_File master-bin.000001
Read_Master_Log_Pos #
Relay_Log_File #
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
Slave_IO_Running Yes
Slave_SQL_Running No
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
Last_Errno 1105
Last_Error Error 'master may suffer from http://bugs.mysql.com/bug.php?id=24432 so slave stops; check error log on slave for more info' on query. Default database: 'test'. Query: 'INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10'
Skip_Counter 0
Exec_Master_Log_Pos 238
Relay_Log_Space #
Until_Condition None
Until_Log_File
Until_Log_Pos 0
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master #
SELECT * FROM t1;
a b
stop slave;
reset slave;
reset master;
drop table t1;
start slave;
CREATE TABLE t1 (
id bigint(20) unsigned NOT NULL auto_increment,
field_1 int(10) unsigned NOT NULL,
field_2 varchar(255) NOT NULL,
field_3 varchar(255) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY field_1 (field_1, field_2)
);
CREATE TABLE t2 (
field_a int(10) unsigned NOT NULL,
field_b varchar(255) NOT NULL,
field_c varchar(255) NOT NULL
);
INSERT INTO t2 (field_a, field_b, field_c) VALUES (1, 'a', '1a');
INSERT INTO t2 (field_a, field_b, field_c) VALUES (2, 'b', '2b');
INSERT INTO t2 (field_a, field_b, field_c) VALUES (3, 'c', '3c');
INSERT INTO t2 (field_a, field_b, field_c) VALUES (4, 'd', '4d');
INSERT INTO t2 (field_a, field_b, field_c) VALUES (5, 'e', '5e');
INSERT INTO t1 (field_1, field_2, field_3)
SELECT t2.field_a, t2.field_b, t2.field_c
FROM t2
ON DUPLICATE KEY UPDATE
t1.field_3 = t2.field_c;
INSERT INTO t2 (field_a, field_b, field_c) VALUES (6, 'f', '6f');
INSERT INTO t1 (field_1, field_2, field_3)
SELECT t2.field_a, t2.field_b, t2.field_c
FROM t2
ON DUPLICATE KEY UPDATE
t1.field_3 = t2.field_c;
SELECT * FROM t1;
id field_1 field_2 field_3
1 1 a 1a
2 2 b 2b
3 3 c 3c
4 4 d 4d
5 5 e 5e
6 6 f 6f
show slave status;;
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
Master_Port #
Connect_Retry 1
Master_Log_File master-bin.000001
Read_Master_Log_Pos #
Relay_Log_File #
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
Slave_IO_Running Yes
Slave_SQL_Running No
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
Last_Errno 1105
Last_Error Error 'master may suffer from http://bugs.mysql.com/bug.php?id=24432 so slave stops; check error log on slave for more info' on query. Default database: 'test'. Query: 'INSERT INTO t1 (field_1, field_2, field_3)
SELECT t2.field_a, t2.field_b, t2.field_c
FROM t2
ON DUPLICATE KEY UPDATE
t1.field_3 = t2.field_c'
Skip_Counter 0
Exec_Master_Log_Pos 1270
Relay_Log_Space #
Until_Condition None
Until_Log_File
Until_Log_Pos 0
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master #
SELECT * FROM t1;
id field_1 field_2 field_3
drop table t1, t2;
drop table t1, t2;

View File

@ -0,0 +1,37 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create table t1 (a varchar(10) character set utf8);
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set @@character_set_database=koi8r;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set @@character_set_database=DEFAULT;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set @@character_set_database=koi8r;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set @@character_set_database=DEFAULT;
load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8r;
select hex(a) from t1;
hex(a)
C3BF
D0AA
C3BF
C3BF
C3BF
D0AA
D0AA
select hex(a) from t1;
hex(a)
C3BF
D0AA
C3BF
C3BF
C3BF
D0AA
D0AA
drop table t1;

View File

@ -41,3 +41,37 @@ select * from t1;
ts
2005-08-12 00:00:00
drop table t1;
*** master ***
create table t1 (a int, b int);
create trigger trg1 before insert on t1 for each row set new.b=2;
create table t2 (a int, b int);
create trigger trg2 before insert on t2 for each row set new.b=2;
show tables;
Tables_in_test
t1
t2
show triggers;
Trigger Event Table Statement Timing Created sql_mode Definer
trg1 INSERT t1 set new.b=2 BEFORE NULL root@localhost
trg2 INSERT t2 set new.b=2 BEFORE NULL root@localhost
*** slave ***
show tables;
Tables_in_test
t1
show triggers;
Trigger Event Table Statement Timing Created sql_mode Definer
trg1 INSERT t1 set new.b=2 BEFORE NULL root@localhost
*** master ***
drop trigger trg1;
drop trigger trg2;
show triggers;
Trigger Event Table Statement Timing Created sql_mode Definer
*** slave ***
show tables;
Tables_in_test
t1
show triggers;
Trigger Event Table Statement Timing Created sql_mode Definer
*** master ***
drop table t1;
drop table t2;

View File

@ -108,4 +108,180 @@ slave-bin.000001 # User var 2 # @`a`=NULL
slave-bin.000001 # Query 1 # use `test`; insert into t1 values (@a),(@a),(@a*5)
insert into t1 select * FROM (select @var1 union select @var2) AS t2;
drop table t1;
End of 4.1 tests.
DROP TABLE IF EXISTS t20;
DROP TABLE IF EXISTS t21;
DROP PROCEDURE IF EXISTS test.insert;
CREATE TABLE t20 (a VARCHAR(20));
CREATE TABLE t21 (a VARCHAR(20));
CREATE PROCEDURE test.insert()
BEGIN
IF (@VAR)
THEN
INSERT INTO test.t20 VALUES ('SP_TRUE');
ELSE
INSERT INTO test.t20 VALUES ('SP_FALSE');
END IF;
END|
CREATE TRIGGER test.insert_bi BEFORE INSERT
ON test.t20 FOR EACH ROW
BEGIN
IF (@VAR)
THEN
INSERT INTO test.t21 VALUES ('TRIG_TRUE');
ELSE
INSERT INTO test.t21 VALUES ('TRIG_FALSE');
END IF;
END|
SET @VAR=0;
CALL test.insert();
SET @VAR=1;
CALL test.insert();
On master: Check the tables for correct data
SELECT * FROM t20;
a
SP_FALSE
SP_TRUE
SELECT * FROM t21;
a
TRIG_FALSE
TRIG_TRUE
On slave: Check the tables for correct data and it matches master
SELECT * FROM t20;
a
SP_FALSE
SP_TRUE
SELECT * FROM t21;
a
TRIG_FALSE
TRIG_TRUE
DROP TABLE t20;
DROP TABLE t21;
DROP PROCEDURE test.insert;
DROP TABLE IF EXISTS t1;
DROP FUNCTION IF EXISTS test.square;
CREATE TABLE t1 (i INT);
CREATE FUNCTION test.square() RETURNS INTEGER DETERMINISTIC RETURN (@var * @var);
SET @var = 1;
INSERT INTO t1 VALUES (square());
SET @var = 2;
INSERT INTO t1 VALUES (square());
SET @var = 3;
INSERT INTO t1 VALUES (square());
SET @var = 4;
INSERT INTO t1 VALUES (square());
SET @var = 5;
INSERT INTO t1 VALUES (square());
On master: Retrieve the values from the table
SELECT * FROM t1;
i
1
4
9
16
25
On slave: Retrieve the values from the table and verify they are the same as on master
SELECT * FROM t1;
i
1
4
9
16
25
DROP TABLE t1;
DROP FUNCTION test.square;
DROP TABLE IF EXISTS t1;
DROP FUNCTION IF EXISTS f1;
DROP FUNCTION IF EXISTS f2;
CREATE TABLE t1(a int);
CREATE FUNCTION f1() returns int deterministic
BEGIN
return @a;
END |
CREATE FUNCTION f2() returns int deterministic
BEGIN
IF (@b > 0) then
SET @c = (@a + @b);
else
SET @c = (@a - 1);
END if;
return @c;
END |
SET @a=500;
INSERT INTO t1 values(f1());
SET @b = 125;
SET @c = 1;
INSERT INTO t1 values(f2());
On master: Retrieve the values from the table
SELECT * from t1;
a
500
625
On slave: Check the tables for correct data and it matches master
SELECT * from t1;
a
500
625
DROP TABLE t1;
DROP FUNCTION f1;
DROP FUNCTION f2;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1 (i int);
CREATE TABLE t2 (k int);
CREATE trigger t1_bi before INSERT on t1 for each row
BEGIN
INSERT INTO t2 values (@a);
SET @a:=42;
INSERT INTO t2 values (@a);
END |
SET @a:=100;
INSERT INTO t1 values (5);
On master: Check to see that data was inserted correctly in both tables
SELECT * from t1;
i
5
SELECT * from t2;
k
100
42
On slave: Check the tables for correct data and it matches master
SELECT * from t1;
i
5
SELECT * from t2;
k
100
42
End of 5.0 tests.
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE IF EXISTS t1;
DROP FUNCTION IF EXISTS f1;
DROP FUNCTION IF EXISTS f2;
CREATE TABLE t1 (i INT);
CREATE FUNCTION f1() RETURNS INT RETURN @a;
CREATE FUNCTION f2() RETURNS INT
BEGIN
INSERT INTO t1 VALUES (10 + @a);
RETURN 0;
END|
SET @a:=123;
SELECT f1(), f2();
f1() f2()
123 0
On master: Check to see that data was inserted correctly
INSERT INTO t1 VALUES(f1());
SELECT * FROM t1;
i
133
123
On slave: Check the table for correct data and it matches master
SELECT * FROM t1;
i
133
123
DROP FUNCTION f1;
DROP FUNCTION f2;
DROP TABLE t1;
stop slave;

View File

@ -3785,4 +3785,152 @@ case when 1 then cast(1111111111111111111 as unsigned) else 1 end c,
coalesce(cast(1111111111111111111 as unsigned), 1) co;
i c co
1111111111111111111 1111111111111111111 1111111111111111111
CREATE TABLE t1 (name varchar(255));
CREATE TABLE t2 (name varchar(255), n int, KEY (name(3)));
INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa');
INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3);
INSERT INTO t2 VALUES (concat('cc ', 0x06), 4);
INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7);
SELECT * FROM t2;
name n
bb 1
aa 2
cc 3
cc  4
cc 5
bb 6
cc 7
SELECT * FROM t2 ORDER BY name;
name n
aa 2
bb 1
bb 6
cc  4
cc 3
cc 5
cc 7
SELECT name, LENGTH(name), n FROM t2 ORDER BY name;
name LENGTH(name) n
aa 2 2
bb 2 1
bb 3 6
cc  4 4
cc 5 3
cc 2 5
cc 3 7
EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref name name 6 const 3 Using where
SELECT name, LENGTH(name), n FROM t2 WHERE name='cc ';
name LENGTH(name) n
cc 5 3
cc 2 5
cc 3 7
EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range name name 6 NULL 3 Using where
SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%';
name LENGTH(name) n
cc 5 3
cc  4 4
cc 2 5
cc 3 7
EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range name name 6 NULL 3 Using where; Using filesort
SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name;
name LENGTH(name) n
cc  4 4
cc 5 3
cc 2 5
cc 3 7
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
1 SIMPLE t2 ref name name 6 test.t1.name 2
SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name;
name name n
ccc NULL NULL
bb bb 1
bb bb 6
cc cc 3
cc cc 5
cc cc 7
aa aa 2
aa aa 2
DROP TABLE t1,t2;
CREATE TABLE t1 (name text);
CREATE TABLE t2 (name text, n int, KEY (name(3)));
INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa');
INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3);
INSERT INTO t2 VALUES (concat('cc ', 0x06), 4);
INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7);
SELECT * FROM t2;
name n
bb 1
aa 2
cc 3
cc  4
cc 5
bb 6
cc 7
SELECT * FROM t2 ORDER BY name;
name n
aa 2
bb 1
bb 6
cc  4
cc 3
cc 5
cc 7
SELECT name, LENGTH(name), n FROM t2 ORDER BY name;
name LENGTH(name) n
aa 2 2
bb 2 1
bb 3 6
cc  4 4
cc 5 3
cc 2 5
cc 3 7
EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref name name 6 const 3 Using where
SELECT name, LENGTH(name), n FROM t2 WHERE name='cc ';
name LENGTH(name) n
cc 5 3
cc 2 5
cc 3 7
EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range name name 6 NULL 3 Using where
SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%';
name LENGTH(name) n
cc 5 3
cc  4 4
cc 2 5
cc 3 7
EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range name name 6 NULL 3 Using where; Using filesort
SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name;
name LENGTH(name) n
cc  4 4
cc 5 3
cc 2 5
cc 3 7
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
1 SIMPLE t2 ref name name 6 test.t1.name 2
SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name;
name name n
ccc NULL NULL
bb bb 1
bb bb 6
cc cc 3
cc cc 5
cc cc 7
aa aa 2
aa aa 2
DROP TABLE t1,t2;
End of 5.0 tests

View File

@ -224,7 +224,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 Using where
Warnings:
Note 1276 Field or reference 't4.a' of SELECT #3 was resolved in SELECT #1
Note 1276 Field or reference 'test.t4.a' of SELECT #3 was resolved in SELECT #1
Note 1003 select `test`.`t4`.`b` AS `b`,(select avg((`test`.`t2`.`a` + (select min(`test`.`t3`.`a`) AS `min(t3.a)` from `test`.`t3` where (`test`.`t3`.`a` >= `test`.`t4`.`a`)))) AS `avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a))` from `test`.`t2`) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4`
select * from t3 where exists (select * from t2 where t2.b=t3.a);
a
@ -313,8 +313,8 @@ id select_type table type possible_keys key key_len ref rows Extra
3 DEPENDENT UNION t5 ALL NULL NULL NULL NULL 2 Using where
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
Warnings:
Note 1276 Field or reference 't2.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 't2.a' of SELECT #3 was resolved in SELECT #1
Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1
Note 1003 select (select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`a`) union select `test`.`t5`.`a` AS `a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2`
select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
ERROR 21000: Subquery returns more than 1 row
@ -330,9 +330,9 @@ patient_uq clinic_uq
explain extended select * from t6 where exists (select * from t7 where uq = clinic_uq);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t6 ALL NULL NULL NULL NULL 4 Using where
2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 Using index
2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 t6.clinic_uq 1 Using where; Using index
Warnings:
Note 1276 Field or reference 'clinic_uq' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where exists(select 1 AS `Not_used` from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`))
select * from t1 where a= (select a from t2,t4 where t2.b=t4.b);
ERROR 23000: Column 'a' in field list is ambiguous
@ -868,7 +868,7 @@ explain extended select (select a+1) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
Warnings:
Note 1276 Field or reference 'a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1249 Select 2 was reduced during optimization
Note 1003 select (`test`.`t1`.`a` + 1) AS `(select a+1)` from `test`.`t1`
select (select a+1) from t1;
@ -1741,9 +1741,9 @@ Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `tes
explain extended select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY tt ALL NULL NULL NULL NULL 12 Using where
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 Using where; Using index
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 tt.id 1 Using where; Using index
Warnings:
Note 1276 Field or reference 'tt.id' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(exists(select `test`.`t1`.`id` AS `id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null))))
insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001');
create table t2 (id int not null, text varchar(20) not null default '', primary key (id));
@ -2279,7 +2279,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY up ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
Warnings:
Note 1276 Field or reference 'up.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where exists(select 1 AS `Not_used` from `test`.`t1` where (`test`.`t1`.`a` = `test`.`up`.`a`))
drop table t1;
CREATE TABLE t1 (t1_a int);
@ -3712,3 +3712,45 @@ bb 2
cc 3
dd 1
DROP TABLE t1,t2,t3;
CREATE TABLE t1(f1 int);
CREATE TABLE t2(f2 int, f21 int, f3 timestamp);
INSERT INTO t1 VALUES (1),(1),(2),(2);
INSERT INTO t2 VALUES (1,1,"2004-02-29 11:11:11"), (2,2,"2004-02-29 11:11:11");
SELECT ((SELECT f2 FROM t2 WHERE f21=f1 LIMIT 1) * COUNT(f1)) AS sq FROM t1 GROUP BY f1;
sq
2
4
SELECT (SELECT SUM(1) FROM t2 ttt GROUP BY t2.f3 LIMIT 1) AS tt FROM t2;
tt
2
2
PREPARE stmt1 FROM 'SELECT ((SELECT f2 FROM t2 WHERE f21=f1 LIMIT 1) * COUNT(f1)) AS sq FROM t1 GROUP BY f1';
EXECUTE stmt1;
sq
2
4
EXECUTE stmt1;
sq
2
4
DEALLOCATE PREPARE stmt1;
SELECT f2, AVG(f21),
(SELECT t.f3 FROM t2 AS t WHERE t2.f2=t.f2 AND t.f3=MAX(t2.f3)) AS test
FROM t2 GROUP BY f2;
f2 AVG(f21) test
1 1.0000 2004-02-29 11:11:11
2 2.0000 2004-02-29 11:11:11
DROP TABLE t1,t2;
CREATE TABLE t1 (a int, b INT, c CHAR(10) NOT NULL);
INSERT INTO t1 VALUES
(1,1,'a'), (1,2,'b'), (1,3,'c'), (1,4,'d'), (1,5,'e'),
(2,1,'f'), (2,2,'g'), (2,3,'h'), (3,4,'i'), (3,3,'j'),
(3,2,'k'), (3,1,'l'), (1,9,'m');
SELECT a, MAX(b),
(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b)) AS test
FROM t1 GROUP BY a;
a MAX(b) test
1 9 m
2 3 h
3 4 i
DROP TABLE t1;

View File

@ -29,7 +29,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 5
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 Using where; Using temporary; Using filesort
Warnings:
Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref`,<in_optimizer>(`test`.`t2`.`a`,<exists>(select max(`test`.`t1`.`ie`) AS `max(ie)` from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having trigcond((<cache>(`test`.`t2`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`)))))) AS `Z` from `test`.`t2`
explain extended
select a, oref from t2
@ -38,7 +38,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 Using where; Using temporary; Using filesort
Warnings:
Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(select max(`test`.`t1`.`ie`) AS `max(ie)` from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having (<cache>(`test`.`t2`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`)))))
select a, oref, a in (
select max(ie) from t1 where oref=t2.oref group by grp union
@ -91,7 +91,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 4
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 Using where; Full scan on NULL key
Warnings:
Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a checking NULL where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))) AS `Z` from `test`.`t2`
flush status;
select oref, a from t2 where a in (select a from t1 where oref=t2.oref);
@ -156,7 +156,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DEPENDENT SUBQUERY t1 ref_or_null a a 5 func 4 Using where; Full scan on NULL key
2 DEPENDENT SUBQUERY t2 ref a a 5 test.t1.b 1 Using where
Warnings:
Note 1276 Field or reference 't3.oref' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<in_optimizer>(`test`.`t3`.`a`,<exists>(select 1 AS `Not_used` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond(((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`)))) having trigcond(<is_not_null_test>(`test`.`t1`.`a`)))) AS `Z` from `test`.`t3`
drop table t1, t2, t3;
create table t1 (a int NOT NULL, b int NOT NULL, key(a));
@ -184,7 +184,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DEPENDENT SUBQUERY t1 ref a a 4 func 2 Using where; Full scan on NULL key
2 DEPENDENT SUBQUERY t2 ref a a 4 test.t1.b 1 Using where
Warnings:
Note 1276 Field or reference 't3.oref' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<in_optimizer>(`test`.`t3`.`a`,<exists>(select 1 AS `Not_used` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`))))) AS `Z` from `test`.`t3`
drop table t1,t2,t3;
create table t1 (oref int, grp int);
@ -240,7 +240,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 Using where; Full scan on NULL key
Warnings:
Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`oref` AS `oref`,<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a checking NULL where ((`test`.`t1`.`c` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`b`) or isnull(`test`.`t1`.`b`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`a`)) and trigcond(<is_not_null_test>(`test`.`t1`.`b`)))))) AS `Z` from `test`.`t2`
select a,b, oref, (a,b) in (select a,b from t1 where c=t2.oref) Z from t2;
a b oref Z
@ -257,7 +257,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DEPENDENT SUBQUERY t1 ref_or_null a a 5 func 2 Using where; Full scan on NULL key
2 DEPENDENT SUBQUERY t4 ALL NULL NULL NULL NULL 100 Using where
Warnings:
Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`oref` AS `oref`,<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t4` where ((`test`.`t1`.`c` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`b`) or isnull(`test`.`t1`.`b`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`a`)) and trigcond(<is_not_null_test>(`test`.`t1`.`b`))))) AS `Z` from `test`.`t2`
select a,b, oref,
(a,b) in (select a,b from t1,t4 where c=t2.oref) Z
@ -302,7 +302,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 8 Using where
2 DEPENDENT SUBQUERY t1 index_subquery idx idx 5 func 4 Using where; Full scan on NULL key
Warnings:
Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on idx checking NULL where ((`test`.`t1`.`oref` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`ie1`) or isnull(`test`.`t1`.`ie1`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`ie2`) or isnull(`test`.`t1`.`ie2`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`ie1`)) and trigcond(<is_not_null_test>(`test`.`t1`.`ie2`)))))) AS `Z` from `test`.`t2` where ((`test`.`t2`.`b` = 10) and (`test`.`t2`.`a` = 10))
drop table t1, t2;
create table t1 (oref char(4), grp int, ie int);
@ -432,7 +432,7 @@ alter table t1 add index idx(oref,ie);
explain select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 7
2 DEPENDENT SUBQUERY t1 ref_or_null idx idx 10 test.t2.oref,func 4 Using where; Using index; Full scan on NULL key
2 DEPENDENT SUBQUERY t1 ref_or_null idx idx 10 t2.oref,func 4 Using where; Using index; Full scan on NULL key
select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2;
oref a Z
ee NULL NULL
@ -457,7 +457,7 @@ group by grp having min(ie) > 1) Z
from t2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 7
2 DEPENDENT SUBQUERY t1 ref idx idx 5 test.t2.oref 2 Using where; Using temporary; Using filesort
2 DEPENDENT SUBQUERY t1 ref idx idx 5 t2.oref 2 Using where; Using temporary; Using filesort
select oref, a,
a in (select min(ie) from t1 where oref=t2.oref
group by grp having min(ie) > 1) Z
@ -572,7 +572,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 7
2 DEPENDENT SUBQUERY t1 index_subquery idx idx 5 func 4 Using where; Full scan on NULL key
Warnings:
Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on idx checking NULL where ((`test`.`t1`.`oref` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`ie1`) or isnull(`test`.`t1`.`ie1`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`ie2`) or isnull(`test`.`t1`.`ie2`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`ie1`)) and trigcond(<is_not_null_test>(`test`.`t1`.`ie2`)))))) AS `Z` from `test`.`t2`
drop table t1,t2;
create table t1 (oref char(4), grp int, ie int primary key);

View File

@ -610,12 +610,12 @@ create table t1 (id integer primary key auto_increment, txt text, index txt_inde
insert into t1 (txt) values ('Chevy'), ('Chevy '), (NULL);
select * from t1 where txt='Chevy' or txt is NULL;
id txt
3 NULL
1 Chevy
2 Chevy
3 NULL
explain select * from t1 where txt='Chevy' or txt is NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range txt_index txt_index 23 NULL 2 Using where
1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 2 Using where
select * from t1 where txt='Chevy ';
id txt
1 Chevy

View File

@ -434,3 +434,22 @@ Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 21
DROP TABLE t1;
CREATE TABLE t1 (
a INT(11),
quux decimal( 31, 30 ),
UNIQUE KEY bar (a),
KEY quux (quux)
);
INSERT INTO
t1 ( a, quux )
VALUES
( 1, 1 ),
( 2, 0.1 );
INSERT INTO t1( a )
SELECT @newA := 1 + a FROM t1 WHERE quux <= 0.1;
SELECT * FROM t1;
a quux
1 1.000000000000000000000000000000
2 0.100000000000000000000000000000
3 NULL
DROP TABLE t1;

View File

@ -6,7 +6,7 @@ select 1;
1
1
select 2;
ERROR HY000: MySQL server has gone away
Got one of the listed errors
select 3;
3
3
@ -14,7 +14,7 @@ select 1;
1
1
select 2;
ERROR HY000: MySQL server has gone away
Got one of the listed errors
select 3;
3
3

Some files were not shown because too many files have changed in this diff Show More