Merge maint2.mysql.com:/data/localhome/tsmith/bk/mrg/g51

into  maint2.mysql.com:/data/localhome/tsmith/bk/mrg/51


libmysqld/libmysqld.def:
  Auto merged
mysql-test/t/handler.test:
  Auto merged
sql/log.cc:
  Auto merged
sql-common/client.c:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
This commit is contained in:
unknown 2006-09-12 19:40:00 +02:00
commit bc053aa0a1
221 changed files with 11572 additions and 9808 deletions

View File

@ -692,6 +692,7 @@ mysql-test/*.ds?
mysql-test/*.vcproj mysql-test/*.vcproj
mysql-test/gmon.out mysql-test/gmon.out
mysql-test/install_test_db mysql-test/install_test_db
mysql-test/mtr
mysql-test/mysql-test-run mysql-test/mysql-test-run
mysql-test/mysql-test-run.log mysql-test/mysql-test-run.log
mysql-test/mysql_test_run_new mysql-test/mysql_test_run_new
@ -1170,6 +1171,7 @@ sql/*.ds?
sql/*.vcproj sql/*.vcproj
sql/.gdbinit sql/.gdbinit
sql/client.c sql/client.c
sql/f.c
sql/gen_lex_hash sql/gen_lex_hash
sql/gmon.out sql/gmon.out
sql/handlerton.cc sql/handlerton.cc

View File

@ -51,7 +51,7 @@ parse_options()
######################################################################## ########################################################################
if ! test -f sql/mysqld.cc if test ! -f sql/mysqld.cc
then then
echo "You must run this script from the MySQL top-level directory" echo "You must run this script from the MySQL top-level directory"
exit 1 exit 1
@ -185,12 +185,6 @@ fi
# (returns 0 if finds lines) # (returns 0 if finds lines)
if ccache -V > /dev/null 2>&1 if ccache -V > /dev/null 2>&1
then then
if ! (echo "$CC" | grep "ccache" > /dev/null) echo "$CC" | grep "ccache" > /dev/null || CC="ccache $CC"
then echo "$CXX" | grep "ccache" > /dev/null || CXX="ccache $CXX"
CC="ccache $CC"
fi
if ! (echo "$CXX" | grep "ccache" > /dev/null)
then
CXX="ccache $CXX"
fi
fi fi

View File

@ -3,213 +3,216 @@
# Check cpu of current machine and find the # Check cpu of current machine and find the
# best compiler optimization flags for gcc # best compiler optimization flags for gcc
# #
#
if test -r /proc/cpuinfo ; then check_cpu () {
# on Linux (and others?) we can get detailed CPU information out of /proc if test -r /proc/cpuinfo ; then
cpuinfo="cat /proc/cpuinfo" # on Linux (and others?) we can get detailed CPU information out of /proc
cpuinfo="cat /proc/cpuinfo"
# detect CPU family # detect CPU family
cpu_family=`$cpuinfo | grep 'family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` cpu_family=`$cpuinfo | grep 'family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
if test -z "$cpu_family" ; then if test -z "$cpu_family" ; then
cpu_family=`$cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` cpu_family=`$cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
fi
# detect CPU vendor and model
cpu_vendor=`$cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
model_name=`$cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1`
if test -z "$model_name" ; then
model_name=`$cpuinfo | grep 'cpu model' | cut -d ':' -f 2 | head -1`
fi
# fallback: get CPU model from uname output
if test -z "$model_name" ; then
model_name=`uname -m`
fi
# parse CPU flags
for flag in `$cpuinfo | grep '^flags' | sed -e 's/^flags.*: //'`; do
eval cpu_flag_$flag=yes
done
else
# Fallback when there is no /proc/cpuinfo
case "`uname -s`" in
FreeBSD|OpenBSD)
cpu_family=`uname -m`;
model_name=`sysctl -n hw.model`
;;
Darwin)
cpu_family=`uname -p`
model_name=`machine`
;;
*)
cpu_family=`uname -m`;
model_name=`uname -p`;
;;
esac
fi fi
# detect CPU vendor and model # detect CPU shortname as used by gcc options
cpu_vendor=`$cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` # this list is not complete, feel free to add further entries
model_name=`$cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1` cpu_arg=""
if test -z "$model_name" ; then case "$cpu_family--$model_name" in
model_name=`$cpuinfo | grep 'cpu model' | cut -d ':' -f 2 | head -1` # DEC Alpha
fi Alpha*EV6*)
cpu_arg="ev6";
# fallback: get CPU model from uname output
if test -z "$model_name" ; then
model_name=`uname -m`
fi
# parse CPU flags
for flag in `$cpuinfo | grep '^flags' | sed -e 's/^flags.*: //'`; do
eval cpu_flag_$flag=yes
done
else
# Fallback when there is no /proc/cpuinfo
case "`uname -s`" in
FreeBSD|OpenBSD)
cpu_family=`uname -m`;
model_name=`sysctl -n hw.model`
;; ;;
Darwin)
cpu_family=`uname -p` # Intel ia32
model_name=`machine` *X[eE][oO][nN]*)
# a Xeon is just another pentium4 ...
# ... unless it has the "lm" (long-mode) flag set,
# in that case it's a Xeon with EM64T support
if [ -z "$cpu_flag_lm" ]; then
cpu_arg="pentium4";
else
cpu_arg="nocona";
fi
;; ;;
*Pentium*4*Mobile*)
cpu_arg="pentium4m";
;;
*Pentium*4*)
cpu_arg="pentium4";
;;
*Pentium*III*Mobile*)
cpu_arg="pentium3m";
;;
*Pentium*III*)
cpu_arg="pentium3";
;;
*Pentium*M*pro*)
cpu_arg="pentium-m";
;;
*Athlon*64*)
cpu_arg="athlon64";
;;
*Athlon*)
cpu_arg="athlon";
;;
*Opteron*)
cpu_arg="opteron";
;;
# MacOSX / Intel
*i386*i486*)
cpu_arg="pentium-m";
;;
# Intel ia64
*Itanium*)
# Don't need to set any flags for itanium(at the moment)
cpu_arg="";
;;
#
*ppc*)
cpu_arg='powerpc'
;;
*powerpc*)
cpu_arg='powerpc'
;;
# unknown
*) *)
cpu_family=`uname -m`; cpu_arg="";
model_name=`uname -p`;
;; ;;
esac esac
fi
# detect CPU shortname as used by gcc options
# this list is not complete, feel free to add further entries
cpu_arg=""
case "$cpu_family--$model_name" in
# DEC Alpha
Alpha*EV6*)
cpu_arg="ev6";
;;
# Intel ia32
*X[eE][oO][nN]*)
# a Xeon is just another pentium4 ...
# ... unless it has the "lm" (long-mode) flag set,
# in that case it's a Xeon with EM64T support
if [ -z "$cpu_flag_lm" ]; then
cpu_arg="pentium4";
else
cpu_arg="nocona";
fi
;;
*Pentium*4*Mobile*)
cpu_arg="pentium4m";
;;
*Pentium*4*)
cpu_arg="pentium4";
;;
*Pentium*III*Mobile*)
cpu_arg="pentium3m";
;;
*Pentium*III*)
cpu_arg="pentium3";
;;
*Pentium*M*pro*)
cpu_arg="pentium-m";
;;
*Athlon*64*)
cpu_arg="athlon64";
;;
*Athlon*)
cpu_arg="athlon";
;;
*Opteron*)
cpu_arg="opteron";
;;
# MacOSX / Intel
*i386*i486*)
cpu_arg="pentium-m";
;;
# Intel ia64
*Itanium*)
# Don't need to set any flags for itanium(at the moment)
cpu_arg="";
;;
#
*ppc*)
cpu_arg='powerpc'
;;
*powerpc*)
cpu_arg='powerpc'
;;
# unknown
*)
cpu_arg="";
;;
esac
if test -z "$cpu_arg"; then if test -z "$cpu_arg"; then
echo "BUILD/check-cpu: Oops, could not find out what kind of cpu this machine is using." echo "BUILD/check-cpu: Oops, could not find out what kind of cpu this machine is using." >&2
check_cpu_cflags=""
return
fi
# different compiler versions have different option names
# for CPU specific command line options
if test -z "$CC" ; then
cc="gcc";
else
cc=$CC
fi
cc_ver=`$cc --version | sed 1q`
cc_verno=`echo $cc_ver | sed -e 's/^.*gcc/gcc/g; s/[^0-9. ]//g; s/^ *//g; s/ .*//g'`
case "$cc_ver--$cc_verno" in
*GCC*)
# different gcc backends (and versions) have different CPU flags
case `gcc -dumpmachine` in
i?86-*)
case "$cc_verno" in
3.4*|3.5*|4.*)
check_cpu_args='-mtune=$cpu_arg -march=$cpu_arg'
;;
*)
check_cpu_args='-mcpu=$cpu_arg -march=$cpu_arg'
;;
esac
;;
ppc-*)
check_cpu_args='-mcpu=$cpu_arg -mtune=$cpu_arg'
;;
x86_64-*)
check_cpu_args='-mtune=$cpu_arg'
;;
*)
check_cpu_cflags=""
return
;;
esac
;;
2.95.*)
# GCC 2.95 doesn't expose its name in --version output
check_cpu_args='-m$cpu_arg'
;;
*)
check_cpu_cflags="" check_cpu_cflags=""
return return
;;
esac
# now we check whether the compiler really understands the cpu type
touch __test.c
while [ "$cpu_arg" ] ; do
echo -n testing $cpu_arg "... "
# compile check
check_cpu_cflags=`eval echo $check_cpu_args`
if $cc -c $check_cpu_cflags __test.c 2>/dev/null; then
echo ok
break;
fi fi
echo failed # different compiler versions have different option names
check_cpu_cflags="" # for CPU specific command line options
if test -z "$CC" ; then
cc="gcc";
else
cc=$CC
fi
# if compile failed: check whether it supports a predecessor of this CPU cc_ver=`$cc --version | sed 1q`
# this list is not complete, feel free to add further entries cc_verno=`echo $cc_ver | sed -e 's/^.*gcc/gcc/g; s/[^0-9. ]//g; s/^ *//g; s/ .*//g'`
case "$cpu_arg" in
# Intel ia32
nocona) cpu_arg=pentium4 ;;
prescott) cpu_arg=pentium4 ;;
pentium4m) cpu_arg=pentium4 ;;
pentium4) cpu_arg=pentium3 ;;
pentium3m) cpu_arg=pentium3 ;;
pentium3) cpu_arg=pentium2 ;;
pentium2) cpu_arg=pentiumpro ;;
pentiumpro) cpu_arg=pentium ;;
pentium) cpu_arg=i486 ;;
i486) cpu_arg=i386 ;;
# power / powerPC case "$cc_ver--$cc_verno" in
7450) cpu_arg=7400 ;; *GCC*)
# different gcc backends (and versions) have different CPU flags
*) cpu_arg="" ;; case `gcc -dumpmachine` in
i?86-*)
case "$cc_verno" in
3.4*|3.5*|4.*)
check_cpu_args='-mtune=$cpu_arg -march=$cpu_arg'
;;
*)
check_cpu_args='-mcpu=$cpu_arg -march=$cpu_arg'
;;
esac
;;
ppc-*)
check_cpu_args='-mcpu=$cpu_arg -mtune=$cpu_arg'
;;
x86_64-*)
check_cpu_args='-mtune=$cpu_arg'
;;
*)
check_cpu_cflags=""
return
;;
esac
;;
2.95.*)
# GCC 2.95 doesn't expose its name in --version output
check_cpu_args='-m$cpu_arg'
;;
*)
check_cpu_cflags=""
return
;;
esac esac
done
rm __test.* # now we check whether the compiler really understands the cpu type
touch __test.c
while [ "$cpu_arg" ] ; do
# FIXME: echo -n isn't portable - see contortions autoconf goes through
echo -n testing $cpu_arg "... " >&2
# compile check
check_cpu_cflags=`eval echo $check_cpu_args`
if $cc -c $check_cpu_cflags __test.c 2>/dev/null; then
echo ok >&2
break;
fi
echo failed >&2
check_cpu_cflags=""
# if compile failed: check whether it supports a predecessor of this CPU
# this list is not complete, feel free to add further entries
case "$cpu_arg" in
# Intel ia32
nocona) cpu_arg=pentium4 ;;
prescott) cpu_arg=pentium4 ;;
pentium4m) cpu_arg=pentium4 ;;
pentium4) cpu_arg=pentium3 ;;
pentium3m) cpu_arg=pentium3 ;;
pentium3) cpu_arg=pentium2 ;;
pentium2) cpu_arg=pentiumpro ;;
pentiumpro) cpu_arg=pentium ;;
pentium) cpu_arg=i486 ;;
i486) cpu_arg=i386 ;;
# power / powerPC
7450) cpu_arg=7400 ;;
*) cpu_arg="" ;;
esac
done
rm __test.*
}
check_cpu

44
bdb/CMakeLists.txt Executable file
View File

@ -0,0 +1,44 @@
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/bdb/build_win32
${CMAKE_SOURCE_DIR}/bdb/dbinc
${CMAKE_SOURCE_DIR}/bdb)
# BDB needs a number of source files that are auto-generated by the unix
# configure. So to build BDB, it is necessary to copy these over to the Windows
# bitkeeper tree, or to use a source .tar.gz package which already has these
# files.
ADD_LIBRARY(bdb btree/bt_compare.c btree/bt_conv.c btree/bt_curadj.c btree/bt_cursor.c
btree/bt_delete.c btree/bt_method.c btree/bt_open.c btree/bt_put.c btree/bt_rec.c
btree/bt_reclaim.c btree/bt_recno.c btree/bt_rsearch.c btree/bt_search.c
btree/bt_split.c btree/bt_stat.c btree/bt_upgrade.c btree/bt_verify.c btree/btree_auto.c
db/crdel_auto.c db/crdel_rec.c db/db.c db/db_am.c db/db_auto.c common/db_byteorder.c
db/db_cam.c db/db_conv.c db/db_dispatch.c db/db_dup.c common/db_err.c common/db_getlong.c
common/db_idspace.c db/db_iface.c db/db_join.c common/db_log2.c db/db_meta.c
db/db_method.c db/db_open.c db/db_overflow.c db/db_pr.c db/db_rec.c db/db_reclaim.c
db/db_remove.c db/db_rename.c db/db_ret.c env/db_salloc.c env/db_shash.c db/db_truncate.c
db/db_upg.c db/db_upg_opd.c db/db_vrfy.c db/db_vrfyutil.c dbm/dbm.c dbreg/dbreg.c
dbreg/dbreg_auto.c dbreg/dbreg_rec.c dbreg/dbreg_util.c env/env_file.c env/env_method.c
env/env_open.c env/env_recover.c env/env_region.c fileops/fileops_auto.c fileops/fop_basic.c
fileops/fop_rec.c fileops/fop_util.c hash/hash.c hash/hash_auto.c hash/hash_conv.c
hash/hash_dup.c hash/hash_func.c hash/hash_meta.c hash/hash_method.c hash/hash_open.c
hash/hash_page.c hash/hash_rec.c hash/hash_reclaim.c hash/hash_stat.c hash/hash_upgrade.c
hash/hash_verify.c hmac/hmac.c hsearch/hsearch.c lock/lock.c lock/lock_deadlock.c
lock/lock_method.c lock/lock_region.c lock/lock_stat.c lock/lock_util.c log/log.c
log/log_archive.c log/log_compare.c log/log_get.c log/log_method.c log/log_put.c
mp/mp_alloc.c mp/mp_bh.c mp/mp_fget.c mp/mp_fopen.c mp/mp_fput.c
mp/mp_fset.c mp/mp_method.c mp/mp_region.c mp/mp_register.c mp/mp_stat.c mp/mp_sync.c
mp/mp_trickle.c mutex/mut_tas.c mutex/mut_win32.c mutex/mutex.c os_win32/os_abs.c
os/os_alloc.c os_win32/os_clock.c os_win32/os_config.c os_win32/os_dir.c os_win32/os_errno.c
os_win32/os_fid.c os_win32/os_fsync.c os_win32/os_handle.c os/os_id.c os_win32/os_map.c
os/os_method.c os/os_oflags.c os_win32/os_open.c os/os_region.c os_win32/os_rename.c
os/os_root.c os/os_rpath.c os_win32/os_rw.c os_win32/os_seek.c os_win32/os_sleep.c
os_win32/os_spin.c os_win32/os_stat.c os/os_tmpdir.c os_win32/os_type.c os/os_unlink.c
qam/qam.c qam/qam_auto.c qam/qam_conv.c qam/qam_files.c qam/qam_method.c qam/qam_open.c
qam/qam_rec.c qam/qam_stat.c qam/qam_upgrade.c qam/qam_verify.c rep/rep_method.c
rep/rep_record.c rep/rep_region.c rep/rep_util.c hmac/sha1.c
clib/strcasecmp.c txn/txn.c txn/txn_auto.c txn/txn_method.c txn/txn_rec.c
txn/txn_recover.c txn/txn_region.c txn/txn_stat.c txn/txn_util.c common/util_log.c
common/util_sig.c xa/xa.c xa/xa_db.c xa/xa_map.c)

View File

@ -338,7 +338,7 @@ static void end_timer(ulong start_time,char *buff);
static void mysql_end_timer(ulong start_time,char *buff); static void mysql_end_timer(ulong start_time,char *buff);
static void nice_time(double sec,char *buff,bool part_second); static void nice_time(double sec,char *buff,bool part_second);
static sig_handler mysql_end(int sig); static sig_handler mysql_end(int sig);
static sig_handler mysql_sigint(int sig); static sig_handler handle_sigint(int sig);
int main(int argc,char *argv[]) int main(int argc,char *argv[])
{ {
@ -420,8 +420,7 @@ int main(int argc,char *argv[])
if (opt_sigint_ignore) if (opt_sigint_ignore)
signal(SIGINT, SIG_IGN); signal(SIGINT, SIG_IGN);
else else
signal(SIGINT, mysql_sigint); // Catch SIGINT to clean up signal(SIGINT, handle_sigint); // Catch SIGINT to clean up
signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up
/* /*
@ -489,28 +488,6 @@ int main(int argc,char *argv[])
#endif #endif
} }
sig_handler mysql_sigint(int sig)
{
char kill_buffer[40];
MYSQL *kill_mysql= NULL;
signal(SIGINT, mysql_sigint);
/* terminate if no query being executed, or we already tried interrupting */
if (!executing_query || interrupted_query++)
mysql_end(sig);
kill_mysql= mysql_init(kill_mysql);
if (!mysql_real_connect(kill_mysql,current_host, current_user, opt_password,
"", opt_mysql_port, opt_mysql_unix_port,0))
mysql_end(sig);
/* kill_buffer is always big enough because max length of %lu is 15 */
sprintf(kill_buffer, "KILL /*!50000 QUERY */ %lu", mysql_thread_id(&mysql));
mysql_real_query(kill_mysql, kill_buffer, strlen(kill_buffer));
mysql_close(kill_mysql);
tee_fprintf(stdout, "Query aborted by Ctrl+C\n");
}
sig_handler mysql_end(int sig) sig_handler mysql_end(int sig)
{ {
mysql_close(&mysql); mysql_close(&mysql);
@ -1058,8 +1035,6 @@ static int read_and_execute(bool interactive)
if (opt_outfile && glob_buffer.is_empty()) if (opt_outfile && glob_buffer.is_empty())
fflush(OUTFILE); fflush(OUTFILE);
interrupted_query= 0;
#if defined( __WIN__) || defined(__NETWARE__) #if defined( __WIN__) || defined(__NETWARE__)
tee_fputs(prompt, stdout); tee_fputs(prompt, stdout);
#if defined(__NETWARE__) #if defined(__NETWARE__)
@ -1982,6 +1957,9 @@ com_charset(String *buffer __attribute__((unused)), char *line)
if (new_cs) if (new_cs)
{ {
charset_info= new_cs; charset_info= new_cs;
mysql_set_character_set(&mysql, charset_info->csname);
default_charset= (char *)charset_info->csname;
default_charset_used= 1;
put_info("Charset changed", INFO_INFO); put_info("Charset changed", INFO_INFO);
} }
else put_info("Charset is not found", INFO_INFO); else put_info("Charset is not found", INFO_INFO);
@ -2041,9 +2019,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
} }
timer=start_timer(); timer=start_timer();
executing_query= 1; executing_query= 1;
error= mysql_real_query_for_lazy(buffer->ptr(),buffer->length()); error= mysql_real_query_for_lazy(buffer->ptr(),buffer->length());
#ifdef HAVE_READLINE #ifdef HAVE_READLINE
@ -2059,7 +2035,6 @@ com_go(String *buffer,char *line __attribute__((unused)))
{ {
executing_query= 0; executing_query= 0;
buffer->length(0); // Remove query on error buffer->length(0); // Remove query on error
executing_query= 0;
return error; return error;
} }
error=0; error=0;
@ -2143,9 +2118,6 @@ com_go(String *buffer,char *line __attribute__((unused)))
fflush(stdout); fflush(stdout);
mysql_free_result(result); mysql_free_result(result);
} while (!(err= mysql_next_result(&mysql))); } while (!(err= mysql_next_result(&mysql)));
executing_query= 0;
if (err >= 1) if (err >= 1)
error= put_error(&mysql); error= put_error(&mysql);
@ -2362,9 +2334,14 @@ print_table_data(MYSQL_RES *result)
(void) tee_fputs("|", PAGER); (void) tee_fputs("|", PAGER);
for (uint off=0; (field = mysql_fetch_field(result)) ; off++) for (uint off=0; (field = mysql_fetch_field(result)) ; off++)
{ {
tee_fprintf(PAGER, " %-*s |",(int) min(field->max_length, uint name_length= (uint) strlen(field->name);
uint numcells= charset_info->cset->numcells(charset_info,
field->name,
field->name + name_length);
uint display_length= field->max_length + name_length - numcells;
tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
MAX_COLUMN_LENGTH), MAX_COLUMN_LENGTH),
field->name); field->name);
num_flag[off]= IS_NUM(field->type); num_flag[off]= IS_NUM(field->type);
not_null_flag[off]= IS_NOT_NULL(field->flags); not_null_flag[off]= IS_NOT_NULL(field->flags);
} }

View File

@ -157,17 +157,29 @@ static int create_defaults_file(const char *path, const char *our_defaults_path)
File our_defaults_file, defaults_file; File our_defaults_file, defaults_file;
char buffer[512]; char buffer[512];
char *buffer_end; char *buffer_end;
int failed_to_open_count= 0;
int error; int error;
/* check if the defaults file is needed at all */ /* check if the defaults file is needed at all */
if (!opt_password) if (!opt_password)
return 0; return 0;
defaults_file= my_open(path, O_BINARY | O_CREAT | O_WRONLY, retry_open:
defaults_file= my_open(path, O_BINARY | O_CREAT | O_WRONLY | O_EXCL,
MYF(MY_FAE | MY_WME)); MYF(MY_FAE | MY_WME));
if (defaults_file < 0) if (defaults_file < 0)
return 1; {
if (failed_to_open_count == 0)
{
remove(path);
failed_to_open_count+= 1;
goto retry_open;
}
else
return 1;
}
upgrade_defaults_created= 1; upgrade_defaults_created= 1;
if (our_defaults_path) if (our_defaults_path)
{ {

View File

@ -430,7 +430,9 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
int string_value); int string_value);
static int dump_selected_tables(char *db, char **table_names, int tables); static int dump_selected_tables(char *db, char **table_names, int tables);
static int dump_all_tables_in_db(char *db); static int dump_all_tables_in_db(char *db);
static int init_dumping(char *); static int init_dumping_views(char *);
static int init_dumping_tables(char *);
static int init_dumping(char *, int init_func(char*));
static int dump_databases(char **); static int dump_databases(char **);
static int dump_all_databases(); static int dump_all_databases();
static char *quote_name(const char *name, char *buff, my_bool force); static char *quote_name(const char *name, char *buff, my_bool force);
@ -861,8 +863,9 @@ static int get_options(int *argc, char ***argv)
static void DB_error(MYSQL *mysql, const char *when) static void DB_error(MYSQL *mysql, const char *when)
{ {
DBUG_ENTER("DB_error"); DBUG_ENTER("DB_error");
my_printf_error(0,"Got error: %d: %s %s", MYF(0), fprintf(stderr, "%s: Got error: %d: %s %s\n", my_progname,
mysql_errno(mysql), mysql_error(mysql), when); mysql_errno(mysql), mysql_error(mysql), when);
fflush(stderr);
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} /* DB_error */ } /* DB_error */
@ -890,8 +893,9 @@ static int mysql_query_with_error_report(MYSQL *mysql_con, MYSQL_RES **res,
if (mysql_query(mysql_con, query) || if (mysql_query(mysql_con, query) ||
(res && !((*res)= mysql_store_result(mysql_con)))) (res && !((*res)= mysql_store_result(mysql_con))))
{ {
my_printf_error(0, "Couldn't execute '%s': %s (%d)", MYF(0), fprintf(stderr, "%s: Couldn't execute '%s': %s (%d)\n",
query, mysql_error(mysql_con), mysql_errno(mysql_con)); my_progname, query,
mysql_error(mysql_con), mysql_errno(mysql_con));
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
return 1; return 1;
} }
@ -2378,7 +2382,10 @@ static void dump_table(char *table, char *db)
check_io(md_result_file); check_io(md_result_file);
} }
if (mysql_query_with_error_report(mysql, 0, query)) if (mysql_query_with_error_report(mysql, 0, query))
{
DB_error(mysql, "when retrieving data from server"); DB_error(mysql, "when retrieving data from server");
goto err;
}
if (quick) if (quick)
res=mysql_use_result(mysql); res=mysql_use_result(mysql);
else else
@ -2905,7 +2912,76 @@ static int dump_databases(char **db_names)
} /* dump_databases */ } /* dump_databases */
static int init_dumping(char *database) /*
View Specific database initalization.
SYNOPSIS
init_dumping_views
qdatabase quoted name of the database
RETURN VALUES
0 Success.
1 Failure.
*/
int init_dumping_views(char *qdatabase)
{
return 0;
} /* init_dumping_views */
/*
Table Specific database initalization.
SYNOPSIS
init_dumping_tables
qdatabase quoted name of the database
RETURN VALUES
0 Success.
1 Failure.
*/
int init_dumping_tables(char *qdatabase)
{
if (!opt_create_db)
{
char qbuf[256];
MYSQL_ROW row;
MYSQL_RES *dbinfo;
my_snprintf(qbuf, sizeof(qbuf),
"SHOW CREATE DATABASE IF NOT EXISTS %s",
qdatabase);
if (mysql_query(mysql, qbuf) || !(dbinfo = mysql_store_result(mysql)))
{
/* Old server version, dump generic CREATE DATABASE */
if (opt_drop_database)
fprintf(md_result_file,
"\n/*!40000 DROP DATABASE IF EXISTS %s;*/\n",
qdatabase);
fprintf(md_result_file,
"\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n",
qdatabase);
}
else
{
if (opt_drop_database)
fprintf(md_result_file,
"\n/*!40000 DROP DATABASE IF EXISTS %s*/;\n",
qdatabase);
row = mysql_fetch_row(dbinfo);
if (row[1])
{
fprintf(md_result_file,"\n%s;\n",row[1]);
}
}
}
return 0;
} /* init_dumping_tables */
static int init_dumping(char *database, int init_func(char*))
{ {
if (mysql_get_server_version(mysql) >= 50003 && if (mysql_get_server_version(mysql) >= 50003 &&
!my_strcasecmp(&my_charset_latin1, database, "information_schema")) !my_strcasecmp(&my_charset_latin1, database, "information_schema"))
@ -2930,40 +3006,10 @@ static int init_dumping(char *database)
fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", qdatabase); fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", qdatabase);
check_io(md_result_file); check_io(md_result_file);
} }
if (!opt_create_db)
{
char qbuf[256];
MYSQL_ROW row;
MYSQL_RES *dbinfo;
my_snprintf(qbuf, sizeof(qbuf), /* Call the view or table specific function */
"SHOW CREATE DATABASE IF NOT EXISTS %s", init_func(qdatabase);
qdatabase);
if (mysql_query(mysql, qbuf) || !(dbinfo = mysql_store_result(mysql)))
{
/* Old server version, dump generic CREATE DATABASE */
if (opt_drop_database)
fprintf(md_result_file,
"\n/*!40000 DROP DATABASE IF EXISTS %s;*/\n",
qdatabase);
fprintf(md_result_file,
"\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n",
qdatabase);
}
else
{
if (opt_drop_database)
fprintf(md_result_file,
"\n/*!40000 DROP DATABASE IF EXISTS %s*/;\n",
qdatabase);
row = mysql_fetch_row(dbinfo);
if (row[1])
{
fprintf(md_result_file,"\n%s;\n",row[1]);
}
}
}
fprintf(md_result_file,"\nUSE %s;\n", qdatabase); fprintf(md_result_file,"\nUSE %s;\n", qdatabase);
check_io(md_result_file); check_io(md_result_file);
} }
@ -2997,7 +3043,7 @@ static int dump_all_tables_in_db(char *database)
if (!strcmp(database, NDB_REP_DB)) /* Skip cluster internal database */ if (!strcmp(database, NDB_REP_DB)) /* Skip cluster internal database */
return 0; return 0;
if (init_dumping(database)) if (init_dumping(database, init_dumping_tables))
return 1; return 1;
if (opt_xml) if (opt_xml)
print_xml_tag1(md_result_file, "", "database name=", database, "\n"); print_xml_tag1(md_result_file, "", "database name=", database, "\n");
@ -3075,23 +3121,8 @@ static my_bool dump_all_views_in_db(char *database)
uint numrows; uint numrows;
char table_buff[NAME_LEN*2+3]; char table_buff[NAME_LEN*2+3];
if (mysql_select_db(mysql, database)) if (init_dumping(database, init_dumping_views))
{
DB_error(mysql, "when selecting the database");
return 1; return 1;
}
if (opt_databases || opt_alldbs)
{
char quoted_database_buf[NAME_LEN*2+3];
char *qdatabase= quote_name(database,quoted_database_buf,opt_quoted);
if (opt_comments)
{
fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", qdatabase);
check_io(md_result_file);
}
fprintf(md_result_file,"\nUSE %s;\n", qdatabase);
check_io(md_result_file);
}
if (opt_xml) if (opt_xml)
print_xml_tag1(md_result_file, "", "database name=", database, "\n"); print_xml_tag1(md_result_file, "", "database name=", database, "\n");
if (lock_tables) if (lock_tables)
@ -3186,7 +3217,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
char **dump_tables, **pos, **end; char **dump_tables, **pos, **end;
DBUG_ENTER("dump_selected_tables"); DBUG_ENTER("dump_selected_tables");
if (init_dumping(db)) if (init_dumping(db, init_dumping_tables))
DBUG_RETURN(1); DBUG_RETURN(1);
init_alloc_root(&root, 8192, 0); init_alloc_root(&root, 8192, 0);

View File

@ -5527,6 +5527,9 @@ int main(int argc, char **argv)
if ( opt_mark_progress ) if ( opt_mark_progress )
dump_progress(result_file); dump_progress(result_file);
dynstr_free(&ds_progress); dynstr_free(&ds_progress);
dynstr_free(&ds_res);
if (!got_end_timer) if (!got_end_timer)
timer_output(); /* No end_timer cmd, end it */ timer_output(); /* No end_timer cmd, end it */
free_used_memory(); free_used_memory();

View File

@ -71,19 +71,18 @@
* *
*/ */
#include <my_global.h> #include <my_global.h>
/* This file won't compile unless DBUG_OFF is undefined locally */
#ifdef DBUG_OFF
#undef DBUG_OFF
#endif
#include <m_string.h> #include <m_string.h>
#include <errno.h> #include <errno.h>
#if defined(MSDOS) || defined(__WIN__) #if defined(MSDOS) || defined(__WIN__)
#include <process.h> #include <process.h>
#endif #endif
#ifndef DBUG_OFF
/* /*
* Manifest constants which may be "tuned" if desired. * Manifest constants which may be "tuned" if desired.
*/ */
@ -316,6 +315,7 @@ static unsigned long Clock(void);
#define ChangeOwner(cs,name) #define ChangeOwner(cs,name)
#endif #endif
/* /*
** Macros to allow dbugging with threads ** Macros to allow dbugging with threads
*/ */
@ -2354,3 +2354,5 @@ va_list ap;
} }
#endif /* NO_VARARGS */ #endif /* NO_VARARGS */
#endif

View File

@ -30,7 +30,7 @@ sub generate_prefix($$)
next; next;
} }
if ( /^\s*[a-zA-Z0-9*_ ]+\s+([_a-zA-Z0-9]+)\s*\(/ ) if ( /^\s*[a-zA-Z0-9*_ ]+\s+\*?([_a-zA-Z0-9]+)\s*\(/ )
{ {
print OUT "#define $1 ya$1\n"; print OUT "#define $1 ya$1\n";
} }

View File

@ -1,5 +1,6 @@
#define Copyright yaCopyright #define Copyright yaCopyright
#define yaSSL_CleanUp yayaSSL_CleanUp #define yaSSL_CleanUp yayaSSL_CleanUp
#define BN_bin2bn yaBN_bin2bn
#define DH_new yaDH_new #define DH_new yaDH_new
#define DH_free yaDH_free #define DH_free yaDH_free
#define RSA_free yaRSA_free #define RSA_free yaRSA_free
@ -92,6 +93,12 @@
#define SSL_want_read yaSSL_want_read #define SSL_want_read yaSSL_want_read
#define SSL_want_write yaSSL_want_write #define SSL_want_write yaSSL_want_write
#define SSL_pending yaSSL_pending #define SSL_pending yaSSL_pending
#define SSLv3_method yaSSLv3_method
#define SSLv3_server_method yaSSLv3_server_method
#define SSLv3_client_method yaSSLv3_client_method
#define TLSv1_server_method yaTLSv1_server_method
#define TLSv1_client_method yaTLSv1_client_method
#define SSLv23_server_method yaSSLv23_server_method
#define SSL_CTX_use_certificate_file yaSSL_CTX_use_certificate_file #define SSL_CTX_use_certificate_file yaSSL_CTX_use_certificate_file
#define SSL_CTX_use_PrivateKey_file yaSSL_CTX_use_PrivateKey_file #define SSL_CTX_use_PrivateKey_file yaSSL_CTX_use_PrivateKey_file
#define SSL_CTX_set_cipher_list yaSSL_CTX_set_cipher_list #define SSL_CTX_set_cipher_list yaSSL_CTX_set_cipher_list
@ -115,11 +122,13 @@
#define RAND_write_file yaRAND_write_file #define RAND_write_file yaRAND_write_file
#define RAND_load_file yaRAND_load_file #define RAND_load_file yaRAND_load_file
#define RAND_status yaRAND_status #define RAND_status yaRAND_status
#define RAND_bytes yaRAND_bytes
#define DES_set_key yaDES_set_key #define DES_set_key yaDES_set_key
#define DES_set_odd_parity yaDES_set_odd_parity #define DES_set_odd_parity yaDES_set_odd_parity
#define DES_ecb_encrypt yaDES_ecb_encrypt #define DES_ecb_encrypt yaDES_ecb_encrypt
#define SSL_CTX_set_default_passwd_cb_userdata yaSSL_CTX_set_default_passwd_cb_userdata #define SSL_CTX_set_default_passwd_cb_userdata yaSSL_CTX_set_default_passwd_cb_userdata
#define SSL_SESSION_free yaSSL_SESSION_free #define SSL_SESSION_free yaSSL_SESSION_free
#define SSL_peek yaSSL_peek
#define SSL_get_certificate yaSSL_get_certificate #define SSL_get_certificate yaSSL_get_certificate
#define SSL_get_privatekey yaSSL_get_privatekey #define SSL_get_privatekey yaSSL_get_privatekey
#define X509_get_pubkey yaX509_get_pubkey #define X509_get_pubkey yaX509_get_pubkey

View File

@ -29,7 +29,7 @@
#include "runtime.hpp" #include "runtime.hpp"
#include "misc.hpp" #include "misc.hpp"
#if !defined(YASSL_MYSQL_COMPATIBLE)
extern "C" { extern "C" {
// for libcurl configure test, these are the signatures they use // for libcurl configure test, these are the signatures they use
@ -37,6 +37,7 @@ extern "C" {
char CRYPTO_lock() { return 0;} char CRYPTO_lock() { return 0;}
char CRYPTO_add_lock() { return 0;} char CRYPTO_add_lock() { return 0;}
} // extern "C" } // extern "C"
#endif
#ifdef YASSL_PURE_C #ifdef YASSL_PURE_C

8
heap/CMakeLists.txt Executable file
View File

@ -0,0 +1,8 @@
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
ADD_LIBRARY(heap _check.c _rectest.c hp_block.c hp_clear.c hp_close.c hp_create.c
hp_delete.c hp_extra.c hp_hash.c hp_info.c hp_open.c hp_panic.c
hp_rename.c hp_rfirst.c hp_rkey.c hp_rlast.c hp_rnext.c hp_rprev.c
hp_rrnd.c hp_rsame.c hp_scan.c hp_static.c hp_update.c hp_write.c)

View File

@ -165,7 +165,6 @@ struct st_mysql_options {
char *ssl_ca; /* PEM CA file */ char *ssl_ca; /* PEM CA file */
char *ssl_capath; /* PEM directory of CA-s? */ char *ssl_capath; /* PEM directory of CA-s? */
char *ssl_cipher; /* cipher to use */ char *ssl_cipher; /* cipher to use */
my_bool ssl_verify_server_cert; /* if to verify server cert */
char *shared_memory_base_name; char *shared_memory_base_name;
unsigned long max_allowed_packet; unsigned long max_allowed_packet;
my_bool use_ssl; /* if to use SSL or not */ my_bool use_ssl; /* if to use SSL or not */

View File

@ -138,8 +138,10 @@ enum enum_server_command
#define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */ #define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */
#define CLIENT_RESERVED 16384 /* Old flag for 4.1 protocol */ #define CLIENT_RESERVED 16384 /* Old flag for 4.1 protocol */
#define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */ #define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */
#define CLIENT_MULTI_STATEMENTS 65536 /* Enable/disable multi-stmt support */ #define CLIENT_MULTI_STATEMENTS (((ulong) 1) << 16) /* Enable/disable multi-stmt support */
#define CLIENT_MULTI_RESULTS 131072 /* Enable/disable multi-results */ #define CLIENT_MULTI_RESULTS (((ulong) 1) << 17) /* Enable/disable multi-results */
#define CLIENT_SSL_VERIFY_SERVER_CERT (((ulong) 1) << 30)
#define CLIENT_REMEMBER_OPTIONS (((ulong) 1) << 31) #define CLIENT_REMEMBER_OPTIONS (((ulong) 1) << 31)
#define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */ #define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */

35
innobase/CMakeLists.txt Executable file
View File

@ -0,0 +1,35 @@
#SET(CMAKE_CXX_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX")
#SET(CMAKE_C_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX")
ADD_DEFINITIONS(-DMYSQL_SERVER -D_WIN32 -DWIN32 -D_LIB)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include include)
ADD_LIBRARY(innobase btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c
buf/buf0buf.c buf/buf0flu.c buf/buf0lru.c buf/buf0rea.c
data/data0data.c data/data0type.c
dict/dict0boot.c dict/dict0crea.c dict/dict0dict.c dict/dict0load.c dict/dict0mem.c
dyn/dyn0dyn.c
eval/eval0eval.c eval/eval0proc.c
fil/fil0fil.c
fsp/fsp0fsp.c
fut/fut0fut.c fut/fut0lst.c
ha/ha0ha.c ha/hash0hash.c
ibuf/ibuf0ibuf.c
pars/lexyy.c pars/pars0grm.c pars/pars0opt.c pars/pars0pars.c pars/pars0sym.c
lock/lock0lock.c
log/log0log.c log/log0recv.c
mach/mach0data.c
mem/mem0mem.c mem/mem0pool.c
mtr/mtr0log.c mtr/mtr0mtr.c
os/os0file.c os/os0proc.c os/os0sync.c os/os0thread.c
page/page0cur.c page/page0page.c
que/que0que.c
read/read0read.c
rem/rem0cmp.c rem/rem0rec.c
row/row0ins.c row/row0mysql.c row/row0purge.c row/row0row.c row/row0sel.c row/row0uins.c
row/row0umod.c row/row0undo.c row/row0upd.c row/row0vers.c
srv/srv0que.c srv/srv0srv.c srv/srv0start.c
sync/sync0arr.c sync/sync0rw.c sync/sync0sync.c
thr/thr0loc.c
trx/trx0purge.c trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c trx/trx0sys.c trx/trx0trx.c trx/trx0undo.c
usr/usr0sess.c
ut/ut0byte.c ut/ut0dbg.c ut/ut0mem.c ut/ut0rnd.c ut/ut0ut.c )

26
myisam/CMakeLists.txt Executable file
View File

@ -0,0 +1,26 @@
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
ADD_LIBRARY(myisam ft_boolean_search.c ft_nlq_search.c ft_parser.c ft_static.c ft_stem.c
ft_stopwords.c ft_update.c mi_cache.c mi_changed.c mi_check.c
mi_checksum.c mi_close.c mi_create.c mi_dbug.c mi_delete.c
mi_delete_all.c mi_delete_table.c mi_dynrec.c mi_extra.c mi_info.c
mi_key.c mi_keycache.c mi_locking.c mi_log.c mi_open.c
mi_packrec.c mi_page.c mi_panic.c mi_preload.c mi_range.c mi_rename.c
mi_rfirst.c mi_rlast.c mi_rnext.c mi_rnext_same.c mi_rprev.c mi_rrnd.c
mi_rsame.c mi_rsamepos.c mi_scan.c mi_search.c mi_static.c mi_statrec.c
mi_unique.c mi_update.c mi_write.c rt_index.c rt_key.c rt_mbr.c
rt_split.c sort.c sp_key.c ft_eval.h myisamdef.h rt_index.h mi_rkey.c)
ADD_EXECUTABLE(myisam_ftdump myisam_ftdump.c)
TARGET_LINK_LIBRARIES(myisam_ftdump myisam mysys dbug strings zlib wsock32)
ADD_EXECUTABLE(myisamchk myisamchk.c)
TARGET_LINK_LIBRARIES(myisamchk myisam mysys dbug strings zlib wsock32)
ADD_EXECUTABLE(myisamlog myisamlog.c)
TARGET_LINK_LIBRARIES(myisamlog myisam mysys dbug strings zlib wsock32)
ADD_EXECUTABLE(myisampack myisampack.c)
TARGET_LINK_LIBRARIES(myisampack myisam mysys dbug strings zlib wsock32)

9
myisammrg/CMakeLists.txt Executable file
View File

@ -0,0 +1,9 @@
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
ADD_LIBRARY(myisammrg myrg_close.c myrg_create.c myrg_delete.c myrg_extra.c myrg_info.c
myrg_locking.c myrg_open.c myrg_panic.c myrg_queue.c myrg_range.c
myrg_rfirst.c myrg_rkey.c myrg_rlast.c myrg_rnext.c myrg_rnext_same.c
myrg_rprev.c myrg_rrnd.c myrg_rsame.c myrg_static.c myrg_update.c
myrg_write.c)

View File

@ -24,7 +24,7 @@ benchdir_root= $(prefix)
testdir = $(benchdir_root)/mysql-test testdir = $(benchdir_root)/mysql-test
EXTRA_SCRIPTS = mysql-test-run.sh install_test_db.sh valgrind.supp $(PRESCRIPTS) EXTRA_SCRIPTS = mysql-test-run.sh install_test_db.sh valgrind.supp $(PRESCRIPTS)
EXTRA_DIST = $(EXTRA_SCRIPTS) EXTRA_DIST = $(EXTRA_SCRIPTS)
GENSCRIPTS = mysql-test-run install_test_db GENSCRIPTS = mysql-test-run install_test_db mtr
PRESCRIPTS = mysql-test-run.pl PRESCRIPTS = mysql-test-run.pl
test_SCRIPTS = $(GENSCRIPTS) $(PRESCRIPTS) test_SCRIPTS = $(GENSCRIPTS) $(PRESCRIPTS)
test_DATA = std_data/client-key.pem std_data/client-cert.pem \ test_DATA = std_data/client-key.pem std_data/client-cert.pem \
@ -113,6 +113,10 @@ install-data-local:
uninstall-local: uninstall-local:
@RM@ -f -r $(DESTDIR)$(testdir) @RM@ -f -r $(DESTDIR)$(testdir)
# mtr - a shortcut for executing mysql-test-run.pl
mtr:
$(RM) -f mtr
$(LN_S) mysql-test-run.pl mtr
SUFFIXES = .sh SUFFIXES = .sh

View File

@ -102,7 +102,7 @@ sub collect_test_cases ($) {
if ( $mysqld_test_exists and $im_test_exists ) if ( $mysqld_test_exists and $im_test_exists )
{ {
mtr_error("Ambiguos test case name ($tname)"); mtr_error("Ambiguous test case name ($tname)");
} }
elsif ( ! $mysqld_test_exists and ! $im_test_exists ) elsif ( ! $mysqld_test_exists and ! $im_test_exists )
{ {
@ -157,34 +157,38 @@ sub collect_test_cases ($) {
if ( $::opt_reorder ) if ( $::opt_reorder )
{ {
@$cases = sort {
if ( ! $a->{'master_restart'} and ! $b->{'master_restart'} )
{
return $a->{'name'} cmp $b->{'name'};
}
if ( $a->{'master_restart'} and $b->{'master_restart'} ) my %sort_criteria;
{ my $tinfo;
my $cmp= mtr_cmp_opts($a->{'master_opt'}, $b->{'master_opt'});
if ( $cmp == 0 )
{
return $a->{'name'} cmp $b->{'name'};
}
else
{
return $cmp;
}
}
if ( $a->{'master_restart'} ) # Make a mapping of test name to a string that represents how that test
{ # should be sorted among the other tests. Put the most important criterion
return 1; # Is greater # first, then a sub-criterion, then sub-sub-criterion, et c.
} foreach $tinfo (@$cases)
else {
{ my @this_criteria = ();
return -1; # Is less
} # Append the criteria for sorting, in order of importance.
} @$cases; push(@this_criteria, join("!", sort @{$tinfo->{'master_opt'}}) . "~"); # Ending with "~" makes empty sort later than filled
push(@this_criteria, "ndb=" . ($tinfo->{'ndb_test'} ? "1" : "0"));
push(@this_criteria, "restart=" . ($tinfo->{'master_restart'} ? "1" : "0"));
push(@this_criteria, "big_test=" . ($tinfo->{'big_test'} ? "1" : "0"));
push(@this_criteria, join("|", sort keys %{$tinfo})); # Group similar things together. The values may differ substantially. FIXME?
push(@this_criteria, $tinfo->{'name'}); # Finally, order by the name
$sort_criteria{$tinfo->{"name"}} = join(" ", @this_criteria);
}
@$cases = sort { $sort_criteria{$a->{"name"}} cmp $sort_criteria{$b->{"name"}}; } @$cases;
### For debugging the sort-order
# foreach $tinfo (@$cases)
# {
# print $sort_criteria{$tinfo->{"name"}};
# print " -> \t";
# print $tinfo->{"name"};
# print "\n";
# }
} }
return $cases; return $cases;
@ -469,14 +473,6 @@ sub collect_one_test_case($$$$$$$) {
{ {
mtr_options_from_test_file($tinfo,"$testdir/${tname}.test"); mtr_options_from_test_file($tinfo,"$testdir/${tname}.test");
if ( ! $tinfo->{'innodb_test'} )
{
# mtr_verbose("Adding '--skip-innodb' to $tinfo->{'name'}");
# FIXME activate the --skip-innodb only when running with
# selected test cases
# push(@{$tinfo->{'master_opt'}}, "--skip-innodb");
}
if ( $tinfo->{'big_test'} and ! $::opt_big_test ) if ( $tinfo->{'big_test'} and ! $::opt_big_test )
{ {
$tinfo->{'skip'}= 1; $tinfo->{'skip'}= 1;

View File

@ -139,6 +139,8 @@ sub mtr_copy_dir($$) {
my $from_dir= shift; my $from_dir= shift;
my $to_dir= shift; my $to_dir= shift;
# mtr_verbose("Copying from $from_dir to $to_dir");
mkpath("$to_dir"); mkpath("$to_dir");
opendir(DIR, "$from_dir") opendir(DIR, "$from_dir")
or mtr_error("Can't find $from_dir$!"); or mtr_error("Can't find $from_dir$!");

View File

@ -115,6 +115,8 @@ sub spawn_impl ($$$$$$$$) {
my $pid_file= shift; # FIXME my $pid_file= shift; # FIXME
my $spawn_opts= shift; my $spawn_opts= shift;
mtr_error("Can't spawn with empty \"path\"") unless defined $path;
if ( $::opt_script_debug ) if ( $::opt_script_debug )
{ {
print STDERR "\n"; print STDERR "\n";
@ -702,7 +704,7 @@ sub mtr_check_stop_servers ($) {
} }
else else
{ {
mtr_verbose("All ports where free, continuing"); mtr_verbose("All ports were free, continuing");
} }
} }
} }
@ -975,6 +977,7 @@ sub check_expected_crash_and_restart($)
sub mtr_record_dead_children () { sub mtr_record_dead_children () {
my $process_died= 0;
my $ret_pid; my $ret_pid;
# Wait without blockinng to see if any processes had died # Wait without blockinng to see if any processes had died
@ -983,7 +986,9 @@ sub mtr_record_dead_children () {
{ {
mtr_warning("mtr_record_dead_children: $ret_pid"); mtr_warning("mtr_record_dead_children: $ret_pid");
mark_process_dead($ret_pid); mark_process_dead($ret_pid);
$process_died= 1;
} }
return $process_died;
} }
sub start_reap_all { sub start_reap_all {

File diff suppressed because it is too large Load Diff

View File

@ -446,52 +446,6 @@ INSERT INTO t1 VALUES(1, 1);
ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment; ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment;
ERROR 23000: ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1' for key 'PRIMARY' ERROR 23000: ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1' for key 'PRIMARY'
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE `t2` (
`k` int(11) NOT NULL auto_increment,
`a` int(11) default NULL,
`c` int(11) default NULL,
PRIMARY KEY (`k`),
UNIQUE KEY `idx_1` (`a`)
) ENGINE=InnoDB;
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
insert into t2 ( a ) values ( 7 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
select last_insert_id();
last_insert_id()
2
select * from t2;
k a c
1 6 NULL
2 7 NULL
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
select last_insert_id();
last_insert_id()
1
select * from t2;
k a c
1 6 1
2 7 NULL
insert ignore into t2 values (null,6,1),(10,8,1);
select last_insert_id();
last_insert_id()
1
insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1);
select last_insert_id();
last_insert_id()
11
select * from t2;
k a c
1 6 1
2 7 NULL
10 8 1
11 15 1
12 20 1
drop table t2;
create table t1 (a int primary key auto_increment, b int, c int, d timestamp default current_timestamp, unique(b),unique(c)); create table t1 (a int primary key auto_increment, b int, c int, d timestamp default current_timestamp, unique(b),unique(c));
insert into t1 values(null,1,1,now()); insert into t1 values(null,1,1,now());
insert into t1 values(null,0,0,null); insert into t1 values(null,0,0,null);

View File

@ -248,3 +248,14 @@ select rpad(c1,3,'
rpad(c1,3,'ö') rpad('ö',3,c1) rpad(c1,3,'ö') rpad('ö',3,c1)
ßöö ößß ßöö ößß
drop table t1; drop table t1;
set names koi8r;
create table t1(a char character set cp1251 default _koi8r 0xFF);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` char(1) CHARACTER SET cp1251 DEFAULT '˙'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1(a char character set latin1 default _cp1251 0xFF);
ERROR 42000: Invalid default value for 'a'
End of 4.1 tests

View File

@ -730,6 +730,45 @@ id MIN(s)
1 ZZZ 1 ZZZ
2 ZZZ 2 ZZZ
DROP TABLE t1; DROP TABLE t1;
drop table if exists bug20536;
set names latin1;
create table bug20536 (id bigint not null auto_increment primary key, name
varchar(255) character set ucs2 not null);
insert into `bug20536` (`id`,`name`) values (1, _latin1 x'7465737431'), (2, "'test\\_2'");
select md5(name) from bug20536;
md5(name)
f4b7ce8b45a20e3c4e84bef515d1525c
48d95db0d8305c2fe11548a3635c9385
select sha1(name) from bug20536;
sha1(name)
e0b52f38deddb9f9e8d5336b153592794cb49baf
677d4d505355eb5b0549b865fcae4b7f0c28aef5
select make_set(3, name, upper(name)) from bug20536;
make_set(3, name, upper(name))
test1,TEST1
'test\_2','TEST\_2'
select export_set(5, name, upper(name)) from bug20536;
export_set(5, name, upper(name))
test1,TEST1,test1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1
'test\_2','TEST\_2','test\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2'
select export_set(5, name, upper(name), ",", 5) from bug20536;
export_set(5, name, upper(name), ",", 5)
test1,TEST1,test1,TEST1,TEST1
'test\_2','TEST\_2','test\_2','TEST\_2','TEST\_2'
select password(name) from bug20536;
password(name)
????????????????????
????????????????????
select old_password(name) from bug20536;
old_password(name)
????????
????????
select quote(name) from bug20536;
quote(name)
????????
????????????????
drop table bug20536;
End of 4.1 tests
CREATE TABLE t1 (a varchar(64) character set ucs2, b decimal(10,3)); CREATE TABLE t1 (a varchar(64) character set ucs2, b decimal(10,3));
INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0); INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0);
update t1 set b=a; update t1 set b=a;
@ -765,3 +804,4 @@ blob 65535 65535
text 65535 65535 text 65535 65535
text 65535 32767 text 65535 32767
drop table t1; drop table t1;
End of 5.0 tests

View File

@ -924,6 +924,37 @@ NULL
select ifnull(NULL, _utf8'string'); select ifnull(NULL, _utf8'string');
ifnull(NULL, _utf8'string') ifnull(NULL, _utf8'string')
string string
set names utf8;
create table t1 (s1 char(5) character set utf8 collate utf8_lithuanian_ci);
insert into t1 values ('I'),('K'),('Y');
select * from t1 where s1 < 'K' and s1 = 'Y';
s1
I
Y
select * from t1 where 'K' > s1 and s1 = 'Y';
s1
I
Y
drop table t1;
create table t1 (s1 char(5) character set utf8 collate utf8_czech_ci);
insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i');
select * from t1 where s1 > 'd' and s1 = 'CH';
s1
ch
CH
Ch
select * from t1 where 'd' < s1 and s1 = 'CH';
s1
ch
CH
Ch
select * from t1 where s1 = 'cH' and s1 <> 'ch';
s1
cH
select * from t1 where 'cH' = s1 and s1 <> 'ch';
s1
cH
drop table t1;
create table t1 (a varchar(255)) default character set utf8; create table t1 (a varchar(255)) default character set utf8;
insert into t1 values (1.0); insert into t1 values (1.0);
drop table t1; drop table t1;

View File

@ -87,6 +87,10 @@ SELECT IS_USED_LOCK('bug16501');
IS_USED_LOCK('bug16501') IS_USED_LOCK('bug16501')
NULL NULL
DROP TABLE t1; DROP TABLE t1;
select export_set(3, _latin1'foo', _utf8'bar', ',', 4);
export_set(3, _latin1'foo', _utf8'bar', ',', 4)
foo,foo,bar,bar
End of 4.1 tests
create table t1 as select uuid(), length(uuid()); create table t1 as select uuid(), length(uuid());
show create table t1; show create table t1;
Table Create Table Table Create Table
@ -130,3 +134,4 @@ timediff(b, a) >= '00:00:03'
drop table t2; drop table t2;
drop table t1; drop table t1;
set global query_cache_size=default; set global query_cache_size=default;
End of 5.0 tests

View File

@ -911,6 +911,18 @@ union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H); (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H);
H H
5 5
SET NAMES latin1;
SET character_set_results = NULL;
SHOW VARIABLES LIKE 'character_set_results';
Variable_name Value
character_set_results
CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32) CHARACTER SET BINARY);
INSERT INTO testBug8868 VALUES ('2006-09-04', 'abcd');
SELECT DATE_FORMAT(field1,'%b-%e %l:%i%p') as fmtddate, field2 FROM testBug8868;
fmtddate field2
Sep-4 12:00AM abcd
DROP TABLE testBug8868;
SET NAMES DEFAULT;
End of 4.1 tests End of 4.1 tests
explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1, explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,
timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2; timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2;

View File

@ -294,3 +294,4 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY; CREATE TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY;
INSERT INTO t1 VALUES(NULL),(NULL); INSERT INTO t1 VALUES(NULL),(NULL);
DROP TABLE t1; DROP TABLE t1;
End of 5.0 tests

View File

@ -1295,24 +1295,16 @@ insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2; insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1; insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2; insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
select count(*) from t1; select count(*) from t1;
count(*) count(*)
29267 623
explain select * from t1 where c between 1 and 2500; explain select * from t1 where c between 1 and 2500;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL # Using where 1 SIMPLE t1 range c c 5 NULL # Using where
update t1 set c=a; update t1 set c=a;
explain select * from t1 where c between 1 and 2500; explain select * from t1 where c between 1 and 2500;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL # Using where 1 SIMPLE t1 ALL c NULL NULL NULL # Using where
drop table t1,t2; drop table t1,t2;
create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) engine=innodb; create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) engine=innodb;
insert into t1 (id) values (null),(null),(null),(null),(null); insert into t1 (id) values (null),(null),(null),(null),(null);
@ -1786,10 +1778,10 @@ Variable_name Value
Innodb_rows_deleted 2070 Innodb_rows_deleted 2070
show status like "Innodb_rows_inserted"; show status like "Innodb_rows_inserted";
Variable_name Value Variable_name Value
Innodb_rows_inserted 31727 Innodb_rows_inserted 3083
show status like "Innodb_rows_updated"; show status like "Innodb_rows_updated";
Variable_name Value Variable_name Value
Innodb_rows_updated 29530 Innodb_rows_updated 886
show status like "Innodb_row_lock_waits"; show status like "Innodb_row_lock_waits";
Variable_name Value Variable_name Value
Innodb_row_lock_waits 0 Innodb_row_lock_waits 0

View File

@ -407,3 +407,71 @@ Warnings:
Warning 1071 Specified key was too long; max key length is 765 bytes Warning 1071 Specified key was too long; max key length is 765 bytes
insert into t1 values('aaa'); insert into t1 values('aaa');
drop table t1; drop table t1;
CREATE TABLE `t2` (
`k` int(11) NOT NULL auto_increment,
`a` int(11) default NULL,
`c` int(11) default NULL,
PRIMARY KEY (`k`),
UNIQUE KEY `idx_1` (`a`)
) ENGINE=InnoDB;
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
insert into t2 ( a ) values ( 7 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
select last_insert_id();
last_insert_id()
2
select * from t2;
k a c
1 6 NULL
2 7 NULL
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
select last_insert_id();
last_insert_id()
2
select last_insert_id(0);
last_insert_id(0)
0
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
select last_insert_id();
last_insert_id()
0
select * from t2;
k a c
1 6 2
2 7 NULL
insert ignore into t2 values (null,6,1),(10,8,1);
select last_insert_id();
last_insert_id()
0
insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1);
select last_insert_id();
last_insert_id()
11
select * from t2;
k a c
1 6 2
2 7 NULL
10 8 1
11 15 1
12 20 1
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1, k=last_insert_id(k);
select last_insert_id();
last_insert_id()
1
select * from t2;
k a c
1 6 3
2 7 NULL
10 8 1
11 15 1
12 20 1
drop table t2;

View File

@ -59,16 +59,16 @@ database()
test test
unlock tables; unlock tables;
drop table t1; drop table t1;
c_cp932 c_cp932
+----------------------+------------+--------+ +----------------------+------------+--------+
| concat('>',col1,'<') | col2 | col3 | | concat('>',col1,'<') | col2 | col3 |
+----------------------+------------+--------+ +----------------------+------------+--------+

View File

@ -1404,92 +1404,6 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
DROP TABLE t1; DROP TABLE t1;
create database db1;
use db1;
CREATE TABLE t2 (
a varchar(30) default NULL,
KEY a (a(5))
);
INSERT INTO t2 VALUES ('alfred');
INSERT INTO t2 VALUES ('angie');
INSERT INTO t2 VALUES ('bingo');
INSERT INTO t2 VALUES ('waffle');
INSERT INTO t2 VALUES ('lemon');
create view v2 as select * from t2 where a like 'a%' with check option;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t2`;
CREATE TABLE `t2` (
`a` varchar(30) DEFAULT NULL,
KEY `a` (`a`(5))
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
LOCK TABLES `t2` WRITE;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
INSERT INTO `t2` VALUES ('alfred'),('angie'),('bingo'),('waffle'),('lemon');
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` varchar(30)
) */;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') */
/*!50002 WITH CASCADED CHECK OPTION */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop table t2;
drop view v2;
drop database db1;
create database db2;
use db2;
create table t1 (a int);
create table t2 (a int, b varchar(10), primary key(a));
insert into t2 values (1, "on"), (2, "off"), (10, "pol"), (12, "meg");
insert into t1 values (289), (298), (234), (456), (789);
create view v1 as select * from t2;
create view v2 as select * from t1;
drop table t1, t2;
drop view v1, v2;
drop database db2;
create database db1;
use db1;
show tables;
Tables_in_db1
t1
t2
v1
v2
select * from t2 order by a;
a b
1 on
2 off
10 pol
12 meg
drop table t1, t2;
drop database db1;
--fields-optionally-enclosed-by="
CREATE DATABASE mysqldump_test_db; CREATE DATABASE mysqldump_test_db;
USE mysqldump_test_db; USE mysqldump_test_db;
CREATE TABLE t1 ( a INT ); CREATE TABLE t1 ( a INT );
@ -1682,6 +1596,7 @@ select * from t1;
a b a b
Osnabrück Köln Osnabrück Köln
drop table t1; drop table t1;
--fields-optionally-enclosed-by="
create table `t1` ( create table `t1` (
t1_name varchar(255) default null, t1_name varchar(255) default null,
t1_id int(10) unsigned not null auto_increment, t1_id int(10) unsigned not null auto_increment,
@ -1756,8 +1671,9 @@ CREATE TABLE `t2` (
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop table t1, t2, t3; drop table t1, t2, t3;
create table t1 (a binary(1), b blob); create table t1 (a int);
insert into t1 values ('',''); mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `t1` WHERE xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': 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 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 (1064)
mysqldump: Got error: 1064: 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 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 when retrieving data from server
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@ -1771,47 +1687,9 @@ insert into t1 values ('','');
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`; DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`a` binary(1) DEFAULT NULL, `a` int(11) DEFAULT NULL
`b` blob
) ENGINE=MyISAM DEFAULT CHARSET=latin1; ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (0x00,'');
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` binary(1) DEFAULT NULL,
`b` blob
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (0x00,'');
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@ -1823,6 +1701,95 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop table t1; drop table t1;
End of 4.1 tests
create database db1;
use db1;
CREATE TABLE t2 (
a varchar(30) default NULL,
KEY a (a(5))
);
INSERT INTO t2 VALUES ('alfred');
INSERT INTO t2 VALUES ('angie');
INSERT INTO t2 VALUES ('bingo');
INSERT INTO t2 VALUES ('waffle');
INSERT INTO t2 VALUES ('lemon');
create view v2 as select * from t2 where a like 'a%' with check option;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t2`;
CREATE TABLE `t2` (
`a` varchar(30) DEFAULT NULL,
KEY `a` (`a`(5))
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
LOCK TABLES `t2` WRITE;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
INSERT INTO `t2` VALUES ('alfred'),('angie'),('bingo'),('waffle'),('lemon');
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` varchar(30)
) */;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') */
/*!50002 WITH CASCADED CHECK OPTION */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop table t2;
drop view v2;
drop database db1;
use test;
create database db2;
use db2;
create table t1 (a int);
create table t2 (a int, b varchar(10), primary key(a));
insert into t2 values (1, "on"), (2, "off"), (10, "pol"), (12, "meg");
insert into t1 values (289), (298), (234), (456), (789);
create view v1 as select * from t2;
create view v2 as select * from t1;
drop table t1, t2;
drop view v1, v2;
drop database db2;
use test;
create database db1;
use db1;
show tables;
Tables_in_db1
t1
t2
v1
v2
select * from t2 order by a;
a b
1 on
2 off
10 pol
12 meg
drop table t1, t2;
drop database db1;
use test;
create table t1(a int); create table t1(a int);
create view v1 as select * from t1; create view v1 as select * from t1;
@ -2605,44 +2572,6 @@ drop view v2;
drop view v0; drop view v0;
drop view v1; drop view v1;
drop table t1; drop table t1;
drop table if exists t1;
CREATE TABLE t1(a int, b int);
INSERT INTO t1 VALUES (1,1);
INSERT INTO t1 VALUES (2,3);
INSERT INTO t1 VALUES (3,4), (4,5);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
REPLACE INTO `t1` VALUES (1,1),(2,3),(3,4),(4,5);
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
DROP TABLE t1;
SET @old_sql_mode = @@SQL_MODE; SET @old_sql_mode = @@SQL_MODE;
SET SQL_MODE = IGNORE_SPACE; SET SQL_MODE = IGNORE_SPACE;
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
@ -2698,7 +2627,73 @@ DELIMITER ;
DROP TRIGGER tr1; DROP TRIGGER tr1;
DROP TABLE t1; DROP TABLE t1;
End of 4.1 tests create table t1 (a binary(1), b blob);
insert into t1 values ('','');
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` binary(1) DEFAULT NULL,
`b` blob
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (0x00,'');
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` binary(1) DEFAULT NULL,
`b` blob
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (0x00,'');
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop table t1;
create table t1 (a int); create table t1 (a int);
insert into t1 values (289), (298), (234), (456), (789); insert into t1 values (289), (298), (234), (456), (789);
create definer = CURRENT_USER view v1 as select * from t1; create definer = CURRENT_USER view v1 as select * from t1;
@ -2925,7 +2920,60 @@ mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need the SU
grant REPLICATION CLIENT on *.* to mysqltest_1@localhost; grant REPLICATION CLIENT on *.* to mysqltest_1@localhost;
drop table t1; drop table t1;
drop user mysqltest_1@localhost; drop user mysqltest_1@localhost;
create database mysqldump_myDB;
use mysqldump_myDB;
create user myDB_User;
grant create view, select on mysqldump_myDB.* to myDB_User@localhost;
create table t1 (c1 int);
insert into t1 values (3);
use mysqldump_myDB;
create view v1 (c1) as select * from t1;
use mysqldump_myDB;
drop view v1;
drop table t1;
revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
drop user myDB_User;
drop database mysqldump_myDB;
use test;
End of 5.0 tests End of 5.0 tests
drop table if exists t1;
CREATE TABLE t1(a int, b int);
INSERT INTO t1 VALUES (1,1);
INSERT INTO t1 VALUES (2,3);
INSERT INTO t1 VALUES (3,4), (4,5);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
REPLACE INTO `t1` VALUES (1,1),(2,3),(3,4),(4,5);
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
DROP TABLE t1;
create table t1 (a text , b text); create table t1 (a text , b text);
create table t2 (a text , b text); create table t2 (a text , b text);
insert t1 values ("Duck, Duck", "goose"); insert t1 values ("Duck, Duck", "goose");

View File

@ -226,7 +226,7 @@ t1 CREATE TABLE `t1` (
`b` int(11) NOT NULL, `b` int(11) NOT NULL,
`c` int(11) NOT NULL, `c` int(11) NOT NULL,
PRIMARY KEY (`pk1`) PRIMARY KEY (`pk1`)
) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
ALTER TABLE test.t2 TABLESPACE table_space1 STORAGE DISK ALTER TABLE test.t2 TABLESPACE table_space1 STORAGE DISK
ENGINE=NDB; ENGINE=NDB;
SHOW CREATE TABLE test.t2; SHOW CREATE TABLE test.t2;
@ -236,7 +236,7 @@ t2 CREATE TABLE `t2` (
`b2` int(11) NOT NULL, `b2` int(11) NOT NULL,
`c2` int(11) NOT NULL, `c2` int(11) NOT NULL,
PRIMARY KEY (`pk2`) PRIMARY KEY (`pk2`)
) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
ALTER TABLE test.t1 ENGINE=NDBCLUSTER; ALTER TABLE test.t1 ENGINE=NDBCLUSTER;
SHOW CREATE TABLE test.t1; SHOW CREATE TABLE test.t1;
Table Create Table Table Create Table
@ -331,7 +331,7 @@ t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL, `a` int(11) NOT NULL,
`b` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`) PRIMARY KEY (`a`)
) TABLESPACE ts1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
SHOW CREATE TABLE t2; SHOW CREATE TABLE t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
@ -931,7 +931,7 @@ t1 CREATE TABLE `t1` (
`a1` int(11) DEFAULT NULL, `a1` int(11) DEFAULT NULL,
`a2` blob, `a2` blob,
`a3` text `a3` text
) TABLESPACE ts STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
DROP TABLE test.t1; DROP TABLE test.t1;
CREATE TABLE test.t1 (a1 INT, a2 BLOB, a3 TEXT) ENGINE=MyISAM; CREATE TABLE test.t1 (a1 INT, a2 BLOB, a3 TEXT) ENGINE=MyISAM;
SHOW CREATE TABLE test.t1; SHOW CREATE TABLE test.t1;
@ -950,7 +950,7 @@ t1 CREATE TABLE `t1` (
`a1` int(11) DEFAULT NULL, `a1` int(11) DEFAULT NULL,
`a2` blob, `a2` blob,
`a3` text `a3` text
) TABLESPACE ts STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
DROP TABLE test.t1; DROP TABLE test.t1;
CREATE TABLE test.t1 (a1 INT PRIMARY KEY, a2 BLOB, a3 TEXT) TABLESPACE ts STORAGE DISK ENGINE=NDB; CREATE TABLE test.t1 (a1 INT PRIMARY KEY, a2 BLOB, a3 TEXT) TABLESPACE ts STORAGE DISK ENGINE=NDB;
SHOW CREATE TABLE test.t1; SHOW CREATE TABLE test.t1;
@ -960,7 +960,7 @@ t1 CREATE TABLE `t1` (
`a2` blob, `a2` blob,
`a3` text, `a3` text,
PRIMARY KEY (`a1`) PRIMARY KEY (`a1`)
) TABLESPACE ts STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
ALTER TABLE test.t1 ENGINE=InnoDB; ALTER TABLE test.t1 ENGINE=InnoDB;
SHOW CREATE TABLE test.t1; SHOW CREATE TABLE test.t1;
Table Create Table Table Create Table
@ -980,7 +980,7 @@ t1 CREATE TABLE `t1` (
`a1` int(11) DEFAULT NULL, `a1` int(11) DEFAULT NULL,
`a2` blob, `a2` blob,
`a3` text `a3` text
) TABLESPACE ts STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
ALTER TABLE test.t1 ENGINE=MyISAM; ALTER TABLE test.t1 ENGINE=MyISAM;
SHOW CREATE TABLE test.t1; SHOW CREATE TABLE test.t1;
Table Create Table Table Create Table

View File

@ -30,7 +30,7 @@ t1 CREATE TABLE `t1` (
`a2` varchar(256) DEFAULT NULL, `a2` varchar(256) DEFAULT NULL,
`a3` blob, `a3` blob,
PRIMARY KEY (`a1`) PRIMARY KEY (`a1`)
) TABLESPACE ts1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
SHOW CREATE TABLE test.t2; SHOW CREATE TABLE test.t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
@ -38,7 +38,7 @@ t2 CREATE TABLE `t2` (
`a2` varchar(256) DEFAULT NULL, `a2` varchar(256) DEFAULT NULL,
`a3` blob, `a3` blob,
PRIMARY KEY (`a1`) PRIMARY KEY (`a1`)
) TABLESPACE ts2 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
INSERT INTO test.t1 VALUES (1,'111111','aaaaaaaa'); INSERT INTO test.t1 VALUES (1,'111111','aaaaaaaa');
INSERT INTO test.t1 VALUES (2,'222222','bbbbbbbb'); INSERT INTO test.t1 VALUES (2,'222222','bbbbbbbb');
SELECT * FROM test.t1 ORDER BY a1; SELECT * FROM test.t1 ORDER BY a1;
@ -93,7 +93,7 @@ t1 CREATE TABLE `t1` (
`a2` varchar(5000) DEFAULT NULL, `a2` varchar(5000) DEFAULT NULL,
`a3` blob, `a3` blob,
PRIMARY KEY (`a1`) PRIMARY KEY (`a1`)
) TABLESPACE ts1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
SHOW CREATE TABLE test.t2; SHOW CREATE TABLE test.t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
@ -101,7 +101,7 @@ t2 CREATE TABLE `t2` (
`a2` varchar(5000) DEFAULT NULL, `a2` varchar(5000) DEFAULT NULL,
`a3` blob, `a3` blob,
PRIMARY KEY (`a1`) PRIMARY KEY (`a1`)
) TABLESPACE ts2 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
INSERT INTO test.t1 VALUES (1,@vc1,@d1); INSERT INTO test.t1 VALUES (1,@vc1,@d1);
INSERT INTO test.t1 VALUES (2,@vc2,@b1); INSERT INTO test.t1 VALUES (2,@vc2,@b1);
INSERT INTO test.t1 VALUES (3,@vc3,@d2); INSERT INTO test.t1 VALUES (3,@vc3,@d2);

View File

@ -175,7 +175,7 @@ t1 CREATE TABLE `t1` (
`c3` int(11) NOT NULL, `c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL, `c4` bit(1) NOT NULL,
PRIMARY KEY (`pk1`,`c3`) PRIMARY KEY (`pk1`,`c3`)
) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c3) PARTITIONS 4 */ ) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c3) PARTITIONS 4 */
SHOW CREATE TABLE test.t2; SHOW CREATE TABLE test.t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
@ -184,7 +184,7 @@ t2 CREATE TABLE `t2` (
`c3` int(11) NOT NULL, `c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL, `c4` bit(1) NOT NULL,
PRIMARY KEY (`pk1`,`c3`) PRIMARY KEY (`pk1`,`c3`)
) TABLESPACE table_space2 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (c3) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) */ ) /*!50100 TABLESPACE table_space2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (c3) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) */
SHOW CREATE TABLE test.t3; SHOW CREATE TABLE test.t3;
Table Create Table Table Create Table
t3 CREATE TABLE `t3` ( t3 CREATE TABLE `t3` (
@ -193,7 +193,7 @@ t3 CREATE TABLE `t3` (
`c3` int(11) NOT NULL, `c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL, `c4` bit(1) NOT NULL,
PRIMARY KEY (`pk1`,`c3`) PRIMARY KEY (`pk1`,`c3`)
) TABLESPACE table_space2 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (c3) (PARTITION x1 VALUES LESS THAN (105) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (720) ENGINE = ndbcluster) */ ) /*!50100 TABLESPACE table_space2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (c3) (PARTITION x1 VALUES LESS THAN (105) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (720) ENGINE = ndbcluster) */
SHOW CREATE TABLE test.t4; SHOW CREATE TABLE test.t4;
Table Create Table Table Create Table
t4 CREATE TABLE `t4` ( t4 CREATE TABLE `t4` (
@ -341,7 +341,7 @@ t1 CREATE TABLE `t1` (
`c3` int(11) NOT NULL, `c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL, `c4` bit(1) NOT NULL,
PRIMARY KEY (`pk1`,`c3`) PRIMARY KEY (`pk1`,`c3`)
) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c3) PARTITIONS 4 */ ) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c3) PARTITIONS 4 */
SHOW CREATE TABLE test.t2; SHOW CREATE TABLE test.t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
@ -350,7 +350,7 @@ t2 CREATE TABLE `t2` (
`c3` int(11) NOT NULL, `c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL, `c4` bit(1) NOT NULL,
PRIMARY KEY (`pk1`,`c3`) PRIMARY KEY (`pk1`,`c3`)
) TABLESPACE table_space2 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (c3) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) */ ) /*!50100 TABLESPACE table_space2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (c3) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) */
SHOW CREATE TABLE test.t3; SHOW CREATE TABLE test.t3;
Table Create Table Table Create Table
t3 CREATE TABLE `t3` ( t3 CREATE TABLE `t3` (
@ -359,7 +359,7 @@ t3 CREATE TABLE `t3` (
`c3` int(11) NOT NULL, `c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL, `c4` bit(1) NOT NULL,
PRIMARY KEY (`pk1`,`c3`) PRIMARY KEY (`pk1`,`c3`)
) TABLESPACE table_space2 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (c3) (PARTITION x1 VALUES LESS THAN (105) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (720) ENGINE = ndbcluster) */ ) /*!50100 TABLESPACE table_space2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (c3) (PARTITION x1 VALUES LESS THAN (105) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (720) ENGINE = ndbcluster) */
SHOW CREATE TABLE test.t4; SHOW CREATE TABLE test.t4;
Table Create Table Table Create Table
t4 CREATE TABLE `t4` ( t4 CREATE TABLE `t4` (

View File

@ -49,7 +49,7 @@ t1 CREATE TABLE `t1` (
`b` int(11) NOT NULL, `b` int(11) NOT NULL,
`c` int(11) NOT NULL, `c` int(11) NOT NULL,
PRIMARY KEY (`pk1`) PRIMARY KEY (`pk1`)
) TABLESPACE ts1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES (0, 0, 0); INSERT INTO t1 VALUES (0, 0, 0);
SELECT * FROM t1; SELECT * FROM t1;
pk1 b c pk1 b c

View File

@ -226,7 +226,7 @@ t1 CREATE TABLE `t1` (
`b` int(11) NOT NULL, `b` int(11) NOT NULL,
`c` int(11) NOT NULL, `c` int(11) NOT NULL,
PRIMARY KEY (`pk1`) PRIMARY KEY (`pk1`)
) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
ALTER TABLE test.t2 TABLESPACE table_space1 STORAGE DISK ALTER TABLE test.t2 TABLESPACE table_space1 STORAGE DISK
ENGINE=NDB; ENGINE=NDB;
SHOW CREATE TABLE test.t2; SHOW CREATE TABLE test.t2;
@ -236,7 +236,7 @@ t2 CREATE TABLE `t2` (
`b2` int(11) NOT NULL, `b2` int(11) NOT NULL,
`c2` int(11) NOT NULL, `c2` int(11) NOT NULL,
PRIMARY KEY (`pk2`) PRIMARY KEY (`pk2`)
) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
ALTER TABLE test.t1 ENGINE=NDBCLUSTER; ALTER TABLE test.t1 ENGINE=NDBCLUSTER;
SHOW CREATE TABLE test.t1; SHOW CREATE TABLE test.t1;
Table Create Table Table Create Table

View File

@ -1134,12 +1134,12 @@ partition by range (a)
subpartition by hash (a) subpartition by hash (a)
(partition p0 VALUES LESS THAN (1) DATA DIRECTORY = 'hello/master-data/tmpdata' INDEX DIRECTORY = 'hello/master-data/tmpinx' (partition p0 VALUES LESS THAN (1) DATA DIRECTORY = 'hello/master-data/tmpdata' INDEX DIRECTORY = 'hello/master-data/tmpinx'
(SUBPARTITION subpart00, SUBPARTITION subpart01)); (SUBPARTITION subpart00, SUBPARTITION subpart01));
hello/master-data/test/t1.frm
hello/master-data/test/t1.par
hello/master-data/test/t1#P#p0#SP#subpart00.MYD hello/master-data/test/t1#P#p0#SP#subpart00.MYD
hello/master-data/test/t1#P#p0#SP#subpart00.MYI hello/master-data/test/t1#P#p0#SP#subpart00.MYI
hello/master-data/test/t1#P#p0#SP#subpart01.MYD hello/master-data/test/t1#P#p0#SP#subpart01.MYD
hello/master-data/test/t1#P#p0#SP#subpart01.MYI hello/master-data/test/t1#P#p0#SP#subpart01.MYI
hello/master-data/test/t1.frm
hello/master-data/test/t1.par
hello/master-data/tmpdata/t1#P#p0#SP#subpart00.MYD hello/master-data/tmpdata/t1#P#p0#SP#subpart00.MYD
hello/master-data/tmpdata/t1#P#p0#SP#subpart01.MYD hello/master-data/tmpdata/t1#P#p0#SP#subpart01.MYD
hello/master-data/tmpinx/t1#P#p0#SP#subpart00.MYI hello/master-data/tmpinx/t1#P#p0#SP#subpart00.MYI
@ -1149,6 +1149,8 @@ ALTER TABLE t1 REORGANIZE PARTITION p0 INTO
(SUBPARTITION subpart10, SUBPARTITION subpart11), (SUBPARTITION subpart10, SUBPARTITION subpart11),
partition p2 VALUES LESS THAN (2) DATA DIRECTORY = 'hello/master-data/tmpdata' INDEX DIRECTORY = 'hello/master-data/tmpinx' partition p2 VALUES LESS THAN (2) DATA DIRECTORY = 'hello/master-data/tmpdata' INDEX DIRECTORY = 'hello/master-data/tmpinx'
(SUBPARTITION subpart20, SUBPARTITION subpart21)); (SUBPARTITION subpart20, SUBPARTITION subpart21));
hello/master-data/test/t1.frm
hello/master-data/test/t1.par
hello/master-data/test/t1#P#p1#SP#subpart10.MYD hello/master-data/test/t1#P#p1#SP#subpart10.MYD
hello/master-data/test/t1#P#p1#SP#subpart10.MYI hello/master-data/test/t1#P#p1#SP#subpart10.MYI
hello/master-data/test/t1#P#p1#SP#subpart11.MYD hello/master-data/test/t1#P#p1#SP#subpart11.MYD
@ -1157,8 +1159,6 @@ hello/master-data/test/t1#P#p2#SP#subpart20.MYD
hello/master-data/test/t1#P#p2#SP#subpart20.MYI hello/master-data/test/t1#P#p2#SP#subpart20.MYI
hello/master-data/test/t1#P#p2#SP#subpart21.MYD hello/master-data/test/t1#P#p2#SP#subpart21.MYD
hello/master-data/test/t1#P#p2#SP#subpart21.MYI hello/master-data/test/t1#P#p2#SP#subpart21.MYI
hello/master-data/test/t1.frm
hello/master-data/test/t1.par
hello/master-data/tmpdata/t1#P#p1#SP#subpart10.MYD hello/master-data/tmpdata/t1#P#p1#SP#subpart10.MYD
hello/master-data/tmpdata/t1#P#p1#SP#subpart11.MYD hello/master-data/tmpdata/t1#P#p1#SP#subpart11.MYD
hello/master-data/tmpdata/t1#P#p2#SP#subpart20.MYD hello/master-data/tmpdata/t1#P#p2#SP#subpart20.MYD

View File

@ -695,4 +695,19 @@ Level Code Message
Warning 1541 The syntax 'SHOW PLUGIN' is deprecated and will be removed in MySQL 5.2. Please use 'SHOW PLUGINS' instead Warning 1541 The syntax 'SHOW PLUGIN' is deprecated and will be removed in MySQL 5.2. Please use 'SHOW PLUGINS' instead
show plugin; show plugin;
show plugins; show plugins;
create database `mysqlttest\1`;
create table `mysqlttest\1`.`a\b` (a int);
show tables from `mysqlttest\1`;
Tables_in_mysqlttest\1
a\b
show fields from `mysqlttest\1`.`a\b`;
Field Type Null Key Default Extra
a int(11) YES NULL
show columns from `a\b` from `mysqlttest\1`;
Field Type Null Key Default Extra
a int(11) YES NULL
show keys from `mysqlttest\1`.`a\b`;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
drop table `mysqlttest\1`.`a\b`;
drop database `mysqlttest\1`;
End of 5.1 tests End of 5.1 tests

View File

@ -689,6 +689,12 @@ select @@log_queries_not_using_indexes;
show variables like 'log_queries_not_using_indexes'; show variables like 'log_queries_not_using_indexes';
Variable_name Value Variable_name Value
log_queries_not_using_indexes OFF log_queries_not_using_indexes OFF
select @@"";
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 '""' at line 1
select @@&;
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 '&' at line 1
select @@@;
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 '@' at line 1
End of 5.0 tests End of 5.0 tests
set global binlog_cache_size =@my_binlog_cache_size; set global binlog_cache_size =@my_binlog_cache_size;
set global connect_timeout =@my_connect_timeout; set global connect_timeout =@my_connect_timeout;

View File

@ -2849,6 +2849,36 @@ SHOW TABLES;
Tables_in_test Tables_in_test
t1 t1
DROP TABLE t1; DROP TABLE t1;
DROP VIEW IF EXISTS v1;
CREATE DATABASE bug21261DB;
USE bug21261DB;
CREATE TABLE t1 (x INT);
CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
GRANT INSERT, UPDATE ON v1 TO 'user21261'@'localhost';
GRANT INSERT, UPDATE ON t1 TO 'user21261'@'localhost';
CREATE TABLE t2 (y INT);
GRANT SELECT ON t2 TO 'user21261'@'localhost';
INSERT INTO v1 (x) VALUES (5);
UPDATE v1 SET x=1;
GRANT SELECT ON v1 TO 'user21261'@'localhost';
GRANT SELECT ON t1 TO 'user21261'@'localhost';
UPDATE v1,t2 SET x=1 WHERE x=y;
SELECT * FROM t1;
x
1
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost';
DROP USER 'user21261'@'localhost';
DROP VIEW v1;
DROP TABLE t1;
DROP DATABASE bug21261DB;
USE test;
create table t1 (f1 datetime);
create view v1 as select * from t1 where f1 between now() and now() + interval 1 minute;
show create view v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` where (`t1`.`f1` between now() and (now() + interval 1 minute))
drop view v1;
drop table t1;
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
DROP VIEW IF EXISTS v1; DROP VIEW IF EXISTS v1;
DROP VIEW IF EXISTS v2; DROP VIEW IF EXISTS v2;
@ -2887,32 +2917,3 @@ DROP FUNCTION f2;
DROP VIEW v1, v2; DROP VIEW v1, v2;
DROP TABLE t1; DROP TABLE t1;
End of 5.0 tests. End of 5.0 tests.
CREATE DATABASE bug21261DB;
USE bug21261DB;
CREATE TABLE t1 (x INT);
CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
GRANT INSERT, UPDATE ON v1 TO 'user21261'@'localhost';
GRANT INSERT, UPDATE ON t1 TO 'user21261'@'localhost';
CREATE TABLE t2 (y INT);
GRANT SELECT ON t2 TO 'user21261'@'localhost';
INSERT INTO v1 (x) VALUES (5);
UPDATE v1 SET x=1;
GRANT SELECT ON v1 TO 'user21261'@'localhost';
GRANT SELECT ON t1 TO 'user21261'@'localhost';
UPDATE v1,t2 SET x=1 WHERE x=y;
SELECT * FROM t1;
x
1
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost';
DROP USER 'user21261'@'localhost';
DROP VIEW v1;
DROP TABLE t1;
DROP DATABASE bug21261DB;
USE test;
create table t1 (f1 datetime);
create view v1 as select * from t1 where f1 between now() and now() + interval 1 minute;
show create view v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` where (`t1`.`f1` between now() and (now() + interval 1 minute))
drop view v1;
drop table t1;

View File

@ -6,3 +6,31 @@ use prn;
ERROR 42000: Unknown database 'prn' ERROR 42000: Unknown database 'prn'
create table nu (a int); create table nu (a int);
drop table nu; drop table nu;
CREATE TABLE `t1` (
`TIM` datetime NOT NULL,
`VAL` double default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `t2` (
`TIM` datetime NOT NULL,
`VAL` double default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `mt` (
`TIM` datetime NOT NULL,
`VAL` double default NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST
UNION=(`t1`,`t2`);
INSERT INTO mt VALUES ('2006-01-01',0);
ALTER TABLE `t2` RENAME TO `t`;
INSERT INTO mt VALUES ('2006-01-01',0);
ERROR HY000: Can't lock file (errno: 155)
select * from mt;
ERROR HY000: Can't lock file (errno: 155)
FLUSH TABLES;
select * from mt;
ERROR HY000: Can't find file: 'mt' (errno: 2)
ALTER TABLE `t` RENAME TO `t2`;
INSERT INTO mt VALUES ('2006-01-01',0);
select * from mt;
TIM VAL
2006-01-01 00:00:00 0
2006-01-01 00:00:00 0

View File

@ -304,42 +304,6 @@ INSERT INTO t1 VALUES(1, 1);
ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment; ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment;
DROP TABLE t1; DROP TABLE t1;
# Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY
# UPDATE": now LAST_INSERT_ID() will return the id of the updated
# row.
CREATE TABLE `t2` (
`k` int(11) NOT NULL auto_increment,
`a` int(11) default NULL,
`c` int(11) default NULL,
PRIMARY KEY (`k`),
UNIQUE KEY `idx_1` (`a`)
) ENGINE=InnoDB;
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
insert into t2 ( a ) values ( 7 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
select last_insert_id();
select * from t2;
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
select last_insert_id();
select * from t2;
# Test of LAST_INSERT_ID() when autogenerated will fail:
# last_insert_id() should not change
insert ignore into t2 values (null,6,1),(10,8,1);
select last_insert_id();
# First and second autogenerated will fail, last_insert_id() should
# point to third
insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1);
select last_insert_id();
select * from t2;
drop table t2;
# Test of REPLACE when it does INSERT+DELETE and not UPDATE: # Test of REPLACE when it does INSERT+DELETE and not UPDATE:
# see if it sets LAST_INSERT_ID() ok # see if it sets LAST_INSERT_ID() ok
create table t1 (a int primary key auto_increment, b int, c int, d timestamp default current_timestamp, unique(b),unique(c)); create table t1 (a int primary key auto_increment, b int, c int, d timestamp default current_timestamp, unique(b),unique(c));

View File

@ -1,4 +1,5 @@
--source include/have_debug.inc --source include/have_debug.inc
--source include/have_innodb.inc
CREATE TABLE t1(a int) engine=innodb; CREATE TABLE t1(a int) engine=innodb;
START TRANSACTION; START TRANSACTION;

View File

@ -187,4 +187,16 @@ select rpad(c1,3,'
#select case c1 when 'ß' then 'ß' when 'ö' then 'ö' else 'c' end from t1; #select case c1 when 'ß' then 'ß' when 'ö' then 'ö' else 'c' end from t1;
#select export_set(5,c1,'ö'), export_set(5,'ö',c1) from t1; #select export_set(5,c1,'ö'), export_set(5,'ö',c1) from t1;
drop table t1; drop table t1;
# End of 4.1 tests
#
# Bug 20695: problem with field default value's character set
#
set names koi8r;
create table t1(a char character set cp1251 default _koi8r 0xFF);
show create table t1;
drop table t1;
--error 1067
create table t1(a char character set latin1 default _cp1251 0xFF);
--echo End of 4.1 tests

View File

@ -465,7 +465,51 @@ INSERT INTO t1 VALUES (1, 'ZZZZZ'), (1, 'ZZZ'), (2, 'ZZZ'), (2, 'ZZZZZ');
SELECT id, MIN(s) FROM t1 GROUP BY id; SELECT id, MIN(s) FROM t1 GROUP BY id;
DROP TABLE t1; DROP TABLE t1;
# End of 4.1 tests
#
# Bug #20536: md5() with GROUP BY and UCS2 return different results on myisam/innodb
#
--disable_warnings
drop table if exists bug20536;
--enable_warnings
set names latin1;
create table bug20536 (id bigint not null auto_increment primary key, name
varchar(255) character set ucs2 not null);
insert into `bug20536` (`id`,`name`) values (1, _latin1 x'7465737431'), (2, "'test\\_2'");
select md5(name) from bug20536;
select sha1(name) from bug20536;
select make_set(3, name, upper(name)) from bug20536;
select export_set(5, name, upper(name)) from bug20536;
select export_set(5, name, upper(name), ",", 5) from bug20536;
# Some broken functions: add these tests just to document current behavior.
# PASSWORD and OLD_PASSWORD don't work with UCS2 strings, but to fix it would
# not be backwards compatible in all cases, so it's best to leave it alone
select password(name) from bug20536;
select old_password(name) from bug20536;
# Disable test case as encrypt relies on 'crypt' function.
# "decrypt" is noramlly tested in func_crypt.test which have a
# "have_crypt.inc" test
--disable_parsing
# ENCRYPT relies on OS function crypt() which takes a NUL-terminated string; it
# doesn't return good results for strings with embedded 0 bytes. It won't be
# fixed unless we choose to re-implement the crypt() function ourselves to take
# an extra size_t string_length argument.
select encrypt(name, 'SALT') from bug20536;
--enable_parsing
# QUOTE doesn't work with UCS2 data. It would require a total rewrite
# of Item_func_quote::val_str(), which isn't worthwhile until UCS2 is
# supported fully as a client character set.
select quote(name) from bug20536;
drop table bug20536;
--echo End of 4.1 tests
# #
# Conversion from an UCS2 string to a decimal column # Conversion from an UCS2 string to a decimal column
@ -497,3 +541,5 @@ create table t1(a blob, b text charset utf8, c text charset ucs2);
select data_type, character_octet_length, character_maximum_length select data_type, character_octet_length, character_maximum_length
from information_schema.columns where table_name='t1'; from information_schema.columns where table_name='t1';
drop table t1; drop table t1;
--echo End of 5.0 tests

View File

@ -727,6 +727,24 @@ drop table t1;
select repeat(_utf8'+',3) as h union select NULL; select repeat(_utf8'+',3) as h union select NULL;
select ifnull(NULL, _utf8'string'); select ifnull(NULL, _utf8'string');
#
# Bug#9509 Optimizer: wrong result after AND with comparisons
#
set names utf8;
create table t1 (s1 char(5) character set utf8 collate utf8_lithuanian_ci);
insert into t1 values ('I'),('K'),('Y');
select * from t1 where s1 < 'K' and s1 = 'Y';
select * from t1 where 'K' > s1 and s1 = 'Y';
drop table t1;
create table t1 (s1 char(5) character set utf8 collate utf8_czech_ci);
insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i');
select * from t1 where s1 > 'd' and s1 = 'CH';
select * from t1 where 'd' < s1 and s1 = 'CH';
select * from t1 where s1 = 'cH' and s1 <> 'ch';
select * from t1 where 'cH' = s1 and s1 <> 'ch';
drop table t1;
# #
# Bug#10714: Inserting double value into utf8 column crashes server # Bug#10714: Inserting double value into utf8 column crashes server
# #

View File

@ -31,7 +31,6 @@ rpl_ndb_innodb2ndb : Bug #19710 Cluster replication to partition table fa
#rpl_ndb_log : BUG#18947 2006-03-21 tomas CRBR: order in binlog of create table and insert (on different table) not determ #rpl_ndb_log : BUG#18947 2006-03-21 tomas CRBR: order in binlog of create table and insert (on different table) not determ
rpl_ndb_myisam2ndb : Bug #19710 Cluster replication to partition table fails on DELETE FROM statement rpl_ndb_myisam2ndb : Bug #19710 Cluster replication to partition table fails on DELETE FROM statement
rpl_row_blob_innodb : BUG#18980 2006-04-10 kent Test fails randomly rpl_row_blob_innodb : BUG#18980 2006-04-10 kent Test fails randomly
rpl_row_func003 : BUG#19074 2006-13-04 andrei test failed
rpl_sp : BUG#16456 2006-02-16 jmiller rpl_sp : BUG#16456 2006-02-16 jmiller
rpl_sp_effects : BUG#19862 2006-06-15 mkindahl rpl_sp_effects : BUG#19862 2006-06-15 mkindahl

View File

@ -78,7 +78,13 @@ connection default;
DROP TABLE t1; DROP TABLE t1;
# End of 4.1 tests #
# Bug #21531: EXPORT_SET() doesn't accept args with coercible character sets
#
select export_set(3, _latin1'foo', _utf8'bar', ',', 4);
--echo End of 4.1 tests
# #
# Test for BUG#9535 # Test for BUG#9535
@ -87,7 +93,9 @@ create table t1 as select uuid(), length(uuid());
show create table t1; show create table t1;
drop table t1; drop table t1;
#
# Bug #6760: Add SLEEP() function # Bug #6760: Add SLEEP() function
#
create table t1 (a timestamp default '2005-05-05 01:01:01', create table t1 (a timestamp default '2005-05-05 01:01:01',
b timestamp default '2005-05-05 01:01:01'); b timestamp default '2005-05-05 01:01:01');
insert into t1 set a = now(); insert into t1 set a = now();
@ -117,4 +125,4 @@ drop table t2;
drop table t1; drop table t1;
set global query_cache_size=default; set global query_cache_size=default;
# End of 5.0 tests --echo End of 5.0 tests

View File

@ -464,6 +464,24 @@ union
union union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H); (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H);
#
# 21913: DATE_FORMAT() Crashes mysql server if I use it through
# mysql-connector-j driver.
#
SET NAMES latin1;
SET character_set_results = NULL;
SHOW VARIABLES LIKE 'character_set_results';
CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32) CHARACTER SET BINARY);
INSERT INTO testBug8868 VALUES ('2006-09-04', 'abcd');
SELECT DATE_FORMAT(field1,'%b-%e %l:%i%p') as fmtddate, field2 FROM testBug8868;
DROP TABLE testBug8868;
SET NAMES DEFAULT;
--echo End of 4.1 tests --echo End of 4.1 tests
explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1, explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,

View File

@ -682,8 +682,6 @@ drop table t2;
drop table t1; drop table t1;
# #
# Bug#20214: Incorrect error when user calls SHOW CREATE VIEW on non # Bug#20214: Incorrect error when user calls SHOW CREATE VIEW on non
# privileged view # privileged view

View File

@ -204,3 +204,4 @@ CREATE TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY;
INSERT INTO t1 VALUES(NULL),(NULL); INSERT INTO t1 VALUES(NULL),(NULL);
DROP TABLE t1; DROP TABLE t1;
--echo End of 5.0 tests

View File

@ -904,14 +904,6 @@ insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2; insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1; insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2; insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
select count(*) from t1; select count(*) from t1;
--replace_column 9 # --replace_column 9 #
explain select * from t1 where c between 1 and 2500; explain select * from t1 where c between 1 and 2500;

View File

@ -367,3 +367,55 @@ create table t1(f1 varchar(800) binary not null, key(f1)) engine = innodb
character set utf8 collate utf8_general_ci; character set utf8 collate utf8_general_ci;
insert into t1 values('aaa'); insert into t1 values('aaa');
drop table t1; drop table t1;
# Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY
# UPDATE": if the row is updated, it's like a regular UPDATE:
# LAST_INSERT_ID() is not affected.
CREATE TABLE `t2` (
`k` int(11) NOT NULL auto_increment,
`a` int(11) default NULL,
`c` int(11) default NULL,
PRIMARY KEY (`k`),
UNIQUE KEY `idx_1` (`a`)
) ENGINE=InnoDB;
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
insert into t2 ( a ) values ( 7 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
select last_insert_id();
select * from t2;
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
select last_insert_id();
# test again when last_insert_id() is 0 initially
select last_insert_id(0);
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
select last_insert_id();
select * from t2;
# Test of LAST_INSERT_ID() when autogenerated will fail:
# last_insert_id() should not change
insert ignore into t2 values (null,6,1),(10,8,1);
select last_insert_id();
# First and second autogenerated will fail, last_insert_id() should
# point to third
insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1);
select last_insert_id();
select * from t2;
# Test of the workaround which enables people to know the id of the
# updated row in INSERT ON DUPLICATE KEY UPDATE, by using
# LAST_INSERT_ID(autoinc_col) in the UPDATE clause.
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1, k=last_insert_id(k);
select last_insert_id();
select * from t2;
drop table t2;

View File

@ -52,8 +52,8 @@ drop table t1;
--exec $MYSQL --default-character-set=cp932 test -e "charset utf8;" --exec $MYSQL --default-character-set=cp932 test -e "charset utf8;"
# its usage to switch internally in mysql to requested charset # its usage to switch internally in mysql to requested charset
--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; set @@session.character_set_client= cp932; select 'ƒ\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('ƒ\'); select * from t1; drop table t1;" --exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('ƒ\'); select * from t1; drop table t1;"
--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; set character_set_client= cp932; select 'ƒ\'" --exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'"
--exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select 'ƒ\'" --exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select 'ƒ\'"
--exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select 'ƒ\'" --exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select 'ƒ\'"

View File

@ -548,71 +548,6 @@ INSERT INTO t1 VALUES (1),(2),(3);
--exec $MYSQL_DUMP --add-drop-database --skip-comments --databases test --exec $MYSQL_DUMP --add-drop-database --skip-comments --databases test
DROP TABLE t1; DROP TABLE t1;
#
# Bug #10213 mysqldump crashes when dumping VIEWs(on MacOS X)
#
create database db1;
use db1;
CREATE TABLE t2 (
a varchar(30) default NULL,
KEY a (a(5))
);
INSERT INTO t2 VALUES ('alfred');
INSERT INTO t2 VALUES ('angie');
INSERT INTO t2 VALUES ('bingo');
INSERT INTO t2 VALUES ('waffle');
INSERT INTO t2 VALUES ('lemon');
create view v2 as select * from t2 where a like 'a%' with check option;
--exec $MYSQL_DUMP --skip-comments db1
drop table t2;
drop view v2;
drop database db1;
#
# Bug 10713 mysqldump includes database in create view and referenced tables
#
# create table and views in db2
create database db2;
use db2;
create table t1 (a int);
create table t2 (a int, b varchar(10), primary key(a));
insert into t2 values (1, "on"), (2, "off"), (10, "pol"), (12, "meg");
insert into t1 values (289), (298), (234), (456), (789);
create view v1 as select * from t2;
create view v2 as select * from t1;
# dump tables and view from db2
--exec $MYSQL_DUMP db2 > $MYSQLTEST_VARDIR/tmp/bug10713.sql
# drop the db, tables and views
drop table t1, t2;
drop view v1, v2;
drop database db2;
# create db1 and reload dump
create database db1;
use db1;
--exec $MYSQL db1 < $MYSQLTEST_VARDIR/tmp/bug10713.sql
# check that all tables and views could be created
show tables;
select * from t2 order by a;
drop table t1, t2;
drop database db1;
#
# BUG#15328 Segmentation fault occured if my.cnf is invalid for escape sequence
#
--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-file=$MYSQL_TEST_DIR/std_data/bug15328.cnf mysqldump
# #
# Bug #9558 mysqldump --no-data db t1 t2 format still dumps data # Bug #9558 mysqldump --no-data db t1 t2 format still dumps data
# #
@ -719,6 +654,12 @@ select * from t1;
drop table t1; drop table t1;
#
# BUG#15328 Segmentation fault occured if my.cnf is invalid for escape sequence
#
--exec $MYSQL_MY_PRINT_DEFAULTS --config-file=$MYSQL_TEST_DIR/std_data/bug15328.cnf mysqldump
# #
# BUG #19025 mysqldump doesn't correctly dump "auto_increment = [int]" # BUG #19025 mysqldump doesn't correctly dump "auto_increment = [int]"
# #
@ -760,14 +701,74 @@ create table t3(a int);
drop table t1, t2, t3; drop table t1, t2, t3;
# #
# Bug #13318: Bad result with empty field and --hex-blob # Bug #21288: mysqldump segmentation fault when using --where
# #
create table t1 (a binary(1), b blob); create table t1 (a int);
insert into t1 values ('',''); --error 2
--exec $MYSQL_DUMP --skip-comments --skip-extended-insert --hex-blob test t1 --exec $MYSQL_DUMP --skip-comments --force test t1 --where='xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 2>&1
--exec $MYSQL_DUMP --skip-comments --hex-blob test t1
drop table t1; drop table t1;
--echo End of 4.1 tests
#
# Bug #10213 mysqldump crashes when dumping VIEWs(on MacOS X)
#
create database db1;
use db1;
CREATE TABLE t2 (
a varchar(30) default NULL,
KEY a (a(5))
);
INSERT INTO t2 VALUES ('alfred');
INSERT INTO t2 VALUES ('angie');
INSERT INTO t2 VALUES ('bingo');
INSERT INTO t2 VALUES ('waffle');
INSERT INTO t2 VALUES ('lemon');
create view v2 as select * from t2 where a like 'a%' with check option;
--exec $MYSQL_DUMP --skip-comments db1
drop table t2;
drop view v2;
drop database db1;
use test;
#
# Bug 10713 mysqldump includes database in create view and referenced tables
#
# create table and views in db2
create database db2;
use db2;
create table t1 (a int);
create table t2 (a int, b varchar(10), primary key(a));
insert into t2 values (1, "on"), (2, "off"), (10, "pol"), (12, "meg");
insert into t1 values (289), (298), (234), (456), (789);
create view v1 as select * from t2;
create view v2 as select * from t1;
# dump tables and view from db2
--exec $MYSQL_DUMP db2 > $MYSQLTEST_VARDIR/tmp/bug10713.sql
# drop the db, tables and views
drop table t1, t2;
drop view v1, v2;
drop database db2;
use test;
# create db1 and reload dump
create database db1;
use db1;
--exec $MYSQL db1 < $MYSQLTEST_VARDIR/tmp/bug10713.sql
# check that all tables and views could be created
show tables;
select * from t2 order by a;
drop table t1, t2;
drop database db1;
use test;
# #
# dump of view # dump of view
@ -832,6 +833,7 @@ select v3.a from v3, v1 where v1.a=v3.a and v3.b=3 limit 1;
drop view v1, v2, v3; drop view v1, v2, v3;
drop table t1; drop table t1;
# #
# Test for dumping triggers # Test for dumping triggers
# #
@ -1057,20 +1059,6 @@ drop view v0;
drop view v1; drop view v1;
drop table t1; drop table t1;
# Check new --replace option
--disable_warnings
drop table if exists t1;
--enable_warnings
CREATE TABLE t1(a int, b int);
INSERT INTO t1 VALUES (1,1);
INSERT INTO t1 VALUES (2,3);
INSERT INTO t1 VALUES (3,4), (4,5);
--exec $MYSQL_DUMP --replace --skip-comments test t1
DROP TABLE t1;
# #
# BUG#14554 - mysqldump does not separate words "ROW" and "BEGIN" # BUG#14554 - mysqldump does not separate words "ROW" and "BEGIN"
# for tables with trigger created in the IGNORE_SPACE sql mode. # for tables with trigger created in the IGNORE_SPACE sql mode.
@ -1095,7 +1083,14 @@ SET SQL_MODE = @old_sql_mode;
DROP TRIGGER tr1; DROP TRIGGER tr1;
DROP TABLE t1; DROP TABLE t1;
--echo End of 4.1 tests #
# Bug #13318: Bad result with empty field and --hex-blob
#
create table t1 (a binary(1), b blob);
insert into t1 values ('','');
--exec $MYSQL_DUMP --skip-comments --skip-extended-insert --hex-blob test t1
--exec $MYSQL_DUMP --skip-comments --hex-blob test t1
drop table t1;
# #
# Bug 14871 Invalid view dump output # Bug 14871 Invalid view dump output
@ -1126,7 +1121,6 @@ select * from v3 order by a;
drop table t1; drop table t1;
drop view v1, v2, v3, v4, v5; drop view v1, v2, v3, v4, v5;
# #
# Bug #16878 dump of trigger # Bug #16878 dump of trigger
# #
@ -1281,10 +1275,11 @@ use mysqldump_dbb;
drop view v1; drop view v1;
drop table t1; drop table t1;
drop database mysqldump_dbb; drop database mysqldump_dbb;
use test;
# #
# Bug#21215 mysqldump creating incomplete backups without warning # Bug#21215 mysqldump creating incomplete backups without warning
# #
use test;
# Create user without sufficient privs to perform the requested operation # Create user without sufficient privs to perform the requested operation
create user mysqltest_1@localhost; create user mysqltest_1@localhost;
@ -1326,8 +1321,52 @@ grant REPLICATION CLIENT on *.* to mysqltest_1@localhost;
drop table t1; drop table t1;
drop user mysqltest_1@localhost; drop user mysqltest_1@localhost;
#
# Bug #21527 mysqldump incorrectly tries to LOCK TABLES on the
# information_schema database.
#
connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
connection root;
create database mysqldump_myDB;
use mysqldump_myDB;
create user myDB_User;
grant create view, select on mysqldump_myDB.* to myDB_User@localhost;
create table t1 (c1 int);
insert into t1 values (3);
connect (user1,localhost,myDB_User,,mysqldump_myDB,$MASTER_MYPORT,$MASTER_MYSOCK);
connection user1;
use mysqldump_myDB;
create view v1 (c1) as select * from t1;
# Backup should not fail.
--exec $MYSQL_DUMP --all-databases --add-drop-table > $MYSQLTEST_VARDIR/tmp/bug21527.sql
# Clean up
connection root;
use mysqldump_myDB;
drop view v1;
drop table t1;
revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
drop user myDB_User;
drop database mysqldump_myDB;
use test;
--echo End of 5.0 tests --echo End of 5.0 tests
# Check new --replace option
--disable_warnings
drop table if exists t1;
--enable_warnings
CREATE TABLE t1(a int, b int);
INSERT INTO t1 VALUES (1,1);
INSERT INTO t1 VALUES (2,3);
INSERT INTO t1 VALUES (3,4), (4,5);
--exec $MYSQL_DUMP --replace --skip-comments test t1
DROP TABLE t1;
# #
# Added for use-thread option # Added for use-thread option
# #

View File

@ -1340,11 +1340,13 @@ subpartition by hash (a)
(SUBPARTITION subpart00, SUBPARTITION subpart01)); (SUBPARTITION subpart00, SUBPARTITION subpart01));
--replace_result $MYSQLTEST_VARDIR "hello" --replace_result $MYSQLTEST_VARDIR "hello"
--exec ls $MYSQLTEST_VARDIR/master-data/test/t1* || true --exec ls $MYSQLTEST_VARDIR/master-data/test/t1.* || true
--replace_result $MYSQLTEST_VARDIR "hello" --replace_result $MYSQLTEST_VARDIR "hello"
--exec ls $MYSQLTEST_VARDIR/master-data/tmpdata/t1* || true --exec ls $MYSQLTEST_VARDIR/master-data/test/t1#* || true
--replace_result $MYSQLTEST_VARDIR "hello" --replace_result $MYSQLTEST_VARDIR "hello"
--exec ls $MYSQLTEST_VARDIR/master-data/tmpinx/t1* || true --exec ls $MYSQLTEST_VARDIR/master-data/tmpdata/t1#* || true
--replace_result $MYSQLTEST_VARDIR "hello"
--exec ls $MYSQLTEST_VARDIR/master-data/tmpinx/t1#* || true
--replace_result $MYSQLTEST_VARDIR "hello" --replace_result $MYSQLTEST_VARDIR "hello"
eval ALTER TABLE t1 REORGANIZE PARTITION p0 INTO eval ALTER TABLE t1 REORGANIZE PARTITION p0 INTO
@ -1354,11 +1356,13 @@ eval ALTER TABLE t1 REORGANIZE PARTITION p0 INTO
(SUBPARTITION subpart20, SUBPARTITION subpart21)); (SUBPARTITION subpart20, SUBPARTITION subpart21));
--replace_result $MYSQLTEST_VARDIR "hello" --replace_result $MYSQLTEST_VARDIR "hello"
--exec ls $MYSQLTEST_VARDIR/master-data/test/t1* || true --exec ls $MYSQLTEST_VARDIR/master-data/test/t1.* || true
--replace_result $MYSQLTEST_VARDIR "hello" --replace_result $MYSQLTEST_VARDIR "hello"
--exec ls $MYSQLTEST_VARDIR/master-data/tmpdata/t1* || true --exec ls $MYSQLTEST_VARDIR/master-data/test/t1#* || true
--replace_result $MYSQLTEST_VARDIR "hello" --replace_result $MYSQLTEST_VARDIR "hello"
--exec ls $MYSQLTEST_VARDIR/master-data/tmpinx/t1* || true --exec ls $MYSQLTEST_VARDIR/master-data/tmpdata/t1#* || true
--replace_result $MYSQLTEST_VARDIR "hello"
--exec ls $MYSQLTEST_VARDIR/master-data/tmpinx/t1#* || true
drop table t1; drop table t1;
--exec rmdir $MYSQLTEST_VARDIR/master-data/tmpdata || true --exec rmdir $MYSQLTEST_VARDIR/master-data/tmpdata || true

View File

@ -24,11 +24,15 @@ PARTITION BY HASH(CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
--replace_result $MYSQLTEST_VARDIR "hello" --replace_result $MYSQLTEST_VARDIR "hello"
--exec ls $MYSQLTEST_VARDIR/master-data/test/t1* --exec ls $MYSQLTEST_VARDIR/master-data/test/t1#*
--replace_result $MYSQLTEST_VARDIR "hello"
--exec ls $MYSQLTEST_VARDIR/master-data/test/t1.*
ALTER TABLE t1 COALESCE PARTITION 1; ALTER TABLE t1 COALESCE PARTITION 1;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
--replace_result $MYSQLTEST_VARDIR "hello" --replace_result $MYSQLTEST_VARDIR "hello"
--exec ls $MYSQLTEST_VARDIR/master-data/test/t1* --exec ls $MYSQLTEST_VARDIR/master-data/test/t1#*
--replace_result $MYSQLTEST_VARDIR "hello"
--exec ls $MYSQLTEST_VARDIR/master-data/test/t1.*
drop table t1; drop table t1;
# #
# Bug 20767: REORGANIZE partition crashes # Bug 20767: REORGANIZE partition crashes

View File

@ -539,4 +539,17 @@ show plugin;
show plugins; show plugins;
--enable_result_log --enable_result_log
#
# Bug #19874: SHOW COLUMNS and SHOW KEYS handle identifiers containing
# \ incorrectly
#
create database `mysqlttest\1`;
create table `mysqlttest\1`.`a\b` (a int);
show tables from `mysqlttest\1`;
show fields from `mysqlttest\1`.`a\b`;
show columns from `a\b` from `mysqlttest\1`;
show keys from `mysqlttest\1`.`a\b`;
drop table `mysqlttest\1`.`a\b`;
drop database `mysqlttest\1`;
--echo End of 5.1 tests --echo End of 5.1 tests

View File

@ -1,6 +1,9 @@
# Embedded server doesn't support external clients # Embedded server doesn't support external clients
--source include/not_embedded.inc --source include/not_embedded.inc
# Windows doesn't support execution of shell scripts (to fix!!)
--source include/not_windows.inc
# check that CSV engine was compiled in, as the test relies on the presence # check that CSV engine was compiled in, as the test relies on the presence
# of the log tables (which are CSV-based) # of the log tables (which are CSV-based)
--source include/have_csv.inc --source include/have_csv.inc

View File

@ -585,6 +585,16 @@ show variables like 'ssl%';
select @@log_queries_not_using_indexes; select @@log_queries_not_using_indexes;
show variables like 'log_queries_not_using_indexes'; show variables like 'log_queries_not_using_indexes';
#
# Bug#20908: Crash if select @@""
#
--error ER_PARSE_ERROR
select @@"";
--error ER_PARSE_ERROR
select @@&;
--error ER_PARSE_ERROR
select @@@;
--echo End of 5.0 tests --echo End of 5.0 tests
# This is at the very after the versioned tests, since it involves doing # This is at the very after the versioned tests, since it involves doing
@ -620,3 +630,4 @@ set global server_id =@my_server_id;
set global slow_launch_time =@my_slow_launch_time; set global slow_launch_time =@my_slow_launch_time;
set global storage_engine =@my_storage_engine; set global storage_engine =@my_storage_engine;
set global thread_cache_size =@my_thread_cache_size; set global thread_cache_size =@my_thread_cache_size;

View File

@ -2720,8 +2720,51 @@ DROP VIEW t1,v1;
SHOW TABLES; SHOW TABLES;
DROP TABLE t1; DROP TABLE t1;
--disable_warnings
DROP VIEW IF EXISTS v1;
--enable_warnings
#
# Bug #21261: Wrong access rights was required for an insert to a view
#
CREATE DATABASE bug21261DB;
USE bug21261DB;
CONNECT (root,localhost,root,,bug21261DB);
CONNECTION root;
CREATE TABLE t1 (x INT);
CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
GRANT INSERT, UPDATE ON v1 TO 'user21261'@'localhost';
GRANT INSERT, UPDATE ON t1 TO 'user21261'@'localhost';
CREATE TABLE t2 (y INT);
GRANT SELECT ON t2 TO 'user21261'@'localhost';
CONNECT (user21261, localhost, user21261,, bug21261DB);
CONNECTION user21261;
INSERT INTO v1 (x) VALUES (5);
UPDATE v1 SET x=1;
CONNECTION root;
GRANT SELECT ON v1 TO 'user21261'@'localhost';
GRANT SELECT ON t1 TO 'user21261'@'localhost';
CONNECTION user21261;
UPDATE v1,t2 SET x=1 WHERE x=y;
CONNECTION root;
SELECT * FROM t1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost';
DROP USER 'user21261'@'localhost';
DROP VIEW v1;
DROP TABLE t1;
DROP DATABASE bug21261DB;
USE test;
#
# Bug #15950: NOW() optimized away in VIEWs
#
create table t1 (f1 datetime);
create view v1 as select * from t1 where f1 between now() and now() + interval 1 minute;
show create view v1;
drop view v1;
drop table t1;
# #
# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause. # Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause.
# #
@ -2797,45 +2840,3 @@ DROP TABLE t1;
--echo End of 5.0 tests. --echo End of 5.0 tests.
#
# Bug #21261: Wrong access rights was required for an insert to a view
#
CREATE DATABASE bug21261DB;
USE bug21261DB;
CONNECT (root,localhost,root,,bug21261DB);
CONNECTION root;
CREATE TABLE t1 (x INT);
CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
GRANT INSERT, UPDATE ON v1 TO 'user21261'@'localhost';
GRANT INSERT, UPDATE ON t1 TO 'user21261'@'localhost';
CREATE TABLE t2 (y INT);
GRANT SELECT ON t2 TO 'user21261'@'localhost';
CONNECT (user21261, localhost, user21261,, bug21261DB);
CONNECTION user21261;
INSERT INTO v1 (x) VALUES (5);
UPDATE v1 SET x=1;
CONNECTION root;
GRANT SELECT ON v1 TO 'user21261'@'localhost';
GRANT SELECT ON t1 TO 'user21261'@'localhost';
CONNECTION user21261;
UPDATE v1,t2 SET x=1 WHERE x=y;
CONNECTION root;
SELECT * FROM t1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost';
DROP USER 'user21261'@'localhost';
DROP VIEW v1;
DROP TABLE t1;
DROP DATABASE bug21261DB;
USE test;
#
# Bug #15950: NOW() optimized away in VIEWs
#
create table t1 (f1 datetime);
create view v1 as select * from t1 where f1 between now() and now() + interval 1 minute;
show create view v1;
drop view v1;
drop table t1;

View File

@ -18,3 +18,42 @@ create table nu (a int);
drop table nu; drop table nu;
# End of 4.1 tests # End of 4.1 tests
#
# Bug #20789: Merge Subtable Rename Causes Crash
#
CREATE TABLE `t1` (
`TIM` datetime NOT NULL,
`VAL` double default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `t2` (
`TIM` datetime NOT NULL,
`VAL` double default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `mt` (
`TIM` datetime NOT NULL,
`VAL` double default NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST
UNION=(`t1`,`t2`);
# insert into the merge table and thus open it.
INSERT INTO mt VALUES ('2006-01-01',0);
# Alter one of the tables that are part of the merge table
ALTER TABLE `t2` RENAME TO `t`;
# Insert into the merge table that has just been altered
--error 1015
INSERT INTO mt VALUES ('2006-01-01',0);
--error 1015
select * from mt;
FLUSH TABLES;
--error 1017
select * from mt;
# Alter one of the tables that are part of the merge table
ALTER TABLE `t` RENAME TO `t2`;
INSERT INTO mt VALUES ('2006-01-01',0);
select * from mt;

View File

@ -36,48 +36,51 @@
uint my_read(File Filedes, byte *Buffer, uint Count, myf MyFlags) uint my_read(File Filedes, byte *Buffer, uint Count, myf MyFlags)
{ {
uint readbytes,save_count; uint readbytes, save_count;
DBUG_ENTER("my_read"); DBUG_ENTER("my_read");
DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %u MyFlags: %d", DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %u MyFlags: %d",
Filedes, Buffer, Count, MyFlags)); Filedes, Buffer, Count, MyFlags));
save_count=Count; save_count= Count;
for (;;) for (;;)
{ {
errno=0; /* Linux doesn't reset this */ errno= 0; /* Linux doesn't reset this */
if ((readbytes = (uint) read(Filedes, Buffer, Count)) != Count) if ((readbytes= (uint) read(Filedes, Buffer, Count)) != Count)
{ {
my_errno=errno ? errno : -1; my_errno= errno ? errno : -1;
DBUG_PRINT("warning",("Read only %ld bytes off %ld from %d, errno: %d", DBUG_PRINT("warning",("Read only %ld bytes off %ld from %d, errno: %d",
readbytes,Count,Filedes,my_errno)); readbytes, Count, Filedes, my_errno));
#ifdef THREAD #ifdef THREAD
if (readbytes == 0 && errno == EINTR) if ((int) readbytes <= 0 && errno == EINTR)
continue; /* Interrupted */ {
DBUG_PRINT("debug", ("my_read() was interrupted and returned %d", (int) readbytes));
continue; /* Interrupted */
}
#endif #endif
if (MyFlags & (MY_WME | MY_FAE | MY_FNABP)) if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
{ {
if ((int) readbytes == -1) if ((int) readbytes == -1)
my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG), my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG),
my_filename(Filedes),my_errno); my_filename(Filedes),my_errno);
else if (MyFlags & (MY_NABP | MY_FNABP)) else if (MyFlags & (MY_NABP | MY_FNABP))
my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG), my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG),
my_filename(Filedes),my_errno); my_filename(Filedes),my_errno);
} }
if ((int) readbytes == -1 || if ((int) readbytes == -1 ||
((MyFlags & (MY_FNABP | MY_NABP)) && !(MyFlags & MY_FULL_IO))) ((MyFlags & (MY_FNABP | MY_NABP)) && !(MyFlags & MY_FULL_IO)))
DBUG_RETURN(MY_FILE_ERROR); /* Return with error */ DBUG_RETURN(MY_FILE_ERROR); /* Return with error */
if (readbytes > 0 && (MyFlags & MY_FULL_IO)) if (readbytes > 0 && (MyFlags & MY_FULL_IO))
{ {
Buffer+=readbytes; Buffer+= readbytes;
Count-=readbytes; Count-= readbytes;
continue; continue;
} }
} }
if (MyFlags & (MY_NABP | MY_FNABP)) if (MyFlags & (MY_NABP | MY_FNABP))
readbytes=0; /* Ok on read */ readbytes= 0; /* Ok on read */
else if (MyFlags & MY_FULL_IO) else if (MyFlags & MY_FULL_IO)
readbytes=save_count; readbytes= save_count;
break; break;
} }
DBUG_RETURN(readbytes); DBUG_RETURN(readbytes);

18
server-tools/CMakeLists.txt Executable file
View File

@ -0,0 +1,18 @@
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
ADD_DEFINITIONS(-DMYSQL_SERVER -DMYSQL_INSTANCE_MANAGER)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/sql
${PROJECT_SOURCE_DIR}/extra/yassl/include)
ADD_EXECUTABLE(mysqlmanager buffer.cc command.cc commands.cc guardian.cc instance.cc instance_map.cc
instance_options.cc listener.cc log.cc manager.cc messages.cc mysql_connection.cc
mysqlmanager.cc options.cc parse.cc parse_output.cc priv.cc protocol.cc
thread_registry.cc user_map.cc imservice.cpp windowsservice.cpp
user_management_commands.cc
../../sql/net_serv.cc ../../sql-common/pack.c ../../sql/password.c
../../sql/sql_state.c ../../sql-common/client.c ../../libmysql/get_password.c
../../libmysql/errmsg.c)
ADD_DEPENDENCIES(mysqlmanager GenError)
TARGET_LINK_LIBRARIES(mysqlmanager dbug mysys strings taocrypt vio yassl zlib wsock32)

View File

@ -1509,7 +1509,6 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
mysql->options.ssl_ca= strdup_if_not_null(ca); mysql->options.ssl_ca= strdup_if_not_null(ca);
mysql->options.ssl_capath= strdup_if_not_null(capath); mysql->options.ssl_capath= strdup_if_not_null(capath);
mysql->options.ssl_cipher= strdup_if_not_null(cipher); mysql->options.ssl_cipher= strdup_if_not_null(cipher);
mysql->options.ssl_verify_server_cert= FALSE; /* Off by default */
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -2198,7 +2197,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
DBUG_PRINT("info", ("IO layer change done!")); DBUG_PRINT("info", ("IO layer change done!"));
/* Verify server cert */ /* Verify server cert */
if (mysql->options.ssl_verify_server_cert && if ((client_flag & CLIENT_SSL_VERIFY_SERVER_CERT) &&
ssl_verify_server_cert(mysql->net.vio, mysql->host)) ssl_verify_server_cert(mysql->net.vio, mysql->host))
{ {
set_mysql_error(mysql, CR_SSL_CONNECTION_ERROR, unknown_sqlstate); set_mysql_error(mysql, CR_SSL_CONNECTION_ERROR, unknown_sqlstate);
@ -2945,7 +2944,10 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
mysql->reconnect= *(my_bool *) arg; mysql->reconnect= *(my_bool *) arg;
break; break;
case MYSQL_OPT_SSL_VERIFY_SERVER_CERT: case MYSQL_OPT_SSL_VERIFY_SERVER_CERT:
mysql->options.ssl_verify_server_cert= *(my_bool *) arg; if (!arg || test(*(uint*) arg))
mysql->options.client_flag|= CLIENT_SSL_VERIFY_SERVER_CERT;
else
mysql->options.client_flag&= ~CLIENT_SSL_VERIFY_SERVER_CERT;
break; break;
default: default:
DBUG_RETURN(1); DBUG_RETURN(1);

11
sql/examples/CMakeLists.txt Executable file
View File

@ -0,0 +1,11 @@
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql
${CMAKE_SOURCE_DIR}/extra/yassl/include
${CMAKE_SOURCE_DIR}/regex)
IF(WITH_EXAMPLE_STORAGE_ENGINE)
ADD_LIBRARY(example ha_example.cc)
ADD_DEPENDENCIES(example GenError)
ENDIF(WITH_EXAMPLE_STORAGE_ENGINE)

View File

@ -442,13 +442,17 @@ int main(int argc,char **argv)
if (get_options(argc,(char **) argv)) if (get_options(argc,(char **) argv))
exit(1); exit(1);
/* Broken up to indicate that it's not advice to you, gentle reader. */
printf("/*\n\n Do " "not " "edit " "this " "file " "directly!\n\n*/\n");
printf("/* Copyright (C) 2001-2004 MySQL AB\n\ printf("/* Copyright (C) 2001-2004 MySQL AB\n\
This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\ This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\
and you are welcome to modify and redistribute it under the GPL license\n\ and you are welcome to modify and redistribute it under the GPL license\n\
\n*/\n\n"); \n*/\n\n");
printf("/* This code is generated by gen_lex_hash.cc that seeks for\ /* Broken up to indicate that it's not advice to you, gentle reader. */
a perfect\nhash function */\n\n"); printf("/* Do " "not " "edit " "this " "file! This is generated by "
"gen_lex_hash.cc\nthat seeks for a perfect hash function */\n\n");
printf("#include \"lex.h\"\n\n"); printf("#include \"lex.h\"\n\n");
calc_length(); calc_length();
@ -468,6 +472,14 @@ static inline SYMBOL *get_hash_symbol(const char *s,\n\
{\n\ {\n\
register uchar *hash_map;\n\ register uchar *hash_map;\n\
register const char *cur_str= s;\n\ register const char *cur_str= s;\n\
\n\
if (len == 0) {\n\
DBUG_PRINT(\"warning\", (\"get_hash_symbol() received a request for a zero-length symbol, which is probably a mistake.\"));\
return(NULL);\n\
}\n"
);
printf("\
if (function){\n\ if (function){\n\
if (len>sql_functions_max_len) return 0;\n\ if (len>sql_functions_max_len) return 0;\n\
hash_map= sql_functions_map;\n\ hash_map= sql_functions_map;\n\
@ -498,7 +510,10 @@ static inline SYMBOL *get_hash_symbol(const char *s,\n\
cur_struct= uint4korr(hash_map+\n\ cur_struct= uint4korr(hash_map+\n\
(((uint16)cur_struct + cur_char - first_char)*4));\n\ (((uint16)cur_struct + cur_char - first_char)*4));\n\
cur_str++;\n\ cur_str++;\n\
}\n\ }\n"
);
printf("\
}else{\n\ }else{\n\
if (len>symbols_max_len) return 0;\n\ if (len>symbols_max_len) return 0;\n\
hash_map= symbols_map;\n\ hash_map= symbols_map;\n\

View File

@ -3567,7 +3567,7 @@ int handler::ha_external_lock(THD *thd, int lock_type)
int handler::ha_reset() int handler::ha_reset()
{ {
DBUG_ENTER("ha_reset"); DBUG_ENTER("ha_reset");
/* Check that we have called all proper delallocation functions */ /* Check that we have called all proper deallocation functions */
DBUG_ASSERT((byte*) table->def_read_set.bitmap + DBUG_ASSERT((byte*) table->def_read_set.bitmap +
table->s->column_bitmap_size == table->s->column_bitmap_size ==
(byte*) table->def_write_set.bitmap); (byte*) table->def_write_set.bitmap);

View File

@ -124,6 +124,7 @@ String *Item_func_md5::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
String * sptr= args[0]->val_str(str); String * sptr= args[0]->val_str(str);
str->set_charset(&my_charset_bin);
if (sptr) if (sptr)
{ {
my_MD5_CTX context; my_MD5_CTX context;
@ -170,6 +171,7 @@ String *Item_func_sha::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
String * sptr= args[0]->val_str(str); String * sptr= args[0]->val_str(str);
str->set_charset(&my_charset_bin);
if (sptr) /* If we got value different from NULL */ if (sptr) /* If we got value different from NULL */
{ {
SHA1_CONTEXT context; /* Context used to generate SHA1 hash */ SHA1_CONTEXT context; /* Context used to generate SHA1 hash */
@ -1605,7 +1607,7 @@ String *Item_func_encrypt::val_str(String *str)
null_value= 1; null_value= 1;
return 0; return 0;
} }
str->set(tmp,(uint) strlen(tmp),res->charset()); str->set(tmp, (uint) strlen(tmp), &my_charset_bin);
str->copy(); str->copy();
pthread_mutex_unlock(&LOCK_crypt); pthread_mutex_unlock(&LOCK_crypt);
return str; return str;
@ -2041,7 +2043,7 @@ String *Item_func_make_set::val_str(String *str)
return &my_empty_string; return &my_empty_string;
result= &tmp_str; result= &tmp_str;
} }
if (tmp_str.append(',') || tmp_str.append(*res)) if (tmp_str.append(STRING_WITH_LEN(","), &my_charset_bin) || tmp_str.append(*res))
return &my_empty_string; return &my_empty_string;
} }
} }
@ -2719,8 +2721,12 @@ String* Item_func_export_set::val_str(String* str)
} }
break; break;
case 3: case 3:
sep_buf.set(STRING_WITH_LEN(","), default_charset()); {
sep = &sep_buf; /* errors is not checked - assume "," can always be converted */
uint errors;
sep_buf.copy(STRING_WITH_LEN(","), &my_charset_bin, collation.collation, &errors);
sep = &sep_buf;
}
break; break;
default: default:
DBUG_ASSERT(0); // cannot happen DBUG_ASSERT(0); // cannot happen

View File

@ -43,7 +43,10 @@ class Item_func_md5 :public Item_str_func
{ {
String tmp_value; String tmp_value;
public: public:
Item_func_md5(Item *a) :Item_str_func(a) {} Item_func_md5(Item *a) :Item_str_func(a)
{
collation.set(&my_charset_bin);
}
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "md5"; } const char *func_name() const { return "md5"; }
@ -54,7 +57,10 @@ public:
class Item_func_sha :public Item_str_func class Item_func_sha :public Item_str_func
{ {
public: public:
Item_func_sha(Item *a) :Item_str_func(a) {} Item_func_sha(Item *a) :Item_str_func(a)
{
collation.set(&my_charset_bin);
}
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "sha"; } const char *func_name() const { return "sha"; }
@ -333,9 +339,21 @@ public:
class Item_func_encrypt :public Item_str_func class Item_func_encrypt :public Item_str_func
{ {
String tmp_value; String tmp_value;
/* Encapsulate common constructor actions */
void constructor_helper()
{
collation.set(&my_charset_bin);
}
public: public:
Item_func_encrypt(Item *a) :Item_str_func(a) {} Item_func_encrypt(Item *a) :Item_str_func(a)
Item_func_encrypt(Item *a, Item *b): Item_str_func(a,b) {} {
constructor_helper();
}
Item_func_encrypt(Item *a, Item *b): Item_str_func(a,b)
{
constructor_helper();
}
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec() { maybe_null=1; max_length = 13; } void fix_length_and_dec() { maybe_null=1; max_length = 13; }
const char *func_name() const { return "encrypt"; } const char *func_name() const { return "encrypt"; }

View File

@ -326,8 +326,6 @@ static char *my_bind_addr_str;
static char *default_collation_name; static char *default_collation_name;
static char *default_storage_engine_str; static char *default_storage_engine_str;
static char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME; static char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME;
static char mysql_data_home_buff[2];
static struct passwd *user_info;
static I_List<THD> thread_cache; static I_List<THD> thread_cache;
static pthread_cond_t COND_thread_cache, COND_flush_thread_cache; static pthread_cond_t COND_thread_cache, COND_flush_thread_cache;
@ -508,7 +506,8 @@ key_map key_map_full(0); // Will be initialized later
const char *opt_date_time_formats[3]; const char *opt_date_time_formats[3];
char *mysql_data_home= mysql_real_data_home; char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home;
struct passwd *user_info;
char server_version[SERVER_VERSION_LENGTH]; char server_version[SERVER_VERSION_LENGTH];
char *mysqld_unix_port, *opt_mysql_tmpdir; char *mysqld_unix_port, *opt_mysql_tmpdir;
const char **errmesg; /* Error messages */ const char **errmesg; /* Error messages */
@ -6215,7 +6214,7 @@ The minimum value for this variable is 4096.",
"If an in-memory temporary table exceeds this size, MySQL will automatically convert it to an on-disk MyISAM table.", "If an in-memory temporary table exceeds this size, MySQL will automatically convert it to an on-disk MyISAM table.",
(gptr*) &global_system_variables.tmp_table_size, (gptr*) &global_system_variables.tmp_table_size,
(gptr*) &max_system_variables.tmp_table_size, 0, GET_ULONG, (gptr*) &max_system_variables.tmp_table_size, 0, GET_ULONG,
REQUIRED_ARG, 32*1024*1024L, 1024, ~0L, 0, 1, 0}, REQUIRED_ARG, 16*1024*1024L, 1024, ~0L, 0, 1, 0}, /* See max_heap_table_size . */
{"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE, {"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE,
"Allocation block size for transactions to be stored in binary log", "Allocation block size for transactions to be stored in binary log",
(gptr*) &global_system_variables.trans_alloc_block_size, (gptr*) &global_system_variables.trans_alloc_block_size,
@ -7592,10 +7591,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
} }
switch (method-1) { switch (method-1) {
case 0: case 0:
method_conv= MI_STATS_METHOD_NULLS_EQUAL; method_conv= MI_STATS_METHOD_NULLS_NOT_EQUAL;
break; break;
case 1: case 1:
method_conv= MI_STATS_METHOD_NULLS_NOT_EQUAL; method_conv= MI_STATS_METHOD_NULLS_EQUAL;
break; break;
case 2: case 2:
method_conv= MI_STATS_METHOD_IGNORE_NULLS; method_conv= MI_STATS_METHOD_IGNORE_NULLS;

View File

@ -859,7 +859,7 @@ my_real_read(NET *net, ulong *complen)
#endif /* EXTRA_DEBUG */ #endif /* EXTRA_DEBUG */
} }
#if defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER) #if defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER)
if (vio_should_retry(net->vio)) if (vio_errno(net->vio) == SOCKET_EINTR)
{ {
DBUG_PRINT("warning",("Interrupted read. Retrying...")); DBUG_PRINT("warning",("Interrupted read. Retrying..."));
continue; continue;

View File

@ -5379,14 +5379,6 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
continue; continue;
} }
if (user_name->host.length > HOSTNAME_LENGTH ||
user_name->user.length > USERNAME_LENGTH)
{
append_user(&wrong_users, user_name);
result= TRUE;
continue;
}
/* /*
Search all in-memory structures and grant tables Search all in-memory structures and grant tables
for a mention of the new user name. for a mention of the new user name.
@ -5579,8 +5571,6 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list)
} }
if (!find_acl_user(lex_user->host.str, lex_user->user.str, TRUE)) if (!find_acl_user(lex_user->host.str, lex_user->user.str, TRUE))
{ {
sql_print_error("REVOKE ALL PRIVILEGES, GRANT: User '%s'@'%s' does not "
"exists", lex_user->user.str, lex_user->host.str);
result= -1; result= -1;
continue; continue;
} }

View File

@ -1145,16 +1145,15 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
} }
info->updated++; info->updated++;
/* /*
If ON DUP KEY UPDATE updates a row instead of inserting one, and If ON DUP KEY UPDATE updates a row instead of inserting one, it's
there is an auto_increment column, then SELECT LAST_INSERT_ID() like a regular UPDATE statement: it should not affect the value of a
returns the id of the updated row: next SELECT LAST_INSERT_ID() or mysql_insert_id().
Except if LAST_INSERT_ID(#) was in the INSERT query, which is
handled separately by THD::arg_of_last_insert_id_function.
*/ */
insert_id_for_cur_row= table->file->insert_id_for_cur_row= 0;
if (table->next_number_field) if (table->next_number_field)
{ table->file->adjust_next_insert_id_after_explicit_value(table->next_number_field->val_int());
longlong field_val= table->next_number_field->val_int();
thd->record_first_successful_insert_id_in_cur_stmt(field_val);
table->file->adjust_next_insert_id_after_explicit_value(field_val);
}
trg_error= (table->triggers && trg_error= (table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
TRG_ACTION_AFTER, TRUE)); TRG_ACTION_AFTER, TRUE));

View File

@ -663,8 +663,9 @@ int MYSQLlex(void *arg, void *yythd)
*/ */
if ((yylval->lex_str.str[0]=='_') && if ((yylval->lex_str.str[0]=='_') &&
(lex->charset=get_charset_by_csname(yylval->lex_str.str+1, (lex->underscore_charset=
MY_CS_PRIMARY,MYF(0)))) get_charset_by_csname(yylval->lex_str.str + 1,
MY_CS_PRIMARY,MYF(0))))
return(UNDERSCORE_CHARSET); return(UNDERSCORE_CHARSET);
return(result_state); // IDENT or IDENT_QUOTED return(result_state); // IDENT or IDENT_QUOTED
@ -1047,6 +1048,8 @@ int MYSQLlex(void *arg, void *yythd)
if (c == '.') if (c == '.')
lex->next_state=MY_LEX_IDENT_SEP; lex->next_state=MY_LEX_IDENT_SEP;
length= (uint) (lex->ptr - lex->tok_start)-1; length= (uint) (lex->ptr - lex->tok_start)-1;
if (length == 0)
return(ABORT_SYM); // Names must be nonempty.
if ((tokval= find_keyword(lex,length,0))) if ((tokval= find_keyword(lex,length,0)))
{ {
yyUnget(); // Put back 'c' yyUnget(); // Put back 'c'

View File

@ -895,7 +895,7 @@ typedef struct st_lex : public Query_tables_list
XID *xid; XID *xid;
gptr yacc_yyss,yacc_yyvs; gptr yacc_yyss,yacc_yyvs;
THD *thd; THD *thd;
CHARSET_INFO *charset; CHARSET_INFO *charset, *underscore_charset;
/* store original leaf_tables for INSERT SELECT and PS/SP */ /* store original leaf_tables for INSERT SELECT and PS/SP */
TABLE_LIST *leaf_tables_insert; TABLE_LIST *leaf_tables_insert;
/* Position (first character index) of SELECT of CREATE VIEW statement */ /* Position (first character index) of SELECT of CREATE VIEW statement */

View File

@ -67,7 +67,6 @@ static int check_for_max_user_connections(THD *thd, USER_CONN *uc);
static void decrease_user_connections(USER_CONN *uc); static void decrease_user_connections(USER_CONN *uc);
#endif /* NO_EMBEDDED_ACCESS_CHECKS */ #endif /* NO_EMBEDDED_ACCESS_CHECKS */
static bool check_multi_update_lock(THD *thd); static bool check_multi_update_lock(THD *thd);
static void remove_escape(char *name);
static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables); static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables);
const char *any_db="*any*"; // Special symbol for check_access const char *any_db="*any*"; // Special symbol for check_access
@ -1442,7 +1441,6 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name)
} }
if (lower_case_table_names) if (lower_case_table_names)
my_casedn_str(files_charset_info, tbl_name); my_casedn_str(files_charset_info, tbl_name);
remove_escape(table_list->table_name);
if (!(table=open_ltable(thd, table_list, TL_READ_NO_INSERT))) if (!(table=open_ltable(thd, table_list, TL_READ_NO_INSERT)))
DBUG_RETURN(1); DBUG_RETURN(1);
@ -1909,7 +1907,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
general_log_print(thd, command, "%s %s", table_list.table_name, fields); general_log_print(thd, command, "%s %s", table_list.table_name, fields);
if (lower_case_table_names) if (lower_case_table_names)
my_casedn_str(files_charset_info, table_list.table_name); my_casedn_str(files_charset_info, table_list.table_name);
remove_escape(table_list.table_name); // This can't have wildcards
if (check_access(thd,SELECT_ACL,table_list.db,&table_list.grant.privilege, if (check_access(thd,SELECT_ACL,table_list.db,&table_list.grant.privilege,
0, 0, test(table_list.schema_table))) 0, 0, test(table_list.schema_table)))
@ -2299,7 +2296,6 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
DBUG_RETURN(1); DBUG_RETURN(1);
} }
db= lex->select_lex.db; db= lex->select_lex.db;
remove_escape(db); // Fix escaped '_'
if (check_db_name(db)) if (check_db_name(db))
{ {
my_error(ER_WRONG_DB_NAME, MYF(0), db); my_error(ER_WRONG_DB_NAME, MYF(0), db);
@ -2338,8 +2334,6 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
lex->query_tables_last= query_tables_last; lex->query_tables_last= query_tables_last;
TABLE_LIST *table_list= (TABLE_LIST*) sel->table_list.first; TABLE_LIST *table_list= (TABLE_LIST*) sel->table_list.first;
char *db= table_list->db; char *db= table_list->db;
remove_escape(db); // Fix escaped '_'
remove_escape(table_list->table_name);
if (check_access(thd,SELECT_ACL | EXTRA_ACL,db, if (check_access(thd,SELECT_ACL | EXTRA_ACL,db,
&table_list->grant.privilege, 0, 0, &table_list->grant.privilege, 0, 0,
test(table_list->schema_table))) test(table_list->schema_table)))
@ -6288,36 +6282,6 @@ add_proc_to_list(THD* thd, Item *item)
} }
/* Fix escaping of _, % and \ in database and table names (for ODBC) */
static void remove_escape(char *name)
{
if (!*name) // For empty DB names
return;
char *to;
#ifdef USE_MB
char *strend=name+(uint) strlen(name);
#endif
for (to=name; *name ; name++)
{
#ifdef USE_MB
int l;
if (use_mb(system_charset_info) &&
(l = my_ismbchar(system_charset_info, name, strend)))
{
while (l--)
*to++ = *name++;
name--;
continue;
}
#endif
if (*name == '\\' && name[1])
name++; // Skip '\\'
*to++= *name;
}
*to=0;
}
/**************************************************************************** /****************************************************************************
** save order by and tables in own lists ** save order by and tables in own lists
****************************************************************************/ ****************************************************************************/

View File

@ -1916,7 +1916,8 @@ void mysql_stmt_prepare(THD *thd, const char *packet, uint packet_length)
thd->stmt_map.erase(stmt); thd->stmt_map.erase(stmt);
} }
else else
general_log_print(thd, COM_STMT_PREPARE, "[%lu] %s", stmt->id, packet); general_log_print(thd, COM_STMT_PREPARE, "[%lu] %.*b", stmt->id,
stmt->query_length, stmt->query);
/* check_prepared_statemnt sends the metadata packet in case of success */ /* check_prepared_statemnt sends the metadata packet in case of success */
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
@ -2291,7 +2292,8 @@ void mysql_stmt_execute(THD *thd, char *packet_arg, uint packet_length)
if (!(specialflag & SPECIAL_NO_PRIOR)) if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(), WAIT_PRIOR); my_pthread_setprio(pthread_self(), WAIT_PRIOR);
if (error == 0) if (error == 0)
general_log_print(thd, COM_STMT_EXECUTE, "[%lu] %s", stmt->id, thd->query); general_log_print(thd, COM_STMT_EXECUTE, "[%lu] %.*b", stmt->id,
thd->query_length, thd->query);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;

View File

@ -7268,6 +7268,8 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
left_item->collation.collation == value->collation.collation)) left_item->collation.collation == value->collation.collation))
{ {
Item *tmp=value->new_item(); Item *tmp=value->new_item();
tmp->collation.set(right_item->collation);
if (tmp) if (tmp)
{ {
thd->change_item_tree(args + 1, tmp); thd->change_item_tree(args + 1, tmp);
@ -7290,6 +7292,8 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
right_item->collation.collation == value->collation.collation)) right_item->collation.collation == value->collation.collation))
{ {
Item *tmp=value->new_item(); Item *tmp=value->new_item();
tmp->collation.set(left_item->collation);
if (tmp) if (tmp)
{ {
thd->change_item_tree(args, tmp); thd->change_item_tree(args, tmp);

View File

@ -1228,9 +1228,10 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
store_key_options(thd, packet, table, key_info); store_key_options(thd, packet, table, key_info);
if (key_info->parser) if (key_info->parser)
{ {
packet->append(" WITH PARSER ", 13); packet->append(STRING_WITH_LEN(" /*!50100 WITH PARSER "));
append_identifier(thd, packet, key_info->parser->name.str, append_identifier(thd, packet, key_info->parser->name.str,
key_info->parser->name.length); key_info->parser->name.length);
packet->append(STRING_WITH_LEN(" */ "));
} }
} }
@ -1256,9 +1257,9 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
if ((for_str= file->get_tablespace_name(thd))) if ((for_str= file->get_tablespace_name(thd)))
{ {
packet->append(" TABLESPACE "); packet->append(STRING_WITH_LEN(" /*!50100 TABLESPACE "));
packet->append(for_str, strlen(for_str)); packet->append(for_str, strlen(for_str));
packet->append(" STORAGE DISK"); packet->append(STRING_WITH_LEN(" STORAGE DISK */"));
my_free(for_str, MYF(0)); my_free(for_str, MYF(0));
} }
@ -1297,7 +1298,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
if(create_info.auto_increment_value > 1) if(create_info.auto_increment_value > 1)
{ {
packet->append(" AUTO_INCREMENT=", 16); packet->append(STRING_WITH_LEN(" AUTO_INCREMENT="));
end= longlong10_to_str(create_info.auto_increment_value, buff,10); end= longlong10_to_str(create_info.auto_increment_value, buff,10);
packet->append(buff, (uint) (end - buff)); packet->append(buff, (uint) (end - buff));
} }

View File

@ -238,6 +238,10 @@ bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *cs)
0 No conversion needed 0 No conversion needed
1 Either character set conversion or adding leading zeros 1 Either character set conversion or adding leading zeros
(e.g. for UCS-2) must be done (e.g. for UCS-2) must be done
NOTE
to_cs may be NULL for "no conversion" if the system variable
character_set_results is NULL.
*/ */
bool String::needs_conversion(uint32 arg_length, bool String::needs_conversion(uint32 arg_length,
@ -246,7 +250,8 @@ bool String::needs_conversion(uint32 arg_length,
uint32 *offset) uint32 *offset)
{ {
*offset= 0; *offset= 0;
if ((to_cs == &my_charset_bin) || if (!to_cs ||
(to_cs == &my_charset_bin) ||
(to_cs == from_cs) || (to_cs == from_cs) ||
my_charset_same(from_cs, to_cs) || my_charset_same(from_cs, to_cs) ||
((from_cs == &my_charset_bin) && ((from_cs == &my_charset_bin) &&

View File

@ -2224,6 +2224,40 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
/*
Convert the default value from client character
set into the column character set if necessary.
*/
if (sql_field->def &&
save_cs != sql_field->def->collation.collation &&
(sql_field->sql_type == FIELD_TYPE_VAR_STRING ||
sql_field->sql_type == FIELD_TYPE_STRING ||
sql_field->sql_type == FIELD_TYPE_SET ||
sql_field->sql_type == FIELD_TYPE_ENUM))
{
Query_arena backup_arena;
bool need_to_change_arena= !thd->stmt_arena->is_conventional();
if (need_to_change_arena)
{
/* Asser that we don't do that at every PS execute */
DBUG_ASSERT(thd->stmt_arena->is_first_stmt_execute() ||
thd->stmt_arena->is_first_sp_execute());
thd->set_n_backup_active_arena(thd->stmt_arena, &backup_arena);
}
sql_field->def= sql_field->def->safe_charset_converter(save_cs);
if (need_to_change_arena)
thd->restore_active_arena(thd->stmt_arena, &backup_arena);
if (sql_field->def == NULL)
{
/* Could not convert */
my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
DBUG_RETURN(-1);
}
}
if (sql_field->sql_type == FIELD_TYPE_SET || if (sql_field->sql_type == FIELD_TYPE_SET ||
sql_field->sql_type == FIELD_TYPE_ENUM) sql_field->sql_type == FIELD_TYPE_ENUM)
{ {
@ -2285,35 +2319,6 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
sql_field->interval_list.empty(); // Don't need interval_list anymore sql_field->interval_list.empty(); // Don't need interval_list anymore
} }
/*
Convert the default value from client character
set into the column character set if necessary.
*/
if (sql_field->def && cs != sql_field->def->collation.collation)
{
Query_arena backup_arena;
bool need_to_change_arena= !thd->stmt_arena->is_conventional();
if (need_to_change_arena)
{
/* Asser that we don't do that at every PS execute */
DBUG_ASSERT(thd->stmt_arena->is_first_stmt_execute() ||
thd->stmt_arena->is_first_sp_execute());
thd->set_n_backup_active_arena(thd->stmt_arena, &backup_arena);
}
sql_field->def= sql_field->def->safe_charset_converter(cs);
if (need_to_change_arena)
thd->restore_active_arena(thd->stmt_arena, &backup_arena);
if (sql_field->def == NULL)
{
/* Could not convert */
my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
DBUG_RETURN(-1);
}
}
if (sql_field->sql_type == FIELD_TYPE_SET) if (sql_field->sql_type == FIELD_TYPE_SET)
{ {
uint32 field_length; uint32 field_length;

View File

@ -8902,7 +8902,7 @@ text_literal:
| NCHAR_STRING | NCHAR_STRING
{ $$= new Item_string($1.str,$1.length,national_charset_info); } { $$= new Item_string($1.str,$1.length,national_charset_info); }
| UNDERSCORE_CHARSET TEXT_STRING | UNDERSCORE_CHARSET TEXT_STRING
{ $$ = new Item_string($2.str,$2.length,Lex->charset); } { $$ = new Item_string($2.str,$2.length,Lex->underscore_charset); }
| text_literal TEXT_STRING_literal | text_literal TEXT_STRING_literal
{ ((Item_string*) $1)->append($2.str,$2.length); } { ((Item_string*) $1)->append($2.str,$2.length); }
; ;
@ -8980,7 +8980,7 @@ literal:
(String*) 0; (String*) 0;
$$= new Item_string(str ? str->ptr() : "", $$= new Item_string(str ? str->ptr() : "",
str ? str->length() : 0, str ? str->length() : 0,
Lex->charset); Lex->underscore_charset);
} }
| UNDERSCORE_CHARSET BIN_NUM | UNDERSCORE_CHARSET BIN_NUM
{ {

View File

@ -21,6 +21,7 @@
#ifdef HAVE_STACKTRACE #ifdef HAVE_STACKTRACE
#include <unistd.h> #include <unistd.h>
#include <strings.h>
#define PTR_SANE(p) ((p) && (char*)(p) >= heap_start && (char*)(p) <= heap_end) #define PTR_SANE(p) ((p) && (char*)(p) >= heap_start && (char*)(p) <= heap_end)
@ -44,7 +45,29 @@ void safe_print_str(const char* name, const char* val, int max_len)
} }
#ifdef TARGET_OS_LINUX #ifdef TARGET_OS_LINUX
#define SIGRETURN_FRAME_COUNT 2
#ifdef __i386__
#define SIGRETURN_FRAME_OFFSET 17
#endif
#ifdef __x86_64__
#define SIGRETURN_FRAME_OFFSET 23
#endif
static my_bool is_nptl;
/* Check if we are using NPTL or LinuxThreads on Linux */
void check_thread_lib(void)
{
char buf[5];
#ifdef _CS_GNU_LIBPTHREAD_VERSION
confstr(_CS_GNU_LIBPTHREAD_VERSION, buf, sizeof(buf));
is_nptl = !strncasecmp(buf, "NPTL", sizeof(buf));
#else
is_nptl = 0;
#endif
}
#if defined(__alpha__) && defined(__GNUC__) #if defined(__alpha__) && defined(__GNUC__)
/* /*
@ -90,7 +113,7 @@ inline uint32* find_prev_pc(uint32* pc, uchar** fp)
void print_stacktrace(gptr stack_bottom, ulong thread_stack) void print_stacktrace(gptr stack_bottom, ulong thread_stack)
{ {
uchar** fp; uchar** fp;
uint frame_count = 0; uint frame_count = 0, sigreturn_frame_count;
#if defined(__alpha__) && defined(__GNUC__) #if defined(__alpha__) && defined(__GNUC__)
uint32* pc; uint32* pc;
#endif #endif
@ -104,24 +127,23 @@ terribly wrong...\n");
__asm __volatile__ ("movl %%ebp,%0" __asm __volatile__ ("movl %%ebp,%0"
:"=r"(fp) :"=r"(fp)
:"r"(fp)); :"r"(fp));
if (!fp) #endif
{ #ifdef __x86_64__
fprintf(stderr, "frame pointer (ebp) is NULL, did you compile with\n\ __asm __volatile__ ("movq %%rbp,%0"
-fomit-frame-pointer? Aborting backtrace!\n"); :"=r"(fp)
return; :"r"(fp));
}
#endif #endif
#if defined(__alpha__) && defined(__GNUC__) #if defined(__alpha__) && defined(__GNUC__)
__asm __volatile__ ("mov $30,%0" __asm __volatile__ ("mov $30,%0"
:"=r"(fp) :"=r"(fp)
:"r"(fp)); :"r"(fp));
#endif
if (!fp) if (!fp)
{ {
fprintf(stderr, "frame pointer (fp) is NULL, did you compile with\n\ fprintf(stderr, "frame pointer is NULL, did you compile with\n\
-fomit-frame-pointer? Aborting backtrace!\n"); -fomit-frame-pointer? Aborting backtrace!\n");
return; return;
} }
#endif /* __alpha__ */
if (!stack_bottom || (gptr) stack_bottom > (gptr) &fp) if (!stack_bottom || (gptr) stack_bottom > (gptr) &fp)
{ {
@ -151,13 +173,16 @@ terribly wrong...\n");
:"r"(pc)); :"r"(pc));
#endif /* __alpha__ */ #endif /* __alpha__ */
/* We are 1 frame above signal frame with NPTL and 2 frames above with LT */
sigreturn_frame_count = is_nptl ? 1 : 2;
while (fp < (uchar**) stack_bottom) while (fp < (uchar**) stack_bottom)
{ {
#ifdef __i386__ #if defined(__i386__) || defined(__x86_64__)
uchar** new_fp = (uchar**)*fp; uchar** new_fp = (uchar**)*fp;
fprintf(stderr, "%p\n", frame_count == SIGRETURN_FRAME_COUNT ? fprintf(stderr, "%p\n", frame_count == sigreturn_frame_count ?
*(fp+17) : *(fp+1)); *(fp + SIGRETURN_FRAME_OFFSET) : *(fp + 1));
#endif /* __386__ */ #endif /* defined(__386__) || defined(__x86_64__) */
#if defined(__alpha__) && defined(__GNUC__) #if defined(__alpha__) && defined(__GNUC__)
uchar** new_fp = find_prev_fp(pc, fp); uchar** new_fp = find_prev_fp(pc, fp);

View File

@ -19,16 +19,20 @@ extern "C" {
#endif #endif
#ifdef TARGET_OS_LINUX #ifdef TARGET_OS_LINUX
#if defined(HAVE_STACKTRACE) || (defined (__i386__) || (defined(__alpha__) && defined(__GNUC__))) #if defined(HAVE_STACKTRACE) || (defined (__x86_64__) || defined (__i386__) || (defined(__alpha__) && defined(__GNUC__)))
#undef HAVE_STACKTRACE #undef HAVE_STACKTRACE
#define HAVE_STACKTRACE #define HAVE_STACKTRACE
extern char* __bss_start; extern char* __bss_start;
extern char* heap_start; extern char* heap_start;
#define init_stacktrace() { heap_start = (char*) &__bss_start; } #define init_stacktrace() do { \
heap_start = (char*) &__bss_start; \
check_thread_lib(); \
} while(0);
void print_stacktrace(gptr stack_bottom, ulong thread_stack); void print_stacktrace(gptr stack_bottom, ulong thread_stack);
void safe_print_str(const char* name, const char* val, int max_len); void safe_print_str(const char* name, const char* val, int max_len);
void check_thread_lib(void);
#endif /* (defined (__i386__) || (defined(__alpha__) && defined(__GNUC__))) */ #endif /* (defined (__i386__) || (defined(__alpha__) && defined(__GNUC__))) */
#endif /* TARGET_OS_LINUX */ #endif /* TARGET_OS_LINUX */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -92,9 +92,9 @@ btr_pcur_store_position(
offs = ut_align_offset(rec, UNIV_PAGE_SIZE); offs = ut_align_offset(rec, UNIV_PAGE_SIZE);
ut_ad(mtr_memo_contains(mtr, buf_block_align(page), ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_S_FIX) MTR_MEMO_PAGE_S_FIX)
|| mtr_memo_contains(mtr, buf_block_align(page), || mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX)); MTR_MEMO_PAGE_X_FIX));
ut_a(cursor->latch_mode != BTR_NO_LATCHES); ut_a(cursor->latch_mode != BTR_NO_LATCHES);
if (UNIV_UNLIKELY(page_get_n_recs(page) == 0)) { if (UNIV_UNLIKELY(page_get_n_recs(page) == 0)) {
@ -133,14 +133,13 @@ btr_pcur_store_position(
} }
cursor->old_stored = BTR_PCUR_OLD_STORED; cursor->old_stored = BTR_PCUR_OLD_STORED;
cursor->old_rec = dict_tree_copy_rec_order_prefix(tree, rec, cursor->old_rec = dict_tree_copy_rec_order_prefix
&cursor->old_n_fields, (tree, rec, &cursor->old_n_fields,
&cursor->old_rec_buf, &cursor->old_rec_buf, &cursor->buf_size);
&cursor->buf_size);
cursor->block_when_stored = buf_block_align(page); cursor->block_when_stored = buf_block_align(page);
cursor->modify_clock = buf_block_get_modify_clock( cursor->modify_clock = buf_block_get_modify_clock
cursor->block_when_stored); (cursor->block_when_stored);
} }
/****************************************************************** /******************************************************************
@ -165,7 +164,7 @@ btr_pcur_copy_stored_position(
pcur_receive->old_rec_buf = mem_alloc(pcur_donate->buf_size); pcur_receive->old_rec_buf = mem_alloc(pcur_donate->buf_size);
ut_memcpy(pcur_receive->old_rec_buf, pcur_donate->old_rec_buf, ut_memcpy(pcur_receive->old_rec_buf, pcur_donate->old_rec_buf,
pcur_donate->buf_size); pcur_donate->buf_size);
pcur_receive->old_rec = pcur_receive->old_rec_buf pcur_receive->old_rec = pcur_receive->old_rec_buf
+ (pcur_donate->old_rec - pcur_donate->old_rec_buf); + (pcur_donate->old_rec - pcur_donate->old_rec_buf);
} }
@ -206,8 +205,8 @@ btr_pcur_restore_position(
mem_heap_t* heap; mem_heap_t* heap;
if (UNIV_UNLIKELY(cursor->old_stored != BTR_PCUR_OLD_STORED) if (UNIV_UNLIKELY(cursor->old_stored != BTR_PCUR_OLD_STORED)
|| UNIV_UNLIKELY(cursor->pos_state != BTR_PCUR_WAS_POSITIONED || UNIV_UNLIKELY(cursor->pos_state != BTR_PCUR_WAS_POSITIONED
&& cursor->pos_state != BTR_PCUR_IS_POSITIONED)) { && cursor->pos_state != BTR_PCUR_IS_POSITIONED)) {
ut_print_buf(stderr, cursor, sizeof(btr_pcur_t)); ut_print_buf(stderr, cursor, sizeof(btr_pcur_t));
if (cursor->trx_if_known) { if (cursor->trx_if_known) {
trx_print(stderr, cursor->trx_if_known, 0); trx_print(stderr, cursor->trx_if_known, 0);
@ -216,19 +215,20 @@ btr_pcur_restore_position(
ut_error; ut_error;
} }
if (UNIV_UNLIKELY(cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE if (UNIV_UNLIKELY
|| cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE)) { (cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE
|| cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE)) {
/* In these cases we do not try an optimistic restoration, /* In these cases we do not try an optimistic restoration,
but always do a search */ but always do a search */
btr_cur_open_at_index_side( btr_cur_open_at_index_side
cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE, (cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE,
btr_pcur_get_btr_cur(cursor)->index, latch_mode, btr_pcur_get_btr_cur(cursor)->index, latch_mode,
btr_pcur_get_btr_cur(cursor), mtr); btr_pcur_get_btr_cur(cursor), mtr);
cursor->block_when_stored = cursor->block_when_stored
buf_block_align(btr_pcur_get_page(cursor)); = buf_block_align(btr_pcur_get_page(cursor));
return(FALSE); return(FALSE);
} }
@ -239,12 +239,13 @@ btr_pcur_restore_position(
page = btr_cur_get_page(btr_pcur_get_btr_cur(cursor)); page = btr_cur_get_page(btr_pcur_get_btr_cur(cursor));
if (UNIV_LIKELY(latch_mode == BTR_SEARCH_LEAF) if (UNIV_LIKELY(latch_mode == BTR_SEARCH_LEAF)
|| UNIV_LIKELY(latch_mode == BTR_MODIFY_LEAF)) { || UNIV_LIKELY(latch_mode == BTR_MODIFY_LEAF)) {
/* Try optimistic restoration */ /* Try optimistic restoration */
if (UNIV_LIKELY(buf_page_optimistic_get(latch_mode, if (UNIV_LIKELY
cursor->block_when_stored, page, (buf_page_optimistic_get(latch_mode,
cursor->modify_clock, mtr))) { cursor->block_when_stored, page,
cursor->modify_clock, mtr))) {
cursor->pos_state = BTR_PCUR_IS_POSITIONED; cursor->pos_state = BTR_PCUR_IS_POSITIONED;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_TREE_NODE); buf_page_dbg_add_level(page, SYNC_TREE_NODE);
@ -262,14 +263,16 @@ btr_pcur_restore_position(
index = btr_pcur_get_btr_cur(cursor)->index; index = btr_pcur_get_btr_cur(cursor)->index;
heap = mem_heap_create(256); heap = mem_heap_create(256);
offsets1 = rec_get_offsets(cursor->old_rec, offsets1 = rec_get_offsets
index, NULL, (cursor->old_rec, index, NULL,
cursor->old_n_fields, &heap); cursor->old_n_fields, &heap);
offsets2 = rec_get_offsets(rec, index, NULL, offsets2 = rec_get_offsets
cursor->old_n_fields, &heap); (rec, index, NULL,
cursor->old_n_fields, &heap);
ut_ad(cmp_rec_rec(cursor->old_rec, ut_ad(!cmp_rec_rec(cursor->old_rec,
rec, offsets1, offsets2, index) == 0); rec, offsets1, offsets2,
index));
mem_heap_free(heap); mem_heap_free(heap);
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
return(TRUE); return(TRUE);
@ -285,7 +288,7 @@ btr_pcur_restore_position(
tree = btr_cur_get_tree(btr_pcur_get_btr_cur(cursor)); tree = btr_cur_get_tree(btr_pcur_get_btr_cur(cursor));
tuple = dict_tree_build_data_tuple(tree, cursor->old_rec, tuple = dict_tree_build_data_tuple(tree, cursor->old_rec,
cursor->old_n_fields, heap); cursor->old_n_fields, heap);
/* Save the old search mode of the cursor */ /* Save the old search mode of the cursor */
old_mode = cursor->search_mode; old_mode = cursor->search_mode;
@ -300,26 +303,27 @@ btr_pcur_restore_position(
} }
btr_pcur_open_with_no_init(btr_pcur_get_btr_cur(cursor)->index, tuple, btr_pcur_open_with_no_init(btr_pcur_get_btr_cur(cursor)->index, tuple,
mode, latch_mode, cursor, 0, mtr); mode, latch_mode, cursor, 0, mtr);
/* Restore the old search mode */ /* Restore the old search mode */
cursor->search_mode = old_mode; cursor->search_mode = old_mode;
if (cursor->rel_pos == BTR_PCUR_ON if (cursor->rel_pos == BTR_PCUR_ON
&& btr_pcur_is_on_user_rec(cursor, mtr) && btr_pcur_is_on_user_rec(cursor, mtr)
&& 0 == cmp_dtuple_rec(tuple, btr_pcur_get_rec(cursor), && 0 == cmp_dtuple_rec(tuple, btr_pcur_get_rec(cursor),
rec_get_offsets(btr_pcur_get_rec(cursor), rec_get_offsets
btr_pcur_get_btr_cur(cursor)->index, (btr_pcur_get_rec(cursor),
NULL, ULINT_UNDEFINED, &heap))) { btr_pcur_get_btr_cur(cursor)->index,
NULL, ULINT_UNDEFINED, &heap))) {
/* We have to store the NEW value for the modify clock, since /* We have to store the NEW value for the modify clock, since
the cursor can now be on a different page! But we can retain the cursor can now be on a different page! But we can retain
the value of old_rec */ the value of old_rec */
cursor->block_when_stored = cursor->block_when_stored = buf_block_align
buf_block_align(btr_pcur_get_page(cursor)); (btr_pcur_get_page(cursor));
cursor->modify_clock = cursor->modify_clock = buf_block_get_modify_clock
buf_block_get_modify_clock(cursor->block_when_stored); (cursor->block_when_stored);
cursor->old_stored = BTR_PCUR_OLD_STORED; cursor->old_stored = BTR_PCUR_OLD_STORED;
mem_heap_free(heap); mem_heap_free(heap);
@ -467,14 +471,14 @@ btr_pcur_move_backward_from_page(
space = buf_frame_get_space_id(page); space = buf_frame_get_space_id(page);
if (btr_pcur_is_before_first_on_page(cursor, mtr) if (btr_pcur_is_before_first_on_page(cursor, mtr)
&& (prev_page_no != FIL_NULL)) { && (prev_page_no != FIL_NULL)) {
prev_page = btr_pcur_get_btr_cur(cursor)->left_page; prev_page = btr_pcur_get_btr_cur(cursor)->left_page;
btr_leaf_page_release(page, latch_mode, mtr); btr_leaf_page_release(page, latch_mode, mtr);
page_cur_set_after_last(prev_page, page_cur_set_after_last(prev_page,
btr_pcur_get_page_cur(cursor)); btr_pcur_get_page_cur(cursor));
} else if (prev_page_no != FIL_NULL) { } else if (prev_page_no != FIL_NULL) {
/* The repositioned cursor did not end on an infimum record on /* The repositioned cursor did not end on an infimum record on

View File

@ -231,19 +231,19 @@ btr_search_info_update_hash(
} }
cmp = ut_pair_cmp(info->n_fields, info->n_bytes, cmp = ut_pair_cmp(info->n_fields, info->n_bytes,
cursor->low_match, cursor->low_bytes); cursor->low_match, cursor->low_bytes);
if ((info->side == BTR_SEARCH_LEFT_SIDE && cmp <= 0) if ((info->side == BTR_SEARCH_LEFT_SIDE && cmp <= 0)
|| (info->side == BTR_SEARCH_RIGHT_SIDE && cmp > 0)) { || (info->side == BTR_SEARCH_RIGHT_SIDE && cmp > 0)) {
goto set_new_recomm; goto set_new_recomm;
} }
cmp = ut_pair_cmp(info->n_fields, info->n_bytes, cmp = ut_pair_cmp(info->n_fields, info->n_bytes,
cursor->up_match, cursor->up_bytes); cursor->up_match, cursor->up_bytes);
if ((info->side == BTR_SEARCH_LEFT_SIDE && cmp > 0) if ((info->side == BTR_SEARCH_LEFT_SIDE && cmp > 0)
|| (info->side == BTR_SEARCH_RIGHT_SIDE && cmp <= 0)) { || (info->side == BTR_SEARCH_RIGHT_SIDE && cmp <= 0)) {
goto set_new_recomm; goto set_new_recomm;
} }
@ -260,7 +260,7 @@ set_new_recomm:
info->hash_analysis = 0; info->hash_analysis = 0;
cmp = ut_pair_cmp(cursor->up_match, cursor->up_bytes, cmp = ut_pair_cmp(cursor->up_match, cursor->up_bytes,
cursor->low_match, cursor->low_bytes); cursor->low_match, cursor->low_bytes);
if (cmp == 0) { if (cmp == 0) {
info->n_hash_potential = 0; info->n_hash_potential = 0;
@ -328,7 +328,7 @@ btr_search_update_block_hash_info(
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED));
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
ut_ad(rw_lock_own(&((buf_block_t*) block)->lock, RW_LOCK_SHARED) ut_ad(rw_lock_own(&((buf_block_t*) block)->lock, RW_LOCK_SHARED)
|| rw_lock_own(&((buf_block_t*) block)->lock, RW_LOCK_EX)); || rw_lock_own(&((buf_block_t*) block)->lock, RW_LOCK_EX));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_ad(cursor); ut_ad(cursor);
@ -338,15 +338,15 @@ btr_search_update_block_hash_info(
ut_a(info->magic_n == BTR_SEARCH_MAGIC_N); ut_a(info->magic_n == BTR_SEARCH_MAGIC_N);
if ((block->n_hash_helps > 0) if ((block->n_hash_helps > 0)
&& (info->n_hash_potential > 0) && (info->n_hash_potential > 0)
&& (block->n_fields == info->n_fields) && (block->n_fields == info->n_fields)
&& (block->n_bytes == info->n_bytes) && (block->n_bytes == info->n_bytes)
&& (block->side == info->side)) { && (block->side == info->side)) {
if ((block->is_hashed) if ((block->is_hashed)
&& (block->curr_n_fields == info->n_fields) && (block->curr_n_fields == info->n_fields)
&& (block->curr_n_bytes == info->n_bytes) && (block->curr_n_bytes == info->n_bytes)
&& (block->curr_side == info->side)) { && (block->curr_side == info->side)) {
/* The search would presumably have succeeded using /* The search would presumably have succeeded using
the hash index */ the hash index */
@ -367,15 +367,15 @@ btr_search_update_block_hash_info(
} }
if ((block->n_hash_helps > page_get_n_recs(block->frame) if ((block->n_hash_helps > page_get_n_recs(block->frame)
/ BTR_SEARCH_PAGE_BUILD_LIMIT) / BTR_SEARCH_PAGE_BUILD_LIMIT)
&& (info->n_hash_potential >= BTR_SEARCH_BUILD_LIMIT)) { && (info->n_hash_potential >= BTR_SEARCH_BUILD_LIMIT)) {
if ((!block->is_hashed) if ((!block->is_hashed)
|| (block->n_hash_helps || (block->n_hash_helps
> 2 * page_get_n_recs(block->frame)) > 2 * page_get_n_recs(block->frame))
|| (block->n_fields != block->curr_n_fields) || (block->n_fields != block->curr_n_fields)
|| (block->n_bytes != block->curr_n_bytes) || (block->n_bytes != block->curr_n_bytes)
|| (block->side != block->curr_side)) { || (block->side != block->curr_side)) {
/* Build a new hash index on the page */ /* Build a new hash index on the page */
@ -410,16 +410,16 @@ btr_search_update_hash_ref(
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX)); ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX));
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED)
|| rw_lock_own(&(block->lock), RW_LOCK_EX)); || rw_lock_own(&(block->lock), RW_LOCK_EX));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_ad(buf_block_align(btr_cur_get_rec(cursor)) == block); ut_ad(buf_block_align(btr_cur_get_rec(cursor)) == block);
ut_a(!block->is_hashed || block->index == cursor->index); ut_a(!block->is_hashed || block->index == cursor->index);
if (block->is_hashed if (block->is_hashed
&& (info->n_hash_potential > 0) && (info->n_hash_potential > 0)
&& (block->curr_n_fields == info->n_fields) && (block->curr_n_fields == info->n_fields)
&& (block->curr_n_bytes == info->n_bytes) && (block->curr_n_bytes == info->n_bytes)
&& (block->curr_side == info->side)) { && (block->curr_side == info->side)) {
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint offsets_[REC_OFFS_NORMAL_SIZE];
*offsets_ = (sizeof offsets_) / sizeof *offsets_; *offsets_ = (sizeof offsets_) / sizeof *offsets_;
@ -432,8 +432,9 @@ btr_search_update_hash_ref(
} }
tree_id = ((cursor->index)->tree)->id; tree_id = ((cursor->index)->tree)->id;
fold = rec_fold(rec, rec_get_offsets(rec, cursor->index, fold = rec_fold(rec,
offsets_, ULINT_UNDEFINED, &heap), rec_get_offsets(rec, cursor->index, offsets_,
ULINT_UNDEFINED, &heap),
block->curr_n_fields, block->curr_n_fields,
block->curr_n_bytes, tree_id); block->curr_n_bytes, tree_id);
if (UNIV_LIKELY_NULL(heap)) { if (UNIV_LIKELY_NULL(heap)) {
@ -516,10 +517,10 @@ btr_search_info_update_slow(
params2 = params + btr_search_this_is_zero; params2 = params + btr_search_this_is_zero;
btr_search_build_page_hash_index(cursor->index, btr_search_build_page_hash_index(cursor->index,
block->frame, block->frame,
params2[0], params2[0],
params2[1], params2[1],
params2[2]); params2[2]);
mem_free(params); mem_free(params);
} }
} }
@ -568,9 +569,9 @@ btr_search_check_guess(
bytes = 0; bytes = 0;
offsets = rec_get_offsets(rec, cursor->index, offsets, offsets = rec_get_offsets(rec, cursor->index, offsets,
n_unique, &heap); n_unique, &heap);
cmp = page_cmp_dtuple_rec_with_match(tuple, rec, cmp = page_cmp_dtuple_rec_with_match(tuple, rec,
offsets, &match, &bytes); offsets, &match, &bytes);
if (mode == PAGE_CUR_GE) { if (mode == PAGE_CUR_GE) {
if (cmp == 1) { if (cmp == 1) {
@ -617,16 +618,16 @@ btr_search_check_guess(
prev_rec = page_rec_get_prev(rec); prev_rec = page_rec_get_prev(rec);
if (page_rec_is_infimum(prev_rec)) { if (page_rec_is_infimum(prev_rec)) {
success = btr_page_get_prev( success = btr_page_get_prev
buf_frame_align(prev_rec), mtr) == FIL_NULL; (buf_frame_align(prev_rec), mtr) == FIL_NULL;
goto exit_func; goto exit_func;
} }
offsets = rec_get_offsets(prev_rec, cursor->index, offsets, offsets = rec_get_offsets(prev_rec, cursor->index, offsets,
n_unique, &heap); n_unique, &heap);
cmp = page_cmp_dtuple_rec_with_match(tuple, prev_rec, cmp = page_cmp_dtuple_rec_with_match(tuple, prev_rec,
offsets, &match, &bytes); offsets, &match, &bytes);
if (mode == PAGE_CUR_GE) { if (mode == PAGE_CUR_GE) {
success = cmp == 1; success = cmp == 1;
} else { } else {
@ -642,8 +643,8 @@ btr_search_check_guess(
next_rec = page_rec_get_next(rec); next_rec = page_rec_get_next(rec);
if (page_rec_is_supremum(next_rec)) { if (page_rec_is_supremum(next_rec)) {
if (btr_page_get_next( if (btr_page_get_next
buf_frame_align(next_rec), mtr) == FIL_NULL) { (buf_frame_align(next_rec), mtr) == FIL_NULL) {
cursor->up_match = 0; cursor->up_match = 0;
success = TRUE; success = TRUE;
@ -653,9 +654,9 @@ btr_search_check_guess(
} }
offsets = rec_get_offsets(next_rec, cursor->index, offsets, offsets = rec_get_offsets(next_rec, cursor->index, offsets,
n_unique, &heap); n_unique, &heap);
cmp = page_cmp_dtuple_rec_with_match(tuple, next_rec, cmp = page_cmp_dtuple_rec_with_match(tuple, next_rec,
offsets, &match, &bytes); offsets, &match, &bytes);
if (mode == PAGE_CUR_LE) { if (mode == PAGE_CUR_LE) {
success = cmp == -1; success = cmp == -1;
cursor->up_match = match; cursor->up_match = match;
@ -709,7 +710,7 @@ btr_search_guess_on_hash(
#endif #endif
ut_ad(index && info && tuple && cursor && mtr); ut_ad(index && info && tuple && cursor && mtr);
ut_ad((latch_mode == BTR_SEARCH_LEAF) ut_ad((latch_mode == BTR_SEARCH_LEAF)
|| (latch_mode == BTR_MODIFY_LEAF)); || (latch_mode == BTR_MODIFY_LEAF));
/* Note that, for efficiency, the struct info may not be protected by /* Note that, for efficiency, the struct info may not be protected by
any latch here! */ any latch here! */
@ -730,7 +731,7 @@ btr_search_guess_on_hash(
} }
if (UNIV_UNLIKELY(tuple_n_fields == cursor->n_fields) if (UNIV_UNLIKELY(tuple_n_fields == cursor->n_fields)
&& (cursor->n_bytes > 0)) { && (cursor->n_bytes > 0)) {
return(FALSE); return(FALSE);
} }
@ -762,10 +763,10 @@ btr_search_guess_on_hash(
if (UNIV_LIKELY(!has_search_latch)) { if (UNIV_LIKELY(!has_search_latch)) {
if (UNIV_UNLIKELY(!buf_page_get_known_nowait(latch_mode, page, if (UNIV_UNLIKELY
(!buf_page_get_known_nowait(latch_mode, page,
BUF_MAKE_YOUNG, BUF_MAKE_YOUNG,
__FILE__, __LINE__, __FILE__, __LINE__, mtr))) {
mtr))) {
goto failure_unlock; goto failure_unlock;
} }
@ -801,10 +802,11 @@ btr_search_guess_on_hash(
record to determine if our guess for the cursor position is record to determine if our guess for the cursor position is
right. */ right. */
if (UNIV_EXPECT(ut_dulint_cmp(tree_id, btr_page_get_index_id(page)), 0) if (UNIV_EXPECT(ut_dulint_cmp(tree_id, btr_page_get_index_id(page)), 0)
|| !btr_search_check_guess(cursor, || !btr_search_check_guess(cursor,
can_only_compare_to_cursor_rec, tuple, mode, mtr)) { can_only_compare_to_cursor_rec,
tuple, mode, mtr)) {
if (UNIV_LIKELY(!has_search_latch)) { if (UNIV_LIKELY(!has_search_latch)) {
btr_leaf_page_release(page, latch_mode, mtr); btr_leaf_page_release(page, latch_mode, mtr);
} }
goto failure; goto failure;
@ -827,9 +829,9 @@ btr_search_guess_on_hash(
btr_leaf_page_release(page, latch_mode, mtr); btr_leaf_page_release(page, latch_mode, mtr);
btr_cur_search_to_nth_level(index, 0, tuple, mode, latch_mode, btr_cur_search_to_nth_level(index, 0, tuple, mode, latch_mode,
&cursor2, 0, mtr); &cursor2, 0, mtr);
if (mode == PAGE_CUR_GE if (mode == PAGE_CUR_GE
&& page_rec_is_supremum(btr_cur_get_rec(&cursor2))) { && page_rec_is_supremum(btr_cur_get_rec(&cursor2))) {
/* If mode is PAGE_CUR_GE, then the binary search /* If mode is PAGE_CUR_GE, then the binary search
in the index tree may actually take us to the supremum in the index tree may actually take us to the supremum
@ -838,7 +840,7 @@ btr_search_guess_on_hash(
info->last_hash_succ = FALSE; info->last_hash_succ = FALSE;
btr_pcur_open_on_user_rec(index, tuple, mode, latch_mode, btr_pcur_open_on_user_rec(index, tuple, mode, latch_mode,
&pcur, mtr); &pcur, mtr);
ut_ad(btr_pcur_get_rec(&pcur) == btr_cur_get_rec(cursor)); ut_ad(btr_pcur_get_rec(&pcur) == btr_cur_get_rec(cursor));
} else { } else {
ut_ad(btr_cur_get_rec(&cursor2) == btr_cur_get_rec(cursor)); ut_ad(btr_cur_get_rec(&cursor2) == btr_cur_get_rec(cursor));
@ -854,7 +856,7 @@ btr_search_guess_on_hash(
btr_search_n_succ++; btr_search_n_succ++;
#endif #endif
if (UNIV_LIKELY(!has_search_latch) if (UNIV_LIKELY(!has_search_latch)
&& buf_block_peek_if_too_old(block)) { && buf_block_peek_if_too_old(block)) {
buf_page_make_young(page); buf_page_make_young(page);
} }
@ -931,8 +933,8 @@ retry:
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED)
|| rw_lock_own(&(block->lock), RW_LOCK_EX) || rw_lock_own(&(block->lock), RW_LOCK_EX)
|| (block->buf_fix_count == 0)); || (block->buf_fix_count == 0));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
n_fields = block->curr_n_fields; n_fields = block->curr_n_fields;
@ -972,7 +974,7 @@ retry:
/* FIXME: in a mixed tree, not all records may have enough /* FIXME: in a mixed tree, not all records may have enough
ordering fields: */ ordering fields: */
offsets = rec_get_offsets(rec, index, offsets, offsets = rec_get_offsets(rec, index, offsets,
n_fields + (n_bytes > 0), &heap); n_fields + (n_bytes > 0), &heap);
ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0)); ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0));
fold = rec_fold(rec, offsets, n_fields, n_bytes, tree_id); fold = rec_fold(rec, offsets, n_fields, n_bytes, tree_id);
@ -1006,7 +1008,7 @@ next_rec:
ut_a(block->index == index); ut_a(block->index == index);
if (UNIV_UNLIKELY(block->curr_n_fields != n_fields) if (UNIV_UNLIKELY(block->curr_n_fields != n_fields)
|| UNIV_UNLIKELY(block->curr_n_bytes != n_bytes)) { || UNIV_UNLIKELY(block->curr_n_bytes != n_bytes)) {
/* Someone else has meanwhile built a new hash index on the /* Someone else has meanwhile built a new hash index on the
page, with different parameters */ page, with different parameters */
@ -1029,8 +1031,10 @@ cleanup:
/* Corruption */ /* Corruption */
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Corruption of adaptive hash index. After dropping\n" " InnoDB: Corruption of adaptive hash index."
"InnoDB: the hash index to a page of %s, still %lu hash nodes remain.\n", " After dropping\n"
"InnoDB: the hash index to a page of %s,"
" still %lu hash nodes remain.\n",
index->name, (ulong) block->n_pointers); index->name, (ulong) block->n_pointers);
rw_lock_x_unlock(&btr_search_latch); rw_lock_x_unlock(&btr_search_latch);
@ -1124,14 +1128,14 @@ btr_search_build_page_hash_index(
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED)
|| rw_lock_own(&(block->lock), RW_LOCK_EX)); || rw_lock_own(&(block->lock), RW_LOCK_EX));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
rw_lock_s_lock(&btr_search_latch); rw_lock_s_lock(&btr_search_latch);
if (block->is_hashed && ((block->curr_n_fields != n_fields) if (block->is_hashed && ((block->curr_n_fields != n_fields)
|| (block->curr_n_bytes != n_bytes) || (block->curr_n_bytes != n_bytes)
|| (block->curr_side != side))) { || (block->curr_side != side))) {
rw_lock_s_unlock(&btr_search_latch); rw_lock_s_unlock(&btr_search_latch);
@ -1155,8 +1159,8 @@ btr_search_build_page_hash_index(
} }
if (dict_index_get_n_unique_in_tree(index) < n_fields if (dict_index_get_n_unique_in_tree(index) < n_fields
|| (dict_index_get_n_unique_in_tree(index) == n_fields || (dict_index_get_n_unique_in_tree(index) == n_fields
&& n_bytes > 0)) { && n_bytes > 0)) {
return; return;
} }
@ -1174,7 +1178,7 @@ btr_search_build_page_hash_index(
rec = page_rec_get_next(rec); rec = page_rec_get_next(rec);
offsets = rec_get_offsets(rec, index, offsets, offsets = rec_get_offsets(rec, index, offsets,
n_fields + (n_bytes > 0), &heap); n_fields + (n_bytes > 0), &heap);
if (!page_rec_is_supremum(rec)) { if (!page_rec_is_supremum(rec)) {
ut_a(n_fields <= rec_offs_n_fields(offsets)); ut_a(n_fields <= rec_offs_n_fields(offsets));
@ -1211,9 +1215,9 @@ btr_search_build_page_hash_index(
} }
offsets = rec_get_offsets(next_rec, index, offsets, offsets = rec_get_offsets(next_rec, index, offsets,
n_fields + (n_bytes > 0), &heap); n_fields + (n_bytes > 0), &heap);
next_fold = rec_fold(next_rec, offsets, n_fields, next_fold = rec_fold(next_rec, offsets, n_fields,
n_bytes, tree_id); n_bytes, tree_id);
if (fold != next_fold) { if (fold != next_fold) {
/* Insert an entry into the hash index */ /* Insert an entry into the hash index */
@ -1239,8 +1243,8 @@ btr_search_build_page_hash_index(
rw_lock_x_lock(&btr_search_latch); rw_lock_x_lock(&btr_search_latch);
if (block->is_hashed && ((block->curr_n_fields != n_fields) if (block->is_hashed && ((block->curr_n_fields != n_fields)
|| (block->curr_n_bytes != n_bytes) || (block->curr_n_bytes != n_bytes)
|| (block->curr_side != side))) { || (block->curr_side != side))) {
goto exit_func; goto exit_func;
} }
@ -1327,7 +1331,7 @@ btr_search_move_or_delete_hash_entries(
ut_a(n_fields + n_bytes > 0); ut_a(n_fields + n_bytes > 0);
btr_search_build_page_hash_index(index, new_page, n_fields, btr_search_build_page_hash_index(index, new_page, n_fields,
n_bytes, side); n_bytes, side);
ut_a(n_fields == block->curr_n_fields); ut_a(n_fields == block->curr_n_fields);
ut_a(n_bytes == block->curr_n_bytes); ut_a(n_bytes == block->curr_n_bytes);
ut_a(side == block->curr_side); ut_a(side == block->curr_side);
@ -1378,8 +1382,8 @@ btr_search_update_hash_on_delete(
tree_id = cursor->index->tree->id; tree_id = cursor->index->tree->id;
fold = rec_fold(rec, rec_get_offsets(rec, cursor->index, offsets_, fold = rec_fold(rec, rec_get_offsets(rec, cursor->index, offsets_,
ULINT_UNDEFINED, &heap), block->curr_n_fields, ULINT_UNDEFINED, &heap),
block->curr_n_bytes, tree_id); block->curr_n_fields, block->curr_n_bytes, tree_id);
if (UNIV_LIKELY_NULL(heap)) { if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap); mem_heap_free(heap);
} }
@ -1423,14 +1427,14 @@ btr_search_update_hash_node_on_insert(
rw_lock_x_lock(&btr_search_latch); rw_lock_x_lock(&btr_search_latch);
if ((cursor->flag == BTR_CUR_HASH) if ((cursor->flag == BTR_CUR_HASH)
&& (cursor->n_fields == block->curr_n_fields) && (cursor->n_fields == block->curr_n_fields)
&& (cursor->n_bytes == block->curr_n_bytes) && (cursor->n_bytes == block->curr_n_bytes)
&& (block->curr_side == BTR_SEARCH_RIGHT_SIDE)) { && (block->curr_side == BTR_SEARCH_RIGHT_SIDE)) {
table = btr_search_sys->hash_index; table = btr_search_sys->hash_index;
ha_search_and_update_if_found(table, cursor->fold, rec, ha_search_and_update_if_found(table, cursor->fold, rec,
page_rec_get_next(rec)); page_rec_get_next(rec));
rw_lock_x_unlock(&btr_search_latch); rw_lock_x_unlock(&btr_search_latch);
} else { } else {
@ -1498,19 +1502,19 @@ btr_search_update_hash_on_insert(
next_rec = page_rec_get_next(ins_rec); next_rec = page_rec_get_next(ins_rec);
offsets = rec_get_offsets(ins_rec, cursor->index, offsets, offsets = rec_get_offsets(ins_rec, cursor->index, offsets,
ULINT_UNDEFINED, &heap); ULINT_UNDEFINED, &heap);
ins_fold = rec_fold(ins_rec, offsets, n_fields, n_bytes, tree_id); ins_fold = rec_fold(ins_rec, offsets, n_fields, n_bytes, tree_id);
if (!page_rec_is_supremum(next_rec)) { if (!page_rec_is_supremum(next_rec)) {
offsets = rec_get_offsets(next_rec, cursor->index, offsets, offsets = rec_get_offsets(next_rec, cursor->index, offsets,
n_fields + (n_bytes > 0), &heap); n_fields + (n_bytes > 0), &heap);
next_fold = rec_fold(next_rec, offsets, n_fields, next_fold = rec_fold(next_rec, offsets, n_fields,
n_bytes, tree_id); n_bytes, tree_id);
} }
if (!page_rec_is_infimum(rec)) { if (!page_rec_is_infimum(rec)) {
offsets = rec_get_offsets(rec, cursor->index, offsets, offsets = rec_get_offsets(rec, cursor->index, offsets,
n_fields + (n_bytes > 0), &heap); n_fields + (n_bytes > 0), &heap);
fold = rec_fold(rec, offsets, n_fields, n_bytes, tree_id); fold = rec_fold(rec, offsets, n_fields, n_bytes, tree_id);
} else { } else {
if (side == BTR_SEARCH_LEFT_SIDE) { if (side == BTR_SEARCH_LEFT_SIDE) {
@ -1570,11 +1574,11 @@ check_next_rec:
if (side == BTR_SEARCH_RIGHT_SIDE) { if (side == BTR_SEARCH_RIGHT_SIDE) {
ha_insert_for_fold(table, ins_fold, ins_rec); ha_insert_for_fold(table, ins_fold, ins_rec);
/* /*
fputs("Hash insert for ", stderr); fputs("Hash insert for ", stderr);
dict_index_name_print(stderr, cursor->index); dict_index_name_print(stderr, cursor->index);
fprintf(stderr, " fold %lu\n", ins_fold); fprintf(stderr, " fold %lu\n", ins_fold);
*/ */
} else { } else {
ha_insert_for_fold(table, next_fold, next_rec); ha_insert_for_fold(table, next_fold, next_rec);
} }
@ -1633,12 +1637,13 @@ btr_search_validate(void)
block = buf_block_align(node->data); block = buf_block_align(node->data);
page = buf_frame_align(node->data); page = buf_frame_align(node->data);
offsets = rec_get_offsets((rec_t*) node->data, offsets = rec_get_offsets((rec_t*) node->data,
block->index, offsets, block->index, offsets,
block->curr_n_fields block->curr_n_fields
+ (block->curr_n_bytes > 0), &heap); + (block->curr_n_bytes > 0),
&heap);
if (!block->is_hashed if (!block->is_hashed || node->fold
|| node->fold != rec_fold((rec_t*)(node->data), != rec_fold((rec_t*)(node->data),
offsets, offsets,
block->curr_n_fields, block->curr_n_fields,
block->curr_n_bytes, block->curr_n_bytes,
@ -1647,28 +1652,36 @@ btr_search_validate(void)
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Error in an adaptive hash index pointer to page %lu\n" " InnoDB: Error in an adaptive hash"
"ptr mem address %p index id %lu %lu, node fold %lu, rec fold %lu\n", " index pointer to page %lu\n"
"InnoDB: ptr mem address %p"
" index id %lu %lu,"
" node fold %lu, rec fold %lu\n",
(ulong) buf_frame_get_page_no(page), (ulong) buf_frame_get_page_no(page),
node->data, node->data,
(ulong) ut_dulint_get_high(btr_page_get_index_id(page)), (ulong) ut_dulint_get_high
(ulong) ut_dulint_get_low(btr_page_get_index_id(page)), (btr_page_get_index_id(page)),
(ulong) ut_dulint_get_low
(btr_page_get_index_id(page)),
(ulong) node->fold, (ulong) node->fold,
(ulong) rec_fold((rec_t*)(node->data), (ulong) rec_fold((rec_t*)(node->data),
offsets, offsets,
block->curr_n_fields, block->curr_n_fields,
block->curr_n_bytes, block->curr_n_bytes,
btr_page_get_index_id(page))); btr_page_get_index_id
(page)));
fputs("InnoDB: Record ", stderr); fputs("InnoDB: Record ", stderr);
rec_print_new(stderr, (rec_t*)node->data, rec_print_new(stderr, (rec_t*)node->data,
offsets); offsets);
fprintf(stderr, "\nInnoDB: on that page." fprintf(stderr, "\nInnoDB: on that page."
"Page mem address %p, is hashed %lu, n fields %lu, n bytes %lu\n" " Page mem address %p, is hashed %lu,"
"side %lu\n", " n fields %lu, n bytes %lu\n"
page, (ulong) block->is_hashed, "InnoDB: side %lu\n",
(ulong) block->curr_n_fields, (void*) page, (ulong) block->is_hashed,
(ulong) block->curr_n_bytes, (ulong) block->curr_side); (ulong) block->curr_n_fields,
(ulong) block->curr_n_bytes,
(ulong) block->curr_side);
if (n_page_dumps < 20) { if (n_page_dumps < 20) {
buf_page_print(page); buf_page_print(page);

View File

@ -160,8 +160,8 @@ and the io-operation for loading the page is queued. The io-handler thread
releases the X-lock on the frame and resets the io_fix field releases the X-lock on the frame and resets the io_fix field
when the io operation completes. when the io operation completes.
A thread may request the above operation using the buf_page_get- A thread may request the above operation using the function
function. It may then continue to request a lock on the frame. buf_page_get(). It may then continue to request a lock on the frame.
The lock is granted when the io-handler releases the x-lock. The lock is granted when the io-handler releases the x-lock.
Read-ahead Read-ahead
@ -253,10 +253,10 @@ buf_calc_page_new_checksum(
there we store the old formula checksum. */ there we store the old formula checksum. */
checksum = ut_fold_binary(page + FIL_PAGE_OFFSET, checksum = ut_fold_binary(page + FIL_PAGE_OFFSET,
FIL_PAGE_FILE_FLUSH_LSN - FIL_PAGE_OFFSET) FIL_PAGE_FILE_FLUSH_LSN - FIL_PAGE_OFFSET)
+ ut_fold_binary(page + FIL_PAGE_DATA, + ut_fold_binary(page + FIL_PAGE_DATA,
UNIV_PAGE_SIZE - FIL_PAGE_DATA UNIV_PAGE_SIZE - FIL_PAGE_DATA
- FIL_PAGE_END_LSN_OLD_CHKSUM); - FIL_PAGE_END_LSN_OLD_CHKSUM);
checksum = checksum & 0xFFFFFFFFUL; checksum = checksum & 0xFFFFFFFFUL;
return(checksum); return(checksum);
@ -302,11 +302,11 @@ buf_page_is_corrupted(
dulint current_lsn; dulint current_lsn;
#endif #endif
if (mach_read_from_4(read_buf + FIL_PAGE_LSN + 4) if (mach_read_from_4(read_buf + FIL_PAGE_LSN + 4)
!= mach_read_from_4(read_buf + UNIV_PAGE_SIZE != mach_read_from_4(read_buf + UNIV_PAGE_SIZE
- FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) {
/* Stored log sequence numbers at the start and the end /* Stored log sequence numbers at the start and the end
of page do not match */ of page do not match */
return(TRUE); return(TRUE);
} }
@ -314,22 +314,28 @@ buf_page_is_corrupted(
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
if (recv_lsn_checks_on && log_peek_lsn(&current_lsn)) { if (recv_lsn_checks_on && log_peek_lsn(&current_lsn)) {
if (ut_dulint_cmp(current_lsn, if (ut_dulint_cmp(current_lsn,
mach_read_from_8(read_buf + FIL_PAGE_LSN)) mach_read_from_8(read_buf + FIL_PAGE_LSN))
< 0) { < 0) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Error: page %lu log sequence number %lu %lu\n" " InnoDB: Error: page %lu log sequence number"
"InnoDB: is in the future! Current system log sequence number %lu %lu.\n" " %lu %lu\n"
"InnoDB: Your database may be corrupt or you may have copied the InnoDB\n" "InnoDB: is in the future! Current system "
"InnoDB: tablespace but not the InnoDB log files. See\n" "log sequence number %lu %lu.\n"
"InnoDB: http://dev.mysql.com/doc/refman/5.0/en/forcing-recovery.html\n" "InnoDB: Your database may be corrupt or "
"InnoDB: for more information.\n", "you may have copied the InnoDB\n"
(ulong) mach_read_from_4(read_buf + FIL_PAGE_OFFSET), "InnoDB: tablespace but not the InnoDB "
(ulong) ut_dulint_get_high( "log files. See\n"
mach_read_from_8(read_buf + FIL_PAGE_LSN)), "InnoDB: http://dev.mysql.com/doc/refman/"
(ulong) ut_dulint_get_low( "5.1/en/forcing-recovery.html\n"
mach_read_from_8(read_buf + FIL_PAGE_LSN)), "InnoDB: for more information.\n",
(ulong) mach_read_from_4(read_buf
+ FIL_PAGE_OFFSET),
(ulong) ut_dulint_get_high
(mach_read_from_8(read_buf + FIL_PAGE_LSN)),
(ulong) ut_dulint_get_low
(mach_read_from_8(read_buf + FIL_PAGE_LSN)),
(ulong) ut_dulint_get_high(current_lsn), (ulong) ut_dulint_get_high(current_lsn),
(ulong) ut_dulint_get_low(current_lsn)); (ulong) ut_dulint_get_low(current_lsn));
} }
@ -344,8 +350,9 @@ buf_page_is_corrupted(
if (srv_use_checksums) { if (srv_use_checksums) {
old_checksum = buf_calc_page_old_checksum(read_buf); old_checksum = buf_calc_page_old_checksum(read_buf);
old_checksum_field = mach_read_from_4(read_buf + UNIV_PAGE_SIZE old_checksum_field = mach_read_from_4
- FIL_PAGE_END_LSN_OLD_CHKSUM); (read_buf + UNIV_PAGE_SIZE
- FIL_PAGE_END_LSN_OLD_CHKSUM);
/* There are 2 valid formulas for old_checksum_field: /* There are 2 valid formulas for old_checksum_field:
@ -356,22 +363,22 @@ buf_page_is_corrupted(
there. */ there. */
if (old_checksum_field != mach_read_from_4(read_buf if (old_checksum_field != mach_read_from_4(read_buf
+ FIL_PAGE_LSN) + FIL_PAGE_LSN)
&& old_checksum_field != old_checksum && old_checksum_field != old_checksum
&& old_checksum_field != BUF_NO_CHECKSUM_MAGIC) { && old_checksum_field != BUF_NO_CHECKSUM_MAGIC) {
return(TRUE); return(TRUE);
} }
checksum = buf_calc_page_new_checksum(read_buf); checksum = buf_calc_page_new_checksum(read_buf);
checksum_field = mach_read_from_4(read_buf + checksum_field = mach_read_from_4(read_buf
FIL_PAGE_SPACE_OR_CHKSUM); + FIL_PAGE_SPACE_OR_CHKSUM);
/* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id /* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id
(always equal to 0), to FIL_PAGE_SPACE_SPACE_OR_CHKSUM */ (always equal to 0), to FIL_PAGE_SPACE_SPACE_OR_CHKSUM */
if (checksum_field != 0 && checksum_field != checksum if (checksum_field != 0 && checksum_field != checksum
&& checksum_field != BUF_NO_CHECKSUM_MAGIC) { && checksum_field != BUF_NO_CHECKSUM_MAGIC) {
return(TRUE); return(TRUE);
} }
@ -398,37 +405,41 @@ buf_page_print(
ut_print_buf(stderr, read_buf, UNIV_PAGE_SIZE); ut_print_buf(stderr, read_buf, UNIV_PAGE_SIZE);
fputs("InnoDB: End of page dump\n", stderr); fputs("InnoDB: End of page dump\n", stderr);
checksum = srv_use_checksums ? checksum = srv_use_checksums
buf_calc_page_new_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC; ? buf_calc_page_new_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC;
old_checksum = srv_use_checksums ? old_checksum = srv_use_checksums
buf_calc_page_old_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC; ? buf_calc_page_old_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC;
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Page checksum %lu, prior-to-4.0.14-form checksum %lu\n" " InnoDB: Page checksum %lu, prior-to-4.0.14-form"
"InnoDB: stored checksum %lu, prior-to-4.0.14-form stored checksum %lu\n", " checksum %lu\n"
(ulong) checksum, (ulong) old_checksum, "InnoDB: stored checksum %lu, prior-to-4.0.14-form"
(ulong) mach_read_from_4(read_buf + FIL_PAGE_SPACE_OR_CHKSUM), " stored checksum %lu\n"
(ulong) mach_read_from_4(read_buf + UNIV_PAGE_SIZE "InnoDB: Page lsn %lu %lu, low 4 bytes of lsn"
- FIL_PAGE_END_LSN_OLD_CHKSUM)); " at page end %lu\n"
fprintf(stderr, "InnoDB: Page number (if stored to page already) %lu,\n"
"InnoDB: Page lsn %lu %lu, low 4 bytes of lsn at page end %lu\n" "InnoDB: space id (if created with >= MySQL-4.1.1"
"InnoDB: Page number (if stored to page already) %lu,\n" " and stored already) %lu\n",
"InnoDB: space id (if created with >= MySQL-4.1.1 and stored already) %lu\n", (ulong) checksum, (ulong) old_checksum,
(ulong) mach_read_from_4(read_buf + FIL_PAGE_SPACE_OR_CHKSUM),
(ulong) mach_read_from_4(read_buf + UNIV_PAGE_SIZE
- FIL_PAGE_END_LSN_OLD_CHKSUM),
(ulong) mach_read_from_4(read_buf + FIL_PAGE_LSN), (ulong) mach_read_from_4(read_buf + FIL_PAGE_LSN),
(ulong) mach_read_from_4(read_buf + FIL_PAGE_LSN + 4), (ulong) mach_read_from_4(read_buf + FIL_PAGE_LSN + 4),
(ulong) mach_read_from_4(read_buf + UNIV_PAGE_SIZE (ulong) mach_read_from_4(read_buf + UNIV_PAGE_SIZE
- FIL_PAGE_END_LSN_OLD_CHKSUM + 4), - FIL_PAGE_END_LSN_OLD_CHKSUM + 4),
(ulong) mach_read_from_4(read_buf + FIL_PAGE_OFFSET), (ulong) mach_read_from_4(read_buf + FIL_PAGE_OFFSET),
(ulong) mach_read_from_4(read_buf + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID)); (ulong) mach_read_from_4(read_buf
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID));
if (mach_read_from_2(read_buf + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_TYPE) if (mach_read_from_2(read_buf + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_TYPE)
== TRX_UNDO_INSERT) { == TRX_UNDO_INSERT) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Page may be an insert undo log page\n"); "InnoDB: Page may be an insert undo log page\n");
} else if (mach_read_from_2(read_buf + TRX_UNDO_PAGE_HDR } else if (mach_read_from_2(read_buf + TRX_UNDO_PAGE_HDR
+ TRX_UNDO_PAGE_TYPE) + TRX_UNDO_PAGE_TYPE)
== TRX_UNDO_UPDATE) { == TRX_UNDO_UPDATE) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Page may be an update undo log page\n"); "InnoDB: Page may be an update undo log page\n");
} }
@ -436,17 +447,20 @@ buf_page_print(
switch (fil_page_get_type(read_buf)) { switch (fil_page_get_type(read_buf)) {
case FIL_PAGE_INDEX: case FIL_PAGE_INDEX:
fprintf(stderr, fprintf(stderr,
"InnoDB: Page may be an index page where index id is %lu %lu\n", "InnoDB: Page may be an index page where"
(ulong) ut_dulint_get_high(btr_page_get_index_id(read_buf)), " index id is %lu %lu\n",
(ulong) ut_dulint_get_low(btr_page_get_index_id(read_buf))); (ulong) ut_dulint_get_high
(btr_page_get_index_id(read_buf)),
(ulong) ut_dulint_get_low
(btr_page_get_index_id(read_buf)));
/* If the code is in ibbackup, dict_sys may be uninitialized, /* If the code is in ibbackup, dict_sys may be uninitialized,
i.e., NULL */ i.e., NULL */
if (dict_sys != NULL) { if (dict_sys != NULL) {
index = dict_index_find_on_id_low( index = dict_index_find_on_id_low
btr_page_get_index_id(read_buf)); (btr_page_get_index_id(read_buf));
if (index) { if (index) {
fputs("InnoDB: (", stderr); fputs("InnoDB: (", stderr);
dict_index_name_print(stderr, NULL, index); dict_index_name_print(stderr, NULL, index);
@ -459,35 +473,35 @@ buf_page_print(
break; break;
case FIL_PAGE_IBUF_FREE_LIST: case FIL_PAGE_IBUF_FREE_LIST:
fputs("InnoDB: Page may be an insert buffer free list page\n", fputs("InnoDB: Page may be an insert buffer free list page\n",
stderr); stderr);
break; break;
case FIL_PAGE_TYPE_ALLOCATED: case FIL_PAGE_TYPE_ALLOCATED:
fputs("InnoDB: Page may be a freshly allocated page\n", fputs("InnoDB: Page may be a freshly allocated page\n",
stderr); stderr);
break; break;
case FIL_PAGE_IBUF_BITMAP: case FIL_PAGE_IBUF_BITMAP:
fputs("InnoDB: Page may be an insert buffer bitmap page\n", fputs("InnoDB: Page may be an insert buffer bitmap page\n",
stderr); stderr);
break; break;
case FIL_PAGE_TYPE_SYS: case FIL_PAGE_TYPE_SYS:
fputs("InnoDB: Page may be a system page\n", fputs("InnoDB: Page may be a system page\n",
stderr); stderr);
break; break;
case FIL_PAGE_TYPE_TRX_SYS: case FIL_PAGE_TYPE_TRX_SYS:
fputs("InnoDB: Page may be a transaction system page\n", fputs("InnoDB: Page may be a transaction system page\n",
stderr); stderr);
break; break;
case FIL_PAGE_TYPE_FSP_HDR: case FIL_PAGE_TYPE_FSP_HDR:
fputs("InnoDB: Page may be a file space header page\n", fputs("InnoDB: Page may be a file space header page\n",
stderr); stderr);
break; break;
case FIL_PAGE_TYPE_XDES: case FIL_PAGE_TYPE_XDES:
fputs("InnoDB: Page may be an extent descriptor page\n", fputs("InnoDB: Page may be an extent descriptor page\n",
stderr); stderr);
break; break;
case FIL_PAGE_TYPE_BLOB: case FIL_PAGE_TYPE_BLOB:
fputs("InnoDB: Page may be a BLOB page\n", fputs("InnoDB: Page may be a BLOB page\n",
stderr); stderr);
break; break;
} }
} }
@ -561,9 +575,12 @@ buf_pool_init(
if (n_frames > curr_size) { if (n_frames > curr_size) {
fprintf(stderr, fprintf(stderr,
"InnoDB: AWE: Error: you must specify in my.cnf .._awe_mem_mb larger\n" "InnoDB: AWE: Error: you must specify in my.cnf"
"InnoDB: than .._buffer_pool_size. Now the former is %lu pages,\n" " .._awe_mem_mb larger\n"
"InnoDB: the latter %lu pages.\n", (ulong) curr_size, (ulong) n_frames); "InnoDB: than .._buffer_pool_size. Now the former"
" is %lu pages,\n"
"InnoDB: the latter %lu pages.\n",
(ulong) curr_size, (ulong) n_frames);
return(NULL); return(NULL);
} }
@ -571,7 +588,7 @@ buf_pool_init(
buf_pool = mem_alloc(sizeof(buf_pool_t)); buf_pool = mem_alloc(sizeof(buf_pool_t));
/* 1. Initialize general fields /* 1. Initialize general fields
---------------------------- */ ---------------------------- */
mutex_create(&buf_pool->mutex, SYNC_BUF_POOL); mutex_create(&buf_pool->mutex, SYNC_BUF_POOL);
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
@ -581,8 +598,8 @@ buf_pool_init(
/* Allocate the virtual address space window, i.e., the /* Allocate the virtual address space window, i.e., the
buffer pool frames */ buffer pool frames */
buf_pool->frame_mem = os_awe_allocate_virtual_mem_window( buf_pool->frame_mem = os_awe_allocate_virtual_mem_window
UNIV_PAGE_SIZE * (n_frames + 1)); (UNIV_PAGE_SIZE * (n_frames + 1));
/* Allocate the physical memory for AWE and the AWE info array /* Allocate the physical memory for AWE and the AWE info array
for buf_pool */ for buf_pool */
@ -590,23 +607,26 @@ buf_pool_init(
if ((curr_size % ((1024 * 1024) / UNIV_PAGE_SIZE)) != 0) { if ((curr_size % ((1024 * 1024) / UNIV_PAGE_SIZE)) != 0) {
fprintf(stderr, fprintf(stderr,
"InnoDB: AWE: Error: physical memory must be allocated in full megabytes.\n" "InnoDB: AWE: Error: physical memory must be"
"InnoDB: Trying to allocate %lu database pages.\n", " allocated in full megabytes.\n"
(ulong) curr_size); "InnoDB: Trying to allocate %lu"
" database pages.\n",
(ulong) curr_size);
return(NULL); return(NULL);
} }
if (!os_awe_allocate_physical_mem(&(buf_pool->awe_info), if (!os_awe_allocate_physical_mem(&(buf_pool->awe_info),
curr_size / ((1024 * 1024) / UNIV_PAGE_SIZE))) { curr_size
/ ((1024 * 1024)
/ UNIV_PAGE_SIZE))) {
return(NULL); return(NULL);
} }
/*----------------------------------------*/ /*----------------------------------------*/
} else { } else {
buf_pool->frame_mem = os_mem_alloc_large( buf_pool->frame_mem = os_mem_alloc_large
UNIV_PAGE_SIZE * (n_frames + 1), (UNIV_PAGE_SIZE * (n_frames + 1), TRUE, FALSE);
TRUE, FALSE);
} }
if (buf_pool->frame_mem == NULL) { if (buf_pool->frame_mem == NULL) {
@ -639,9 +659,10 @@ buf_pool_init(
the window */ the window */
os_awe_map_physical_mem_to_window(buf_pool->frame_zero, os_awe_map_physical_mem_to_window(buf_pool->frame_zero,
n_frames * n_frames
(UNIV_PAGE_SIZE / OS_AWE_X86_PAGE_SIZE), * (UNIV_PAGE_SIZE
buf_pool->awe_info); / OS_AWE_X86_PAGE_SIZE),
buf_pool->awe_info);
/*----------------------------------------*/ /*----------------------------------------*/
} }
@ -697,7 +718,7 @@ buf_pool_init(
buf_pool->n_pages_awe_remapped_old = 0; buf_pool->n_pages_awe_remapped_old = 0;
/* 2. Initialize flushing fields /* 2. Initialize flushing fields
---------------------------- */ ---------------------------- */
UT_LIST_INIT(buf_pool->flush_list); UT_LIST_INIT(buf_pool->flush_list);
for (i = BUF_FLUSH_LRU; i <= BUF_FLUSH_LIST; i++) { for (i = BUF_FLUSH_LRU; i <= BUF_FLUSH_LIST; i++) {
@ -712,7 +733,7 @@ buf_pool_init(
buf_pool->freed_page_clock = 0; buf_pool->freed_page_clock = 0;
/* 3. Initialize LRU fields /* 3. Initialize LRU fields
---------------------------- */ ---------------------------- */
UT_LIST_INIT(buf_pool->LRU); UT_LIST_INIT(buf_pool->LRU);
buf_pool->LRU_old = NULL; buf_pool->LRU_old = NULL;
@ -738,7 +759,8 @@ buf_pool_init(
frames */ frames */
UT_LIST_ADD_LAST(awe_LRU_free_mapped, UT_LIST_ADD_LAST(awe_LRU_free_mapped,
buf_pool->awe_LRU_free_mapped, block); buf_pool->awe_LRU_free_mapped,
block);
} }
} }
@ -749,8 +771,8 @@ buf_pool_init(
mutex_exit(&(buf_pool->mutex)); mutex_exit(&(buf_pool->mutex));
if (srv_use_adaptive_hash_indexes) { if (srv_use_adaptive_hash_indexes) {
btr_search_sys_create( btr_search_sys_create(curr_size * UNIV_PAGE_SIZE
curr_size * UNIV_PAGE_SIZE / sizeof(void*) / 64); / sizeof(void*) / 64);
} else { } else {
/* Create only a small dummy system */ /* Create only a small dummy system */
btr_search_sys_create(1000); btr_search_sys_create(1000);
@ -792,35 +814,36 @@ buf_awe_map_page_to_frame(
while (bck) { while (bck) {
if (bck->state == BUF_BLOCK_FILE_PAGE if (bck->state == BUF_BLOCK_FILE_PAGE
&& (bck->buf_fix_count != 0 || bck->io_fix != 0)) { && (bck->buf_fix_count != 0 || bck->io_fix != 0)) {
/* We have to skip this */ /* We have to skip this */
bck = UT_LIST_GET_PREV(awe_LRU_free_mapped, bck); bck = UT_LIST_GET_PREV(awe_LRU_free_mapped, bck);
} else { } else {
/* We can map block to the frame of bck */ /* We can map block to the frame of bck */
os_awe_map_physical_mem_to_window( os_awe_map_physical_mem_to_window
bck->frame, (bck->frame,
UNIV_PAGE_SIZE / OS_AWE_X86_PAGE_SIZE, UNIV_PAGE_SIZE / OS_AWE_X86_PAGE_SIZE,
block->awe_info); block->awe_info);
block->frame = bck->frame; block->frame = bck->frame;
*(buf_pool->blocks_of_frames *(buf_pool->blocks_of_frames
+ (((ulint)(block->frame + (((ulint)(block->frame
- buf_pool->frame_zero)) - buf_pool->frame_zero))
>> UNIV_PAGE_SIZE_SHIFT)) >> UNIV_PAGE_SIZE_SHIFT))
= block; = block;
bck->frame = NULL; bck->frame = NULL;
UT_LIST_REMOVE(awe_LRU_free_mapped, UT_LIST_REMOVE(awe_LRU_free_mapped,
buf_pool->awe_LRU_free_mapped, buf_pool->awe_LRU_free_mapped,
bck); bck);
if (add_to_mapped_list) { if (add_to_mapped_list) {
UT_LIST_ADD_FIRST(awe_LRU_free_mapped, UT_LIST_ADD_FIRST
buf_pool->awe_LRU_free_mapped, (awe_LRU_free_mapped,
block); buf_pool->awe_LRU_free_mapped,
block);
} }
buf_pool->n_pages_awe_remapped++; buf_pool->n_pages_awe_remapped++;
@ -830,8 +853,8 @@ buf_awe_map_page_to_frame(
} }
fprintf(stderr, fprintf(stderr,
"InnoDB: AWE: Fatal error: cannot find a page to unmap\n" "InnoDB: AWE: Fatal error: cannot find a page to unmap\n"
"InnoDB: awe_LRU_free_mapped list length %lu\n", "InnoDB: awe_LRU_free_mapped list length %lu\n",
(ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped)); (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
ut_a(0); ut_a(0);
@ -864,7 +887,7 @@ buf_block_make_young(
buf_block_t* block) /* in: block to make younger */ buf_block_t* block) /* in: block to make younger */
{ {
if (buf_pool->freed_page_clock >= block->freed_page_clock if (buf_pool->freed_page_clock >= block->freed_page_clock
+ 1 + (buf_pool->curr_size / 1024)) { + 1 + (buf_pool->curr_size / 1024)) {
/* There has been freeing activity in the LRU list: /* There has been freeing activity in the LRU list:
best to move to the head of the LRU list */ best to move to the head of the LRU list */
@ -1118,11 +1141,11 @@ buf_page_get_gen(
ut_ad(mtr); ut_ad(mtr);
ut_ad((rw_latch == RW_S_LATCH) ut_ad((rw_latch == RW_S_LATCH)
|| (rw_latch == RW_X_LATCH) || (rw_latch == RW_X_LATCH)
|| (rw_latch == RW_NO_LATCH)); || (rw_latch == RW_NO_LATCH));
ut_ad((mode != BUF_GET_NO_LATCH) || (rw_latch == RW_NO_LATCH)); ut_ad((mode != BUF_GET_NO_LATCH) || (rw_latch == RW_NO_LATCH));
ut_ad((mode == BUF_GET) || (mode == BUF_GET_IF_IN_POOL) ut_ad((mode == BUF_GET) || (mode == BUF_GET_IF_IN_POOL)
|| (mode == BUF_GET_NO_LATCH) || (mode == BUF_GET_NOWAIT)); || (mode == BUF_GET_NO_LATCH) || (mode == BUF_GET_NOWAIT));
#ifndef UNIV_LOG_DEBUG #ifndef UNIV_LOG_DEBUG
ut_ad(!ibuf_inside() || ibuf_page(space, offset)); ut_ad(!ibuf_inside() || ibuf_page(space, offset));
#endif #endif
@ -1136,7 +1159,7 @@ loop:
block = buf_block_align(guess); block = buf_block_align(guess);
if ((offset != block->offset) || (space != block->space) if ((offset != block->offset) || (space != block->space)
|| (block->state != BUF_BLOCK_FILE_PAGE)) { || (block->state != BUF_BLOCK_FILE_PAGE)) {
block = NULL; block = NULL;
} }
@ -1229,12 +1252,12 @@ loop:
if (mode == BUF_GET_NOWAIT) { if (mode == BUF_GET_NOWAIT) {
if (rw_latch == RW_S_LATCH) { if (rw_latch == RW_S_LATCH) {
success = rw_lock_s_lock_func_nowait(&(block->lock), success = rw_lock_s_lock_func_nowait(&(block->lock),
file, line); file, line);
fix_type = MTR_MEMO_PAGE_S_FIX; fix_type = MTR_MEMO_PAGE_S_FIX;
} else { } else {
ut_ad(rw_latch == RW_X_LATCH); ut_ad(rw_latch == RW_X_LATCH);
success = rw_lock_x_lock_func_nowait(&(block->lock), success = rw_lock_x_lock_func_nowait(&(block->lock),
file, line); file, line);
fix_type = MTR_MEMO_PAGE_X_FIX; fix_type = MTR_MEMO_PAGE_X_FIX;
} }
@ -1331,8 +1354,8 @@ buf_page_optimistic_get_func(
/* If AWE is used, block may have a different frame now, e.g., NULL */ /* If AWE is used, block may have a different frame now, e.g., NULL */
if (UNIV_UNLIKELY(block->state != BUF_BLOCK_FILE_PAGE) if (UNIV_UNLIKELY(block->state != BUF_BLOCK_FILE_PAGE)
|| UNIV_UNLIKELY(block->frame != guess)) { || UNIV_UNLIKELY(block->frame != guess)) {
exit_func: exit_func:
mutex_exit(&(buf_pool->mutex)); mutex_exit(&(buf_pool->mutex));
return(FALSE); return(FALSE);
@ -1357,11 +1380,11 @@ buf_page_optimistic_get_func(
if (rw_latch == RW_S_LATCH) { if (rw_latch == RW_S_LATCH) {
success = rw_lock_s_lock_func_nowait(&(block->lock), success = rw_lock_s_lock_func_nowait(&(block->lock),
file, line); file, line);
fix_type = MTR_MEMO_PAGE_S_FIX; fix_type = MTR_MEMO_PAGE_S_FIX;
} else { } else {
success = rw_lock_x_lock_func_nowait(&(block->lock), success = rw_lock_x_lock_func_nowait(&(block->lock),
file, line); file, line);
fix_type = MTR_MEMO_PAGE_X_FIX; fix_type = MTR_MEMO_PAGE_X_FIX;
} }
@ -1414,7 +1437,7 @@ buf_page_optimistic_get_func(
read-ahead */ read-ahead */
buf_read_ahead_linear(buf_frame_get_space_id(guess), buf_read_ahead_linear(buf_frame_get_space_id(guess),
buf_frame_get_page_no(guess)); buf_frame_get_page_no(guess));
} }
#ifdef UNIV_IBUF_DEBUG #ifdef UNIV_IBUF_DEBUG
@ -1482,11 +1505,11 @@ buf_page_get_known_nowait(
if (rw_latch == RW_S_LATCH) { if (rw_latch == RW_S_LATCH) {
success = rw_lock_s_lock_func_nowait(&(block->lock), success = rw_lock_s_lock_func_nowait(&(block->lock),
file, line); file, line);
fix_type = MTR_MEMO_PAGE_S_FIX; fix_type = MTR_MEMO_PAGE_S_FIX;
} else { } else {
success = rw_lock_x_lock_func_nowait(&(block->lock), success = rw_lock_x_lock_func_nowait(&(block->lock),
file, line); file, line);
fix_type = MTR_MEMO_PAGE_X_FIX; fix_type = MTR_MEMO_PAGE_X_FIX;
} }
@ -1519,7 +1542,7 @@ buf_page_get_known_nowait(
#ifdef UNIV_IBUF_DEBUG #ifdef UNIV_IBUF_DEBUG
ut_a((mode == BUF_KEEP_OLD) ut_a((mode == BUF_KEEP_OLD)
|| (ibuf_count_get(block->space, block->offset) == 0)); || (ibuf_count_get(block->space, block->offset) == 0));
#endif #endif
buf_pool->n_page_gets++; buf_pool->n_page_gets++;
@ -1598,7 +1621,8 @@ buf_page_init(
if (buf_page_hash_get(space, offset)) { if (buf_page_hash_get(space, offset)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: page %lu %lu already found from the hash table\n", "InnoDB: Error: page %lu %lu already found"
" in the hash table\n",
(ulong) space, (ulong) space,
(ulong) offset); (ulong) offset);
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
@ -1611,7 +1635,7 @@ buf_page_init(
} }
HASH_INSERT(buf_block_t, hash, buf_pool->page_hash, HASH_INSERT(buf_block_t, hash, buf_pool->page_hash,
buf_page_address_fold(space, offset), block); buf_page_address_fold(space, offset), block);
block->freed_page_clock = 0; block->freed_page_clock = 0;
@ -1686,27 +1710,28 @@ buf_page_init_for_read(
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
if (fil_tablespace_deleted_or_being_deleted_in_mem(space, if (fil_tablespace_deleted_or_being_deleted_in_mem
tablespace_version)) { (space, tablespace_version)) {
*err = DB_TABLESPACE_DELETED; *err = DB_TABLESPACE_DELETED;
} }
if (*err == DB_TABLESPACE_DELETED if (*err == DB_TABLESPACE_DELETED
|| NULL != buf_page_hash_get(space, offset)) { || NULL != buf_page_hash_get(space, offset)) {
/* The page belongs to a space which has been deleted or is /* The page belongs to a space which has been
being deleted, or the page is already in buf_pool, return */ deleted or is being deleted, or the page is
already in buf_pool, return */
mutex_exit(&(buf_pool->mutex)); mutex_exit(&(buf_pool->mutex));
buf_block_free(block); buf_block_free(block);
if (mode == BUF_READ_IBUF_PAGES_ONLY) { if (mode == BUF_READ_IBUF_PAGES_ONLY) {
mtr_commit(&mtr); mtr_commit(&mtr);
} }
return(NULL); return(NULL);
} }
ut_ad(block); ut_ad(block);
@ -1866,23 +1891,24 @@ buf_page_io_complete(
/* If this page is not uninitialized and not in the /* If this page is not uninitialized and not in the
doublewrite buffer, then the page number and space id doublewrite buffer, then the page number and space id
should be the same as in block. */ should be the same as in block. */
ulint read_page_no = mach_read_from_4((block->frame) ulint read_page_no = mach_read_from_4
+ FIL_PAGE_OFFSET); (block->frame + FIL_PAGE_OFFSET);
ulint read_space_id = mach_read_from_4((block->frame) ulint read_space_id = mach_read_from_4
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); (block->frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
if (!block->space && trx_doublewrite_page_inside( if (!block->space
block->offset)) { && trx_doublewrite_page_inside(block->offset)) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Error: reading page %lu\n" " InnoDB: Error: reading page %lu\n"
"InnoDB: which is in the doublewrite buffer!\n", "InnoDB: which is in the"
" doublewrite buffer!\n",
(ulong) block->offset); (ulong) block->offset);
} else if (!read_space_id && !read_page_no) { } else if (!read_space_id && !read_page_no) {
/* This is likely an uninitialized page. */ /* This is likely an uninitialized page. */
} else if ((block->space && block->space != read_space_id) } else if ((block->space && block->space != read_space_id)
|| block->offset != read_page_no) { || block->offset != read_page_no) {
/* We did not compare space_id to read_space_id /* We did not compare space_id to read_space_id
if block->space == 0, because the field on the if block->space == 0, because the field on the
page may contain garbage in MySQL < 4.1.1, page may contain garbage in MySQL < 4.1.1,
@ -1890,59 +1916,73 @@ buf_page_io_complete(
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Error: space id and page n:o stored in the page\n" " InnoDB: Error: space id and page n:o"
"InnoDB: read in are %lu:%lu, should be %lu:%lu!\n", " stored in the page\n"
"InnoDB: read in are %lu:%lu,"
" should be %lu:%lu!\n",
(ulong) read_space_id, (ulong) read_page_no, (ulong) read_space_id, (ulong) read_page_no,
(ulong) block->space, (ulong) block->offset); (ulong) block->space, (ulong) block->offset);
} }
/* From version 3.23.38 up we store the page checksum /* From version 3.23.38 up we store the page checksum
to the 4 first bytes of the page end lsn field */ to the 4 first bytes of the page end lsn field */
if (buf_page_is_corrupted(block->frame)) { if (buf_page_is_corrupted(block->frame)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Database page corruption on disk or a failed\n" "InnoDB: Database page corruption on disk"
"InnoDB: file read of page %lu.\n", (ulong) block->offset); " or a failed\n"
"InnoDB: file read of page %lu.\n",
(ulong) block->offset);
fputs( fputs("InnoDB: You may have to recover"
"InnoDB: You may have to recover from a backup.\n", stderr); " from a backup.\n", stderr);
buf_page_print(block->frame); buf_page_print(block->frame);
fprintf(stderr, fprintf(stderr,
"InnoDB: Database page corruption on disk or a failed\n" "InnoDB: Database page corruption on disk"
"InnoDB: file read of page %lu.\n", (ulong) block->offset); " or a failed\n"
fputs( "InnoDB: file read of page %lu.\n",
"InnoDB: You may have to recover from a backup.\n", stderr); (ulong) block->offset);
fputs( fputs("InnoDB: You may have to recover"
"InnoDB: It is also possible that your operating\n" " from a backup.\n", stderr);
"InnoDB: system has corrupted its own file cache\n" fputs("InnoDB: It is also possible that"
"InnoDB: and rebooting your computer removes the\n" " your operating\n"
"InnoDB: error.\n" "InnoDB: system has corrupted its"
"InnoDB: If the corrupt page is an index page\n" " own file cache\n"
"InnoDB: you can also try to fix the corruption\n" "InnoDB: and rebooting your computer"
"InnoDB: by dumping, dropping, and reimporting\n" " removes the\n"
"InnoDB: the corrupt table. You can use CHECK\n" "InnoDB: error.\n"
"InnoDB: TABLE to scan your table for corruption.\n" "InnoDB: If the corrupt page is an index page\n"
"InnoDB: See also " "InnoDB: you can also try to"
"InnoDB: http://dev.mysql.com/doc/refman/5.0/en/forcing-recovery.html\n" " fix the corruption\n"
"InnoDB: about forcing recovery.\n", stderr); "InnoDB: by dumping, dropping,"
" and reimporting\n"
"InnoDB: the corrupt table."
" You can use CHECK\n"
"InnoDB: TABLE to scan your"
" table for corruption.\n"
"InnoDB: See also"
" http://dev.mysql.com/doc/refman/5.1/en/"
"forcing-recovery.html\n"
"InnoDB: about forcing recovery.\n", stderr);
if (srv_force_recovery < SRV_FORCE_IGNORE_CORRUPT) { if (srv_force_recovery < SRV_FORCE_IGNORE_CORRUPT) {
fputs( fputs("InnoDB: Ending processing because of"
"InnoDB: Ending processing because of a corrupt database page.\n", " a corrupt database page.\n",
stderr); stderr);
exit(1); exit(1);
} }
} }
if (recv_recovery_is_on()) { if (recv_recovery_is_on()) {
recv_recover_page(FALSE, TRUE, block->frame, recv_recover_page(FALSE, TRUE, block->frame,
block->space, block->offset); block->space, block->offset);
} }
if (!recv_no_ibuf_operations) { if (!recv_no_ibuf_operations) {
ibuf_merge_or_delete_for_page(block->frame, ibuf_merge_or_delete_for_page
block->space, block->offset, TRUE); (block->frame, block->space,
block->offset, TRUE);
} }
} }
@ -2058,25 +2098,25 @@ buf_validate(void)
if (block->state == BUF_BLOCK_FILE_PAGE) { if (block->state == BUF_BLOCK_FILE_PAGE) {
ut_a(buf_page_hash_get(block->space, ut_a(buf_page_hash_get(block->space,
block->offset) == block); block->offset) == block);
n_page++; n_page++;
#ifdef UNIV_IBUF_DEBUG #ifdef UNIV_IBUF_DEBUG
ut_a((block->io_fix == BUF_IO_READ) ut_a((block->io_fix == BUF_IO_READ)
|| ibuf_count_get(block->space, block->offset) || ibuf_count_get(block->space, block->offset)
== 0); == 0);
#endif #endif
if (block->io_fix == BUF_IO_WRITE) { if (block->io_fix == BUF_IO_WRITE) {
if (block->flush_type == BUF_FLUSH_LRU) { if (block->flush_type == BUF_FLUSH_LRU) {
n_lru_flush++; n_lru_flush++;
ut_a(rw_lock_is_locked(&(block->lock), ut_a(rw_lock_is_locked
RW_LOCK_SHARED)); (&block->lock, RW_LOCK_SHARED));
} else if (block->flush_type == } else if (block->flush_type
BUF_FLUSH_LIST) { == BUF_FLUSH_LIST) {
n_list_flush++; n_list_flush++;
} else if (block->flush_type == } else if (block->flush_type
BUF_FLUSH_SINGLE_PAGE) { == BUF_FLUSH_SINGLE_PAGE) {
n_single_flush++; n_single_flush++;
} else { } else {
ut_error; ut_error;
@ -2085,14 +2125,14 @@ buf_validate(void)
} else if (block->io_fix == BUF_IO_READ) { } else if (block->io_fix == BUF_IO_READ) {
ut_a(rw_lock_is_locked(&(block->lock), ut_a(rw_lock_is_locked(&(block->lock),
RW_LOCK_EX)); RW_LOCK_EX));
} }
n_lru++; n_lru++;
if (ut_dulint_cmp(block->oldest_modification, if (ut_dulint_cmp(block->oldest_modification,
ut_dulint_zero) > 0) { ut_dulint_zero) > 0) {
n_flush++; n_flush++;
} }
} else if (block->state == BUF_BLOCK_NOT_USED) { } else if (block->state == BUF_BLOCK_NOT_USED) {
@ -2101,14 +2141,16 @@ buf_validate(void)
} }
if (n_lru + n_free > buf_pool->curr_size) { if (n_lru + n_free > buf_pool->curr_size) {
fprintf(stderr, "n LRU %lu, n free %lu\n", (ulong) n_lru, (ulong) n_free); fprintf(stderr, "n LRU %lu, n free %lu\n",
(ulong) n_lru, (ulong) n_free);
ut_error; ut_error;
} }
ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == n_lru); ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == n_lru);
if (UT_LIST_GET_LEN(buf_pool->free) != n_free) { if (UT_LIST_GET_LEN(buf_pool->free) != n_free) {
fprintf(stderr, "Free list len %lu, free blocks %lu\n", fprintf(stderr, "Free list len %lu, free blocks %lu\n",
(ulong) UT_LIST_GET_LEN(buf_pool->free), (ulong) n_free); (ulong) UT_LIST_GET_LEN(buf_pool->free),
(ulong) n_free);
ut_error; ut_error;
} }
ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush); ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush);
@ -2233,9 +2275,9 @@ Returns the number of latched pages in the buffer pool. */
ulint ulint
buf_get_latched_pages_number(void) buf_get_latched_pages_number(void)
{ {
buf_block_t* block; buf_block_t* block;
ulint i; ulint i;
ulint fixed_pages_number = 0; ulint fixed_pages_number = 0;
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
@ -2243,9 +2285,10 @@ buf_get_latched_pages_number(void)
block = buf_pool_get_nth_block(buf_pool, i); block = buf_pool_get_nth_block(buf_pool, i);
if (((block->buf_fix_count != 0) || (block->io_fix != 0)) && if (((block->buf_fix_count != 0) || (block->io_fix != 0))
block->magic_n == BUF_BLOCK_MAGIC_N ) && block->magic_n == BUF_BLOCK_MAGIC_N) {
fixed_pages_number++; fixed_pages_number++;
}
} }
mutex_exit(&(buf_pool->mutex)); mutex_exit(&(buf_pool->mutex));
@ -2261,9 +2304,9 @@ buf_get_n_pending_ios(void)
/*=======================*/ /*=======================*/
{ {
return(buf_pool->n_pend_reads return(buf_pool->n_pend_reads
+ buf_pool->n_flush[BUF_FLUSH_LRU] + buf_pool->n_flush[BUF_FLUSH_LRU]
+ buf_pool->n_flush[BUF_FLUSH_LIST] + buf_pool->n_flush[BUF_FLUSH_LIST]
+ buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]); + buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]);
} }
/************************************************************************* /*************************************************************************
@ -2280,7 +2323,7 @@ buf_get_modified_ratio_pct(void)
ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list)) ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list))
/ (1 + UT_LIST_GET_LEN(buf_pool->LRU) / (1 + UT_LIST_GET_LEN(buf_pool->LRU)
+ UT_LIST_GET_LEN(buf_pool->free)); + UT_LIST_GET_LEN(buf_pool->free));
/* 1 + is there to avoid division by zero */ /* 1 + is there to avoid division by zero */
@ -2308,12 +2351,14 @@ buf_print_io(
if (srv_use_awe) { if (srv_use_awe) {
fprintf(stderr, fprintf(stderr,
"AWE: Buffer pool memory frames %lu\n", "AWE: Buffer pool memory frames %lu\n",
(ulong) buf_pool->n_frames); (ulong) buf_pool->n_frames);
fprintf(stderr, fprintf(stderr,
"AWE: Database pages and free buffers mapped in frames %lu\n", "AWE: Database pages and free buffers"
(ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped)); " mapped in frames %lu\n",
(ulong)
UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
} }
fprintf(file, fprintf(file,
"Buffer pool size %lu\n" "Buffer pool size %lu\n"
@ -2328,14 +2373,14 @@ buf_print_io(
(ulong) UT_LIST_GET_LEN(buf_pool->flush_list), (ulong) UT_LIST_GET_LEN(buf_pool->flush_list),
(ulong) buf_pool->n_pend_reads, (ulong) buf_pool->n_pend_reads,
(ulong) buf_pool->n_flush[BUF_FLUSH_LRU] (ulong) buf_pool->n_flush[BUF_FLUSH_LRU]
+ buf_pool->init_flush[BUF_FLUSH_LRU], + buf_pool->init_flush[BUF_FLUSH_LRU],
(ulong) buf_pool->n_flush[BUF_FLUSH_LIST] (ulong) buf_pool->n_flush[BUF_FLUSH_LIST]
+ buf_pool->init_flush[BUF_FLUSH_LIST], + buf_pool->init_flush[BUF_FLUSH_LIST],
(ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]); (ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]);
current_time = time(NULL); current_time = time(NULL);
time_elapsed = 0.001 + difftime(current_time, time_elapsed = 0.001 + difftime(current_time,
buf_pool->last_printout_time); buf_pool->last_printout_time);
buf_pool->last_printout_time = current_time; buf_pool->last_printout_time = current_time;
fprintf(file, fprintf(file,
@ -2353,19 +2398,21 @@ buf_print_io(
if (srv_use_awe) { if (srv_use_awe) {
fprintf(file, "AWE: %.2f page remaps/s\n", fprintf(file, "AWE: %.2f page remaps/s\n",
(buf_pool->n_pages_awe_remapped (buf_pool->n_pages_awe_remapped
- buf_pool->n_pages_awe_remapped_old) - buf_pool->n_pages_awe_remapped_old)
/ time_elapsed); / time_elapsed);
} }
if (buf_pool->n_page_gets > buf_pool->n_page_gets_old) { if (buf_pool->n_page_gets > buf_pool->n_page_gets_old) {
fprintf(file, "Buffer pool hit rate %lu / 1000\n", fprintf(file, "Buffer pool hit rate %lu / 1000\n",
(ulong) (1000 - (ulong)
((1000 * (buf_pool->n_pages_read - buf_pool->n_pages_read_old)) (1000 - ((1000 * (buf_pool->n_pages_read
/ (buf_pool->n_page_gets - buf_pool->n_page_gets_old)))); - buf_pool->n_pages_read_old))
/ (buf_pool->n_page_gets
- buf_pool->n_page_gets_old))));
} else { } else {
fputs("No buffer pool page gets since the last printout\n", fputs("No buffer pool page gets since the last printout\n",
file); file);
} }
buf_pool->n_page_gets_old = buf_pool->n_page_gets; buf_pool->n_page_gets_old = buf_pool->n_page_gets;
@ -2416,7 +2463,8 @@ buf_all_freed(void)
fprintf(stderr, fprintf(stderr,
"Page %lu %lu still fixed or dirty\n", "Page %lu %lu still fixed or dirty\n",
(ulong) block->space, (ulong) block->offset); (ulong) block->space,
(ulong) block->offset);
ut_error; ut_error;
} }
} }
@ -2441,8 +2489,8 @@ buf_pool_check_no_pending_io(void)
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
if (buf_pool->n_pend_reads + buf_pool->n_flush[BUF_FLUSH_LRU] if (buf_pool->n_pend_reads + buf_pool->n_flush[BUF_FLUSH_LRU]
+ buf_pool->n_flush[BUF_FLUSH_LIST] + buf_pool->n_flush[BUF_FLUSH_LIST]
+ buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]) { + buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]) {
ret = FALSE; ret = FALSE;
} else { } else {
ret = TRUE; ret = TRUE;

View File

@ -55,10 +55,9 @@ buf_flush_insert_into_flush_list(
ut_a(block->state == BUF_BLOCK_FILE_PAGE); ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_ad((UT_LIST_GET_FIRST(buf_pool->flush_list) == NULL) ut_ad((UT_LIST_GET_FIRST(buf_pool->flush_list) == NULL)
|| (ut_dulint_cmp( || (ut_dulint_cmp((UT_LIST_GET_FIRST(buf_pool->flush_list))
(UT_LIST_GET_FIRST(buf_pool->flush_list)) ->oldest_modification,
->oldest_modification, block->oldest_modification) <= 0));
block->oldest_modification) <= 0));
UT_LIST_ADD_FIRST(flush_list, buf_pool->flush_list, block); UT_LIST_ADD_FIRST(flush_list, buf_pool->flush_list, block);
@ -86,7 +85,7 @@ buf_flush_insert_sorted_into_flush_list(
b = UT_LIST_GET_FIRST(buf_pool->flush_list); b = UT_LIST_GET_FIRST(buf_pool->flush_list);
while (b && (ut_dulint_cmp(b->oldest_modification, while (b && (ut_dulint_cmp(b->oldest_modification,
block->oldest_modification) > 0)) { block->oldest_modification) > 0)) {
prev_b = b; prev_b = b;
b = UT_LIST_GET_NEXT(flush_list, b); b = UT_LIST_GET_NEXT(flush_list, b);
} }
@ -95,7 +94,7 @@ buf_flush_insert_sorted_into_flush_list(
UT_LIST_ADD_FIRST(flush_list, buf_pool->flush_list, block); UT_LIST_ADD_FIRST(flush_list, buf_pool->flush_list, block);
} else { } else {
UT_LIST_INSERT_AFTER(flush_list, buf_pool->flush_list, prev_b, UT_LIST_INSERT_AFTER(flush_list, buf_pool->flush_list, prev_b,
block); block);
} }
ut_ad(buf_flush_validate_low()); ut_ad(buf_flush_validate_low());
@ -118,7 +117,8 @@ buf_flush_ready_for_replace(
if (block->state != BUF_BLOCK_FILE_PAGE) { if (block->state != BUF_BLOCK_FILE_PAGE) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Error: buffer block state %lu in the LRU list!\n", " InnoDB: Error: buffer block state %lu"
" in the LRU list!\n",
(ulong)block->state); (ulong)block->state);
ut_print_buf(stderr, block, sizeof(buf_block_t)); ut_print_buf(stderr, block, sizeof(buf_block_t));
@ -126,8 +126,8 @@ buf_flush_ready_for_replace(
} }
if ((ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0) if ((ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0)
|| (block->buf_fix_count != 0) || (block->buf_fix_count != 0)
|| (block->io_fix != 0)) { || (block->io_fix != 0)) {
return(FALSE); return(FALSE);
} }
@ -152,7 +152,7 @@ buf_flush_ready_for_flush(
ut_a(block->state == BUF_BLOCK_FILE_PAGE); ut_a(block->state == BUF_BLOCK_FILE_PAGE);
if ((ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0) if ((ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0)
&& (block->io_fix == 0)) { && (block->io_fix == 0)) {
if (flush_type != BUF_FLUSH_LRU) { if (flush_type != BUF_FLUSH_LRU) {
return(TRUE); return(TRUE);
@ -202,10 +202,10 @@ buf_flush_write_complete(
} }
/* fprintf(stderr, "n pending flush %lu\n", /* fprintf(stderr, "n pending flush %lu\n",
buf_pool->n_flush[block->flush_type]); */ buf_pool->n_flush[block->flush_type]); */
if ((buf_pool->n_flush[block->flush_type] == 0) if ((buf_pool->n_flush[block->flush_type] == 0)
&& (buf_pool->init_flush[block->flush_type] == FALSE)) { && (buf_pool->init_flush[block->flush_type] == FALSE)) {
/* The running flush batch has ended */ /* The running flush batch has ended */
@ -255,27 +255,33 @@ buf_flush_buffered_writes(void)
ut_a(block->state == BUF_BLOCK_FILE_PAGE); ut_a(block->state == BUF_BLOCK_FILE_PAGE);
if (mach_read_from_4(block->frame + FIL_PAGE_LSN + 4) if (mach_read_from_4(block->frame + FIL_PAGE_LSN + 4)
!= mach_read_from_4(block->frame + UNIV_PAGE_SIZE != mach_read_from_4(block->frame + UNIV_PAGE_SIZE
- FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: ERROR: The page to be written seems corrupt!\n" " InnoDB: ERROR: The page to be written"
"InnoDB: The lsn fields do not match! Noticed in the buffer pool\n" " seems corrupt!\n"
"InnoDB: before posting to the doublewrite buffer.\n"); "InnoDB: The lsn fields do not match!"
" Noticed in the buffer pool\n"
"InnoDB: before posting to the"
" doublewrite buffer.\n");
} }
if (block->check_index_page_at_flush if (block->check_index_page_at_flush
&& !page_simple_validate(block->frame)) { && !page_simple_validate(block->frame)) {
buf_page_print(block->frame); buf_page_print(block->frame);
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Apparent corruption of an index page n:o %lu in space %lu\n" " InnoDB: Apparent corruption of an"
"InnoDB: to be written to data file. We intentionally crash server\n" " index page n:o %lu in space %lu\n"
"InnoDB: to prevent corrupt data from ending up in data\n" "InnoDB: to be written to data file."
"InnoDB: files.\n", " We intentionally crash server\n"
(ulong) block->offset, (ulong) block->space); "InnoDB: to prevent corrupt data"
" from ending up in data\n"
"InnoDB: files.\n",
(ulong) block->offset, (ulong) block->space);
ut_error; ut_error;
} }
@ -292,47 +298,54 @@ buf_flush_buffered_writes(void)
} }
fil_io(OS_FILE_WRITE, fil_io(OS_FILE_WRITE,
TRUE, TRX_SYS_SPACE, TRUE, TRX_SYS_SPACE,
trx_doublewrite->block1, 0, len, trx_doublewrite->block1, 0, len,
(void*)trx_doublewrite->write_buf, NULL); (void*)trx_doublewrite->write_buf, NULL);
write_buf = trx_doublewrite->write_buf; write_buf = trx_doublewrite->write_buf;
for (len2 = 0; len2 + UNIV_PAGE_SIZE <= len; len2 += UNIV_PAGE_SIZE) { for (len2 = 0; len2 + UNIV_PAGE_SIZE <= len; len2 += UNIV_PAGE_SIZE) {
if (mach_read_from_4(write_buf + len2 + FIL_PAGE_LSN + 4) if (mach_read_from_4(write_buf + len2 + FIL_PAGE_LSN + 4)
!= mach_read_from_4(write_buf + len2 + UNIV_PAGE_SIZE != mach_read_from_4(write_buf + len2 + UNIV_PAGE_SIZE
- FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: ERROR: The page to be written seems corrupt!\n" " InnoDB: ERROR: The page to be written"
"InnoDB: The lsn fields do not match! Noticed in the doublewrite block1.\n"); " seems corrupt!\n"
"InnoDB: The lsn fields do not match!"
" Noticed in the doublewrite block1.\n");
} }
} }
if (trx_doublewrite->first_free > TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) { if (trx_doublewrite->first_free > TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) {
len = (trx_doublewrite->first_free len = (trx_doublewrite->first_free
- TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) * UNIV_PAGE_SIZE; - TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) * UNIV_PAGE_SIZE;
fil_io(OS_FILE_WRITE, fil_io(OS_FILE_WRITE,
TRUE, TRX_SYS_SPACE, TRUE, TRX_SYS_SPACE,
trx_doublewrite->block2, 0, len, trx_doublewrite->block2, 0, len,
(void*)(trx_doublewrite->write_buf (void*)(trx_doublewrite->write_buf
+ TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE), + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE
NULL); * UNIV_PAGE_SIZE),
NULL);
write_buf = trx_doublewrite->write_buf write_buf = trx_doublewrite->write_buf
+ TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE; + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE;
for (len2 = 0; len2 + UNIV_PAGE_SIZE <= len; for (len2 = 0; len2 + UNIV_PAGE_SIZE <= len;
len2 += UNIV_PAGE_SIZE) { len2 += UNIV_PAGE_SIZE) {
if (mach_read_from_4(write_buf + len2 if (mach_read_from_4(write_buf + len2
+ FIL_PAGE_LSN + 4) + FIL_PAGE_LSN + 4)
!= mach_read_from_4(write_buf + len2 != mach_read_from_4(write_buf + len2
+ UNIV_PAGE_SIZE + UNIV_PAGE_SIZE
- FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { - FIL_PAGE_END_LSN_OLD_CHKSUM
+ 4)) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: ERROR: The page to be written seems corrupt!\n" " InnoDB: ERROR: The page to be"
"InnoDB: The lsn fields do not match! Noticed in the doublewrite block2.\n"); " written seems corrupt!\n"
"InnoDB: The lsn fields do not match!"
" Noticed in"
" the doublewrite block2.\n");
} }
} }
} }
@ -349,14 +362,18 @@ buf_flush_buffered_writes(void)
block = trx_doublewrite->buf_block_arr[i]; block = trx_doublewrite->buf_block_arr[i];
if (mach_read_from_4(block->frame + FIL_PAGE_LSN + 4) if (mach_read_from_4(block->frame + FIL_PAGE_LSN + 4)
!= mach_read_from_4(block->frame + UNIV_PAGE_SIZE != mach_read_from_4(block->frame + UNIV_PAGE_SIZE
- FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: ERROR: The page to be written seems corrupt!\n" " InnoDB: ERROR: The page to be written"
"InnoDB: The lsn fields do not match! Noticed in the buffer pool\n" " seems corrupt!\n"
"InnoDB: after posting and flushing the doublewrite buffer.\n" "InnoDB: The lsn fields do not match!"
"InnoDB: Page buf fix count %lu, io fix %lu, state %lu\n", " Noticed in the buffer pool\n"
"InnoDB: after posting and flushing"
" the doublewrite buffer.\n"
"InnoDB: Page buf fix count %lu,"
" io fix %lu, state %lu\n",
(ulong)block->buf_fix_count, (ulong)block->buf_fix_count,
(ulong)block->io_fix, (ulong)block->io_fix,
(ulong)block->state); (ulong)block->state);
@ -364,8 +381,8 @@ buf_flush_buffered_writes(void)
ut_a(block->state == BUF_BLOCK_FILE_PAGE); ut_a(block->state == BUF_BLOCK_FILE_PAGE);
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER, fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
FALSE, block->space, block->offset, 0, UNIV_PAGE_SIZE, FALSE, block->space, block->offset, 0, UNIV_PAGE_SIZE,
(void*)block->frame, (void*)block); (void*)block->frame, (void*)block);
} }
/* Wake possible simulated aio thread to actually post the /* Wake possible simulated aio thread to actually post the
@ -405,7 +422,7 @@ try_again:
ut_a(block->state == BUF_BLOCK_FILE_PAGE); ut_a(block->state == BUF_BLOCK_FILE_PAGE);
if (trx_doublewrite->first_free if (trx_doublewrite->first_free
>= 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) { >= 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) {
mutex_exit(&(trx_doublewrite->mutex)); mutex_exit(&(trx_doublewrite->mutex));
buf_flush_buffered_writes(); buf_flush_buffered_writes();
@ -414,15 +431,15 @@ try_again:
} }
ut_memcpy(trx_doublewrite->write_buf ut_memcpy(trx_doublewrite->write_buf
+ UNIV_PAGE_SIZE * trx_doublewrite->first_free, + UNIV_PAGE_SIZE * trx_doublewrite->first_free,
block->frame, UNIV_PAGE_SIZE); block->frame, UNIV_PAGE_SIZE);
trx_doublewrite->buf_block_arr[trx_doublewrite->first_free] = block; trx_doublewrite->buf_block_arr[trx_doublewrite->first_free] = block;
trx_doublewrite->first_free++; trx_doublewrite->first_free++;
if (trx_doublewrite->first_free if (trx_doublewrite->first_free
>= 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) { >= 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) {
mutex_exit(&(trx_doublewrite->mutex)); mutex_exit(&(trx_doublewrite->mutex));
buf_flush_buffered_writes(); buf_flush_buffered_writes();
@ -448,7 +465,7 @@ buf_flush_init_for_writing(
mach_write_to_8(page + FIL_PAGE_LSN, newest_lsn); mach_write_to_8(page + FIL_PAGE_LSN, newest_lsn);
mach_write_to_8(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, mach_write_to_8(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM,
newest_lsn); newest_lsn);
/* Write the page number and the space id */ /* Write the page number and the space id */
mach_write_to_4(page + FIL_PAGE_OFFSET, page_no); mach_write_to_4(page + FIL_PAGE_OFFSET, page_no);
@ -457,8 +474,9 @@ buf_flush_init_for_writing(
/* Store the new formula checksum */ /* Store the new formula checksum */
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
srv_use_checksums ? srv_use_checksums
buf_calc_page_new_checksum(page) : BUF_NO_CHECKSUM_MAGIC); ? buf_calc_page_new_checksum(page)
: BUF_NO_CHECKSUM_MAGIC);
/* We overwrite the first 4 bytes of the end lsn field to store /* We overwrite the first 4 bytes of the end lsn field to store
the old formula checksum. Since it depends also on the field the old formula checksum. Since it depends also on the field
@ -466,8 +484,9 @@ buf_flush_init_for_writing(
new formula checksum. */ new formula checksum. */
mach_write_to_4(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, mach_write_to_4(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM,
srv_use_checksums ? srv_use_checksums
buf_calc_page_old_checksum(page) : BUF_NO_CHECKSUM_MAGIC); ? buf_calc_page_old_checksum(page)
: BUF_NO_CHECKSUM_MAGIC);
} }
/************************************************************************ /************************************************************************
@ -493,21 +512,21 @@ buf_flush_write_block_low(
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (!univ_log_debug_warned) { if (!univ_log_debug_warned) {
univ_log_debug_warned = TRUE; univ_log_debug_warned = TRUE;
fputs( fputs("Warning: cannot force log to disk if"
"Warning: cannot force log to disk if UNIV_LOG_DEBUG is defined!\n" " UNIV_LOG_DEBUG is defined!\n"
"Crash recovery will not work!\n", "Crash recovery will not work!\n",
stderr); stderr);
} }
#else #else
/* Force the log to the disk before writing the modified block */ /* Force the log to the disk before writing the modified block */
log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE); log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE);
#endif #endif
buf_flush_init_for_writing(block->frame, block->newest_modification, buf_flush_init_for_writing(block->frame, block->newest_modification,
block->space, block->offset); block->space, block->offset);
if (!srv_use_doublewrite_buf || !trx_doublewrite) { if (!srv_use_doublewrite_buf || !trx_doublewrite) {
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER, fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
FALSE, block->space, block->offset, 0, UNIV_PAGE_SIZE, FALSE, block->space, block->offset, 0, UNIV_PAGE_SIZE,
(void*)block->frame, (void*)block); (void*)block->frame, (void*)block);
} else { } else {
buf_flush_post_to_doublewrite_buf(block); buf_flush_post_to_doublewrite_buf(block);
} }
@ -532,7 +551,7 @@ buf_flush_try_page(
ibool locked; ibool locked;
ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST
|| flush_type == BUF_FLUSH_SINGLE_PAGE); || flush_type == BUF_FLUSH_SINGLE_PAGE);
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
@ -541,7 +560,7 @@ buf_flush_try_page(
ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE); ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE);
if (flush_type == BUF_FLUSH_LIST if (flush_type == BUF_FLUSH_LIST
&& block && buf_flush_ready_for_flush(block, flush_type)) { && block && buf_flush_ready_for_flush(block, flush_type)) {
block->io_fix = BUF_IO_WRITE; block->io_fix = BUF_IO_WRITE;
@ -600,7 +619,7 @@ buf_flush_try_page(
return(1); return(1);
} else if (flush_type == BUF_FLUSH_LRU && block } else if (flush_type == BUF_FLUSH_LRU && block
&& buf_flush_ready_for_flush(block, flush_type)) { && buf_flush_ready_for_flush(block, flush_type)) {
/* VERY IMPORTANT: /* VERY IMPORTANT:
Because any thread may call the LRU flush, even when owning Because any thread may call the LRU flush, even when owning
@ -647,7 +666,7 @@ buf_flush_try_page(
return(1); return(1);
} else if (flush_type == BUF_FLUSH_SINGLE_PAGE && block } else if (flush_type == BUF_FLUSH_SINGLE_PAGE && block
&& buf_flush_ready_for_flush(block, flush_type)) { && buf_flush_ready_for_flush(block, flush_type)) {
block->io_fix = BUF_IO_WRITE; block->io_fix = BUF_IO_WRITE;
@ -680,9 +699,10 @@ buf_flush_try_page(
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (buf_debug_prints) { if (buf_debug_prints) {
fprintf(stderr, fprintf(stderr,
"Flushing single page space %lu, page no %lu \n", "Flushing single page space %lu,"
(ulong) block->space, " page no %lu \n",
(ulong) block->offset); (ulong) block->space,
(ulong) block->offset);
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
@ -739,7 +759,7 @@ buf_flush_try_neighbors(
ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE); ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE);
if (block && flush_type == BUF_FLUSH_LRU && i != offset if (block && flush_type == BUF_FLUSH_LRU && i != offset
&& !block->old) { && !block->old) {
/* We avoid flushing 'non-old' blocks in an LRU flush, /* We avoid flushing 'non-old' blocks in an LRU flush,
because the flushed blocks are soon freed */ because the flushed blocks are soon freed */
@ -748,7 +768,7 @@ buf_flush_try_neighbors(
} }
if (block && buf_flush_ready_for_flush(block, flush_type) if (block && buf_flush_ready_for_flush(block, flush_type)
&& (i == offset || block->buf_fix_count == 0)) { && (i == offset || block->buf_fix_count == 0)) {
/* We only try to flush those neighbors != offset /* We only try to flush those neighbors != offset
where the buf fix count is zero, as we then know that where the buf fix count is zero, as we then know that
we probably can latch the page without a semaphore we probably can latch the page without a semaphore
@ -806,13 +826,13 @@ buf_flush_batch(
ibool found; ibool found;
ut_ad((flush_type == BUF_FLUSH_LRU) ut_ad((flush_type == BUF_FLUSH_LRU)
|| (flush_type == BUF_FLUSH_LIST)); || (flush_type == BUF_FLUSH_LIST));
ut_ad((flush_type != BUF_FLUSH_LIST) ut_ad((flush_type != BUF_FLUSH_LIST)
|| sync_thread_levels_empty_gen(TRUE)); || sync_thread_levels_empty_gen(TRUE));
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
if ((buf_pool->n_flush[flush_type] > 0) if ((buf_pool->n_flush[flush_type] > 0)
|| (buf_pool->init_flush[flush_type] == TRUE)) { || (buf_pool->init_flush[flush_type] == TRUE)) {
/* There is already a flush batch of the same type running */ /* There is already a flush batch of the same type running */
@ -840,8 +860,8 @@ buf_flush_batch(
block = UT_LIST_GET_LAST(buf_pool->flush_list); block = UT_LIST_GET_LAST(buf_pool->flush_list);
if (!block if (!block
|| (ut_dulint_cmp(block->oldest_modification, || (ut_dulint_cmp(block->oldest_modification,
lsn_limit) >= 0)) { lsn_limit) >= 0)) {
/* We have flushed enough */ /* We have flushed enough */
break; break;
@ -870,9 +890,8 @@ buf_flush_batch(
old_page_count = page_count; old_page_count = page_count;
/* Try to flush also all the neighbors */ /* Try to flush also all the neighbors */
page_count += page_count += buf_flush_try_neighbors
buf_flush_try_neighbors(space, offset, (space, offset, flush_type);
flush_type);
/* fprintf(stderr, /* fprintf(stderr,
"Flush type %lu, page no %lu, neighb %lu\n", "Flush type %lu, page no %lu, neighb %lu\n",
flush_type, offset, flush_type, offset,
@ -900,7 +919,7 @@ buf_flush_batch(
(buf_pool->init_flush)[flush_type] = FALSE; (buf_pool->init_flush)[flush_type] = FALSE;
if ((buf_pool->n_flush[flush_type] == 0) if ((buf_pool->n_flush[flush_type] == 0)
&& (buf_pool->init_flush[flush_type] == FALSE)) { && (buf_pool->init_flush[flush_type] == FALSE)) {
/* The running flush batch has ended */ /* The running flush batch has ended */
@ -914,7 +933,7 @@ buf_flush_batch(
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (buf_debug_prints && page_count > 0) { if (buf_debug_prints && page_count > 0) {
ut_a(flush_type == BUF_FLUSH_LRU ut_a(flush_type == BUF_FLUSH_LRU
|| flush_type == BUF_FLUSH_LIST); || flush_type == BUF_FLUSH_LIST);
fprintf(stderr, flush_type == BUF_FLUSH_LRU fprintf(stderr, flush_type == BUF_FLUSH_LRU
? "Flushed %lu pages in LRU flush\n" ? "Flushed %lu pages in LRU flush\n"
: "Flushed %lu pages in flush list flush\n", : "Flushed %lu pages in flush list flush\n",
@ -923,7 +942,7 @@ buf_flush_batch(
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
if (page_count != ULINT_UNDEFINED) if (page_count != ULINT_UNDEFINED)
srv_buf_pool_flushed+= page_count; srv_buf_pool_flushed+= page_count;
return(page_count); return(page_count);
} }
@ -963,9 +982,9 @@ buf_flush_LRU_recommendation(void)
block = UT_LIST_GET_LAST(buf_pool->LRU); block = UT_LIST_GET_LAST(buf_pool->LRU);
while ((block != NULL) while ((block != NULL)
&& (n_replaceable < BUF_FLUSH_FREE_BLOCK_MARGIN && (n_replaceable < BUF_FLUSH_FREE_BLOCK_MARGIN
+ BUF_FLUSH_EXTRA_MARGIN) + BUF_FLUSH_EXTRA_MARGIN)
&& (distance < BUF_LRU_FREE_SEARCH_LEN)) { && (distance < BUF_LRU_FREE_SEARCH_LEN)) {
if (buf_flush_ready_for_replace(block)) { if (buf_flush_ready_for_replace(block)) {
n_replaceable++; n_replaceable++;
@ -984,7 +1003,7 @@ buf_flush_LRU_recommendation(void)
} }
return(BUF_FLUSH_FREE_BLOCK_MARGIN + BUF_FLUSH_EXTRA_MARGIN return(BUF_FLUSH_FREE_BLOCK_MARGIN + BUF_FLUSH_EXTRA_MARGIN
- n_replaceable); - n_replaceable);
} }
/************************************************************************* /*************************************************************************
@ -1005,7 +1024,7 @@ buf_flush_free_margin(void)
if (n_to_flush > 0) { if (n_to_flush > 0) {
n_flushed = buf_flush_batch(BUF_FLUSH_LRU, n_to_flush, n_flushed = buf_flush_batch(BUF_FLUSH_LRU, n_to_flush,
ut_dulint_zero); ut_dulint_zero);
if (n_flushed == ULINT_UNDEFINED) { if (n_flushed == ULINT_UNDEFINED) {
/* There was an LRU type flush batch already running; /* There was an LRU type flush batch already running;
let us wait for it to end */ let us wait for it to end */
@ -1039,7 +1058,7 @@ buf_flush_validate_low(void)
if (block) { if (block) {
ut_a(ut_dulint_cmp(om, block->oldest_modification) ut_a(ut_dulint_cmp(om, block->oldest_modification)
>= 0); >= 0);
} }
} }

View File

@ -89,7 +89,7 @@ scan_again:
ut_a(block->state == BUF_BLOCK_FILE_PAGE); ut_a(block->state == BUF_BLOCK_FILE_PAGE);
if (block->space == id if (block->space == id
&& (block->buf_fix_count > 0 || block->io_fix != 0)) { && (block->buf_fix_count > 0 || block->io_fix != 0)) {
/* We cannot remove this page during this scan yet; /* We cannot remove this page during this scan yet;
maybe the system is currently reading it in, or maybe the system is currently reading it in, or
@ -103,8 +103,8 @@ scan_again:
if (block->space == id) { if (block->space == id) {
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (buf_debug_prints) { if (buf_debug_prints) {
printf( fprintf(stderr,
"Dropping space %lu page %lu\n", "Dropping space %lu page %lu\n",
(ulong) block->space, (ulong) block->space,
(ulong) block->offset); (ulong) block->offset);
} }
@ -118,19 +118,19 @@ scan_again:
an S-latch on the page */ an S-latch on the page */
btr_search_drop_page_hash_when_freed(id, btr_search_drop_page_hash_when_freed(id,
page_no); page_no);
goto scan_again; goto scan_again;
} }
if (0 != ut_dulint_cmp(block->oldest_modification, if (0 != ut_dulint_cmp(block->oldest_modification,
ut_dulint_zero)) { ut_dulint_zero)) {
/* Remove from the flush list of modified /* Remove from the flush list of modified
blocks */ blocks */
block->oldest_modification = ut_dulint_zero; block->oldest_modification = ut_dulint_zero;
UT_LIST_REMOVE(flush_list, UT_LIST_REMOVE(flush_list,
buf_pool->flush_list, block); buf_pool->flush_list, block);
} }
/* Remove from the LRU list */ /* Remove from the LRU list */
@ -216,7 +216,8 @@ buf_LRU_search_and_free_block(
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (buf_debug_prints) { if (buf_debug_prints) {
fprintf(stderr, fprintf(stderr,
"Putting space %lu page %lu to free list\n", "Putting space %lu page %lu"
" to free list\n",
(ulong) block->space, (ulong) block->space,
(ulong) block->offset); (ulong) block->offset);
} }
@ -246,8 +247,8 @@ buf_LRU_search_and_free_block(
distance++; distance++;
if (!freed && n_iterations <= 10 if (!freed && n_iterations <= 10
&& distance > 100 + (n_iterations * buf_pool->curr_size) && distance > 100 + (n_iterations * buf_pool->curr_size)
/ 10) { / 10) {
buf_pool->LRU_flush_ended = 0; buf_pool->LRU_flush_ended = 0;
mutex_exit(&(buf_pool->mutex)); mutex_exit(&(buf_pool->mutex));
@ -309,7 +310,7 @@ buf_LRU_buf_pool_running_out(void)
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free) if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
+ UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 4) { + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 4) {
ret = TRUE; ret = TRUE;
} }
@ -340,23 +341,28 @@ loop:
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free) if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
+ UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 20) { + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 20) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: ERROR: over 95 percent of the buffer pool is occupied by\n" " InnoDB: ERROR: over 95 percent of the buffer pool"
"InnoDB: lock heaps or the adaptive hash index! Check that your\n" " is occupied by\n"
"InnoDB: transactions do not set too many row locks.\n" "InnoDB: lock heaps or the adaptive hash index!"
"InnoDB: Your buffer pool size is %lu MB. Maybe you should make\n" " Check that your\n"
"InnoDB: the buffer pool bigger?\n" "InnoDB: transactions do not set too many row locks.\n"
"InnoDB: We intentionally generate a seg fault to print a stack trace\n" "InnoDB: Your buffer pool size is %lu MB."
"InnoDB: on Linux!\n", " Maybe you should make\n"
(ulong)(buf_pool->curr_size / (1024 * 1024 / UNIV_PAGE_SIZE))); "InnoDB: the buffer pool bigger?\n"
"InnoDB: We intentionally generate a seg fault"
" to print a stack trace\n"
"InnoDB: on Linux!\n",
(ulong) (buf_pool->curr_size
/ (1024 * 1024 / UNIV_PAGE_SIZE)));
ut_error; ut_error;
} else if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free) } else if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
+ UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 3) { + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 3) {
if (!buf_lru_switched_on_innodb_mon) { if (!buf_lru_switched_on_innodb_mon) {
@ -366,14 +372,20 @@ loop:
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: WARNING: over 67 percent of the buffer pool is occupied by\n" " InnoDB: WARNING: over 67 percent of"
"InnoDB: lock heaps or the adaptive hash index! Check that your\n" " the buffer pool is occupied by\n"
"InnoDB: transactions do not set too many row locks.\n" "InnoDB: lock heaps or the adaptive"
"InnoDB: Your buffer pool size is %lu MB. Maybe you should make\n" " hash index! Check that your\n"
"InnoDB: the buffer pool bigger?\n" "InnoDB: transactions do not set too many"
"InnoDB: Starting the InnoDB Monitor to print diagnostics, including\n" " row locks.\n"
"InnoDB: lock heap and hash index sizes.\n", "InnoDB: Your buffer pool size is %lu MB."
(ulong) (buf_pool->curr_size / (1024 * 1024 / UNIV_PAGE_SIZE))); " Maybe you should make\n"
"InnoDB: the buffer pool bigger?\n"
"InnoDB: Starting the InnoDB Monitor to print"
" diagnostics, including\n"
"InnoDB: lock heap and hash index sizes.\n",
(ulong) (buf_pool->curr_size
/ (1024 * 1024 / UNIV_PAGE_SIZE)));
buf_lru_switched_on_innodb_mon = TRUE; buf_lru_switched_on_innodb_mon = TRUE;
srv_print_innodb_monitor = TRUE; srv_print_innodb_monitor = TRUE;
@ -405,7 +417,8 @@ loop:
/* Remove from the list of mapped pages */ /* Remove from the list of mapped pages */
UT_LIST_REMOVE(awe_LRU_free_mapped, UT_LIST_REMOVE(awe_LRU_free_mapped,
buf_pool->awe_LRU_free_mapped, block); buf_pool->awe_LRU_free_mapped,
block);
} else { } else {
/* We map the page to a frame; second param /* We map the page to a frame; second param
FALSE below because we do not want it to be FALSE below because we do not want it to be
@ -440,18 +453,25 @@ loop:
if (n_iterations > 30) { if (n_iterations > 30) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
"InnoDB: Warning: difficult to find free blocks from\n" "InnoDB: Warning: difficult to find free blocks from\n"
"InnoDB: the buffer pool (%lu search iterations)! Consider\n" "InnoDB: the buffer pool (%lu search iterations)!"
"InnoDB: increasing the buffer pool size.\n" " Consider\n"
"InnoDB: It is also possible that in your Unix version\n" "InnoDB: increasing the buffer pool size.\n"
"InnoDB: fsync is very slow, or completely frozen inside\n" "InnoDB: It is also possible that"
"InnoDB: the OS kernel. Then upgrading to a newer version\n" " in your Unix version\n"
"InnoDB: of your operating system may help. Look at the\n" "InnoDB: fsync is very slow, or"
"InnoDB: number of fsyncs in diagnostic info below.\n" " completely frozen inside\n"
"InnoDB: Pending flushes (fsync) log: %lu; buffer pool: %lu\n" "InnoDB: the OS kernel. Then upgrading to"
"InnoDB: %lu OS file reads, %lu OS file writes, %lu OS fsyncs\n" " a newer version\n"
"InnoDB: Starting InnoDB Monitor to print further\n" "InnoDB: of your operating system may help."
"InnoDB: diagnostics to the standard output.\n", " Look at the\n"
"InnoDB: number of fsyncs in diagnostic info below.\n"
"InnoDB: Pending flushes (fsync) log: %lu;"
" buffer pool: %lu\n"
"InnoDB: %lu OS file reads, %lu OS file writes,"
" %lu OS fsyncs\n"
"InnoDB: Starting InnoDB Monitor to print further\n"
"InnoDB: diagnostics to the standard output.\n",
(ulong) n_iterations, (ulong) n_iterations,
(ulong) fil_n_pending_log_flushes, (ulong) fil_n_pending_log_flushes,
(ulong) fil_n_pending_tablespace_flushes, (ulong) fil_n_pending_tablespace_flushes,
@ -522,20 +542,20 @@ buf_LRU_old_adjust_len(void)
if (old_len < new_len - BUF_LRU_OLD_TOLERANCE) { if (old_len < new_len - BUF_LRU_OLD_TOLERANCE) {
buf_pool->LRU_old = UT_LIST_GET_PREV(LRU, buf_pool->LRU_old = UT_LIST_GET_PREV
buf_pool->LRU_old); (LRU, buf_pool->LRU_old);
(buf_pool->LRU_old)->old = TRUE; (buf_pool->LRU_old)->old = TRUE;
buf_pool->LRU_old_len++; buf_pool->LRU_old_len++;
} else if (old_len > new_len + BUF_LRU_OLD_TOLERANCE) { } else if (old_len > new_len + BUF_LRU_OLD_TOLERANCE) {
(buf_pool->LRU_old)->old = FALSE; (buf_pool->LRU_old)->old = FALSE;
buf_pool->LRU_old = UT_LIST_GET_NEXT(LRU, buf_pool->LRU_old = UT_LIST_GET_NEXT
buf_pool->LRU_old); (LRU, buf_pool->LRU_old);
buf_pool->LRU_old_len--; buf_pool->LRU_old_len--;
} else { } else {
ut_a(buf_pool->LRU_old); /* Check that we did not ut_a(buf_pool->LRU_old); /* Check that we did not
fall out of the LRU list */ fall out of the LRU list */
return; return;
} }
} }
@ -613,7 +633,7 @@ buf_LRU_remove_block(
/* Remove from the list of mapped pages */ /* Remove from the list of mapped pages */
UT_LIST_REMOVE(awe_LRU_free_mapped, UT_LIST_REMOVE(awe_LRU_free_mapped,
buf_pool->awe_LRU_free_mapped, block); buf_pool->awe_LRU_free_mapped, block);
} }
/* If the LRU list is so short that LRU_old not defined, return */ /* If the LRU list is so short that LRU_old not defined, return */
@ -672,7 +692,7 @@ buf_LRU_add_block_to_end_low(
/* Add to the list of mapped pages */ /* Add to the list of mapped pages */
UT_LIST_ADD_LAST(awe_LRU_free_mapped, UT_LIST_ADD_LAST(awe_LRU_free_mapped,
buf_pool->awe_LRU_free_mapped, block); buf_pool->awe_LRU_free_mapped, block);
} }
if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) { if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) {
@ -729,7 +749,7 @@ buf_LRU_add_block_low(
TRUE */ TRUE */
UT_LIST_ADD_FIRST(awe_LRU_free_mapped, UT_LIST_ADD_FIRST(awe_LRU_free_mapped,
buf_pool->awe_LRU_free_mapped, block); buf_pool->awe_LRU_free_mapped, block);
} }
if (!old || (UT_LIST_GET_LEN(buf_pool->LRU) < BUF_LRU_OLD_MIN_LEN)) { if (!old || (UT_LIST_GET_LEN(buf_pool->LRU) < BUF_LRU_OLD_MIN_LEN)) {
@ -740,7 +760,7 @@ buf_LRU_add_block_low(
block->freed_page_clock = buf_pool->freed_page_clock; block->freed_page_clock = buf_pool->freed_page_clock;
} else { } else {
UT_LIST_INSERT_AFTER(LRU, buf_pool->LRU, buf_pool->LRU_old, UT_LIST_INSERT_AFTER(LRU, buf_pool->LRU, buf_pool->LRU_old,
block); block);
buf_pool->LRU_old_len++; buf_pool->LRU_old_len++;
/* We copy the LRU position field of the previous block /* We copy the LRU position field of the previous block
@ -822,7 +842,7 @@ buf_LRU_block_free_non_file_page(
ut_ad(block); ut_ad(block);
ut_a((block->state == BUF_BLOCK_MEMORY) ut_a((block->state == BUF_BLOCK_MEMORY)
|| (block->state == BUF_BLOCK_READY_FOR_USE)); || (block->state == BUF_BLOCK_READY_FOR_USE));
ut_a(block->n_pointers == 0); ut_a(block->n_pointers == 0);
ut_a(!block->in_free_list); ut_a(!block->in_free_list);
@ -840,7 +860,7 @@ buf_LRU_block_free_non_file_page(
/* Add to the list of mapped pages */ /* Add to the list of mapped pages */
UT_LIST_ADD_FIRST(awe_LRU_free_mapped, UT_LIST_ADD_FIRST(awe_LRU_free_mapped,
buf_pool->awe_LRU_free_mapped, block); buf_pool->awe_LRU_free_mapped, block);
} }
} }
@ -875,16 +895,21 @@ buf_LRU_block_remove_hashed_page(
if (block != buf_page_hash_get(block->space, block->offset)) { if (block != buf_page_hash_get(block->space, block->offset)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: page %lu %lu not found from the hash table\n", "InnoDB: Error: page %lu %lu not found"
" in the hash table\n",
(ulong) block->space, (ulong) block->space,
(ulong) block->offset); (ulong) block->offset);
if (buf_page_hash_get(block->space, block->offset)) { if (buf_page_hash_get(block->space, block->offset)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: From hash table we find block %p of %lu %lu which is not %p\n", "InnoDB: In hash table we find block"
(void*) buf_page_hash_get(block->space, block->offset), " %p of %lu %lu which is not %p\n",
(ulong) buf_page_hash_get(block->space, block->offset)->space, (void*) buf_page_hash_get
(ulong) buf_page_hash_get(block->space, block->offset)->offset, (block->space, block->offset),
(void*) block); (ulong) buf_page_hash_get
(block->space, block->offset)->space,
(ulong) buf_page_hash_get
(block->space, block->offset)->offset,
(void*) block);
} }
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
@ -897,8 +922,8 @@ buf_LRU_block_remove_hashed_page(
} }
HASH_DELETE(buf_block_t, hash, buf_pool->page_hash, HASH_DELETE(buf_block_t, hash, buf_pool->page_hash,
buf_page_address_fold(block->space, block->offset), buf_page_address_fold(block->space, block->offset),
block); block);
block->state = BUF_BLOCK_REMOVE_HASH; block->state = BUF_BLOCK_REMOVE_HASH;
} }
@ -1009,7 +1034,8 @@ buf_LRU_print(void)
ut_ad(buf_pool); ut_ad(buf_pool);
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
fprintf(stderr, "Pool ulint clock %lu\n", (ulong) buf_pool->ulint_clock); fprintf(stderr, "Pool ulint clock %lu\n",
(ulong) buf_pool->ulint_clock);
block = UT_LIST_GET_FIRST(buf_pool->LRU); block = UT_LIST_GET_FIRST(buf_pool->LRU);
@ -1033,7 +1059,7 @@ buf_LRU_print(void)
} }
if (ut_dulint_cmp(block->oldest_modification, if (ut_dulint_cmp(block->oldest_modification,
ut_dulint_zero) > 0) { ut_dulint_zero) > 0) {
fputs("modif. ", stderr); fputs("modif. ", stderr);
} }
@ -1042,7 +1068,8 @@ buf_LRU_print(void)
fprintf(stderr, "LRU pos %lu type %lu index id %lu ", fprintf(stderr, "LRU pos %lu type %lu index id %lu ",
(ulong) block->LRU_position, (ulong) block->LRU_position,
(ulong) fil_page_get_type(frame), (ulong) fil_page_get_type(frame),
(ulong) ut_dulint_get_low(btr_page_get_index_id(frame))); (ulong) ut_dulint_get_low
(btr_page_get_index_id(frame)));
block = UT_LIST_GET_NEXT(LRU, block); block = UT_LIST_GET_NEXT(LRU, block);
if (++len == 10) { if (++len == 10) {

View File

@ -81,32 +81,21 @@ buf_read_page_low(
mode = mode & ~OS_AIO_SIMULATED_WAKE_LATER; mode = mode & ~OS_AIO_SIMULATED_WAKE_LATER;
if (trx_doublewrite && space == TRX_SYS_SPACE if (trx_doublewrite && space == TRX_SYS_SPACE
&& ( (offset >= trx_doublewrite->block1 && ( (offset >= trx_doublewrite->block1
&& offset < trx_doublewrite->block1 && offset < trx_doublewrite->block1
+ TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE)
|| (offset >= trx_doublewrite->block2 || (offset >= trx_doublewrite->block2
&& offset < trx_doublewrite->block2 && offset < trx_doublewrite->block2
+ TRX_SYS_DOUBLEWRITE_BLOCK_SIZE))) { + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE))) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Warning: trying to read doublewrite buffer page %lu\n", " InnoDB: Warning: trying to read"
" doublewrite buffer page %lu\n",
(ulong) offset); (ulong) offset);
return(0); return(0);
} }
#ifdef UNIV_LOG_DEBUG
if (space % 2 == 1) {
/* We are updating a replicate space while holding the
log mutex: the read must be handled before other reads
which might incur ibuf operations and thus write to the log */
fputs("Log debug: reading replicate page in sync mode\n",
stderr);
sync = TRUE;
}
#endif
if (ibuf_bitmap_page(offset) || trx_sys_hdr_page(space, offset)) { if (ibuf_bitmap_page(offset) || trx_sys_hdr_page(space, offset)) {
/* Trx sys header is so low in the latching order that we play /* Trx sys header is so low in the latching order that we play
@ -123,7 +112,7 @@ buf_read_page_low(
pool for read, then DISCARD cannot proceed until the read has pool for read, then DISCARD cannot proceed until the read has
completed */ completed */
block = buf_page_init_for_read(err, mode, space, tablespace_version, block = buf_page_init_for_read(err, mode, space, tablespace_version,
offset); offset);
if (block == NULL) { if (block == NULL) {
return(0); return(0);
@ -133,17 +122,17 @@ buf_read_page_low(
if (buf_debug_prints) { if (buf_debug_prints) {
fprintf(stderr, fprintf(stderr,
"Posting read request for page %lu, sync %lu\n", "Posting read request for page %lu, sync %lu\n",
(ulong) offset, (ulong) offset,
(ulong) sync); (ulong) sync);
} }
#endif #endif
ut_a(block->state == BUF_BLOCK_FILE_PAGE); ut_a(block->state == BUF_BLOCK_FILE_PAGE);
*err = fil_io(OS_FILE_READ | wake_later, *err = fil_io(OS_FILE_READ | wake_later,
sync, space, sync, space,
offset, 0, UNIV_PAGE_SIZE, offset, 0, UNIV_PAGE_SIZE,
(void*)block->frame, (void*)block); (void*)block->frame, (void*)block);
ut_a(*err == DB_SUCCESS); ut_a(*err == DB_SUCCESS);
if (sync) { if (sync) {
@ -208,9 +197,9 @@ buf_read_ahead_random(
tablespace_version = fil_space_get_version(space); tablespace_version = fil_space_get_version(space);
low = (offset / BUF_READ_AHEAD_RANDOM_AREA) low = (offset / BUF_READ_AHEAD_RANDOM_AREA)
* BUF_READ_AHEAD_RANDOM_AREA; * BUF_READ_AHEAD_RANDOM_AREA;
high = (offset / BUF_READ_AHEAD_RANDOM_AREA + 1) high = (offset / BUF_READ_AHEAD_RANDOM_AREA + 1)
* BUF_READ_AHEAD_RANDOM_AREA; * BUF_READ_AHEAD_RANDOM_AREA;
if (high > fil_space_get_size(space)) { if (high > fil_space_get_size(space)) {
high = fil_space_get_size(space); high = fil_space_get_size(space);
@ -224,8 +213,8 @@ buf_read_ahead_random(
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
if (buf_pool->n_pend_reads > if (buf_pool->n_pend_reads
buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) {
mutex_exit(&(buf_pool->mutex)); mutex_exit(&(buf_pool->mutex));
return(0); return(0);
@ -238,8 +227,8 @@ buf_read_ahead_random(
block = buf_page_hash_get(space, i); block = buf_page_hash_get(space, i);
if ((block) if ((block)
&& (block->LRU_position > LRU_recent_limit) && (block->LRU_position > LRU_recent_limit)
&& block->accessed) { && block->accessed) {
recent_blocks++; recent_blocks++;
} }
@ -268,15 +257,18 @@ buf_read_ahead_random(
mode: hence FALSE as the first parameter */ mode: hence FALSE as the first parameter */
if (!ibuf_bitmap_page(i)) { if (!ibuf_bitmap_page(i)) {
count += buf_read_page_low(&err, FALSE, ibuf_mode count += buf_read_page_low
| OS_AIO_SIMULATED_WAKE_LATER, (&err, FALSE,
space, tablespace_version, i); ibuf_mode | OS_AIO_SIMULATED_WAKE_LATER,
space, tablespace_version, i);
if (err == DB_TABLESPACE_DELETED) { if (err == DB_TABLESPACE_DELETED) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Warning: in random readahead trying to access tablespace\n" " InnoDB: Warning: in random"
"InnoDB: %lu page no. %lu,\n" " readahead trying to access\n"
"InnoDB: but the tablespace does not exist or is just being dropped.\n", "InnoDB: tablespace %lu page %lu,\n"
"InnoDB: but the tablespace does not"
" exist or is just being dropped.\n",
(ulong) space, (ulong) i); (ulong) space, (ulong) i);
} }
} }
@ -292,8 +284,8 @@ buf_read_ahead_random(
if (buf_debug_prints && (count > 0)) { if (buf_debug_prints && (count > 0)) {
fprintf(stderr, fprintf(stderr,
"Random read-ahead space %lu offset %lu pages %lu\n", "Random read-ahead space %lu offset %lu pages %lu\n",
(ulong) space, (ulong) offset, (ulong) space, (ulong) offset,
(ulong) count); (ulong) count);
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
@ -329,14 +321,16 @@ buf_read_page(
switches: hence TRUE */ switches: hence TRUE */
count2 = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space, count2 = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
tablespace_version, offset); tablespace_version, offset);
srv_buf_pool_reads+= count2; srv_buf_pool_reads+= count2;
if (err == DB_TABLESPACE_DELETED) { if (err == DB_TABLESPACE_DELETED) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Error: trying to access tablespace %lu page no. %lu,\n" " InnoDB: Error: trying to access"
"InnoDB: but the tablespace does not exist or is just being dropped.\n", " tablespace %lu page no. %lu,\n"
(ulong) space, (ulong) offset); "InnoDB: but the tablespace does not exist"
" or is just being dropped.\n",
(ulong) space, (ulong) offset);
} }
/* Flush pages from the end of the LRU list if necessary */ /* Flush pages from the end of the LRU list if necessary */
@ -407,9 +401,9 @@ buf_read_ahead_linear(
} }
low = (offset / BUF_READ_AHEAD_LINEAR_AREA) low = (offset / BUF_READ_AHEAD_LINEAR_AREA)
* BUF_READ_AHEAD_LINEAR_AREA; * BUF_READ_AHEAD_LINEAR_AREA;
high = (offset / BUF_READ_AHEAD_LINEAR_AREA + 1) high = (offset / BUF_READ_AHEAD_LINEAR_AREA + 1)
* BUF_READ_AHEAD_LINEAR_AREA; * BUF_READ_AHEAD_LINEAR_AREA;
if ((offset != low) && (offset != high - 1)) { if ((offset != low) && (offset != high - 1)) {
/* This is not a border page of the area: return */ /* This is not a border page of the area: return */
@ -432,8 +426,8 @@ buf_read_ahead_linear(
return(0); return(0);
} }
if (buf_pool->n_pend_reads > if (buf_pool->n_pend_reads
buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) {
mutex_exit(&(buf_pool->mutex)); mutex_exit(&(buf_pool->mutex));
return(0); return(0);
@ -459,9 +453,9 @@ buf_read_ahead_linear(
fail_count++; fail_count++;
} else if (pred_block } else if (pred_block
&& (ut_ulint_cmp(block->LRU_position, && (ut_ulint_cmp(block->LRU_position,
pred_block->LRU_position) pred_block->LRU_position)
!= asc_or_desc)) { != asc_or_desc)) {
/* Accesses not in the right order */ /* Accesses not in the right order */
fail_count++; fail_count++;
@ -469,8 +463,8 @@ buf_read_ahead_linear(
} }
} }
if (fail_count > BUF_READ_AHEAD_LINEAR_AREA - if (fail_count > BUF_READ_AHEAD_LINEAR_AREA
BUF_READ_AHEAD_LINEAR_THRESHOLD) { - BUF_READ_AHEAD_LINEAR_THRESHOLD) {
/* Too many failures: return */ /* Too many failures: return */
mutex_exit(&(buf_pool->mutex)); mutex_exit(&(buf_pool->mutex));
@ -518,9 +512,9 @@ buf_read_ahead_linear(
} }
low = (new_offset / BUF_READ_AHEAD_LINEAR_AREA) low = (new_offset / BUF_READ_AHEAD_LINEAR_AREA)
* BUF_READ_AHEAD_LINEAR_AREA; * BUF_READ_AHEAD_LINEAR_AREA;
high = (new_offset / BUF_READ_AHEAD_LINEAR_AREA + 1) high = (new_offset / BUF_READ_AHEAD_LINEAR_AREA + 1)
* BUF_READ_AHEAD_LINEAR_AREA; * BUF_READ_AHEAD_LINEAR_AREA;
if ((new_offset != low) && (new_offset != high - 1)) { if ((new_offset != low) && (new_offset != high - 1)) {
/* This is not a border page of the area: return */ /* This is not a border page of the area: return */
@ -555,16 +549,19 @@ buf_read_ahead_linear(
aio mode: hence FALSE as the first parameter */ aio mode: hence FALSE as the first parameter */
if (!ibuf_bitmap_page(i)) { if (!ibuf_bitmap_page(i)) {
count += buf_read_page_low(&err, FALSE, ibuf_mode count += buf_read_page_low
| OS_AIO_SIMULATED_WAKE_LATER, (&err, FALSE,
space, tablespace_version, i); ibuf_mode | OS_AIO_SIMULATED_WAKE_LATER,
space, tablespace_version, i);
if (err == DB_TABLESPACE_DELETED) { if (err == DB_TABLESPACE_DELETED) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Warning: in linear readahead trying to access tablespace\n" " InnoDB: Warning: in"
"InnoDB: %lu page no. %lu,\n" " linear readahead trying to access\n"
"InnoDB: but the tablespace does not exist or is just being dropped.\n", "InnoDB: tablespace %lu page %lu,\n"
(ulong) space, (ulong) i); "InnoDB: but the tablespace does not"
" exist or is just being dropped.\n",
(ulong) space, (ulong) i);
} }
} }
} }
@ -581,8 +578,8 @@ buf_read_ahead_linear(
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (buf_debug_prints && (count > 0)) { if (buf_debug_prints && (count > 0)) {
fprintf(stderr, fprintf(stderr,
"LINEAR read-ahead space %lu offset %lu pages %lu\n", "LINEAR read-ahead space %lu offset %lu pages %lu\n",
(ulong) space, (ulong) offset, (ulong) count); (ulong) space, (ulong) offset, (ulong) count);
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
@ -618,26 +615,24 @@ buf_read_ibuf_merge_pages(
#ifdef UNIV_IBUF_DEBUG #ifdef UNIV_IBUF_DEBUG
ut_a(n_stored < UNIV_PAGE_SIZE); ut_a(n_stored < UNIV_PAGE_SIZE);
#endif #endif
while (buf_pool->n_pend_reads > while (buf_pool->n_pend_reads
buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) {
os_thread_sleep(500000); os_thread_sleep(500000);
} }
for (i = 0; i < n_stored; i++) { for (i = 0; i < n_stored; i++) {
if ((i + 1 == n_stored) && sync) { buf_read_page_low(&err,
buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, (i + 1 == n_stored) && sync,
space_ids[i], space_versions[i], page_nos[i]); BUF_READ_ANY_PAGE,
} else { space_ids[i], space_versions[i],
buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE, page_nos[i]);
space_ids[i], space_versions[i], page_nos[i]);
}
if (err == DB_TABLESPACE_DELETED) { if (err == DB_TABLESPACE_DELETED) {
/* We have deleted or are deleting the single-table /* We have deleted or are deleting the single-table
tablespace: remove the entries for that page */ tablespace: remove the entries for that page */
ibuf_merge_or_delete_for_page(NULL, space_ids[i], ibuf_merge_or_delete_for_page(NULL, space_ids[i],
page_nos[i], FALSE); page_nos[i], FALSE);
} }
} }
@ -650,7 +645,7 @@ buf_read_ibuf_merge_pages(
if (buf_debug_prints) { if (buf_debug_prints) {
fprintf(stderr, fprintf(stderr,
"Ibuf merge read-ahead space %lu pages %lu\n", "Ibuf merge read-ahead space %lu pages %lu\n",
(ulong) space_ids[0], (ulong) n_stored); (ulong) space_ids[0], (ulong) n_stored);
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
} }
@ -691,11 +686,14 @@ buf_read_recv_pages(
if (count > 100) { if (count > 100) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: InnoDB has waited for 50 seconds for pending\n" "InnoDB: Error: InnoDB has waited for"
"InnoDB: reads to the buffer pool to be finished.\n" " 50 seconds for pending\n"
"InnoDB: Number of pending reads %lu, pending pread calls %lu\n", "InnoDB: reads to the buffer pool to"
(ulong) buf_pool->n_pend_reads, " be finished.\n"
(ulong)os_file_n_pending_preads); "InnoDB: Number of pending reads %lu,"
" pending pread calls %lu\n",
(ulong) buf_pool->n_pend_reads,
(ulong)os_file_n_pending_preads);
os_aio_print_debug = TRUE; os_aio_print_debug = TRUE;
} }
@ -704,12 +702,14 @@ buf_read_recv_pages(
os_aio_print_debug = FALSE; os_aio_print_debug = FALSE;
if ((i + 1 == n_stored) && sync) { if ((i + 1 == n_stored) && sync) {
buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space, buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE,
tablespace_version, page_nos[i]); space, tablespace_version,
page_nos[i]);
} else { } else {
buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE
| OS_AIO_SIMULATED_WAKE_LATER, | OS_AIO_SIMULATED_WAKE_LATER,
space, tablespace_version, page_nos[i]); space, tablespace_version,
page_nos[i]);
} }
} }
@ -721,7 +721,8 @@ buf_read_recv_pages(
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (buf_debug_prints) { if (buf_debug_prints) {
fprintf(stderr, fprintf(stderr,
"Recovery applies read-ahead pages %lu\n", (ulong) n_stored); "Recovery applies read-ahead pages %lu\n",
(ulong) n_stored);
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
} }

View File

@ -189,10 +189,10 @@ dfield_check_typed_no_assert(
dfield_t* field) /* in: data field */ dfield_t* field) /* in: data field */
{ {
if (dfield_get_type(field)->mtype > DATA_MYSQL if (dfield_get_type(field)->mtype > DATA_MYSQL
|| dfield_get_type(field)->mtype < DATA_VARCHAR) { || dfield_get_type(field)->mtype < DATA_VARCHAR) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: data field type %lu, len %lu\n", "InnoDB: Error: data field type %lu, len %lu\n",
(ulong) dfield_get_type(field)->mtype, (ulong) dfield_get_type(field)->mtype,
(ulong) dfield_get_len(field)); (ulong) dfield_get_len(field));
return(FALSE); return(FALSE);
@ -215,9 +215,9 @@ dtuple_check_typed_no_assert(
if (dtuple_get_n_fields(tuple) > REC_MAX_N_FIELDS) { if (dtuple_get_n_fields(tuple) > REC_MAX_N_FIELDS) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: index entry has %lu fields\n", "InnoDB: Error: index entry has %lu fields\n",
(ulong) dtuple_get_n_fields(tuple)); (ulong) dtuple_get_n_fields(tuple));
dump: dump:
fputs("InnoDB: Tuple contents: ", stderr); fputs("InnoDB: Tuple contents: ", stderr);
dtuple_print(stderr, tuple); dtuple_print(stderr, tuple);
putc('\n', stderr); putc('\n', stderr);
@ -247,10 +247,10 @@ dfield_check_typed(
dfield_t* field) /* in: data field */ dfield_t* field) /* in: data field */
{ {
if (dfield_get_type(field)->mtype > DATA_MYSQL if (dfield_get_type(field)->mtype > DATA_MYSQL
|| dfield_get_type(field)->mtype < DATA_VARCHAR) { || dfield_get_type(field)->mtype < DATA_VARCHAR) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: data field type %lu, len %lu\n", "InnoDB: Error: data field type %lu, len %lu\n",
(ulong) dfield_get_type(field)->mtype, (ulong) dfield_get_type(field)->mtype,
(ulong) dfield_get_len(field)); (ulong) dfield_get_len(field));
@ -319,8 +319,8 @@ dtuple_validate(
for (j = 0; j < len; j++) { for (j = 0; j < len; j++) {
data_dummy += *data; /* fool the compiler not data_dummy += *data; /* fool the compiler not
to optimize out this to optimize out this
code */ code */
data++; data++;
} }
} }
@ -433,15 +433,20 @@ dfield_print_also_hex(
/***************************************************************** /*****************************************************************
Print a dfield value using ut_print_buf. */ Print a dfield value using ut_print_buf. */
static
void void
dfield_print_raw( dfield_print_raw(
/*=============*/ /*=============*/
FILE* f, /* in: output stream */ FILE* f, /* in: output stream */
dfield_t* dfield) /* in: dfield */ dfield_t* dfield) /* in: dfield */
{ {
if (dfield->len != UNIV_SQL_NULL) { ulint len = dfield->len;
ut_print_buf(f, dfield->data, dfield->len); if (len != UNIV_SQL_NULL) {
ulint print_len = ut_min(len, 1000);
ut_print_buf(f, dfield->data, print_len);
if (len != print_len) {
fprintf(f, "(total %lu bytes)", (ulong) len);
}
} else { } else {
fputs(" SQL NULL", f); fputs(" SQL NULL", f);
} }
@ -513,14 +518,15 @@ dtuple_convert_big_rec(
if (UNIV_UNLIKELY(size > 1000000000)) { if (UNIV_UNLIKELY(size > 1000000000)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Warning: tuple size very big: %lu\n", (ulong) size); "InnoDB: Warning: tuple size very big: %lu\n",
(ulong) size);
fputs("InnoDB: Tuple contents: ", stderr); fputs("InnoDB: Tuple contents: ", stderr);
dtuple_print(stderr, entry); dtuple_print(stderr, entry);
putc('\n', stderr); putc('\n', stderr);
} }
heap = mem_heap_create(size + dtuple_get_n_fields(entry) heap = mem_heap_create(size + dtuple_get_n_fields(entry)
* sizeof(big_rec_field_t) + 1000); * sizeof(big_rec_field_t) + 1000);
vector = mem_heap_alloc(heap, sizeof(big_rec_t)); vector = mem_heap_alloc(heap, sizeof(big_rec_t));
@ -534,13 +540,13 @@ dtuple_convert_big_rec(
n_fields = 0; n_fields = 0;
while (rec_get_converted_size(index, entry) while (rec_get_converted_size(index, entry)
>= ut_min(page_get_free_space_of_empty( >= ut_min(page_get_free_space_of_empty
dict_table_is_comp(index->table)) / 2, (dict_table_is_comp(index->table)) / 2,
REC_MAX_DATA_SIZE)) { REC_MAX_DATA_SIZE)) {
longest = 0; longest = 0;
for (i = dict_index_get_n_unique_in_tree(index); for (i = dict_index_get_n_unique_in_tree(index);
i < dtuple_get_n_fields(entry); i++) { i < dtuple_get_n_fields(entry); i++) {
/* Skip over fields which already are externally /* Skip over fields which already are externally
stored */ stored */
@ -559,8 +565,8 @@ dtuple_convert_big_rec(
dfield = dtuple_get_nth_field(entry, i); dfield = dtuple_get_nth_field(entry, i);
if (dfield->len != UNIV_SQL_NULL && if (dfield->len != UNIV_SQL_NULL
dfield->len > longest) { && dfield->len > longest) {
longest = dfield->len; longest = dfield->len;
@ -577,7 +583,7 @@ dtuple_convert_big_rec(
#endif #endif
if (longest < BTR_EXTERN_FIELD_REF_SIZE + 10 if (longest < BTR_EXTERN_FIELD_REF_SIZE + 10
+ DICT_MAX_INDEX_COL_LEN) { + DICT_MAX_INDEX_COL_LEN) {
/* Cannot shorten more */ /* Cannot shorten more */
mem_heap_free(heap); mem_heap_free(heap);
@ -602,24 +608,24 @@ dtuple_convert_big_rec(
ut_a(dfield->len > DICT_MAX_INDEX_COL_LEN); ut_a(dfield->len > DICT_MAX_INDEX_COL_LEN);
vector->fields[n_fields].len = dfield->len vector->fields[n_fields].len = dfield->len
- DICT_MAX_INDEX_COL_LEN; - DICT_MAX_INDEX_COL_LEN;
vector->fields[n_fields].data = mem_heap_alloc(heap, vector->fields[n_fields].data = mem_heap_alloc
vector->fields[n_fields].len); (heap, vector->fields[n_fields].len);
/* Copy data (from the end of field) to big rec vector */ /* Copy data (from the end of field) to big rec vector */
ut_memcpy(vector->fields[n_fields].data, ut_memcpy(vector->fields[n_fields].data,
((byte*)dfield->data) + dfield->len ((byte*)dfield->data) + dfield->len
- vector->fields[n_fields].len, - vector->fields[n_fields].len,
vector->fields[n_fields].len); vector->fields[n_fields].len);
dfield->len = dfield->len - vector->fields[n_fields].len dfield->len = dfield->len - vector->fields[n_fields].len
+ BTR_EXTERN_FIELD_REF_SIZE; + BTR_EXTERN_FIELD_REF_SIZE;
/* Set the extern field reference in dfield to zero */ /* Set the extern field reference in dfield to zero */
memset(((byte*)dfield->data) memset(((byte*)dfield->data)
+ dfield->len - BTR_EXTERN_FIELD_REF_SIZE, + dfield->len - BTR_EXTERN_FIELD_REF_SIZE,
0, BTR_EXTERN_FIELD_REF_SIZE); 0, BTR_EXTERN_FIELD_REF_SIZE);
n_fields++; n_fields++;
} }
@ -646,15 +652,15 @@ dtuple_convert_back_big_rec(
for (i = 0; i < vector->n_fields; i++) { for (i = 0; i < vector->n_fields; i++) {
dfield = dtuple_get_nth_field(entry, dfield = dtuple_get_nth_field(entry,
vector->fields[i].field_no); vector->fields[i].field_no);
/* Copy data from big rec vector */ /* Copy data from big rec vector */
ut_memcpy(((byte*)dfield->data) ut_memcpy(((byte*)dfield->data)
+ dfield->len - BTR_EXTERN_FIELD_REF_SIZE, + dfield->len - BTR_EXTERN_FIELD_REF_SIZE,
vector->fields[i].data, vector->fields[i].data,
vector->fields[i].len); vector->fields[i].len);
dfield->len = dfield->len + vector->fields[i].len dfield->len = dfield->len + vector->fields[i].len
- BTR_EXTERN_FIELD_REF_SIZE; - BTR_EXTERN_FIELD_REF_SIZE;
} }
mem_heap_free(vector->heap); mem_heap_free(vector->heap);

View File

@ -67,9 +67,9 @@ dtype_get_at_most_n_mbchars(
if (dtype->mbminlen != dtype->mbmaxlen) { if (dtype->mbminlen != dtype->mbmaxlen) {
ut_a(!(prefix_len % dtype->mbmaxlen)); ut_a(!(prefix_len % dtype->mbmaxlen));
return(innobase_get_at_most_n_mbchars( return(innobase_get_at_most_n_mbchars
dtype_get_charset_coll(dtype->prtype), (dtype_get_charset_coll(dtype->prtype),
prefix_len, data_len, str)); prefix_len, data_len, str));
} }
if (prefix_len < data_len) { if (prefix_len < data_len) {
@ -98,8 +98,8 @@ dtype_is_string_type(
ulint mtype) /* in: InnoDB main data type code: DATA_CHAR, ... */ ulint mtype) /* in: InnoDB main data type code: DATA_CHAR, ... */
{ {
if (mtype <= DATA_BLOB if (mtype <= DATA_BLOB
|| mtype == DATA_MYSQL || mtype == DATA_MYSQL
|| mtype == DATA_VARMYSQL) { || mtype == DATA_VARMYSQL) {
return(TRUE); return(TRUE);
} }
@ -120,8 +120,8 @@ dtype_is_binary_string_type(
ulint prtype) /* in: precise type */ ulint prtype) /* in: precise type */
{ {
if ((mtype == DATA_FIXBINARY) if ((mtype == DATA_FIXBINARY)
|| (mtype == DATA_BINARY) || (mtype == DATA_BINARY)
|| (mtype == DATA_BLOB && (prtype & DATA_BINARY_TYPE))) { || (mtype == DATA_BLOB && (prtype & DATA_BINARY_TYPE))) {
return(TRUE); return(TRUE);
} }
@ -143,7 +143,7 @@ dtype_is_non_binary_string_type(
ulint prtype) /* in: precise type */ ulint prtype) /* in: precise type */
{ {
if (dtype_is_string_type(mtype) == TRUE if (dtype_is_string_type(mtype) == TRUE
&& dtype_is_binary_string_type(mtype, prtype) == FALSE) { && dtype_is_binary_string_type(mtype, prtype) == FALSE) {
return(TRUE); return(TRUE);
} }
@ -258,9 +258,9 @@ dtype_print(
len = type->len; len = type->len;
if ((type->mtype == DATA_SYS) if ((type->mtype == DATA_SYS)
|| (type->mtype == DATA_VARCHAR) || (type->mtype == DATA_VARCHAR)
|| (type->mtype == DATA_CHAR)) { || (type->mtype == DATA_CHAR)) {
putc(' ', stderr); putc(' ', stderr);
if (prtype == DATA_ROW_ID) { if (prtype == DATA_ROW_ID) {
fputs("DATA_ROW_ID", stderr); fputs("DATA_ROW_ID", stderr);
len = DATA_ROW_ID_LEN; len = DATA_ROW_ID_LEN;
@ -317,9 +317,9 @@ dtype_get_max_size(
case DATA_BINARY: case DATA_BINARY:
case DATA_DECIMAL: case DATA_DECIMAL:
case DATA_VARMYSQL: case DATA_VARMYSQL:
return(type->len); return(type->len);
case DATA_BLOB: case DATA_BLOB:
return(ULINT_MAX); return(ULINT_MAX);
default: default:
ut_error; ut_error;
} }

View File

@ -38,7 +38,7 @@ dict_hdr_get(
ut_ad(mtr); ut_ad(mtr);
header = DICT_HDR + buf_page_get(DICT_HDR_SPACE, DICT_HDR_PAGE_NO, header = DICT_HDR + buf_page_get(DICT_HDR_SPACE, DICT_HDR_PAGE_NO,
RW_X_LATCH, mtr); RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(header, SYNC_DICT_HEADER); buf_page_dbg_add_level(header, SYNC_DICT_HEADER);
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
@ -59,7 +59,7 @@ dict_hdr_get_new_id(
mtr_t mtr; mtr_t mtr;
ut_ad((type == DICT_HDR_TABLE_ID) || (type == DICT_HDR_INDEX_ID) ut_ad((type == DICT_HDR_TABLE_ID) || (type == DICT_HDR_INDEX_ID)
|| (type == DICT_HDR_MIX_ID)); || (type == DICT_HDR_MIX_ID));
mtr_start(&mtr); mtr_start(&mtr);
@ -122,7 +122,7 @@ dict_hdr_create(
/* Create the dictionary header file block in a new, allocated file /* Create the dictionary header file block in a new, allocated file
segment in the system tablespace */ segment in the system tablespace */
page = fseg_create(DICT_HDR_SPACE, 0, page = fseg_create(DICT_HDR_SPACE, 0,
DICT_HDR + DICT_HDR_FSEG_HEADER, mtr); DICT_HDR + DICT_HDR_FSEG_HEADER, mtr);
hdr_page_no = buf_frame_get_page_no(page); hdr_page_no = buf_frame_get_page_no(page);
@ -133,70 +133,70 @@ dict_hdr_create(
/* Start counting row, table, index, and tree ids from /* Start counting row, table, index, and tree ids from
DICT_HDR_FIRST_ID */ DICT_HDR_FIRST_ID */
mlog_write_dulint(dict_header + DICT_HDR_ROW_ID, mlog_write_dulint(dict_header + DICT_HDR_ROW_ID,
ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
mlog_write_dulint(dict_header + DICT_HDR_TABLE_ID, mlog_write_dulint(dict_header + DICT_HDR_TABLE_ID,
ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
mlog_write_dulint(dict_header + DICT_HDR_INDEX_ID, mlog_write_dulint(dict_header + DICT_HDR_INDEX_ID,
ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
mlog_write_dulint(dict_header + DICT_HDR_MIX_ID, mlog_write_dulint(dict_header + DICT_HDR_MIX_ID,
ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
/* Create the B-tree roots for the clustered indexes of the basic /* Create the B-tree roots for the clustered indexes of the basic
system tables */ system tables */
/*--------------------------*/ /*--------------------------*/
root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE, root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
DICT_HDR_SPACE, DICT_TABLES_ID, FALSE, mtr); DICT_HDR_SPACE, DICT_TABLES_ID, FALSE, mtr);
if (root_page_no == FIL_NULL) { if (root_page_no == FIL_NULL) {
return(FALSE); return(FALSE);
} }
mlog_write_ulint(dict_header + DICT_HDR_TABLES, root_page_no, mlog_write_ulint(dict_header + DICT_HDR_TABLES, root_page_no,
MLOG_4BYTES, mtr); MLOG_4BYTES, mtr);
/*--------------------------*/ /*--------------------------*/
root_page_no = btr_create(DICT_UNIQUE, DICT_HDR_SPACE, root_page_no = btr_create(DICT_UNIQUE, DICT_HDR_SPACE,
DICT_TABLE_IDS_ID, FALSE, mtr); DICT_TABLE_IDS_ID, FALSE, mtr);
if (root_page_no == FIL_NULL) { if (root_page_no == FIL_NULL) {
return(FALSE); return(FALSE);
} }
mlog_write_ulint(dict_header + DICT_HDR_TABLE_IDS, root_page_no, mlog_write_ulint(dict_header + DICT_HDR_TABLE_IDS, root_page_no,
MLOG_4BYTES, mtr); MLOG_4BYTES, mtr);
/*--------------------------*/ /*--------------------------*/
root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE, root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
DICT_HDR_SPACE, DICT_COLUMNS_ID, FALSE, mtr); DICT_HDR_SPACE, DICT_COLUMNS_ID, FALSE, mtr);
if (root_page_no == FIL_NULL) { if (root_page_no == FIL_NULL) {
return(FALSE); return(FALSE);
} }
mlog_write_ulint(dict_header + DICT_HDR_COLUMNS, root_page_no, mlog_write_ulint(dict_header + DICT_HDR_COLUMNS, root_page_no,
MLOG_4BYTES, mtr); MLOG_4BYTES, mtr);
/*--------------------------*/ /*--------------------------*/
root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE, root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
DICT_HDR_SPACE, DICT_INDEXES_ID, FALSE, mtr); DICT_HDR_SPACE, DICT_INDEXES_ID, FALSE, mtr);
if (root_page_no == FIL_NULL) { if (root_page_no == FIL_NULL) {
return(FALSE); return(FALSE);
} }
mlog_write_ulint(dict_header + DICT_HDR_INDEXES, root_page_no, mlog_write_ulint(dict_header + DICT_HDR_INDEXES, root_page_no,
MLOG_4BYTES, mtr); MLOG_4BYTES, mtr);
/*--------------------------*/ /*--------------------------*/
root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE, root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
DICT_HDR_SPACE, DICT_FIELDS_ID, FALSE, mtr); DICT_HDR_SPACE, DICT_FIELDS_ID, FALSE, mtr);
if (root_page_no == FIL_NULL) { if (root_page_no == FIL_NULL) {
return(FALSE); return(FALSE);
} }
mlog_write_ulint(dict_header + DICT_HDR_FIELDS, root_page_no, mlog_write_ulint(dict_header + DICT_HDR_FIELDS, root_page_no,
MLOG_4BYTES, mtr); MLOG_4BYTES, mtr);
/*--------------------------*/ /*--------------------------*/
return(TRUE); return(TRUE);
@ -236,11 +236,11 @@ dict_boot(void)
..._MARGIN, it will immediately be updated to the disk-based ..._MARGIN, it will immediately be updated to the disk-based
header. */ header. */
dict_sys->row_id = ut_dulint_add( dict_sys->row_id = ut_dulint_add
ut_dulint_align_up( (ut_dulint_align_up(mtr_read_dulint
mtr_read_dulint(dict_hdr + DICT_HDR_ROW_ID, &mtr), (dict_hdr + DICT_HDR_ROW_ID, &mtr),
DICT_HDR_ROW_ID_WRITE_MARGIN), DICT_HDR_ROW_ID_WRITE_MARGIN),
DICT_HDR_ROW_ID_WRITE_MARGIN); DICT_HDR_ROW_ID_WRITE_MARGIN);
/* Insert into the dictionary cache the descriptions of the basic /* Insert into the dictionary cache the descriptions of the basic
system tables */ system tables */
@ -262,23 +262,27 @@ dict_boot(void)
dict_sys->sys_tables = table; dict_sys->sys_tables = table;
index = dict_mem_index_create("SYS_TABLES", "CLUST_IND", index = dict_mem_index_create("SYS_TABLES", "CLUST_IND",
DICT_HDR_SPACE, DICT_UNIQUE | DICT_CLUSTERED, 1); DICT_HDR_SPACE,
DICT_UNIQUE | DICT_CLUSTERED, 1);
dict_mem_index_add_field(index, "NAME", 0); dict_mem_index_add_field(index, "NAME", 0);
index->id = DICT_TABLES_ID; index->id = DICT_TABLES_ID;
success = dict_index_add_to_cache(table, index, mtr_read_ulint( success = dict_index_add_to_cache(table, index, mtr_read_ulint
dict_hdr + DICT_HDR_TABLES, MLOG_4BYTES, &mtr)); (dict_hdr + DICT_HDR_TABLES,
MLOG_4BYTES, &mtr));
ut_a(success); ut_a(success);
/*-------------------------*/ /*-------------------------*/
index = dict_mem_index_create("SYS_TABLES", "ID_IND", index = dict_mem_index_create("SYS_TABLES", "ID_IND",
DICT_HDR_SPACE, DICT_UNIQUE, 1); DICT_HDR_SPACE, DICT_UNIQUE, 1);
dict_mem_index_add_field(index, "ID", 0); dict_mem_index_add_field(index, "ID", 0);
index->id = DICT_TABLE_IDS_ID; index->id = DICT_TABLE_IDS_ID;
success = dict_index_add_to_cache(table, index, mtr_read_ulint( success = dict_index_add_to_cache(table, index,
dict_hdr + DICT_HDR_TABLE_IDS, MLOG_4BYTES, &mtr)); mtr_read_ulint
(dict_hdr + DICT_HDR_TABLE_IDS,
MLOG_4BYTES, &mtr));
ut_a(success); ut_a(success);
/*-------------------------*/ /*-------------------------*/
table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0); table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0);
@ -297,14 +301,16 @@ dict_boot(void)
dict_sys->sys_columns = table; dict_sys->sys_columns = table;
index = dict_mem_index_create("SYS_COLUMNS", "CLUST_IND", index = dict_mem_index_create("SYS_COLUMNS", "CLUST_IND",
DICT_HDR_SPACE, DICT_UNIQUE | DICT_CLUSTERED, 2); DICT_HDR_SPACE,
DICT_UNIQUE | DICT_CLUSTERED, 2);
dict_mem_index_add_field(index, "TABLE_ID", 0); dict_mem_index_add_field(index, "TABLE_ID", 0);
dict_mem_index_add_field(index, "POS", 0); dict_mem_index_add_field(index, "POS", 0);
index->id = DICT_COLUMNS_ID; index->id = DICT_COLUMNS_ID;
success = dict_index_add_to_cache(table, index, mtr_read_ulint( success = dict_index_add_to_cache(table, index, mtr_read_ulint
dict_hdr + DICT_HDR_COLUMNS, MLOG_4BYTES, &mtr)); (dict_hdr + DICT_HDR_COLUMNS,
MLOG_4BYTES, &mtr));
ut_a(success); ut_a(success);
/*-------------------------*/ /*-------------------------*/
table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0); table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0);
@ -333,14 +339,16 @@ dict_boot(void)
dict_sys->sys_indexes = table; dict_sys->sys_indexes = table;
index = dict_mem_index_create("SYS_INDEXES", "CLUST_IND", index = dict_mem_index_create("SYS_INDEXES", "CLUST_IND",
DICT_HDR_SPACE, DICT_UNIQUE | DICT_CLUSTERED, 2); DICT_HDR_SPACE,
DICT_UNIQUE | DICT_CLUSTERED, 2);
dict_mem_index_add_field(index, "TABLE_ID", 0); dict_mem_index_add_field(index, "TABLE_ID", 0);
dict_mem_index_add_field(index, "ID", 0); dict_mem_index_add_field(index, "ID", 0);
index->id = DICT_INDEXES_ID; index->id = DICT_INDEXES_ID;
success = dict_index_add_to_cache(table, index, mtr_read_ulint( success = dict_index_add_to_cache(table, index, mtr_read_ulint
dict_hdr + DICT_HDR_INDEXES, MLOG_4BYTES, &mtr)); (dict_hdr + DICT_HDR_INDEXES,
MLOG_4BYTES, &mtr));
ut_a(success); ut_a(success);
/*-------------------------*/ /*-------------------------*/
table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0); table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0);
@ -354,14 +362,16 @@ dict_boot(void)
dict_sys->sys_fields = table; dict_sys->sys_fields = table;
index = dict_mem_index_create("SYS_FIELDS", "CLUST_IND", index = dict_mem_index_create("SYS_FIELDS", "CLUST_IND",
DICT_HDR_SPACE, DICT_UNIQUE | DICT_CLUSTERED, 2); DICT_HDR_SPACE,
DICT_UNIQUE | DICT_CLUSTERED, 2);
dict_mem_index_add_field(index, "INDEX_ID", 0); dict_mem_index_add_field(index, "INDEX_ID", 0);
dict_mem_index_add_field(index, "POS", 0); dict_mem_index_add_field(index, "POS", 0);
index->id = DICT_FIELDS_ID; index->id = DICT_FIELDS_ID;
success = dict_index_add_to_cache(table, index, mtr_read_ulint( success = dict_index_add_to_cache(table, index, mtr_read_ulint
dict_hdr + DICT_HDR_FIELDS, MLOG_4BYTES, &mtr)); (dict_hdr + DICT_HDR_FIELDS,
MLOG_4BYTES, &mtr));
ut_a(success); ut_a(success);
mtr_commit(&mtr); mtr_commit(&mtr);

View File

@ -69,7 +69,7 @@ dict_create_sys_tables_tuple(
ptr = mem_heap_alloc(heap, 4); ptr = mem_heap_alloc(heap, 4);
mach_write_to_4(ptr, table->n_def mach_write_to_4(ptr, table->n_def
| ((table->flags & DICT_TF_COMPACT) << 31)); | ((table->flags & DICT_TF_COMPACT) << 31));
dfield_set_data(dfield, ptr, 4); dfield_set_data(dfield, ptr, 4);
/* 5: TYPE -----------------------------*/ /* 5: TYPE -----------------------------*/
dfield = dtuple_get_nth_field(entry, 3); dfield = dtuple_get_nth_field(entry, 3);
@ -222,8 +222,8 @@ dict_build_table_def_step(
row_len = 0; row_len = 0;
for (i = 0; i < table->n_def; i++) { for (i = 0; i < table->n_def; i++) {
row_len += dtype_get_min_size(dict_col_get_type( row_len += dtype_get_min_size(dict_col_get_type
&table->cols[i])); (&table->cols[i]));
} }
if (row_len > BTR_PAGE_MAX_REC_SIZE) { if (row_len > BTR_PAGE_MAX_REC_SIZE) {
return(DB_TOO_BIG_RECORD); return(DB_TOO_BIG_RECORD);
@ -236,7 +236,7 @@ dict_build_table_def_step(
- page 1 is an ibuf bitmap page, - page 1 is an ibuf bitmap page,
- page 2 is the first inode page, - page 2 is the first inode page,
- page 3 will contain the root of the clustered index of the - page 3 will contain the root of the clustered index of the
table we create here. */ table we create here. */
table->space = 0; /* reset to zero for the call below */ table->space = 0; /* reset to zero for the call below */
@ -251,9 +251,9 @@ dict_build_table_def_step(
is_path = FALSE; is_path = FALSE;
} }
error = fil_create_new_single_table_tablespace( error = fil_create_new_single_table_tablespace
&(table->space), path_or_name, is_path, (&table->space, path_or_name, is_path,
FIL_IBD_FILE_INITIAL_SIZE); FIL_IBD_FILE_INITIAL_SIZE);
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {
return(error); return(error);
@ -285,7 +285,7 @@ dict_build_col_def_step(
dtuple_t* row; dtuple_t* row;
row = dict_create_sys_columns_tuple(node->table, node->col_no, row = dict_create_sys_columns_tuple(node->table, node->col_no,
node->heap); node->heap);
ins_node_set_new_row(node->col_def, row); ins_node_set_new_row(node->col_def, row);
return(DB_SUCCESS); return(DB_SUCCESS);
@ -450,7 +450,7 @@ dict_create_sys_fields_tuple(
dfield = dtuple_get_nth_field(entry, 2); dfield = dtuple_get_nth_field(entry, 2);
dfield_set_data(dfield, field->name, dfield_set_data(dfield, field->name,
ut_strlen(field->name)); ut_strlen(field->name));
/*---------------------------------*/ /*---------------------------------*/
dict_table_copy_types(entry, sys_fields); dict_table_copy_types(entry, sys_fields);
@ -528,7 +528,7 @@ dict_build_index_def_step(
node->table = table; node->table = table;
ut_ad((UT_LIST_GET_LEN(table->indexes) > 0) ut_ad((UT_LIST_GET_LEN(table->indexes) > 0)
|| (index->type & DICT_CLUSTERED)); || (index->type & DICT_CLUSTERED));
index->id = dict_hdr_get_new_id(DICT_HDR_INDEX_ID); index->id = dict_hdr_get_new_id(DICT_HDR_INDEX_ID);
@ -600,19 +600,19 @@ dict_create_index_tree_step(
search_tuple = dict_create_search_tuple(node->ind_row, node->heap); search_tuple = dict_create_search_tuple(node->ind_row, node->heap);
btr_pcur_open(UT_LIST_GET_FIRST(sys_indexes->indexes), btr_pcur_open(UT_LIST_GET_FIRST(sys_indexes->indexes),
search_tuple, PAGE_CUR_L, BTR_MODIFY_LEAF, search_tuple, PAGE_CUR_L, BTR_MODIFY_LEAF,
&pcur, &mtr); &pcur, &mtr);
btr_pcur_move_to_next_user_rec(&pcur, &mtr); btr_pcur_move_to_next_user_rec(&pcur, &mtr);
node->page_no = btr_create(index->type, index->space, index->id, node->page_no = btr_create(index->type, index->space, index->id,
dict_table_is_comp(table), &mtr); dict_table_is_comp(table), &mtr);
/* printf("Created a new index tree in space %lu root page %lu\n", /* printf("Created a new index tree in space %lu root page %lu\n",
index->space, index->page_no); */ index->space, index->page_no); */
page_rec_write_index_page_no(btr_pcur_get_rec(&pcur), page_rec_write_index_page_no(btr_pcur_get_rec(&pcur),
DICT_SYS_INDEXES_PAGE_NO_FIELD, DICT_SYS_INDEXES_PAGE_NO_FIELD,
node->page_no, &mtr); node->page_no, &mtr);
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
mtr_commit(&mtr); mtr_commit(&mtr);
@ -657,7 +657,7 @@ dict_drop_index_tree(
} }
ptr = rec_get_nth_field_old(rec, ptr = rec_get_nth_field_old(rec,
DICT_SYS_INDEXES_SPACE_NO_FIELD, &len); DICT_SYS_INDEXES_SPACE_NO_FIELD, &len);
ut_ad(len == 4); ut_ad(len == 4);
@ -680,11 +680,12 @@ dict_drop_index_tree(
record: this mini-transaction marks the B-tree totally freed */ record: this mini-transaction marks the B-tree totally freed */
/* printf("Dropping index tree in space %lu root page %lu\n", space, /* printf("Dropping index tree in space %lu root page %lu\n", space,
root_page_no); */ root_page_no); */
btr_free_root(space, root_page_no, mtr); btr_free_root(space, root_page_no, mtr);
page_rec_write_index_page_no(rec, page_rec_write_index_page_no(rec,
DICT_SYS_INDEXES_PAGE_NO_FIELD, FIL_NULL, mtr); DICT_SYS_INDEXES_PAGE_NO_FIELD,
FIL_NULL, mtr);
} }
/*********************************************************************** /***********************************************************************
@ -732,7 +733,7 @@ dict_truncate_index_tree(
} }
ptr = rec_get_nth_field_old(rec, ptr = rec_get_nth_field_old(rec,
DICT_SYS_INDEXES_SPACE_NO_FIELD, &len); DICT_SYS_INDEXES_SPACE_NO_FIELD, &len);
ut_ad(len == 4); ut_ad(len == 4);
@ -749,7 +750,7 @@ dict_truncate_index_tree(
} }
ptr = rec_get_nth_field_old(rec, ptr = rec_get_nth_field_old(rec,
DICT_SYS_INDEXES_TYPE_FIELD, &len); DICT_SYS_INDEXES_TYPE_FIELD, &len);
ut_ad(len == 4); ut_ad(len == 4);
type = mach_read_from_4(ptr); type = mach_read_from_4(ptr);
@ -767,8 +768,8 @@ dict_truncate_index_tree(
appropriate field in the SYS_INDEXES record: this mini-transaction appropriate field in the SYS_INDEXES record: this mini-transaction
marks the B-tree totally truncated */ marks the B-tree totally truncated */
comp = page_is_comp(btr_page_get( comp = page_is_comp(btr_page_get
space, root_page_no, RW_X_LATCH, mtr)); (space, root_page_no, RW_X_LATCH, mtr));
btr_free_root(space, root_page_no, mtr); btr_free_root(space, root_page_no, mtr);
/* We will temporarily write FIL_NULL to the PAGE_NO field /* We will temporarily write FIL_NULL to the PAGE_NO field
@ -776,7 +777,7 @@ dict_truncate_index_tree(
inconsistent state in case it crashes between the mtr_commit() inconsistent state in case it crashes between the mtr_commit()
below and the following mtr_commit() call. */ below and the following mtr_commit() call. */
page_rec_write_index_page_no(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD, page_rec_write_index_page_no(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD,
FIL_NULL, mtr); FIL_NULL, mtr);
/* We will need to commit the mini-transaction in order to avoid /* We will need to commit the mini-transaction in order to avoid
deadlocks in the btr_create() call, because otherwise we would deadlocks in the btr_create() call, because otherwise we would
@ -788,8 +789,8 @@ dict_truncate_index_tree(
/* Find the index corresponding to this SYS_INDEXES record. */ /* Find the index corresponding to this SYS_INDEXES record. */
for (index = UT_LIST_GET_FIRST(table->indexes); for (index = UT_LIST_GET_FIRST(table->indexes);
index; index;
index = UT_LIST_GET_NEXT(indexes, index)) { index = UT_LIST_GET_NEXT(indexes, index)) {
if (!ut_dulint_cmp(index->id, index_id)) { if (!ut_dulint_cmp(index->id, index_id)) {
break; break;
} }
@ -834,11 +835,11 @@ tab_create_graph_create(
node->heap = mem_heap_create(256); node->heap = mem_heap_create(256);
node->tab_def = ins_node_create(INS_DIRECT, dict_sys->sys_tables, node->tab_def = ins_node_create(INS_DIRECT, dict_sys->sys_tables,
heap); heap);
node->tab_def->common.parent = node; node->tab_def->common.parent = node;
node->col_def = ins_node_create(INS_DIRECT, dict_sys->sys_columns, node->col_def = ins_node_create(INS_DIRECT, dict_sys->sys_columns,
heap); heap);
node->col_def->common.parent = node; node->col_def->common.parent = node;
node->commit_node = commit_node_create(heap); node->commit_node = commit_node_create(heap);
@ -871,11 +872,11 @@ ind_create_graph_create(
node->heap = mem_heap_create(256); node->heap = mem_heap_create(256);
node->ind_def = ins_node_create(INS_DIRECT, node->ind_def = ins_node_create(INS_DIRECT,
dict_sys->sys_indexes, heap); dict_sys->sys_indexes, heap);
node->ind_def->common.parent = node; node->ind_def->common.parent = node;
node->field_def = ins_node_create(INS_DIRECT, node->field_def = ins_node_create(INS_DIRECT,
dict_sys->sys_fields, heap); dict_sys->sys_fields, heap);
node->field_def->common.parent = node; node->field_def->common.parent = node;
node->commit_node = commit_node_create(heap); node->commit_node = commit_node_create(heap);
@ -1088,7 +1089,7 @@ dict_create_index_step(
if (node->state == INDEX_ADD_TO_CACHE) { if (node->state == INDEX_ADD_TO_CACHE) {
success = dict_index_add_to_cache(node->table, node->index, success = dict_index_add_to_cache(node->table, node->index,
node->page_no); node->page_no);
ut_a(success); ut_a(success);
@ -1136,8 +1137,8 @@ dict_create_or_check_foreign_constraint_tables(void)
table2 = dict_table_get_low("SYS_FOREIGN_COLS"); table2 = dict_table_get_low("SYS_FOREIGN_COLS");
if (table1 && table2 if (table1 && table2
&& UT_LIST_GET_LEN(table1->indexes) == 3 && UT_LIST_GET_LEN(table1->indexes) == 3
&& UT_LIST_GET_LEN(table2->indexes) == 1) { && UT_LIST_GET_LEN(table2->indexes) == 1) {
/* Foreign constraint system tables have already been /* Foreign constraint system tables have already been
created, and they are ok */ created, and they are ok */
@ -1157,13 +1158,15 @@ dict_create_or_check_foreign_constraint_tables(void)
if (table1) { if (table1) {
fprintf(stderr, fprintf(stderr,
"InnoDB: dropping incompletely created SYS_FOREIGN table\n"); "InnoDB: dropping incompletely created"
" SYS_FOREIGN table\n");
row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE); row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE);
} }
if (table2) { if (table2) {
fprintf(stderr, fprintf(stderr,
"InnoDB: dropping incompletely created SYS_FOREIGN_COLS table\n"); "InnoDB: dropping incompletely created"
" SYS_FOREIGN_COLS table\n");
row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE); row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE);
} }
@ -1181,19 +1184,25 @@ dict_create_or_check_foreign_constraint_tables(void)
design. */ design. */
error = que_eval_sql(NULL, error = que_eval_sql(NULL,
"PROCEDURE CREATE_FOREIGN_SYS_TABLES_PROC () IS\n" "PROCEDURE CREATE_FOREIGN_SYS_TABLES_PROC () IS\n"
"BEGIN\n" "BEGIN\n"
"CREATE TABLE\n" "CREATE TABLE\n"
"SYS_FOREIGN(ID CHAR, FOR_NAME CHAR, REF_NAME CHAR, N_COLS INT);\n" "SYS_FOREIGN(ID CHAR, FOR_NAME CHAR,"
"CREATE UNIQUE CLUSTERED INDEX ID_IND ON SYS_FOREIGN (ID);\n" " REF_NAME CHAR, N_COLS INT);\n"
"CREATE INDEX FOR_IND ON SYS_FOREIGN (FOR_NAME);\n" "CREATE UNIQUE CLUSTERED INDEX ID_IND"
"CREATE INDEX REF_IND ON SYS_FOREIGN (REF_NAME);\n" " ON SYS_FOREIGN (ID);\n"
"CREATE TABLE\n" "CREATE INDEX FOR_IND"
"SYS_FOREIGN_COLS(ID CHAR, POS INT, FOR_COL_NAME CHAR, REF_COL_NAME CHAR);\n" " ON SYS_FOREIGN (FOR_NAME);\n"
"CREATE UNIQUE CLUSTERED INDEX ID_IND ON SYS_FOREIGN_COLS (ID, POS);\n" "CREATE INDEX REF_IND"
"COMMIT WORK;\n" " ON SYS_FOREIGN (REF_NAME);\n"
"END;\n" "CREATE TABLE\n"
, FALSE, trx); "SYS_FOREIGN_COLS(ID CHAR, POS INT,"
" FOR_COL_NAME CHAR, REF_COL_NAME CHAR);\n"
"CREATE UNIQUE CLUSTERED INDEX ID_IND"
" ON SYS_FOREIGN_COLS (ID, POS);\n"
"COMMIT WORK;\n"
"END;\n"
, FALSE, trx);
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {
fprintf(stderr, "InnoDB: error %lu in creation\n", fprintf(stderr, "InnoDB: error %lu in creation\n",
@ -1201,10 +1210,11 @@ dict_create_or_check_foreign_constraint_tables(void)
ut_a(error == DB_OUT_OF_FILE_SPACE); ut_a(error == DB_OUT_OF_FILE_SPACE);
fprintf(stderr, "InnoDB: creation failed\n");
fprintf(stderr, "InnoDB: tablespace is full\n");
fprintf(stderr, fprintf(stderr,
"InnoDB: dropping incompletely created SYS_FOREIGN tables\n"); "InnoDB: creation failed\n"
"InnoDB: tablespace is full\n"
"InnoDB: dropping incompletely created"
" SYS_FOREIGN tables\n");
row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE); row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE);
row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE); row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE);
@ -1220,7 +1230,8 @@ dict_create_or_check_foreign_constraint_tables(void)
if (error == DB_SUCCESS) { if (error == DB_SUCCESS) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Foreign key constraint system tables created\n"); "InnoDB: Foreign key constraint system tables"
" created\n");
} }
return(error); return(error);
@ -1249,22 +1260,22 @@ dict_foreign_eval_sql(
rewind(ef); rewind(ef);
ut_print_timestamp(ef); ut_print_timestamp(ef);
fputs(" Error in foreign key constraint creation for table ", fputs(" Error in foreign key constraint creation for table ",
ef); ef);
ut_print_name(ef, trx, TRUE, table->name); ut_print_name(ef, trx, TRUE, table->name);
fputs(".\nA foreign key constraint of name ", ef); fputs(".\nA foreign key constraint of name ", ef);
ut_print_name(ef, trx, FALSE, foreign->id); ut_print_name(ef, trx, FALSE, foreign->id);
fputs("\nalready exists." fputs("\nalready exists."
" (Note that internally InnoDB adds 'databasename/'\n" " (Note that internally InnoDB adds 'databasename/'\n"
"in front of the user-defined constraint name).\n", "in front of the user-defined constraint name).\n",
ef); ef);
fputs("Note that InnoDB's FOREIGN KEY system tables store\n" fputs("Note that InnoDB's FOREIGN KEY system tables store\n"
"constraint names as case-insensitive, with the\n" "constraint names as case-insensitive, with the\n"
"MySQL standard latin1_swedish_ci collation. If you\n" "MySQL standard latin1_swedish_ci collation. If you\n"
"create tables or databases whose names differ only in\n" "create tables or databases whose names differ only in\n"
"the character case, then collisions in constraint\n" "the character case, then collisions in constraint\n"
"names can occur. Workaround: name your constraints\n" "names can occur. Workaround: name your constraints\n"
"explicitly with unique names.\n", "explicitly with unique names.\n",
ef); ef);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
@ -1279,10 +1290,11 @@ dict_foreign_eval_sql(
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_print_timestamp(ef); ut_print_timestamp(ef);
fputs(" Internal error in foreign key constraint creation" fputs(" Internal error in foreign key constraint creation"
" for table ", ef); " for table ", ef);
ut_print_name(ef, trx, TRUE, table->name); ut_print_name(ef, trx, TRUE, table->name);
fputs(".\n" fputs(".\n"
"See the MySQL .err log in the datadir for more information.\n", ef); "See the MySQL .err log in the datadir"
" for more information.\n", ef);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
return(error); return(error);
@ -1311,18 +1323,18 @@ dict_create_add_foreign_field_to_dictionary(
pars_info_add_int4_literal(info, "pos", field_nr); pars_info_add_int4_literal(info, "pos", field_nr);
pars_info_add_str_literal(info, "for_col_name", pars_info_add_str_literal(info, "for_col_name",
foreign->foreign_col_names[field_nr]); foreign->foreign_col_names[field_nr]);
pars_info_add_str_literal(info, "ref_col_name", pars_info_add_str_literal(info, "ref_col_name",
foreign->referenced_col_names[field_nr]); foreign->referenced_col_names[field_nr]);
return dict_foreign_eval_sql(info, return(dict_foreign_eval_sql
"PROCEDURE P () IS\n" (info, "PROCEDURE P () IS\n"
"BEGIN\n" "BEGIN\n"
"INSERT INTO SYS_FOREIGN_COLS VALUES" "INSERT INTO SYS_FOREIGN_COLS VALUES"
"(:id, :pos, :for_col_name, :ref_col_name);\n" "(:id, :pos, :for_col_name, :ref_col_name);\n"
"END;\n" "END;\n",
, table, foreign, trx); table, foreign, trx));
} }
/************************************************************************ /************************************************************************
@ -1362,18 +1374,18 @@ dict_create_add_foreign_to_dictionary(
pars_info_add_str_literal(info, "for_name", table->name); pars_info_add_str_literal(info, "for_name", table->name);
pars_info_add_str_literal(info, "ref_name", pars_info_add_str_literal(info, "ref_name",
foreign->referenced_table_name); foreign->referenced_table_name);
pars_info_add_int4_literal(info, "n_cols", pars_info_add_int4_literal(info, "n_cols",
foreign->n_fields + (foreign->type << 24)); foreign->n_fields + (foreign->type << 24));
error = dict_foreign_eval_sql(info, error = dict_foreign_eval_sql(info,
"PROCEDURE P () IS\n" "PROCEDURE P () IS\n"
"BEGIN\n" "BEGIN\n"
"INSERT INTO SYS_FOREIGN VALUES" "INSERT INTO SYS_FOREIGN VALUES"
"(:id, :for_name, :ref_name, :n_cols);\n" "(:id, :for_name, :ref_name, :n_cols);\n"
"END;\n" "END;\n"
, table, foreign, trx); , table, foreign, trx);
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {
@ -1381,8 +1393,8 @@ dict_create_add_foreign_to_dictionary(
} }
for (i = 0; i < foreign->n_fields; i++) { for (i = 0; i < foreign->n_fields; i++) {
error = dict_create_add_foreign_field_to_dictionary(i, error = dict_create_add_foreign_field_to_dictionary
table, foreign, trx); (i, table, foreign, trx);
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {
@ -1391,11 +1403,11 @@ dict_create_add_foreign_to_dictionary(
} }
error = dict_foreign_eval_sql(NULL, error = dict_foreign_eval_sql(NULL,
"PROCEDURE P () IS\n" "PROCEDURE P () IS\n"
"BEGIN\n" "BEGIN\n"
"COMMIT WORK;\n" "COMMIT WORK;\n"
"END;\n" "END;\n"
, table, foreign, trx); , table, foreign, trx);
return(error); return(error);
} }
@ -1428,7 +1440,8 @@ dict_create_add_foreigns_to_dictionary(
if (NULL == dict_table_get_low("SYS_FOREIGN")) { if (NULL == dict_table_get_low("SYS_FOREIGN")) {
fprintf(stderr, fprintf(stderr,
"InnoDB: table SYS_FOREIGN not found from internal data dictionary\n"); "InnoDB: table SYS_FOREIGN not found"
" in internal data dictionary\n");
return(DB_ERROR); return(DB_ERROR);
} }
@ -1437,8 +1450,8 @@ dict_create_add_foreigns_to_dictionary(
foreign; foreign;
foreign = UT_LIST_GET_NEXT(foreign_list, foreign)) { foreign = UT_LIST_GET_NEXT(foreign_list, foreign)) {
error = dict_create_add_foreign_to_dictionary(&number, error = dict_create_add_foreign_to_dictionary
table, foreign, trx); (&number, table, foreign, trx);
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {

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