Merge janus.mylan:/usr/home/serg/Abk/mysql-5.1

into  janus.mylan:/usr/home/serg/Abk/mysql-maria


Makefile.am:
  Auto merged
configure.in:
  Auto merged
BitKeeper/triggers/post-commit:
  Auto merged
client/mysqldump.c:
  Auto merged
client/mysqltest.c:
  Auto merged
include/my_dbug.h:
  Auto merged
include/mysql_com.h:
  Auto merged
libmysql/CMakeLists.txt:
  Auto merged
libmysqld/Makefile.am:
  Auto merged
mysql-test/lib/mtr_report.pl:
  Auto merged
mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/t/disabled.def:
  Auto merged
mysql-test/t/variables.test:
  Auto merged
server-tools/instance-manager/CMakeLists.txt:
  Auto merged
server-tools/instance-manager/mysql_connection.cc:
  Auto merged
sql/Makefile.am:
  Auto merged
sql/filesort.cc:
  Auto merged
sql/gen_lex_hash.cc:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/ha_partition.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/lex.h:
  Auto merged
sql/lock.cc:
  Auto merged
sql/log.cc:
  Auto merged
sql/net_serv.cc:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/slave.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_delete.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.h:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/table.cc:
  Auto merged
sql/table.h:
  Auto merged
storage/myisam/ha_myisam.cc:
  Auto merged
storage/myisam/mi_open.c:
  Auto merged
storage/myisammrg/ha_myisammrg.cc:
  Auto merged
sql/handler.cc:
  merged
sql/handler.h:
  merged
sql/mysql_priv.h:
  merged
sql/mysqld.cc:
  merged
sql/set_var.cc:
  merged
sql/sql_select.cc:
  merged
sql/sql_show.cc:
  merged
unittest/mysys/my_atomic-t.c:
  merged
This commit is contained in:
unknown 2007-12-27 18:16:02 +01:00
commit 7fdbc4230e
385 changed files with 97334 additions and 2452 deletions

View File

@ -1,6 +1,7 @@
*-t *-t
*.Plo *.Plo
*.Po *.Po
*.Tpo
*.a *.a
*.bb *.bb
*.bbg *.bbg
@ -1079,6 +1080,7 @@ libmysqld/ha_innobase.cc
libmysqld/ha_innodb.cc libmysqld/ha_innodb.cc
libmysqld/ha_isam.cc libmysqld/ha_isam.cc
libmysqld/ha_isammrg.cc libmysqld/ha_isammrg.cc
libmysqld/ha_maria.cc
libmysqld/ha_myisam.cc libmysqld/ha_myisam.cc
libmysqld/ha_myisammrg.cc libmysqld/ha_myisammrg.cc
libmysqld/ha_ndbcluster.cc libmysqld/ha_ndbcluster.cc
@ -1220,6 +1222,7 @@ linked_tools_sources
locked locked
ltmain.sh ltmain.sh
man/*.1 man/*.1
maria_log_control
merge/*.ds? merge/*.ds?
merge/*.vcproj merge/*.vcproj
missing missing
@ -2429,6 +2432,45 @@ storage/innobase/ut/.deps/ut0rnd.Po
storage/innobase/ut/.deps/ut0ut.Po storage/innobase/ut/.deps/ut0ut.Po
storage/innobase/ut/.deps/ut0vec.Po storage/innobase/ut/.deps/ut0vec.Po
storage/innobase/ut/.deps/ut0wqueue.Po storage/innobase/ut/.deps/ut0wqueue.Po
storage/maria/*.MAD
storage/maria/*.MAI
storage/maria/ma_rt_test
storage/maria/ma_sp_test
storage/maria/ma_test1
storage/maria/ma_test2
storage/maria/ma_test3
storage/maria/ma_test_all
storage/maria/maria.log
storage/maria/maria_chk
storage/maria/maria_control
storage/maria/maria_ftdump
storage/maria/maria_log
storage/maria/maria_log.*
storage/maria/maria_pack
storage/maria/maria_read_log
storage/maria/tmp/*
storage/maria/unittest/ma_pagecache_consist_1k-t-big
storage/maria/unittest/ma_pagecache_consist_1kHC-t-big
storage/maria/unittest/ma_pagecache_consist_1kRD-t-big
storage/maria/unittest/ma_pagecache_consist_1kWR-t-big
storage/maria/unittest/ma_pagecache_consist_64k-t-big
storage/maria/unittest/ma_pagecache_consist_64kHC-t-big
storage/maria/unittest/ma_pagecache_consist_64kRD-t-big
storage/maria/unittest/ma_pagecache_consist_64kWR-t-big
storage/maria/unittest/ma_pagecache_single_64k-t-big
storage/maria/unittest/ma_test_loghandler_long-t-big
storage/maria/unittest/maria_control
storage/maria/unittest/mf_pagecache_consist_1k-t-big
storage/maria/unittest/mf_pagecache_consist_1kHC-t-big
storage/maria/unittest/mf_pagecache_consist_1kRD-t-big
storage/maria/unittest/mf_pagecache_consist_1kWR-t-big
storage/maria/unittest/mf_pagecache_consist_64k-t-big
storage/maria/unittest/mf_pagecache_consist_64kHC-t-big
storage/maria/unittest/mf_pagecache_consist_64kRD-t-big
storage/maria/unittest/mf_pagecache_consist_64kWR-t-big
storage/maria/unittest/mf_pagecache_single_64k-t-big
storage/maria/unittest/page_cache_test_file_1
storage/maria/unittest/pagecache_debug.log
storage/myisam/.deps/ft_boolean_search.Po storage/myisam/.deps/ft_boolean_search.Po
storage/myisam/.deps/ft_nlq_search.Po storage/myisam/.deps/ft_nlq_search.Po
storage/myisam/.deps/ft_parser.Po storage/myisam/.deps/ft_parser.Po
@ -2981,13 +3023,25 @@ unittest/examples/.deps/simple-t.Po
unittest/examples/.deps/skip-t.Po unittest/examples/.deps/skip-t.Po
unittest/examples/.deps/skip_all-t.Po unittest/examples/.deps/skip_all-t.Po
unittest/examples/.deps/todo-t.Po unittest/examples/.deps/todo-t.Po
unittest/maria_control
unittest/mysys/*.t unittest/mysys/*.t
unittest/mysys/.deps/base64-t.Po unittest/mysys/.deps/base64-t.Po
unittest/mysys/.deps/bitmap-t.Po unittest/mysys/.deps/bitmap-t.Po
unittest/mysys/.deps/my_atomic-t.Po unittest/mysys/.deps/my_atomic-t.Po
unittest/mysys/mf_pagecache_consist_1k-t-big
unittest/mysys/mf_pagecache_consist_1kHC-t-big
unittest/mysys/mf_pagecache_consist_1kRD-t-big
unittest/mysys/mf_pagecache_consist_1kWR-t-big
unittest/mysys/mf_pagecache_consist_64k-t-big
unittest/mysys/mf_pagecache_consist_64kHC-t-big
unittest/mysys/mf_pagecache_consist_64kRD-t-big
unittest/mysys/mf_pagecache_consist_64kWR-t-big
unittest/mysys/mf_pagecache_single_64k-t-big
unittest/mytap/.deps/tap.Po unittest/mytap/.deps/tap.Po
unittest/mytap/t/*.t unittest/mytap/t/*.t
unittest/mytap/t/.deps/basic-t.Po unittest/mytap/t/.deps/basic-t.Po
unittest/page_cache_test_file_1
unittest/pagecache_debug.log
unittest/unit unittest/unit
vi.h vi.h
vio/*.ds? vio/*.ds?

0
.tree-is-private Normal file
View File

View File

@ -145,6 +145,7 @@ base_configs="--prefix=$prefix --enable-assembler "
base_configs="$base_configs --with-extra-charsets=complex " base_configs="$base_configs --with-extra-charsets=complex "
base_configs="$base_configs --enable-thread-safe-client " base_configs="$base_configs --enable-thread-safe-client "
base_configs="$base_configs --with-big-tables" base_configs="$base_configs --with-big-tables"
base_configs="$base_configs --with-plugin-maria"
if test -d "$path/../cmd-line-utils/readline" if test -d "$path/../cmd-line-utils/readline"
then then
@ -170,10 +171,10 @@ max_configs="$SSL_LIBRARY --with-plugins=max --with-embedded-server"
# CPU and platform specific compilation flags. # CPU and platform specific compilation flags.
# #
alpha_cflags="$check_cpu_cflags -Wa,-m$cpu_flag" alpha_cflags="$check_cpu_cflags -Wa,-m$cpu_flag"
amd64_cflags="$check_cpu_cflags" amd64_cflags="$check_cpu_cflags -DSTACK_DIRECTION=-1"
amd64_cxxflags="" # If dropping '--with-big-tables', add here "-DBIG_TABLES" amd64_cxxflags="" # If dropping '--with-big-tables', add here "-DBIG_TABLES"
pentium_cflags="$check_cpu_cflags" pentium_cflags="$check_cpu_cflags -DSTACK_DIRECTION=-1"
pentium64_cflags="$check_cpu_cflags -m64" pentium64_cflags="$check_cpu_cflags -m64 -DSTACK_DIRECTION=-1"
ppc_cflags="$check_cpu_cflags" ppc_cflags="$check_cpu_cflags"
sparc_cflags="" sparc_cflags=""

View File

@ -0,0 +1,7 @@
#! /bin/sh
path=`dirname $0`
. "$path/SETUP.sh"
extra_flags="$amd64_cflags -pg -g"
extra_configs="$amd64_configs $max_no_ndb_configs --disable-shared $static_link"
. "$path/FINISH.sh"

View File

@ -40,5 +40,6 @@ fi
# Make sure to enable all features that affect "make dist" # Make sure to enable all features that affect "make dist"
./configure \ ./configure \
--with-maria-storage-engine \
--with-ndbcluster --with-ndbcluster
make make

View File

@ -11,7 +11,7 @@ FROM=$COMMITTER@mysql.com
COMMITS=commits@lists.mysql.com COMMITS=commits@lists.mysql.com
DOCS=docs-commit@mysql.com DOCS=docs-commit@mysql.com
LIMIT=10000 LIMIT=10000
VERSION="5.1" VERSION="maria"
BKROOT=`bk root` BKROOT=`bk root`
if [ -x /usr/sbin/sendmail ]; then if [ -x /usr/sbin/sendmail ]; then
@ -103,7 +103,7 @@ see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
EOF EOF
bk changes -v -r+ bk changes -v -r+
bk rset -r+ -ah | bk gnupatch -h -dup -T bk rset -r+ -ah | bk gnupatch -h -dup -T
) | bk sed -e ${LIMIT}q > $BKROOT/BitKeeper/tmp/commits.txt ) > $BKROOT/BitKeeper/tmp/commits.txt
$SENDMAIL -t < $BKROOT/BitKeeper/tmp/commits.txt $SENDMAIL -t < $BKROOT/BitKeeper/tmp/commits.txt

View File

@ -20,3 +20,18 @@ then
exit 1 exit 1
fi fi
# detect if C/C++ files have new trailing white space
trailingblank=`echo $BK_FILE | egrep '\.(c|.h)'`
if [ -n "$trailingblank" ]
then
trailingblank=`bk diffs $BK_FILE | grep '^> .*[[:space:]]$'`
if [ -n "$trailingblank" ]
then
echo "bk diffs $BK_FILE | grep '^> .*[[:space:]]$'"
echo "reported white space at end of some added/modified lines"
echo ""
echo "Checkin FAILED!"
echo "Fix the problem and retry."
exit 1
fi
fi

View File

@ -111,7 +111,7 @@ test-embedded:
echo "no program found for 'embedded' tests - skipped testing" ; \ echo "no program found for 'embedded' tests - skipped testing" ; \
fi fi
test: test-unit test-ns test-pr test: test-ns test-pr
test-full: test test-nr test-ps test-full: test test-nr test-ps

View File

@ -534,7 +534,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
If this behaviour is ever changed, Docs should be notified. If this behaviour is ever changed, Docs should be notified.
*/ */
struct rand_struct rand_st; struct my_rnd_struct rand_st;
for (; argc > 0 ; argv++,argc--) for (; argc > 0 ; argv++,argc--)
{ {
@ -846,7 +846,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
time_t start_time; time_t start_time;
/* Do initialization the same way as we do in mysqld */ /* Do initialization the same way as we do in mysqld */
start_time=time((time_t*) 0); start_time=time((time_t*) 0);
randominit(&rand_st,(ulong) start_time,(ulong) start_time/2); my_rnd_init(&rand_st,(ulong) start_time,(ulong) start_time/2);
if (argc < 2) if (argc < 2)
{ {

View File

@ -63,7 +63,8 @@
enum { enum {
OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION, OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION,
OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL, OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
OPT_MAX_CONNECT_RETRIES, OPT_MARK_PROGRESS, OPT_LOG_DIR, OPT_TAIL_LINES OPT_MAX_CONNECT_RETRIES, OPT_MARK_PROGRESS, OPT_LOG_DIR, OPT_TAIL_LINES,
OPT_GLOBAL_SUBST
}; };
static int record= 0, opt_sleep= -1; static int record= 0, opt_sleep= -1;
@ -104,6 +105,9 @@ static char delimiter[MAX_DELIMITER_LENGTH]= ";";
static uint delimiter_length= 1; static uint delimiter_length= 1;
static char TMPDIR[FN_REFLEN]; static char TMPDIR[FN_REFLEN];
static char global_subst_from[200];
static char global_subst_to[200];
static char *global_subst= NULL;
/* Block stack */ /* Block stack */
enum block_cmd { enum block_cmd {
@ -168,6 +172,10 @@ static void init_re(void);
static int match_re(my_regex_t *, char *); static int match_re(my_regex_t *, char *);
static void free_re(void); static void free_re(void);
static int replace(DYNAMIC_STRING *ds_str,
const char *search_str, ulong search_len,
const char *replace_str, ulong replace_len);
DYNAMIC_ARRAY q_lines; DYNAMIC_ARRAY q_lines;
#include "sslopt-vars.h" #include "sslopt-vars.h"
@ -1542,6 +1550,7 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname)
void check_result(DYNAMIC_STRING* ds) void check_result(DYNAMIC_STRING* ds)
{ {
int res;
const char* mess= "Result content mismatch\n"; const char* mess= "Result content mismatch\n";
DBUG_ENTER("check_result"); DBUG_ENTER("check_result");
@ -1551,7 +1560,32 @@ void check_result(DYNAMIC_STRING* ds)
if (access(result_file_name, F_OK) != 0) if (access(result_file_name, F_OK) != 0)
die("The specified result file does not exist: '%s'", result_file_name); die("The specified result file does not exist: '%s'", result_file_name);
switch (dyn_string_cmp(ds, result_file_name)) { res= dyn_string_cmp(ds, result_file_name);
if (global_subst && res != RESULT_OK)
{
/**
@todo MARIA_HACK
This serves for when a test is run with --default-storage-engine=X
where X is not MyISAM: tests using SHOW CREATE TABLE will always fail
because SHOW CREATE TABLE prints X instead of MyISAM. With
--global-subst=X,MyISAM , such trivial differences are eliminated and
test may be reported as passing.
--global-subst is only a quick way to run a lot of existing tests
with Maria and find bugs; it is not good enough for reaching the main
trees when Maria is merged into them.
--global-subst should be removed.
*/
uint global_subst_from_len= strlen(global_subst_from);
uint global_subst_to_len= strlen(global_subst_to);
while (replace(ds,
global_subst_from, global_subst_from_len,
global_subst_to, global_subst_to_len) == 0)
/* do nothing */ ;
/* let's compare again to see if it is ok now */
res= dyn_string_cmp(ds, result_file_name);
}
switch(res)
{
case RESULT_OK: case RESULT_OK:
break; /* ok */ break; /* ok */
case RESULT_LENGTH_MISMATCH: case RESULT_LENGTH_MISMATCH:
@ -1997,9 +2031,9 @@ void var_set_query_get_value(struct st_command *command, VAR *var)
static DYNAMIC_STRING ds_col; static DYNAMIC_STRING ds_col;
static DYNAMIC_STRING ds_row; static DYNAMIC_STRING ds_row;
const struct command_arg query_get_value_args[] = { const struct command_arg query_get_value_args[] = {
"query", ARG_STRING, TRUE, &ds_query, "Query to run", {"query", ARG_STRING, TRUE, &ds_query, "Query to run"},
"column name", ARG_STRING, TRUE, &ds_col, "Name of column", {"column name", ARG_STRING, TRUE, &ds_col, "Name of column"},
"row number", ARG_STRING, TRUE, &ds_row, "Number for row" {"row number", ARG_STRING, TRUE, &ds_row, "Number for row"},
}; };
DBUG_ENTER("var_set_query_get_value"); DBUG_ENTER("var_set_query_get_value");
@ -5006,6 +5040,11 @@ static struct my_option my_long_options[] =
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
(uchar**) &debug_info_flag, (uchar**) &debug_info_flag, (uchar**) &debug_info_flag, (uchar**) &debug_info_flag,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"global-subst", OPT_GLOBAL_SUBST, "argument should be 'X,Y' ;"
" substitute string X with another Y accross the whole test's current"
" result before comparing with expected result file",
(uchar**) &global_subst, (uchar**) &global_subst, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", (uchar**) &opt_host, (uchar**) &opt_host, 0, {"host", 'h', "Connect to host.", (uchar**) &opt_host, (uchar**) &opt_host, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"include", 'i', "Include SQL before each test case.", (uchar**) &opt_include, {"include", 'i', "Include SQL before each test case.", (uchar**) &opt_include,
@ -5264,6 +5303,16 @@ int parse_args(int argc, char **argv)
if (debug_check_flag) if (debug_check_flag)
my_end_arg= MY_CHECK_ERROR; my_end_arg= MY_CHECK_ERROR;
if (global_subst != NULL)
{
char *comma= strstr(global_subst, ",");
if (comma == NULL)
die("wrong --global-subst, must be X,Y");
memcpy(global_subst_from, global_subst, (comma-global_subst));
global_subst_from[comma-global_subst]= 0;
memcpy(global_subst_to, comma+1, strlen(comma));
}
return 0; return 0;
} }

View File

@ -808,7 +808,7 @@ AC_HEADER_STDC
AC_HEADER_SYS_WAIT AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h float.h floatingpoint.h ieeefp.h limits.h \ AC_CHECK_HEADERS(fcntl.h float.h floatingpoint.h ieeefp.h limits.h \
memory.h pwd.h select.h \ memory.h pwd.h select.h \
stdlib.h stddef.h \ stdlib.h stddef.h sys/stat.h \
strings.h string.h synch.h sys/mman.h sys/socket.h netinet/in.h arpa/inet.h \ strings.h string.h synch.h sys/mman.h sys/socket.h netinet/in.h arpa/inet.h \
sys/timeb.h sys/types.h sys/un.h sys/vadvise.h sys/wait.h term.h \ sys/timeb.h sys/types.h sys/un.h sys/vadvise.h sys/wait.h term.h \
unistd.h utime.h sys/utime.h termio.h termios.h sched.h crypt.h alloca.h \ unistd.h utime.h sys/utime.h termio.h termios.h sched.h crypt.h alloca.h \
@ -2013,7 +2013,7 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \
pthread_setprio_np pthread_setschedparam pthread_sigmask readlink \ pthread_setprio_np pthread_setschedparam pthread_sigmask readlink \
realpath rename rint rwlock_init setupterm \ realpath rename rint rwlock_init setupterm \
shmget shmat shmdt shmctl sigaction sigemptyset sigaddset \ shmget shmat shmdt shmctl sigaction sigemptyset sigaddset \
sighold sigset sigthreadmask port_create sleep \ sighold sigset sigthreadmask port_create sleep thr_yield \
snprintf socket stpcpy strcasecmp strerror strsignal strnlen strpbrk strstr \ snprintf socket stpcpy strcasecmp strerror strsignal strnlen strpbrk strstr \
strtol strtoll strtoul strtoull tell tempnam thr_setconcurrency vidattr \ strtol strtoll strtoul strtoull tell tempnam thr_setconcurrency vidattr \
posix_fallocate) posix_fallocate)
@ -2321,6 +2321,17 @@ MYSQL_CHECK_SSL
# functions tested above # functions tested above
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# MyISAM is declared here,not in storage/myisam/plug.in
# because we want it to be the first in the list of plugins,
# Maria needs it. When it'll be fixed the declaration below can
# be removed and restored (uncommented) in storage/myisam/plug.in
MYSQL_STORAGE_ENGINE(myisam,no, [MyISAM Storage Engine],
[Traditional non-transactional MySQL tables])
MYSQL_PLUGIN_DIRECTORY(myisam, [storage/myisam])
MYSQL_PLUGIN_STATIC(myisam, [libmyisam.a])
MYSQL_PLUGIN_MANDATORY(myisam) dnl Default
MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(myisam, [ha_myisam.cc])
MYSQL_STORAGE_ENGINE(partition, partition, [Partition Support], MYSQL_STORAGE_ENGINE(partition, partition, [Partition Support],
[MySQL Partitioning Support], [max,max-no-ndb]) [MySQL Partitioning Support], [max,max-no-ndb])
@ -2547,8 +2558,6 @@ AC_SUBST(readline_basedir)
AC_SUBST(readline_link) AC_SUBST(readline_link)
AC_SUBST(readline_h_ln_cmd) AC_SUBST(readline_h_ln_cmd)
# Include man pages, if desired, adapted to the configured parts. # Include man pages, if desired, adapted to the configured parts.
if test X"$with_man" = Xyes if test X"$with_man" = Xyes
then then

View File

@ -71,7 +71,12 @@
* *
*/ */
/*
We can't have SAFE_MUTEX defined here as this will cause recursion
in pthread_mutex_lock
*/
#undef SAFE_MUTEX
#include <my_global.h> #include <my_global.h>
#include <m_string.h> #include <m_string.h>
#include <errno.h> #include <errno.h>
@ -79,7 +84,6 @@
#include <process.h> #include <process.h>
#endif #endif
#ifndef DBUG_OFF #ifndef DBUG_OFF
@ -322,12 +326,11 @@ static unsigned long Clock(void);
#ifdef THREAD #ifdef THREAD
#include <my_pthread.h> #include <my_pthread.h>
pthread_mutex_t THR_LOCK_dbug; static pthread_mutex_t THR_LOCK_dbug;
static CODE_STATE *code_state(void) static CODE_STATE *code_state(void)
{ {
CODE_STATE *cs=0; CODE_STATE *cs, **cs_ptr;
struct st_my_thread_var *tmp;
if (!init_done) if (!init_done)
{ {
@ -338,18 +341,17 @@ static CODE_STATE *code_state(void)
init_done=TRUE; init_done=TRUE;
} }
if ((tmp=my_thread_var)) if (!(cs_ptr= (CODE_STATE**) my_thread_var_dbug()))
return 0; /* Thread not initialised */
if (!(cs= *cs_ptr))
{ {
if (!(cs=(CODE_STATE *) tmp->dbug)) cs=(CODE_STATE*) DbugMalloc(sizeof(*cs));
{ bzero((uchar*) cs,sizeof(*cs));
cs=(CODE_STATE*) DbugMalloc(sizeof(*cs)); cs->process= db_process ? db_process : "dbug";
bzero((uchar*) cs,sizeof(*cs)); cs->func="?func";
cs->process= db_process ? db_process : "dbug"; cs->file="?file";
cs->func="?func"; cs->stack=&init_settings;
cs->file="?file"; *cs_ptr= cs;
cs->stack=&init_settings;
tmp->dbug= (void*) cs;
}
} }
return cs; return cs;
} }

View File

@ -7,7 +7,7 @@ $ctags="exctags -x -f - --c-types=f -u";
sub get_tag { sub get_tag {
local $.; local $_=<TAGS>; local $.; local $_=<TAGS>;
($symbol, $line)= /^(.*\S)\s+function\s+(\d+)/; ($symbol, $line)= /^(.*\S)\s+function\s+(\d+)/;
$symbol=$1 if /\s(\S+)\s*\(/; $symbol=$1 if /[\s*]([^\s*]+)\s*\(/;
$line=1e50 unless $line; $line=1e50 unless $line;
} }
@ -51,7 +51,7 @@ while($src=shift)
$skip=!$semicolon; $skip=!$semicolon;
$semicolon= /;\s*$/; $semicolon= /;\s*$/;
print && next if $skip || print && next if $skip ||
(/^\s+\w+((::\w+)?|<\w+>)\s+\**\w+/ && !/^\s*return/); (/^\s+\w+((::\w+)?|<\w+>)\s+\**\w+/ && !/^\s*return\b/);
last if /DBUG_ENTER/; last if /DBUG_ENTER/;
print "$tab DBUG_ENTER(\"$symbol\");\n"; print "$tab DBUG_ENTER(\"$symbol\");\n";
print "\n" unless $_ eq "\n"; print "\n" unless $_ eq "\n";

View File

@ -26,8 +26,8 @@ pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \
my_getopt.h sslopt-longopts.h my_dir.h \ my_getopt.h sslopt-longopts.h my_dir.h \
sslopt-vars.h sslopt-case.h sql_common.h keycache.h \ sslopt-vars.h sslopt-case.h sql_common.h keycache.h \
m_ctype.h my_attribute.h $(HEADERS_GEN) m_ctype.h my_attribute.h $(HEADERS_GEN)
noinst_HEADERS = config-win.h config-netware.h \ noinst_HEADERS = config-win.h config-netware.h lf.h my_bit.h \
heap.h my_bitmap.h my_uctype.h \ heap.h maria.h myisamchk.h my_bitmap.h my_uctype.h \
myisam.h myisampack.h myisammrg.h ft_global.h\ myisam.h myisampack.h myisammrg.h ft_global.h\
mysys_err.h my_base.h help_start.h help_end.h \ mysys_err.h my_base.h help_start.h help_end.h \
my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \ my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \
@ -36,7 +36,7 @@ noinst_HEADERS = config-win.h config-netware.h \
mysql_version.h.in my_handler.h my_time.h \ mysql_version.h.in my_handler.h my_time.h \
my_vle.h my_user.h my_atomic.h atomic/nolock.h \ my_vle.h my_user.h my_atomic.h atomic/nolock.h \
atomic/rwlock.h atomic/x86-gcc.h atomic/x86-msvc.h \ atomic/rwlock.h atomic/x86-gcc.h atomic/x86-msvc.h \
my_libwrap.h my_libwrap.h wqueue.h
# Remove built files and the symlinked directories # Remove built files and the symlinked directories
CLEANFILES = $(BUILT_SOURCES) readline openssl CLEANFILES = $(BUILT_SOURCES) readline openssl

View File

@ -13,24 +13,25 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#if defined(__i386__) || defined(_M_IX86) #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)
#ifdef MY_ATOMIC_MODE_DUMMY # ifdef MY_ATOMIC_MODE_DUMMY
# define LOCK "" # define LOCK_prefix ""
#else # else
# define LOCK "lock" # define LOCK_prefix "lock"
#endif # endif
#ifdef __GNUC__ # ifdef __GNUC__
#include "x86-gcc.h" # include "x86-gcc.h"
#elif defined(_MSC_VER) # elif defined(_MSC_VER)
#include "x86-msvc.h" # error Broken!
#endif # include "x86-msvc.h"
# endif
#endif #endif
#ifdef make_atomic_cas_body #ifdef make_atomic_cas_body
typedef struct { } my_atomic_rwlock_t; typedef struct { } my_atomic_rwlock_t __attribute__ ((unused));
#define my_atomic_rwlock_destroy(name) #define my_atomic_rwlock_destroy(name)
#define my_atomic_rwlock_init(name) #define my_atomic_rwlock_init(name)
#define my_atomic_rwlock_rdlock(name) #define my_atomic_rwlock_rdlock(name)

View File

@ -13,7 +13,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
typedef struct {pthread_rwlock_t rw;} my_atomic_rwlock_t; typedef struct {pthread_mutex_t rw;} my_atomic_rwlock_t;
#ifdef MY_ATOMIC_MODE_DUMMY #ifdef MY_ATOMIC_MODE_DUMMY
/* /*
@ -31,17 +31,22 @@ typedef struct {pthread_rwlock_t rw;} my_atomic_rwlock_t;
#define my_atomic_rwlock_wrunlock(name) #define my_atomic_rwlock_wrunlock(name)
#define MY_ATOMIC_MODE "dummy (non-atomic)" #define MY_ATOMIC_MODE "dummy (non-atomic)"
#else #else
#define my_atomic_rwlock_destroy(name) pthread_rwlock_destroy(& (name)->rw) /*
#define my_atomic_rwlock_init(name) pthread_rwlock_init(& (name)->rw, 0) we're using read-write lock macros but map them to mutex locks, and they're
#define my_atomic_rwlock_rdlock(name) pthread_rwlock_rdlock(& (name)->rw) faster. Still, having semantically rich API we can change the
#define my_atomic_rwlock_wrlock(name) pthread_rwlock_wrlock(& (name)->rw) underlying implementation, if necessary.
#define my_atomic_rwlock_rdunlock(name) pthread_rwlock_unlock(& (name)->rw) */
#define my_atomic_rwlock_wrunlock(name) pthread_rwlock_unlock(& (name)->rw) #define my_atomic_rwlock_destroy(name) pthread_mutex_destroy(& (name)->rw)
#define MY_ATOMIC_MODE "rwlocks" #define my_atomic_rwlock_init(name) pthread_mutex_init(& (name)->rw, 0)
#define my_atomic_rwlock_rdlock(name) pthread_mutex_lock(& (name)->rw)
#define my_atomic_rwlock_wrlock(name) pthread_mutex_lock(& (name)->rw)
#define my_atomic_rwlock_rdunlock(name) pthread_mutex_unlock(& (name)->rw)
#define my_atomic_rwlock_wrunlock(name) pthread_mutex_unlock(& (name)->rw)
#define MY_ATOMIC_MODE "mutex"
#endif #endif
#define make_atomic_add_body(S) int ## S sav; sav= *a; *a+= v; v=sav; #define make_atomic_add_body(S) int ## S sav; sav= *a; *a+= v; v=sav;
#define make_atomic_swap_body(S) int ## S sav; sav= *a; *a= v; v=sav; #define make_atomic_fas_body(S) int ## S sav; sav= *a; *a= v; v=sav;
#define make_atomic_cas_body(S) if ((ret= (*a == *cmp))) *a= set; else *cmp=*a; #define make_atomic_cas_body(S) if ((ret= (*a == *cmp))) *a= set; else *cmp=*a;
#define make_atomic_load_body(S) ret= *a; #define make_atomic_load_body(S) ret= *a;
#define make_atomic_store_body(S) *a= v; #define make_atomic_store_body(S) *a= v;

View File

@ -19,10 +19,18 @@
architectures support double-word (128-bit) cas. architectures support double-word (128-bit) cas.
*/ */
#ifdef MY_ATOMIC_NO_XADD #ifdef __x86_64__
#define MY_ATOMIC_MODE "gcc-x86" LOCK "-no-xadd" # ifdef MY_ATOMIC_NO_XADD
# define MY_ATOMIC_MODE "gcc-amd64" LOCK_prefix "-no-xadd"
# else
# define MY_ATOMIC_MODE "gcc-amd64" LOCK_prefix
# endif
#else #else
#define MY_ATOMIC_MODE "gcc-x86" LOCK # ifdef MY_ATOMIC_NO_XADD
# define MY_ATOMIC_MODE "gcc-x86" LOCK_prefix "-no-xadd"
# else
# define MY_ATOMIC_MODE "gcc-x86" LOCK_prefix
# endif
#endif #endif
/* fix -ansi errors while maintaining readability */ /* fix -ansi errors while maintaining readability */
@ -32,12 +40,12 @@
#ifndef MY_ATOMIC_NO_XADD #ifndef MY_ATOMIC_NO_XADD
#define make_atomic_add_body(S) \ #define make_atomic_add_body(S) \
asm volatile (LOCK "; xadd %0, %1;" : "+r" (v) , "+m" (*a)) asm volatile (LOCK_prefix "; xadd %0, %1;" : "+r" (v) , "+m" (*a))
#endif #endif
#define make_atomic_swap_body(S) \ #define make_atomic_fas_body(S) \
asm volatile ("; xchg %0, %1;" : "+r" (v) , "+m" (*a)) asm volatile ("xchg %0, %1;" : "+r" (v) , "+m" (*a))
#define make_atomic_cas_body(S) \ #define make_atomic_cas_body(S) \
asm volatile (LOCK "; cmpxchg %3, %0; setz %2;" \ asm volatile (LOCK_prefix "; cmpxchg %3, %0; setz %2;" \
: "+m" (*a), "+a" (*cmp), "=q" (ret): "r" (set)) : "+m" (*a), "+a" (*cmp), "=q" (ret): "r" (set))
#ifdef MY_ATOMIC_MODE_DUMMY #ifdef MY_ATOMIC_MODE_DUMMY
@ -46,13 +54,16 @@
#else #else
/* /*
Actually 32-bit reads/writes are always atomic on x86 Actually 32-bit reads/writes are always atomic on x86
But we add LOCK here anyway to force memory barriers But we add LOCK_prefix here anyway to force memory barriers
*/ */
#define make_atomic_load_body(S) \ #define make_atomic_load_body(S) \
ret=0; \ ret=0; \
asm volatile (LOCK "; cmpxchg %2, %0" \ asm volatile (LOCK_prefix "; cmpxchg %2, %0" \
: "+m" (*a), "+a" (ret): "r" (ret)) : "+m" (*a), "+a" (ret): "r" (ret))
#define make_atomic_store_body(S) \ #define make_atomic_store_body(S) \
asm volatile ("; xchg %0, %1;" : "+m" (*a) : "r" (v)) asm volatile ("; xchg %0, %1;" : "+m" (*a), "+r" (v))
#endif #endif
/* TODO test on intel whether the below helps. on AMD it makes no difference */
//#define LF_BACKOFF ({asm volatile ("rep; nop"); 1; })

View File

@ -25,24 +25,24 @@
#ifndef _atomic_h_cleanup_ #ifndef _atomic_h_cleanup_
#define _atomic_h_cleanup_ "atomic/x86-msvc.h" #define _atomic_h_cleanup_ "atomic/x86-msvc.h"
#define MY_ATOMIC_MODE "msvc-x86" LOCK #define MY_ATOMIC_MODE "msvc-x86" LOCK_prefix
#define make_atomic_add_body(S) \ #define make_atomic_add_body(S) \
_asm { \ _asm { \
_asm mov reg_ ## S, v \ _asm mov reg_ ## S, v \
_asm LOCK xadd *a, reg_ ## S \ _asm LOCK_prefix xadd *a, reg_ ## S \
_asm movzx v, reg_ ## S \ _asm movzx v, reg_ ## S \
} }
#define make_atomic_cas_body(S) \ #define make_atomic_cas_body(S) \
_asm { \ _asm { \
_asm mov areg_ ## S, *cmp \ _asm mov areg_ ## S, *cmp \
_asm mov reg2_ ## S, set \ _asm mov reg2_ ## S, set \
_asm LOCK cmpxchg *a, reg2_ ## S \ _asm LOCK_prefix cmpxchg *a, reg2_ ## S \
_asm mov *cmp, areg_ ## S \ _asm mov *cmp, areg_ ## S \
_asm setz al \ _asm setz al \
_asm movzx ret, al \ _asm movzx ret, al \
} }
#define make_atomic_swap_body(S) \ #define make_atomic_fas_body(S) \
_asm { \ _asm { \
_asm mov reg_ ## S, v \ _asm mov reg_ ## S, v \
_asm xchg *a, reg_ ## S \ _asm xchg *a, reg_ ## S \
@ -55,13 +55,13 @@
#else #else
/* /*
Actually 32-bit reads/writes are always atomic on x86 Actually 32-bit reads/writes are always atomic on x86
But we add LOCK here anyway to force memory barriers But we add LOCK_prefix here anyway to force memory barriers
*/ */
#define make_atomic_load_body(S) \ #define make_atomic_load_body(S) \
_asm { \ _asm { \
_asm mov areg_ ## S, 0 \ _asm mov areg_ ## S, 0 \
_asm mov reg2_ ## S, areg_ ## S \ _asm mov reg2_ ## S, areg_ ## S \
_asm LOCK cmpxchg *a, reg2_ ## S \ _asm LOCK_prefix cmpxchg *a, reg2_ ## S \
_asm mov ret, areg_ ## S \ _asm mov ret, areg_ ## S \
} }
#define make_atomic_store_body(S) \ #define make_atomic_store_body(S) \

View File

@ -65,6 +65,17 @@ void ft_free_stopwords(void);
FT_INFO *ft_init_search(uint,void *, uint, uchar *, uint,CHARSET_INFO *, uchar *); FT_INFO *ft_init_search(uint,void *, uint, uchar *, uint,CHARSET_INFO *, uchar *);
my_bool ft_boolean_check_syntax_string(const uchar *); my_bool ft_boolean_check_syntax_string(const uchar *);
/* Internal symbols for fulltext between maria and MyISAM */
#define HA_FT_WTYPE HA_KEYTYPE_FLOAT
#define HA_FT_WLEN 4
#define FT_SEGS 2
#define ft_sintXkorr(A) mi_sint4korr(A)
#define ft_intXstore(T,A) mi_int4store(T,A)
extern const HA_KEYSEG ft_keysegs[FT_SEGS];
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -132,7 +132,8 @@ extern void end_key_cache(KEY_CACHE *keycache, my_bool cleanup);
/* Functions to handle multiple key caches */ /* Functions to handle multiple key caches */
extern my_bool multi_keycache_init(void); extern my_bool multi_keycache_init(void);
extern void multi_keycache_free(void); extern void multi_keycache_free(void);
extern KEY_CACHE *multi_key_cache_search(uchar *key, uint length); extern KEY_CACHE *multi_key_cache_search(uchar *key, uint length,
KEY_CACHE *def);
extern my_bool multi_key_cache_set(const uchar *key, uint length, extern my_bool multi_key_cache_set(const uchar *key, uint length,
KEY_CACHE *key_cache); KEY_CACHE *key_cache);
extern void multi_key_cache_change(KEY_CACHE *old_data, extern void multi_key_cache_change(KEY_CACHE *old_data,

260
include/lf.h Normal file
View File

@ -0,0 +1,260 @@
/* Copyright (C) 2007 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef _lf_h
#define _lf_h
#include <my_atomic.h>
/*
Helpers to define both func() and _func(), where
func() is a _func() protected by my_atomic_rwlock_wrlock()
*/
#define lock_wrap(f, t, proto_args, args, lock) \
t _ ## f proto_args; \
static inline t f proto_args \
{ \
t ret; \
my_atomic_rwlock_wrlock(lock); \
ret= _ ## f args; \
my_atomic_rwlock_wrunlock(lock); \
return ret; \
}
#define lock_wrap_void(f, proto_args, args, lock) \
void _ ## f proto_args; \
static inline void f proto_args \
{ \
my_atomic_rwlock_wrlock(lock); \
_ ## f args; \
my_atomic_rwlock_wrunlock(lock); \
}
#define nolock_wrap(f, t, proto_args, args) \
t _ ## f proto_args; \
static inline t f proto_args \
{ \
return _ ## f args; \
}
#define nolock_wrap_void(f, proto_args, args) \
void _ ## f proto_args; \
static inline void f proto_args \
{ \
_ ## f args; \
}
/*
wait-free dynamic array, see lf_dynarray.c
4 levels of 256 elements each mean 4311810304 elements in an array - it
should be enough for a while
*/
#define LF_DYNARRAY_LEVEL_LENGTH 256
#define LF_DYNARRAY_LEVELS 4
typedef struct {
void * volatile level[LF_DYNARRAY_LEVELS];
uint size_of_element;
my_atomic_rwlock_t lock;
} LF_DYNARRAY;
typedef int (*lf_dynarray_func)(void *, void *);
void lf_dynarray_init(LF_DYNARRAY *array, uint element_size);
void lf_dynarray_destroy(LF_DYNARRAY *array);
nolock_wrap(lf_dynarray_value, void *,
(LF_DYNARRAY *array, uint idx),
(array, idx))
lock_wrap(lf_dynarray_lvalue, void *,
(LF_DYNARRAY *array, uint idx),
(array, idx),
&array->lock)
nolock_wrap(lf_dynarray_iterate, int,
(LF_DYNARRAY *array, lf_dynarray_func func, void *arg),
(array, func, arg))
/*
pin manager for memory allocator, lf_alloc-pin.c
*/
#define LF_PINBOX_PINS 4
#define LF_PURGATORY_SIZE 10
typedef void lf_pinbox_free_func(void *, void *, void*);
typedef struct {
LF_DYNARRAY pinarray;
lf_pinbox_free_func *free_func;
void *free_func_arg;
uint free_ptr_offset;
uint32 volatile pinstack_top_ver; /* this is a versioned pointer */
uint32 volatile pins_in_array; /* number of elements in array */
} LF_PINBOX;
typedef struct {
void * volatile pin[LF_PINBOX_PINS];
LF_PINBOX *pinbox;
void *stack_ends_here;
void *purgatory;
uint32 purgatory_count;
uint32 volatile link;
/* we want sizeof(LF_PINS) to be 128 to avoid false sharing */
char pad[128-sizeof(uint32)*2
-sizeof(LF_PINBOX *)
-sizeof(void*)
-sizeof(void *)*(LF_PINBOX_PINS+1)];
} LF_PINS;
/*
shortcut macros to do an atomic_wrlock on a structure that uses pins
(e.g. lf_hash).
*/
#define lf_rwlock_by_pins(PINS) \
my_atomic_rwlock_wrlock(&(PINS)->pinbox->pinarray.lock)
#define lf_rwunlock_by_pins(PINS) \
my_atomic_rwlock_wrunlock(&(PINS)->pinbox->pinarray.lock)
/*
compile-time assert, to require "no less than N" pins
it's enough if it'll fail on at least one compiler, so
we'll enable it on GCC only, which supports zero-length arrays.
*/
#if defined(__GNUC__) && defined(MY_LF_EXTRA_DEBUG)
#define LF_REQUIRE_PINS(N) \
static const char require_pins[LF_PINBOX_PINS-N] \
__attribute__ ((unused)); \
static const int LF_NUM_PINS_IN_THIS_FILE= N;
#define _lf_pin(PINS, PIN, ADDR) \
( \
assert(PIN < LF_NUM_PINS_IN_THIS_FILE), \
my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR)) \
)
#else
#define LF_REQUIRE_PINS(N)
#define _lf_pin(PINS, PIN, ADDR) my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR))
#endif
#define _lf_unpin(PINS, PIN) _lf_pin(PINS, PIN, NULL)
#define lf_pin(PINS, PIN, ADDR) \
do { \
lf_rwlock_by_pins(PINS); \
_lf_pin(PINS, PIN, ADDR); \
lf_rwunlock_by_pins(PINS); \
} while (0)
#define lf_unpin(PINS, PIN) lf_pin(PINS, PIN, NULL)
#define _lf_assert_pin(PINS, PIN) assert((PINS)->pin[PIN] != 0)
#define _lf_assert_unpin(PINS, PIN) assert((PINS)->pin[PIN] == 0)
void lf_pinbox_init(LF_PINBOX *pinbox, uint free_ptr_offset,
lf_pinbox_free_func *free_func, void * free_func_arg);
void lf_pinbox_destroy(LF_PINBOX *pinbox);
lock_wrap(lf_pinbox_get_pins, LF_PINS *,
(LF_PINBOX *pinbox, void *stack_end),
(pinbox, stack_end),
&pinbox->pinarray.lock)
lock_wrap_void(lf_pinbox_put_pins,
(LF_PINS *pins),
(pins),
&pins->pinbox->pinarray.lock)
lock_wrap_void(lf_pinbox_free,
(LF_PINS *pins, void *addr),
(pins, addr),
&pins->pinbox->pinarray.lock)
/*
memory allocator, lf_alloc-pin.c
*/
struct st_lf_alloc_node {
struct st_lf_alloc_node *next;
};
typedef struct st_lf_allocator {
LF_PINBOX pinbox;
struct st_lf_alloc_node * volatile top;
uint element_size;
uint32 volatile mallocs;
} LF_ALLOCATOR;
void lf_alloc_init(LF_ALLOCATOR *allocator, uint size, uint free_ptr_offset);
void lf_alloc_destroy(LF_ALLOCATOR *allocator);
uint lf_alloc_pool_count(LF_ALLOCATOR *allocator);
/*
shortcut macros to access underlying pinbox functions from an LF_ALLOCATOR
see _lf_pinbox_get_pins() and _lf_pinbox_put_pins()
*/
#define _lf_alloc_free(PINS, PTR) _lf_pinbox_free((PINS), (PTR))
#define lf_alloc_free(PINS, PTR) lf_pinbox_free((PINS), (PTR))
#define _lf_alloc_get_pins(A, ST) _lf_pinbox_get_pins(&(A)->pinbox, (ST))
#define lf_alloc_get_pins(A, ST) lf_pinbox_get_pins(&(A)->pinbox, (ST))
#define _lf_alloc_put_pins(PINS) _lf_pinbox_put_pins(PINS)
#define lf_alloc_put_pins(PINS) lf_pinbox_put_pins(PINS)
#define lf_alloc_direct_free(ALLOC, ADDR) my_free((uchar*)(ADDR), MYF(0))
lock_wrap(lf_alloc_new, void *,
(LF_PINS *pins),
(pins),
&pins->pinbox->pinarray.lock)
/*
extendible hash, lf_hash.c
*/
#include <hash.h>
#define LF_HASH_UNIQUE 1
typedef struct {
LF_DYNARRAY array; /* hash itself */
LF_ALLOCATOR alloc; /* allocator for elements */
hash_get_key get_key; /* see HASH */
CHARSET_INFO *charset; /* see HASH */
uint key_offset, key_length; /* see HASH */
uint element_size, flags; /* LF_HASH_UNIQUE, etc */
int32 volatile size; /* size of array */
int32 volatile count; /* number of elements in the hash */
} LF_HASH;
void lf_hash_init(LF_HASH *hash, uint element_size, uint flags,
uint key_offset, uint key_length, hash_get_key get_key,
CHARSET_INFO *charset);
void lf_hash_destroy(LF_HASH *hash);
int lf_hash_insert(LF_HASH *hash, LF_PINS *pins, const void *data);
void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen);
int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen);
/*
shortcut macros to access underlying pinbox functions from an LF_HASH
see _lf_pinbox_get_pins() and _lf_pinbox_put_pins()
*/
#define _lf_hash_get_pins(HASH, ST) _lf_alloc_get_pins(&(HASH)->alloc, (ST))
#define lf_hash_get_pins(HASH, ST) lf_alloc_get_pins(&(HASH)->alloc, (ST))
#define _lf_hash_put_pins(PINS) _lf_pinbox_put_pins(PINS)
#define lf_hash_put_pins(PINS) lf_pinbox_put_pins(PINS)
#define lf_hash_search_unpin(PINS) lf_unpin((PINS), 2)
/*
cleanup
*/
#undef lock_wrap_void
#undef lock_wrap
#undef nolock_wrap_void
#undef nolock_wrap
#endif

View File

@ -67,7 +67,7 @@
# define bcopy(s, d, n) memcpy((d), (s), (n)) # define bcopy(s, d, n) memcpy((d), (s), (n))
# define bcmp(A,B,C) memcmp((A),(B),(C)) # define bcmp(A,B,C) memcmp((A),(B),(C))
# define bzero(A,B) memset((A),0,(B)) # define bzero(A,B) memset((A),0,(B))
# define bmove_align(A,B,C) memcpy((A),(B),(C)) # define bmove_align(A,B,C) memcpy((A),(B),(C))
#endif #endif
#if defined(__cplusplus) #if defined(__cplusplus)
@ -129,7 +129,10 @@ extern size_t bcmp(const uchar *s1,const uchar *s2,size_t len);
extern size_t my_bcmp(const uchar *s1,const uchar *s2,size_t len); extern size_t my_bcmp(const uchar *s1,const uchar *s2,size_t len);
#undef bcmp #undef bcmp
#define bcmp(A,B,C) my_bcmp((A),(B),(C)) #define bcmp(A,B,C) my_bcmp((A),(B),(C))
#endif #define bzero_if_purify(A,B) bzero(A,B)
#else
#define bzero_if_purify(A,B)
#endif /* HAVE_purify */
#ifndef bmove512 #ifndef bmove512
extern void bmove512(uchar *dst,const uchar *src,size_t len); extern void bmove512(uchar *dst,const uchar *src,size_t len);

448
include/maria.h Normal file
View File

@ -0,0 +1,448 @@
/* Copyright (C) 2006 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* This file should be included when using maria functions */
#ifndef _maria_h
#define _maria_h
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _my_base_h
#include <my_base.h>
#endif
#ifndef _m_ctype_h
#include <m_ctype.h>
#endif
#include "../storage/maria/ma_pagecache.h"
#include "my_handler.h"
#include "ft_global.h"
#include <myisamchk.h>
#include <mysql/plugin.h>
/*
Limit max keys according to HA_MAX_POSSIBLE_KEY; See myisamchk.h for details
*/
#if MAX_INDEXES > HA_MAX_POSSIBLE_KEY
#define MARIA_MAX_KEY HA_MAX_POSSIBLE_KEY /* Max allowed keys */
#else
#define MARIA_MAX_KEY MAX_INDEXES /* Max allowed keys */
#endif
#define MARIA_MAX_MSG_BUF 1024 /* used in CHECK TABLE, REPAIR TABLE */
#define MARIA_NAME_IEXT ".MAI"
#define MARIA_NAME_DEXT ".MAD"
/* Max extra space to use when sorting keys */
#define MARIA_MAX_TEMP_LENGTH 2*1024L*1024L*1024L
/* Possible values for maria_block_size (must be power of 2) */
#define MARIA_KEY_BLOCK_LENGTH 8192 /* default key block length */
#define MARIA_MIN_KEY_BLOCK_LENGTH 1024 /* Min key block length */
#define MARIA_MAX_KEY_BLOCK_LENGTH 32768
/* Minimal page cache when we only want to be able to scan a table */
#define MARIA_MIN_PAGE_CACHE_SIZE (8192L*16L)
/*
In the following macros '_keyno_' is 0 .. keys-1.
If there can be more keys than bits in the key_map, the highest bit
is for all upper keys. They cannot be switched individually.
This means that clearing of high keys is ignored, setting one high key
sets all high keys.
*/
#define MARIA_KEYMAP_BITS (8 * SIZEOF_LONG_LONG)
#define MARIA_KEYMAP_HIGH_MASK (ULL(1) << (MARIA_KEYMAP_BITS - 1))
#define maria_get_mask_all_keys_active(_keys_) \
(((_keys_) < MARIA_KEYMAP_BITS) ? \
((ULL(1) << (_keys_)) - ULL(1)) : \
(~ ULL(0)))
#if MARIA_MAX_KEY > MARIA_KEYMAP_BITS
#define maria_is_key_active(_keymap_,_keyno_) \
(((_keyno_) < MARIA_KEYMAP_BITS) ? \
test((_keymap_) & (ULL(1) << (_keyno_))) : \
test((_keymap_) & MARIA_KEYMAP_HIGH_MASK))
#define maria_set_key_active(_keymap_,_keyno_) \
(_keymap_)|= (((_keyno_) < MARIA_KEYMAP_BITS) ? \
(ULL(1) << (_keyno_)) : \
MARIA_KEYMAP_HIGH_MASK)
#define maria_clear_key_active(_keymap_,_keyno_) \
(_keymap_)&= (((_keyno_) < MARIA_KEYMAP_BITS) ? \
(~ (ULL(1) << (_keyno_))) : \
(~ (ULL(0))) /*ignore*/ )
#else
#define maria_is_key_active(_keymap_,_keyno_) \
test((_keymap_) & (ULL(1) << (_keyno_)))
#define maria_set_key_active(_keymap_,_keyno_) \
(_keymap_)|= (ULL(1) << (_keyno_))
#define maria_clear_key_active(_keymap_,_keyno_) \
(_keymap_)&= (~ (ULL(1) << (_keyno_)))
#endif
#define maria_is_any_key_active(_keymap_) \
test((_keymap_))
#define maria_is_all_keys_active(_keymap_,_keys_) \
((_keymap_) == maria_get_mask_all_keys_active(_keys_))
#define maria_set_all_keys_active(_keymap_,_keys_) \
(_keymap_)= maria_get_mask_all_keys_active(_keys_)
#define maria_clear_all_keys_active(_keymap_) \
(_keymap_)= 0
#define maria_intersect_keys_active(_to_,_from_) \
(_to_)&= (_from_)
#define maria_is_any_intersect_keys_active(_keymap1_,_keys_,_keymap2_) \
((_keymap1_) & (_keymap2_) & \
maria_get_mask_all_keys_active(_keys_))
#define maria_copy_keys_active(_to_,_maxkeys_,_from_) \
(_to_)= (maria_get_mask_all_keys_active(_maxkeys_) & \
(_from_))
/* Param to/from maria_info */
typedef ulonglong MARIA_RECORD_POS;
typedef struct st_maria_info
{
ha_rows records; /* Records in database */
ha_rows deleted; /* Deleted records in database */
MARIA_RECORD_POS recpos; /* Pos for last used record */
MARIA_RECORD_POS newrecpos; /* Pos if we write new record */
MARIA_RECORD_POS dup_key_pos; /* Position to record with dup key */
my_off_t data_file_length; /* Length of data file */
my_off_t max_data_file_length, index_file_length;
my_off_t max_index_file_length, delete_length;
ulonglong auto_increment;
ulonglong key_map; /* Which keys are used */
time_t create_time; /* When table was created */
time_t check_time;
time_t update_time;
ulong record_offset;
double *rec_per_key; /* for sql optimizing */
ulong reclength; /* Recordlength */
ulong mean_reclength; /* Mean recordlength (if packed) */
char *data_file_name, *index_file_name;
enum data_file_type data_file_type;
uint keys; /* Number of keys in use */
uint options; /* HA_OPTION_... used */
uint reflength;
int errkey, /* With key was dupplicated on err */
sortkey; /* clustered by this key */
File filenr; /* (uniq) filenr for datafile */
} MARIA_INFO;
typedef struct st_maria_create_info
{
const char *index_file_name, *data_file_name; /* If using symlinks */
ha_rows max_rows;
ha_rows reloc_rows;
ulonglong auto_increment;
ulonglong data_file_length;
ulonglong key_file_length;
/* Size of null bitmap at start of row */
uint null_bytes;
uint old_options;
enum data_file_type org_data_file_type;
uint8 language;
my_bool with_auto_increment, transactional;
} MARIA_CREATE_INFO;
struct st_maria_share;
struct st_maria_handler; /* For referense */
typedef struct st_maria_handler MARIA_HA;
struct st_maria_s_param;
typedef struct st_maria_keydef /* Key definition with open & info */
{
struct st_maria_share *share; /* Pointer to base (set in open) */
uint16 keysegs; /* Number of key-segment */
uint16 flag; /* NOSAME, PACK_USED */
uint8 key_alg; /* BTREE, RTREE */
uint8 key_nr; /* key number (auto) */
uint16 block_length; /* Length of keyblock (auto) */
uint16 underflow_block_length; /* When to execute underflow */
uint16 keylength; /* Tot length of keyparts (auto) */
uint16 minlength; /* min length of (packed) key (auto) */
uint16 maxlength; /* max length of (packed) key (auto) */
uint32 write_comp_flag; /* compare flag for write key (auto) */
uint32 version; /* For concurrent read/write */
uint32 ftparser_nr; /* distinct ftparser number */
HA_KEYSEG *seg, *end;
struct st_mysql_ftparser *parser; /* Fulltext [pre]parser */
int (*bin_search)(MARIA_HA *info,
struct st_maria_keydef *keyinfo, uchar *page,
const uchar *key, uint key_len, uint comp_flag,
uchar **ret_pos,
uchar *buff, my_bool *was_last_key);
uint(*get_key)(struct st_maria_keydef *keyinfo, uint nod_flag,
uchar **page, uchar *key);
int (*pack_key)(struct st_maria_keydef *keyinfo, uint nod_flag,
uchar *next_key, uchar *org_key, uchar *prev_key,
const uchar *key, struct st_maria_s_param *s_temp);
void (*store_key)(struct st_maria_keydef *keyinfo, uchar *key_pos,
struct st_maria_s_param *s_temp);
int (*ck_insert)(MARIA_HA *inf, uint k_nr, uchar *k, uint klen);
int (*ck_delete)(MARIA_HA *inf, uint k_nr, uchar *k, uint klen);
} MARIA_KEYDEF;
#define MARIA_UNIQUE_HASH_LENGTH 4
typedef struct st_maria_unique_def /* Segment definition of unique */
{
uint16 keysegs; /* Number of key-segment */
uint8 key; /* Mapped to which key */
uint8 null_are_equal;
HA_KEYSEG *seg, *end;
} MARIA_UNIQUEDEF;
typedef struct st_maria_decode_tree /* Decode huff-table */
{
uint16 *table;
uint quick_table_bits;
uchar *intervalls;
} MARIA_DECODE_TREE;
struct st_maria_bit_buff;
/*
Note that null markers should always be first in a row !
When creating a column, one should only specify:
type, length, null_bit and null_pos
*/
typedef struct st_maria_columndef /* column information */
{
enum en_fieldtype type;
uint32 offset; /* Offset to position in row */
uint16 length; /* length of field */
uint16 column_nr;
/* Intern variable (size of total storage area for the row) */
uint16 fill_length;
uint16 null_pos; /* Position for null marker */
uint16 empty_pos; /* Position for empty marker */
uint8 null_bit; /* If column may be NULL */
/* Intern. Set if column should be zero packed (part of empty_bits) */
uint8 empty_bit;
#ifndef NOT_PACKED_DATABASES
void(*unpack)(struct st_maria_columndef *rec,
struct st_maria_bit_buff *buff,
uchar *start, uchar *end);
enum en_fieldtype base_type;
uint space_length_bits, pack_type;
MARIA_DECODE_TREE *huff_tree;
#endif
} MARIA_COLUMNDEF;
extern ulong maria_block_size, maria_checkpoint_frequency;
extern ulong maria_concurrent_insert;
extern my_bool maria_flush, maria_single_user, maria_page_checksums;
extern my_bool maria_delay_key_write;
extern my_off_t maria_max_temp_length;
extern ulong maria_bulk_insert_tree_size, maria_data_pointer_size;
extern PAGECACHE maria_pagecache_var, *maria_pagecache;
extern MY_TMPDIR *maria_tmpdir;
/* Prototypes for maria-functions */
extern int maria_init(void);
extern void maria_end(void);
extern int maria_close(MARIA_HA *file);
extern int maria_delete(MARIA_HA *file, const uchar *buff);
extern MARIA_HA *maria_open(const char *name, int mode,
uint wait_if_locked);
extern MARIA_HA *maria_clone(struct st_maria_share *share, int mode);
extern int maria_panic(enum ha_panic_function function);
extern int maria_rfirst(MARIA_HA *file, uchar *buf, int inx);
extern int maria_rkey(MARIA_HA *file, uchar *buf, int inx,
const uchar *key, key_part_map keypart_map,
enum ha_rkey_function search_flag);
extern int maria_rlast(MARIA_HA *file, uchar *buf, int inx);
extern int maria_rnext(MARIA_HA *file, uchar *buf, int inx);
extern int maria_rnext_same(MARIA_HA *info, uchar *buf);
extern int maria_rprev(MARIA_HA *file, uchar *buf, int inx);
extern int maria_rrnd(MARIA_HA *file, uchar *buf,
MARIA_RECORD_POS pos);
extern int maria_scan_init(MARIA_HA *file);
extern int maria_scan(MARIA_HA *file, uchar *buf);
extern void maria_scan_end(MARIA_HA *file);
extern int maria_rsame(MARIA_HA *file, uchar *record, int inx);
extern int maria_rsame_with_pos(MARIA_HA *file, uchar *record,
int inx, MARIA_RECORD_POS pos);
extern int maria_update(MARIA_HA *file, const uchar *old,
uchar *new_record);
extern int maria_write(MARIA_HA *file, uchar *buff);
extern MARIA_RECORD_POS maria_position(MARIA_HA *file);
extern int maria_status(MARIA_HA *info, MARIA_INFO *x, uint flag);
extern int maria_lock_database(MARIA_HA *file, int lock_type);
extern int maria_create(const char *name, enum data_file_type record_type,
uint keys, MARIA_KEYDEF *keydef,
uint columns, MARIA_COLUMNDEF *columndef,
uint uniques, MARIA_UNIQUEDEF *uniquedef,
MARIA_CREATE_INFO *create_info, uint flags);
extern int maria_delete_table(const char *name);
extern int maria_rename(const char *from, const char *to);
extern int maria_extra(MARIA_HA *file,
enum ha_extra_function function, void *extra_arg);
extern int maria_reset(MARIA_HA *file);
extern ha_rows maria_records_in_range(MARIA_HA *info, int inx,
key_range *min_key, key_range *max_key);
extern int maria_is_changed(MARIA_HA *info);
extern int maria_delete_all_rows(MARIA_HA *info);
extern uint maria_get_pointer_length(ulonglong file_length, uint def);
extern int maria_commit(MARIA_HA *info);
extern int maria_begin(MARIA_HA *info);
extern void maria_disable_logging(MARIA_HA *info);
extern void maria_enable_logging(MARIA_HA *info);
/* this is used to pass to mysql_mariachk_table */
#define MARIA_CHK_REPAIR 1 /* equivalent to mariachk -r */
#define MARIA_CHK_VERIFY 2 /* Verify, run repair if failure */
typedef uint maria_bit_type;
typedef struct st_maria_bit_buff
{ /* Used for packing of record */
maria_bit_type current_byte;
uint bits;
uchar *pos, *end, *blob_pos, *blob_end;
uint error;
} MARIA_BIT_BUFF;
typedef struct st_maria_sort_info
{
#ifdef THREAD
/* sync things */
pthread_mutex_t mutex;
pthread_cond_t cond;
#endif
MARIA_HA *info, *new_info;
HA_CHECK *param;
char *buff;
SORT_KEY_BLOCKS *key_block, *key_block_end;
SORT_FT_BUF *ft_buf;
my_off_t filelength, dupp, buff_length;
ulonglong page;
ha_rows max_records;
uint current_key, total_keys;
uint got_error, threads_running;
myf myf_rw;
enum data_file_type new_data_file_type, org_data_file_type;
} MARIA_SORT_INFO;
typedef struct st_maria_sort_param
{
pthread_t thr;
IO_CACHE read_cache, tempfile, tempfile_for_exceptions;
DYNAMIC_ARRAY buffpek;
MARIA_BIT_BUFF bit_buff; /* For parallel repair of packrec. */
MARIA_KEYDEF *keyinfo;
MARIA_SORT_INFO *sort_info;
HA_KEYSEG *seg;
uchar **sort_keys;
uchar *rec_buff;
void *wordlist, *wordptr;
MEM_ROOT wordroot;
char *record;
MY_TMPDIR *tmpdir;
/*
The next two are used to collect statistics, see maria_update_key_parts for
description.
*/
ulonglong unique[HA_MAX_KEY_SEG+1];
ulonglong notnull[HA_MAX_KEY_SEG+1];
MARIA_RECORD_POS pos,max_pos,filepos,start_recpos, current_filepos;
uint key, key_length,real_key_length,sortbuff_size;
uint maxbuffers, keys, find_length, sort_keys_length;
my_bool fix_datafile, master;
my_bool calc_checksum; /* calculate table checksum */
size_t rec_buff_size;
int (*key_cmp)(struct st_maria_sort_param *, const void *, const void *);
int (*key_read)(struct st_maria_sort_param *, uchar *);
int (*key_write)(struct st_maria_sort_param *, const uchar *);
void (*lock_in_memory)(HA_CHECK *);
int (*write_keys)(struct st_maria_sort_param *, register uchar **,
uint , struct st_buffpek *, IO_CACHE *);
uint (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint);
int (*write_key)(struct st_maria_sort_param *, IO_CACHE *,uchar *,
uint, uint);
} MARIA_SORT_PARAM;
/* functions in maria_check */
void maria_chk_init(HA_CHECK *param);
int maria_chk_status(HA_CHECK *param, MARIA_HA *info);
int maria_chk_del(HA_CHECK *param, MARIA_HA *info, uint test_flag);
int maria_chk_size(HA_CHECK *param, MARIA_HA *info);
int maria_chk_key(HA_CHECK *param, MARIA_HA *info);
int maria_chk_data_link(HA_CHECK *param, MARIA_HA *info, int extend);
int maria_repair(HA_CHECK *param, MARIA_HA *info, char * name, uint rep_quick);
int maria_sort_index(HA_CHECK *param, MARIA_HA *info, char * name);
int maria_repair_by_sort(HA_CHECK *param, MARIA_HA *info,
const char *name, uint rep_quick);
int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
const char *name, uint rep_quick);
int maria_change_to_newfile(const char *filename, const char *old_ext,
const char *new_ext, myf myflags);
void maria_lock_memory(HA_CHECK *param);
int maria_update_state_info(HA_CHECK *param, MARIA_HA *info, uint update);
void maria_update_key_parts(MARIA_KEYDEF *keyinfo, double *rec_per_key_part,
ulonglong *unique, ulonglong *notnull,
ulonglong records);
int maria_filecopy(HA_CHECK *param, File to, File from, my_off_t start,
my_off_t length, const char *type);
int maria_movepoint(MARIA_HA *info, uchar *record, my_off_t oldpos,
my_off_t newpos, uint prot_key);
int maria_write_data_suffix(MARIA_SORT_INFO *sort_info, my_bool fix_datafile);
int maria_test_if_almost_full(MARIA_HA *info);
int maria_recreate_table(HA_CHECK *param, MARIA_HA **org_info, char *filename);
int maria_disable_indexes(MARIA_HA *info);
int maria_enable_indexes(MARIA_HA *info);
int maria_indexes_are_disabled(MARIA_HA *info);
void maria_disable_non_unique_index(MARIA_HA *info, ha_rows rows);
my_bool maria_test_if_sort_rep(MARIA_HA *info, ha_rows rows, ulonglong key_map,
my_bool force);
int maria_init_bulk_insert(MARIA_HA *info, ulong cache_size, ha_rows rows);
void maria_flush_bulk_insert(MARIA_HA *info, uint inx);
void maria_end_bulk_insert(MARIA_HA *info);
int maria_assign_to_pagecache(MARIA_HA *info, ulonglong key_map,
PAGECACHE *key_cache);
void maria_change_pagecache(PAGECACHE *old_key_cache,
PAGECACHE *new_key_cache);
int maria_preload(MARIA_HA *info, ulonglong key_map, my_bool ignore_leaves);
/* fulltext functions */
FT_INFO *maria_ft_init_search(uint,void *, uint, uchar *, uint,
CHARSET_INFO *, uchar *);
/* 'Almost-internal' Maria functions */
void _ma_update_auto_increment_key(HA_CHECK *param, MARIA_HA *info,
my_bool repair);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -13,6 +13,40 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
This header defines five atomic operations:
my_atomic_add#(&var, what)
add 'what' to *var, and return the old value of *var
my_atomic_fas#(&var, what)
'Fetch And Store'
store 'what' in *var, and return the old value of *var
my_atomic_cas#(&var, &old, new)
'Compare And Swap'
if *var is equal to *old, then store 'new' in *var, and return TRUE
otherwise store *var in *old, and return FALSE
my_atomic_load#(&var)
return *var
my_atomic_store#(&var, what)
store 'what' in *var
'#' is substituted by a size suffix - 8, 16, 32, or ptr
(e.g. my_atomic_add8, my_atomic_fas32, my_atomic_casptr).
NOTE This operations are not always atomic, so they always must be
enclosed in my_atomic_rwlock_rdlock(lock)/my_atomic_rwlock_rdunlock(lock)
or my_atomic_rwlock_wrlock(lock)/my_atomic_rwlock_wrunlock(lock).
Hint: if a code block makes intensive use of atomic ops, it make sense
to take/release rwlock once for the whole block, not for every statement.
On architectures where these operations are really atomic, rwlocks will
be optimized away.
*/
#ifndef my_atomic_rwlock_init #ifndef my_atomic_rwlock_init
#define intptr void * #define intptr void *
@ -26,70 +60,124 @@
#endif #endif
#ifndef make_atomic_add_body #ifndef make_atomic_add_body
#define make_atomic_add_body(S) \ #define make_atomic_add_body(S) \
int ## S tmp=*a; \ int ## S tmp=*a; \
while (!my_atomic_cas ## S(a, &tmp, tmp+v)); \ while (!my_atomic_cas ## S(a, &tmp, tmp+v)); \
v=tmp; v=tmp;
#endif #endif
/*
transparent_union doesn't work in g++
Bug ?
Darwin's gcc doesn't want to put pointers in a transparent_union
when built with -arch ppc64. Complains:
warning: 'transparent_union' attribute ignored
*/
#if defined(__GNUC__) && !defined(__cplusplus) && \
! (defined(__APPLE__) && defined(_ARCH_PPC64))
/*
we want to be able to use my_atomic_xxx functions with
both signed and unsigned integers. But gcc will issue a warning
"passing arg N of `my_atomic_XXX' as [un]signed due to prototype"
if the signedness of the argument doesn't match the prototype, or
"pointer targets in passing argument N of my_atomic_XXX differ in signedness"
if int* is used where uint* is expected (or vice versa).
Let's shut these warnings up
*/
#define make_transparent_unions(S) \
typedef union { \
int ## S i; \
uint ## S u; \
} U_ ## S __attribute__ ((transparent_union)); \
typedef union { \
int ## S volatile *i; \
uint ## S volatile *u; \
} Uv_ ## S __attribute__ ((transparent_union));
#define uintptr intptr
make_transparent_unions(8)
make_transparent_unions(16)
make_transparent_unions(32)
make_transparent_unions(ptr)
#undef uintptr
#undef make_transparent_unions
#define a U_a.i
#define cmp U_cmp.i
#define v U_v.i
#define set U_set.i
#else
#define U_8 int8
#define U_16 int16
#define U_32 int32
#define U_ptr intptr
#define Uv_8 int8
#define Uv_16 int16
#define Uv_32 int32
#define Uv_ptr intptr
#define U_a volatile *a
#define U_cmp *cmp
#define U_v v
#define U_set set
#endif /* __GCC__ transparent_union magic */
#ifdef HAVE_INLINE #ifdef HAVE_INLINE
#define make_atomic_add(S) \ #define make_atomic_add(S) \
static inline int ## S my_atomic_add ## S( \ STATIC_INLINE int ## S my_atomic_add ## S( \
int ## S volatile *a, int ## S v) \ Uv_ ## S U_a, U_ ## S U_v) \
{ \ { \
make_atomic_add_body(S); \ make_atomic_add_body(S); \
return v; \ return v; \
} }
#define make_atomic_swap(S) \ #define make_atomic_fas(S) \
static inline int ## S my_atomic_swap ## S( \ STATIC_INLINE int ## S my_atomic_fas ## S( \
int ## S volatile *a, int ## S v) \ Uv_ ## S U_a, U_ ## S U_v) \
{ \ { \
make_atomic_swap_body(S); \ make_atomic_fas_body(S); \
return v; \ return v; \
} }
#define make_atomic_cas(S) \ #define make_atomic_cas(S) \
static inline int my_atomic_cas ## S(int ## S volatile *a, \ STATIC_INLINE int my_atomic_cas ## S(Uv_ ## S U_a, \
int ## S *cmp, int ## S set) \ Uv_ ## S U_cmp, U_ ## S U_set) \
{ \ { \
int8 ret; \ int8 ret; \
make_atomic_cas_body(S); \ make_atomic_cas_body(S); \
return ret; \ return ret; \
} }
#define make_atomic_load(S) \ #define make_atomic_load(S) \
static inline int ## S my_atomic_load ## S(int ## S volatile *a) \ STATIC_INLINE int ## S my_atomic_load ## S(Uv_ ## S U_a) \
{ \ { \
int ## S ret; \ int ## S ret; \
make_atomic_load_body(S); \ make_atomic_load_body(S); \
return ret; \ return ret; \
} }
#define make_atomic_store(S) \ #define make_atomic_store(S) \
static inline void my_atomic_store ## S( \ STATIC_INLINE void my_atomic_store ## S( \
int ## S volatile *a, int ## S v) \ Uv_ ## S U_a, U_ ## S U_v) \
{ \ { \
make_atomic_store_body(S); \ make_atomic_store_body(S); \
} }
#else /* no inline functions */ #else /* no inline functions */
#define make_atomic_add(S) \ #define make_atomic_add(S) \
extern int ## S my_atomic_add ## S(int ## S volatile *a, int ## S v); extern int ## S my_atomic_add ## S(Uv_ ## S, U_ ## S);
#define make_atomic_swap(S) \ #define make_atomic_fas(S) \
extern int ## S my_atomic_swap ## S(int ## S volatile *a, int ## S v); extern int ## S my_atomic_fas ## S(Uv_ ## S, U_ ## S);
#define make_atomic_cas(S) \ #define make_atomic_cas(S) \
extern int my_atomic_cas ## S(int ## S volatile *a, int ## S *cmp, int ## S set); extern int my_atomic_cas ## S(Uv_ ## S, Uv_ ## S, U_ ## S);
#define make_atomic_load(S) \ #define make_atomic_load(S) \
extern int ## S my_atomic_load ## S(int ## S volatile *a); extern int ## S my_atomic_load ## S(Uv_ ## S);
#define make_atomic_store(S) \ #define make_atomic_store(S) \
extern void my_atomic_store ## S(int ## S volatile *a, int ## S v); extern void my_atomic_store ## S(Uv_ ## S, U_ ## S);
#endif #endif
@ -112,28 +200,49 @@ make_atomic_store(16)
make_atomic_store(32) make_atomic_store(32)
make_atomic_store(ptr) make_atomic_store(ptr)
make_atomic_swap( 8) make_atomic_fas( 8)
make_atomic_swap(16) make_atomic_fas(16)
make_atomic_swap(32) make_atomic_fas(32)
make_atomic_swap(ptr) make_atomic_fas(ptr)
#undef make_atomic_add
#undef make_atomic_cas
#undef make_atomic_load
#undef make_atomic_store
#undef make_atomic_swap
#undef make_atomic_add_body
#undef make_atomic_cas_body
#undef make_atomic_load_body
#undef make_atomic_store_body
#undef make_atomic_swap_body
#undef intptr
#ifdef _atomic_h_cleanup_ #ifdef _atomic_h_cleanup_
#include _atomic_h_cleanup_ #include _atomic_h_cleanup_
#undef _atomic_h_cleanup_ #undef _atomic_h_cleanup_
#endif #endif
#undef U_8
#undef U_16
#undef U_32
#undef U_ptr
#undef a
#undef cmp
#undef v
#undef set
#undef U_a
#undef U_cmp
#undef U_v
#undef U_set
#undef make_atomic_add
#undef make_atomic_cas
#undef make_atomic_load
#undef make_atomic_store
#undef make_atomic_fas
#undef make_atomic_add_body
#undef make_atomic_cas_body
#undef make_atomic_load_body
#undef make_atomic_store_body
#undef make_atomic_fas_body
#undef intptr
/*
the macro below defines (as an expression) the code that
will be run in spin-loops. Intel manuals recummend to have PAUSE there.
It is expected to be defined in include/atomic/ *.h files
*/
#ifndef LF_BACKOFF
#define LF_BACKOFF (1)
#endif
#define MY_ATOMIC_OK 0 #define MY_ATOMIC_OK 0
#define MY_ATOMIC_NOT_1CPU 1 #define MY_ATOMIC_NOT_1CPU 1
extern int my_atomic_initialize(); extern int my_atomic_initialize();

View File

@ -14,7 +14,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* This file includes constants used with all databases */ /* This file includes constants used with all databases */
/* Author: Michael Widenius */
#ifndef _my_base_h #ifndef _my_base_h
#define _my_base_h #define _my_base_h
@ -48,10 +47,11 @@
#define HA_OPEN_FOR_REPAIR 32 /* open even if crashed */ #define HA_OPEN_FOR_REPAIR 32 /* open even if crashed */
#define HA_OPEN_FROM_SQL_LAYER 64 #define HA_OPEN_FROM_SQL_LAYER 64
#define HA_OPEN_MMAP 128 /* open memory mapped */ #define HA_OPEN_MMAP 128 /* open memory mapped */
#define HA_OPEN_COPY 256 /* Open copy (for repair) */
/* Internal temp table, used for temporary results */ /* Internal temp table, used for temporary results */
#define HA_OPEN_INTERNAL_TABLE 256 #define HA_OPEN_INTERNAL_TABLE 512
/* The following is parameter to ha_rkey() how to use key */ /* The following is parameter to ha_rkey() how to use key */
/* /*
We define a complete-field prefix of a key value as a prefix where We define a complete-field prefix of a key value as a prefix where
@ -137,7 +137,7 @@ enum ha_extra_function {
HA_EXTRA_RESET_STATE, /* Reset positions */ HA_EXTRA_RESET_STATE, /* Reset positions */
HA_EXTRA_IGNORE_DUP_KEY, /* Dup keys don't rollback everything*/ HA_EXTRA_IGNORE_DUP_KEY, /* Dup keys don't rollback everything*/
HA_EXTRA_NO_IGNORE_DUP_KEY, HA_EXTRA_NO_IGNORE_DUP_KEY,
HA_EXTRA_PREPARE_FOR_DELETE, HA_EXTRA_PREPARE_FOR_DROP,
HA_EXTRA_PREPARE_FOR_UPDATE, /* Remove read cache if problems */ HA_EXTRA_PREPARE_FOR_UPDATE, /* Remove read cache if problems */
HA_EXTRA_PRELOAD_BUFFER_SIZE, /* Set buffer size for preloading */ HA_EXTRA_PRELOAD_BUFFER_SIZE, /* Set buffer size for preloading */
/* /*
@ -193,7 +193,9 @@ enum ha_extra_function {
begin and end of a statement. begin and end of a statement.
*/ */
HA_EXTRA_ATTACH_CHILDREN, HA_EXTRA_ATTACH_CHILDREN,
HA_EXTRA_DETACH_CHILDREN HA_EXTRA_DETACH_CHILDREN,
/* Inform handler that we will do a rename */
HA_EXTRA_PREPARE_FOR_RENAME
}; };
/* The following is parameter to ha_panic() */ /* The following is parameter to ha_panic() */
@ -300,8 +302,12 @@ enum ha_base_keytype {
#define HA_OPTION_NO_PACK_KEYS 128 /* Reserved for MySQL */ #define HA_OPTION_NO_PACK_KEYS 128 /* Reserved for MySQL */
#define HA_OPTION_CREATE_FROM_ENGINE 256 #define HA_OPTION_CREATE_FROM_ENGINE 256
#define HA_OPTION_RELIES_ON_SQL_LAYER 512 #define HA_OPTION_RELIES_ON_SQL_LAYER 512
#define HA_OPTION_TEMP_COMPRESS_RECORD ((uint) 16384) /* set by isamchk */ #define HA_OPTION_NULL_FIELDS 1024
#define HA_OPTION_READ_ONLY_DATA ((uint) 32768) /* Set by isamchk */ #define HA_OPTION_PAGE_CHECKSUM 2048
#define HA_OPTION_TEMP_COMPRESS_RECORD (1L << 15) /* set by isamchk */
#define HA_OPTION_READ_ONLY_DATA (1L << 16) /* Set by isamchk */
#define HA_OPTION_NO_CHECKSUM (1L << 17)
#define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18)
/* Bits in flag to create() */ /* Bits in flag to create() */
@ -310,6 +316,7 @@ enum ha_base_keytype {
#define HA_CREATE_TMP_TABLE 4 #define HA_CREATE_TMP_TABLE 4
#define HA_CREATE_CHECKSUM 8 #define HA_CREATE_CHECKSUM 8
#define HA_CREATE_KEEP_FILES 16 /* don't overwrite .MYD and MYI */ #define HA_CREATE_KEEP_FILES 16 /* don't overwrite .MYD and MYI */
#define HA_CREATE_PAGE_CHECKSUM 32
#define HA_CREATE_DELAY_KEY_WRITE 64 #define HA_CREATE_DELAY_KEY_WRITE 64
#define HA_CREATE_RELIES_ON_SQL_LAYER 128 #define HA_CREATE_RELIES_ON_SQL_LAYER 128
@ -356,14 +363,18 @@ enum ha_base_keytype {
*/ */
#define HA_STATUS_AUTO 64 #define HA_STATUS_AUTO 64
/* Errorcodes given by functions */ /*
Errorcodes given by handler functions
opt_sum_query() assumes these codes are > 1
Do not add error numbers before HA_ERR_FIRST.
If necessary to add lower numbers, change HA_ERR_FIRST accordingly.
*/
#define HA_ERR_FIRST 120 /* Copy of first error nr.*/
/* opt_sum_query() assumes these codes are > 1 */
/* Do not add error numbers before HA_ERR_FIRST. */
/* If necessary to add lower numbers, change HA_ERR_FIRST accordingly. */
#define HA_ERR_FIRST 120 /*Copy first error nr.*/
#define HA_ERR_KEY_NOT_FOUND 120 /* Didn't find key on read or update */ #define HA_ERR_KEY_NOT_FOUND 120 /* Didn't find key on read or update */
#define HA_ERR_FOUND_DUPP_KEY 121 /* Dupplicate key on write */ #define HA_ERR_FOUND_DUPP_KEY 121 /* Dupplicate key on write */
#define HA_ERR_INTERNAL_ERROR 122 /* Internal error */
#define HA_ERR_RECORD_CHANGED 123 /* Uppdate with is recoverable */ #define HA_ERR_RECORD_CHANGED 123 /* Uppdate with is recoverable */
#define HA_ERR_WRONG_INDEX 124 /* Wrong index given to function */ #define HA_ERR_WRONG_INDEX 124 /* Wrong index given to function */
#define HA_ERR_CRASHED 126 /* Indexfile is crashed */ #define HA_ERR_CRASHED 126 /* Indexfile is crashed */
@ -382,7 +393,7 @@ enum ha_base_keytype {
#define HA_WRONG_CREATE_OPTION 140 /* Wrong create option */ #define HA_WRONG_CREATE_OPTION 140 /* Wrong create option */
#define HA_ERR_FOUND_DUPP_UNIQUE 141 /* Dupplicate unique on write */ #define HA_ERR_FOUND_DUPP_UNIQUE 141 /* Dupplicate unique on write */
#define HA_ERR_UNKNOWN_CHARSET 142 /* Can't open charset */ #define HA_ERR_UNKNOWN_CHARSET 142 /* Can't open charset */
#define HA_ERR_WRONG_MRG_TABLE_DEF 143 /* conflicting MyISAM tables in MERGE */ #define HA_ERR_WRONG_MRG_TABLE_DEF 143 /* conflicting tables in MERGE */
#define HA_ERR_CRASHED_ON_REPAIR 144 /* Last (automatic?) repair failed */ #define HA_ERR_CRASHED_ON_REPAIR 144 /* Last (automatic?) repair failed */
#define HA_ERR_CRASHED_ON_USAGE 145 /* Table must be repaired */ #define HA_ERR_CRASHED_ON_USAGE 145 /* Table must be repaired */
#define HA_ERR_LOCK_WAIT_TIMEOUT 146 #define HA_ERR_LOCK_WAIT_TIMEOUT 146
@ -397,30 +408,38 @@ enum ha_base_keytype {
#define HA_ERR_NO_SUCH_TABLE 155 /* The table does not exist in engine */ #define HA_ERR_NO_SUCH_TABLE 155 /* The table does not exist in engine */
#define HA_ERR_TABLE_EXIST 156 /* The table existed in storage engine */ #define HA_ERR_TABLE_EXIST 156 /* The table existed in storage engine */
#define HA_ERR_NO_CONNECTION 157 /* Could not connect to storage engine */ #define HA_ERR_NO_CONNECTION 157 /* Could not connect to storage engine */
#define HA_ERR_NULL_IN_SPATIAL 158 /* NULLs are not supported in spatial index */ /* NULLs are not supported in spatial index */
#define HA_ERR_NULL_IN_SPATIAL 158
#define HA_ERR_TABLE_DEF_CHANGED 159 /* The table changed in storage engine */ #define HA_ERR_TABLE_DEF_CHANGED 159 /* The table changed in storage engine */
#define HA_ERR_NO_PARTITION_FOUND 160 /* There's no partition in table for #define HA_ERR_NO_PARTITION_FOUND 160 /* There's no partition in table for
given value */ given value */
#define HA_ERR_RBR_LOGGING_FAILED 161 /* Row-based binlogging of row failed */ #define HA_ERR_RBR_LOGGING_FAILED 161 /* Row-based binlogging of row failed */
#define HA_ERR_DROP_INDEX_FK 162 /* Index needed in foreign key constr. */ #define HA_ERR_DROP_INDEX_FK 162 /* Index needed in foreign key constr */
#define HA_ERR_FOREIGN_DUPLICATE_KEY 163 /* Upholding foreign key constraints /*
would lead to a duplicate key Upholding foreign key constraints would lead to a duplicate key error
error in some other table. */ in some other table.
#define HA_ERR_TABLE_NEEDS_UPGRADE 164 /* The table changed in storage engine */ */
#define HA_ERR_TABLE_READONLY 165 /* The table is not writable */ #define HA_ERR_FOREIGN_DUPLICATE_KEY 163
/* The table changed in storage engine */
#define HA_ERR_TABLE_NEEDS_UPGRADE 164
#define HA_ERR_TABLE_READONLY 165 /* The table is not writable */
#define HA_ERR_AUTOINC_READ_FAILED 166 /* Failed to get next autoinc value */ #define HA_ERR_AUTOINC_READ_FAILED 166 /* Failed to get next autoinc value */
#define HA_ERR_AUTOINC_ERANGE 167 /* Failed to set row autoinc value */ #define HA_ERR_AUTOINC_ERANGE 167 /* Failed to set row autoinc value */
#define HA_ERR_GENERIC 168 /* Generic error */ #define HA_ERR_GENERIC 168 /* Generic error */
#define HA_ERR_RECORD_IS_THE_SAME 169 /* row not actually updated : /* row not actually updated: new values same as the old values */
new values same as the old values */ #define HA_ERR_RECORD_IS_THE_SAME 169
/* It is not possible to log this statement */
#define HA_ERR_LOGGING_IMPOSSIBLE 170 /* It is not possible to log this #define HA_ERR_LOGGING_IMPOSSIBLE 170
statement */
#define HA_ERR_CORRUPT_EVENT 171 /* The event was corrupt, leading to #define HA_ERR_CORRUPT_EVENT 171 /* The event was corrupt, leading to
illegal data being read */ illegal data being read */
#define HA_ERR_LAST 171 /*Copy last error nr.*/ #define HA_ERR_NEW_FILE 172 /* New file format */
/* Add error numbers before HA_ERR_LAST and change it accordingly. */ #define HA_ERR_INITIALIZATION 173 /* Error during initialization */
#define HA_ERR_FILE_TOO_SHORT 174 /* File too short */
#define HA_ERR_WRONG_CRC 175 /* Wrong CRC on page */
#define HA_ERR_LAST 175 /* Copy of last error nr */
/* Number of different errors */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1) #define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
/* Other constants */ /* Other constants */
@ -484,7 +503,7 @@ enum en_fieldtype {
}; };
enum data_file_type { enum data_file_type {
STATIC_RECORD,DYNAMIC_RECORD,COMPRESSED_RECORD STATIC_RECORD, DYNAMIC_RECORD, COMPRESSED_RECORD, BLOCK_RECORD
}; };
/* For key ranges */ /* For key ranges */
@ -536,4 +555,7 @@ typedef ulong ha_rows;
#define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 :2) #define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 :2)
/* invalidator function reference for Query Cache */
typedef void (* invalidator_by_filename)(const char * filename);
#endif /* _my_base_h */ #endif /* _my_base_h */

107
include/my_bit.h Normal file
View File

@ -0,0 +1,107 @@
/*
Some useful bit functions
*/
#ifdef HAVE_INLINE
extern const char _my_bits_nbits[256];
extern const uchar _my_bits_reverse_table[256];
/*
Find smallest X in 2^X >= value
This can be used to divide a number with value by doing a shift instead
*/
STATIC_INLINE uint my_bit_log2(ulong value)
{
uint bit;
for (bit=0 ; value > 1 ; value>>=1, bit++) ;
return bit;
}
STATIC_INLINE uint my_count_bits(ulonglong v)
{
#if SIZEOF_LONG_LONG > 4
/* The following code is a bit faster on 16 bit machines than if we would
only shift v */
ulong v2=(ulong) (v >> 32);
return (uint) (uchar) (_my_bits_nbits[(uchar) v] +
_my_bits_nbits[(uchar) (v >> 8)] +
_my_bits_nbits[(uchar) (v >> 16)] +
_my_bits_nbits[(uchar) (v >> 24)] +
_my_bits_nbits[(uchar) (v2)] +
_my_bits_nbits[(uchar) (v2 >> 8)] +
_my_bits_nbits[(uchar) (v2 >> 16)] +
_my_bits_nbits[(uchar) (v2 >> 24)]);
#else
return (uint) (uchar) (_my_bits_nbits[(uchar) v] +
_my_bits_nbits[(uchar) (v >> 8)] +
_my_bits_nbits[(uchar) (v >> 16)] +
_my_bits_nbits[(uchar) (v >> 24)]);
#endif
}
STATIC_INLINE uint my_count_bits_ushort(ushort v)
{
return _my_bits_nbits[v];
}
/*
Next highest power of two
SYNOPSIS
my_round_up_to_next_power()
v Value to check
RETURN
Next or equal power of 2
Note: 0 will return 0
NOTES
Algorithm by Sean Anderson, according to:
http://graphics.stanford.edu/~seander/bithacks.html
(Orignal code public domain)
Comments shows how this works with 01100000000000000000000000001011
*/
STATIC_INLINE uint32 my_round_up_to_next_power(uint32 v)
{
v--; /* 01100000000000000000000000001010 */
v|= v >> 1; /* 01110000000000000000000000001111 */
v|= v >> 2; /* 01111100000000000000000000001111 */
v|= v >> 4; /* 01111111110000000000000000001111 */
v|= v >> 8; /* 01111111111111111100000000001111 */
v|= v >> 16; /* 01111111111111111111111111111111 */
return v+1; /* 10000000000000000000000000000000 */
}
STATIC_INLINE uint32 my_clear_highest_bit(uint32 v)
{
uint32 w=v >> 1;
w|= w >> 1;
w|= w >> 2;
w|= w >> 4;
w|= w >> 8;
w|= w >> 16;
return v & w;
}
STATIC_INLINE uint32 my_reverse_bits(uint32 key)
{
return
(_my_bits_reverse_table[ key & 255] << 24) |
(_my_bits_reverse_table[(key>> 8) & 255] << 16) |
(_my_bits_reverse_table[(key>>16) & 255] << 8) |
_my_bits_reverse_table[(key>>24) ];
}
#else
extern uint my_bit_log2(ulong value);
extern uint32 my_round_up_to_next_power(uint32 v);
uint32 my_clear_highest_bit(uint32 v);
uint32 my_reverse_bits(uint32 key);
extern uint my_count_bits(ulonglong v);
extern uint my_count_bits_ushort(ushort v);
#endif

View File

@ -101,7 +101,7 @@ extern FILE *_db_fp_(void);
#define DBUG_LONGJMP(a1) longjmp(a1) #define DBUG_LONGJMP(a1) longjmp(a1)
#define DBUG_DUMP(keyword,a1,a2) #define DBUG_DUMP(keyword,a1,a2)
#define DBUG_END() #define DBUG_END()
#define DBUG_ASSERT(A) #define DBUG_ASSERT(A) do { } while(0)
#define DBUG_LOCK_FILE #define DBUG_LOCK_FILE
#define DBUG_FILE (stderr) #define DBUG_FILE (stderr)
#define DBUG_UNLOCK_FILE #define DBUG_UNLOCK_FILE

View File

@ -242,6 +242,8 @@
#endif #endif
#undef inline_test_2 #undef inline_test_2
#undef inline_test_1 #undef inline_test_1
/* helper macro for "instantiating" inline functions */
#define STATIC_INLINE static inline
/* /*
The following macros are used to control inlining a bit more than The following macros are used to control inlining a bit more than
@ -429,6 +431,9 @@ C_MODE_END
#ifdef HAVE_FCNTL_H #ifdef HAVE_FCNTL_H
#include <fcntl.h> #include <fcntl.h>
#endif #endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_SYS_TIMEB_H #ifdef HAVE_SYS_TIMEB_H
#include <sys/timeb.h> /* Avoid warnings on SCO */ #include <sys/timeb.h> /* Avoid warnings on SCO */
#endif #endif
@ -571,7 +576,7 @@ typedef unsigned short ushort;
#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1) #define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
#define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0) #define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
#define swap_variables(t, a, b) { register t dummy; dummy= a; a= b; b= dummy; } #define swap_variables(t, a, b) { register t swap_dummy; swap_dummy= a; a= b; b= swap_dummy; }
#define test(a) ((a) ? 1 : 0) #define test(a) ((a) ? 1 : 0)
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0) #define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0) #define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
@ -1015,6 +1020,8 @@ typedef long long intptr;
#error sizeof(void *) is neither sizeof(int) nor sizeof(long) nor sizeof(long long) #error sizeof(void *) is neither sizeof(int) nor sizeof(long) nor sizeof(long long)
#endif #endif
#define MY_ERRPTR ((void*)(intptr)1)
#ifdef USE_RAID #ifdef USE_RAID
/* /*
The following is done with a if to not get problems with pre-processors The following is done with a if to not get problems with pre-processors
@ -1476,6 +1483,7 @@ do { doubleget_union _tmp; \
#define dlerror() "" #define dlerror() ""
#endif #endif
#ifndef __NETWARE__ #ifndef __NETWARE__
/* /*
* Include standard definitions of operator new and delete. * Include standard definitions of operator new and delete.
@ -1506,6 +1514,13 @@ inline void operator delete[](void*, void*) { /* Do nothing */ }
#if !defined(max) #if !defined(max)
#define max(a, b) ((a) > (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b))
#endif
/*
Only Linux is known to need an explicit sync of the directory to make sure a
file creation/deletion/renaming in(from,to) this directory durable.
*/
#ifdef TARGET_OS_LINUX
#define NEED_EXPLICIT_SYNC_DIR 1
#endif #endif
#endif /* my_global_h */ #endif /* my_global_h */

View File

@ -18,10 +18,30 @@
#ifndef _my_handler_h #ifndef _my_handler_h
#define _my_handler_h #define _my_handler_h
#include "my_base.h"
#include "m_ctype.h"
#include "myisampack.h" #include "myisampack.h"
/*
There is a hard limit for the maximum number of keys as there are only
8 bits in the index file header for the number of keys in a table.
This means that 0..255 keys can exist for a table. The idea of
HA_MAX_POSSIBLE_KEY is to ensure that one can use myisamchk & tools on
a MyISAM table for which one has more keys than MyISAM is normally
compiled for. If you don't have this, you will get a core dump when
running myisamchk compiled for 128 keys on a table with 255 keys.
*/
#define HA_MAX_POSSIBLE_KEY 255 /* For myisamchk */
/*
The following defines can be increased if necessary.
But beware the dependency of HA_MAX_POSSIBLE_KEY_BUFF and HA_MAX_KEY_LENGTH.
*/
#define HA_MAX_KEY_LENGTH 1000 /* Max length in bytes */
#define HA_MAX_KEY_SEG 16 /* Max segments for key */
#define HA_MAX_POSSIBLE_KEY_BUFF (HA_MAX_KEY_LENGTH + 24+ 6+6)
#define HA_MAX_KEY_BUFF (HA_MAX_KEY_LENGTH+HA_MAX_KEY_SEG*6+8+8)
typedef struct st_HA_KEYSEG /* Key-portion */ typedef struct st_HA_KEYSEG /* Key-portion */
{ {
CHARSET_INFO *charset; CHARSET_INFO *charset;
@ -38,33 +58,35 @@ typedef struct st_HA_KEYSEG /* Key-portion */
} HA_KEYSEG; } HA_KEYSEG;
#define get_key_length(length,key) \ #define get_key_length(length,key) \
{ if ((uchar) *(key) != 255) \ { if (*(uchar*) (key) != 255) \
length= (uint) (uchar) *((key)++); \ length= (uint) *(uchar*) ((key)++); \
else \ else \
{ length=mi_uint2korr((key)+1); (key)+=3; } \ { length= mi_uint2korr((key)+1); (key)+=3; } \
} }
#define get_key_length_rdonly(length,key) \ #define get_key_length_rdonly(length,key) \
{ if ((uchar) *(key) != 255) \ { if (*(uchar*) (key) != 255) \
length= ((uint) (uchar) *((key))); \ length= ((uint) *(uchar*) ((key))); \
else \ else \
{ length=mi_uint2korr((key)+1); } \ { length= mi_uint2korr((key)+1); } \
} }
#define get_key_pack_length(length,length_pack,key) \ #define get_key_pack_length(length,length_pack,key) \
{ if ((uchar) *(key) != 255) \ { if (*(uchar*) (key) != 255) \
{ length= (uint) (uchar) *((key)++); length_pack=1; }\ { length= (uint) *(uchar*) ((key)++); length_pack= 1; }\
else \ else \
{ length=mi_uint2korr((key)+1); (key)+=3; length_pack=3; } \ { length=mi_uint2korr((key)+1); (key)+= 3; length_pack= 3; } \
} }
#define store_key_length_inc(key,length) \ #define store_key_length_inc(key,length) \
{ if ((length) < 255) \ { if ((length) < 255) \
{ *(key)++=(length); } \ { *(key)++= (length); } \
else \ else \
{ *(key)=255; mi_int2store((key)+1,(length)); (key)+=3; } \ { *(key)=255; mi_int2store((key)+1,(length)); (key)+=3; } \
} }
#define size_to_store_key_length(length) ((length) < 255 ? 1 : 3)
#define get_rec_bits(bit_ptr, bit_ofs, bit_len) \ #define get_rec_bits(bit_ptr, bit_ofs, bit_len) \
(((((uint16) (bit_ptr)[1] << 8) | (uint16) (bit_ptr)[0]) >> (bit_ofs)) & \ (((((uint16) (bit_ptr)[1] << 8) | (uint16) (bit_ptr)[0]) >> (bit_ofs)) & \
((1 << (bit_len)) - 1)) ((1 << (bit_len)) - 1))
@ -81,12 +103,20 @@ typedef struct st_HA_KEYSEG /* Key-portion */
#define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \ #define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \
set_rec_bits(0, bit_ptr, bit_ofs, bit_len) set_rec_bits(0, bit_ptr, bit_ofs, bit_len)
extern int mi_compare_text(CHARSET_INFO *, uchar *, uint, uchar *, uint , extern int ha_compare_text(CHARSET_INFO *, const uchar *, uint,
my_bool, my_bool); const uchar *, uint , my_bool, my_bool);
extern int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, extern int ha_key_cmp(register HA_KEYSEG *keyseg, register const uchar *a,
register uchar *b, uint key_length, uint nextflag, register const uchar *b, uint key_length, uint nextflag,
uint *diff_pos); uint *diff_pos);
extern HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a); extern HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a);
extern void my_handler_error_register(void);
extern void my_handler_error_unregister(void);
/*
Inside an in-memory data record, memory pointers to pieces of the
record (like BLOBs) are stored in their native byte order and in
this amount of bytes.
*/
#define portable_sizeof_char_ptr 8
#endif /* _my_handler_h */ #endif /* _my_handler_h */

View File

@ -172,6 +172,7 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
#define pthread_detach_this_thread() #define pthread_detach_this_thread()
#define pthread_condattr_init(A) #define pthread_condattr_init(A)
#define pthread_condattr_destroy(A) #define pthread_condattr_destroy(A)
#define pthread_yield() Sleep(0) /* according to MSDN */
#define my_pthread_getprio(thread_id) pthread_dummy(0) #define my_pthread_getprio(thread_id) pthread_dummy(0)
@ -397,6 +398,17 @@ void my_pthread_attr_getstacksize(pthread_attr_t *attrib, size_t *size);
int my_pthread_mutex_trylock(pthread_mutex_t *mutex); int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
#endif #endif
#if !defined(HAVE_PTHREAD_YIELD_ONE_ARG) && !defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
/* no pthread_yield() available */
#ifdef HAVE_SCHED_YIELD
#define pthread_yield() sched_yield()
#elif defined(HAVE_PTHREAD_YIELD_NP) /* can be Mac OS X */
#define pthread_yield() pthread_yield_np()
#elif defined(HAVE_THR_YIELD)
#define pthread_yield() thr_yield()
#endif
#endif
/* /*
The defines set_timespec and set_timespec_nsec should be used The defines set_timespec and set_timespec_nsec should be used
for calculating an absolute time at which for calculating an absolute time at which
@ -447,7 +459,7 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
typedef struct st_safe_mutex_t typedef struct st_safe_mutex_t
{ {
pthread_mutex_t global,mutex; pthread_mutex_t global,mutex;
const char *file; const char *file, *name;
uint line,count; uint line,count;
pthread_t thread; pthread_t thread;
#ifdef SAFE_MUTEX_DETECT_DESTROY #ifdef SAFE_MUTEX_DETECT_DESTROY
@ -472,7 +484,7 @@ typedef struct st_safe_mutex_info_t
#endif /* SAFE_MUTEX_DETECT_DESTROY */ #endif /* SAFE_MUTEX_DETECT_DESTROY */
int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr, int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr,
const char *file, uint line); const char *file, uint line, const char *name);
int safe_mutex_lock(safe_mutex_t *mp, my_bool try_lock, const char *file, uint line); int safe_mutex_lock(safe_mutex_t *mp, my_bool try_lock, const char *file, uint line);
int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line); int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line);
int safe_mutex_destroy(safe_mutex_t *mp,const char *file, uint line); int safe_mutex_destroy(safe_mutex_t *mp,const char *file, uint line);
@ -495,7 +507,7 @@ void safe_mutex_end(FILE *file);
#undef pthread_cond_wait #undef pthread_cond_wait
#undef pthread_cond_timedwait #undef pthread_cond_timedwait
#undef pthread_mutex_trylock #undef pthread_mutex_trylock
#define pthread_mutex_init(A,B) safe_mutex_init((A),(B),__FILE__,__LINE__) #define pthread_mutex_init(A,B) safe_mutex_init((A),(B),__FILE__,__LINE__,#A)
#define pthread_mutex_lock(A) safe_mutex_lock((A), FALSE, __FILE__, __LINE__) #define pthread_mutex_lock(A) safe_mutex_lock((A), FALSE, __FILE__, __LINE__)
#define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__) #define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__)
#define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__) #define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__)
@ -681,6 +693,7 @@ struct st_my_thread_var
}; };
extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const)); extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
extern void **my_thread_var_dbug();
extern uint my_thread_end_wait_time; extern uint my_thread_end_wait_time;
#define my_thread_var (_my_thread_var()) #define my_thread_var (_my_thread_var())
#define my_errno my_thread_var->thr_errno #define my_errno my_thread_var->thr_errno

View File

@ -51,6 +51,7 @@ extern int NEAR my_errno; /* Last error in mysys */
#define MY_WME 16 /* Write message on error */ #define MY_WME 16 /* Write message on error */
#define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */ #define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */
#define MY_IGNORE_BADFD 32 /* my_sync: ignore 'bad descriptor' errors */ #define MY_IGNORE_BADFD 32 /* my_sync: ignore 'bad descriptor' errors */
#define MY_SYNC_DIR 1024 /* my_create/delete/rename: sync directory */
#define MY_RAID 64 /* Support for RAID */ #define MY_RAID 64 /* Support for RAID */
#define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */ #define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */
#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */ #define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */
@ -61,12 +62,14 @@ extern int NEAR my_errno; /* Last error in mysys */
#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */ #define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */
#define MY_REDEL_MAKE_BACKUP 256 #define MY_REDEL_MAKE_BACKUP 256
#define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */ #define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */
#define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */ #define MY_SHORT_WAIT 64 /* my_lock() don't wait if can't lock */
#define MY_FORCE_LOCK 128 /* use my_lock() even if disable_locking */
#define MY_NO_WAIT 256 /* my_lock() don't wait at all */
#define MY_ZEROFILL 32 /* my_malloc(), fill array with zero */ #define MY_ZEROFILL 32 /* my_malloc(), fill array with zero */
#define MY_ALLOW_ZERO_PTR 64 /* my_realloc() ; zero ptr -> malloc */ #define MY_ALLOW_ZERO_PTR 64 /* my_realloc() ; zero ptr -> malloc */
#define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */ #define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */
#define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */ #define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */
#define MY_DONT_OVERWRITE_FILE 1024 /* my_copy: Don't overwrite file */ #define MY_DONT_OVERWRITE_FILE 2048 /* my_copy: Don't overwrite file */
#define MY_THREADSAFE 2048 /* my_seek(): lock fd mutex */ #define MY_THREADSAFE 2048 /* my_seek(): lock fd mutex */
#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */ #define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */
@ -89,6 +92,8 @@ extern int NEAR my_errno; /* Last error in mysys */
#define ME_COLOUR1 ((1 << ME_HIGHBYTE)) /* Possibly error-colours */ #define ME_COLOUR1 ((1 << ME_HIGHBYTE)) /* Possibly error-colours */
#define ME_COLOUR2 ((2 << ME_HIGHBYTE)) #define ME_COLOUR2 ((2 << ME_HIGHBYTE))
#define ME_COLOUR3 ((3 << ME_HIGHBYTE)) #define ME_COLOUR3 ((3 << ME_HIGHBYTE))
#define ME_JUST_INFO 1024 /**< not error but just info */
#define ME_JUST_WARNING 2048 /**< not error but just warning */
/* Bits in last argument to fn_format */ /* Bits in last argument to fn_format */
#define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */ #define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */
@ -207,11 +212,13 @@ extern int errno; /* declare errno */
extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE]; extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
extern char *home_dir; /* Home directory for user */ extern char *home_dir; /* Home directory for user */
extern const char *my_progname; /* program-name (printed in errors) */ extern const char *my_progname; /* program-name (printed in errors) */
extern const char *my_progname_short; /* like above but without directory */
extern char NEAR curr_dir[]; /* Current directory for user */ extern char NEAR curr_dir[]; /* Current directory for user */
extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags); extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags);
extern int (*fatal_error_handler_hook)(uint my_err, const char *str, extern int (*fatal_error_handler_hook)(uint my_err, const char *str,
myf MyFlags); myf MyFlags);
extern uint my_file_limit; extern uint my_file_limit;
extern ulong my_thread_stack_size;
#ifdef HAVE_LARGE_PAGES #ifdef HAVE_LARGE_PAGES
extern my_bool my_use_large_pages; extern my_bool my_use_large_pages;
@ -276,7 +283,18 @@ enum cache_type
enum flush_type enum flush_type
{ {
FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE FLUSH_KEEP, /* flush block and keep it in the cache */
FLUSH_RELEASE, /* flush block and remove it from the cache */
FLUSH_IGNORE_CHANGED, /* remove block from the cache */
/* as my_disable_flush_pagecache_blocks is always 0, it is
strictly equivalent to FLUSH_KEEP */
FLUSH_FORCE_WRITE,
/**
@brief like FLUSH_KEEP but return immediately if file is already being
flushed (even partially) by another thread; only for page cache,
forbidden for key cache.
*/
FLUSH_KEEP_LAZY
}; };
typedef struct st_record_cache /* Used when cacheing records */ typedef struct st_record_cache /* Used when cacheing records */
@ -530,6 +548,7 @@ my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */
*(info)->current_pos) *(info)->current_pos)
typedef uint32 ha_checksum; typedef uint32 ha_checksum;
extern ha_checksum my_crc_dbug_check;
/* Define the type of function to be passed to process_default_option_files */ /* Define the type of function to be passed to process_default_option_files */
typedef int (*Process_option_func)(void *ctx, const char *group_name, typedef int (*Process_option_func)(void *ctx, const char *group_name,
@ -627,6 +646,8 @@ extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
extern int my_fclose(FILE *fd,myf MyFlags); extern int my_fclose(FILE *fd,myf MyFlags);
extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags); extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
extern int my_sync(File fd, myf my_flags); extern int my_sync(File fd, myf my_flags);
extern int my_sync_dir(const char *dir_name, myf my_flags);
extern int my_sync_dir_by_file(const char *file_name, myf my_flags);
extern int my_error _VARARGS((int nr,myf MyFlags, ...)); extern int my_error _VARARGS((int nr,myf MyFlags, ...));
extern int my_printf_error _VARARGS((uint my_err, const char *format, extern int my_printf_error _VARARGS((uint my_err, const char *format,
myf MyFlags, ...)) myf MyFlags, ...))
@ -661,7 +682,7 @@ extern char *my_tmpdir(MY_TMPDIR *tmpdir);
extern void free_tmpdir(MY_TMPDIR *tmpdir); extern void free_tmpdir(MY_TMPDIR *tmpdir);
extern void my_remember_signal(int signal_number,sig_handler (*func)(int)); extern void my_remember_signal(int signal_number,sig_handler (*func)(int));
extern size_t dirname_part(char * to, const char *name, size_t *to_res_length); extern size_t dirname_part(char * to,const char *name, size_t *to_res_length);
extern size_t dirname_length(const char *name); extern size_t dirname_length(const char *name);
#define base_name(A) (A+dirname_length(A)) #define base_name(A) (A+dirname_length(A))
extern int test_if_hard_path(const char *dir_name); extern int test_if_hard_path(const char *dir_name);
@ -709,7 +730,7 @@ extern sig_handler sigtstp_handler(int signal_number);
extern void handle_recived_signals(void); extern void handle_recived_signals(void);
extern sig_handler my_set_alarm_variable(int signo); extern sig_handler my_set_alarm_variable(int signo);
extern void my_string_ptr_sort(uchar *base, uint items, size_t size); extern void my_string_ptr_sort(uchar *base,uint items,size_t size);
extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements, extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
size_t size_of_element,uchar *buffer[]); size_t size_of_element,uchar *buffer[]);
extern qsort_t my_qsort(void *base_ptr, size_t total_elems, size_t size, extern qsort_t my_qsort(void *base_ptr, size_t total_elems, size_t size,
@ -777,6 +798,7 @@ extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,uchar * element);
extern uchar *alloc_dynamic(DYNAMIC_ARRAY *array); extern uchar *alloc_dynamic(DYNAMIC_ARRAY *array);
extern uchar *pop_dynamic(DYNAMIC_ARRAY*); extern uchar *pop_dynamic(DYNAMIC_ARRAY*);
extern my_bool set_dynamic(DYNAMIC_ARRAY *array,uchar * element,uint array_index); extern my_bool set_dynamic(DYNAMIC_ARRAY *array,uchar * element,uint array_index);
extern my_bool allocate_dynamic(DYNAMIC_ARRAY *array, uint max_elements);
extern void get_dynamic(DYNAMIC_ARRAY *array,uchar * element,uint array_index); extern void get_dynamic(DYNAMIC_ARRAY *array,uchar * element,uint array_index);
extern void delete_dynamic(DYNAMIC_ARRAY *array); extern void delete_dynamic(DYNAMIC_ARRAY *array);
extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index); extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index);
@ -843,11 +865,9 @@ extern int unpackfrm(uchar **, size_t *, const uchar *);
extern ha_checksum my_checksum(ha_checksum crc, const uchar *mem, extern ha_checksum my_checksum(ha_checksum crc, const uchar *mem,
size_t count); size_t count);
extern uint my_bit_log2(ulong value); extern void my_debug_put_break_here(void);
extern uint32 my_round_up_to_next_power(uint32 v);
extern uint my_count_bits(ulonglong v);
extern uint my_count_bits_ushort(ushort v);
extern void my_sleep(ulong m_seconds); extern void my_sleep(ulong m_seconds);
extern ulong crc32(ulong crc, const uchar *buf, uint len);
extern uint my_set_max_open_files(uint files); extern uint my_set_max_open_files(uint files);
void my_free_open_file_info(void); void my_free_open_file_info(void);
@ -865,7 +885,7 @@ extern int my_getncpus();
#ifndef MAP_NOSYNC #ifndef MAP_NOSYNC
#define MAP_NOSYNC 0 #define MAP_NOSYNC 0
#endif #endif
#ifndef MAP_NORESERVE #ifndef MAP_NORESERVE
#define MAP_NORESERVE 0 /* For irix and AIX */ #define MAP_NORESERVE 0 /* For irix and AIX */
#endif #endif
@ -904,6 +924,19 @@ int my_getpagesize(void);
int my_msync(int, void *, size_t, int); int my_msync(int, void *, size_t, int);
#define MY_UUID_SIZE 16
void my_uuid_init(ulong seed1, ulong seed2);
void my_uuid(uchar *guid);
void my_uuid_end();
struct my_rnd_struct {
unsigned long seed1,seed2,max_value;
double max_value_dbl;
};
void my_rnd_init(struct my_rnd_struct *rand_st, ulong seed1, ulong seed2);
double my_rnd(struct my_rnd_struct *rand_st);
/* character sets */ /* character sets */
extern uint get_charset_number(const char *cs_name, uint cs_flags); extern uint get_charset_number(const char *cs_name, uint cs_flags);
extern uint get_collation_number(const char *name); extern uint get_collation_number(const char *name);

View File

@ -31,33 +31,19 @@ extern "C" {
#include "keycache.h" #include "keycache.h"
#endif #endif
#include "my_handler.h" #include "my_handler.h"
#include <myisamchk.h>
#include <mysql/plugin.h> #include <mysql/plugin.h>
/* /*
There is a hard limit for the maximum number of keys as there are only Limit max keys according to HA_MAX_POSSIBLE_KEY; See myisamchk.h for details
8 bits in the index file header for the number of keys in a table.
This means that 0..255 keys can exist for a table. The idea of
MI_MAX_POSSIBLE_KEY is to ensure that one can use myisamchk & tools on
a MyISAM table for which one has more keys than MyISAM is normally
compiled for. If you don't have this, you will get a core dump when
running myisamchk compiled for 128 keys on a table with 255 keys.
*/ */
#define MI_MAX_POSSIBLE_KEY 255 /* For myisam_chk */
#if MAX_INDEXES > MI_MAX_POSSIBLE_KEY #if MAX_INDEXES > HA_MAX_POSSIBLE_KEY
#define MI_MAX_KEY MI_MAX_POSSIBLE_KEY /* Max allowed keys */ #define MI_MAX_KEY HA_MAX_POSSIBLE_KEY /* Max allowed keys */
#else #else
#define MI_MAX_KEY MAX_INDEXES /* Max allowed keys */ #define MI_MAX_KEY MAX_INDEXES /* Max allowed keys */
#endif #endif
#define MI_MAX_POSSIBLE_KEY_BUFF (1024+6+6) /* For myisam_chk */
/*
The following defines can be increased if necessary.
But beware the dependency of MI_MAX_POSSIBLE_KEY_BUFF and MI_MAX_KEY_LENGTH.
*/
#define MI_MAX_KEY_LENGTH 1000 /* Max length in bytes */
#define MI_MAX_KEY_SEG 16 /* Max segments for key */
#define MI_MAX_KEY_BUFF (MI_MAX_KEY_LENGTH+MI_MAX_KEY_SEG*6+8+8)
#define MI_MAX_MSG_BUF 1024 /* used in CHECK TABLE, REPAIR TABLE */ #define MI_MAX_MSG_BUF 1024 /* used in CHECK TABLE, REPAIR TABLE */
#define MI_NAME_IEXT ".MYI" #define MI_NAME_IEXT ".MYI"
#define MI_NAME_DEXT ".MYD" #define MI_NAME_DEXT ".MYD"
@ -69,8 +55,6 @@ extern "C" {
#define MI_MIN_KEY_BLOCK_LENGTH 1024 /* Min key block length */ #define MI_MIN_KEY_BLOCK_LENGTH 1024 /* Min key block length */
#define MI_MAX_KEY_BLOCK_LENGTH 16384 #define MI_MAX_KEY_BLOCK_LENGTH 16384
#define mi_portable_sizeof_char_ptr 8
/* /*
In the following macros '_keyno_' is 0 .. keys-1. In the following macros '_keyno_' is 0 .. keys-1.
If there can be more keys than bits in the key_map, the highest bit If there can be more keys than bits in the key_map, the highest bit
@ -241,7 +225,7 @@ struct st_mi_bit_buff;
typedef struct st_columndef /* column information */ typedef struct st_columndef /* column information */
{ {
int16 type; /* en_fieldtype */ enum en_fieldtype type;
uint16 length; /* length of field */ uint16 length; /* length of field */
uint32 offset; /* Offset to position in row */ uint32 offset; /* Offset to position in row */
uint8 null_bit; /* If column may be 0 */ uint8 null_bit; /* If column may be 0 */
@ -256,9 +240,6 @@ typedef struct st_columndef /* column information */
#endif #endif
} MI_COLUMNDEF; } MI_COLUMNDEF;
/* invalidator function reference for Query Cache */
typedef void (* invalidator_by_filename)(const char * filename);
extern char * myisam_log_filename; /* Name of logfile */ extern char * myisam_log_filename; /* Name of logfile */
extern ulong myisam_block_size; extern ulong myisam_block_size;
extern ulong myisam_concurrent_insert; extern ulong myisam_concurrent_insert;
@ -302,7 +283,7 @@ extern int mi_extra(struct st_myisam_info *file,
enum ha_extra_function function, enum ha_extra_function function,
void *extra_arg); void *extra_arg);
extern int mi_reset(struct st_myisam_info *file); extern int mi_reset(struct st_myisam_info *file);
extern ha_rows mi_records_in_range(MI_INFO *info, int inx, extern ha_rows mi_records_in_range(MI_INFO *info,int inx,
key_range *min_key, key_range *max_key); key_range *min_key, key_range *max_key);
extern int mi_log(int activate_log); extern int mi_log(int activate_log);
extern int mi_is_changed(struct st_myisam_info *info); extern int mi_is_changed(struct st_myisam_info *info);
@ -310,195 +291,117 @@ extern int mi_delete_all_rows(struct st_myisam_info *info);
extern ulong _mi_calc_blob_length(uint length , const uchar *pos); extern ulong _mi_calc_blob_length(uint length , const uchar *pos);
extern uint mi_get_pointer_length(ulonglong file_length, uint def); extern uint mi_get_pointer_length(ulonglong file_length, uint def);
/* this is used to pass to mysql_myisamchk_table -- by Sasha Pachev */ /* this is used to pass to mysql_myisamchk_table */
#define MYISAMCHK_REPAIR 1 /* equivalent to myisamchk -r */ #define MYISAMCHK_REPAIR 1 /* equivalent to myisamchk -r */
#define MYISAMCHK_VERIFY 2 /* Verify, run repair if failure */ #define MYISAMCHK_VERIFY 2 /* Verify, run repair if failure */
/* typedef uint mi_bit_type;
Definitions needed for myisamchk.c
Entries marked as "QQ to be removed" are NOT used to typedef struct st_mi_bit_buff
pass check/repair options to mi_check.c. They are used { /* Used for packing of record */
internally by myisamchk.c or/and ha_myisam.cc and should NOT mi_bit_type current_byte;
be stored together with other flags. They should be removed uint bits;
from the following list to make addition of new flags possible. uchar *pos, *end, *blob_pos, *blob_end;
*/ uint error;
} MI_BIT_BUFF;
#define T_AUTO_INC 1
#define T_AUTO_REPAIR 2 /* QQ to be removed */
#define T_BACKUP_DATA 4
#define T_CALC_CHECKSUM 8
#define T_CHECK 16 /* QQ to be removed */
#define T_CHECK_ONLY_CHANGED 32 /* QQ to be removed */
#define T_CREATE_MISSING_KEYS 64
#define T_DESCRIPT 128
#define T_DONT_CHECK_CHECKSUM 256
#define T_EXTEND 512
#define T_FAST (1L << 10) /* QQ to be removed */
#define T_FORCE_CREATE (1L << 11) /* QQ to be removed */
#define T_FORCE_UNIQUENESS (1L << 12)
#define T_INFO (1L << 13)
#define T_MEDIUM (1L << 14)
#define T_QUICK (1L << 15) /* QQ to be removed */
#define T_READONLY (1L << 16) /* QQ to be removed */
#define T_REP (1L << 17)
#define T_REP_BY_SORT (1L << 18) /* QQ to be removed */
#define T_REP_PARALLEL (1L << 19) /* QQ to be removed */
#define T_RETRY_WITHOUT_QUICK (1L << 20)
#define T_SAFE_REPAIR (1L << 21)
#define T_SILENT (1L << 22)
#define T_SORT_INDEX (1L << 23) /* QQ to be removed */
#define T_SORT_RECORDS (1L << 24) /* QQ to be removed */
#define T_STATISTICS (1L << 25)
#define T_UNPACK (1L << 26)
#define T_UPDATE_STATE (1L << 27)
#define T_VERBOSE (1L << 28)
#define T_VERY_SILENT (1L << 29)
#define T_WAIT_FOREVER (1L << 30)
#define T_WRITE_LOOP ((ulong) 1L << 31)
#define T_REP_ANY (T_REP | T_REP_BY_SORT | T_REP_PARALLEL) typedef struct st_sort_info
/*
Flags used by myisamchk.c or/and ha_myisam.cc that are NOT passed
to mi_check.c follows:
*/
#define TT_USEFRM 1
#define TT_FOR_UPGRADE 2
#define O_NEW_INDEX 1 /* Bits set in out_flag */
#define O_NEW_DATA 2
#define O_DATA_LOST 4
/* these struct is used by my_check to tell it what to do */
typedef struct st_sort_key_blocks /* Used when sorting */
{ {
uchar *buff,*end_pos; #ifdef THREAD
uchar lastkey[MI_MAX_POSSIBLE_KEY_BUFF]; /* sync things */
uint last_length; pthread_mutex_t mutex;
int inited; pthread_cond_t cond;
} SORT_KEY_BLOCKS; #endif
MI_INFO *info;
HA_CHECK *param;
/* uchar *buff;
MyISAM supports several statistics collection methods. Currently statistics SORT_KEY_BLOCKS *key_block, *key_block_end;
collection method is not stored in MyISAM file and has to be specified for SORT_FT_BUF *ft_buf;
each table analyze/repair operation in MI_CHECK::stats_method. my_off_t filelength, dupp, buff_length;
*/ ha_rows max_records;
uint current_key, total_keys;
typedef enum uint got_error, threads_running;
{
/* Treat NULLs as inequal when collecting statistics (default for 4.1/5.0) */
MI_STATS_METHOD_NULLS_NOT_EQUAL,
/* Treat NULLs as equal when collecting statistics (like 4.0 did) */
MI_STATS_METHOD_NULLS_EQUAL,
/* Ignore NULLs - count only tuples without NULLs in the index components */
MI_STATS_METHOD_IGNORE_NULLS
} enum_mi_stats_method;
typedef struct st_mi_check_param
{
ulonglong auto_increment_value;
ulonglong max_data_file_length;
ulonglong keys_in_use;
ulonglong max_record_length;
my_off_t search_after_block;
my_off_t new_file_pos,key_file_blocks;
my_off_t keydata,totaldata,key_blocks,start_check_pos;
ha_rows total_records,total_deleted;
ha_checksum record_checksum,glob_crc;
ulong use_buffers,read_buffer_length,write_buffer_length,
sort_buffer_length,sort_key_blocks;
uint out_flag,warning_printed,error_printed,verbose;
uint opt_sort_key,total_files,max_level;
uint testflag, key_cache_block_size;
uint8 language;
my_bool using_global_keycache, opt_lock_memory, opt_follow_links;
my_bool retry_repair, force_sort;
char temp_filename[FN_REFLEN],*isam_file_name;
MY_TMPDIR *tmpdir;
int tmpfile_createflag;
myf myf_rw; myf myf_rw;
IO_CACHE read_cache; enum data_file_type new_data_file_type;
} MI_SORT_INFO;
typedef struct st_mi_sort_param
{
pthread_t thr;
IO_CACHE read_cache, tempfile, tempfile_for_exceptions;
DYNAMIC_ARRAY buffpek;
MI_BIT_BUFF bit_buff; /* For parallel repair of packrec. */
MI_KEYDEF *keyinfo;
MI_SORT_INFO *sort_info;
HA_KEYSEG *seg;
uchar **sort_keys;
uchar *rec_buff;
void *wordlist, *wordptr;
MEM_ROOT wordroot;
uchar *record;
MY_TMPDIR *tmpdir;
/* /*
The next two are used to collect statistics, see update_key_parts for The next two are used to collect statistics, see update_key_parts for
description. description.
*/ */
ulonglong unique_count[MI_MAX_KEY_SEG+1]; ulonglong unique[HA_MAX_KEY_SEG+1];
ulonglong notnull_count[MI_MAX_KEY_SEG+1]; ulonglong notnull[HA_MAX_KEY_SEG+1];
ha_checksum key_crc[MI_MAX_POSSIBLE_KEY];
ulong rec_per_key_part[MI_MAX_KEY_SEG*MI_MAX_POSSIBLE_KEY];
void *thd;
const char *db_name, *table_name;
const char *op_name;
enum_mi_stats_method stats_method;
} MI_CHECK;
typedef struct st_sort_ft_buf my_off_t pos,max_pos,filepos,start_recpos;
{ uint key, key_length,real_key_length,sortbuff_size;
uchar *buf, *end; uint maxbuffers, keys, find_length, sort_keys_length;
int count; my_bool fix_datafile, master;
uchar lastkey[MI_MAX_KEY_BUFF]; my_bool calc_checksum; /* calculate table checksum */
} SORT_FT_BUF;
int (*key_cmp)(struct st_mi_sort_param *, const void *, const void *);
int (*key_read)(struct st_mi_sort_param *,void *);
int (*key_write)(struct st_mi_sort_param *, const void *);
void (*lock_in_memory)(HA_CHECK *);
NEAR int (*write_keys)(struct st_mi_sort_param *, register uchar **,
uint , struct st_buffpek *, IO_CACHE *);
NEAR uint (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint);
NEAR int (*write_key)(struct st_mi_sort_param *, IO_CACHE *,uchar *,
uint, uint);
} MI_SORT_PARAM;
typedef struct st_sort_info
{
my_off_t filelength,dupp,buff_length;
ha_rows max_records;
uint current_key, total_keys;
myf myf_rw;
enum data_file_type new_data_file_type;
MI_INFO *info;
MI_CHECK *param;
uchar *buff;
SORT_KEY_BLOCKS *key_block,*key_block_end;
SORT_FT_BUF *ft_buf;
/* sync things */
uint got_error, threads_running;
#ifdef THREAD
pthread_mutex_t mutex;
pthread_cond_t cond;
#endif
} SORT_INFO;
/* functions in mi_check */ /* functions in mi_check */
void myisamchk_init(MI_CHECK *param); void myisamchk_init(HA_CHECK *param);
int chk_status(MI_CHECK *param, MI_INFO *info); int chk_status(HA_CHECK *param, MI_INFO *info);
int chk_del(MI_CHECK *param, register MI_INFO *info, uint test_flag); int chk_del(HA_CHECK *param, register MI_INFO *info, uint test_flag);
int chk_size(MI_CHECK *param, MI_INFO *info); int chk_size(HA_CHECK *param, MI_INFO *info);
int chk_key(MI_CHECK *param, MI_INFO *info); int chk_key(HA_CHECK *param, MI_INFO *info);
int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend); int chk_data_link(HA_CHECK *param, MI_INFO *info,int extend);
int mi_repair(MI_CHECK *param, register MI_INFO *info, int mi_repair(HA_CHECK *param, register MI_INFO *info,
char * name, int rep_quick); char * name, int rep_quick);
int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name); int mi_sort_index(HA_CHECK *param, register MI_INFO *info, char * name);
int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info,
const char * name, int rep_quick); const char * name, int rep_quick);
int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info,
const char * name, int rep_quick); const char * name, int rep_quick);
int change_to_newfile(const char * filename, const char * old_ext, int change_to_newfile(const char * filename, const char * old_ext,
const char * new_ext, uint raid_chunks, const char * new_ext, uint raid_chunks,
myf myflags); myf myflags);
int lock_file(MI_CHECK *param, File file, my_off_t start, int lock_type, int lock_file(HA_CHECK *param, File file, my_off_t start, int lock_type,
const char *filetype, const char *filename); const char *filetype, const char *filename);
void lock_memory(MI_CHECK *param); void lock_memory(HA_CHECK *param);
void update_auto_increment_key(MI_CHECK *param, MI_INFO *info, void update_auto_increment_key(HA_CHECK *param, MI_INFO *info,
my_bool repair); my_bool repair);
int update_state_info(MI_CHECK *param, MI_INFO *info,uint update); int update_state_info(HA_CHECK *param, MI_INFO *info,uint update);
void update_key_parts(MI_KEYDEF *keyinfo, ulong *rec_per_key_part, void update_key_parts(MI_KEYDEF *keyinfo, ulong *rec_per_key_part,
ulonglong *unique, ulonglong *notnull, ulonglong *unique, ulonglong *notnull,
ulonglong records); ulonglong records);
int filecopy(MI_CHECK *param, File to,File from,my_off_t start, int filecopy(HA_CHECK *param, File to,File from,my_off_t start,
my_off_t length, const char *type); my_off_t length, const char *type);
int movepoint(MI_INFO *info,uchar *record,my_off_t oldpos, int movepoint(MI_INFO *info,uchar *record,my_off_t oldpos,
my_off_t newpos, uint prot_key); my_off_t newpos, uint prot_key);
int write_data_suffix(SORT_INFO *sort_info, my_bool fix_datafile); int write_data_suffix(MI_SORT_INFO *sort_info, my_bool fix_datafile);
int test_if_almost_full(MI_INFO *info); int test_if_almost_full(MI_INFO *info);
int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename); int recreate_table(HA_CHECK *param, MI_INFO **org_info, char *filename);
void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows); void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows);
my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, ulonglong key_map, my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, ulonglong key_map,
my_bool force); my_bool force);
@ -512,6 +415,13 @@ void mi_change_key_cache(KEY_CACHE *old_key_cache,
KEY_CACHE *new_key_cache); KEY_CACHE *new_key_cache);
int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves); int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves);
int write_data_suffix(MI_SORT_INFO *sort_info, my_bool fix_datafile);
int flush_pending_blocks(MI_SORT_PARAM *param);
int sort_ft_buf_flush(MI_SORT_PARAM *sort_param);
int thr_write_keys(MI_SORT_PARAM *sort_param);
int sort_write_record(MI_SORT_PARAM *sort_param);
int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

166
include/myisamchk.h Normal file
View File

@ -0,0 +1,166 @@
/* Copyright (C) 2006 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Definitions needed for myisamchk/mariachk.c */
/*
Entries marked as "QQ to be removed" are NOT used to
pass check/repair options to xxx_check.c. They are used
internally by xxxchk.c or/and ha_xxxx.cc and should NOT
be stored together with other flags. They should be removed
from the following list to make addition of new flags possible.
*/
#ifndef _myisamchk_h
#define _myisamchk_h
#define T_AUTO_INC 1
#define T_AUTO_REPAIR 2 /* QQ to be removed */
#define T_BACKUP_DATA 4
#define T_CALC_CHECKSUM 8
#define T_CHECK 16 /* QQ to be removed */
#define T_CHECK_ONLY_CHANGED 32 /* QQ to be removed */
#define T_CREATE_MISSING_KEYS 64
#define T_DESCRIPT 128
#define T_DONT_CHECK_CHECKSUM 256
#define T_EXTEND 512
#define T_FAST (1L << 10) /* QQ to be removed */
#define T_FORCE_CREATE (1L << 11) /* QQ to be removed */
#define T_FORCE_UNIQUENESS (1L << 12)
#define T_INFO (1L << 13)
#define T_MEDIUM (1L << 14)
#define T_QUICK (1L << 15) /* QQ to be removed */
#define T_READONLY (1L << 16) /* QQ to be removed */
#define T_REP (1L << 17)
#define T_REP_BY_SORT (1L << 18) /* QQ to be removed */
#define T_REP_PARALLEL (1L << 19) /* QQ to be removed */
#define T_RETRY_WITHOUT_QUICK (1L << 20)
#define T_SAFE_REPAIR (1L << 21)
#define T_SILENT (1L << 22)
#define T_SORT_INDEX (1L << 23) /* QQ to be removed */
#define T_SORT_RECORDS (1L << 24) /* QQ to be removed */
#define T_STATISTICS (1L << 25)
#define T_UNPACK (1L << 26)
#define T_UPDATE_STATE (1L << 27)
#define T_VERBOSE (1L << 28)
#define T_VERY_SILENT (1L << 29)
#define T_WAIT_FOREVER (1L << 30)
#define T_WRITE_LOOP ((ulong) 1L << 31)
#define T_REP_ANY (T_REP | T_REP_BY_SORT | T_REP_PARALLEL)
/*
Flags used by xxxxchk.c or/and ha_xxxx.cc that are NOT passed
to xxxcheck.c follows:
*/
#define TT_USEFRM 1
#define TT_FOR_UPGRADE 2
#define O_NEW_INDEX 1 /* Bits set in out_flag */
#define O_NEW_DATA 2
#define O_DATA_LOST 4
typedef struct st_sort_key_blocks /* Used when sorting */
{
uchar *buff, *end_pos;
uchar lastkey[HA_MAX_POSSIBLE_KEY_BUFF];
uint last_length;
int inited;
} SORT_KEY_BLOCKS;
/*
MARIA/MYISAM supports several statistics collection
methods. Currently statistics collection method is not stored in
MARIA file and has to be specified for each table analyze/repair
operation in MI_CHECK::stats_method.
*/
typedef enum
{
/* Treat NULLs as inequal when collecting statistics (default for 4.1/5.0) */
MI_STATS_METHOD_NULLS_NOT_EQUAL,
/* Treat NULLs as equal when collecting statistics (like 4.0 did) */
MI_STATS_METHOD_NULLS_EQUAL,
/* Ignore NULLs - count only tuples without NULLs in the index components */
MI_STATS_METHOD_IGNORE_NULLS
} enum_handler_stats_method;
typedef struct st_handler_check_param
{
char *isam_file_name;
MY_TMPDIR *tmpdir;
void *thd;
const char *db_name, *table_name, *op_name;
ulonglong auto_increment_value;
ulonglong max_data_file_length;
ulonglong keys_in_use;
ulonglong max_record_length;
/*
The next two are used to collect statistics, see update_key_parts for
description.
*/
ulonglong unique_count[HA_MAX_KEY_SEG + 1];
ulonglong notnull_count[HA_MAX_KEY_SEG + 1];
my_off_t search_after_block;
my_off_t new_file_pos, key_file_blocks;
my_off_t keydata, totaldata, key_blocks, start_check_pos;
my_off_t used, empty, splits, del_length, link_used;
ha_rows total_records, total_deleted, records,del_blocks;
ha_rows full_page_count, tail_count;
ha_checksum record_checksum, glob_crc;
ha_checksum key_crc[HA_MAX_POSSIBLE_KEY];
ha_checksum tmp_key_crc[HA_MAX_POSSIBLE_KEY];
ha_checksum tmp_record_checksum;
ulonglong org_key_map;
size_t use_buffers, read_buffer_length, write_buffer_length;
size_t sort_buffer_length, sort_key_blocks;
ulong rec_per_key_part[HA_MAX_KEY_SEG * HA_MAX_POSSIBLE_KEY];
double new_rec_per_key_part[HA_MAX_KEY_SEG * HA_MAX_POSSIBLE_KEY];
uint out_flag, warning_printed, error_printed, verbose;
uint opt_sort_key, total_files, max_level;
uint testflag, key_cache_block_size, pagecache_block_size;
int tmpfile_createflag, err_count;
myf myf_rw;
uint8 language;
my_bool using_global_keycache, opt_lock_memory, opt_follow_links;
my_bool retry_repair, force_sort, calc_checksum, static_row_size;
char temp_filename[FN_REFLEN];
IO_CACHE read_cache;
enum_handler_stats_method stats_method;
} HA_CHECK;
typedef struct st_sort_ftbuf
{
uchar *buf, *end;
int count;
uchar lastkey[HA_MAX_KEY_BUFF];
} SORT_FT_BUF;
typedef struct st_buffpek {
my_off_t file_pos; /* Where we are in the sort file */
uchar *base, *key; /* Key pointers */
ha_rows count; /* Number of rows in table */
ulong mem_count; /* numbers of keys in memory */
ulong max_keys; /* Max keys in buffert */
} BUFFPEK;
#endif /* _myisamchk_h */

View File

@ -365,11 +365,7 @@ void my_net_set_read_timeout(NET *net, uint timeout);
struct sockaddr; struct sockaddr;
int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen, int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen,
unsigned int timeout); unsigned int timeout);
struct my_rnd_struct;
struct rand_struct {
unsigned long seed1,seed2,max_value;
double max_value_dbl;
};
#ifdef __cplusplus #ifdef __cplusplus
} }
@ -423,10 +419,8 @@ extern "C" {
implemented in sql/password.c implemented in sql/password.c
*/ */
void randominit(struct rand_struct *, unsigned long seed1, void create_random_string(char *to, unsigned int length,
unsigned long seed2); struct my_rnd_struct *rand_st);
double my_rnd(struct rand_struct *);
void create_random_string(char *to, unsigned int length, struct rand_struct *rand_st);
void hash_password(unsigned long *to, const char *password, unsigned int password_len); void hash_password(unsigned long *to, const char *password, unsigned int password_len);
void make_scrambled_password_323(char *to, const char *password); void make_scrambled_password_323(char *to, const char *password);

26
include/wqueue.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef _wqueue_h
#define _wqueue_h
#include <my_global.h>
#include <my_pthread.h>
/* info about requests in a waiting queue */
typedef struct st_pagecache_wqueue
{
struct st_my_thread_var *last_thread; /* circular list of waiting
threads */
} WQUEUE;
#ifdef THREAD
void wqueue_link_into_queue(WQUEUE *wqueue, struct st_my_thread_var *thread);
void wqueue_unlink_from_queue(WQUEUE *wqueue, struct st_my_thread_var *thread);
void wqueue_add_to_queue(WQUEUE *wqueue, struct st_my_thread_var *thread);
void wqueue_add_and_wait(WQUEUE *wqueue,
struct st_my_thread_var *thread,
pthread_mutex_t *lock);
void wqueue_release_queue(WQUEUE *wqueue);
#endif
#endif

View File

@ -71,10 +71,10 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c
../strings/ctype-simple.c ../strings/ctype-sjis.c ../strings/ctype-tis620.c ../strings/ctype-simple.c ../strings/ctype-sjis.c ../strings/ctype-tis620.c
../strings/ctype-uca.c ../strings/ctype-ucs2.c ../strings/ctype-ujis.c ../strings/ctype-uca.c ../strings/ctype-ucs2.c ../strings/ctype-ujis.c
../strings/ctype-utf8.c ../strings/ctype-win1250ch.c ../strings/ctype.c ../strings/ctype-utf8.c ../strings/ctype-win1250ch.c ../strings/ctype.c
../mysys/default.c errmsg.c ../mysys/errors.c ../mysys/default.c errmsg.c ../mysys/errors.c ../mysys/my_sync.c
../mysys/hash.c ../mysys/my_sleep.c ../mysys/default_modify.c ../mysys/hash.c ../mysys/my_sleep.c ../mysys/default_modify.c
get_password.c ../strings/int2str.c ../strings/is_prefix.c get_password.c ../strings/int2str.c ../strings/is_prefix.c
libmysql.c ../mysys/list.c ../strings/llstr.c libmysql.c ../mysys/list.c ../strings/llstr.c ../mysys/my_rnd.c
../strings/longlong2str.c manager.c ../mysys/mf_arr_appstr.c ../mysys/mf_cache.c ../strings/longlong2str.c manager.c ../mysys/mf_arr_appstr.c ../mysys/mf_cache.c
../mysys/mf_dirname.c ../mysys/mf_fn_ext.c ../mysys/mf_format.c ../mysys/mf_dirname.c ../mysys/mf_fn_ext.c ../mysys/mf_format.c
../mysys/mf_iocache.c ../mysys/mf_iocache2.c ../mysys/mf_loadpath.c ../mysys/mf_iocache.c ../mysys/mf_iocache2.c ../mysys/mf_loadpath.c

View File

@ -66,9 +66,9 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
my_compress.lo array.lo my_once.lo list.lo my_net.lo \ my_compress.lo array.lo my_once.lo list.lo my_net.lo \
charset.lo charset-def.lo hash.lo mf_iocache.lo \ charset.lo charset-def.lo hash.lo mf_iocache.lo \
mf_iocache2.lo my_seek.lo my_sleep.lo \ mf_iocache2.lo my_seek.lo my_sleep.lo \
my_pread.lo mf_cache.lo md5.lo sha1.lo \ my_pread.lo mf_cache.lo md5.lo sha1.lo my_rnd.lo \
my_getopt.lo my_gethostbyname.lo my_port.lo \ my_getopt.lo my_gethostbyname.lo my_port.lo \
my_rename.lo my_chsize.lo my_getsystime.lo my_rename.lo my_chsize.lo my_sync.lo my_getsystime.lo
sqlobjects = net.lo sqlobjects = net.lo
sql_cmn_objects = pack.lo client.lo my_time.lo sql_cmn_objects = pack.lo client.lo my_time.lo

View File

@ -9,9 +9,9 @@
let $SERVER_VERSION=`select version()`; let $SERVER_VERSION=`select version()`;
create table t1 (a int); create table t1 (a int) ENGINE=MyISAM;
insert into t1 values (10); insert into t1 values (10);
create table t2 (a int); create table t2 (a int) ENGINE=MyISAM;
create table t3 (a int) engine=merge union(t1); create table t3 (a int) engine=merge union(t1);
create table t4 (a int); create table t4 (a int);
# We force the slave to open t3 (because we want to try confusing him) with this : # We force the slave to open t3 (because we want to try confusing him) with this :

View File

@ -17,7 +17,7 @@ select @@global.binlog_format;
# happened only in statement-based binlogging. # happened only in statement-based binlogging.
# #
CREATE TABLE t1 (id INT primary key auto_increment, name VARCHAR(64)); CREATE TABLE t1 (id INT primary key auto_increment, name VARCHAR(64)) ENGINE=MyISAM;
let $query = "INSERT DELAYED INTO t1 VALUES (null, 'Dr. No'), (null, 'From Russia With Love'), (null, 'Goldfinger'), (null, 'Thunderball'), (null, 'You Only Live Twice')"; let $query = "INSERT DELAYED INTO t1 VALUES (null, 'Dr. No'), (null, 'From Russia With Love'), (null, 'Goldfinger'), (null, 'Thunderball'), (null, 'You Only Live Twice')";
--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=200 --query=$query --delimiter=";" --exec $MYSQL_SLAP --silent --concurrency=5 --iterations=200 --query=$query --delimiter=";"

View File

@ -0,0 +1,4 @@
-- require r/have_maria.require
disable_query_log;
show variables like "have_maria";
enable_query_log;

View File

@ -0,0 +1,33 @@
# Maria help script.
# Cleans up all logs to give recovery a fresh start.
# API: none, just uses vardir, port and socket.
connection admin;
-- echo * shut down mysqld, removed logs, restarted it
append_file $MYSQLTEST_VARDIR/tmp/master0.expect;
wait-maria_empty_logs.inc
EOF
--exec $MYSQLADMIN --no-defaults -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= shutdown 2>&1;
remove_file $MYSQLTEST_VARDIR/master-data/maria_log_control;
remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000001;
-- error 0,1 # maybe there is just one log
remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000002;
# Hope there were not more than these logs.
-- error 0,1
remove_file $MYSQLTEST_VARDIR/master-data/maria_recovery.trace;
append_file $MYSQLTEST_VARDIR/tmp/master0.expect;
restart-maria_empty_logs.inc
EOF
--source include/wait_until_connected_again.inc
connection default;
# the effect of "use" is lost after a restart so we are back into db "test",
# because connection 'default' was created with db "test".
use mysqltest;

View File

@ -0,0 +1,48 @@
# Maria helper script
# Copies table' data and index file to other directory, or back, or compares.
# The other directory looks like a database directory, so that we can
# read copies from inside mysqld, that's also why we copy the frm.
# "mms" is a namespace for Maria_Make_Snapshot
# API:
# 1) set one of
# $mms_copy : to copy table from database to spare directory
# $mms_reverse : to copy it back
# $mms_compare_physically : to compare both byte-for-byte
# 2) set $mms_table_to_use to a number N: table will be mysqltest.tN
# 3) set $mms_purpose to say what this copy is for (influences the naming
# of the spare directory).
if ($mms_copy)
{
--echo * copied t$mms_table_to_use for $mms_purpose
copy_file $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAD $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.MAD;
copy_file $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAI $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.MAI;
copy_file $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.frm $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.frm;
}
if ($mms_reverse_copy)
{
# do not call this without flushing target table first!
--echo * copied t$mms_table_to_use back for $mms_purpose
-- error 0,1
remove_file $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAD;
copy_file $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.MAD $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAD;
-- error 0,1
remove_file $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAI;
copy_file $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.MAI $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAI;
}
if ($mms_compare_physically)
{
# After the UNDO phase this is normally impossible
# (UNDO execution has created new log records => pages have new LSNs).
# So, do this only when testing REDO phase.
# If UNDO phase, we nevertheless compare checksums
# (see maria_verify_recovery.inc).
--echo * compared t$mms_table_to_use to old version
diff_files $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAD $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.MAD;
# index file not yet recovered
# diff_files $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAI $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.MAI;
}

View File

@ -0,0 +1,30 @@
# Maria helper script
# Copies clean tables' data and index file to other directory
# Tables are t1...t[$mms_tables]
# They are later used as a reference to see if recovery works.
# API:
# set $mms_tables to N, the script will cover tables mysqltest.t1,...tN
connection admin;
let $mms_table_to_use=$mms_tables;
let $mms_purpose=comparison;
let $mms_copy=1;
--disable_query_log
--disable_warnings
eval drop database if exists mysqltest_for_$mms_purpose;
--enable_warnings
eval create database mysqltest_for_$mms_purpose;
--enable_query_log
while ($mms_table_to_use)
{
# to serve as a reference, table must be in a clean state
eval flush table t$mms_table_to_use;
-- source include/maria_make_snapshot.inc
dec $mms_table_to_use;
}
let $mms_copy=0;
connection default;

View File

@ -0,0 +1,35 @@
# Maria helper script
# Copies tables' data and index file to other directory, and control file.
# Tables are t1...t[$mms_tables].
# Later, mysqld is shutdown, and that snapshot is put back into the
# datadir, control file too ("flashing recovery's brain"), and recovery is let
# to run on it (see maria_verify_recovery.inc).
# API:
# set $mms_tables to N, the script will cover tables mysqltest.t1,...tN
connection admin;
let $mms_table_to_use=$mms_tables;
let $mms_purpose=feeding_recovery;
let $mms_copy=1;
--disable_query_log
--disable_warnings
eval drop database if exists mysqltest_for_$mms_purpose;
--enable_warnings
eval create database mysqltest_for_$mms_purpose;
--enable_query_log
while ($mms_table_to_use)
{
-- source include/maria_make_snapshot.inc
dec $mms_table_to_use;
}
let $mms_copy=0;
-- error 0,1
remove_file $MYSQLTEST_VARDIR/tmp/mms_for_$mms_purpose.maria_log_control;
copy_file $MYSQLTEST_VARDIR/master-data/maria_log_control $MYSQLTEST_VARDIR/tmp/mms_for_$mms_purpose.maria_log_control;
connection default;

View File

@ -0,0 +1,96 @@
# Maria helper script.
# Runs recovery, compare with expected table data.
# API:
# 1) set $mms_tables to N, the script will cover tables mysqltest.t1,...tN
# 2) set $mvr_debug_option to the crash way
# 3) set $mvr_crash_statement to the statement which will trigger a crash
# 4) set $mvr_restore_old_snapshot to 1 if you want recovery to run on
# an old copy of tables and of the control file, 0 for normal recovery.
# 5) set $mms_compare_physically to 1 if you want a physical byte-for-byte
# comparison with expected table. Checksum comparison is always done.
# "mvr" is a namespace for Maria_Verify_Recovery
connection admin;
# we may do a copy-back of tables before comparison, so save comparison
# request made by caller:
let $mms_compare_physically_save=$mms_compare_physically;
let $mms_compare_physically=0;
# warn mtr that mysqld is going to die and should not be restarted immediately
#append_file $MYSQLTEST_VARDIR/tmp/master0.expect;
#wait-maria_verify_recovery.inc
#EOF
# todo: remove this "system" and uncomment above when BUG#32296 is fixed
system echo wait-maria_verify_recovery.inc >> $MYSQLTEST_VARDIR/tmp/master0.expect;
# flush page cache and log, only log, or nothing, and kill mysqld with
# abort().
# When we restore an old snapshot, we could just kill mysqld nicely,
# but that would implicitely commit all work, which the tester may
# not want (tester may want to observe rollback happening).
eval SET SESSION debug=$mvr_debug_option;
--echo * crashing mysqld intentionally
--error 2013
eval $mvr_crash_statement; # this will crash (DBUG magic)
if ($mvr_restore_old_snapshot)
{
# copy snapshot made by maria_make_snapshot_for_feeding_recovery back
# into datadir.
let $mms_table_to_use=$mms_tables;
let $mms_purpose=feeding_recovery;
let $mms_reverse_copy=1;
while ($mms_table_to_use)
{
-- source include/maria_make_snapshot.inc
dec $mms_table_to_use;
}
let $mms_reverse_copy=0;
# also copy back control file, to force recovery to start from an early
# point, ignoring further checkpoints.
-- error 0,1
remove_file $MYSQLTEST_VARDIR/master-data/maria_log_control;
copy_file $MYSQLTEST_VARDIR/tmp/mms_for_$mms_purpose.maria_log_control $MYSQLTEST_VARDIR/master-data/maria_log_control;
}
--echo * recovery happens
# let mtr restart mysqld (and thus execute the maria log)
#append_file $MYSQLTEST_VARDIR/tmp/master0.expect;
#restart-maria_verify_recovery.inc
#EOF
system echo restart-maria_verify_recovery.inc >> $MYSQLTEST_VARDIR/tmp/master0.expect;
--source include/wait_until_connected_again.inc
# Compare that tables of $mms_tables are identical to old.
# We always compare with CHECKSUM TABLE, and if requested (which makes sense
# only for testing the REDO phase, as UNDO phase generates new records so new
# LSNs on pages.) with a physical byte-for-byte comparison.
let $mms_table_to_use=$mms_tables;
let $mms_purpose=comparison;
let $mms_compare_physically=$mms_compare_physically_save;
while ($mms_table_to_use)
{
eval check table t$mms_table_to_use extended;
--echo * testing that checksum after recovery is as expected
let $new_checksum=`CHECKSUM TABLE t$mms_table_to_use`;
let $old_checksum=`CHECKSUM TABLE mysqltest_for_$mms_purpose.t$mms_table_to_use`;
# the $ text variables above are of the form "db.tablename\tchecksum",
# as db differs, we use substring().
--disable_query_log
eval select if(substring("$new_checksum",instr("$new_checksum",".t1")) = substring("$old_checksum",instr("$old_checksum",".t1")),"ok","failure") as "Checksum-check";
--enable_query_log
# this script may compare physically or do nothing
-- source include/maria_make_snapshot.inc
dec $mms_table_to_use;
}
connection default;
# the effect of "use" is lost after a restart so we are back into db "test"
use mysqltest;

View File

@ -52,7 +52,7 @@ set @arg14= 'abc';
set @arg14= NULL ; set @arg14= NULL ;
set @arg15= CAST('abc' as binary) ; set @arg15= CAST('abc' as binary) ;
set @arg15= NULL ; set @arg15= NULL ;
create table t5 as select eval create table t5 engine = MyISAM as select
8 as const01, @arg01 as param01, 8 as const01, @arg01 as param01,
8.0 as const02, @arg02 as param02, 8.0 as const02, @arg02 as param02,
80.00000000000e-1 as const03, @arg03 as param03, 80.00000000000e-1 as const03, @arg03 as param03,

View File

@ -1,12 +1,14 @@
# #
# Include this script to wait until the connection to the # Include this script to wait until the connection to the
# server has been restored or timeout occurs # server has been restored or timeout occurs.
# You should have done --enable_reconnect first
--disable_result_log --disable_result_log
--disable_query_log --disable_query_log
let $counter= 500; let $counter= 500;
let $mysql_errno= 1;
while ($mysql_errno) while ($mysql_errno)
{ {
--error 0,2002,2006 --error 0,2002,2003,2006
show status; show status;
dec $counter; dec $counter;

View File

@ -474,12 +474,6 @@ sub mtr_kill_leftovers () {
} }
} }
} }
else
{
mtr_warning("Found non pid file $elem in $rundir")
if -f "$rundir/$elem";
next;
}
} }
closedir(RUNDIR); closedir(RUNDIR);
@ -886,15 +880,33 @@ sub check_expected_crash_and_restart($)
mtr_verbose("$mysqld->{'type'} $mysqld->{'idx'} exited, pid: $ret_pid"); mtr_verbose("$mysqld->{'type'} $mysqld->{'idx'} exited, pid: $ret_pid");
$mysqld->{'pid'}= 0; $mysqld->{'pid'}= 0;
# Check if crash expected and restart if it was # Check if crash expected, and restart if it was
my $expect_file= "$::opt_vardir/tmp/" . "$mysqld->{'type'}" . my $expect_file= "$::opt_vardir/tmp/" . "$mysqld->{'type'}" .
"$mysqld->{'idx'}" . ".expect"; "$mysqld->{'idx'}" . ".expect";
if ( -f $expect_file ) while ( 1 )
{ {
mtr_verbose("Crash was expected, file $expect_file exists"); if ( -f $expect_file )
mysqld_start($mysqld, $mysqld->{'start_opts'}, {
$mysqld->{'start_slave_master_info'}); mtr_verbose("Crash was expected, file $expect_file exists");
unlink($expect_file); my $expect_file_handler;
open($expect_file_handler, "<$expect_file") or die;
my @expect_lines= <$expect_file_handler>;
close $expect_file_handler;
# look at most recent order by the test
my $expect_content= pop @expect_lines;
chomp $expect_content;
if ( $expect_content =~ /^wait/ )
{
mtr_verbose("Test asks that we wait before restart");
# Millisceond sleep emulated with select
select(undef, undef, undef, (0.1));
next;
}
unlink($expect_file);
mysqld_start($mysqld, $mysqld->{'start_opts'},
$mysqld->{'start_slave_master_info'});
}
last;
} }
return; return;
@ -914,8 +926,8 @@ sub check_expected_crash_and_restart($)
if ( -f $expect_file ) if ( -f $expect_file )
{ {
mtr_verbose("Crash was expected, file $expect_file exists"); mtr_verbose("Crash was expected, file $expect_file exists");
ndbmgmd_start($cluster);
unlink($expect_file); unlink($expect_file);
ndbmgmd_start($cluster);
} }
return; return;
} }
@ -933,9 +945,9 @@ sub check_expected_crash_and_restart($)
if ( -f $expect_file ) if ( -f $expect_file )
{ {
mtr_verbose("Crash was expected, file $expect_file exists"); mtr_verbose("Crash was expected, file $expect_file exists");
unlink($expect_file);
ndbd_start($cluster, $ndbd->{'idx'}, ndbd_start($cluster, $ndbd->{'idx'},
$ndbd->{'start_extra_args'}); $ndbd->{'start_extra_args'});
unlink($expect_file);
} }
return; return;
} }

View File

@ -216,7 +216,7 @@ sub mtr_report_stats ($) {
# the "var/log/*.err" files. We save this info in "var/log/warnings" # the "var/log/*.err" files. We save this info in "var/log/warnings"
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
if ( ! $::glob_use_running_server ) if ( ! $::glob_use_running_server && !$::opt_extern)
{ {
# Save and report if there was any fatal warnings/errors in err logs # Save and report if there was any fatal warnings/errors in err logs

View File

@ -175,6 +175,7 @@ our $opt_big_test= 0;
our @opt_combination; our @opt_combination;
our @opt_extra_mysqld_opt; our @opt_extra_mysqld_opt;
our @opt_extra_mysqltest_opt;
our $opt_compress; our $opt_compress;
our $opt_ssl; our $opt_ssl;
@ -590,6 +591,9 @@ sub command_line_setup () {
# Extra options used when starting mysqld # Extra options used when starting mysqld
'mysqld=s' => \@opt_extra_mysqld_opt, 'mysqld=s' => \@opt_extra_mysqld_opt,
# Extra options used when starting mysqld
'mysqltest=s' => \@opt_extra_mysqltest_opt,
# Run test on running server # Run test on running server
'extern' => \$opt_extern, 'extern' => \$opt_extern,
'ndb-connectstring=s' => \$opt_ndbconnectstring, 'ndb-connectstring=s' => \$opt_ndbconnectstring,
@ -954,7 +958,7 @@ sub command_line_setup () {
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
if ($opt_extern) if ($opt_extern)
{ {
mtr_report("Disable instance manager when running with extern mysqld"); # mtr_report("Disable instance manager when running with extern mysqld");
$opt_skip_im= 1; $opt_skip_im= 1;
} }
elsif ( $mysql_version_id < 50000 ) elsif ( $mysql_version_id < 50000 )
@ -1323,19 +1327,6 @@ sub command_line_setup () {
$path_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log"; $path_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log";
$path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/"; $path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/";
if ( $opt_valgrind and $opt_debug )
{
# When both --valgrind and --debug is selected, send
# all output to the trace file, making it possible to
# see the exact location where valgrind complains
foreach my $mysqld (@{$master}, @{$slave})
{
my $sidx= $mysqld->{idx} ? "$mysqld->{idx}" : "";
$mysqld->{path_myerr}=
"$opt_vardir/log/" . $mysqld->{type} . "$sidx.trace";
}
}
} }
# #
@ -2117,7 +2108,10 @@ sub environment_setup () {
$ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables; $ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables;
} }
$ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}= $file_mysql_fix_privilege_tables; if ( !$opt_extern )
{
$ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}= $file_mysql_fix_privilege_tables;
}
# ---------------------------------------------------- # ----------------------------------------------------
# Setup env so childs can execute my_print_defaults # Setup env so childs can execute my_print_defaults
@ -2417,6 +2411,25 @@ sub setup_vardir() {
{ {
unlink($name); unlink($name);
} }
if ( $opt_valgrind and $opt_debug )
{
# When both --valgrind and --debug is selected, send
# all output to the trace file, making it possible to
# see the exact location where valgrind complains
foreach my $mysqld (@{$master}, @{$slave})
{
my $sidx= $mysqld->{idx} ? "$mysqld->{idx}" : "";
my $trace_name= "$opt_vardir/log/" . $mysqld->{type} . "$sidx.trace";
open(LOG, ">$mysqld->{path_myerr}") or die "Can't create $mysqld->{path_myerr}\n";
print LOG "
NOTE: When running with --valgrind --debug the output from the .err file is
stored together with the trace file to make it easier to find the exact
position for valgrind errors.
See trace file $trace_name.\n";
close(LOG);
$mysqld->{path_myerr}= $trace_name;
}
}
} }
@ -3102,6 +3115,7 @@ sub install_db ($$) {
mtr_add_arg($args, "--datadir=%s", $data_dir); mtr_add_arg($args, "--datadir=%s", $data_dir);
mtr_add_arg($args, "--loose-skip-innodb"); mtr_add_arg($args, "--loose-skip-innodb");
mtr_add_arg($args, "--loose-skip-ndbcluster"); mtr_add_arg($args, "--loose-skip-ndbcluster");
mtr_add_arg($args, "--sync-frm=0");
mtr_add_arg($args, "--tmpdir=."); mtr_add_arg($args, "--tmpdir=.");
mtr_add_arg($args, "--core-file"); mtr_add_arg($args, "--core-file");
@ -3857,6 +3871,7 @@ sub mysqld_arguments ($$$$) {
mtr_add_arg($args, "%s--datadir=%s", $prefix, mtr_add_arg($args, "%s--datadir=%s", $prefix,
$mysqld->{'path_myddir'}); $mysqld->{'path_myddir'});
mtr_add_arg($args, "--sync-frm=0"); # Faster test
if ( $mysql_version_id >= 50106 ) if ( $mysql_version_id >= 50106 )
{ {
@ -4843,6 +4858,11 @@ sub run_mysqltest ($) {
mtr_add_arg($args, "--skip-ssl"); mtr_add_arg($args, "--skip-ssl");
} }
foreach my $arg ( @opt_extra_mysqltest_opt )
{
mtr_add_arg($args, "%s", $arg);
}
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# If embedded server, we create server args to give mysqltest to pass on # If embedded server, we create server args to give mysqltest to pass on
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
@ -4959,12 +4979,7 @@ sub gdb_arguments {
{ {
# write init file for mysqld # write init file for mysqld
mtr_tofile($gdb_init_file, mtr_tofile($gdb_init_file,
"set args $str\n" . "set args $str\n");
"break mysql_parse\n" .
"commands 1\n" .
"disable 1\n" .
"end\n" .
"run");
} }
if ( $opt_manual_gdb ) if ( $opt_manual_gdb )
@ -5024,11 +5039,7 @@ sub ddd_arguments {
# write init file for mysqld # write init file for mysqld
mtr_tofile($gdb_init_file, mtr_tofile($gdb_init_file,
"file $$exe\n" . "file $$exe\n" .
"set args $str\n" . "set args $str\n");
"break mysql_parse\n" .
"commands 1\n" .
"disable 1\n" .
"end");
} }
if ( $opt_manual_ddd ) if ( $opt_manual_ddd )

View File

@ -298,7 +298,7 @@ t1 0 a 1 a A 3 NULL NULL YES BTREE
t1 0 a 2 b A 300 NULL NULL YES BTREE t1 0 a 2 b A 300 NULL NULL YES BTREE
t1 1 b 1 b A 100 NULL NULL YES BTREE t1 1 b 1 b A 100 NULL NULL YES BTREE
drop table t1; drop table t1;
CREATE TABLE t1 (i int(10), index(i) ); CREATE TABLE t1 (i int(10), index(i) ) ENGINE=MyISAM;
ALTER TABLE t1 DISABLE KEYS; ALTER TABLE t1 DISABLE KEYS;
INSERT DELAYED INTO t1 VALUES(1),(2),(3); INSERT DELAYED INTO t1 VALUES(1),(2),(3);
ALTER TABLE t1 ENABLE KEYS; ALTER TABLE t1 ENABLE KEYS;

View File

@ -11,3 +11,4 @@ Level Warning
Code 1592 Code 1592
Message Statement is not safe to log in statement format. Message Statement is not safe to log in statement format.
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
DROP VIEW v1;

View File

@ -1717,7 +1717,7 @@ t1 CREATE TABLE `t1` (
`TIME` bigint(7) NOT NULL DEFAULT '0', `TIME` bigint(7) NOT NULL DEFAULT '0',
`STATE` varchar(64) DEFAULT NULL, `STATE` varchar(64) DEFAULT NULL,
`INFO` longtext `INFO` longtext
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ) ENGINE=MARIA DEFAULT CHARSET=utf8
drop table t1; drop table t1;
create temporary table t1 like information_schema.processlist; create temporary table t1 like information_schema.processlist;
show create table t1; show create table t1;
@ -1731,7 +1731,7 @@ t1 CREATE TEMPORARY TABLE `t1` (
`TIME` bigint(7) NOT NULL DEFAULT '0', `TIME` bigint(7) NOT NULL DEFAULT '0',
`STATE` varchar(64) DEFAULT NULL, `STATE` varchar(64) DEFAULT NULL,
`INFO` longtext `INFO` longtext
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ) ENGINE=MARIA DEFAULT CHARSET=utf8
drop table t1; drop table t1;
create table t1 like information_schema.character_sets; create table t1 like information_schema.character_sets;
show create table t1; show create table t1;

View File

@ -0,0 +1,2 @@
Variable_name Value
have_maria YES

View File

@ -1416,7 +1416,7 @@ insert t2 select * from t1;
insert t3 select * from t1; insert t3 select * from t1;
checksum table t1, t2, t3, t4 quick; checksum table t1, t2, t3, t4 quick;
Table Checksum Table Checksum
test.t1 2948697075 test.t1 3442722830
test.t2 NULL test.t2 NULL
test.t3 NULL test.t3 NULL
test.t4 NULL test.t4 NULL
@ -1424,17 +1424,17 @@ Warnings:
Error 1146 Table 'test.t4' doesn't exist Error 1146 Table 'test.t4' doesn't exist
checksum table t1, t2, t3, t4; checksum table t1, t2, t3, t4;
Table Checksum Table Checksum
test.t1 2948697075 test.t1 3442722830
test.t2 2948697075 test.t2 3442722830
test.t3 2948697075 test.t3 3442722830
test.t4 NULL test.t4 NULL
Warnings: Warnings:
Error 1146 Table 'test.t4' doesn't exist Error 1146 Table 'test.t4' doesn't exist
checksum table t1, t2, t3, t4 extended; checksum table t1, t2, t3, t4 extended;
Table Checksum Table Checksum
test.t1 2948697075 test.t1 3442722830
test.t2 2948697075 test.t2 3442722830
test.t3 2948697075 test.t3 3442722830
test.t4 NULL test.t4 NULL
Warnings: Warnings:
Error 1146 Table 'test.t4' doesn't exist Error 1146 Table 'test.t4' doesn't exist

View File

@ -0,0 +1,63 @@
set storage_engine=maria;
affected rows: 0
set global maria_log_file_size=4294967295;
affected rows: 0
drop table if exists t1, t2;
affected rows: 0
create table t1(a char(3));
affected rows: 0
insert into t1 values("abc");
affected rows: 1
insert into t1 select "def" from t1;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
insert into t1 select "ghi" from t1;
affected rows: 2
info: Records: 2 Duplicates: 0 Warnings: 0
insert into t1 select "jkl" from t1;
affected rows: 4
info: Records: 4 Duplicates: 0 Warnings: 0
insert into t1 select "mno" from t1;
affected rows: 8
info: Records: 8 Duplicates: 0 Warnings: 0
insert into t1 select "pqr" from t1;
affected rows: 16
info: Records: 16 Duplicates: 0 Warnings: 0
insert into t1 select "stu" from t1;
affected rows: 32
info: Records: 32 Duplicates: 0 Warnings: 0
insert into t1 select "vwx" from t1;
affected rows: 64
info: Records: 64 Duplicates: 0 Warnings: 0
insert into t1 select "yza" from t1;
affected rows: 128
info: Records: 128 Duplicates: 0 Warnings: 0
insert into t1 select "ceg" from t1;
affected rows: 256
info: Records: 256 Duplicates: 0 Warnings: 0
insert into t1 select "ikm" from t1;
affected rows: 512
info: Records: 512 Duplicates: 0 Warnings: 0
insert into t1 select "oqs" from t1;
affected rows: 1024
info: Records: 1024 Duplicates: 0 Warnings: 0
select count(*) from t1;
count(*)
2048
affected rows: 1
insert into t1 select "uwy" from t1;
affected rows: 2048
info: Records: 2048 Duplicates: 0 Warnings: 0
create table t2 select * from t1;
affected rows: 4096
info: Records: 4096 Duplicates: 0 Warnings: 0
select count(*) from t1;
count(*)
4096
affected rows: 1
select count(*) from t2;
count(*)
4096
affected rows: 1
drop table t1, t2;
affected rows: 0

View File

@ -0,0 +1,24 @@
set global storage_engine=maria;
set session storage_engine=maria;
set global maria_log_file_size=4294967295;
drop table if exists t1;
SET SQL_WARNINGS=1;
RESET MASTER;
set binlog_format=statement;
CREATE TABLE t1 (a int primary key);
insert t1 values (1),(2),(3);
insert t1 values (4),(2),(5);
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
select * from t1;
a
1
2
3
4
SHOW BINLOG EVENTS FROM 106;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 106 Query 1 204 use `test`; CREATE TABLE t1 (a int primary key)
master-bin.000001 204 Query 1 295 use `test`; insert t1 values (1),(2),(3)
master-bin.000001 295 Query 1 386 use `test`; insert t1 values (4),(2),(5)
drop table t1;
set binlog_format=default;

View File

@ -0,0 +1,92 @@
set global storage_engine=maria;
set session storage_engine=maria;
set global maria_log_file_size=4294967296;
drop table if exists t1,t2;
SET SQL_WARNINGS=1;
CREATE TABLE t1 (
STRING_DATA char(255) default NULL
);
CREATE TABLE t2 (
STRING_DATA char(255) default NULL
);
INSERT INTO t1 VALUES ('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
INSERT INTO t1 VALUES ('DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD');
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
set global maria_log_file_size=16777216;
set global maria_checkpoint_interval=30;
SHOW ENGINE maria logs;
Type Name Status
maria master-data/maria_log.00000002 in use
insert into t2 select * from t1;
insert into t1 select * from t2;
set global maria_checkpoint_interval=30;
SHOW ENGINE maria logs;
Type Name Status
maria master-data/maria_log.00000004 in use
set global maria_log_file_size=16777216;
select @@global.maria_log_file_size;
@@global.maria_log_file_size
16777216
set global maria_checkpoint_interval=30;
SHOW ENGINE maria logs;
Type Name Status
maria master-data/maria_log.00000004 in use
set global maria_log_file_size=8388608;
select @@global.maria_log_file_size;
@@global.maria_log_file_size
8388608
set global maria_log_purge_type=at_flush;
insert into t1 select * from t2;
set global maria_checkpoint_interval=30;
SHOW ENGINE maria logs;
Type Name Status
maria master-data/maria_log.00000004 free
maria master-data/maria_log.00000005 free
maria master-data/maria_log.00000006 free
maria master-data/maria_log.00000007 free
maria master-data/maria_log.00000008 in use
flush logs;
SHOW ENGINE maria logs;
Type Name Status
maria master-data/maria_log.00000008 in use
set global maria_log_file_size=16777216;
set global maria_log_purge_type=external;
insert into t1 select * from t2;
set global maria_checkpoint_interval=30;
SHOW ENGINE maria logs;
Type Name Status
maria master-data/maria_log.00000008 free
maria master-data/maria_log.00000009 in use
flush logs;
SHOW ENGINE maria logs;
Type Name Status
maria master-data/maria_log.00000008 free
maria master-data/maria_log.00000009 in use
set global maria_log_purge_type=immediate;
insert into t1 select * from t2;
set global maria_checkpoint_interval=30;
SHOW ENGINE maria logs;
Type Name Status
maria master-data/maria_log.00000011 in use
drop table t1, t2;

View File

@ -0,0 +1,29 @@
drop database if exists mysqltest;
create database mysqltest;
use mysqltest;
* shut down mysqld, removed logs, restarted it
use mysqltest;
create table t1 (a varchar(10000)) engine=maria;
* TEST of over-allocated bitmap not flushed by checkpoint
insert into t1 values ("bbbbbbb");
flush table t1;
* copied t1 for comparison
insert into t1 values ("bbbbbbb");
delete from t1 limit 1;
set session debug="+d,info,enter,exit,maria_over_alloc_bitmap";
insert into t1 values ("aaaaaaaaa");
set global maria_checkpoint_interval=1;
SET SESSION debug="+d,maria_crash";
* crashing mysqld intentionally
set global maria_checkpoint_interval=1;
ERROR HY000: Lost connection to MySQL server during query
* recovery happens
check table t1 extended;
Table Op Msg_type Msg_text
mysqltest.t1 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
use mysqltest;
drop database mysqltest_for_comparison;
drop database mysqltest;

View File

@ -0,0 +1,219 @@
set global maria_log_file_size=4294967295;
drop database if exists mysqltest;
create database mysqltest;
use mysqltest;
* shut down mysqld, removed logs, restarted it
use mysqltest;
create table t1 (a varchar(1000)) engine=maria;
* TEST of REDO: see if recovery can reconstruct if we give it an old table
* copied t1 for feeding_recovery
insert into t1 values ("00000000");
flush table t1;
* copied t1 for comparison
SET SESSION debug="+d,maria_flush_whole_log,maria_crash";
* crashing mysqld intentionally
set global maria_checkpoint_interval=1;
ERROR HY000: Lost connection to MySQL server during query
* copied t1 back for feeding_recovery
* recovery happens
check table t1 extended;
Table Op Msg_type Msg_text
mysqltest.t1 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
* compared t1 to old version
use mysqltest;
select * from t1;
a
00000000
* TEST of REDO+UNDO: normal recovery test (no moving tables under its feet)
insert into t1 values ("00000000");
flush table t1;
* copied t1 for comparison
lock tables t1 write;
insert into t1 values ("aaaaaaaaa");
SET SESSION debug="+d,maria_crash";
* crashing mysqld intentionally
set global maria_checkpoint_interval=1;
ERROR HY000: Lost connection to MySQL server during query
* recovery happens
check table t1 extended;
Table Op Msg_type Msg_text
mysqltest.t1 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
use mysqltest;
select * from t1;
a
00000000
00000000
insert into t1 values ("00000000");
flush table t1;
* copied t1 for comparison
lock tables t1 write;
insert into t1 values ("aaaaaaaaa");
SET SESSION debug="+d,maria_flush_whole_page_cache,maria_crash";
* crashing mysqld intentionally
set global maria_checkpoint_interval=1;
ERROR HY000: Lost connection to MySQL server during query
* recovery happens
check table t1 extended;
Table Op Msg_type Msg_text
mysqltest.t1 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
use mysqltest;
select * from t1;
a
00000000
00000000
00000000
insert into t1 values ("00000000");
flush table t1;
* copied t1 for comparison
lock tables t1 write;
insert into t1 values ("aaaaaaaaa");
SET SESSION debug="+d,maria_flush_states,maria_flush_whole_log,maria_crash";
* crashing mysqld intentionally
set global maria_checkpoint_interval=1;
ERROR HY000: Lost connection to MySQL server during query
* recovery happens
check table t1 extended;
Table Op Msg_type Msg_text
mysqltest.t1 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
use mysqltest;
select * from t1;
a
00000000
00000000
00000000
00000000
insert into t1 values ("00000000");
flush table t1;
* copied t1 for comparison
lock tables t1 write;
insert into t1 values ("aaaaaaaaa");
SET SESSION debug="+d,maria_flush_whole_log,maria_crash";
* crashing mysqld intentionally
set global maria_checkpoint_interval=1;
ERROR HY000: Lost connection to MySQL server during query
* recovery happens
check table t1 extended;
Table Op Msg_type Msg_text
mysqltest.t1 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
use mysqltest;
select * from t1;
a
00000000
00000000
00000000
00000000
00000000
drop table t1;
* TEST of two REDOs for same page in one REDO group
* shut down mysqld, removed logs, restarted it
use mysqltest;
CREATE TABLE t1 (
i int,
b blob default NULL,
c varchar(6000) default NULL
) ENGINE=MARIA CHECKSUM=1;
* copied t1 for feeding_recovery
INSERT INTO t1 VALUES (1, REPEAT('a', 5000), REPEAT('b', 5000));
UPDATE t1 SET i=3, b=CONCAT(b,'c') WHERE i=1;
SELECT LENGTH(b) FROM t1 WHERE i=3;
LENGTH(b)
5001
flush table t1;
* copied t1 for comparison
SET SESSION debug="+d,maria_flush_whole_log,maria_crash";
* crashing mysqld intentionally
set global maria_checkpoint_interval=1;
ERROR HY000: Lost connection to MySQL server during query
* copied t1 back for feeding_recovery
* recovery happens
check table t1 extended;
Table Op Msg_type Msg_text
mysqltest.t1 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
use mysqltest;
SELECT LENGTH(b) FROM t1 WHERE i=3;
LENGTH(b)
5001
drop table t1;
* TEST of INSERT vs state.auto_increment
* shut down mysqld, removed logs, restarted it
use mysqltest;
CREATE TABLE t1 (
i int auto_increment primary key,
c varchar(6),
key(c)
) ENGINE=MARIA;
insert into t1 values(null,"b");
* copied t1 for feeding_recovery
insert into t1 values(null,"a"), (null,"c"), (null,"d");
delete from t1 where c="d";
flush table t1;
* copied t1 for comparison
SET SESSION debug="+d,maria_flush_whole_log,maria_crash";
* crashing mysqld intentionally
set global maria_checkpoint_interval=1;
ERROR HY000: Lost connection to MySQL server during query
* copied t1 back for feeding_recovery
* recovery happens
check table t1 extended;
Table Op Msg_type Msg_text
mysqltest.t1 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
use mysqltest;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) NOT NULL AUTO_INCREMENT,
`c` varchar(6) DEFAULT NULL,
PRIMARY KEY (`i`),
KEY `c` (`c`)
) ENGINE=MARIA AUTO_INCREMENT=5 DEFAULT CHARSET=latin1
* TEST of UPDATE vs state.auto_increment
* copied t1 for feeding_recovery
update t1 set i=15 where c="a";
flush table t1;
* copied t1 for comparison
SET SESSION debug="+d,maria_flush_whole_log,maria_crash";
* crashing mysqld intentionally
set global maria_checkpoint_interval=1;
ERROR HY000: Lost connection to MySQL server during query
* copied t1 back for feeding_recovery
* recovery happens
check table t1 extended;
Table Op Msg_type Msg_text
mysqltest.t1 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
use mysqltest;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) NOT NULL AUTO_INCREMENT,
`c` varchar(6) DEFAULT NULL,
PRIMARY KEY (`i`),
KEY `c` (`c`)
) ENGINE=MARIA AUTO_INCREMENT=16 DEFAULT CHARSET=latin1
drop table t1;
drop database mysqltest_for_feeding_recovery;
drop database mysqltest_for_comparison;
drop database mysqltest;

2081
mysql-test/r/maria.result Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,5 @@
set global storage_engine=myisam;
set session storage_engine=myisam;
drop table if exists t1,t2,t3,t4,t5,t6; drop table if exists t1,t2,t3,t4,t5,t6;
drop database if exists mysqltest; drop database if exists mysqltest;
create table t1 (a int not null primary key auto_increment, message char(20)); create table t1 (a int not null primary key auto_increment, message char(20));

View File

@ -1232,34 +1232,34 @@ insert t5 select * from t1;
insert t6 select * from t1; insert t6 select * from t1;
checksum table t1, t2, t3, t4, t5, t6, t7 quick; checksum table t1, t2, t3, t4, t5, t6, t7 quick;
Table Checksum Table Checksum
test.t1 2948697075 test.t1 3442722830
test.t2 NULL test.t2 NULL
test.t3 NULL test.t3 NULL
test.t4 NULL test.t4 NULL
test.t5 2948697075 test.t5 3442722830
test.t6 NULL test.t6 NULL
test.t7 NULL test.t7 NULL
Warnings: Warnings:
Error 1146 Table 'test.t7' doesn't exist Error 1146 Table 'test.t7' doesn't exist
checksum table t1, t2, t3, t4, t5, t6, t7; checksum table t1, t2, t3, t4, t5, t6, t7;
Table Checksum Table Checksum
test.t1 2948697075 test.t1 3442722830
test.t2 2948697075 test.t2 3442722830
test.t3 2948697075 test.t3 3442722830
test.t4 2948697075 test.t4 3442722830
test.t5 2948697075 test.t5 3442722830
test.t6 2948697075 test.t6 3442722830
test.t7 NULL test.t7 NULL
Warnings: Warnings:
Error 1146 Table 'test.t7' doesn't exist Error 1146 Table 'test.t7' doesn't exist
checksum table t1, t2, t3, t4, t5, t6, t7 extended; checksum table t1, t2, t3, t4, t5, t6, t7 extended;
Table Checksum Table Checksum
test.t1 2948697075 test.t1 3442722830
test.t2 2948697075 test.t2 3442722830
test.t3 2948697075 test.t3 3442722830
test.t4 2948697075 test.t4 3442722830
test.t5 2948697075 test.t5 3442722830
test.t6 2948697075 test.t6 3442722830
test.t7 NULL test.t7 NULL
Warnings: Warnings:
Error 1146 Table 'test.t7' doesn't exist Error 1146 Table 'test.t7' doesn't exist

View File

@ -1,4 +1,4 @@
drop table if exists t1,t2; drop table if exists t1,t2,t3;
SET SQL_WARNINGS=1; SET SQL_WARNINGS=1;
CREATE TABLE t1 ( CREATE TABLE t1 (
STRING_DATA char(255) default NULL, STRING_DATA char(255) default NULL,
@ -551,22 +551,22 @@ insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
insert t2 select * from t1; insert t2 select * from t1;
checksum table t1, t2, t3 quick; checksum table t1, t2, t3 quick;
Table Checksum Table Checksum
test.t1 2948697075 test.t1 3442722830
test.t2 NULL test.t2 NULL
test.t3 NULL test.t3 NULL
Warnings: Warnings:
Error 1146 Table 'test.t3' doesn't exist Error 1146 Table 'test.t3' doesn't exist
checksum table t1, t2, t3; checksum table t1, t2, t3;
Table Checksum Table Checksum
test.t1 2948697075 test.t1 3442722830
test.t2 2948697075 test.t2 3442722830
test.t3 NULL test.t3 NULL
Warnings: Warnings:
Error 1146 Table 'test.t3' doesn't exist Error 1146 Table 'test.t3' doesn't exist
checksum table t1, t2, t3 extended; checksum table t1, t2, t3 extended;
Table Checksum Table Checksum
test.t1 2948697075 test.t1 3442722830
test.t2 2948697075 test.t2 3442722830
test.t3 NULL test.t3 NULL
Warnings: Warnings:
Error 1146 Table 'test.t3' doesn't exist Error 1146 Table 'test.t3' doesn't exist

View File

@ -723,7 +723,7 @@ DROP TABLE t1;
# #
# Test for --insert-ignore # Test for --insert-ignore
# #
CREATE TABLE t1 (a int); CREATE TABLE t1 (a int) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2),(3); INSERT INTO t1 VALUES (1),(2),(3);
INSERT INTO t1 VALUES (4),(5),(6); INSERT INTO t1 VALUES (4),(5),(6);
@ -3644,8 +3644,8 @@ CREATE TABLE t1(a int);
INSERT INTO t1 VALUES (1), (2); INSERT INTO t1 VALUES (1), (2);
mysqldump: Input filename too long: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa mysqldump: Input filename too long: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t2 (a int); CREATE TABLE t2 (a int) ENGINE=MyISAM;
CREATE TABLE t3 (a int); CREATE TABLE t3 (a int) ENGINE=MyISAM;
CREATE TABLE t1 (a int) ENGINE=merge UNION=(t2, t3); CREATE TABLE t1 (a int) ENGINE=merge UNION=(t2, t3);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;

View File

@ -0,0 +1,14 @@
drop table if exists t1,t2;
create table t1 (a int, b varchar(200), c text not null) checksum=1;
create table t2 (a int, b varchar(200), c text not null) checksum=0;
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
insert t2 select * from t1;
checksum table t1, t2;
Table Checksum
test.t1 3442722830
test.t2 2948697075
checksum table t1, t2 extended;
Table Checksum
test.t1 2948697075
test.t2 2948697075
drop table t1,t2;

View File

@ -1756,7 +1756,7 @@ set @arg14= 'abc';
set @arg14= NULL ; set @arg14= NULL ;
set @arg15= CAST('abc' as binary) ; set @arg15= CAST('abc' as binary) ;
set @arg15= NULL ; set @arg15= NULL ;
create table t5 as select create table t5 engine = MyISAM as select
8 as const01, @arg01 as param01, 8 as const01, @arg01 as param01,
8.0 as const02, @arg02 as param02, 8.0 as const02, @arg02 as param02,
80.00000000000e-1 as const03, @arg03 as param03, 80.00000000000e-1 as const03, @arg03 as param03,

View File

@ -1739,7 +1739,7 @@ set @arg14= 'abc';
set @arg14= NULL ; set @arg14= NULL ;
set @arg15= CAST('abc' as binary) ; set @arg15= CAST('abc' as binary) ;
set @arg15= NULL ; set @arg15= NULL ;
create table t5 as select create table t5 engine = MyISAM as select
8 as const01, @arg01 as param01, 8 as const01, @arg01 as param01,
8.0 as const02, @arg02 as param02, 8.0 as const02, @arg02 as param02,
80.00000000000e-1 as const03, @arg03 as param03, 80.00000000000e-1 as const03, @arg03 as param03,

View File

@ -1740,7 +1740,7 @@ set @arg14= 'abc';
set @arg14= NULL ; set @arg14= NULL ;
set @arg15= CAST('abc' as binary) ; set @arg15= CAST('abc' as binary) ;
set @arg15= NULL ; set @arg15= NULL ;
create table t5 as select create table t5 engine = MyISAM as select
8 as const01, @arg01 as param01, 8 as const01, @arg01 as param01,
8.0 as const02, @arg02 as param02, 8.0 as const02, @arg02 as param02,
80.00000000000e-1 as const03, @arg03 as param03, 80.00000000000e-1 as const03, @arg03 as param03,

View File

@ -1676,7 +1676,7 @@ set @arg14= 'abc';
set @arg14= NULL ; set @arg14= NULL ;
set @arg15= CAST('abc' as binary) ; set @arg15= CAST('abc' as binary) ;
set @arg15= NULL ; set @arg15= NULL ;
create table t5 as select create table t5 engine = MyISAM as select
8 as const01, @arg01 as param01, 8 as const01, @arg01 as param01,
8.0 as const02, @arg02 as param02, 8.0 as const02, @arg02 as param02,
80.00000000000e-1 as const03, @arg03 as param03, 80.00000000000e-1 as const03, @arg03 as param03,
@ -4698,7 +4698,7 @@ set @arg14= 'abc';
set @arg14= NULL ; set @arg14= NULL ;
set @arg15= CAST('abc' as binary) ; set @arg15= CAST('abc' as binary) ;
set @arg15= NULL ; set @arg15= NULL ;
create table t5 as select create table t5 engine = MyISAM as select
8 as const01, @arg01 as param01, 8 as const01, @arg01 as param01,
8.0 as const02, @arg02 as param02, 8.0 as const02, @arg02 as param02,
80.00000000000e-1 as const03, @arg03 as param03, 80.00000000000e-1 as const03, @arg03 as param03,

3146
mysql-test/r/ps_maria.result Normal file

File diff suppressed because it is too large Load Diff

View File

@ -42,9 +42,9 @@ drop table t1;
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 0 Qcache_queries_in_cache 0
create table t1 (a int not null); create table t1 (a int not null) ENGINE=MyISAM;
insert into t1 values (1),(2),(3); insert into t1 values (1),(2),(3);
create table t2 (a int not null); create table t2 (a int not null) ENGINE=MyISAM;
insert into t2 values (4),(5),(6); insert into t2 values (4),(5),(6);
create table t3 (a int not null) engine=MERGE UNION=(t1,t2) INSERT_METHOD=FIRST; create table t3 (a int not null) engine=MERGE UNION=(t1,t2) INSERT_METHOD=FIRST;
select * from t3; select * from t3;
@ -460,7 +460,7 @@ Qcache_queries_in_cache 2
drop table t1; drop table t1;
flush query cache; flush query cache;
reset query cache; reset query cache;
create table t1 (a int not null); create table t1 (a int not null) ENGINE=MyISAM;
insert into t1 values (1),(2),(3); insert into t1 values (1),(2),(3);
select * from t1; select * from t1;
a a

View File

@ -626,8 +626,8 @@ a b
33 10 33 10
22 11 22 11
drop table t11, t12, t2; drop table t11, t12, t2;
CREATE TABLE t1 (x int); CREATE TABLE t1 (x int) ENGINE=MyISAM;
create table t2 (a int); create table t2 (a int) ENGINE=MyISAM;
create table t3 (b int); create table t3 (b int);
insert into t2 values (1); insert into t2 values (1);
insert into t3 values (1),(2); insert into t3 values (1),(2);
@ -674,7 +674,7 @@ x
11 11
2 2
drop table t1, t2, t3; drop table t1, t2, t3;
CREATE TABLE t1 (x int not null, y int, primary key (x)); CREATE TABLE t1 (x int not null, y int, primary key (x)) ENGINE=MyISAM;
create table t2 (a int); create table t2 (a int);
create table t3 (a int); create table t3 (a int);
insert into t2 values (1); insert into t2 values (1);

View File

@ -1739,7 +1739,7 @@ set @arg14= 'abc';
set @arg14= NULL ; set @arg14= NULL ;
set @arg15= CAST('abc' as binary) ; set @arg15= CAST('abc' as binary) ;
set @arg15= NULL ; set @arg15= NULL ;
create table t5 as select create table t5 engine = MyISAM as select
8 as const01, @arg01 as param01, 8 as const01, @arg01 as param01,
8.0 as const02, @arg02 as param02, 8.0 as const02, @arg02 as param02,
80.00000000000e-1 as const03, @arg03 as param03, 80.00000000000e-1 as const03, @arg03 as param03,

View File

@ -9,7 +9,7 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave; start slave;
CREATE SCHEMA IF NOT EXISTS mysqlslap; CREATE SCHEMA IF NOT EXISTS mysqlslap;
USE mysqlslap; USE mysqlslap;
CREATE TABLE t1 (id INT, name VARCHAR(64)); CREATE TABLE t1 (id INT, name VARCHAR(64)) ENGINE=MyISAM;
SELECT COUNT(*) FROM mysqlslap.t1; SELECT COUNT(*) FROM mysqlslap.t1;
COUNT(*) COUNT(*)
5000 5000

View File

@ -4,21 +4,21 @@ reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave; start slave;
create table t1 (a int); create table t1 (a int) ENGINE=MyISAM;
insert into t1 values (10); insert into t1 values (10);
create table t2 (a int); create table t2 (a int) ENGINE=MyISAM;
create table t3 (a int) engine=merge union(t1); create table t3 (a int) engine=merge union(t1);
create table t4 (a int); create table t4 (a int);
insert into t4 select * from t3; insert into t4 select * from t3;
rename table t1 to t5, t2 to t1; rename table t1 to t5, t2 to t1;
flush no_write_to_binlog tables; flush no_write_to_binlog tables;
SHOW BINLOG EVENTS FROM 623 ; SHOW BINLOG EVENTS FROM 651 ;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; rename table t1 to t5, t2 to t1 master-bin.000001 # Query 1 # use `test`; rename table t1 to t5, t2 to t1
select * from t3; select * from t3;
a a
flush tables; flush tables;
SHOW BINLOG EVENTS FROM 623 ; SHOW BINLOG EVENTS FROM 651 ;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; rename table t1 to t5, t2 to t1 master-bin.000001 # Query 1 # use `test`; rename table t1 to t5, t2 to t1
master-bin.000001 # Query 1 # use `test`; flush tables master-bin.000001 # Query 1 # use `test`; flush tables

View File

@ -11,7 +11,7 @@ USE mysqlslap;
select @@global.binlog_format; select @@global.binlog_format;
@@global.binlog_format @@global.binlog_format
ROW ROW
CREATE TABLE t1 (id INT primary key auto_increment, name VARCHAR(64)); CREATE TABLE t1 (id INT primary key auto_increment, name VARCHAR(64)) ENGINE=MyISAM;
FLUSH TABLE t1; FLUSH TABLE t1;
SELECT COUNT(*) FROM t1; SELECT COUNT(*) FROM t1;
COUNT(*) COUNT(*)

View File

@ -4,21 +4,21 @@ reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave; start slave;
create table t1 (a int); create table t1 (a int) ENGINE=MyISAM;
insert into t1 values (10); insert into t1 values (10);
create table t2 (a int); create table t2 (a int) ENGINE=MyISAM;
create table t3 (a int) engine=merge union(t1); create table t3 (a int) engine=merge union(t1);
create table t4 (a int); create table t4 (a int);
insert into t4 select * from t3; insert into t4 select * from t3;
rename table t1 to t5, t2 to t1; rename table t1 to t5, t2 to t1;
flush no_write_to_binlog tables; flush no_write_to_binlog tables;
SHOW BINLOG EVENTS FROM 656 ; SHOW BINLOG EVENTS FROM 684 ;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; rename table t1 to t5, t2 to t1 master-bin.000001 # Query 1 # use `test`; rename table t1 to t5, t2 to t1
select * from t3; select * from t3;
a a
flush tables; flush tables;
SHOW BINLOG EVENTS FROM 656 ; SHOW BINLOG EVENTS FROM 684 ;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; rename table t1 to t5, t2 to t1 master-bin.000001 # Query 1 # use `test`; rename table t1 to t5, t2 to t1
master-bin.000001 # Query 1 # use `test`; flush tables master-bin.000001 # Query 1 # use `test`; flush tables

View File

@ -11,7 +11,7 @@ USE mysqlslap;
select @@global.binlog_format; select @@global.binlog_format;
@@global.binlog_format @@global.binlog_format
STATEMENT STATEMENT
CREATE TABLE t1 (id INT primary key auto_increment, name VARCHAR(64)); CREATE TABLE t1 (id INT primary key auto_increment, name VARCHAR(64)) ENGINE=MyISAM;
FLUSH TABLE t1; FLUSH TABLE t1;
SELECT COUNT(*) FROM t1; SELECT COUNT(*) FROM t1;
COUNT(*) COUNT(*)
@ -77,7 +77,7 @@ USE mysqlslap;
select @@global.binlog_format; select @@global.binlog_format;
@@global.binlog_format @@global.binlog_format
MIXED MIXED
CREATE TABLE t1 (id INT primary key auto_increment, name VARCHAR(64)); CREATE TABLE t1 (id INT primary key auto_increment, name VARCHAR(64)) ENGINE=MyISAM;
FLUSH TABLE t1; FLUSH TABLE t1;
SELECT COUNT(*) FROM t1; SELECT COUNT(*) FROM t1;
COUNT(*) COUNT(*)

View File

@ -135,7 +135,7 @@ execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
insert into t1 values(concat("for_23_",UUID())); insert into t1 values(concat("for_23_",UUID()));
insert into t1 select "yesterday_24_"; insert into t1 select "yesterday_24_";
create table t2 select rpad(UUID(),100,' '); create table t2 ENGINE=MyISAM select rpad(UUID(),100,' ');
create table t3 select 1 union select UUID(); create table t3 select 1 union select UUID();
create table t4 select * from t1 where 3 in (select 1 union select 2 union select UUID() union select 3); create table t4 select * from t1 where 3 in (select 1 union select 2 union select UUID() union select 3);
create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3); create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3);
@ -473,7 +473,7 @@ master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # use `mysqltest1`; insert into t1 select "yesterday_24_" master-bin.000001 # Query # # use `mysqltest1`; insert into t1 select "yesterday_24_"
master-bin.000001 # Query # # use `mysqltest1`; CREATE TABLE `t2` ( master-bin.000001 # Query # # use `mysqltest1`; CREATE TABLE `t2` (
`rpad(UUID(),100,' ')` varchar(100) CHARACTER SET utf8 NOT NULL DEFAULT '' `rpad(UUID(),100,' ')` varchar(100) CHARACTER SET utf8 NOT NULL DEFAULT ''
) ) ENGINE=MyISAM
master-bin.000001 # Table_map # # table_id: # (mysqltest1.t2) master-bin.000001 # Table_map # # table_id: # (mysqltest1.t2)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # use `mysqltest1`; CREATE TABLE `t3` ( master-bin.000001 # Query # # use `mysqltest1`; CREATE TABLE `t3` (
@ -801,7 +801,7 @@ master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # use `mysqltest1`; insert into t1 select "yesterday_24_" master-bin.000001 # Query # # use `mysqltest1`; insert into t1 select "yesterday_24_"
master-bin.000001 # Query # # use `mysqltest1`; CREATE TABLE `t2` ( master-bin.000001 # Query # # use `mysqltest1`; CREATE TABLE `t2` (
`rpad(UUID(),100,' ')` varchar(100) CHARACTER SET utf8 NOT NULL DEFAULT '' `rpad(UUID(),100,' ')` varchar(100) CHARACTER SET utf8 NOT NULL DEFAULT ''
) ) ENGINE=MyISAM
master-bin.000001 # Table_map # # table_id: # (mysqltest1.t2) master-bin.000001 # Table_map # # table_id: # (mysqltest1.t2)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # use `mysqltest1`; CREATE TABLE `t3` ( master-bin.000001 # Query # # use `mysqltest1`; CREATE TABLE `t3` (

View File

@ -1,3 +1,4 @@
--source include/big_test.inc
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/have_partition.inc --source include/have_partition.inc
--source include/have_binlog_format_mixed_or_row.inc --source include/have_binlog_format_mixed_or_row.inc

View File

@ -11,7 +11,7 @@ CREATE SCHEMA IF NOT EXISTS mysqlslap;
USE mysqlslap; USE mysqlslap;
--enable_warnings --enable_warnings
CREATE TABLE t1 (id INT, name VARCHAR(64)); CREATE TABLE t1 (id INT, name VARCHAR(64)) ENGINE=MyISAM;
let $query = "INSERT DELAYED INTO t1 VALUES (1, 'Dr. No'), (2, 'From Russia With Love'), (3, 'Goldfinger'), (4, 'Thunderball'), (5, 'You Only Live Twice')"; let $query = "INSERT DELAYED INTO t1 VALUES (1, 'Dr. No'), (2, 'From Russia With Love'), (3, 'Goldfinger'), (4, 'Thunderball'), (5, 'You Only Live Twice')";
--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=200 --query=$query --delimiter=";" --exec $MYSQL_SLAP --silent --concurrency=5 --iterations=200 --query=$query --delimiter=";"

View File

@ -1,7 +1,7 @@
# depends on the binlog output # depends on the binlog output
-- source include/have_binlog_format_row.inc -- source include/have_binlog_format_row.inc
let $rename_event_pos= 623; let $rename_event_pos= 651;
# Bug#18326: Do not lock table for writing during prepare of statement # Bug#18326: Do not lock table for writing during prepare of statement
# The use of the ps protocol causes extra table maps in the binlog, so # The use of the ps protocol causes extra table maps in the binlog, so

View File

@ -1,7 +1,7 @@
# depends on the binlog output # depends on the binlog output
--source include/have_binlog_format_mixed_or_statement.inc --source include/have_binlog_format_mixed_or_statement.inc
let $rename_event_pos= 656; let $rename_event_pos= 684;
-- source extra/rpl_tests/rpl_flsh_tbls.test -- source extra/rpl_tests/rpl_flsh_tbls.test
# End of 4.1 tests # End of 4.1 tests

View File

@ -140,7 +140,7 @@ insert into t1 select "yesterday_24_";
# Test of CREATE TABLE SELECT # Test of CREATE TABLE SELECT
create table t2 select rpad(UUID(),100,' '); create table t2 ENGINE=MyISAM select rpad(UUID(),100,' ');
create table t3 select 1 union select UUID(); create table t3 select 1 union select UUID();
create table t4 select * from t1 where 3 in (select 1 union select 2 union select UUID() union select 3); create table t4 select * from t1 where 3 in (select 1 union select 2 union select UUID() union select 3);
create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3); create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3);

View File

@ -159,7 +159,7 @@ drop table t1;
# Test of ALTER TABLE DELAYED # Test of ALTER TABLE DELAYED
# #
CREATE TABLE t1 (i int(10), index(i) ); CREATE TABLE t1 (i int(10), index(i) ) ENGINE=MyISAM;
ALTER TABLE t1 DISABLE KEYS; ALTER TABLE t1 DISABLE KEYS;
INSERT DELAYED INTO t1 VALUES(1),(2),(3); INSERT DELAYED INTO t1 VALUES(1),(2),(3);
ALTER TABLE t1 ENABLE KEYS; ALTER TABLE t1 ENABLE KEYS;

View File

@ -14,5 +14,4 @@ INSERT INTO t1 SELECT UUID();
query_vertical SHOW WARNINGS; query_vertical SHOW WARNINGS;
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
DROP VIEW v1;

View File

@ -5,6 +5,15 @@
# (Can't be tested with purify :( ) # (Can't be tested with purify :( )
# #
# limit the test to engines which support INSERT DELAYED
disable_query_log;
--require r/true.require
select @@global.storage_engine in
("memory","myisam","archive","blackhole") and
@@session.storage_engine in
("memory","myisam","archive","blackhole") as `TRUE`;
enable_query_log;
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1;
--enable_warnings --enable_warnings

View File

@ -12,6 +12,7 @@
user_limits : Bug#23921 random failure of user_limits.test user_limits : Bug#23921 random failure of user_limits.test
concurrent_innodb : BUG#21579 2006-08-11 mleich innodb_concurrent random failures with varying differences concurrent_innodb : BUG#21579 2006-08-11 mleich innodb_concurrent random failures with varying differences
ctype_big5 : BUG#26711 2007-06-21 Lars Test has never worked on Double Whopper ctype_big5 : BUG#26711 2007-06-21 Lars Test has never worked on Double Whopper
federated_transactions : Bug#29523 Transactions do not work federated_transactions : Bug#29523 Transactions do not work

View File

@ -75,12 +75,10 @@ create event ev_log_general on schedule at now() on completion not preserve
--replace_column 1 USER_HOST --replace_column 1 USER_HOST
select user_host, db, sql_text from mysql.slow_log select user_host, db, sql_text from mysql.slow_log
where sql_text like 'select \'events_logs_test\'%'; where sql_text like 'select \'events_logs_test\'%';
drop database events_test; drop database events_test;
set global event_scheduler=off; set global event_scheduler=off;
set @@global.long_query_time=default; set @@global.long_query_time=default;
set @@session.long_query_time=default; set @@session.long_query_time=default;
# #
# Safety # Safety
# #

View File

@ -0,0 +1,28 @@
# Test of scenarios potentially too big for --valgrind or --mem
-- source include/have_maria.inc
enable_info;
set storage_engine=maria;
set global maria_log_file_size=4294967295;
disable_warnings;
drop table if exists t1, t2;
enable_warnings;
create table t1(a char(3));
insert into t1 values("abc");
insert into t1 select "def" from t1;
insert into t1 select "ghi" from t1;
insert into t1 select "jkl" from t1;
insert into t1 select "mno" from t1;
insert into t1 select "pqr" from t1;
insert into t1 select "stu" from t1;
insert into t1 select "vwx" from t1;
insert into t1 select "yza" from t1;
insert into t1 select "ceg" from t1;
insert into t1 select "ikm" from t1;
insert into t1 select "oqs" from t1;
select count(*) from t1;
insert into t1 select "uwy" from t1;
create table t2 select * from t1;
select count(*) from t1;
select count(*) from t2;
drop table t1, t2;
disable_info;

View File

@ -0,0 +1,42 @@
#
# Test that can't be run with --extern
#
-- source include/have_maria.inc
-- source include/have_log_bin.inc
let $default=`select @@global.storage_engine`;
set global storage_engine=maria;
set session storage_engine=maria;
set global maria_log_file_size=4294967295;
# Initialise
--disable_warnings
drop table if exists t1;
--enable_warnings
SET SQL_WARNINGS=1;
#
# UNIQUE key test
#
# as long as maria cannot rollback, binlog should contain both inserts
#
RESET MASTER;
set binlog_format=statement;
CREATE TABLE t1 (a int primary key);
insert t1 values (1),(2),(3);
--error ER_DUP_ENTRY
insert t1 values (4),(2),(5);
select * from t1;
SHOW BINLOG EVENTS FROM 106;
drop table t1;
set binlog_format=default;
# End of 5.2 tests
--disable_result_log
--disable_query_log
eval set global storage_engine=$default;
--enable_result_log
--enable_query_log

View File

@ -0,0 +1,104 @@
-- source include/have_maria.inc
-- source include/big_test.inc
let $default=`select @@global.storage_engine`;
set global storage_engine=maria;
set session storage_engine=maria;
let $def_logsize=`select @@global.maria_log_file_size`;
let $def_checkinterval=`select @@global.maria_checkpoint_interval`;
set global maria_log_file_size=4294967296;
# Initialise
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
SET SQL_WARNINGS=1;
CREATE TABLE t1 (
STRING_DATA char(255) default NULL
);
CREATE TABLE t2 (
STRING_DATA char(255) default NULL
);
INSERT INTO t1 VALUES ('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
INSERT INTO t1 VALUES ('DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD');
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
set global maria_log_file_size=16777216;
eval set global maria_checkpoint_interval=$def_checkinterval;
--replace_regex /Size +[0-9]+ ; .+master-data/master-data/
SHOW ENGINE maria logs;
insert into t2 select * from t1;
insert into t1 select * from t2;
eval set global maria_checkpoint_interval=$def_checkinterval;
--replace_regex /Size +[0-9]+ ; .+master-data/master-data/
SHOW ENGINE maria logs;
set global maria_log_file_size=16777216;
select @@global.maria_log_file_size;
eval set global maria_checkpoint_interval=$def_checkinterval;
--replace_regex /Size +[0-9]+ ; .+master-data/master-data/
SHOW ENGINE maria logs;
set global maria_log_file_size=8388608;
select @@global.maria_log_file_size;
set global maria_log_purge_type=at_flush;
insert into t1 select * from t2;
eval set global maria_checkpoint_interval=$def_checkinterval;
--replace_regex /Size +[0-9]+ ; .+master-data/master-data/
SHOW ENGINE maria logs;
flush logs;
--replace_regex /Size +[0-9]+ ; .+master-data/master-data/
SHOW ENGINE maria logs;
set global maria_log_file_size=16777216;
set global maria_log_purge_type=external;
insert into t1 select * from t2;
eval set global maria_checkpoint_interval=$def_checkinterval;
--replace_regex /Size +[0-9]+ ; .+master-data/master-data/
SHOW ENGINE maria logs;
flush logs;
--replace_regex /Size +[0-9]+ ; .+master-data/master-data/
SHOW ENGINE maria logs;
set global maria_log_purge_type=immediate;
insert into t1 select * from t2;
eval set global maria_checkpoint_interval=$def_checkinterval;
--replace_regex /Size +[0-9]+ ; .+master-data/master-data/
SHOW ENGINE maria logs;
drop table t1, t2;
--disable_result_log
--disable_query_log
set global maria_log_purge_type=immediate;
eval set global storage_engine=$default;
eval set global maria_log_file_size=$def_logsize;
eval set global maria_checkpoint_interval=$def_checkinterval;
--enable_result_log
--enable_query_log

View File

@ -0,0 +1,2 @@
--skip-stack-trace --skip-core-file

View File

@ -0,0 +1,79 @@
# Tests of Maria's recovery of the bitmap pages
--source include/not_embedded.inc
# Don't test this under valgrind, memory leaks will occur as we crash
--source include/not_valgrind.inc
# Binary must be compiled with debug for crash to occur
--source include/have_debug.inc
--source include/have_maria.inc
--disable_warnings
drop database if exists mysqltest;
--enable_warnings
create database mysqltest;
# Include scripts can perform SQL. For it to not influence the main test
# they use a separate connection. This way if they use a DDL it would
# not autocommit in the main test.
connect (admin, 127.0.0.1, root,,mysqltest,,);
--enable_reconnect
connection default;
use mysqltest;
--enable_reconnect
-- source include/maria_empty_logs.inc
let $mms_tables=1;
create table t1 (a varchar(10000)) engine=maria;
# we want recovery to use the tables as they were at time of crash
let $mvr_restore_old_snapshot=0;
# UNDO phase prevents physical comparison, normally,
# so we'll only use checksums to compare.
let $mms_compare_physically=0;
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
--echo * TEST of over-allocated bitmap not flushed by checkpoint
let $mvr_debug_option="+d,maria_crash";
insert into t1 values ("bbbbbbb");
-- source include/maria_make_snapshot_for_comparison.inc
# make_snapshot_for_comparison closed the table, which lost its id.
# So we make a null operation just to give a short id to the table so
# that checkpoint includes table in checkpoint (otherwise nothing to
# test).
insert into t1 values ("bbbbbbb");
delete from t1 limit 1;
set session debug="+d,info,enter,exit,maria_over_alloc_bitmap";
send insert into t1 values ("aaaaaaaaa");
connection admin;
# Leave time for INSERT to block after modifying bitmap;
# in the future we should not use sleep but something like
# debug_sync_point().
sleep 5;
# force a checkpoint, which could, if buggy, flush over-allocated
# bitmap page; as REDO-UNDO was not written, bitmap and data page
# would be inconsistent. Correct checkpoint will wait until UNDO is
# written.
set global maria_checkpoint_interval=1;
-- source include/maria_verify_recovery.inc
# disabled until pagecache callback framework is coded at which point
# we can add a get_lsn() callback for bitmaps, fixing the below bug.
if (0)
{
--echo * TEST of bitmap flushed without REDO-UNDO in the log (WAL violation)
# before crashing we'll flush the bitmap page
let $mvr_debug_option="+d,maria_flush_bitmap,maria_crash";
-- source include/maria_make_snapshot_for_comparison.inc
lock tables t1 write;
insert into t1 values (REPEAT('a', 6000));
# bitmap of after-INSERT will be on disk, but data pages will not; if
# log is not flushed the bitmap is inconsistent with the data.
-- source include/maria_verify_recovery.inc
drop table t1;
}
# clean up everything
let $mms_purpose=comparison;
eval drop database mysqltest_for_$mms_purpose;
drop database mysqltest;

View File

@ -0,0 +1,2 @@
--skip-stack-trace --skip-core-file

View File

@ -0,0 +1,187 @@
--source include/not_embedded.inc
# Don't test this under valgrind, memory leaks will occur as we crash
--source include/not_valgrind.inc
# Binary must be compiled with debug for crash to occur
--source include/have_debug.inc
--source include/have_maria.inc
set global maria_log_file_size=4294967295;
--disable_warnings
drop database if exists mysqltest;
--enable_warnings
create database mysqltest;
# Include scripts can perform SQL. For it to not influence the main test
# they use a separate connection. This way if they use a DDL it would
# not autocommit in the main test.
connect (admin, 127.0.0.1, root,,mysqltest,,);
--enable_reconnect
connection default;
use mysqltest;
--enable_reconnect
# A sample test
-- source include/maria_empty_logs.inc
let $mms_tables=1;
create table t1 (a varchar(1000)) engine=maria;
--echo * TEST of REDO: see if recovery can reconstruct if we give it an old table
-- source include/maria_make_snapshot_for_feeding_recovery.inc
# Your committed statements here, which we expect to
# be reconstructed from the log
insert into t1 values ("00000000");
-- source include/maria_make_snapshot_for_comparison.inc
# we want recovery to run on the first snapshot made above
let $mvr_restore_old_snapshot=1;
# As we did only committed work, we test REDO applying, which could
# produce a physically identical table.
let $mms_compare_physically=1;
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash";
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
# the script below will trigger recovery and compare checksums
-- source include/maria_verify_recovery.inc
let $mms_compare_physically=0;
# so a SELECT like this is pure visual effect, brings nothing.
select * from t1;
--echo * TEST of REDO+UNDO: normal recovery test (no moving tables under its feet)
# different types of crash => a loop; here are loop control variables
let $crash_no_flush=1;
let $crash_flush_whole_page_cache=0;
let $crash_flush_states=0;
let $crash_flush_whole_log=0;
let $crash_loop=1;
# we want recovery to use the tables as they were at time of crash
let $mvr_restore_old_snapshot=0;
# UNDO phase prevents physical comparison, normally,
# so we'll only use checksums to compare.
let $mms_compare_physically=0;
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
# Note that we don't remove logs between iterations. Test is
# cumulative (each new recovery processes more log records than the previous).
while ($crash_loop)
{
if ($crash_flush_whole_log)
{
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash";
# set up what next iteration should do:
let $crash_flush_whole_log=0;
let $crash_loop=0;
}
if ($crash_flush_states)
{
let $mvr_debug_option="+d,maria_flush_states,maria_flush_whole_log,maria_crash";
let $crash_flush_states=0;
let $crash_flush_whole_log=1;
}
if ($crash_flush_whole_page_cache)
{
let $mvr_debug_option="+d,maria_flush_whole_page_cache,maria_crash";
let $crash_flush_whole_page_cache=0;
let $crash_flush_states=1;
}
if ($crash_no_flush)
{
let $mvr_debug_option="+d,maria_crash";
let $crash_no_flush=0;
let $crash_flush_whole_page_cache=1;
}
# Your committed statements here
insert into t1 values ("00000000");
-- source include/maria_make_snapshot_for_comparison.inc
# Your statements which we expect to be rolled back
lock tables t1 write;
insert into t1 values ("aaaaaaaaa");
-- source include/maria_verify_recovery.inc
select * from t1;
}
drop table t1;
# what did we compare above:
# - checksum: tells that the tables contain the same amount of rows
# and same data in rows
# - index: no, neither state nor pages were compared
# - bitmap pages: the REPAIR QUICK done above very probably checks
# that bitmap reflects page occupation; do we need to do physical
# compare?
# - page LSN: not compared; we should compare that page's LSN in new
# table is >= page's LSN in old table (it can be >, due to UNDO phase)
# we had a bug where new page's LSN was 0... todo.
#
# Test for this bug: an UPDATE purges and rewrites a tail page, and
# recovery applied the purge, stamped page with UNDO's LSN, thus
# the rewrite was ignored.
#
--echo * TEST of two REDOs for same page in one REDO group
-- source include/maria_empty_logs.inc
let $mms_tables=1;
CREATE TABLE t1 (
i int,
b blob default NULL,
c varchar(6000) default NULL
) ENGINE=MARIA CHECKSUM=1;
-- source include/maria_make_snapshot_for_feeding_recovery.inc
INSERT INTO t1 VALUES (1, REPEAT('a', 5000), REPEAT('b', 5000));
UPDATE t1 SET i=3, b=CONCAT(b,'c') WHERE i=1;
SELECT LENGTH(b) FROM t1 WHERE i=3;
-- source include/maria_make_snapshot_for_comparison.inc
# we want recovery to run on the first snapshot made above
let $mvr_restore_old_snapshot=1;
let $mms_compare_physically=0;
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash";
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
-- source include/maria_verify_recovery.inc
SELECT LENGTH(b) FROM t1 WHERE i=3;
drop table t1;
# Test that INSERT's effect on auto-increment is recovered
--echo * TEST of INSERT vs state.auto_increment
-- source include/maria_empty_logs.inc
let $mms_tables=1;
CREATE TABLE t1 (
i int auto_increment primary key,
c varchar(6),
key(c)
) ENGINE=MARIA;
insert into t1 values(null,"b");
-- source include/maria_make_snapshot_for_feeding_recovery.inc
insert into t1 values(null,"a"), (null,"c"), (null,"d");
# With this DELETE we also verify that Recovery cares only about INSERTs
delete from t1 where c="d";
-- source include/maria_make_snapshot_for_comparison.inc
let $mvr_restore_old_snapshot=1;
let $mms_compare_physically=0;
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash";
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
-- source include/maria_verify_recovery.inc
show create table t1;
# Test that UPDATE's effect on auto-increment is recovered
--echo * TEST of UPDATE vs state.auto_increment
-- source include/maria_make_snapshot_for_feeding_recovery.inc
update t1 set i=15 where c="a";
-- source include/maria_make_snapshot_for_comparison.inc
let $mvr_restore_old_snapshot=1;
let $mms_compare_physically=0;
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash";
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
-- source include/maria_verify_recovery.inc
show create table t1;
drop table t1;
# clean up everything
let $mms_purpose=feeding_recovery;
eval drop database mysqltest_for_$mms_purpose;
let $mms_purpose=comparison;
eval drop database mysqltest_for_$mms_purpose;
drop database mysqltest;

1334
mysql-test/t/maria.test Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,11 @@
# Test of MERGE TABLES # Test of MERGE TABLES
# #
# MERGE tables require MyISAM tables
let $default=`select @@global.storage_engine`;
set global storage_engine=myisam;
set session storage_engine=myisam;
--disable_warnings --disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6; drop table if exists t1,t2,t3,t4,t5,t6;
drop database if exists mysqltest; drop database if exists mysqltest;
@ -599,9 +604,9 @@ SELECT * FROM t3;
DROP TABLE t1, t2, t3; DROP TABLE t1, t2, t3;
--echo End of 5.0 tests --echo End of 5.0 tests
# #
# Bug #8306: TRUNCATE leads to index corruption # Bug #8306: TRUNCATE leads to index corruption
# #
@ -738,7 +743,7 @@ DROP TABLE t1, t2;
# *after* the administration task. It was terminated by UNLOCK TABLES only. # *after* the administration task. It was terminated by UNLOCK TABLES only.
# #
# This is the same test case as for # This is the same test case as for
# Bug#26867 - LOCK TABLES + REPAIR + merge table result in memory/cpu hogging # Bug#26867 - LOCK TABLES REPAIR + merge table result in memory/cpu hogging
# #
# #
CREATE TABLE t1 (c1 INT) ENGINE= MyISAM; CREATE TABLE t1 (c1 INT) ENGINE= MyISAM;
@ -1381,3 +1386,8 @@ FLUSH TABLES m1, t1;
UNLOCK TABLES; UNLOCK TABLES;
DROP TABLE t1, m1; DROP TABLE t1, m1;
--disable_result_log
--disable_query_log
eval set global storage_engine=$default;
--enable_result_log
--enable_query_log

View File

@ -4,7 +4,7 @@
# Initialise # Initialise
--disable_warnings --disable_warnings
drop table if exists t1,t2; drop table if exists t1,t2,t3;
--enable_warnings --enable_warnings
SET SQL_WARNINGS=1; SET SQL_WARNINGS=1;

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