BitKeeper/etc/logging_ok:
  auto-union
configure.in:
  Auto merged
libmysqld/Makefile.am:
  Auto merged
mysql-test/mysql-test-run.sh:
  Auto merged
sql/field.cc:
  Auto merged
sql/field.h:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/ha_ndbcluster.h:
  Auto merged
sql/handler.cc:
  Auto merged
sql/handler.h:
  Auto merged
sql/item.cc:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_delete.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
sql/table.cc:
  Auto merged
sql/unireg.cc:
  Auto merged
storage/innobase/row/row0mysql.c:
  Auto merged
storage/myisam/mi_create.c:
  Auto merged
storage/myisam/mi_dynrec.c:
  Auto merged
storage/myisam/mi_key.c:
  Auto merged
storage/myisam/mi_locking.c:
  Auto merged
storage/myisam/mi_static.c:
  Auto merged
storage/myisam/mi_statrec.c:
  Auto merged
storage/myisam/mi_write.c:
  Auto merged
storage/myisam/myisamdef.h:
  Auto merged
storage/ndb/src/cw/cpcd/APIService.cpp:
  Auto merged
storage/ndb/src/cw/cpcd/APIService.hpp:
  Auto merged
storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp:
  Auto merged
storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp:
  Auto merged
storage/ndb/src/kernel/blocks/dbdict/SchemaFile.hpp:
  Auto merged
storage/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp:
  Auto merged
storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp:
  Auto merged
storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp:
  Auto merged
storage/ndb/test/ndbapi/testNodeRestart.cpp:
  Auto merged
storage/ndb/test/ndbapi/testScan.cpp:
  Auto merged
storage/ndb/test/run-test/main.cpp:
  Auto merged
storage/ndb/test/run-test/run-test.hpp:
  Auto merged
This commit is contained in:
unknown 2005-05-17 10:17:53 +02:00
commit 598df75bc9
155 changed files with 2990 additions and 991 deletions

View File

@ -57,6 +57,7 @@ case "$cpu_family--$model_name" in
;;
*Pentium*M*pro*)
cpu_flag="pentium-m";
cpu_flag_old="pentium";
;;
*Athlon*64*)
cpu_flag="athlon64";

View File

@ -69,6 +69,7 @@ pager:
hours:
[serg:]checkout:get
[arjen:]checkout:get
[kostja:]checkout:get
[nick:]checkout:get
checkout:edit
eoln:unix

View File

@ -58,6 +58,7 @@ evgen@moonbone.local
gbichot@production.mysql.com
gbichot@quadita2.mysql.com
gbichot@quadxeon.mysql.com
geert@kriem.kemuri.org
georg@beethoven.local
georg@beethoven.site
georg@lmy002.wdf.sap.corp
@ -127,6 +128,7 @@ kaa@polly.local
kaj@work.mysql.com
kent@mysql.com
konstantin@mysql.com
kosipov@production.mysql.com
kostja@oak.local
lars@mysql.com
lenz@kallisto.mysql.com

View File

@ -49,5 +49,5 @@ enum options_client
#ifdef HAVE_NDBCLUSTER_DB
OPT_NDBCLUSTER, OPT_NDB_CONNECTSTRING,
#endif
OPT_IGNORE_TABLE,OPT_INSERT_IGNORE
OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS
};

View File

@ -135,7 +135,8 @@ static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0,
opt_xml=0,opt_nopager=1, opt_outfile=0, named_cmds= 0,
tty_password= 0, opt_nobeep=0, opt_reconnect=1,
default_charset_used= 0, opt_secure_auth= 0,
default_pager_set= 0, opt_sigint_ignore= 0;
default_pager_set= 0, opt_sigint_ignore= 0,
show_warnings = 0;
static ulong opt_max_allowed_packet, opt_net_buffer_length;
static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0;
static my_string opt_mysql_unix_port=0;
@ -194,7 +195,8 @@ static int com_quit(String *str,char*),
com_use(String *str,char*), com_source(String *str, char*),
com_rehash(String *str, char*), com_tee(String *str, char*),
com_notee(String *str, char*),
com_prompt(String *str, char*), com_delimiter(String *str, char*);
com_prompt(String *str, char*), com_delimiter(String *str, char*),
com_warnings(String *str, char*), com_nowarnings(String *str, char*);
#ifdef USE_POPEN
static int com_nopager(String *str, char*), com_pager(String *str, char*),
@ -266,6 +268,10 @@ static COMMANDS commands[] = {
"Set outfile [to_outfile]. Append everything into given outfile." },
{ "use", 'u', com_use, 1,
"Use another database. Takes database name as argument." },
{ "warnings", 'W', com_warnings, 0,
"Show warnings after every statement." },
{ "nowarning", 'w', com_nowarnings, 0,
"Don't show warnings after every statement." },
/* Get bash-like expansion for some commands */
{ "create table", 0, 0, 0, ""},
{ "create database", 0, 0, 0, ""},
@ -323,6 +329,7 @@ static void print_table_data_html(MYSQL_RES *result);
static void print_table_data_xml(MYSQL_RES *result);
static void print_tab_data(MYSQL_RES *result);
static void print_table_data_vertically(MYSQL_RES *result);
static void print_warnings(void);
static ulong start_timer(void);
static void end_timer(ulong start_time,char *buff);
static void mysql_end_timer(ulong start_time,char *buff);
@ -693,6 +700,9 @@ static struct my_option my_long_options[] =
{"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
" uses old (pre-4.1.1) protocol", (gptr*) &opt_secure_auth,
(gptr*) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"show-warnings", OPT_SHOW_WARNINGS, "Show warnings after every statement.",
(gptr*) &show_warnings, (gptr*) &show_warnings, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@ -1962,6 +1972,13 @@ com_go(String *buffer,char *line __attribute__((unused)))
if (err >= 1)
error= put_error(&mysql);
if (show_warnings == 1 && warnings >= 1) /* Show warnings if any */
{
init_pager();
print_warnings();
end_pager();
}
if (!error && !status.batch &&
(mysql.server_status & SERVER_STATUS_DB_DROPPED))
get_current_db();
@ -2077,7 +2094,8 @@ print_table_data(MYSQL_RES *result)
separator.fill(separator.length()+length+2,'-');
separator.append('+');
}
tee_puts(separator.c_ptr_safe(), PAGER);
separator.append('\0'); // End marker for \0
tee_puts((char*) separator.ptr(), PAGER);
if (column_names)
{
mysql_field_seek(result,0);
@ -2090,7 +2108,7 @@ print_table_data(MYSQL_RES *result)
num_flag[off]= IS_NUM(field->type);
}
(void) tee_fputs("\n", PAGER);
tee_puts(separator.c_ptr(), PAGER);
tee_puts((char*) separator.ptr(), PAGER);
}
while ((cur= mysql_fetch_row(result)))
@ -2119,7 +2137,7 @@ print_table_data(MYSQL_RES *result)
}
(void) tee_fputs("\n", PAGER);
}
tee_puts(separator.c_ptr(), PAGER);
tee_puts((char*) separator.ptr(), PAGER);
my_afree((gptr) num_flag);
}
@ -2219,6 +2237,35 @@ print_table_data_vertically(MYSQL_RES *result)
}
}
/* print_warnings should be called right after executing a statement */
static void
print_warnings()
{
char query[30];
MYSQL_RES *result;
MYSQL_ROW cur;
MYSQL_FIELD *field;
/* Get the warnings */
strmov(query,"show warnings");
mysql_real_query_for_lazy(query,strlen(query));
mysql_store_result_for_lazy(&result);
/* Bail out when no warnings */
my_ulonglong num_rows = mysql_num_rows(result);
if (num_rows == 0)
{
mysql_free_result(result);
return;
}
/* Print the warnings */
while ((cur= mysql_fetch_row(result)))
{
tee_fprintf(PAGER, "%s (Code %s): %s\n", cur[0], cur[1], cur[2]);
}
mysql_free_result(result);
}
static const char
*array_value(const char **array, char key)
@ -2715,6 +2762,23 @@ com_use(String *buffer __attribute__((unused)), char *line)
return 0;
}
static int
com_warnings(String *buffer __attribute__((unused)),
char *line __attribute__((unused)))
{
show_warnings = 1;
put_info("Show warnings enabled.",INFO_INFO);
return 0;
}
static int
com_nowarnings(String *buffer __attribute__((unused)),
char *line __attribute__((unused)))
{
show_warnings = 0;
put_info("Show warnings disabled.",INFO_INFO);
return 0;
}
/*
Gets argument from a command on the command line. If get_next_arg is

View File

@ -593,7 +593,7 @@ static void abort_not_supported_test()
printf("skipped\n");
free_used_memory();
my_end(MY_CHECK_ERROR);
exit(2);
exit(62);
}
static void verbose_msg(const char* fmt, ...)
@ -2729,6 +2729,8 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags)
if (!disable_result_log)
{
ulong affected_rows; /* Ok to be undef if 'disable_info' is set */
if (res)
{
MYSQL_FIELD *field= mysql_fetch_fields(res);
@ -2750,6 +2752,13 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags)
append_result(ds, res);
}
/*
Need to call mysql_affected_rows() before the new
query to find the warnings
*/
if (!disable_info)
affected_rows= (ulong)mysql_affected_rows(mysql);
/*
Add all warnings to the result. We can't do this if we are in
the middle of processing results from multi-statement, because
@ -2777,7 +2786,7 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags)
if (!disable_info)
{
char buf[40];
sprintf(buf,"affected rows: %lu\n",(ulong) mysql_affected_rows(mysql));
sprintf(buf,"affected rows: %lu\n", affected_rows);
dynstr_append(ds, buf);
if (mysql_info(mysql))
{

View File

@ -73,7 +73,7 @@ typedef KEYMAP_ENTRY *Keymap;
#ifndef CTRL
#include <sys/ioctl.h>
#ifdef __GLIBC__
#if defined(__GLIBC__) || defined(__MWERKS__)
#include <sys/ttydefaults.h>
#endif
#ifndef CTRL

View File

@ -1014,7 +1014,7 @@ vi_histedit(EditLine *el, int c)
return CC_ERROR;
case 0:
close(fd);
execlp("vi", "vi", tempfile, 0);
execlp("vi", "vi", tempfile, (char *) NULL);
exit(0);
/*NOTREACHED*/
default:

View File

@ -141,8 +141,11 @@ AC_ARG_WITH(darwin-mwcc,
export CC CXX LD AR RANLIB
AC_SUBST(AR)
AC_SUBST(RANLIB)
with_darwin_mwcc=yes
])
AM_CONDITIONAL(DARWIN_MWCC, test x$with_darwin_mwcc = xyes)
if test "x${CFLAGS-}" = x ; then
cflags_is_set=no
else
@ -1371,20 +1374,20 @@ then
AC_MSG_CHECKING("for gcc")
if expr "$CC" : ".*gcc.*"
then
CC="$CC -pthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK";
CXX="$CXX -pthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK";
CC="$CC -pthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK"
CXX="$CXX -pthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK"
else
CC="$CC -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK";
CXX="$CXX -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK";
CC="$CC -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK"
CXX="$CXX -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK"
fi
else
{ AC_MSG_ERROR([configure: error: Can't find thread libs on SCO UnixWare7. See the Installation chapter in the Reference Manual.]) };
AC_MSG_ERROR([configure: error: Can't find thread libs on SCO UnixWare7. See the Installation chapter in the Reference Manual.])
fi
else
AC_MSG_RESULT("no")
fi
else
AC_MSG_ERROR([On SCO UNIX MySQL requires that the FSUThreads package is installed. See the Installation chapter in the Reference Manual.]);
AC_MSG_ERROR([On SCO UNIX MySQL requires that the FSUThreads package is installed. See the Installation chapter in the Reference Manual.])
fi
else
AC_MSG_RESULT("no")
@ -1416,15 +1419,15 @@ then
AC_MSG_CHECKING("for gcc")
if expr "$CC" : ".*gcc.*"
then
CC="$CC -pthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK";
CXX="$CXX -pthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK";
CC="$CC -pthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK"
CXX="$CXX -pthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK"
else
CC="$CC -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK";
CXX="$CXX -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK";
CC="$CC -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK"
CXX="$CXX -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK"
fi
AC_MSG_RESULT("yes")
else
{ AC_MSG_ERROR([configure: error: Can't find thread libs on SCO UnixWare7. See the Installation chapter in the Reference Manual.]) };
AC_MSG_ERROR([configure: error: Can't find thread libs on SCO UnixWare7. See the Installation chapter in the Reference Manual.])
fi
else
AC_MSG_RESULT("no")
@ -1459,15 +1462,15 @@ then
AC_MSG_CHECKING("for gcc")
if expr "$CC" : ".*gcc.*"
then
CC="$CC -pthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK";
CXX="$CXX -pthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK";
CC="$CC -pthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK"
CXX="$CXX -pthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK"
else
CC="$CC -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK";
CXX="$CXX -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK";
CC="$CC -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK"
CXX="$CXX -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK"
fi
AC_MSG_RESULT("yes")
else
{ AC_MSG_ERROR([configure: error: Can't find thread libs on Caldera OpenUNIX 8. See the Installation chapter in the Reference Manual.]) };
AC_MSG_ERROR([configure: error: Can't find thread libs on Caldera OpenUNIX 8. See the Installation chapter in the Reference Manual.])
fi
else
AC_MSG_RESULT("no")

View File

@ -95,6 +95,7 @@ extern const char *client_errors[]; /* Error messages */
#define CR_FETCH_CANCELED 2050
#define CR_NO_DATA 2051
#define CR_NO_STMT_METADATA 2052
#define CR_ERROR_LAST /*Copy last error nr:*/ 2052
#define CR_NO_RESULT_SET 2053
#define CR_ERROR_LAST /*Copy last error nr:*/ 2053
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */

View File

@ -778,6 +778,11 @@ extern void reset_root_defaults(MEM_ROOT *mem_root, uint block_size,
extern char *strdup_root(MEM_ROOT *root,const char *str);
extern char *strmake_root(MEM_ROOT *root,const char *str,uint len);
extern char *memdup_root(MEM_ROOT *root,const char *str,uint len);
extern int my_correct_defaults_file(const char *file_location,
const char *option,
const char *option_value,
const char *section_name,
int remove_option);
extern void get_defaults_files(int argc, char **argv,
char **defaults, char **extra_defaults);
extern int load_defaults(const char *conf_file, const char **groups,

View File

@ -190,10 +190,10 @@ typedef struct st_columndef /* column information */
typedef void (* invalidator_by_filename)(const char * filename);
extern my_string myisam_log_filename; /* Name of logfile */
extern uint myisam_block_size;
extern ulong myisam_block_size;
extern ulong myisam_concurrent_insert;
extern my_bool myisam_flush,myisam_delay_key_write,myisam_single_user;
extern my_bool myisam_concurrent_insert;
extern my_off_t myisam_max_temp_length,myisam_max_extra_temp_length;
extern my_off_t myisam_max_temp_length;
extern ulong myisam_bulk_insert_tree_size, myisam_data_pointer_size;
/* Prototypes for myisam-functions */

View File

@ -384,6 +384,7 @@ unsigned int STDCALL mysql_warning_count(MYSQL *mysql);
const char * STDCALL mysql_info(MYSQL *mysql);
unsigned long STDCALL mysql_thread_id(MYSQL *mysql);
const char * STDCALL mysql_character_set_name(MYSQL *mysql);
int STDCALL mysql_set_character_set(MYSQL *mysql, char *csname);
MYSQL * STDCALL mysql_init(MYSQL *mysql);
my_bool STDCALL mysql_ssl_set(MYSQL *mysql, const char *key,

View File

@ -88,10 +88,10 @@ typedef struct st_thr_lock {
struct st_lock_list read;
struct st_lock_list write_wait;
struct st_lock_list write;
/* write_lock_count is incremented for write locks and reset on read locks */
/* write_lock_count is incremented for write locks and reset on read locks */
ulong write_lock_count;
uint read_no_write_count;
void (*get_status)(void*); /* When one gets a lock */
void (*get_status)(void*, int); /* When one gets a lock */
void (*copy_status)(void*,void*);
void (*update_status)(void*); /* Before release of write */
my_bool (*check_status)(void *);

View File

@ -67,7 +67,7 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
mf_iocache2.lo my_seek.lo my_sleep.lo \
my_pread.lo mf_cache.lo md5.lo sha1.lo \
my_getopt.lo my_gethostbyname.lo my_port.lo \
my_rename.lo
my_rename.lo my_chsize.lo
sqlobjects = net.lo
sql_cmn_objects = pack.lo client.lo my_time.lo

View File

@ -80,6 +80,7 @@ const char *client_errors[]=
"Row retrieval was canceled by mysql_stmt_close() call",
"Attempt to read column without prior row fetch",
"Prepared statement contains no metadata",
"Attempt to read a row while there is no result set associated with the statement",
""
};
@ -141,6 +142,7 @@ const char *client_errors[]=
"Row retrieval was canceled by mysql_stmt_close() call",
"Attempt to read column without prior row fetch",
"Prepared statement contains no metadata",
"Attempt to read a row while there is no result set associated with the statement",
""
};
@ -200,6 +202,7 @@ const char *client_errors[]=
"Row retrieval was canceled by mysql_stmt_close() call",
"Attempt to read column without prior row fetch",
"Prepared statement contains no metadata",
"Attempt to read a row while there is no result set associated with the statement",
""
};
#endif

View File

@ -1496,6 +1496,39 @@ const char * STDCALL mysql_character_set_name(MYSQL *mysql)
}
int STDCALL mysql_set_character_set(MYSQL *mysql, char *cs_name)
{
struct charset_info_st *cs;
const char *save_csdir= charsets_dir;
if (mysql->options.charset_dir)
charsets_dir= mysql->options.charset_dir;
if ((cs= get_charset_by_csname(cs_name, MY_CS_PRIMARY, MYF(0))))
{
char buff[MY_CS_NAME_SIZE + 10];
charsets_dir= save_csdir;
sprintf(buff, "SET NAMES %s", cs_name);
if (!mysql_query(mysql, buff))
{
mysql->charset= cs;
}
}
else
{
char cs_dir_name[FN_REFLEN];
get_charsets_dir(cs_dir_name);
mysql->net.last_errno= CR_CANT_READ_CHARSET;
strmov(mysql->net.sqlstate, unknown_sqlstate);
my_snprintf(mysql->net.last_error, sizeof(mysql->net.last_error) - 1,
ER(mysql->net.last_errno), cs_name, cs_dir_name);
}
charsets_dir= save_csdir;
return mysql->net.last_errno;
}
uint STDCALL mysql_thread_safe(void)
{
#ifdef THREAD
@ -1724,6 +1757,13 @@ static int stmt_read_row_no_data(MYSQL_STMT *stmt, unsigned char **row);
static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data);
static my_bool setup_one_fetch_function(MYSQL_BIND *bind, MYSQL_FIELD *field);
/* Auxilary function used to reset statement handle. */
#define RESET_SERVER_SIDE 1
#define RESET_LONG_DATA 2
static my_bool reset_stmt_handle(MYSQL_STMT *stmt, uint flags);
/*
Maximum sizes of MYSQL_TYPE_DATE, MYSQL_TYPE_TIME, MYSQL_TYPE_DATETIME
values stored in network buffer.
@ -2019,7 +2059,8 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length)
/* This is second prepare with another statement */
char buff[MYSQL_STMT_HEADER]; /* 4 bytes - stmt id */
mysql_stmt_free_result(stmt);
if (reset_stmt_handle(stmt, RESET_LONG_DATA))
DBUG_RETURN(1);
/*
These members must be reset for API to
function in case of error or misuse.
@ -2702,12 +2743,8 @@ static int
stmt_read_row_no_data(MYSQL_STMT *stmt __attribute__((unused)),
unsigned char **row __attribute__((unused)))
{
if ((int) stmt->state < (int) MYSQL_STMT_PREPARE_DONE)
{
set_stmt_error(stmt, CR_NO_PREPARE_STMT, unknown_sqlstate);
return 1;
}
return MYSQL_NO_DATA;
set_stmt_error(stmt, CR_NO_RESULT_SET, unknown_sqlstate);
return 1;
}
@ -2817,7 +2854,8 @@ int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt)
DBUG_RETURN(1);
}
mysql_stmt_free_result(stmt);
if (reset_stmt_handle(stmt, 0))
DBUG_RETURN(1);
/*
No need to check for stmt->state: if the statement wasn't
prepared we'll get 'unknown statement handler' error from server.
@ -4370,9 +4408,12 @@ my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
/*
We only need to check that stmt->field_count - if it is not null
stmt->bind was initialized in mysql_stmt_prepare
*/
stmt->bind overlaps with bind if mysql_stmt_bind_param
is called from mysql_stmt_store_result.
*/
memcpy((char*) stmt->bind, (char*) bind, sizeof(MYSQL_BIND) * bind_count);
if (stmt->bind != bind)
memcpy((char*) stmt->bind, (char*) bind, sizeof(MYSQL_BIND) * bind_count);
for (param= stmt->bind, end= param + bind_count, field= stmt->fields ;
param < end ;
@ -4805,16 +4846,21 @@ my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt)
DBUG_RETURN(stmt->result.rows);
}
my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt)
/*
Free the client side memory buffers, reset long data state
on client if necessary, and reset the server side statement if
this has been requested.
*/
static my_bool reset_stmt_handle(MYSQL_STMT *stmt, uint flags)
{
MYSQL_DATA *result= &stmt->result;
DBUG_ENTER("mysql_stmt_free_result");
DBUG_ASSERT(stmt != 0);
/* If statement hasn't been prepared there is nothing to reset */
if ((int) stmt->state > (int) MYSQL_STMT_INIT_DONE)
{
MYSQL *mysql= stmt->mysql;
MYSQL_DATA *result= &stmt->result;
my_bool has_cursor= stmt->read_row_func == stmt_read_row_from_cursor;
if (result->data)
{
@ -4824,23 +4870,58 @@ my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt)
result->rows= 0;
stmt->data_cursor= NULL;
}
if (mysql && stmt->field_count &&
(int) stmt->state > (int) MYSQL_STMT_PREPARE_DONE)
if (flags & RESET_LONG_DATA)
{
if (mysql->unbuffered_fetch_owner == &stmt->unbuffered_fetch_cancelled)
mysql->unbuffered_fetch_owner= 0;
if (mysql->status != MYSQL_STATUS_READY)
MYSQL_BIND *param= stmt->params, *param_end= param + stmt->param_count;
/* Clear long_data_used flags */
for (; param < param_end; param++)
param->long_data_used= 0;
}
stmt->read_row_func= stmt_read_row_no_data;
if (mysql)
{
if ((int) stmt->state > (int) MYSQL_STMT_PREPARE_DONE)
{
/* There is a result set and it belongs to this statement */
(*mysql->methods->flush_use_result)(mysql);
mysql->status= MYSQL_STATUS_READY;
if (mysql->unbuffered_fetch_owner == &stmt->unbuffered_fetch_cancelled)
mysql->unbuffered_fetch_owner= 0;
if (stmt->field_count && mysql->status != MYSQL_STATUS_READY)
{
/* There is a result set and it belongs to this statement */
(*mysql->methods->flush_use_result)(mysql);
if (mysql->unbuffered_fetch_owner)
*mysql->unbuffered_fetch_owner= TRUE;
mysql->status= MYSQL_STATUS_READY;
}
}
if (has_cursor || (flags & RESET_SERVER_SIDE))
{
/*
Reset the server side statement and close the server side
cursor if it exists.
*/
char buff[MYSQL_STMT_HEADER]; /* packet header: 4 bytes for stmt id */
int4store(buff, stmt->stmt_id);
if ((*mysql->methods->advanced_command)(mysql, COM_RESET_STMT, buff,
sizeof(buff), 0, 0, 0))
{
set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno,
mysql->net.sqlstate);
stmt->state= MYSQL_STMT_INIT_DONE;
return 1;
}
}
}
stmt->state= MYSQL_STMT_PREPARE_DONE;
stmt->read_row_func= stmt_read_row_no_data;
}
DBUG_RETURN(0);
return 0;
}
my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt)
{
DBUG_ENTER("mysql_stmt_free_result");
/* Free the client side and close the server side cursor if there is one */
DBUG_RETURN(reset_stmt_handle(stmt, RESET_LONG_DATA));
}
/********************************************************************
@ -4913,33 +4994,10 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
my_bool STDCALL mysql_stmt_reset(MYSQL_STMT *stmt)
{
char buff[MYSQL_STMT_HEADER]; /* packet header: 4 bytes for stmt id */
MYSQL *mysql;
MYSQL_BIND *param, *param_end;
DBUG_ENTER("mysql_stmt_reset");
DBUG_ASSERT(stmt != 0);
/* If statement hasnt been prepared there is nothing to reset */
if ((int) stmt->state < (int) MYSQL_STMT_PREPARE_DONE)
DBUG_RETURN(0);
mysql= stmt->mysql->last_used_con;
int4store(buff, stmt->stmt_id); /* Send stmt id to server */
if ((*mysql->methods->advanced_command)(mysql, COM_RESET_STMT, buff,
sizeof(buff), 0, 0, 0))
{
set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno,
mysql->net.sqlstate);
DBUG_RETURN(1);
}
/* Clear long_data_used for next call (as we do in mysql_stmt_execute() */
for (param= stmt->params, param_end= param + stmt->param_count;
param < param_end;
param++)
param->long_data_used= 0;
DBUG_RETURN(0);
/* Reset the client and server sides of the prepared statement */
DBUG_RETURN(reset_stmt_handle(stmt, RESET_SERVER_SIDE | RESET_LONG_DATA));
}
/*

View File

@ -148,6 +148,7 @@ EXPORTS
mysql_embedded
mysql_server_init
mysql_server_end
mysql_set_character_set
get_defaults_files
get_charset_by_csname
get_charsets_dir

View File

@ -87,6 +87,9 @@ INC_LIB= $(top_builddir)/regex/libregex.a \
# generate a total libmysqld.a from all library files,
libmysqld.a: libmysqld_int.a $(INC_LIB)
if DARWIN_MWCC
mwld -lib -o $@ libmysqld_int.a `ls -1 $(INC_LIB) | sort -u`
else
if test "$(host_os)" = "netware" ; \
then \
$(libmysqld_a_AR) libmysqld.a libmysqld_int.a $(INC_LIB) ; \
@ -108,7 +111,7 @@ libmysqld.a: libmysqld_int.a $(INC_LIB)
rm -f tmp/* ; \
$(RANLIB) libmysqld.a ; \
fi
endif
## XXX: any time the client interface changes, we'll need to bump
## the version info for libmysqld; however, it's possible for the

View File

@ -218,7 +218,8 @@ or
), mysqldump will create rows up to net_buffer_length length. If you increase this variable, you should also ensure that the max_allowed_packet variable in the MySQL server is bigger than the net_buffer_length.
.SH EXAMPLES
.TP
The most normal use of mysqldump is probably for making a backup of whole databases. See Mysql Manual section 21.2 Database Backups.
The most normal use of mysqldump is probably for making a backup of whole
databases. See the section on Database Backups in the MySQL Reference Manual.
.TP
mysqldump \-\-opt \fP\fIdatabase\fP > backup-file.sql
.TP

View File

@ -0,0 +1,5 @@
-- require r/have_outfile.require
disable_query_log;
select load_file(concat(@tmpdir,"/outfile.test"));
--exec rm $MYSQL_TEST_DIR/var/tmp/outfile.test
enable_query_log;

View File

@ -0,0 +1 @@
eval select "Outfile OK" into outfile "$MYSQL_TEST_DIR/var/tmp/outfile.test";

View File

@ -1,4 +1,5 @@
USE mysql;
use mysql;
set table_type=myisam;
CREATE TABLE db (
Host char(60) binary DEFAULT '' NOT NULL,
@ -206,7 +207,7 @@ INSERT INTO time_zone_name (Name, Time_Zone_id) VALUES
CREATE TABLE time_zone (
Time_zone_id int unsigned NOT NULL auto_increment,
Use_leap_seconds enum('Y','N') DEFAULT 'N' NOT NULL,
Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
PRIMARY KEY TzId (Time_zone_id)
) engine=MyISAM
CHARACTER SET utf8

View File

@ -344,7 +344,7 @@ sub mtr_kill_leftovers () {
# We scan the "var/run/" directory for other process id's to kill
# FIXME $path_run_dir or something
my $rundir= "$::glob_mysql_test_dir/var/run";
my $rundir= "$::opt_vardir/run";
if ( -d $rundir )
{

View File

@ -89,9 +89,10 @@ sub mtr_report_test_passed ($) {
my $tinfo= shift;
my $timer= "";
if ( $::opt_timer and -f "$::glob_mysql_test_dir/var/log/timer" )
if ( $::opt_timer and -f "$::opt_vardir/log/timer" )
{
$timer= mtr_fromfile("$::glob_mysql_test_dir/var/log/timer");
$timer= mtr_fromfile("$::opt_vardir/log/timer");
$::glob_tot_real_time += $timer;
$timer= sprintf "%12s", $timer;
}
$tinfo->{'result'}= 'MTR_RES_PASSED';
@ -177,8 +178,8 @@ sub mtr_report_stats ($) {
# Report if there was any fatal warnings/errors in the log files
#
unlink("$::glob_mysql_test_dir/var/log/warnings");
unlink("$::glob_mysql_test_dir/var/log/warnings.tmp");
unlink("$::opt_vardir/log/warnings");
unlink("$::opt_vardir/log/warnings.tmp");
# Remove some non fatal warnings from the log files
# FIXME what is going on ????? ;-)
@ -196,11 +197,11 @@ sub mtr_report_stats ($) {
# found_error=1
# }
# done
# unlink("$::glob_mysql_test_dir/var/log/warnings.tmp");
# unlink("$::opt_vardir/log/warnings.tmp");
# if ( $found_error= "1" )
# {
# print "WARNING: Got errors/warnings while running tests. Please examine\n"
# print "$::glob_mysql_test_dir/var/log/warnings for details.\n"
# print "$::opt_vardir/log/warnings for details.\n"
# }
# }
}

View File

@ -84,7 +84,7 @@ use Sys::Hostname;
#use Carp;
use IO::Socket;
use IO::Socket::INET;
#use Data::Dumper;
use Data::Dumper;
use strict;
#use diagnostics;
@ -177,6 +177,7 @@ our $path_timefile;
our $path_manager_log; # Used by mysqldadmin
our $path_slave_load_tmpdir; # What is this?!
our $path_my_basedir;
our $opt_vardir; # A path but set directly on cmd line
our $opt_tmpdir; # A path but set directly on cmd line
our $opt_usage;
@ -447,8 +448,6 @@ sub initial_setup () {
$glob_basedir= dirname($glob_mysql_test_dir);
$glob_mysql_bench_dir= "$glob_basedir/mysql-bench"; # FIXME make configurable
$path_timefile= "$glob_mysql_test_dir/var/log/mysqltest-time";
# needs to be same length to test logging (FIXME what???)
$path_slave_load_tmpdir= "../../var/tmp";
@ -469,11 +468,6 @@ sub command_line_setup () {
# These are defaults for things that are set on the command line
$opt_suite= "main"; # Special default suite
$opt_tmpdir= "$glob_mysql_test_dir/var/tmp";
# FIXME maybe unneded?
$path_manager_log= "$glob_mysql_test_dir/var/log/manager.log";
$opt_current_test= "$glob_mysql_test_dir/var/log/current_test";
my $opt_master_myport= 9306;
my $opt_slave_myport= 9308;
$opt_ndbcluster_port= 9350;
@ -549,6 +543,7 @@ sub command_line_setup () {
'unified-diff|udiff' => \$opt_udiff,
'user-test=s' => \$opt_user_test,
'user=s' => \$opt_user,
'vardir=s' => \$opt_vardir,
'verbose' => \$opt_verbose,
'wait-timeout=i' => \$opt_wait_timeout,
'warnings|log-warnings' => \$opt_warnings,
@ -564,51 +559,35 @@ sub command_line_setup () {
@opt_cases= @ARGV;
# Put this into a hash, will be a C struct
# --------------------------------------------------------------------------
# Set the "var/" directory, as it is the base for everything else
# --------------------------------------------------------------------------
$master->[0]->{'path_myddir'}= "$glob_mysql_test_dir/var/master-data";
$master->[0]->{'path_myerr'}= "$glob_mysql_test_dir/var/log/master.err";
$master->[0]->{'path_mylog'}= "$glob_mysql_test_dir/var/log/master.log";
$master->[0]->{'path_mypid'}= "$glob_mysql_test_dir/var/run/master.pid";
$master->[0]->{'path_mysock'}= "$opt_tmpdir/master.sock";
$master->[0]->{'path_myport'}= $opt_master_myport;
$master->[0]->{'start_timeout'}= 400; # enough time create innodb tables
if ( ! $opt_vardir )
{
$opt_vardir= "$glob_mysql_test_dir/var";
}
$master->[0]->{'ndbcluster'}= 1; # ndbcluster not started
if ( $opt_vardir !~ m,^/, )
{
# Make absolute path, relative test dir
$opt_vardir= "$glob_mysql_test_dir/$opt_vardir";
}
$master->[1]->{'path_myddir'}= "$glob_mysql_test_dir/var/master1-data";
$master->[1]->{'path_myerr'}= "$glob_mysql_test_dir/var/log/master1.err";
$master->[1]->{'path_mylog'}= "$glob_mysql_test_dir/var/log/master1.log";
$master->[1]->{'path_mypid'}= "$glob_mysql_test_dir/var/run/master1.pid";
$master->[1]->{'path_mysock'}= "$opt_tmpdir/master1.sock";
$master->[1]->{'path_myport'}= $opt_master_myport + 1;
$master->[1]->{'start_timeout'}= 400; # enough time create innodb tables
# --------------------------------------------------------------------------
# If not set, set these to defaults
# --------------------------------------------------------------------------
$slave->[0]->{'path_myddir'}= "$glob_mysql_test_dir/var/slave-data";
$slave->[0]->{'path_myerr'}= "$glob_mysql_test_dir/var/log/slave.err";
$slave->[0]->{'path_mylog'}= "$glob_mysql_test_dir/var/log/slave.log";
$slave->[0]->{'path_mypid'}= "$glob_mysql_test_dir/var/run/slave.pid";
$slave->[0]->{'path_mysock'}= "$opt_tmpdir/slave.sock";
$slave->[0]->{'path_myport'}= $opt_slave_myport;
$slave->[0]->{'start_timeout'}= 400;
$slave->[1]->{'path_myddir'}= "$glob_mysql_test_dir/var/slave1-data";
$slave->[1]->{'path_myerr'}= "$glob_mysql_test_dir/var/log/slave1.err";
$slave->[1]->{'path_mylog'}= "$glob_mysql_test_dir/var/log/slave1.log";
$slave->[1]->{'path_mypid'}= "$glob_mysql_test_dir/var/run/slave1.pid";
$slave->[1]->{'path_mysock'}= "$opt_tmpdir/slave1.sock";
$slave->[1]->{'path_myport'}= $opt_slave_myport + 1;
$slave->[1]->{'start_timeout'}= 300;
$slave->[2]->{'path_myddir'}= "$glob_mysql_test_dir/var/slave2-data";
$slave->[2]->{'path_myerr'}= "$glob_mysql_test_dir/var/log/slave2.err";
$slave->[2]->{'path_mylog'}= "$glob_mysql_test_dir/var/log/slave2.log";
$slave->[2]->{'path_mypid'}= "$glob_mysql_test_dir/var/run/slave2.pid";
$slave->[2]->{'path_mysock'}= "$opt_tmpdir/slave2.sock";
$slave->[2]->{'path_myport'}= $opt_slave_myport + 2;
$slave->[2]->{'start_timeout'}= 300;
$opt_tmpdir= "$opt_vardir/tmp" unless $opt_tmpdir;
# FIXME maybe not needed?
$path_manager_log= "$opt_vardir/log/manager.log"
unless $path_manager_log;
$opt_current_test= "$opt_vardir/log/current_test"
unless $opt_current_test;
# --------------------------------------------------------------------------
# Do sanity checks of command line arguments
# --------------------------------------------------------------------------
if ( $opt_extern and $opt_local )
{
@ -621,13 +600,6 @@ sub command_line_setup () {
$opt_socket= "/tmp/mysql.sock"; # FIXME
}
if ( $opt_extern )
{
$glob_use_running_server= 1;
$opt_skip_rpl= 1; # We don't run rpl test cases
$master->[0]->{'path_mysock'}= $opt_socket;
}
# --------------------------------------------------------------------------
# Look at the command line options and set script flags
# --------------------------------------------------------------------------
@ -746,6 +718,58 @@ sub command_line_setup () {
}
}
# Put this into a hash, will be a C struct
$master->[0]->{'path_myddir'}= "$opt_vardir/master-data";
$master->[0]->{'path_myerr'}= "$opt_vardir/log/master.err";
$master->[0]->{'path_mylog'}= "$opt_vardir/log/master.log";
$master->[0]->{'path_mypid'}= "$opt_vardir/run/master.pid";
$master->[0]->{'path_mysock'}= "$opt_tmpdir/master.sock";
$master->[0]->{'path_myport'}= $opt_master_myport;
$master->[0]->{'start_timeout'}= 400; # enough time create innodb tables
$master->[0]->{'ndbcluster'}= 1; # ndbcluster not started
$master->[1]->{'path_myddir'}= "$opt_vardir/master1-data";
$master->[1]->{'path_myerr'}= "$opt_vardir/log/master1.err";
$master->[1]->{'path_mylog'}= "$opt_vardir/log/master1.log";
$master->[1]->{'path_mypid'}= "$opt_vardir/run/master1.pid";
$master->[1]->{'path_mysock'}= "$opt_tmpdir/master1.sock";
$master->[1]->{'path_myport'}= $opt_master_myport + 1;
$master->[1]->{'start_timeout'}= 400; # enough time create innodb tables
$slave->[0]->{'path_myddir'}= "$opt_vardir/slave-data";
$slave->[0]->{'path_myerr'}= "$opt_vardir/log/slave.err";
$slave->[0]->{'path_mylog'}= "$opt_vardir/log/slave.log";
$slave->[0]->{'path_mypid'}= "$opt_vardir/run/slave.pid";
$slave->[0]->{'path_mysock'}= "$opt_tmpdir/slave.sock";
$slave->[0]->{'path_myport'}= $opt_slave_myport;
$slave->[0]->{'start_timeout'}= 400;
$slave->[1]->{'path_myddir'}= "$opt_vardir/slave1-data";
$slave->[1]->{'path_myerr'}= "$opt_vardir/log/slave1.err";
$slave->[1]->{'path_mylog'}= "$opt_vardir/log/slave1.log";
$slave->[1]->{'path_mypid'}= "$opt_vardir/run/slave1.pid";
$slave->[1]->{'path_mysock'}= "$opt_tmpdir/slave1.sock";
$slave->[1]->{'path_myport'}= $opt_slave_myport + 1;
$slave->[1]->{'start_timeout'}= 300;
$slave->[2]->{'path_myddir'}= "$opt_vardir/slave2-data";
$slave->[2]->{'path_myerr'}= "$opt_vardir/log/slave2.err";
$slave->[2]->{'path_mylog'}= "$opt_vardir/log/slave2.log";
$slave->[2]->{'path_mypid'}= "$opt_vardir/run/slave2.pid";
$slave->[2]->{'path_mysock'}= "$opt_tmpdir/slave2.sock";
$slave->[2]->{'path_myport'}= $opt_slave_myport + 2;
$slave->[2]->{'start_timeout'}= 300;
if ( $opt_extern )
{
$glob_use_running_server= 1;
$opt_skip_rpl= 1; # We don't run rpl test cases
$master->[0]->{'path_mysock'}= $opt_socket;
}
$path_timefile= "$opt_vardir/log/mysqltest-time";
}
@ -892,8 +916,8 @@ sub executable_setup () {
}
$path_ndb_backup_dir=
"$glob_mysql_test_dir/var/ndbcluster-$opt_ndbcluster_port";
$file_ndb_testrun_log= "$glob_mysql_test_dir/var/log/ndb_testrun.log";
"$opt_vardir/ndbcluster-$opt_ndbcluster_port";
$file_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log";
}
@ -981,7 +1005,7 @@ sub kill_running_server () {
# leftovers from previous runs.
mtr_report("Killing Possible Leftover Processes");
mkpath("$glob_mysql_test_dir/var/log"); # Needed for mysqladmin log
mkpath("$opt_vardir/log"); # Needed for mysqladmin log
mtr_kill_leftovers();
ndbcluster_stop();
@ -995,15 +1019,20 @@ sub kill_and_cleanup () {
mtr_report("Removing Stale Files");
rmtree("$glob_mysql_test_dir/var/log");
rmtree("$glob_mysql_test_dir/var/ndbcluster-$opt_ndbcluster_port");
rmtree("$glob_mysql_test_dir/var/run");
rmtree("$glob_mysql_test_dir/var/tmp");
if ( -l $opt_vardir and ! unlink($opt_vardir) )
{
mtr_error("Can't remove soft link \"$opt_vardir\"");
}
mkpath("$glob_mysql_test_dir/var/log");
mkpath("$glob_mysql_test_dir/var/run");
mkpath("$glob_mysql_test_dir/var/tmp");
mkpath($opt_tmpdir);
rmtree("$opt_vardir/log");
rmtree("$opt_vardir/ndbcluster-$opt_ndbcluster_port");
rmtree("$opt_vardir/run");
rmtree("$opt_vardir/tmp");
mkpath("$opt_vardir/log");
mkpath("$opt_vardir/run");
mkpath("$opt_vardir/tmp");
mkpath($opt_tmpdir) if $opt_tmpdir ne "$opt_vardir/tmp";
# FIXME do we really need to create these all, or are they
# created for us when tables are created?
@ -1027,6 +1056,16 @@ sub kill_and_cleanup () {
rmtree("$slave->[2]->{'path_myddir'}");
mkpath("$slave->[2]->{'path_myddir'}/mysql");
mkpath("$slave->[2]->{'path_myddir'}/test");
# To make some old test cases work, we create a soft
# link from the old "var" location to the new one
if ( ! $glob_win32 and $opt_vardir ne "$glob_mysql_test_dir/var" )
{
# FIXME why bother with the above, why not always remove all of var?!
rmtree("$glob_mysql_test_dir/var"); # Clean old var, FIXME or rename it?!
symlink($opt_vardir, "$glob_mysql_test_dir/var");
}
}
@ -1048,7 +1087,7 @@ sub ndbcluster_install () {
my $ndbcluster_opts= $opt_bench ? "" : "--small";
if ( mtr_run("$glob_mysql_test_dir/ndb/ndbcluster",
["--port=$opt_ndbcluster_port",
"--data-dir=$glob_mysql_test_dir/var",
"--data-dir=$opt_vardir",
$ndbcluster_opts,
"--initial"],
"", "", "", "") )
@ -1072,7 +1111,7 @@ sub ndbcluster_start () {
# FIXME, we want to _append_ output to file $file_ndb_testrun_log instead of /dev/null
if ( mtr_run("$glob_mysql_test_dir/ndb/ndbcluster",
["--port=$opt_ndbcluster_port",
"--data-dir=$glob_mysql_test_dir/var"],
"--data-dir=$opt_vardir"],
"", "/dev/null", "", "") )
{
mtr_error("Error ndbcluster_start");
@ -1091,7 +1130,7 @@ sub ndbcluster_stop () {
# FIXME, we want to _append_ output to file $file_ndb_testrun_log instead of /dev/null
mtr_run("$glob_mysql_test_dir/ndb/ndbcluster",
["--port=$opt_ndbcluster_port",
"--data-dir=$glob_mysql_test_dir/var",
"--data-dir=$opt_vardir",
"--stop"],
"", "/dev/null", "", "");
@ -1494,15 +1533,15 @@ sub run_testcase ($) {
{
mtr_report_test_passed($tinfo);
}
elsif ( $res == 2 )
elsif ( $res == 62 )
{
# Testcase itself tell us to skip this one
mtr_report_test_skipped($tinfo);
}
else
{
# Test case failed
if ( $res > 2 )
# Test case failed, if in control mysqltest returns 1
if ( $res != 1 )
{
mtr_tofile($path_timefile,
"mysqltest returned unexpected code $res, " .
@ -1563,17 +1602,17 @@ sub do_before_start_master ($$) {
$tname ne "rpl_crash_binlog_ib_3b")
{
# FIXME we really want separate dir for binlogs
foreach my $bin ( glob("$glob_mysql_test_dir/var/log/master*-bin.*") )
foreach my $bin ( glob("$opt_vardir/log/master*-bin.*") )
{
unlink($bin);
}
}
# Remove old master.info and relay-log.info files
unlink("$glob_mysql_test_dir/var/master-data/master.info");
unlink("$glob_mysql_test_dir/var/master-data/relay-log.info");
unlink("$glob_mysql_test_dir/var/master1-data/master.info");
unlink("$glob_mysql_test_dir/var/master1-data/relay-log.info");
unlink("$opt_vardir/master-data/master.info");
unlink("$opt_vardir/master-data/relay-log.info");
unlink("$opt_vardir/master1-data/master.info");
unlink("$opt_vardir/master1-data/relay-log.info");
# Run master initialization shell script if one exists
if ( $init_script )
@ -1600,13 +1639,13 @@ sub do_before_start_slave ($$) {
$tname ne "rpl_crash_binlog_ib_3b" )
{
# FIXME we really want separate dir for binlogs
foreach my $bin ( glob("$glob_mysql_test_dir/var/log/slave*-bin.*") )
foreach my $bin ( glob("$opt_vardir/log/slave*-bin.*") )
{
unlink($bin);
}
# FIXME really master?!
unlink("$glob_mysql_test_dir/var/slave-data/master.info");
unlink("$glob_mysql_test_dir/var/slave-data/relay-log.info");
unlink("$opt_vardir/slave-data/master.info");
unlink("$opt_vardir/slave-data/relay-log.info");
}
# Run slave initialization shell script if one exists
@ -1620,8 +1659,8 @@ sub do_before_start_slave ($$) {
}
}
`rm -f $glob_mysql_test_dir/var/slave-data/log.*`;
# unlink("$glob_mysql_test_dir/var/slave-data/log.*");
`rm -f $opt_vardir/slave-data/log.*`;
# unlink("$opt_vardir/slave-data/log.*");
}
sub mysqld_arguments ($$$$$) {
@ -1667,8 +1706,7 @@ sub mysqld_arguments ($$$$$) {
if ( $type eq 'master' )
{
mtr_add_arg($args, "%s--log-bin=%s/var/log/master-bin", $prefix,
$glob_mysql_test_dir);
mtr_add_arg($args, "%s--log-bin=%s/log/master-bin", $prefix, $opt_vardir);
mtr_add_arg($args, "%s--pid-file=%s", $prefix,
$master->[$idx]->{'path_mypid'});
mtr_add_arg($args, "%s--port=%d", $prefix,
@ -1692,8 +1730,8 @@ sub mysqld_arguments ($$$$$) {
# FIXME slave get this option twice?!
mtr_add_arg($args, "%s--exit-info=256", $prefix);
mtr_add_arg($args, "%s--init-rpl-role=slave", $prefix);
mtr_add_arg($args, "%s--log-bin=%s/var/log/slave%s-bin", $prefix,
$glob_mysql_test_dir, $sidx); # FIXME use own dir for binlogs
mtr_add_arg($args, "%s--log-bin=%s/log/slave%s-bin", $prefix,
$opt_vardir, $sidx); # FIXME use own dir for binlogs
mtr_add_arg($args, "%s--log-slave-updates", $prefix);
# FIXME option duplicated for slave
mtr_add_arg($args, "%s--log=%s", $prefix,
@ -1703,8 +1741,8 @@ sub mysqld_arguments ($$$$$) {
$slave->[$idx]->{'path_mypid'});
mtr_add_arg($args, "%s--port=%d", $prefix,
$slave->[$idx]->{'path_myport'});
mtr_add_arg($args, "%s--relay-log=%s/var/log/slave%s-relay-bin", $prefix,
$glob_mysql_test_dir, $sidx);
mtr_add_arg($args, "%s--relay-log=%s/log/slave%s-relay-bin", $prefix,
$opt_vardir, $sidx);
mtr_add_arg($args, "%s--report-host=127.0.0.1", $prefix);
mtr_add_arg($args, "%s--report-port=%d", $prefix,
$slave->[$idx]->{'path_myport'});
@ -1742,13 +1780,13 @@ sub mysqld_arguments ($$$$$) {
{
if ( $type eq 'master' )
{
mtr_add_arg($args, "%s--debug=d:t:i:A,%s/var/log/master%s.trace",
$prefix, $glob_mysql_test_dir, $sidx);
mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/master%s.trace",
$prefix, $opt_vardir, $sidx);
}
if ( $type eq 'slave' )
{
mtr_add_arg($args, "%s--debug=d:t:i:A,%s/var/log/slave%s.trace",
$prefix, $glob_mysql_test_dir, $sidx);
mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/slave%s.trace",
$prefix, $opt_vardir, $sidx);
}
}
@ -2000,7 +2038,7 @@ sub run_mysqltest ($$) {
if ( $opt_debug )
{
$cmdline_mysqldump .=
" --debug=d:t:A,$glob_mysql_test_dir/var/log/mysqldump.trace";
" --debug=d:t:A,$opt_vardir/log/mysqldump.trace";
}
my $cmdline_mysqlbinlog=
@ -2009,7 +2047,7 @@ sub run_mysqltest ($$) {
if ( $opt_debug )
{
$cmdline_mysqlbinlog .=
" --debug=d:t:A,$glob_mysql_test_dir/var/log/mysqlbinlog.trace";
" --debug=d:t:A,$opt_vardir/log/mysqlbinlog.trace";
}
my $cmdline_mysql=
@ -2072,13 +2110,13 @@ sub run_mysqltest ($$) {
{
$exe= "strace"; # FIXME there are ktrace, ....
mtr_add_arg($args, "-o");
mtr_add_arg($args, "%s/var/log/mysqltest.strace", $glob_mysql_test_dir);
mtr_add_arg($args, "%s/log/mysqltest.strace", $opt_vardir);
mtr_add_arg($args, "$exe_mysqltest");
}
if ( $opt_timer )
{
mtr_add_arg($args, "--timer-file=%s/var/log/timer", $glob_mysql_test_dir);
mtr_add_arg($args, "--timer-file=%s/log/timer", $opt_vardir);
}
if ( $opt_big_test )
@ -2103,8 +2141,7 @@ sub run_mysqltest ($$) {
if ( $opt_debug )
{
mtr_add_arg($args, "--debug=d:t:A,%s/var/log/mysqltest.trace",
$glob_mysql_test_dir);
mtr_add_arg($args, "--debug=d:t:A,%s/log/mysqltest.trace", $opt_vardir);
}
if ( $opt_with_openssl )
@ -2126,7 +2163,7 @@ sub run_mysqltest ($$) {
mysqld_arguments($args,'master',0,$tinfo->{'master_opt'},[]);
}
return mtr_run_test($exe_mysqltest,$args,$tinfo->{'path'},"",$path_timefile,"");
return mtr_run_test($exe,$args,$tinfo->{'path'},"",$path_timefile,"");
}
##############################################################################

View File

@ -586,10 +586,7 @@ if [ x$SOURCE_DIST = x1 ] ; then
NDB_MGM="$BASEDIR/storage/ndb/src/mgmclient/ndb_mgm"
if [ -n "$USE_PURIFY" ] ; then
PSUP="$MYSQL_TEST_DIR/purify.suppress"
echo "suppress UMR rw_read_held; mi_open; ha_myisam::open64; handler::ha_open; openfrm" > $PSUP
echo "suppress UMR my_end; main" >> $PSUP
echo "suppress UMR _doprnt; fprintf; my_end; main" >> $PSUP
PSUP="$MYSQL_TEST_DIR/suppress.purify"
PURIFYOPTIONS="-windows=no -log-file=%v.purifylog -append-logfile -add-suppression-files=$PSUP"
if [ -f "${MYSQL_TEST}-purify" ] ; then
MYSQL_TEST="${MYSQL_TEST}-purify"
@ -1705,11 +1702,11 @@ run_testcase ()
$ECHO "$RES$RES_SPACE [ pass ] $TIMER"
else
# why the following ``if'' ? That is why res==1 is special ?
if [ $res = 2 ]; then
if [ $res = 62 ]; then
skip_inc
$ECHO "$RES$RES_SPACE [ skipped ]"
else
if [ $res -gt 2 ]; then
if [ $res -ne 1 ]; then
$ECHO "mysqltest returned unexpected code $res, it has probably crashed" >> $TIMEFILE
fi
total_inc

View File

@ -303,6 +303,129 @@ ALTER TABLE t1 DISABLE KEYS;
INSERT DELAYED INTO t1 VALUES(1),(2),(3);
ALTER TABLE t1 ENABLE KEYS;
drop table t1;
CREATE TABLE t1 (
Host varchar(16) binary NOT NULL default '',
User varchar(16) binary NOT NULL default '',
PRIMARY KEY (Host,User)
) ENGINE=MyISAM;
ALTER TABLE t1 DISABLE KEYS;
LOCK TABLES t1 WRITE;
INSERT INTO t1 VALUES ('localhost','root'),('localhost',''),('games','monty');
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
t1 0 PRIMARY 2 User A 3 NULL NULL BTREE
ALTER TABLE t1 ENABLE KEYS;
UNLOCK TABLES;
CHECK TABLES t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
CREATE TABLE t1 (
Host varchar(16) binary NOT NULL default '',
User varchar(16) binary NOT NULL default '',
PRIMARY KEY (Host,User),
KEY (Host)
) ENGINE=MyISAM;
ALTER TABLE t1 DISABLE KEYS;
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
LOCK TABLES t1 WRITE;
INSERT INTO t1 VALUES ('localhost','root'),('localhost','');
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
t1 0 PRIMARY 2 User A 2 NULL NULL BTREE
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
ALTER TABLE t1 ENABLE KEYS;
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
t1 0 PRIMARY 2 User A 2 NULL NULL BTREE
t1 1 Host 1 Host A 1 NULL NULL BTREE
UNLOCK TABLES;
CHECK TABLES t1;
Table Op Msg_type Msg_text
test.t1 check status OK
LOCK TABLES t1 WRITE;
ALTER TABLE t1 RENAME t2;
UNLOCK TABLES;
select * from t2;
Host User
localhost
localhost root
DROP TABLE t2;
CREATE TABLE t1 (
Host varchar(16) binary NOT NULL default '',
User varchar(16) binary NOT NULL default '',
PRIMARY KEY (Host,User),
KEY (Host)
) ENGINE=MyISAM;
LOCK TABLES t1 WRITE;
ALTER TABLE t1 DISABLE KEYS;
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
DROP TABLE t1;
create table t1 (a int);
alter table t1 rename to `t1\\`;
ERROR 42000: Incorrect table name 't1\\'
rename table t1 to `t1\\`;
ERROR 42000: Incorrect table name 't1\\'
drop table t1;
drop table if exists t1, t2;
Warnings:
Note 1051 Unknown table 't1'
Note 1051 Unknown table 't2'
create table t1 ( a varchar(10) not null primary key ) engine=myisam;
create table t2 ( a varchar(10) not null primary key ) engine=merge union=(t1);
flush tables;
alter table t1 modify a varchar(10);
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` varchar(10) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`)
flush tables;
alter table t1 modify a varchar(10) not null;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` varchar(10) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`)
drop table if exists t1, t2;
create table t1 (a int, b int, c int, d int, e int, f int, g int, h int,i int, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
insert into t1 (a) values(1);
show table status like 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 10 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL
alter table t1 modify a int;
show table status like 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 10 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL
drop table t1;
create table t1 (a int not null, b int not null, c int not null, d int not null, e int not null, f int not null, g int not null, h int not null,i int not null, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
insert into t1 (a) values(1);
Warnings:
Warning 1364 Field 'b' doesn't have a default value
Warning 1364 Field 'c' doesn't have a default value
Warning 1364 Field 'd' doesn't have a default value
Warning 1364 Field 'e' doesn't have a default value
Warning 1364 Field 'f' doesn't have a default value
Warning 1364 Field 'g' doesn't have a default value
Warning 1364 Field 'h' doesn't have a default value
Warning 1364 Field 'i' doesn't have a default value
show table status like 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 10 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL
drop table t1;
set names koi8r;
create table t1 (a char(10) character set koi8r);
insert into t1 values ('ÔÅÓÔ');
@ -382,75 +505,6 @@ t1 CREATE TABLE `t1` (
`mytext` longtext character set latin1 collate latin1_general_cs
) ENGINE=MyISAM DEFAULT CHARSET=latin2
drop table t1;
CREATE TABLE t1 (
Host varchar(16) binary NOT NULL default '',
User varchar(16) binary NOT NULL default '',
PRIMARY KEY (Host,User)
) ENGINE=MyISAM;
ALTER TABLE t1 DISABLE KEYS;
LOCK TABLES t1 WRITE;
INSERT INTO t1 VALUES ('localhost','root'),('localhost',''),('games','monty');
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
t1 0 PRIMARY 2 User A 3 NULL NULL BTREE
ALTER TABLE t1 ENABLE KEYS;
UNLOCK TABLES;
CHECK TABLES t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
CREATE TABLE t1 (
Host varchar(16) binary NOT NULL default '',
User varchar(16) binary NOT NULL default '',
PRIMARY KEY (Host,User),
KEY (Host)
) ENGINE=MyISAM;
ALTER TABLE t1 DISABLE KEYS;
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
LOCK TABLES t1 WRITE;
INSERT INTO t1 VALUES ('localhost','root'),('localhost','');
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
t1 0 PRIMARY 2 User A 2 NULL NULL BTREE
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
ALTER TABLE t1 ENABLE KEYS;
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
t1 0 PRIMARY 2 User A 2 NULL NULL BTREE
t1 1 Host 1 Host A 1 NULL NULL BTREE
UNLOCK TABLES;
CHECK TABLES t1;
Table Op Msg_type Msg_text
test.t1 check status OK
LOCK TABLES t1 WRITE;
ALTER TABLE t1 RENAME t2;
UNLOCK TABLES;
select * from t2;
Host User
localhost
localhost root
DROP TABLE t2;
CREATE TABLE t1 (
Host varchar(16) binary NOT NULL default '',
User varchar(16) binary NOT NULL default '',
PRIMARY KEY (Host,User),
KEY (Host)
) ENGINE=MyISAM;
LOCK TABLES t1 WRITE;
ALTER TABLE t1 DISABLE KEYS;
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
DROP TABLE t1;
CREATE TABLE t1 (a int PRIMARY KEY, b INT UNIQUE);
ALTER TABLE t1 DROP PRIMARY KEY;
SHOW CREATE TABLE t1;
@ -469,12 +523,6 @@ alter table t1 drop key no_such_key;
ERROR 42000: Can't DROP 'no_such_key'; check that column/key exists
alter table t1 drop key a;
drop table t1;
create table t1 (a int);
alter table t1 rename to `t1\\`;
ERROR 42000: Incorrect table name 't1\\'
rename table t1 to `t1\\`;
ERROR 42000: Incorrect table name 't1\\'
drop table t1;
create table t1 (a text) character set koi8r;
insert into t1 values (_koi8r'ÔÅÓÔ');
select hex(a) from t1;

View File

@ -341,3 +341,17 @@ a b
2 3
3 4
drop table t1;
CREATE TABLE t1 ( a INT AUTO_INCREMENT, b BLOB, PRIMARY KEY (a,b(10)));
INSERT INTO t1 (b) VALUES ('aaaa');
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 (b) VALUES ('');
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 (b) VALUES ('bbbb');
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE IF EXISTS t1;

View File

@ -606,6 +606,24 @@ ucs2_bin 00610009
ucs2_bin 0061
ucs2_bin 00610020
drop table t1;
select hex(substr(_ucs2 0x00e400e50068,1));
hex(substr(_ucs2 0x00e400e50068,1))
00E400E50068
select hex(substr(_ucs2 0x00e400e50068,2));
hex(substr(_ucs2 0x00e400e50068,2))
00E50068
select hex(substr(_ucs2 0x00e400e50068,3));
hex(substr(_ucs2 0x00e400e50068,3))
0068
select hex(substr(_ucs2 0x00e400e50068,-1));
hex(substr(_ucs2 0x00e400e50068,-1))
0068
select hex(substr(_ucs2 0x00e400e50068,-2));
hex(substr(_ucs2 0x00e400e50068,-2))
00E50068
select hex(substr(_ucs2 0x00e400e50068,-3));
hex(substr(_ucs2 0x00e400e50068,-3))
00E400E50068
SET NAMES latin1;
SET collation_connection='ucs2_swedish_ci';
CREATE TABLE t1 (Field1 int(10) default '0');

View File

@ -167,7 +167,7 @@ count(*)
150
EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range g g 32 NULL 7 Using where
1 SIMPLE t1 range g g 32 NULL 8 Using where
SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
fid AsText(g)
1 LINESTRING(150 150,150 150)

View File

@ -287,7 +287,7 @@ b i421 l421
b m422 p422
explain select a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 Using where; Using index for group-by
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
@ -317,22 +317,22 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
explain select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t2 where a1 < 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL 12 Using where; Using index for group-by
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL 14 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t2 where a1 < 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 12 Using where; Using index for group-by
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 14 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 16 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL 18 Using where; Using index for group-by
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL 17 Using where; Using index for group-by
explain select a1, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL 18 Using where; Using index for group-by
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL 17 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t2 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 21 Using where; Using index for group-by
@ -353,7 +353,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 16 Using where; Using index for group-by
explain select a1, max(c) from t2 where a1 in ('a','b','d') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL 13 Using where; Using index for group-by
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL 14 Using where; Using index for group-by
select a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;
a1 a2 b min(c) max(c)
a a a a111 d111
@ -1398,10 +1398,10 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 163 NULL 21 Using where; Using index for group-by
explain select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 17 Using where; Using index for group-by
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 16 Using where; Using index for group-by
explain select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 17 Using where; Using index for group-by
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 16 Using where; Using index for group-by
explain select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL 16 Using where; Using index for group-by
@ -1824,16 +1824,16 @@ ord(a1) + count(distinct a1,a2,b)
104
explain select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 Using where; Using index for group-by
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
explain select concat(a1,min(c)),b from t1 where a1 < 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 Using where; Using index for group-by
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
explain select concat(a1,min(c)),b,max(c) from t1 where a1 < 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 Using where; Using index for group-by
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
explain select concat(a1,a2),b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 Using where; Using index for group-by
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
explain select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 130 NULL 9 Using index for group-by

View File

@ -0,0 +1,3 @@
load_file(concat(@tmpdir,"/outfile.test"))
Outfile OK

View File

@ -17,11 +17,11 @@ Table Op Msg_type Msg_text
test.t0 analyze status OK
explain select * from t0 where key1 < 3 or key1 > 1020;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 range i1 i1 4 NULL 55 Using where
1 SIMPLE t0 range i1 i1 4 NULL 78 Using where
explain
select * from t0 where key1 < 3 or key2 > 1020;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 31 Using sort_union(i1,i2); Using where
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 45 Using sort_union(i1,i2); Using where
select * from t0 where key1 < 3 or key2 > 1020;
key1 key2 key3 key4 key5 key6 key7 key8
1 1 1 1 1 1 1 1023
@ -36,7 +36,7 @@ id select_type table type possible_keys key key_len ref rows Extra
explain
select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 9 Using sort_union(i1,i2); Using where
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 11 Using sort_union(i1,i2); Using where
select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40);
key1 key2 key3 key4 key5 key6 key7 key8
31 31 31 31 31 31 31 993
@ -90,7 +90,7 @@ id select_type table type possible_keys key key_len ref rows Extra
explain select key1 from t0 where (key1 <=> null) or (key1 < 5) or
(key3=10) or (key4 <=> null);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 index_merge i1,i3,i4 i1,i3 4,4 NULL 5 Using sort_union(i1,i3); Using where
1 SIMPLE t0 index_merge i1,i3,i4 i1,i3 4,4 NULL 6 Using sort_union(i1,i3); Using where
explain select * from t0 where
(key1 < 3 or key2 < 3) and (key3 < 4 or key4 < 4) and (key5 < 5 or key6 < 5);
id select_type table type possible_keys key key_len ref rows Extra
@ -113,7 +113,7 @@ id select_type table type possible_keys key key_len ref rows Extra
explain select * from t0 where
(key1 < 3 or key2 < 3) and (key3 < 100);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 range i1,i2,i3 i3 4 NULL 96 Using where
1 SIMPLE t0 range i1,i2,i3 i3 4 NULL 95 Using where
explain select * from t0 where
(key1 < 3 or key2 < 3) and (key3 < 1000);
id select_type table type possible_keys key key_len ref rows Extra
@ -152,7 +152,7 @@ explain select * from t0 where
or
((key7 <7 or key8 < 4) and (key5 < 5 or key6 < 6));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7,i8 i3,i5,i7,i8 4,4,4,4 NULL 21 Using sort_union(i3,i5,i7,i8); Using where
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7,i8 i3,i5,i7,i8 4,4,4,4 NULL 20 Using sort_union(i3,i5,i7,i8); Using where
explain select * from t0 where
((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
or
@ -257,7 +257,7 @@ explain
select * from t0,t1 where (t0.key1=t1.key1) and
(t0.key1=3 or t0.key2=4) and t1.key1<200;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 range i1,i2 i1 4 NULL 179 Using where
1 SIMPLE t0 ALL i1,i2 NULL NULL NULL 1024 Using where
1 SIMPLE t1 ref i1 i1 4 test.t0.key1 1
explain
select * from t0,t1 where (t0.key1=t1.key1) and
@ -345,8 +345,8 @@ from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
where (A.key1 < 500000 or A.key2 < 3)
and (B.key1 < 500000 or B.key2 < 3);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE A index_merge i1,i2 i1,i2 4,4 NULL 1016 Using sort_union(i1,i2); Using where
1 SIMPLE B index_merge i1,i2 i1,i2 4,4 NULL 1016 Using sort_union(i1,i2); Using where
1 SIMPLE A index_merge i1,i2 i1,i2 4,4 NULL 1013 Using sort_union(i1,i2); Using where
1 SIMPLE B index_merge i1,i2 i1,i2 4,4 NULL 1013 Using sort_union(i1,i2); Using where
select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
where (A.key1 < 500000 or A.key2 < 3)
@ -371,11 +371,11 @@ alter table t0 add filler1 char(200), add filler2 char(200), add filler3 char(20
update t0 set key2=1, key3=1, key4=1, key5=1,key6=1,key7=1 where key7 < 500;
explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
from t0 as A, t0 as B
where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7or16 = 1 or A.key8=1)
and (B.key1 = 1 and B.key2 = 1 and B.key3 = 1 and B.key4=1 and B.key5=1 and B.key6=1 and B.key7or16 = 1 or B.key8=1);
where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key# = 1 or A.key8=1)
and (B.key1 = 1 and B.key2 = 1 and B.key3 = 1 and B.key4=1 and B.key5=1 and B.key6=1 and B.key# = 1 or B.key8=1);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE A index_merge i1,i2,i3,i4,i5,i6,i7?,i8 i2,i3,i4,i5,i6,i7?,i8 X NULL 7or16 Using union(intersect(i2,i3,i4,i5,i6,i7?),i8); Using where
1 SIMPLE B index_merge i1,i2,i3,i4,i5,i6,i7?,i8 i2,i3,i4,i5,i6,i7?,i8 X NULL 7or16 Using union(intersect(i2,i3,i4,i5,i6,i7?),i8); Using where
1 SIMPLE A index_merge i1,i2,i3,i4,i5,i6,i7?,i8 i2,i3,i4,i5,i6,i7?,i8 X NULL # Using union(intersect(i2,i3,i4,i5,i6,i7?),i8); Using where
1 SIMPLE B index_merge i1,i2,i3,i4,i5,i6,i7?,i8 i2,i3,i4,i5,i6,i7?,i8 X NULL # Using union(intersect(i2,i3,i4,i5,i6,i7?),i8); Using where
select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
from t0 as A, t0 as B
where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1)

View File

@ -4,13 +4,13 @@ count(*)
64801
explain select key1,key2 from t1 where key1=100 and key2=100;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 3 Using intersect(key1,key2); Using where; Using index
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 58 Using intersect(key1,key2); Using where; Using index
select key1,key2 from t1 where key1=100 and key2=100;
key1 key2
100 100
explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 8 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 154 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
key1 key2 key3 key4 filler1
100 100 100 100 key1-key2-key3-key4
@ -18,21 +18,21 @@ insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, -1, -1, 'key1
insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, 100, 100, 'key4-key3');
explain select key1,key2,filler1 from t1 where key1=100 and key2=100;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 3 Using intersect(key1,key2); Using where
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 58 Using intersect(key1,key2); Using where
select key1,key2,filler1 from t1 where key1=100 and key2=100;
key1 key2 filler1
100 100 key1-key2-key3-key4
100 100 key1-key2
explain select key1,key2 from t1 where key1=100 and key2=100;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 3 Using intersect(key1,key2); Using where; Using index
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 58 Using intersect(key1,key2); Using where; Using index
select key1,key2 from t1 where key1=100 and key2=100;
key1 key2
100 100
100 100
explain select key1,key2,key3,key4 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 8 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 154 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
select key1,key2,key3,key4 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
key1 key2 key3 key4
100 100 100 100
@ -40,7 +40,7 @@ key1 key2 key3 key4
-1 -1 100 100
explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 8 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 154 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
key1 key2 key3 key4 filler1
100 100 100 100 key1-key2-key3-key4
@ -48,14 +48,14 @@ key1 key2 key3 key4 filler1
-1 -1 100 100 key4-key3
explain select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2,key3 key1,key2,key3 5,5,5 NULL 1 Using intersect(key1,key2,key3); Using where; Using index
1 SIMPLE t1 index_merge key1,key2,key3 key1,key2,key3 5,5,5 NULL 2 Using intersect(key1,key2,key3); Using where; Using index
select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100;
key1 key2 key3
100 100 100
insert into t1 (key1,key2,key3,key4,filler1) values (101,101,101,101, 'key1234-101');
explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=101;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2,key3 key1,key2,key3 5,5,5 NULL 5 Using union(intersect(key1,key2),key3); Using where
1 SIMPLE t1 index_merge key1,key2,key3 key1,key2,key3 5,5,5 NULL 83 Using union(intersect(key1,key2),key3); Using where
select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=101;
key1 key2 key3 key4 filler1
100 100 100 100 key1-key2-key3-key4
@ -72,19 +72,19 @@ select key1,key2,filler1 from t1 where key2=100 and key2=200;
key1 key2 filler1
explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 8 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 152 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
key1 key2 key3 key4 filler1
-1 -1 100 100 key4-key3
delete from t1 where key3=100 and key4=100;
explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 8 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 152 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
key1 key2 key3 key4 filler1
explain select key1,key2 from t1 where key1=100 and key2=100;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 3 Using intersect(key1,key2); Using where; Using index
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 57 Using intersect(key1,key2); Using where; Using index
select key1,key2 from t1 where key1=100 and key2=100;
key1 key2
insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-1');
@ -92,7 +92,7 @@ insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key
insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-3');
explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 16 Using union(key3,intersect(key1,key2),key4); Using where
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 136 Using union(key3,intersect(key1,key2),key4); Using where
select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
key1 key2 key3 key4 filler1
100 100 200 200 key1-key2-key3-key4-3
@ -101,7 +101,7 @@ key1 key2 key3 key4 filler1
insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, -1, 200,'key4');
explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 18 Using union(key3,intersect(key1,key2),key4); Using where
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 146 Using union(key3,intersect(key1,key2),key4); Using where
select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
key1 key2 key3 key4 filler1
100 100 200 200 key1-key2-key3-key4-3
@ -111,7 +111,7 @@ key1 key2 key3 key4 filler1
insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, 200, -1,'key3');
explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 20 Using union(key3,intersect(key1,key2),key4); Using where
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 156 Using union(key3,intersect(key1,key2),key4); Using where
select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
key1 key2 key3 key4 filler1
100 100 200 200 key1-key2-key3-key4-3
@ -121,50 +121,50 @@ key1 key2 key3 key4 filler1
-1 -1 200 -1 key3
explain select * from t1 where st_a=1 and st_b=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b st_a,st_b 4,4 NULL 2508 Using intersect(st_a,st_b); Using where
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b st_a,st_b 4,4 NULL 2637 Using intersect(st_a,st_b); Using where
explain select st_a,st_b from t1 where st_a=1 and st_b=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b st_a,st_b 4,4 NULL 2508 Using intersect(st_a,st_b); Using where; Using index
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b st_a,st_b 4,4 NULL 2637 Using intersect(st_a,st_b); Using where; Using index
explain select st_a from t1 ignore index (st_a) where st_a=1 and st_b=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,stb_swt1a_2b,stb_swt1b,st_b st_b 4 const 14720 Using where
1 SIMPLE t1 ref sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,stb_swt1a_2b,stb_swt1b,st_b st_b 4 const 15093 Using where
explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a sta_swt12a 12 const,const,const 958
1 SIMPLE t1 ref sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a sta_swt21a 12 const,const,const 971
explain select * from t1 where st_b=1 and swt1b=1 and swt2b=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref stb_swt1a_2b,stb_swt1b,st_b stb_swt1b 8 const,const 3757 Using where
1 SIMPLE t1 ref stb_swt1a_2b,stb_swt1b,st_b stb_swt1a_2b 8 const,const 3879 Using where
explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt12a,stb_swt1a_2b 12,12 NULL 42 Using intersect(sta_swt12a,stb_swt1a_2b); Using where
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt12a,stb_swt1a_2b 12,12 NULL 44 Using intersect(sta_swt12a,stb_swt1a_2b); Using where
explain select * from t1 ignore index (sta_swt21a, stb_swt1a_2b)
where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,st_a,stb_swt1b,st_b sta_swt12a,stb_swt1b 12,8 NULL 42 Using intersect(sta_swt12a,stb_swt1b); Using where
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,st_a,stb_swt1b,st_b sta_swt12a,stb_swt1b 12,8 NULL 44 Using intersect(sta_swt12a,stb_swt1b); Using where
explain select * from t1 ignore index (sta_swt21a, sta_swt12a, stb_swt1a_2b)
where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge sta_swt1a,sta_swt2a,st_a,stb_swt1b,st_b sta_swt1a,sta_swt2a,stb_swt1b 8,8,8 NULL 41 Using intersect(sta_swt1a,sta_swt2a,stb_swt1b); Using where
1 SIMPLE t1 index_merge sta_swt1a,sta_swt2a,st_a,stb_swt1b,st_b sta_swt1a,sta_swt2a,stb_swt1b 8,8,8 NULL 43 Using intersect(sta_swt1a,sta_swt2a,stb_swt1b); Using where
explain select * from t1 ignore index (sta_swt21a, sta_swt12a, stb_swt1a_2b, stb_swt1b)
where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge sta_swt1a,sta_swt2a,st_a,st_b sta_swt1a,sta_swt2a,st_b 8,8,4 NULL 159 Using intersect(sta_swt1a,sta_swt2a,st_b); Using where
1 SIMPLE t1 index_merge sta_swt1a,sta_swt2a,st_a,st_b sta_swt1a,sta_swt2a,st_b 8,8,4 NULL 168 Using intersect(sta_swt1a,sta_swt2a,st_b); Using where
explain select * from t1
where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt12a,stb_swt1a_2b 12,12 NULL 42 Using intersect(sta_swt12a,stb_swt1a_2b); Using where
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt12a,stb_swt1a_2b 12,12 NULL 44 Using intersect(sta_swt12a,stb_swt1a_2b); Using where
explain select * from t1
where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL 163 Using intersect(sta_swt1a,stb_swt1b); Using where
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL 174 Using intersect(sta_swt1a,stb_swt1b); Using where
explain select st_a from t1
where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL 163 Using intersect(sta_swt1a,stb_swt1b); Using where; Using index
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL 174 Using intersect(sta_swt1a,stb_swt1b); Using where; Using index
explain select st_a from t1
where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL 163 Using intersect(sta_swt1a,stb_swt1b); Using where; Using index
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL 174 Using intersect(sta_swt1a,stb_swt1b); Using where; Using index
drop table t0,t1;
create table t2 (
a char(10),

View File

@ -2397,3 +2397,7 @@ select distinct concat(a, b) from t1;
concat(a, b)
11113333
drop table t1;
CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB;
SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE);
ERROR HY000: The used table type doesn't support FULLTEXT indexes
DROP TABLE t1;

View File

@ -167,7 +167,7 @@ a b c VALUES(a)
2 1 11 NULL
DROP TABLE t1;
DROP TABLE t2;
create table t1 (a int not null unique);
create table t1 (a int not null unique) engine=myisam;
insert into t1 values (1),(2);
insert ignore into t1 select 1 on duplicate key update a=2;
select * from t1;
@ -179,4 +179,11 @@ select * from t1;
a
1
3
insert into t1 select 1 on duplicate key update a=2;
select * from t1;
a
2
3
insert into t1 select a from t1 on duplicate key update a=a+1 ;
ERROR 23000: Duplicate entry '3' for key 1
drop table t1;

View File

@ -39,7 +39,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 range a a 4 NULL 18 Using where
explain select * from t3 where a > 10 and a < 20;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 range a a 4 NULL 16 Using where
1 SIMPLE t3 range a a 4 NULL 17 Using where
select * from t3 where a = 10;
a b
10 Testing

View File

@ -1203,3 +1203,60 @@ drop table t1;
Got one of the listed errors
drop table t1;
ERROR 42S02: Unknown table 't1'
set @save_concurrent_insert=@@concurrent_insert;
set global concurrent_insert=1;
create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5);
lock table t1 read local;
insert into t1 values(6),(7);
unlock tables;
delete from t1 where a>=3 and a<=4;
lock table t1 read local;
set global concurrent_insert=2;
insert into t1 values (8),(9);
unlock tables;
insert into t1 values (10),(11),(12);
select * from t1;
a
1
2
11
10
5
6
7
8
9
12
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
create table t1 (a int, b varchar(30) default "hello");
insert into t1 (a) values (1),(2),(3),(4),(5);
lock table t1 read local;
insert into t1 (a) values(6),(7);
unlock tables;
delete from t1 where a>=3 and a<=4;
lock table t1 read local;
set global concurrent_insert=2;
insert into t1 (a) values (8),(9);
unlock tables;
insert into t1 (a) values (10),(11),(12);
select a from t1;
a
1
2
11
10
5
6
7
8
9
12
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
set global concurrent_insert=@save_concurrent_insert;

View File

@ -170,7 +170,7 @@ insert into t1 select i*2 from t1;
insert into t1 values(null);
explain select * from t1 where i=2 or i is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref_or_null i i 5 const 10 Using where; Using index
1 SIMPLE t1 ref_or_null i i 5 const 9 Using where; Using index
select count(*) from t1 where i=2 or i is null;
count(*)
10
@ -179,7 +179,7 @@ Warnings:
Warning 1265 Data truncated for column 'i' at row 513
explain select * from t1 where i=2 or i is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref i i 4 const 8 Using index
1 SIMPLE t1 ref i i 4 const 7 Using index
select count(*) from t1 where i=2 or i is null;
count(*)
9

Binary file not shown.

View File

@ -55,15 +55,15 @@ count(*)
4181
show status like "key_read%";
Variable_name Value
Key_read_requests 217
Key_reads 45
Key_read_requests 294
Key_reads 60
select count(*) from t1 where b = 'test1';
count(*)
4181
show status like "key_read%";
Variable_name Value
Key_read_requests 434
Key_reads 45
Key_read_requests 588
Key_reads 60
flush tables;
flush status;
select @@preload_buffer_size;
@ -74,15 +74,15 @@ Table Op Msg_type Msg_text
test.t1 preload_keys status OK
show status like "key_read%";
Variable_name Value
Key_read_requests 581
Key_reads 581
Key_read_requests 774
Key_reads 774
select count(*) from t1 where b = 'test1';
count(*)
4181
show status like "key_read%";
Variable_name Value
Key_read_requests 798
Key_reads 581
Key_read_requests 1068
Key_reads 774
flush tables;
flush status;
show status like "key_read%";
@ -98,15 +98,15 @@ Table Op Msg_type Msg_text
test.t1 preload_keys status OK
show status like "key_read%";
Variable_name Value
Key_read_requests 10
Key_reads 10
Key_read_requests 17
Key_reads 17
select count(*) from t1 where b = 'test1';
count(*)
4181
show status like "key_read%";
Variable_name Value
Key_read_requests 227
Key_reads 52
Key_read_requests 311
Key_reads 75
flush tables;
flush status;
show status like "key_read%";
@ -123,8 +123,8 @@ test.t1 preload_keys status OK
test.t2 preload_keys status OK
show status like "key_read%";
Variable_name Value
Key_read_requests 587
Key_reads 587
Key_read_requests 785
Key_reads 785
select count(*) from t1 where b = 'test1';
count(*)
4181
@ -133,8 +133,8 @@ count(*)
2584
show status like "key_read%";
Variable_name Value
Key_read_requests 938
Key_reads 613
Key_read_requests 1266
Key_reads 821
flush tables;
flush status;
show status like "key_read%";
@ -149,8 +149,8 @@ Warnings:
Error 1146 Table 'test.t3' doesn't exist
show status like "key_read%";
Variable_name Value
Key_read_requests 355
Key_reads 355
Key_read_requests 478
Key_reads 478
flush tables;
flush status;
show status like "key_read%";

View File

@ -1,4 +1,5 @@
drop table if exists t1,t2;
drop database if exists client_test_db;
create table t1
(
a int primary key,

View File

@ -290,11 +290,11 @@ t2 1 t2_idx 1 b A NULL NULL NULL YES BTREE
prepare stmt4 from ' show table status from test like ''t2%'' ';
execute stmt4;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t2 MyISAM 10 Fixed 0 0 0 64424509439 1024 0 NULL # # # latin1_swedish_ci NULL
t2 MyISAM 10 Fixed 0 0 0 4222124650659839 1024 0 NULL # # # latin1_swedish_ci NULL
prepare stmt4 from ' show table status from test like ''t9%'' ';
execute stmt4;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t9 MyISAM 10 Dynamic 2 216 432 4294967295 2048 0 NULL # # # latin1_swedish_ci NULL
t9 MyISAM 10 Dynamic 2 216 432 281474976710655 2048 0 NULL # # # latin1_swedish_ci NULL
prepare stmt4 from ' show status like ''Threads_running'' ';
execute stmt4;
Variable_name Value
@ -803,4 +803,4 @@ prepare stmt1 from @string ;
execute stmt1 ;
prepare stmt1 from ' select * from t5 ' ;
execute stmt1 ;
drop table t5 ;
drop table t5, t9;

View File

@ -1,7 +1,3 @@
prepare stmt4 from ' show full processlist ';
execute stmt4;
Id User Host db Command Time State Info
number root localhost test Query time NULL show full processlist
test_sequence
------ grant/revoke/drop affects a parallel session test ------
show grants for second_user@localhost ;
@ -91,3 +87,8 @@ revoke all privileges on test.t1 from drop_user@localhost ;
prepare stmt3 from ' drop user drop_user@localhost ';
ERROR HY000: This command is not supported in the prepared statement protocol yet
drop user drop_user@localhost;
prepare stmt4 from ' show full processlist ';
execute stmt4;
Id User Host db Command Time State Info
number root localhost test Query time NULL show full processlist
deallocate prepare stmt4;

View File

@ -421,19 +421,19 @@ test.t1 analyze status OK
test.t2 analyze status Table is already up to date
explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uid_index uid_index 4 NULL 128 Using where
1 SIMPLE t1 range uid_index uid_index 4 NULL 112 Using where
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uid_index uid_index 4 NULL 128 Using where
1 SIMPLE t1 range uid_index uid_index 4 NULL 112 Using where
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uid_index uid_index 4 NULL 129 Using where
1 SIMPLE t1 range uid_index uid_index 4 NULL 113 Using where
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid != 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uid_index uid_index 4 NULL 129 Using where
1 SIMPLE t1 range uid_index uid_index 4 NULL 113 Using where
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
id name uid id name uid

View File

@ -6,3 +6,12 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
set global slave_net_timeout=100;
set global sql_slave_skip_counter=100;
show variables like 'slave_compressed_protocol';
Variable_name Value
slave_compressed_protocol OFF
show variables like 'slave_load_tmpdir';
Variable_name Value
slave_load_tmpdir MYSQL_TEST_DIR/var/tmp/
show variables like 'slave_skip_errors';
Variable_name Value
slave_skip_errors 3,100,137,643,1752

View File

@ -2482,7 +2482,7 @@ a
select distinct distinct * from t1;
a
select all distinct * from t1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'distinct * from t1' at line 1
ERROR HY000: Incorrect usage of ALL and DISTINCT
select distinct all * from t1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'all * from t1' at line 1
ERROR HY000: Incorrect usage of ALL and DISTINCT
drop table t1;

View File

@ -3073,4 +3073,29 @@ update v1 set data = 10|
call bug9841()|
drop view v1|
drop procedure bug9841|
drop procedure if exists bug5963|
create procedure bug5963_1 () begin declare v int; set v = (select s1 from t3); select v; end;|
create table t3 (s1 int)|
insert into t3 values (5)|
call bug5963_1()|
v
5
call bug5963_1()|
v
5
drop procedure bug5963_1|
drop table t3|
create procedure bug5963_2 (cfk_value int)
begin
if cfk_value in (select cpk from t3) then
set @x = 5;
end if;
end;
|
create table t3 (cpk int)|
insert into t3 values (1)|
call bug5963_2(1)|
call bug5963_2(1)|
drop procedure bug5963_2|
drop table t3|
drop table t1,t2;

View File

@ -1232,3 +1232,8 @@ INSERT INTO t1 VALUES (DEFAULT,1);
Warnings:
Warning 1364 Field 'i' doesn't have a default value
DROP TABLE t1;
set @@sql_mode='traditional';
create table t1(a varchar(65537));
ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead
create table t1(a varbinary(65537));
ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead

View File

@ -9,7 +9,7 @@ d mediumtext YES NULL
e longtext YES NULL
CREATE TABLE t2 (a char(255), b varbinary(70000), c varchar(70000000));
Warnings:
Note 1246 Converting column 'b' from VARCHAR to BLOB
Note 1246 Converting column 'b' from VARBINARY to BLOB
Note 1246 Converting column 'c' from VARCHAR to TEXT
CREATE TABLE t4 (c varchar(65530) character set utf8 not null);
Warnings:

View File

@ -876,3 +876,12 @@ SELECT * FROM t1;
f1 f2
9999999999999999999999999999999999.00000000000000000000 0.00
DROP TABLE t1;
CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB;
INSERT INTO t1 (GRADE) VALUES (151),(252),(343);
SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300;
GRADE
252
SELECT GRADE FROM t1 WHERE GRADE= 151;
GRADE
151
DROP TABLE t1;

View File

@ -117,27 +117,23 @@ id select_type table type possible_keys key key_len ref rows Extra
Warnings:
Note 1003 select sql_no_cache 345 AS `@@IDENTITY`,last_insert_id() AS `last_insert_id()`,345 AS `@@identity`
set big_tables=OFF, big_tables=ON, big_tables=0, big_tables=1, big_tables="OFF", big_tables="ON";
set global concurrent_insert=ON;
set global concurrent_insert=2;
show variables like 'concurrent_insert';
Variable_name Value
concurrent_insert ON
concurrent_insert 2
set global concurrent_insert=1;
show variables like 'concurrent_insert';
Variable_name Value
concurrent_insert ON
concurrent_insert 1
set global concurrent_insert=0;
show variables like 'concurrent_insert';
Variable_name Value
concurrent_insert OFF
set global concurrent_insert=OFF;
show variables like 'concurrent_insert';
Variable_name Value
concurrent_insert OFF
concurrent_insert 0
set global concurrent_insert=DEFAULT;
show variables like 'concurrent_insert';
Variable_name Value
concurrent_insert ON
set global timed_mutexes=1;
select @@concurrent_insert;
@@concurrent_insert
1
set global timed_mutexes=ON;
show variables like 'timed_mutexes';
Variable_name Value
timed_mutexes ON
@ -281,8 +277,6 @@ select @@global.sql_auto_is_null;
ERROR HY000: Variable 'sql_auto_is_null' is a SESSION variable
set myisam_max_sort_file_size=100;
ERROR HY000: Variable 'myisam_max_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL
set myisam_max_extra_sort_file_size=100;
ERROR HY000: Variable 'myisam_max_extra_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL
set @@SQL_WARNINGS=NULL;
ERROR 42000: Variable 'sql_warnings' can't be set to the value of 'NULL'
set autocommit=1;
@ -338,11 +332,6 @@ select @@max_user_connections;
@@max_user_connections
100
set global max_write_lock_count=100;
set global myisam_max_extra_sort_file_size=100;
select @@myisam_max_extra_sort_file_size;
@@myisam_max_extra_sort_file_size
100
set global myisam_max_sort_file_size=100;
set myisam_sort_buffer_size=100;
set net_buffer_length=100;
set net_read_timeout=100;

View File

@ -1,4 +1,4 @@
drop table if exists t1,t2,`t1a``b`,v1,v2,v3,v4,v5,v6;
drop table if exists t1,t2,t9,`t1a``b`,v1,v2,v3,v4,v5,v6;
drop view if exists t1,t2,`t1a``b`,v1,v2,v3,v4,v5,v6;
drop database if exists mysqltest;
use test;
@ -51,7 +51,7 @@ explain extended select c from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 5
Warnings:
Note 1003 select (`test`.`t1`.`b` + 1) AS `c` from `test`.`v1`
Note 1003 select (`test`.`t1`.`b` + 1) AS `c` from `test`.`t1`
create algorithm=temptable view v2 (c) as select b+1 from t1;
show create view v2;
View Create View
@ -85,7 +85,7 @@ explain extended select c from v3;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 5
Warnings:
Note 1003 select ((`test`.`t1`.`b` + 1) + 1) AS `c` from `test`.`v3`
Note 1003 select ((`test`.`t1`.`b` + 1) + 1) AS `c` from `test`.`t1`
create algorithm=temptable view v4 (c) as select c+1 from v2;
select c from v4;
c
@ -114,7 +114,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived3> ALL NULL NULL NULL NULL 5
3 DERIVED t1 ALL NULL NULL NULL NULL 5
Warnings:
Note 1003 select (`v2`.`c` + 1) AS `c` from `test`.`v5`
Note 1003 select (`v2`.`c` + 1) AS `c` from `test`.`v2`
create algorithm=temptable view v6 (c) as select c+1 from v1;
select c from v6;
c
@ -149,7 +149,7 @@ v5 VIEW
v6 VIEW
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 10 Fixed 5 9 45 38654705663 1024 0 NULL # # NULL latin1_swedish_ci NULL
t1 MyISAM 10 Fixed 5 9 45 2533274790395903 1024 0 NULL # # NULL latin1_swedish_ci NULL
v1 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL view
v2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL view
v3 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL view
@ -204,21 +204,6 @@ create table t1 (a int);
insert into t1 values (1), (2), (3);
create view v1 (a) as select a+1 from t1;
create view v2 (a) as select a-1 from t1;
select * from t1 natural left join v1;
a a
1 NULL
2 2
3 3
select * from v2 natural left join t1;
a a
0 NULL
1 1
2 2
select * from v2 natural left join v1;
a a
0 NULL
1 NULL
2 2
drop view v1, v2;
drop table t1;
create table t1 (a int);
@ -378,7 +363,7 @@ explain extended select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
Warnings:
Note 1003 select `test`.`t1`.`b` AS `c` from `test`.`v1` where (`test`.`t1`.`a` < 3)
Note 1003 select `test`.`t1`.`b` AS `c` from `test`.`t1` where (`test`.`t1`.`a` < 3)
update v1 set c=c+1;
select * from t1;
a b
@ -1393,7 +1378,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
Warnings:
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `b` from `test`.`t3` left join (`test`.`v1` left join `test`.`v2` on((`test`.`t1`.`a` = `test`.`t2`.`a`))) on((`test`.`t3`.`a` = `test`.`t1`.`a`)) where 1
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `b` from `test`.`t3` left join (`test`.`t1` left join (`test`.`t2`) on((`test`.`t1`.`a` = `test`.`t2`.`a`))) on((`test`.`t3`.`a` = `test`.`t1`.`a`)) where 1
prepare stmt1 from "select * from t3 left join v4 on (t3.a = v4.a);";
execute stmt1;
a a b
@ -1712,3 +1697,18 @@ a b a b
3 3 3 3
drop view v1, v2;
drop table t1, t2, t3;
CREATE TABLE t1 (a int);
CREATE TABLE t2 (b int);
INSERT INTO t1 VALUES (1), (2), (3), (4);
INSERT INTO t2 VALUES (4), (2);
CREATE VIEW v1 AS SELECT * FROM t1,t2 WHERE t1.a=t2.b;
SELECT * FROM v1;
a b
2 2
4 4
CREATE VIEW v2 AS SELECT * FROM v1;
SELECT * FROM v2;
a b
2 2
4 4
DROP VIEW v2,v1;

View File

@ -0,0 +1,10 @@
suppress UMR rw_read_held; mi_open; ha_myisam::open64; handler::ha_open; openfrm
suppress UMR my_end; main
suppress UMR _doprnt; fprintf; my_end; main
suppress umr rw_read_held; mi_open
suppress umr _putmsg; putmsg; _tx_sndudata
suppress umr rw_read_held; Query_cache::store_query(THD*,st_table_list*); mysql_execute_command(THD*)
suppress sig ...; _select; select; handle_connections_sockets; main; _start
suppress sig ...; read; vio_read; my_real_read(st_net*,unsigned long*); my_net_read; do_command(THD*)
suppress sig ...; read; vio_read; my_real_read(st_net*,unsigned long*); my_net_read; net_safe_read
suppress sig ...; write; vio_write; net_real_write; net_write_buff(st_net*,const char*,unsigned long); my_net_write

View File

@ -165,56 +165,6 @@ INSERT DELAYED INTO t1 VALUES(1),(2),(3);
ALTER TABLE t1 ENABLE KEYS;
drop table t1;
#
# Test that data get converted when character set is changed
# Test that data doesn't get converted when src or dst is BINARY/BLOB
#
set names koi8r;
create table t1 (a char(10) character set koi8r);
insert into t1 values ('ÔÅÓÔ');
select a,hex(a) from t1;
alter table t1 change a a char(10) character set cp1251;
select a,hex(a) from t1;
alter table t1 change a a binary(10);
select a,hex(a) from t1;
alter table t1 change a a char(10) character set cp1251;
select a,hex(a) from t1;
alter table t1 change a a char(10) character set koi8r;
select a,hex(a) from t1;
alter table t1 change a a varchar(10) character set cp1251;
select a,hex(a) from t1;
alter table t1 change a a char(10) character set koi8r;
select a,hex(a) from t1;
alter table t1 change a a text character set cp1251;
select a,hex(a) from t1;
alter table t1 change a a char(10) character set koi8r;
select a,hex(a) from t1;
delete from t1;
#
# Test ALTER TABLE .. CHARACTER SET ..
#
show create table t1;
alter table t1 DEFAULT CHARACTER SET latin1;
show create table t1;
alter table t1 CONVERT TO CHARACTER SET latin1;
show create table t1;
alter table t1 DEFAULT CHARACTER SET cp1251;
show create table t1;
drop table t1;
#
# Bug#2821
# Test that table CHARACTER SET does not affect blobs
#
create table t1 (myblob longblob,mytext longtext)
default charset latin1 collate latin1_general_cs;
show create table t1;
alter table t1 character set latin2;
show create table t1;
drop table t1;
#
# Test ALTER TABLE ENABLE/DISABLE keys when things are locked
#
@ -277,6 +227,97 @@ ALTER TABLE t1 DISABLE KEYS;
SHOW INDEX FROM t1;
DROP TABLE t1;
#
# BUG#4717 - check for valid table names
#
create table t1 (a int);
--error 1103
alter table t1 rename to `t1\\`;
--error 1103
rename table t1 to `t1\\`;
drop table t1;
#
# BUG#6236 - ALTER TABLE MODIFY should set implicit NOT NULL on PK columns
#
drop table if exists t1, t2;
create table t1 ( a varchar(10) not null primary key ) engine=myisam;
create table t2 ( a varchar(10) not null primary key ) engine=merge union=(t1);
flush tables;
alter table t1 modify a varchar(10);
show create table t2;
flush tables;
alter table t1 modify a varchar(10) not null;
show create table t2;
drop table if exists t1, t2;
# The following is also part of bug #6236 (CREATE TABLE didn't properly count
# not null columns for primary keys)
create table t1 (a int, b int, c int, d int, e int, f int, g int, h int,i int, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
insert into t1 (a) values(1);
--replace_column 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
show table status like 't1';
alter table t1 modify a int;
--replace_column 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
show table status like 't1';
drop table t1;
create table t1 (a int not null, b int not null, c int not null, d int not null, e int not null, f int not null, g int not null, h int not null,i int not null, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
insert into t1 (a) values(1);
--replace_column 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
show table status like 't1';
drop table t1;
#
# Test that data get converted when character set is changed
# Test that data doesn't get converted when src or dst is BINARY/BLOB
#
set names koi8r;
create table t1 (a char(10) character set koi8r);
insert into t1 values ('ÔÅÓÔ');
select a,hex(a) from t1;
alter table t1 change a a char(10) character set cp1251;
select a,hex(a) from t1;
alter table t1 change a a binary(10);
select a,hex(a) from t1;
alter table t1 change a a char(10) character set cp1251;
select a,hex(a) from t1;
alter table t1 change a a char(10) character set koi8r;
select a,hex(a) from t1;
alter table t1 change a a varchar(10) character set cp1251;
select a,hex(a) from t1;
alter table t1 change a a char(10) character set koi8r;
select a,hex(a) from t1;
alter table t1 change a a text character set cp1251;
select a,hex(a) from t1;
alter table t1 change a a char(10) character set koi8r;
select a,hex(a) from t1;
delete from t1;
#
# Test ALTER TABLE .. CHARACTER SET ..
#
show create table t1;
alter table t1 DEFAULT CHARACTER SET latin1;
show create table t1;
alter table t1 CONVERT TO CHARACTER SET latin1;
show create table t1;
alter table t1 DEFAULT CHARACTER SET cp1251;
show create table t1;
drop table t1;
#
# Bug#2821
# Test that table CHARACTER SET does not affect blobs
#
create table t1 (myblob longblob,mytext longtext)
default charset latin1 collate latin1_general_cs;
show create table t1;
alter table t1 character set latin2;
show create table t1;
drop table t1;
#
# Bug 2361 (Don't drop UNIQUE with DROP PRIMARY KEY)
#
@ -296,16 +337,6 @@ alter table t1 drop key no_such_key;
alter table t1 drop key a;
drop table t1;
#
# BUG#4717 - check for valid table names
#
create table t1 (a int);
--error 1103
alter table t1 rename to `t1\\`;
--error 1103
rename table t1 to `t1\\`;
drop table t1;
#
# Bug #6479 ALTER TABLE ... changing charset fails for TEXT columns
#

View File

@ -206,3 +206,15 @@ alter table t1 modify b varchar(255);
insert into t1 values (0,4);
select * from t1;
drop table t1;
#
# BUG #10045: Problem with composite AUTO_INCREMENT + BLOB key
CREATE TABLE t1 ( a INT AUTO_INCREMENT, b BLOB, PRIMARY KEY (a,b(10)));
INSERT INTO t1 (b) VALUES ('aaaa');
CHECK TABLE t1;
INSERT INTO t1 (b) VALUES ('');
CHECK TABLE t1;
INSERT INTO t1 (b) VALUES ('bbbb');
CHECK TABLE t1;
DROP TABLE IF EXISTS t1;

View File

@ -376,6 +376,16 @@ SET NAMES latin1;
SET collation_connection='ucs2_bin';
-- source include/ctype_filesort.inc
#
# Bug#10344 Some string functions fail for UCS2
#
select hex(substr(_ucs2 0x00e400e50068,1));
select hex(substr(_ucs2 0x00e400e50068,2));
select hex(substr(_ucs2 0x00e400e50068,3));
select hex(substr(_ucs2 0x00e400e50068,-1));
select hex(substr(_ucs2 0x00e400e50068,-2));
select hex(substr(_ucs2 0x00e400e50068,-3));
SET NAMES latin1;
#
# Bug#8235

View File

@ -310,7 +310,7 @@ update t0 set key2=1, key3=1, key4=1, key5=1,key6=1,key7=1 where key7 < 500;
# The next query will not use index i7 in intersection if the OS doesn't
# support file sizes > 2GB. (ha_myisam::ref_length depends on this and index
# scan cost estimates depend on ha_myisam::ref_length)
--replace_result "4,4,4,4,4,4,4" X "4,4,4,4,4,4" X "i6,i7" "i6,i7?" "i6" "i6,i7?" 7 7or16 16 7or16
--replace_result "4,4,4,4,4,4,4" X "4,4,4,4,4,4" X "i6,i7" "i6,i7?" "i6" "i6,i7?" 7 # 16 # 18 #
explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
from t0 as A, t0 as B
where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1)

View File

@ -184,6 +184,8 @@ explain select st_a from t1 ignore index (st_a) where st_a=1 and st_b=1;
# Check that keys that don't improve selectivity are skipped.
#
# Different value on 32 and 64 bit
--replace_result sta_swt12a sta_swt21a sta_swt12a, sta_swt12a,
explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1;
explain select * from t1 where st_b=1 and swt1b=1 and swt2b=1;

View File

@ -1309,3 +1309,13 @@ create table t1(a int(1) , b int(1)) engine=innodb;
insert into t1 values ('1111', '3333');
select distinct concat(a, b) from t1;
drop table t1;
#
# BUG#7709 test case - Boolean fulltext query against unsupported
# engines does not fail
#
CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB;
--error 1214;
SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE);
DROP TABLE t1;

View File

@ -85,10 +85,14 @@ DROP TABLE t2;
# Bug#9725 - "disapearing query/hang" and "unknown error" with "on duplicate key update"
# INSERT INGORE...UPDATE gives bad error or breaks protocol.
#
create table t1 (a int not null unique);
create table t1 (a int not null unique) engine=myisam;
insert into t1 values (1),(2);
insert ignore into t1 select 1 on duplicate key update a=2;
select * from t1;
insert ignore into t1 select a from t1 on duplicate key update a=a+1 ;
select * from t1;
insert into t1 select 1 on duplicate key update a=2;
select * from t1;
--error 1062
insert into t1 select a from t1 on duplicate key update a=a+1 ;
drop table t1;

View File

@ -606,3 +606,57 @@ system rm ./var/master-data/test/t1.MYD ;
drop table t1;
--error 1051
drop table t1;
#
# Test concurrent insert
# First with static record length
#
set @save_concurrent_insert=@@concurrent_insert;
set global concurrent_insert=1;
create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5);
lock table t1 read local;
connect (con1,localhost,root,,);
connection con1;
# Insert in table without hole
insert into t1 values(6),(7);
connection default;
unlock tables;
delete from t1 where a>=3 and a<=4;
lock table t1 read local;
connection con1;
set global concurrent_insert=2;
# Insert in table with hole -> Should insert at end
insert into t1 values (8),(9);
connection default;
unlock tables;
# Insert into hole
insert into t1 values (10),(11),(12);
select * from t1;
check table t1;
drop table t1;
# Same test with dynamic record length
create table t1 (a int, b varchar(30) default "hello");
insert into t1 (a) values (1),(2),(3),(4),(5);
lock table t1 read local;
connect (con1,localhost,root,,);
connection con1;
# Insert in table without hole
insert into t1 (a) values(6),(7);
connection default;
unlock tables;
delete from t1 where a>=3 and a<=4;
lock table t1 read local;
connection con1;
set global concurrent_insert=2;
# Insert in table with hole -> Should insert at end
insert into t1 (a) values (8),(9);
connection default;
unlock tables;
# Insert into hole
insert into t1 (a) values (10),(11),(12);
select a from t1;
check table t1;
drop table t1;
set global concurrent_insert=@save_concurrent_insert;

View File

@ -1,3 +1,9 @@
disable_query_log;
-- source include/test_outfile.inc
eval set @tmpdir="$MYSQL_TEST_DIR/var/tmp";
enable_query_log;
-- source include/have_outfile.inc
#
# test of into outfile|dumpfile
#
@ -6,29 +12,45 @@
drop table if exists t1;
--enable_warnings
# We need to check that we have 'file' privilege.
create table t1 (`a` blob);
insert into t1 values("hello world"),("Hello mars"),(NULL);
disable_query_log;
eval select * into outfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.1" from t1;
enable_query_log;
select load_file(concat(@tmpdir,"/outfile-test.1"));
disable_query_log;
eval select * into dumpfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.2" from t1 limit 1;
enable_query_log;
select load_file(concat(@tmpdir,"/outfile-test.2"));
disable_query_log;
eval select * into dumpfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.3" from t1 where a is null;
enable_query_log;
select load_file(concat(@tmpdir,"/outfile-test.3"));
#create table t1 (`a` blob);
#insert into t1 values("hello world"),("Hello mars"),(NULL);
#select * into outfile "/tmp/select-test.1" from t1;
#select load_file("/tmp/select-test.1");
#select * into dumpfile "/tmp/select-test.2" from t1 limit 1;
#select load_file("/tmp/select-test.2");
#select * into dumpfile "/tmp/select-test.3" from t1 where a is null;
#select load_file("/tmp/select-test.3");
#
## the following should give errors
#
#select * into outfile "/tmp/select-test.1" from t1;
#select * into dumpfile "/tmp/select-test.1" from t1;
#select * into dumpfile "/tmp/select-test.99" from t1;
#select load_file("/tmp/select-test.not-exist");
#drop table t1;
#drop table if exists t;
#CREATE TABLE t ( t timestamp NOT NULL, c char(200) character set latin1 NOT NULL default '', i int(11), v varchar(200), b blob, KEY t (t)) ENGINE=MyISAM;
#INSERT INTO t VALUES ('2002-12-20 12:01:20','',1,"aaa","bbb");
#select * from t into outfile "check";
#drop table if exists t;
# the following should give errors
#disabled as error message has variable path
#disable_query_log;
#--error 1086
#eval select * into outfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.1" from t1;
#--error 1086
#eval select * into dumpfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.2" from t1;
#--error 1086
#eval select * into dumpfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.3" from t1;
#enable_query_log;
--error 13,2
select load_file(concat(@tmpdir,"/outfile-test.not-exist"));
--exec rm $MYSQL_TEST_DIR/var/tmp/outfile-test.1
--exec rm $MYSQL_TEST_DIR/var/tmp/outfile-test.2
--exec rm $MYSQL_TEST_DIR/var/tmp/outfile-test.3
drop table t1;
# Bug#8191
disable_query_log;
eval select 1 into outfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.4";
enable_query_log;
select load_file(concat(@tmpdir,"/outfile-test.4"));
--exec rm $MYSQL_TEST_DIR/var/tmp/outfile-test.4
#
# Bug #5382: 'explain select into outfile' crashes the server

View File

@ -3,6 +3,9 @@
#
--disable_warnings
drop table if exists t1,t2;
# Avoid wrong warnings if mysql_client_test fails
drop database if exists client_test_db;
--enable_warnings
create table t1

View File

@ -833,7 +833,7 @@ execute stmt1 ;
--disable_metadata
--horizontal_results
drop table t5 ;
drop table t5, t9;
##### RULES OF THUMB TO PRESERVE THE SYSTEMATICS OF THE PS TEST CASES #####
#

View File

@ -1,10 +1,6 @@
# Can't test grants with embedded server
-- source include/not_embedded.inc
# Tested here simply so it is not tested with embedded server
prepare stmt4 from ' show full processlist ';
--replace_column 1 number 6 time 3 localhost
execute stmt4;
let $type= 'MYISAM' ;
@ -116,6 +112,7 @@ show grants for second_user@localhost ;
drop database mysqltest;
## grant/revoke + drop user
--error 1295
prepare stmt3 from ' grant all on test.t1 to drop_user@localhost
@ -130,3 +127,10 @@ revoke all privileges on test.t1 from drop_user@localhost ;
prepare stmt3 from ' drop user drop_user@localhost ';
drop user drop_user@localhost;
# This test must be the last one, otherwise it may produce extra
# rows in the processlist under high load.
# Tested here simply so it is not tested with embedded server
prepare stmt4 from ' show full processlist ';
--replace_column 1 number 6 time 3 localhost
execute stmt4;
deallocate prepare stmt4;

View File

@ -0,0 +1 @@
--slave-skip-errors=3,100,137,643,1752

View File

@ -2,3 +2,11 @@ source include/master-slave.inc;
set global slave_net_timeout=100;
set global sql_slave_skip_counter=100;
# BUG #7800: Add various-slave related variables to SHOW VARIABLES
show variables like 'slave_compressed_protocol';
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
show variables like 'slave_load_tmpdir';
# We just set some arbitrary values in variables-master.opt so we can test
# that a list of values works correctly
show variables like 'slave_skip_errors';

View File

@ -2064,9 +2064,9 @@ drop table t1;
create table t1 (a int(11));
select all all * from t1;
select distinct distinct * from t1;
--error 1064
--error 1221
select all distinct * from t1;
--error 1064
--error 1221
select distinct all * from t1;
drop table t1;

View File

@ -3772,6 +3772,35 @@ drop view v1|
drop procedure bug9841|
#
# BUG#5963 subqueries in SET/IF
#
--disable_warnings
drop procedure if exists bug5963|
--enable_warnings
create procedure bug5963_1 () begin declare v int; set v = (select s1 from t3); select v; end;|
create table t3 (s1 int)|
insert into t3 values (5)|
call bug5963_1()|
call bug5963_1()|
drop procedure bug5963_1|
drop table t3|
create procedure bug5963_2 (cfk_value int)
begin
if cfk_value in (select cpk from t3) then
set @x = 5;
end if;
end;
|
create table t3 (cpk int)|
insert into t3 values (1)|
call bug5963_2(1)|
call bug5963_2(1)|
drop procedure bug5963_2|
drop table t3|
#
# BUG#NNNN: New bug synopsis
#

View File

@ -1083,3 +1083,13 @@ INSERT INTO t1 SET j = 1, i = DEFAULT;
INSERT INTO t1 SET j = 1, i = DEFAULT(i);
INSERT INTO t1 VALUES (DEFAULT,1);
DROP TABLE t1;
#
# Bugs #8295 and #8296: varchar and varbinary conversion
#
set @@sql_mode='traditional';
--error 1074
create table t1(a varchar(65537));
--error 1074
create table t1(a varbinary(65537));

View File

@ -906,3 +906,13 @@ CREATE TABLE t1 (f1 DECIMAL (64,20), f2 DECIMAL(2,2));
INSERT INTO t1 VALUES (9999999999999999999999999999999999, 0);
SELECT * FROM t1;
DROP TABLE t1;
#
# Bug #10465
#
CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB;
INSERT INTO t1 (GRADE) VALUES (151),(252),(343);
SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300;
SELECT GRADE FROM t1 WHERE GRADE= 151;
DROP TABLE t1;

View File

@ -72,23 +72,20 @@ explain extended select @@IDENTITY,last_insert_id(), @@identity;
set big_tables=OFF, big_tables=ON, big_tables=0, big_tables=1, big_tables="OFF", big_tables="ON";
set global concurrent_insert=ON;
set global concurrent_insert=2;
show variables like 'concurrent_insert';
set global concurrent_insert=1;
show variables like 'concurrent_insert';
set global concurrent_insert=0;
show variables like 'concurrent_insert';
set global concurrent_insert=OFF;
show variables like 'concurrent_insert';
set global concurrent_insert=DEFAULT;
show variables like 'concurrent_insert';
select @@concurrent_insert;
set global timed_mutexes=1;
set global timed_mutexes=ON;
show variables like 'timed_mutexes';
set global timed_mutexes=0;
show variables like 'timed_mutexes';
set storage_engine=MYISAM, storage_engine="HEAP", global storage_engine="MERGE";
show local variables like 'storage_engine';
show global variables like 'storage_engine';
@ -174,8 +171,6 @@ set @@global.sql_auto_is_null=1;
select @@global.sql_auto_is_null;
--error 1229
set myisam_max_sort_file_size=100;
--error 1229
set myisam_max_extra_sort_file_size=100;
--error 1231
set @@SQL_WARNINGS=NULL;
@ -222,9 +217,6 @@ set max_tmp_tables=100;
set global max_user_connections=100;
select @@max_user_connections;
set global max_write_lock_count=100;
set global myisam_max_extra_sort_file_size=100;
select @@myisam_max_extra_sort_file_size;
set global myisam_max_sort_file_size=100;
set myisam_sort_buffer_size=100;
set net_buffer_length=100;
set net_read_timeout=100;

View File

@ -1,5 +1,5 @@
--disable_warnings
drop table if exists t1,t2,`t1a``b`,v1,v2,v3,v4,v5,v6;
drop table if exists t1,t2,t9,`t1a``b`,v1,v2,v3,v4,v5,v6;
drop view if exists t1,t2,`t1a``b`,v1,v2,v3,v4,v5,v6;
drop database if exists mysqltest;
--enable_warnings
@ -148,9 +148,10 @@ insert into t1 values (1), (2), (3);
create view v1 (a) as select a+1 from t1;
create view v2 (a) as select a-1 from t1;
select * from t1 natural left join v1;
select * from v2 natural left join t1;
select * from v2 natural left join v1;
# WL #2486 should enable these tests
#select * from t1 natural left join v1;
#select * from v2 natural left join t1;
#select * from v2 natural left join v1;
drop view v1, v2;
drop table t1;
@ -1533,3 +1534,18 @@ select * from v2 A, v2 B where A.a = B.b;
drop view v1, v2;
drop table t1, t2, t3;
#
# Test case for bug #8528: select from view over multi-table view
#
CREATE TABLE t1 (a int);
CREATE TABLE t2 (b int);
INSERT INTO t1 VALUES (1), (2), (3), (4);
INSERT INTO t2 VALUES (4), (2);
CREATE VIEW v1 AS SELECT * FROM t1,t2 WHERE t1.a=t2.b;
SELECT * FROM v1;
CREATE VIEW v2 AS SELECT * FROM v1;
SELECT * FROM v2;
DROP VIEW v2,v1;

View File

@ -50,9 +50,11 @@ const char *default_directories[MAX_DEFAULT_DIRS + 1];
#ifdef __WIN__
static const char *f_extensions[]= { ".ini", ".cnf", 0 };
#define NEWLINE "\r\n"
static char system_dir[FN_REFLEN], shared_system_dir[FN_REFLEN];
#else
static const char *f_extensions[]= { ".cnf", 0 };
#define NEWLINE "\n"
#endif
/*
@ -79,6 +81,141 @@ static void init_default_directories();
static char *remove_end_comment(char *ptr);
/*
Add/remove option to the option file section.
SYNOPSYS
my_correct_file()
file_location The location of configuration file to edit
option option to look for
option value The value of the option we would like to set
section_name the name of the section
remove_option This is true if we want to remove the option.
False otherwise.
IMPLEMENTATION
We open the option file first, then read the file line-by-line,
looking for the section we need. At the same time we put these lines
into a buffer. Then we look for the option within this section and
change/remove it. In the end we get a buffer with modified version of the
file. Then we write it to the file, truncate it if needed and close it.
RETURN
0 - ok
1 - some error has occured. Probably due to the lack of resourses
-1 - cannot open the file
*/
int my_correct_defaults_file(const char *file_location, const char *option,
const char *option_value,
const char *section_name, int remove_option)
{
FILE *cnf_file;
struct stat file_stat;
char linebuff[512], *ptr;
uint optlen;
uint len;
char *file_buffer;
uint position= 0;
int is_found= FALSE;
DBUG_ENTER("my_correct_defaults_file");
optlen= strlen(option);
if (!(cnf_file= my_fopen(file_location, O_RDWR, MYF(0))))
goto err_fopen;
/* my_fstat doesn't use the flag parameter */
if (my_fstat(fileno(cnf_file), &file_stat, MYF(0)))
goto err;
/*
Reserve space to read the contents of the file and some more
for the option we want ot add.
*/
file_buffer= (char*) my_malloc(sizeof(char)*
(file_stat.st_size + /* current file size */
optlen + /* option name len */
2 + /* reserve space for newline */
1 + /* reserve for '=' char */
strlen(option_value)), /* option value len */
MYF(MY_WME));
if (!file_buffer)
goto malloc_err;
while (fgets(linebuff, sizeof(linebuff), cnf_file))
{
len= strlen(linebuff);
/* if the section is found traverse it */
if (is_found)
{
/* skip the old value of the option we are changing */
if (strncmp(linebuff, option, optlen))
{
/* copy all other lines */
strmake(file_buffer + position, linebuff, len);
position+= len;
}
}
else
{
strmake(file_buffer + position, linebuff, len);
position+= len;
}
/* looking for appropriate section */
for (ptr= linebuff ; my_isspace(&my_charset_latin1,*ptr) ; ptr++)
{}
if (*ptr == '[')
{
/* copy the line to the buffer */
if (!strncmp(++ptr, section_name, strlen(section_name)))
{
is_found= TRUE;
/* add option */
if (!remove_option)
{
strmake(file_buffer + position, option, optlen);
position+= optlen;
if (*option_value)
{
*(file_buffer + position++)= '=';
strmake(file_buffer + position, option_value,
strlen(option_value));
position+= strlen(option_value);
}
/* add a newline */
strcat(file_buffer + position, NEWLINE);
position+= strlen(NEWLINE);
}
}
else
is_found= FALSE; /* mark that this section is of no interest to us */
}
}
if (my_chsize(fileno(cnf_file), position, 0, MYF(MY_WME)) ||
my_fseek(cnf_file, 0, MY_SEEK_SET, MYF(0)) ||
my_fwrite(cnf_file, file_buffer, position, MYF(MY_NABP)) ||
my_fclose(cnf_file, MYF(MY_WME)))
goto err;
my_free(file_buffer, MYF(0));
DBUG_RETURN(0);
err:
my_free(file_buffer, MYF(0));
malloc_err:
my_fclose(cnf_file, MYF(0));
DBUG_RETURN(1); /* out of resources */
err_fopen:
DBUG_RETURN(-1); /* cannot access the option file */
}
/*
Process config files in default directories.
@ -152,8 +289,8 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv,
}
else if (defaults_extra_file)
{
if (search_default_file_with_ext(func, func_ctx, "", "",
defaults_extra_file, 0) < 0)
if ((error= search_default_file_with_ext(func, func_ctx, "", "",
defaults_extra_file, 0)) < 0)
goto err; /* Fatal error */
if (error > 0)
{

View File

@ -30,7 +30,9 @@
MyFlags Flags
DESCRIPTION
my_chsize() truncates file if shorter else fill with the filler character
my_chsize() truncates file if shorter else fill with the filler character.
The function also changes the file pointer. Usually it points to the end
of the file after execution.
RETURN VALUE
0 Ok

View File

@ -409,7 +409,7 @@ static my_bool wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
result=0;
statistic_increment(locks_waited, &THR_LOCK_lock);
if (data->lock->get_status)
(*data->lock->get_status)(data->status_param);
(*data->lock->get_status)(data->status_param, 0);
check_locks(data->lock,"got wait_for_lock",0);
}
pthread_mutex_unlock(&data->lock->mutex);
@ -468,7 +468,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
lock->read_no_write_count++;
check_locks(lock,"read lock with old write lock",0);
if (lock->get_status)
(*lock->get_status)(data->status_param);
(*lock->get_status)(data->status_param, 0);
statistic_increment(locks_immediate,&THR_LOCK_lock);
goto end;
}
@ -489,7 +489,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
data->prev=lock->read.last;
lock->read.last= &data->next;
if (lock->get_status)
(*lock->get_status)(data->status_param);
(*lock->get_status)(data->status_param, 0);
if ((int) lock_type == (int) TL_READ_NO_INSERT)
lock->read_no_write_count++;
check_locks(lock,"read lock with no write locks",0);
@ -567,7 +567,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
lock->write.last= &data->next;
check_locks(lock,"second write lock",0);
if (data->lock->get_status)
(*data->lock->get_status)(data->status_param);
(*data->lock->get_status)(data->status_param, 0);
statistic_increment(locks_immediate,&THR_LOCK_lock);
goto end;
}
@ -580,9 +580,16 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
(ulong) lock->write_wait.data));
if (!lock->write_wait.data)
{ /* no scheduled write locks */
if (lock_type == TL_WRITE_CONCURRENT_INSERT &&
(*lock->check_status)(data->status_param))
data->type=lock_type= thr_upgraded_concurrent_insert_lock;
my_bool concurrent_insert= 0;
if (lock_type == TL_WRITE_CONCURRENT_INSERT)
{
concurrent_insert= 1;
if ((*lock->check_status)(data->status_param))
{
concurrent_insert= 0;
data->type=lock_type= thr_upgraded_concurrent_insert_lock;
}
}
if (!lock->read.data ||
(lock_type <= TL_WRITE_DELAYED &&
@ -594,7 +601,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
data->prev=lock->write.last;
lock->write.last= &data->next;
if (data->lock->get_status)
(*data->lock->get_status)(data->status_param);
(*data->lock->get_status)(data->status_param, concurrent_insert);
check_locks(lock,"only write lock",0);
statistic_increment(locks_immediate,&THR_LOCK_lock);
goto end;
@ -1033,7 +1040,7 @@ my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data)
if (!lock->read.data) /* No read locks */
{ /* We have the lock */
if (data->lock->get_status)
(*data->lock->get_status)(data->status_param);
(*data->lock->get_status)(data->status_param, 0);
pthread_mutex_unlock(&lock->mutex);
DBUG_RETURN(0);
}
@ -1221,7 +1228,8 @@ static ulong sum=0;
/* The following functions is for WRITE_CONCURRENT_INSERT */
static void test_get_status(void* param __attribute__((unused)))
static void test_get_status(void* param __attribute__((unused)),
int concurrent_insert __attribute__((unused)))
{
}

View File

@ -64,7 +64,7 @@ int Buffer::append(uint position, const char *string, uint len_arg)
DESCRIPTION
The method checks whether it is possible to pus a string of teh "len_arg"
The method checks whether it is possible to put a string of the "len_arg"
length into the buffer, starting from "position" byte. In the case when the
buffer is too small it reallocs the buffer. The total size of the buffer is
restricted with 16 Mb.
@ -81,7 +81,7 @@ int Buffer::reserve(uint position, uint len_arg)
if (position + len_arg >= buffer_size)
{
buffer= (char *) my_realloc(buffer,
buffer= (char*) my_realloc(buffer,
min(MAX_BUFFER_SIZE,
max((uint) (buffer_size*1.5),
position + len_arg)), MYF(0));

View File

@ -25,6 +25,40 @@
#include <m_string.h>
#include <mysql.h>
#include <my_dir.h>
/*
Add a string to a buffer
SYNOPSYS
put_to_buff()
buff buffer to add the string
str string to add
uint offset in the buff to add a string
DESCRIPTION
Function to add a string to the buffer. It is different from
store_to_string, which is used in the protocol.cc. The last
one also stores the length of the string in a special way.
This is required for MySQL client/server protocol support only.
RETURN
0 - ok
1 - error occured
*/
static inline int put_to_buff(Buffer *buff, const char *str, uint *position)
{
uint len= strlen(str);
if (buff->append(*position, str, len))
return 1;
*position+= len;
return 0;
}
/* implementation for Show_instances: */
@ -34,15 +68,16 @@
The method sends a list of instances in the instance map to the client.
SYNOPSYS
Show_instances::do_command()
net The network connection to the client.
Show_instances::execute()
net The network connection to the client.
connection_id Client connection ID
RETURN
0 - ok
1 - error occured
*/
int Show_instances::do_command(struct st_net *net)
int Show_instances::execute(struct st_net *net, ulong connection_id)
{
Buffer send_buff; /* buffer for packets */
LIST name, status;
@ -50,11 +85,11 @@ int Show_instances::do_command(struct st_net *net)
LIST *field_list;
uint position=0;
name_field.name= (char *) "instance_name";
name_field.length= 20;
name_field.name= (char*) "instance_name";
name_field.length= DEFAULT_FIELD_LENGTH;
name.data= &name_field;
status_field.name= (char *) "status";
status_field.length= 20;
status_field.name= (char*) "status";
status_field.length= DEFAULT_FIELD_LENGTH;
status.data= &status_field;
field_list= list_add(NULL, &status);
field_list= list_add(field_list, &name);
@ -71,9 +106,9 @@ int Show_instances::do_command(struct st_net *net)
position= 0;
store_to_string(&send_buff, instance->options.instance_name, &position);
if (instance->is_running())
store_to_string(&send_buff, (char *) "online", &position);
store_to_string(&send_buff, (char*) "online", &position);
else
store_to_string(&send_buff, (char *) "offline", &position);
store_to_string(&send_buff, (char*) "offline", &position);
if (my_net_write(net, send_buff.buffer, (uint) position))
goto err;
}
@ -86,16 +121,7 @@ int Show_instances::do_command(struct st_net *net)
return 0;
err:
return 1;
}
int Show_instances::execute(struct st_net *net, ulong connection_id)
{
if (do_command(net))
return ER_OUT_OF_RESOURCES;
return 0;
return ER_OUT_OF_RESOURCES;
}
@ -103,10 +129,10 @@ int Show_instances::execute(struct st_net *net, ulong connection_id)
int Flush_instances::execute(struct st_net *net, ulong connection_id)
{
if (instance_map->flush_instances())
if (instance_map->flush_instances() ||
net_send_ok(net, connection_id, NULL))
return ER_OUT_OF_RESOURCES;
net_send_ok(net, connection_id);
return 0;
}
@ -119,11 +145,9 @@ Show_instance_status::Show_instance_status(Instance_map *instance_map_arg,
{
Instance *instance;
/* we make a search here, since we don't want t store the name */
/* we make a search here, since we don't want to store the name */
if ((instance= instance_map->find(name, len)))
{
instance_name= instance->options.instance_name;
}
else
instance_name= NULL;
}
@ -143,8 +167,8 @@ Show_instance_status::Show_instance_status(Instance_map *instance_map_arg,
*/
int Show_instance_status::do_command(struct st_net *net,
const char *instance_name)
int Show_instance_status::execute(struct st_net *net,
ulong connection_id)
{
enum { MAX_VERSION_LENGTH= 40 };
Buffer send_buff; /* buffer for packets */
@ -153,14 +177,17 @@ int Show_instance_status::do_command(struct st_net *net,
NAME_WITH_LENGTH name_field, status_field, version_field;
uint position=0;
if (!instance_name)
return ER_BAD_INSTANCE_NAME;
/* create list of the fileds to be passed to send_fields */
name_field.name= (char *) "instance_name";
name_field.length= 20;
name_field.name= (char*) "instance_name";
name_field.length= DEFAULT_FIELD_LENGTH;
name.data= &name_field;
status_field.name= (char *) "status";
status_field.length= 20;
status_field.name= (char*) "status";
status_field.length= DEFAULT_FIELD_LENGTH;
status.data= &status_field;
version_field.name= (char *) "version";
version_field.name= (char*) "version";
version_field.length= MAX_VERSION_LENGTH;
version.data= &version_field;
field_list= list_add(NULL, &version);
@ -172,18 +199,18 @@ int Show_instance_status::do_command(struct st_net *net,
{
Instance *instance;
store_to_string(&send_buff, (char *) instance_name, &position);
store_to_string(&send_buff, (char*) instance_name, &position);
if (!(instance= instance_map->find(instance_name, strlen(instance_name))))
goto err;
if (instance->is_running())
{
store_to_string(&send_buff, (char *) "online", &position);
store_to_string(&send_buff, (char*) "online", &position);
store_to_string(&send_buff, "unknown", &position);
}
else
{
store_to_string(&send_buff, (char *) "offline", &position);
store_to_string(&send_buff, (char *) "unknown", &position);
store_to_string(&send_buff, (char*) "offline", &position);
store_to_string(&send_buff, (char*) "unknown", &position);
}
@ -192,28 +219,13 @@ int Show_instance_status::do_command(struct st_net *net,
goto err;
}
send_eof(net);
net_flush(net);
if (send_eof(net) || net_flush(net))
goto err;
return 0;
err:
return 1;
}
int Show_instance_status::execute(struct st_net *net, ulong connection_id)
{
if ((instance_name))
{
if (do_command(net, instance_name))
return ER_OUT_OF_RESOURCES;
return 0;
}
else
{
return ER_BAD_INSTANCE_NAME;
}
return ER_OUT_OF_RESOURCES;
}
@ -225,32 +237,31 @@ Show_instance_options::Show_instance_options(Instance_map *instance_map_arg,
{
Instance *instance;
/* we make a search here, since we don't want t store the name */
/* we make a search here, since we don't want to store the name */
if ((instance= instance_map->find(name, len)))
{
instance_name= instance->options.instance_name;
}
else
instance_name= NULL;
}
int Show_instance_options::do_command(struct st_net *net,
const char *instance_name)
int Show_instance_options::execute(struct st_net *net, ulong connection_id)
{
enum { MAX_VERSION_LENGTH= 40 };
Buffer send_buff; /* buffer for packets */
LIST name, option;
LIST *field_list;
NAME_WITH_LENGTH name_field, option_field;
uint position=0;
if (!instance_name)
return ER_BAD_INSTANCE_NAME;
/* create list of the fileds to be passed to send_fields */
name_field.name= (char *) "option_name";
name_field.length= 20;
name_field.name= (char*) "option_name";
name_field.length= DEFAULT_FIELD_LENGTH;
name.data= &name_field;
option_field.name= (char *) "value";
option_field.length= 20;
option_field.name= (char*) "value";
option_field.length= DEFAULT_FIELD_LENGTH;
option.data= &option_field;
field_list= list_add(NULL, &option);
field_list= list_add(field_list, &name);
@ -262,16 +273,16 @@ int Show_instance_options::do_command(struct st_net *net,
if (!(instance= instance_map->find(instance_name, strlen(instance_name))))
goto err;
store_to_string(&send_buff, (char *) "instance_name", &position);
store_to_string(&send_buff, (char *) instance_name, &position);
store_to_string(&send_buff, (char*) "instance_name", &position);
store_to_string(&send_buff, (char*) instance_name, &position);
if (my_net_write(net, send_buff.buffer, (uint) position))
goto err;
if ((instance->options.mysqld_path))
{
position= 0;
store_to_string(&send_buff, (char *) "mysqld-path", &position);
store_to_string(&send_buff, (char*) "mysqld-path", &position);
store_to_string(&send_buff,
(char *) instance->options.mysqld_path,
(char*) instance->options.mysqld_path,
&position);
if (send_buff.is_error() ||
my_net_write(net, send_buff.buffer, (uint) position))
@ -281,7 +292,7 @@ int Show_instance_options::do_command(struct st_net *net,
if ((instance->options.nonguarded))
{
position= 0;
store_to_string(&send_buff, (char *) "nonguarded", &position);
store_to_string(&send_buff, (char*) "nonguarded", &position);
store_to_string(&send_buff, "", &position);
if (send_buff.is_error() ||
my_net_write(net, send_buff.buffer, (uint) position))
@ -305,7 +316,8 @@ int Show_instance_options::do_command(struct st_net *net,
/* join name and the value into the same option again */
*option_value= '=';
}
else store_to_string(&send_buff, tmp_option + 2, &position);
else
store_to_string(&send_buff, tmp_option + 2, &position);
if (send_buff.is_error() ||
my_net_write(net, send_buff.buffer, (uint) position))
@ -313,28 +325,13 @@ int Show_instance_options::do_command(struct st_net *net,
}
}
send_eof(net);
net_flush(net);
if (send_eof(net) || net_flush(net))
goto err;
return 0;
err:
return 1;
}
int Show_instance_options::execute(struct st_net *net, ulong connection_id)
{
if ((instance_name))
{
if (do_command(net, instance_name))
return ER_OUT_OF_RESOURCES;
return 0;
}
else
{
return ER_BAD_INSTANCE_NAME;
}
return ER_OUT_OF_RESOURCES;
}
@ -344,7 +341,7 @@ Start_instance::Start_instance(Instance_map *instance_map_arg,
const char *name, uint len)
:Command(instance_map_arg)
{
/* we make a search here, since we don't want t store the name */
/* we make a search here, since we don't want to store the name */
if ((instance= instance_map->find(name, len)))
instance_name= instance->options.instance_name;
}
@ -354,9 +351,7 @@ int Start_instance::execute(struct st_net *net, ulong connection_id)
{
uint err_code;
if (instance == 0)
{
return ER_BAD_INSTANCE_NAME; /* haven't found an instance */
}
else
{
if ((err_code= instance->start()))
@ -365,19 +360,408 @@ int Start_instance::execute(struct st_net *net, ulong connection_id)
if (!(instance->options.nonguarded))
instance_map->guardian->guard(instance);
net_send_ok(net, connection_id);
net_send_ok(net, connection_id, "Instance started");
return 0;
}
}
/* implementation for Show_instance_log: */
Show_instance_log::Show_instance_log(Instance_map *instance_map_arg,
const char *name, uint len,
Log_type log_type_arg,
const char *size_arg,
const char *offset_arg)
:Command(instance_map_arg)
{
Instance *instance;
if (offset_arg != NULL)
offset= atoi(offset_arg);
else
offset= 0;
size= atoi(size_arg);
log_type= log_type_arg;
/* we make a search here, since we don't want to store the name */
if ((instance= instance_map->find(name, len)))
instance_name= instance->options.instance_name;
else
instance_name= NULL;
}
/*
Open the logfile, read requested part of the log and send the info
to the client.
SYNOPSYS
Show_instance_log::execute()
net The network connection to the client.
connection_id Client connection ID
DESCRIPTION
Send a table with the content of the log requested. The function also
deals with errro handling, to be verbose.
RETURN
ER_OFFSET_ERROR We were requested to read negative number of bytes
from the log
ER_NO_SUCH_LOG The kind log being read is not enabled in the instance
ER_GUESS_LOGFILE IM wasn't able to figure out the log placement, while
it is enabled. Probably user should specify the path
to the logfile explicitly.
ER_OPEN_LOGFILE Cannot open the logfile
ER_READ_FILE Cannot read the logfile
ER_OUT_OF_RESOURCES We weren't able to allocate some resources
*/
int Show_instance_log::execute(struct st_net *net, ulong connection_id)
{
Buffer send_buff; /* buffer for packets */
LIST name;
LIST *field_list;
NAME_WITH_LENGTH name_field;
uint position= 0;
/* create list of the fileds to be passed to send_fields */
name_field.name= (char*) "Log";
name_field.length= DEFAULT_FIELD_LENGTH;
name.data= &name_field;
field_list= list_add(NULL, &name);
if (!instance_name)
return ER_BAD_INSTANCE_NAME;
/* cannot read negative number of bytes */
if (offset > size)
return ER_OFFSET_ERROR;
send_fields(net, field_list);
{
Instance *instance;
const char *logpath;
File fd;
if ((instance= instance_map->find(instance_name,
strlen(instance_name))) == NULL)
goto err;
logpath= instance->options.logs[log_type];
/* Instance has no such log */
if (logpath == NULL)
return ER_NO_SUCH_LOG;
else if (*logpath == '\0')
return ER_GUESS_LOGFILE;
if ((fd= my_open(logpath, O_RDONLY | O_BINARY, MYF(MY_WME))) >= 0)
{
size_t buff_size;
int read_len;
/* calculate buffer size */
struct stat file_stat;
/* my_fstat doesn't use the flag parameter */
if (my_fstat(fd, &file_stat, MYF(0)))
goto err;
buff_size= (size - offset);
/* read in one chunk */
read_len= my_seek(fd, file_stat.st_size - size, MY_SEEK_SET, MYF(0));
char *bf= (char*) malloc(sizeof(char)*buff_size);
if ((read_len= my_read(fd, bf, buff_size, MYF(0))) < 0)
return ER_READ_FILE;
store_to_string(&send_buff, (char*) bf, &position, read_len);
close(fd);
}
else
return ER_OPEN_LOGFILE;
if (my_net_write(net, send_buff.buffer, (uint) position))
goto err;
}
if (send_eof(net) || net_flush(net))
goto err;
return 0;
err:
return ER_OUT_OF_RESOURCES;
}
/* implementation for Show_instance_log_files: */
Show_instance_log_files::Show_instance_log_files
(Instance_map *instance_map_arg, const char *name, uint len)
:Command(instance_map_arg)
{
Instance *instance;
/* we make a search here, since we don't want to store the name */
if ((instance= instance_map->find(name, len)))
instance_name= instance->options.instance_name;
else
instance_name= NULL;
}
/*
The method sends a table with a list of log files
used by the instance.
SYNOPSYS
Show_instance_log_files::execute()
net The network connection to the client.
connection_id The ID of the client connection
RETURN
ER_BAD_INSTANCE_NAME The instance name specified is not valid
ER_OUT_OF_RESOURCES some error occured
0 - ok
*/
int Show_instance_log_files::execute(struct st_net *net, ulong connection_id)
{
Buffer send_buff; /* buffer for packets */
LIST name, path, size;
LIST *field_list;
NAME_WITH_LENGTH name_field, path_field, size_field;
uint position= 0;
if (!instance_name)
return ER_BAD_INSTANCE_NAME;
/* create list of the fileds to be passed to send_fields */
name_field.name= (char*) "Logfile";
name_field.length= DEFAULT_FIELD_LENGTH;
name.data= &name_field;
path_field.name= (char*) "Path";
path_field.length= DEFAULT_FIELD_LENGTH;
path.data= &path_field;
size_field.name= (char*) "Filesize";
size_field.length= DEFAULT_FIELD_LENGTH;
size.data= &size_field;
field_list= list_add(NULL, &size);
field_list= list_add(field_list, &path);
field_list= list_add(field_list, &name);
send_fields(net, field_list);
Instance *instance;
if ((instance= instance_map->
find(instance_name, strlen(instance_name))) == NULL)
goto err;
{
/*
We have alike structure in instance_options.cc. We use such to be able
to loop through the options, which we need to handle in some common way.
*/
struct log_files_st
{
const char *name;
const char *value;
} logs[]=
{
{"ERROR LOG", instance->options.logs[LOG_ERROR]},
{"GENERAL LOG", instance->options.logs[LOG_GENERAL]},
{"SLOW LOG", instance->options.logs[LOG_SLOW]},
{NULL, NULL}
};
struct log_files_st *log_files;
for (log_files= logs; log_files->name; log_files++)
{
if (log_files->value != NULL)
{
struct stat file_stat;
/*
Save some more space for the log file names. In fact all
we need is srtlen("GENERAL_LOG") + 1
*/
enum { LOG_NAME_BUFFER_SIZE= 20 };
char buff[LOG_NAME_BUFFER_SIZE];
position= 0;
/* store the type of the log in the send buffer */
store_to_string(&send_buff, log_files->name, &position);
if (stat(log_files->value, &file_stat))
{
store_to_string(&send_buff, "", &position);
store_to_string(&send_buff, (char*) "0", &position);
}
else if (S_ISREG(file_stat.st_mode))
{
store_to_string(&send_buff,
(char*) log_files->value,
&position);
int10_to_str(file_stat.st_size, buff, 10);
store_to_string(&send_buff, (char*) buff, &position);
}
if (my_net_write(net, send_buff.buffer, (uint) position))
goto err;
}
}
}
if (send_eof(net) || net_flush(net))
goto err;
return 0;
err:
return ER_OUT_OF_RESOURCES;
}
/* implementation for SET instance_name.option=option_value: */
Set_option::Set_option(Instance_map *instance_map_arg,
const char *name, uint len,
const char *option_arg, uint option_len_arg,
const char *option_value_arg, uint option_value_len_arg)
:Command(instance_map_arg)
{
Instance *instance;
/* we make a search here, since we don't want to store the name */
if ((instance= instance_map->find(name, len)))
{
instance_name= instance->options.instance_name;
/* add prefix for add_option */
if ((option_len_arg < MAX_OPTION_LEN - 1) ||
(option_value_len_arg < MAX_OPTION_LEN - 1))
{
strmake(option, option_arg, option_len_arg);
strmake(option_value, option_value_arg, option_value_len_arg);
/* strncpy(option, option_arg, option_len_arg);
option[option_len_arg]= 0;
strncpy(option_value, option_value_arg, option_value_len_arg);
option_value[option_value_len_arg]= 0; */
}
else
{
option[0]= 0;
option_value[0]= 0;
}
instance_name_len= len;
}
else
{
instance_name= NULL;
instance_name_len= 0;
}
}
/*
The method sends a table with a list of log files
used by the instance.
SYNOPSYS
Set_option::correct_file()
skip Skip the option, being searched while writing the result file.
That is, to delete it.
DESCRIPTION
Correct the option file. The "skip" option is used to remove the found
option.
RETURN
ER_BAD_INSTANCE_NAME The instance name specified is not valid
ER_ACCESS_OPTION_FILE Cannot access the option file
0 - ok
*/
int Set_option::correct_file(int skip)
{
int error;
error= my_correct_defaults_file("/etc/my.cnf", option,
option_value, instance_name, skip);
if (error > 0)
return ER_OUT_OF_RESOURCES;
else if (error < 0)
return ER_ACCESS_OPTION_FILE;
/* everything was fine */
return 0;
}
/*
The method sets an option in the the default config file (/etc/my.cnf).
SYNOPSYS
Set_option::do_command()
net The network connection to the client.
RETURN
0 - ok
1 - error occured
*/
int Set_option::do_command(struct st_net *net)
{
int error= 0;
/* we must hold the instance_map mutex while changing config file */
instance_map->lock();
error= correct_file(FALSE);
instance_map->unlock();
return error;
}
int Set_option::execute(struct st_net *net, ulong connection_id)
{
if (instance_name != NULL)
{
int val;
val= do_command(net);
if (val == 0)
{
net_send_ok(net, connection_id, NULL);
return 0;
}
return val;
}
else
return ER_BAD_INSTANCE_NAME;
}
/* the only function from Unset_option we need to Implement */
int Unset_option::do_command(struct st_net *net)
{
return correct_file(TRUE);
}
/* Implementation for Stop_instance: */
Stop_instance::Stop_instance(Instance_map *instance_map_arg,
const char *name, uint len)
:Command(instance_map_arg)
{
/* we make a search here, since we don't want t store the name */
/* we make a search here, since we don't want to store the name */
if ((instance= instance_map->find(name, len)))
instance_name= instance->options.instance_name;
}
@ -388,9 +772,7 @@ int Stop_instance::execute(struct st_net *net, ulong connection_id)
uint err_code;
if (instance == 0)
{
return ER_BAD_INSTANCE_NAME; /* haven't found an instance */
}
else
{
if (!(instance->options.nonguarded))
@ -398,7 +780,7 @@ int Stop_instance::execute(struct st_net *net, ulong connection_id)
stop_guard(instance);
if ((err_code= instance->stop()))
return err_code;
net_send_ok(net, connection_id);
net_send_ok(net, connection_id, NULL);
return 0;
}
}

View File

@ -18,6 +18,7 @@
#include "command.h"
#include "instance.h"
#include "parse.h"
/*
Print all instances of this instance manager.
@ -30,7 +31,6 @@ public:
Show_instances(Instance_map *instance_map_arg): Command(instance_map_arg)
{}
int do_command(struct st_net *net);
int execute(struct st_net *net, ulong connection_id);
};
@ -59,8 +59,8 @@ class Show_instance_status : public Command
{
public:
Show_instance_status(Instance_map *instance_map_arg, const char *name, uint len);
int do_command(struct st_net *net, const char *instance_name);
Show_instance_status(Instance_map *instance_map_arg,
const char *name, uint len);
int execute(struct st_net *net, ulong connection_id);
const char *instance_name;
};
@ -75,10 +75,10 @@ class Show_instance_options : public Command
{
public:
Show_instance_options(Instance_map *instance_map_arg, const char *name, uint len);
Show_instance_options(Instance_map *instance_map_arg,
const char *name, uint len);
int execute(struct st_net *net, ulong connection_id);
int do_command(struct st_net *net, const char *instance_name);
const char *instance_name;
};
@ -116,10 +116,48 @@ public:
/*
Syntax error command. This command is issued if parser reported a syntax error.
We need it to distinguish the parse error and the situation when parser internal
error occured. E.g. parsing failed because we hadn't had enought memory. In the
latter case parse_command() should return an error.
Print requested part of the log
Grammar:
SHOW <instance_name> log {ERROR | SLOW | GENERAL} size[, offset_from_end]
*/
class Show_instance_log : public Command
{
public:
Show_instance_log(Instance_map *instance_map_arg, const char *name,
uint len, Log_type log_type_arg, const char *size_arg,
const char *offset_arg);
int execute(struct st_net *net, ulong connection_id);
Log_type log_type;
const char *instance_name;
uint size;
uint offset;
};
/*
Shows the list of the log files, used by an instance.
Grammar: SHOW <instance_name> LOG FILES
*/
class Show_instance_log_files : public Command
{
public:
Show_instance_log_files(Instance_map *instance_map_arg,
const char *name, uint len);
int execute(struct st_net *net, ulong connection_id);
const char *instance_name;
const char *option;
};
/*
Syntax error command. This command is issued if parser reported a syntax
error. We need it to distinguish the parse error and the situation when
parser internal error occured. E.g. parsing failed because we hadn't had
enought memory. In the latter case parse_command() should return an error.
*/
class Syntax_error : public Command
@ -128,4 +166,50 @@ public:
int execute(struct st_net *net, ulong connection_id);
};
/*
Set an option for the instance.
Grammar: SET instance_name.option=option_value
*/
class Set_option : public Command
{
public:
Set_option(Instance_map *instance_map_arg, const char *name, uint len,
const char *option_arg, uint option_len,
const char *option_value_arg, uint option_value_len);
/*
the following function is virtual to let Unset_option to use
*/
virtual int do_command(struct st_net *net);
int execute(struct st_net *net, ulong connection_id);
protected:
int correct_file(int skip);
public:
const char *instance_name;
uint instance_name_len;
/* buffer for the option */
enum { MAX_OPTION_LEN= 1024 };
char option[MAX_OPTION_LEN];
char option_value[MAX_OPTION_LEN];
};
/*
Remove option of the instance from config file
Grammar: UNSET instance_name.option
*/
class Unset_option: public Set_option
{
public:
Unset_option(Instance_map *instance_map_arg, const char *name, uint len,
const char *option_arg, uint option_len,
const char *option_value_arg, uint option_value_len):
Set_option(instance_map_arg, name, len, option_arg, option_len,
option_value_arg, option_value_len)
{}
int do_command(struct st_net *net);
};
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_COMMANDS_H */

View File

@ -16,40 +16,85 @@
#include "factory.h"
Show_instances *Command_factory::new_Show_instances()
{
return new Show_instances(&instance_map);
}
Flush_instances *Command_factory::new_Flush_instances()
{
return new Flush_instances(&instance_map);
}
Show_instance_status *Command_factory::
new_Show_instance_status(const char *name, uint len)
{
return new Show_instance_status(&instance_map, name, len);
}
Show_instance_options *Command_factory::
new_Show_instance_options(const char *name, uint len)
{
return new Show_instance_options(&instance_map, name, len);
}
Start_instance *Command_factory::
new_Start_instance(const char *name, uint len)
{
return new Start_instance(&instance_map, name, len);
}
Stop_instance *Command_factory::new_Stop_instance(const char *name, uint len)
{
return new Stop_instance(&instance_map, name, len);
}
Syntax_error *Command_factory::new_Syntax_error()
{
return new Syntax_error();
}
Set_option *Command_factory::
new_Set_option(const char* name, uint len,
const char *option_arg, uint option_len,
const char *option_value_arg, uint option_value_len)
{
return new Set_option(&instance_map, name, len, option_arg,
option_len, option_value_arg, option_value_len);
}
Unset_option *Command_factory::
new_Unset_option(const char* name, uint len,
const char *option_arg, uint option_len,
const char *option_value_arg, uint option_value_len)
{
return new Unset_option(&instance_map, name, len, option_arg,
option_len, option_value_arg, option_value_len);
}
Show_instance_log *Command_factory::
new_Show_instance_log(const char *name, uint len,
Log_type log_type_arg,
const char *size, const char *offset)
{
return new Show_instance_log(&instance_map, name, len,
log_type_arg, size, offset);
}
Show_instance_log_files *Command_factory::
new_Show_instance_log_files(const char *name, uint len)
{
return new Show_instance_log_files(&instance_map, name, len);
}

View File

@ -26,6 +26,8 @@
Http_command_factory e.t.c. Also see comment in the instance_map.cc
*/
class Show_instances;
class Command_factory
{
public:
@ -33,12 +35,26 @@ public:
{}
Show_instances *new_Show_instances ();
Flush_instances *new_Flush_instances ();
Syntax_error *new_Syntax_error ();
Show_instance_status *new_Show_instance_status (const char *name, uint len);
Show_instance_options *new_Show_instance_options (const char *name, uint len);
Start_instance *new_Start_instance (const char *name, uint len);
Stop_instance *new_Stop_instance (const char *name, uint len);
Flush_instances *new_Flush_instances ();
Syntax_error *new_Syntax_error ();
Show_instance_log *new_Show_instance_log (const char *name, uint len,
Log_type log_type_arg,
const char *size,
const char *offset);
Set_option *new_Set_option (const char *name, uint len,
const char *option_arg, uint option_len,
const char *option_value_arg,
uint option_value_len);
Unset_option *new_Unset_option (const char *name, uint len,
const char *option_arg, uint option_len,
const char *option_value_arg,
uint option_value_len);
Show_instance_log_files *new_Show_instance_log_files (const char *name,
uint len);
Instance_map &instance_map;
};

View File

@ -315,7 +315,7 @@ int Guardian_thread::guard(Instance *instance, bool nolock)
content->restart_counter= 0;
content->crash_moment= 0;
content->state= NOT_STARTED;
node->data= (void *) content;
node->data= (void*) content;
if (nolock)
guarded_instances= list_add(guarded_instances, node);

View File

@ -304,12 +304,11 @@ void Instance::kill_instance(int signum)
*/
if (!kill(pid, signum))
options.unlink_pidfile();
else
if (signum == SIGKILL) /* really killed instance with SIGKILL */
log_error("The instance %s is being stopped forsibly. Normally \
it should not happed. Probably the instance has been \
hanging. You should also check your IM setup",
options.instance_name);
else if (signum == SIGKILL) /* really killed instance with SIGKILL */
log_error("The instance %s is being stopped forsibly. Normally \
it should not happed. Probably the instance has been \
hanging. You should also check your IM setup",
options.instance_name);
}
return;
}

View File

@ -246,7 +246,7 @@ int Instance_map::load()
argv_options[1]= '\0';
if (my_search_option_files("my", &argc, (char ***) &argv, &args_used,
process_option, (void *) this) ||
process_option, (void*) this) ||
complete_initialization())
return 1;

View File

@ -24,7 +24,6 @@
#include "buffer.h"
#include <my_sys.h>
#include <mysql.h>
#include <signal.h>
#include <m_string.h>
@ -36,7 +35,7 @@
get_default_option()
result buffer to put found value
result_len buffer size
oprion_name the name of the option, prefixed with "--"
option_name the name of the option, prefixed with "--"
DESCRIPTION
@ -47,6 +46,7 @@
1 - error occured
*/
int Instance_options::get_default_option(char *result, size_t result_len,
const char *option_name)
{
@ -54,7 +54,7 @@ int Instance_options::get_default_option(char *result, size_t result_len,
int rc= 1;
char verbose_option[]= " --no-defaults --verbose --help";
Buffer cmd(strlen(mysqld_path)+sizeof(verbose_option)+1);
Buffer cmd(strlen(mysqld_path) + sizeof(verbose_option) + 1);
if (cmd.get_size()) /* malloc succeeded */
{
cmd.append(position, mysqld_path, strlen(mysqld_path));
@ -76,6 +76,146 @@ err:
}
/*
Get compiled-in value of default_option
SYNOPSYS
get_default_option()
result buffer to put found value
result_len buffer size
option_name the name of the option, prefixed with "--"
DESCRIPTION
Get compile-in value of requested option from server
RETURN
0 - ok
1 - error occured
*/
int Instance_options::fill_log_options()
{
Buffer buff;
uint position= 0;
char **tmp_argv= argv;
enum { MAX_LOG_OPTION_LENGTH= 256 };
char datadir[MAX_LOG_OPTION_LENGTH];
char hostname[MAX_LOG_OPTION_LENGTH];
uint hostname_length;
struct log_files_st
{
const char *name;
uint length;
char **value;
const char *default_suffix;
} logs_st[]=
{
{"--log-error", 11, &(logs[LOG_ERROR]), ".err"},
{"--log", 5, &(logs[LOG_GENERAL]), ".log"},
{"--log-slow-queries", 18, &(logs[LOG_SLOW]), "-slow.log"},
{NULL, 0, NULL, NULL}
};
struct log_files_st *log_files;
/* compute hostname and datadir for the instance */
if (mysqld_datadir == NULL)
{
if (get_default_option(datadir,
MAX_LOG_OPTION_LENGTH, "--datadir"))
goto err;
}
else /* below is safe, as --datadir always has a value */
strncpy(datadir, strchr(mysqld_datadir, '=') + 1,
MAX_LOG_OPTION_LENGTH);
if (gethostname(hostname,sizeof(hostname)-1) < 0)
strmov(hostname, "mysql");
hostname[MAX_LOG_OPTION_LENGTH - 1]= 0; /* Safety */
hostname_length= strlen(hostname);
for (log_files= logs_st; log_files->name; log_files++)
{
for (int i=0; (argv[i] != 0); i++)
{
if (!strncmp(argv[i], log_files->name, log_files->length))
{
/*
This is really log_files->name option if and only if it is followed
by '=', '\0' or space character. This way we can distinguish such
options as '--log' and '--log-bin'. This is checked in the following
two statements.
*/
if (argv[i][log_files->length] == '\0' ||
my_isspace(default_charset_info, argv[i][log_files->length]))
{
char full_name[MAX_LOG_OPTION_LENGTH];
fn_format(full_name, hostname, datadir, "",
MY_UNPACK_FILENAME | MY_SAFE_PATH);
if ((MAX_LOG_OPTION_LENGTH - strlen(full_name)) >
strlen(log_files->default_suffix))
{
strcpy(full_name + strlen(full_name),
log_files->default_suffix);
}
else
goto err;
/*
If there were specified two identical logfiles options,
we would loose some memory in MEM_ROOT here. However
this situation is not typical.
*/
*(log_files->value)= strdup_root(&alloc, full_name);
}
if (argv[i][log_files->length] == '=')
{
char full_name[MAX_LOG_OPTION_LENGTH];
fn_format(full_name, argv[i] +log_files->length + 1,
datadir, "", MY_UNPACK_FILENAME | MY_SAFE_PATH);
if (!(*(log_files->value)=
strdup_root(&alloc, full_name)))
goto err;
}
}
}
}
return 0;
err:
return 1;
}
/*
Get the full pid file name with path
SYNOPSYS
get_pid_filaname()
result buffer to sotre the pidfile value
IMPLEMENTATION
Get the data directory, then get the pid filename
(which is always set for an instance), then load the
full path with my_load_path(). It takes into account
whether it is already an absolute path or it should be
prefixed with the datadir and so on.
RETURN
0 - ok
1 - error occured
*/
int Instance_options::get_pid_filename(char *result)
{
const char *pid_file= mysqld_pid_file;
@ -190,6 +330,8 @@ int Instance_options::complete_initialization(const char *default_path,
options_array.elements*sizeof(char*));
argv[filled_default_options + options_array.elements]= 0;
fill_log_options();
return 0;
err:
@ -274,7 +416,7 @@ int Instance_options::add_to_argv(const char* option)
DBUG_ASSERT(filled_default_options < MAX_NUMBER_OF_DEFAULT_OPTIONS);
if ((option))
argv[filled_default_options++]= (char *) option;
argv[filled_default_options++]= (char*) option;
return 0;
}
@ -302,10 +444,10 @@ int Instance_options::init(const char *instance_name_arg)
init_alloc_root(&alloc, MEM_ROOT_BLOCK_SIZE, 0);
if (my_init_dynamic_array(&options_array, sizeof(char *), 0, 32))
if (my_init_dynamic_array(&options_array, sizeof(char*), 0, 32))
goto err;
if (!(instance_name= strmake_root(&alloc, (char *) instance_name_arg,
if (!(instance_name= strmake_root(&alloc, (char*) instance_name_arg,
instance_name_len)))
goto err;

View File

@ -18,6 +18,7 @@
#include <my_global.h>
#include <my_sys.h>
#include "parse.h"
#ifdef __GNUC__
#pragma interface
@ -76,9 +77,13 @@ public:
const char *nonguarded;
const char *shutdown_delay;
uint shutdown_delay_val;
/* log enums are defined in parse.h */
char *logs[3];
/* this value is computed and cashed here */
DYNAMIC_ARRAY options_array;
private:
int fill_log_options();
int add_to_argv(const char *option);
int get_default_option(char *result, size_t result_len,
const char *option_name);

View File

@ -241,23 +241,20 @@ void Listener_thread::run()
}
}
}
else
if (FD_ISSET(ip_socket, &read_fds_arg))
else if (FD_ISSET(ip_socket, &read_fds_arg))
{
int client_fd= accept(ip_socket, 0, 0);
/* accept may return -1 (failure or spurious wakeup) */
if (client_fd >= 0) // connection established
{
int client_fd= accept(ip_socket, 0, 0);
/* accept may return -1 (failure or spurious wakeup) */
if (client_fd >= 0) // connection established
if (Vio *vio= vio_new(client_fd, VIO_TYPE_TCPIP, 0))
handle_new_mysql_connection(vio);
else
{
if (Vio *vio= vio_new(client_fd, VIO_TYPE_TCPIP, 0))
{
handle_new_mysql_connection(vio);
}
else
{
shutdown(client_fd, SHUT_RDWR);
close(client_fd);
}
shutdown(client_fd, SHUT_RDWR);
close(client_fd);
}
}
}
}
}

View File

@ -70,7 +70,7 @@ static inline void log(FILE *file, const char *format, va_list args)
if (n < 0 || n == sizeof(buff_stack))
{
int size= sizeof(buff_stack) * 2;
buff_msg= (char *) my_malloc(size, 0);
buff_msg= (char*) my_malloc(size, MYF(0));
while (true)
{
if (buff_msg == 0)
@ -86,16 +86,16 @@ static inline void log(FILE *file, const char *format, va_list args)
size*= 2;
/* realloc() does unnecessary memcpy */
my_free(buff_msg, 0);
buff_msg= (char *) my_malloc(size, 0);
buff_msg= (char*) my_malloc(size, MYF(0));
}
}
else if ((size_t) n > sizeof(buff_stack))
{
buff_msg= (char *) my_malloc(n + 1, 0);
buff_msg= (char*) my_malloc(n + 1, MYF(0));
#ifdef DBUG
DBUG_ASSERT(n == vsnprintf(buff_msg, n + 1, format, args));
#else
vsnprintf(buff_msg, n + 1, format, args);
vsnprintf(buff_msg, n + 1, format, args);
#endif
}
fprintf(file, "%s%s\n", buff_date, buff_msg);

View File

@ -197,8 +197,7 @@ void manager(const Options &options)
goto err;
}
switch (signo)
{
switch (signo) {
case THR_SERVER_ALARM:
process_alarm(signo);
break;

View File

@ -55,8 +55,21 @@ static const char *mysqld_error_message(unsigned sql_errno)
case ER_CANNOT_START_INSTANCE:
return "Cannot start instance. Possible reasons are wrong instance options"
" or resources shortage";
case ER_OFFSET_ERROR:
return "Cannot read negative number of bytes";
case ER_STOP_INSTANCE:
return "Cannot stop instance";
case ER_READ_FILE:
return "Cannot read requested part of the logfile";
case ER_NO_SUCH_LOG:
return "The instance has no such log enabled";
case ER_OPEN_LOGFILE:
return "Cannot open log file";
case ER_GUESS_LOGFILE:
return "Cannot guess the log filename. Try specifying full log name"
"in the instance options";
case ER_ACCESS_OPTION_FILE:
return "Cannot open the option file to edit. Check permissions";
default:
DBUG_ASSERT(0);
return 0;

View File

@ -261,10 +261,10 @@ int Mysql_connection_thread::check_connection()
}
client_capabilities|= ((ulong) uint2korr(net.read_pos + 2)) << 16;
pos= (char *) net.read_pos + 32;
pos= (char*) net.read_pos + 32;
/* At least one byte for username and one byte for password */
if (pos >= (char *) net.read_pos + pkt_len + 2)
if (pos >= (char*) net.read_pos + pkt_len + 2)
{
/*TODO add user and password handling in error messages*/
net_send_error(&net, ER_HANDSHAKE_ERROR);
@ -284,7 +284,7 @@ int Mysql_connection_thread::check_connection()
net_send_error(&net, ER_ACCESS_DENIED_ERROR);
return 1;
}
net_send_ok(&net, connection_id);
net_send_ok(&net, connection_id, NULL);
return 0;
}
@ -301,9 +301,7 @@ int Mysql_connection_thread::do_command()
{
/* Check if we can continue without closing the connection */
if (net.error != 3) // what is 3 - find out
{
return 1;
}
if (thread_registry.is_shutdown())
return 1;
net_send_error(&net, net.last_errno);
@ -332,7 +330,7 @@ int Mysql_connection_thread::dispatch_command(enum enum_server_command command,
return 1;
case COM_PING:
log_info("query for connection %d received ping command", connection_id);
net_send_ok(&net, connection_id);
net_send_ok(&net, connection_id, NULL);
break;
case COM_QUERY:
{
@ -346,14 +344,12 @@ int Mysql_connection_thread::dispatch_command(enum enum_server_command command,
res= command->execute(&net, connection_id);
delete command;
if (!res)
{
log_info("query for connection %d executed ok",connection_id);
}
log_info("query for connection %d executed ok",connection_id);
else
{
log_info("query for connection %d executed err=%d",connection_id,res);
net_send_error(&net, res);
return 0;
log_info("query for connection %d executed err=%d",connection_id,res);
net_send_error(&net, res);
return 0;
}
}
else

View File

@ -23,5 +23,11 @@
#define ER_INSTANCE_ALREADY_STARTED 3002
#define ER_CANNOT_START_INSTANCE 3003
#define ER_STOP_INSTANCE 3004
#define ER_NO_SUCH_LOG 3005
#define ER_OPEN_LOGFILE 3006
#define ER_GUESS_LOGFILE 3007
#define ER_ACCESS_OPTION_FILE 3008
#define ER_OFFSET_ERROR 3009
#define ER_READ_FILE 3010
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_MYSQL_MANAGER_ERROR_H */

View File

@ -136,7 +136,8 @@ static struct passwd *check_user(const char *user)
{
/* Allow a numeric uid to be used */
const char *pos;
for (pos= user; my_isdigit(default_charset_info, *pos); pos++) ;
for (pos= user; my_isdigit(default_charset_info, *pos); pos++)
{}
if (*pos) /* Not numeric id */
goto err;
if (!(user_info= getpwuid(atoi(user))))

View File

@ -158,7 +158,7 @@ static void passwd()
fprintf(stderr, "Creating record for new user.\n");
fprintf(stderr, "Enter user name: ");
if (! fgets(user, sizeof(user), stdin))
if (!fgets(user, sizeof(user), stdin))
{
fprintf(stderr, "Unable to read user.\n");
return;

View File

@ -15,38 +15,56 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "parse.h"
#include "factory.h"
#include <string.h>
enum Token
{
TOK_FLUSH = 0,
TOK_ERROR= 0, /* Encodes the "ERROR" word, it doesn't indicate error. */
TOK_FILES,
TOK_FLUSH,
TOK_GENERAL,
TOK_INSTANCE,
TOK_INSTANCES,
TOK_LOG,
TOK_OPTIONS,
TOK_SET,
TOK_SLOW,
TOK_START,
TOK_STATUS,
TOK_STOP,
TOK_SHOW,
TOK_UNSET,
TOK_NOT_FOUND, // must be after all tokens
TOK_END
};
struct tokens_st
{
uint length;
const char *tok_name;
};
static struct tokens_st tokens[]= {
{5, "ERROR"},
{5, "FILES"},
{5, "FLUSH"},
{7, "GENERAL"},
{8, "INSTANCE"},
{9, "INSTANCES"},
{3, "LOG"},
{7, "OPTIONS"},
{3, "SET"},
{4, "SLOW"},
{5, "START"},
{6, "STATUS"},
{4, "STOP"},
{4, "SHOW"}
{4, "SHOW"},
{5, "UNSET"}
};
@ -86,13 +104,6 @@ Token shift_token(const char **text, uint *word_len)
}
void print_token(const char *token, uint tok_len)
{
for (uint i= 0; i < tok_len; ++i)
printf("%c", token[i]);
}
int get_text_id(const char **text, uint *word_len, const char **id)
{
get_word(text, word_len);
@ -108,7 +119,15 @@ Command *parse_command(Command_factory *factory, const char *text)
uint word_len;
const char *instance_name;
uint instance_name_len;
const char *option;
uint option_len;
const char *option_value;
uint option_value_len;
const char *log_size;
Command *command;
const char *saved_text= text;
bool skip= false;
const char *tmp;
Token tok1= shift_token(&text, &word_len);
@ -143,6 +162,53 @@ Command *parse_command(Command_factory *factory, const char *text)
command= factory->new_Flush_instances();
break;
case TOK_UNSET:
skip= true;
case TOK_SET:
get_text_id(&text, &instance_name_len, &instance_name);
text+= instance_name_len;
/* the next token should be a dot */
get_word(&text, &word_len);
if (*text != '.')
goto syntax_error;
text++;
get_word(&text, &option_len, NONSPACE);
option= text;
if ((tmp= strchr(text, '=')) != NULL)
option_len= tmp - text;
text+= option_len;
get_word(&text, &word_len);
if (*text == '=')
{
text++; /* skip '=' */
get_word(&text, &option_value_len, NONSPACE);
option_value= text;
text+= option_value_len;
}
else
{
option_value= "";
option_value_len= 0;
}
/* should be empty */
get_word(&text, &word_len);
if (word_len)
goto syntax_error;
if (skip)
command= factory->new_Unset_option(instance_name, instance_name_len,
option, option_len, option_value,
option_value_len);
else
command= factory->new_Set_option(instance_name, instance_name_len,
option, option_len, option_value,
option_value_len);
break;
case TOK_SHOW:
switch (shift_token(&text, &word_len)) {
case TOK_INSTANCES:
@ -157,6 +223,7 @@ Command *parse_command(Command_factory *factory, const char *text)
case TOK_STATUS:
get_text_id(&text, &instance_name_len, &instance_name);
text+= instance_name_len;
/* check that this is the end of the command */
get_word(&text, &word_len);
if (word_len)
goto syntax_error;
@ -172,7 +239,87 @@ Command *parse_command(Command_factory *factory, const char *text)
}
break;
default:
goto syntax_error;
instance_name= text - word_len;
instance_name_len= word_len;
if (instance_name_len)
{
Log_type log_type;
switch (shift_token(&text, &word_len)) {
case TOK_LOG:
switch (Token tok3= shift_token(&text, &word_len)) {
case TOK_FILES:
get_word(&text, &word_len);
/* check that this is the end of the command */
if (word_len)
goto syntax_error;
command= (Command *)
factory->new_Show_instance_log_files(instance_name,
instance_name_len);
break;
case TOK_ERROR:
case TOK_GENERAL:
case TOK_SLOW:
/* define a log type */
switch (tok3) {
case TOK_ERROR:
log_type= LOG_ERROR;
break;
case TOK_GENERAL:
log_type= LOG_GENERAL;
break;
case TOK_SLOW:
log_type= LOG_SLOW;
break;
default:
goto syntax_error;
}
/* get the size of the log we want to retrieve */
get_text_id(&text, &word_len, &log_size);
text+= word_len;
/* this parameter is required */
if (!word_len)
goto syntax_error;
/* the next token should be comma, or nothing */
get_word(&text, &word_len);
switch (*text) {
case ',':
text++; /* swallow the comma */
/* read the next word */
get_word(&text, &word_len);
if (!word_len)
goto syntax_error;
command= (Command *)
factory->new_Show_instance_log(instance_name,
instance_name_len,
log_type,
log_size,
text);
//get_text_id(&text, &log_size_len, &log_size);
break;
case '\0':
command= (Command *)
factory->new_Show_instance_log(instance_name,
instance_name_len,
log_type,
log_size,
NULL);
break; /* this is ok */
default:
goto syntax_error;
}
break;
default:
goto syntax_error;
}
break;
default:
goto syntax_error;
}
}
else
goto syntax_error;
break;
}
break;
default:
@ -181,4 +328,3 @@ syntax_error:
}
return command;
}

View File

@ -16,7 +16,18 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "factory.h"
#include <my_global.h>
#include <my_sys.h>
class Command;
class Command_factory;
enum Log_type
{
LOG_ERROR= 0,
LOG_GENERAL,
LOG_SLOW
};
Command *parse_command(Command_factory *factory, const char *text);
@ -44,10 +55,12 @@ inline void get_word(const char **text, uint *word_len,
while (my_isalnum(default_charset_info, *word_end))
++word_end;
else
while (!my_isspace(default_charset_info, *word_end))
while (!my_isspace(default_charset_info, *word_end) &&
(*word_end != '\0'))
++word_end;
*word_len= word_end - *text;
}
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_PARSE_H */

View File

@ -47,7 +47,7 @@ int parse_output_and_get_value(const char *command, const char *word,
{
FILE *output;
uint wordlen;
/* should be enought to store the string from the output */
/* should be enough to store the string from the output */
enum { MAX_LINE_LEN= 512 };
char linebuf[MAX_LINE_LEN];
@ -99,3 +99,4 @@ pclose:
err:
return 1;
}

View File

@ -1,3 +1,5 @@
#ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_PARSE_OUTPUT_H
#define INCLUDES_MYSQL_INSTANCE_MANAGER_PARSE_OUTPUT_H
/* Copyright (C) 2004 MySQL AB
This program is free software; you can redistribute it and/or modify
@ -17,3 +19,4 @@
int parse_output_and_get_value(const char *command, const char *word,
char *result, size_t result_len);
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_PARSE_OUTPUT_H */

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