1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

Merge zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.1-comeng-unification

into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.1-recentcommmerge


BitKeeper/deleted/.del-ha_berkeley.cc:
  Auto merged
BitKeeper/deleted/.del-mysqld.vcproj~6aa7b3f9c3e28fcb:
  Auto merged
BitKeeper/triggers/post-commit:
  Auto merged
client/mysqlcheck.c:
  Auto merged
include/config-win.h:
  Auto merged
include/my_dbug.h:
  Auto merged
libmysqld/Makefile.am:
  Auto merged
mysql-test/r/func_in.result:
  Auto merged
mysql-test/r/information_schema.result:
  Auto merged
mysql-test/r/information_schema_db.result:
  Auto merged
mysql-test/t/func_in.test:
  Auto merged
mysql-test/t/information_schema.test:
  Auto merged
sql/Makefile.am:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/lock.cc:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/repl_failsafe.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_delete.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_repl.cc:
  Auto merged
sql/sql_view.cc:
  Auto merged
sql/structs.h:
  Auto merged
sql/table.h:
  Auto merged
storage/archive/ha_archive.cc:
  Auto merged
storage/myisam/ha_myisam.cc:
  Auto merged
storage/myisam/mi_open.c:
  Auto merged
storage/myisammrg/ha_myisammrg.cc:
  Auto merged
storage/ndb/src/common/util/File.cpp:
  Auto merged
configure.in:
  Manual merge.
sql/CMakeLists.txt:
  Manual merge.
sql/mysql_priv.h:
  Manual merge.
sql/mysqld.cc:
  Manual merge.
sql/set_var.cc:
  Manual merge.
sql/slave.cc:
  Manual merge.
sql/sql_cache.cc:
  Manual merge.
sql/sql_class.cc:
  Manual merge.
sql/sql_lex.h:
  Manual merge.
sql/sql_parse.cc:
  Manual merge.
sql/sql_select.cc:
  Manual merge.
sql/sql_show.cc:
  Manual merge.
sql/sql_table.cc:
  Manual merge.
sql/sql_update.cc:
  Manual merge.
sql/sql_yacc.yy:
  Manual merge.
This commit is contained in:
unknown
2007-10-17 14:05:43 -04:00
2610 changed files with 159083 additions and 65835 deletions

View File

@ -5,6 +5,7 @@
*.bb *.bb
*.bbg *.bbg
*.bin *.bin
*.cdf
*.core *.core
*.d *.d
*.da *.da
@ -38,7 +39,9 @@
*/.libs/* */.libs/*
*/.pure */.pure
*/debug/* */debug/*
*/minsizerel/*
*/release/* */release/*
*/relwithdebinfo/*
*~ *~
.*.swp .*.swp
./CMakeCache.txt ./CMakeCache.txt
@ -473,6 +476,9 @@ contrib/*.vcproj
core core
core.* core.*
core.2430 core.2430
cscope.in.out
cscope.out
cscope.po.out
db-*.*.* db-*.*.*
dbug/*.ds? dbug/*.ds?
dbug/*.vcproj dbug/*.vcproj
@ -489,6 +495,8 @@ dbug/main.r
dbug/output*.r dbug/output*.r
dbug/user.ps dbug/user.ps
dbug/user.t dbug/user.t
debian/control
debian/defs.mk
depcomp depcomp
emacs.h emacs.h
examples/*.ds? examples/*.ds?
@ -580,6 +588,7 @@ heap/hp_test2
help help
help.c help.c
help.h help.h
include/abi_check
include/check_abi include/check_abi
include/link_sources include/link_sources
include/my_config.h include/my_config.h
@ -1017,6 +1026,7 @@ libmysqld/.deps/unireg.Po
libmysqld/backup_dir libmysqld/backup_dir
libmysqld/client.c libmysqld/client.c
libmysqld/client_settings.h libmysqld/client_settings.h
libmysqld/cmake_dummy.c
libmysqld/convert.cc libmysqld/convert.cc
libmysqld/derror.cc libmysqld/derror.cc
libmysqld/discover.cc libmysqld/discover.cc
@ -1071,6 +1081,7 @@ libmysqld/ha_myisam.cc
libmysqld/ha_myisammrg.cc libmysqld/ha_myisammrg.cc
libmysqld/ha_ndbcluster.cc libmysqld/ha_ndbcluster.cc
libmysqld/ha_ndbcluster_binlog.cc libmysqld/ha_ndbcluster_binlog.cc
libmysqld/ha_ndbcluster_cond.cc
libmysqld/ha_partition.cc libmysqld/ha_partition.cc
libmysqld/ha_tina.cc libmysqld/ha_tina.cc
libmysqld/handler.cc libmysqld/handler.cc
@ -1091,6 +1102,7 @@ libmysqld/item_sum.cc
libmysqld/item_timefunc.cc libmysqld/item_timefunc.cc
libmysqld/item_uniq.cc libmysqld/item_uniq.cc
libmysqld/key.cc libmysqld/key.cc
libmysqld/lex_hash.h
libmysqld/lib_sql.cpp libmysqld/lib_sql.cpp
libmysqld/libmysql.c libmysqld/libmysql.c
libmysqld/link_sources libmysqld/link_sources
@ -1099,6 +1111,8 @@ libmysqld/log.cc
libmysqld/log_event.cc libmysqld/log_event.cc
libmysqld/log_event_old.cc libmysqld/log_event_old.cc
libmysqld/md5.c libmysqld/md5.c
libmysqld/message.h
libmysqld/message.rc
libmysqld/mf_iocache.cc libmysqld/mf_iocache.cc
libmysqld/mini_client.cc libmysqld/mini_client.cc
libmysqld/my_decimal.cc libmysqld/my_decimal.cc
@ -1274,7 +1288,6 @@ mysql-test/r/*.err
mysql-test/r/*.log mysql-test/r/*.log
mysql-test/r/*.out mysql-test/r/*.out
mysql-test/r/*.reject mysql-test/r/*.reject
mysql-test/r/*.warnings
mysql-test/r/alter_table.err mysql-test/r/alter_table.err
mysql-test/r/archive.err mysql-test/r/archive.err
mysql-test/r/backup.log mysql-test/r/backup.log
@ -2875,6 +2888,7 @@ support-files/mysql-3.23.29-gamma.spec
support-files/mysql-log-rotate support-files/mysql-log-rotate
support-files/mysql.server support-files/mysql.server
support-files/mysql.spec support-files/mysql.spec
support-files/mysqld_multi.server
support-files/ndb-config-2-node.ini support-files/ndb-config-2-node.ini
tags tags
test/ndbapi/bank/bankCreator test/ndbapi/bank/bankCreator
@ -2940,6 +2954,7 @@ tests/.deps/thread_test.Po
tests/.libs -prune tests/.libs -prune
tests/.libs/lt-mysql_client_test tests/.libs/lt-mysql_client_test
tests/.libs/mysql_client_test tests/.libs/mysql_client_test
tests/bug25714
tests/client_test tests/client_test
tests/connect_test tests/connect_test
tests/mysql_client_test tests/mysql_client_test

View File

@ -28,6 +28,7 @@ EXTRA_DIST = FINISH.sh \
compile-alpha-debug \ compile-alpha-debug \
compile-amd64-debug-max \ compile-amd64-debug-max \
compile-amd64-max \ compile-amd64-max \
compile-amd64-max-sci \
compile-darwin-mwcc \ compile-darwin-mwcc \
compile-dist \ compile-dist \
compile-hpux11-parisc2-aCC \ compile-hpux11-parisc2-aCC \
@ -52,6 +53,7 @@ EXTRA_DIST = FINISH.sh \
compile-pentium-valgrind-max \ compile-pentium-valgrind-max \
compile-pentium64-debug \ compile-pentium64-debug \
compile-pentium64-debug-max \ compile-pentium64-debug-max \
compile-pentium64-max-sci \
compile-pentium64-valgrind-max \ compile-pentium64-valgrind-max \
compile-ppc \ compile-ppc \
compile-ppc-debug \ compile-ppc-debug \

View File

@ -105,7 +105,7 @@ if [ "x$warning_mode" != "xpedantic" ]; then
# Added unless --with-debug=full # Added unless --with-debug=full
debug_extra_cflags="-O1 -Wuninitialized" debug_extra_cflags="-O1 -Wuninitialized"
else else
warnings="-W -Wall -ansi -pedantic -Wno-long-long -D_POSIX_SOURCE" warnings="-W -Wall -ansi -pedantic -Wno-long-long -Wno-unused -D_POSIX_SOURCE"
c_warnings="$warnings" c_warnings="$warnings"
cxx_warnings="$warnings -std=c++98" cxx_warnings="$warnings -std=c++98"
# NOTE: warning mode should not influence optimize/debug mode. # NOTE: warning mode should not influence optimize/debug mode.
@ -207,3 +207,28 @@ then
echo "$CC" | grep "ccache" > /dev/null || CC="ccache $CC" echo "$CC" | grep "ccache" > /dev/null || CC="ccache $CC"
echo "$CXX" | grep "ccache" > /dev/null || CXX="ccache $CXX" echo "$CXX" | grep "ccache" > /dev/null || CXX="ccache $CXX"
fi fi
# gcov
# The -fprofile-arcs and -ftest-coverage options cause GCC to instrument the
# code with profiling information used by gcov.
# The -DDISABLE_TAO_ASM is needed to avoid build failures in Yassl.
# The -DHAVE_gcov enables code to write out coverage info even when crashing.
gcov_compile_flags="-fprofile-arcs -ftest-coverage"
gcov_compile_flags="$gcov_compile_flags -DDISABLE_TAO_ASM"
gcov_compile_flags="$gcov_compile_flags -DMYSQL_SERVER_SUFFIX=-gcov -DHAVE_gcov"
# GCC4 needs -fprofile-arcs -ftest-coverage on the linker command line (as well
# as on the compiler command line), and this requires setting LDFLAGS for BDB.
gcov_link_flags="-fprofile-arcs -ftest-coverage"
gcov_configs="--disable-shared"
# gprof
gprof_compile_flags="-O2 -pg -g"
gprof_link_flags="--disable-shared $static_link"

View File

@ -105,6 +105,12 @@ check_cpu () {
*Athlon*64*) *Athlon*64*)
cpu_arg="athlon64"; cpu_arg="athlon64";
;; ;;
*Turion*)
cpu_arg="athlon64";
;;
*Opteron*)
cpu_arg="athlon64";
;;
*Athlon*) *Athlon*)
cpu_arg="athlon"; cpu_arg="athlon";
;; ;;

17
BUILD/compile-amd64-gcov Executable file
View File

@ -0,0 +1,17 @@
#! /bin/sh
path=`dirname $0`
. "$path/SETUP.sh"
# Need to disable ccache, or we loose the gcov-needed compiler output files.
CCACHE_DISABLE=1
export CCACHE_DISABLE
export LDFLAGS="$gcov_link_flags"
extra_flags="$amd64_cflags $debug_cflags $max_cflags $gcov_compile_flags"
c_warnings="$c_warnings $debug_extra_warnings"
cxx_warnings="$cxx_warnings $debug_extra_warnings"
extra_configs="$amd64_configs $debug_configs $gcov_configs $max_configs"
. "$path/FINISH.sh"

9
BUILD/compile-amd64-gprof Executable file
View File

@ -0,0 +1,9 @@
#! /bin/sh
path=`dirname $0`
. "$path/SETUP.sh"
extra_flags="$amd64_cflags $gprof_compile_flags"
extra_configs="$amd64_configs $debug_configs $gprof_link_flags"
. "$path/FINISH.sh"

View File

@ -0,0 +1,8 @@
#! /bin/sh
path=`dirname $0`
. "$path/SETUP.sh"
extra_flags="$amd64_cflags $fast_cflags -g"
extra_configs="$amd64_configs $max_configs --with-ndb-sci=/opt/DIS"
. "$path/FINISH.sh"

View File

@ -45,16 +45,5 @@ fi
# Make sure to enable all features that affect "make dist" # Make sure to enable all features that affect "make dist"
./configure \ ./configure \
--with-embedded-server \ --with-ndbcluster
--with-archive-storage-engine \
--with-blackhole-storage-engine \
--with-csv-storage-engine \
--with-example-storage-engine \
--with-federated-storage-engine \
--with-innodb \
--with-ssl \
--enable-thread-safe-client \
--with-extra-charsets=complex \
--with-ndbcluster \
--with-zlib-dir=bundled
make make

View File

@ -20,17 +20,11 @@ export CCACHE_GCOV_VERSION_ENABLED
path=`dirname $0` path=`dirname $0`
. "$path/SETUP.sh" . "$path/SETUP.sh"
# GCC4 needs -fprofile-arcs -ftest-coverage on the linker command line (as well export LDFLAGS="$gcov_link_flags"
# as on the compiler command line), and this requires setting LDFLAGS for BDB.
export LDFLAGS="-fprofile-arcs -ftest-coverage"
# The -fprofile-arcs and -ftest-coverage options cause GCC to instrument the extra_flags="$pentium_cflags $debug_cflags $max_cflags $gcov_compile_flags"
# code with profiling information used by gcov.
# the -DDISABLE_TAO_ASM is needed to avoid build failures in Yassl.
extra_flags="$pentium_cflags -fprofile-arcs -ftest-coverage -DDISABLE_TAO_ASM -DHAVE_MUTEX_THREAD_ONLY $debug_extra_flags $debug_cflags $max_cflags -DMYSQL_SERVER_SUFFIX=-gcov"
extra_configs="$pentium_configs $debug_configs --disable-shared $static_link"
extra_configs="$extra_configs $max_configs"
c_warnings="$c_warnings $debug_extra_warnings" c_warnings="$c_warnings $debug_extra_warnings"
cxx_warnings="$cxx_warnings $debug_extra_warnings" cxx_warnings="$cxx_warnings $debug_extra_warnings"
extra_configs="$pentium_configs $debug_configs $gcov_configs $max_configs"
. "$path/FINISH.sh" . "$path/FINISH.sh"

View File

@ -3,7 +3,7 @@
path=`dirname $0` path=`dirname $0`
. "$path/SETUP.sh" . "$path/SETUP.sh"
extra_flags="$pentium_cflags -O2 -pg -g" extra_flags="$pentium_cflags $gprof_compile_flags"
extra_configs="$pentium_configs $debug_configs --disable-shared $static_link" extra_configs="$pentium_configs $debug_configs $gprof_link_flags"
. "$path/FINISH.sh" . "$path/FINISH.sh"

17
BUILD/compile-pentium64-gcov Executable file
View File

@ -0,0 +1,17 @@
#! /bin/sh
path=`dirname $0`
. "$path/SETUP.sh"
# Need to disable ccache, or we loose the gcov-needed compiler output files.
CCACHE_DISABLE=1
export CCACHE_DISABLE
export LDFLAGS="$gcov_link_flags"
extra_flags="$pentium64_cflags $debug_cflags $max_cflags $gcov_compile_flags"
c_warnings="$c_warnings $debug_extra_warnings"
cxx_warnings="$cxx_warnings $debug_extra_warnings"
extra_configs="$pentium64_configs $debug_configs $gcov_configs $max_configs"
. "$path/FINISH.sh"

9
BUILD/compile-pentium64-gprof Executable file
View File

@ -0,0 +1,9 @@
#! /bin/sh
path=`dirname $0`
. "$path/SETUP.sh"
extra_flags="$pentium64_cflags $gprof_compile_flags"
extra_configs="$pentium64_configs $debug_configs $gprof_link_flags"
. "$path/FINISH.sh"

View File

@ -0,0 +1,9 @@
#! /bin/sh
path=`dirname $0`
. "$path/SETUP.sh"
extra_flags="$pentium64_cflags $fast_cflags -g"
extra_configs="$pentium_configs $max_configs --with-ndb-sci=/opt/DIS"
. "$path/FINISH.sh"

View File

@ -6,6 +6,6 @@ make -k clean || true
path=`dirname $0` path=`dirname $0`
. "$path/autorun.sh" . "$path/autorun.sh"
CFLAGS="-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Wunused -O3 -fno-omit-frame-pointer -mcpu=v8 -Wa,-xarch=v8plusa" CXX=gcc CXXFLAGS="-Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti -O3 -fno-omit-frame-pointer -mcpu=v8 -Wa,-xarch=v8plusa -g" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-debug CFLAGS="-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Wunused -O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti -O3 -fno-omit-frame-pointer" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-debug
make -j 4 make -j 4

View File

@ -3,7 +3,13 @@
# Assume Forte is installed in /opt/SUNWSpro and ld is installed in # Assume Forte is installed in /opt/SUNWSpro and ld is installed in
# /usr/ccs/bin # /usr/ccs/bin
PATH=/opt/SUNWspro/bin/:/usr/ccs/bin:$PATH PATH=/opt/SUNWspro/bin:/usr/ccs/bin:/usr/sfw/bin:/opt/csw/bin:$PATH
prefix="/usr/local/mysql"
if test -n "$MYSQL_BUILD_PREFIX"
then
prefix="$MYSQL_BUILD_PREFIX"
fi
make -k maintainer-clean || true make -k maintainer-clean || true
/bin/rm -f */.deps/*.P config.cache /bin/rm -f */.deps/*.P config.cache
@ -12,9 +18,9 @@ path=`dirname $0`
. "$path/autorun.sh" . "$path/autorun.sh"
# For "optimal" code for this computer add -fast to EXTRA # For "optimal" code for this computer add -fast to EXTRA
# To compile 64 bit, add -xarch=v9 to EXTRA_64_BIT # To compile 32/64 bit, uncomment/comment EXTRA_64_BIT
EXTRA_64_BIT="-xarch=v9" # Remove comment to get 64 bit binaries EXTRA_64_BIT="-m64"
EXTRA="-fast" # Remove comment to target current machine EXTRA="-fast" # Remove comment to target current machine
# #
@ -22,10 +28,9 @@ EXTRA="-fast" # Remove comment to target current machine
# #
STD="-mt -D_FORTEC_ $EXTRA $EXTRA_64_BIT" STD="-mt -D_FORTEC_ $EXTRA $EXTRA_64_BIT"
ASFLAGS="$EXTRA_64_BIT" \
CC=cc-5.0 CFLAGS="-Xa -xstrconst $STD" \ CC=cc-5.0 CFLAGS="-Xa -xstrconst $STD" \
CXX=CC CXXFLAGS="-noex $STD" \ CXX=CC CXXFLAGS="-noex $STD" \
./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --prefix=$PREFIX
make -j 4 make -j 4
if [ $? = 0 ] if [ $? = 0 ]

View File

@ -33,6 +33,13 @@ then
exit exit
fi fi
IS_MERGE=`bk changes -r+ -k -m`
if [ "$IS_MERGE" = "" ]
then
echo Merge changeset, not sending mails
exit
fi
CHANGESET=`bk -R prs -r+ -h -d':P:::I:' ChangeSet` CHANGESET=`bk -R prs -r+ -h -d':P:::I:' ChangeSet`
CSETKEY=`bk -R prs -r+ -h -d':KEY:' ChangeSet` CSETKEY=`bk -R prs -r+ -h -d':KEY:' ChangeSet`
# #
@ -48,44 +55,35 @@ WL=`bk -R prs -r+ -h -d':C:' ChangeSet | \
s/.*\(WL#[0-9][0-9]*\)/ \1/p'` s/.*\(WL#[0-9][0-9]*\)/ \1/p'`
if [ "$BUG" = "" ] if [ "$BUG" = "" ]
then then
TO=dev-public@mysql.com # TO=dev-public@mysql.com
BS="" BS=""
BH="" BH=""
else else
TO=dev-bugs@mysql.com # TO=dev-bugs@mysql.com
BS=" BUG#$BUG" BS=" BUG#$BUG"
# need newline here # need newline here
BH="X-Bug: $BUG BH="X-Bug: $BUG
" "
fi fi
#++ #++
# dev-public@ / dev-bugs@ # commits@ or dev-private@ mail
#-- #--
echo "Commit successful, notifying developers at $TO"
LIST="commits"
TO="commits@lists.mysql.com"
if [ -f .tree-is-private ]
then
LIST="dev-private"
TO="dev-private@mysql.com"
fi
echo "Notifying $LIST list at $TO"
( (
cat <<EOF cat <<EOF
List-ID: <bk.mysql-$VERSION> List-ID: <bk.mysql-$VERSION>
From: $FROM From: $FROM
To: $TO To: $TO
Subject: bk commit - $VERSION tree ($CHANGESET)${BS}${WL}
X-CSetKey: <$CSETKEY>
$BH
EOF
bk changes -v -r+
bk rset -r+ -ah | bk gnupatch -h -dup -T
) > $BKROOT/BitKeeper/tmp/dev_public.txt
$SENDMAIL -t < $BKROOT/BitKeeper/tmp/dev_public.txt
#++
# commits@ mail
#--
echo "Notifying commits list at $COMMITS"
(
cat <<EOF
List-ID: <bk.mysql-$VERSION>
From: $FROM
To: $COMMITS
Subject: bk commit into $VERSION tree ($CHANGESET)$BS Subject: bk commit into $VERSION tree ($CHANGESET)$BS
X-CSetKey: <$CSETKEY> X-CSetKey: <$CSETKEY>
$BH $BH
@ -98,7 +96,7 @@ see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
EOF EOF
bk changes -v -r+ bk changes -v -r+
bk cset -r+ -d bk rset -r+ -ah | bk gnupatch -h -dup -T
) | bk sed -e ${LIMIT}q > $BKROOT/BitKeeper/tmp/commits.txt ) | bk sed -e ${LIMIT}q > $BKROOT/BitKeeper/tmp/commits.txt
$SENDMAIL -t < $BKROOT/BitKeeper/tmp/commits.txt $SENDMAIL -t < $BKROOT/BitKeeper/tmp/commits.txt
@ -120,7 +118,7 @@ Subject: bk commit - $VERSION tree (Manual) ($CHANGESET)$BS
EOF EOF
bk changes -v -r+ bk changes -v -r+
bk cset -r+ -d bk rset -r+ -ah | bk gnupatch -h -dup -T
) > $BKROOT/BitKeeper/tmp/docs.txt ) > $BKROOT/BitKeeper/tmp/docs.txt
$SENDMAIL -t < $BKROOT/BitKeeper/tmp/docs.txt $SENDMAIL -t < $BKROOT/BitKeeper/tmp/docs.txt
fi fi

View File

@ -20,4 +20,3 @@ then
echo "Set REAL_EMAIL and retry." echo "Set REAL_EMAIL and retry."
exit 1 exit 1
fi fi

View File

@ -47,6 +47,7 @@ my @bad_csets=
'stewart@mysql.com|ChangeSet|20060525073521|11169', 'stewart@mysql.com|ChangeSet|20060525073521|11169',
'stewart@mysql.com|ChangeSet|20060605154220|12975', 'stewart@mysql.com|ChangeSet|20060605154220|12975',
'stewart@mysql.com|ChangeSet|20060606040001|15337', 'stewart@mysql.com|ChangeSet|20060606040001|15337',
'hartmut@mysql.com/linux.site|ChangeSet|20070413121444|50289'
); );
# Read the list of changesets. # Read the list of changesets.

View File

@ -47,6 +47,7 @@ my @bad_csets=
'stewart@mysql.com|ChangeSet|20060525073521|11169', 'stewart@mysql.com|ChangeSet|20060525073521|11169',
'stewart@mysql.com|ChangeSet|20060605154220|12975', 'stewart@mysql.com|ChangeSet|20060605154220|12975',
'stewart@mysql.com|ChangeSet|20060606040001|15337', 'stewart@mysql.com|ChangeSet|20060606040001|15337',
'hartmut@mysql.com/linux.site|ChangeSet|20070413121444|50289'
); );
# Read the list of changesets. # Read the list of changesets.

145
CMakeLists.txt Normal file → Executable file
View File

@ -24,44 +24,53 @@ SET(WITH_CSV_STORAGE_ENGINE TRUE)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in
${CMAKE_SOURCE_DIR}/include/mysql_version.h @ONLY) ${CMAKE_SOURCE_DIR}/include/mysql_version.h @ONLY)
# Set standard options
ADD_DEFINITIONS(-DHAVE_YASSL)
# Set debug options
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DFORCE_INIT_OF_VARS")
# Note that some engines are always compiled in, MyISAM, MyISAMMRG and HEAP,
# these three plugin defintions are dummys for symmetry
SET(WITH_HEAP_STORAGE_ENGINE TRUE) SET(WITH_HEAP_STORAGE_ENGINE TRUE)
ADD_DEFINITIONS(-D WITH_HEAP_STORAGE_ENGINE) ADD_DEFINITIONS(-DWITH_HEAP_STORAGE_ENGINE)
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_heap_plugin") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_heap_plugin")
SET(WITH_MYISAM_STORAGE_ENGINE TRUE) SET(WITH_MYISAM_STORAGE_ENGINE TRUE)
ADD_DEFINITIONS(-D WITH_MYISAM_STORAGE_ENGINE) ADD_DEFINITIONS(-DWITH_MYISAM_STORAGE_ENGINE)
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_myisam_plugin") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_myisam_plugin")
SET(WITH_MYISAMMRG_STORAGE_ENGINE TRUE) SET(WITH_MYISAMMRG_STORAGE_ENGINE TRUE)
ADD_DEFINITIONS(-D WITH_MYISAMMRG_STORAGE_ENGINE) ADD_DEFINITIONS(-DWITH_MYISAMMRG_STORAGE_ENGINE)
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_myisammrg_plugin") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_myisammrg_plugin")
IF(WITH_ARCHIVE_STORAGE_ENGINE) IF(WITH_ARCHIVE_STORAGE_ENGINE)
ADD_DEFINITIONS(-D WITH_ARCHIVE_STORAGE_ENGINE) ADD_DEFINITIONS(-DWITH_ARCHIVE_STORAGE_ENGINE)
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_archive_plugin") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_archive_plugin")
ENDIF(WITH_ARCHIVE_STORAGE_ENGINE) ENDIF(WITH_ARCHIVE_STORAGE_ENGINE)
IF(WITH_BLACKHOLE_STORAGE_ENGINE) IF(WITH_BLACKHOLE_STORAGE_ENGINE)
ADD_DEFINITIONS(-D WITH_BLACKHOLE_STORAGE_ENGINE) ADD_DEFINITIONS(-DWITH_BLACKHOLE_STORAGE_ENGINE)
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_blackhole_plugin") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_blackhole_plugin")
ENDIF(WITH_BLACKHOLE_STORAGE_ENGINE) ENDIF(WITH_BLACKHOLE_STORAGE_ENGINE)
IF(WITH_CSV_STORAGE_ENGINE) IF(WITH_CSV_STORAGE_ENGINE)
ADD_DEFINITIONS(-D WITH_CSV_STORAGE_ENGINE) ADD_DEFINITIONS(-DWITH_CSV_STORAGE_ENGINE)
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_csv_plugin") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_csv_plugin")
ENDIF(WITH_CSV_STORAGE_ENGINE) ENDIF(WITH_CSV_STORAGE_ENGINE)
IF(WITH_EXAMPLE_STORAGE_ENGINE) IF(WITH_EXAMPLE_STORAGE_ENGINE)
ADD_DEFINITIONS(-D WITH_EXAMPLE_STORAGE_ENGINE) ADD_DEFINITIONS(-DWITH_EXAMPLE_STORAGE_ENGINE)
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_example_plugin") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_example_plugin")
ENDIF(WITH_EXAMPLE_STORAGE_ENGINE) ENDIF(WITH_EXAMPLE_STORAGE_ENGINE)
IF(WITH_INNOBASE_STORAGE_ENGINE) IF(WITH_INNOBASE_STORAGE_ENGINE)
ADD_DEFINITIONS(-D WITH_INNOBASE_STORAGE_ENGINE) ADD_DEFINITIONS(-DWITH_INNOBASE_STORAGE_ENGINE)
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_innobase_plugin") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_innobase_plugin")
ENDIF(WITH_INNOBASE_STORAGE_ENGINE) ENDIF(WITH_INNOBASE_STORAGE_ENGINE)
IF(WITH_PARTITION_STORAGE_ENGINE) IF(WITH_PARTITION_STORAGE_ENGINE)
ADD_DEFINITIONS(-D WITH_PARTITION_STORAGE_ENGINE) ADD_DEFINITIONS(-DWITH_PARTITION_STORAGE_ENGINE)
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_partition_plugin") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_partition_plugin")
ENDIF(WITH_PARTITION_STORAGE_ENGINE) ENDIF(WITH_PARTITION_STORAGE_ENGINE)
IF(WITH_FEDERATED_STORAGE_ENGINE) IF(WITH_FEDERATED_STORAGE_ENGINE)
ADD_DEFINITIONS(-D WITH_FEDERATED_STORAGE_ENGINE) ADD_DEFINITIONS(-DWITH_FEDERATED_STORAGE_ENGINE)
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_federated_plugin") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_federated_plugin")
ENDIF(WITH_FEDERATED_STORAGE_ENGINE) ENDIF(WITH_FEDERATED_STORAGE_ENGINE)
@ -81,86 +90,118 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-small.cnf.sh
${CMAKE_SOURCE_DIR}/support-files/my-small.ini @ONLY) ${CMAKE_SOURCE_DIR}/support-files/my-small.ini @ONLY)
IF(__NT__) IF(__NT__)
ADD_DEFINITIONS(-D __NT__) ADD_DEFINITIONS(-D__NT__)
ENDIF(__NT__) ENDIF(__NT__)
IF(CYBOZU) IF(CYBOZU)
ADD_DEFINITIONS(-D CYBOZU) ADD_DEFINITIONS(-DCYBOZU)
ENDIF(CYBOZU) ENDIF(CYBOZU)
# in some places we use DBUG_OFF # in some places we use DBUG_OFF
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D DBUG_OFF") SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D DBUG_OFF") SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDBUG_OFF")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")
IF(CMAKE_GENERATOR MATCHES "Visual Studio 8") IF(CMAKE_GENERATOR MATCHES "Visual Studio 8")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /wd4996") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /wd4996")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /wd4996") SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /wd4996")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /wd4996")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /wd4996") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /wd4996")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /wd4996") SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /wd4996")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /wd4996")
ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8") ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8")
IF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR IF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR
CMAKE_GENERATOR MATCHES "Visual Studio 8") CMAKE_GENERATOR MATCHES "Visual Studio 8")
# replace /MDd with /MTd
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG_INIT
${CMAKE_CXX_FLAGS_DEBUG_INIT})
STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG_INIT
${CMAKE_C_FLAGS_DEBUG_INIT})
STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE
${CMAKE_C_FLAGS_RELEASE})
STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG
${CMAKE_C_FLAGS_DEBUG})
STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE
${CMAKE_CXX_FLAGS_RELEASE})
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG
${CMAKE_CXX_FLAGS_DEBUG})
STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO # replace /MDd with /MTd
${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO})
${CMAKE_C_FLAGS_RELWITHDEBINFO}) STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG_INIT ${CMAKE_C_FLAGS_DEBUG_INIT})
# generate .map files STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MAP /MAPINFO:EXPORTS") STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG_INIT ${CMAKE_CXX_FLAGS_DEBUG_INIT})
# generate map files, set stack size (see bug#20815)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MAP /MAPINFO:EXPORTS")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:1048576")
# remove support for Exception handling
STRING(REPLACE "/GX" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT ${CMAKE_CXX_FLAGS_INIT})
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_DEBUG_INIT ${CMAKE_CXX_FLAGS_DEBUG_INIT})
# remove support for Exception handling
STRING(REPLACE "/GX" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT
${CMAKE_CXX_FLAGS_INIT})
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_DEBUG_INIT
${CMAKE_CXX_FLAGS_DEBUG_INIT})
ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR
CMAKE_GENERATOR MATCHES "Visual Studio 8") CMAKE_GENERATOR MATCHES "Visual Studio 8")
ADD_DEFINITIONS("-D_WINDOWS -D__WIN__ -D _CRT_SECURE_NO_DEPRECATE") IF(WIN32)
ADD_DEFINITIONS("-D_WINDOWS -D__WIN__ -D_CRT_SECURE_NO_DEPRECATE")
ENDIF(WIN32)
IF(EMBED_MANIFESTS) IF(EMBED_MANIFESTS)
# Search for the Manifest tool. CMake will first search it's defaults # Search for the tools (mt, makecat, signtool) necessary for embedding
# (CMAKE_FRAMEWORK_PATH, CMAKE_APPBUNDLE_PATH, CMAKE_PROGRAM_PATH and # manifests and signing executables with the MySQL AB authenticode cert.
# the system PATH) followed by the listed paths which are the current #
# possible defaults and should be updated when necessary. The custom # CMake will first search it's defaults (CMAKE_FRAMEWORK_PATH,
# manifests are designed to be compatible with all mt versions. # CMAKE_APPBUNDLE_PATH, CMAKE_PROGRAM_PATH and the system PATH) followed
# by the listed paths which are the current possible defaults and should be
# updated when necessary.
#
# The custom manifests are designed to be compatible with all mt versions.
# The MySQL AB Authenticode certificate is available only internally.
# Others should store a single signing certificate in a local cryptographic
# service provider and alter the signtool command as necessary.
FIND_PROGRAM(HAVE_MANIFEST_TOOL NAMES mt FIND_PROGRAM(HAVE_MANIFEST_TOOL NAMES mt
PATHS PATHS
"$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/VC/bin" "$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/VC/bin"
"$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/Common7/Tools/Bin" "$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/Common7/Tools/Bin"
"$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/SDK/v2.0/Bin") "$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/SDK/v2.0/Bin")
FIND_PROGRAM(HAVE_CATALOG_TOOL NAMES makecat
PATHS
"$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/Common7/Tools/Bin")
FIND_PROGRAM(HAVE_SIGN_TOOL NAMES signtool
PATHS
"$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/Common7/Tools/Bin"
"$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/SDK/v2.0/Bin")
IF(HAVE_MANIFEST_TOOL) IF(HAVE_MANIFEST_TOOL)
MESSAGE(STATUS "Found Mainfest Tool. Embedding custom manifests.") MESSAGE(STATUS "Found Mainfest Tool.")
ELSE(HAVE_MANIFEST_TOOL) ELSE(HAVE_MANIFEST_TOOL)
MESSAGE(FATAL_ERROR "Manifest tool, mt.exe, can't be found.") MESSAGE(FATAL_ERROR "Manifest tool, mt.exe, can't be found.")
ENDIF(HAVE_MANIFEST_TOOL) ENDIF(HAVE_MANIFEST_TOOL)
IF(HAVE_CATALOG_TOOL)
MESSAGE(STATUS "Found Catalog Tool.")
ELSE(HAVE_CATALOG_TOOL)
MESSAGE(FATAL_ERROR "Catalog tool, makecat.exe, can't be found.")
ENDIF(HAVE_CATALOG_TOOL)
IF(HAVE_SIGN_TOOL)
MESSAGE(STATUS "Found Sign Tool. Embedding custom manifests and signing executables.")
ELSE(HAVE_SIGN_TOOL)
MESSAGE(FATAL_ERROR "Sign tool, signtool.exe, can't be found.")
ENDIF(HAVE_SIGN_TOOL)
# Disable automatic manifest generation. # Disable automatic manifest generation.
STRING(REPLACE "/MANIFEST" "/MANIFEST:NO" CMAKE_EXE_LINKER_FLAGS STRING(REPLACE "/MANIFEST" "/MANIFEST:NO" CMAKE_EXE_LINKER_FLAGS
${CMAKE_EXE_LINKER_FLAGS}) ${CMAKE_EXE_LINKER_FLAGS})
# Explicitly disable it since it is the default for newer versions of VS
STRING(REGEX MATCH "MANIFEST:NO" tmp_manifest ${CMAKE_EXE_LINKER_FLAGS})
IF(NOT tmp_manifest)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
ENDIF(NOT tmp_manifest)
# Set the processor architecture. # Set the processor architecture.
IF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64") IF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64")
SET(PROCESSOR_ARCH "X64") SET(PROCESSOR_ARCH "amd64")
ELSE(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64") ELSE(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64")
SET(PROCESSOR_ARCH "X86") SET(PROCESSOR_ARCH "X86")
ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64") ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64")
ENDIF(EMBED_MANIFESTS) ENDIF(EMBED_MANIFESTS)
# FIXME "debug" only needed if build type is "Debug", but
# CMAKE_BUILD_TYPE is not set during configure time.
ADD_SUBDIRECTORY(vio) ADD_SUBDIRECTORY(vio)
ADD_SUBDIRECTORY(dbug) ADD_SUBDIRECTORY(dbug)
ADD_SUBDIRECTORY(strings) ADD_SUBDIRECTORY(strings)
@ -197,7 +238,7 @@ ADD_SUBDIRECTORY(sql)
ADD_SUBDIRECTORY(server-tools/instance-manager) ADD_SUBDIRECTORY(server-tools/instance-manager)
ADD_SUBDIRECTORY(libmysql) ADD_SUBDIRECTORY(libmysql)
ADD_SUBDIRECTORY(tests) ADD_SUBDIRECTORY(tests)
IF(WITH_EMBEDDED_SERVER)
# disable libmysqld until it's fixed, so we can use Cmake 2.2 and 2.4 ADD_SUBDIRECTORY(libmysqld)
#ADD_SUBDIRECTORY(libmysqld) ADD_SUBDIRECTORY(libmysqld/examples)
#ADD_SUBDIRECTORY(libmysqld/examples) ENDIF(WITH_EMBEDDED_SERVER)

View File

@ -20,16 +20,25 @@ AUTOMAKE_OPTIONS = foreign
# These are built from source in the Docs directory # These are built from source in the Docs directory
EXTRA_DIST = INSTALL-SOURCE INSTALL-WIN-SOURCE \ EXTRA_DIST = INSTALL-SOURCE INSTALL-WIN-SOURCE \
README COPYING EXCEPTIONS-CLIENT CMakeLists.txt README COPYING EXCEPTIONS-CLIENT CMakeLists.txt
SUBDIRS = . include @docs_dirs@ @zlib_dir@ \ SUBDIRS = . include @docs_dirs@ @zlib_dir@ \
@readline_topdir@ sql-common scripts \ @readline_topdir@ sql-common scripts \
@thread_dirs@ pstack \ @pstack_dir@ \
@sql_union_dirs@ unittest storage plugin \ @sql_union_dirs@ unittest storage plugin \
@sql_server@ @man_dirs@ tests \ @sql_server@ @man_dirs@ tests \
netware @libmysqld_dirs@ \ netware @libmysqld_dirs@ \
mysql-test support-files sql-bench @tools_dirs@ \ mysql-test support-files sql-bench @tools_dirs@ \
win win
DIST_SUBDIRS = $(SUBDIRS) BUILD debian DIST_SUBDIRS = . include Docs zlib \
cmd-line-utils sql-common scripts \
pstack \
strings mysys dbug extra regex libmysql libmysql_r client unittest storage plugin \
vio sql man tests \
netware libmysqld \
mysql-test support-files sql-bench server-tools \
win \
BUILD debian
DISTCLEANFILES = ac_available_languages_fragment DISTCLEANFILES = ac_available_languages_fragment
@ -44,7 +53,6 @@ bin-dist: all
# Create initial database files for Windows installations. # Create initial database files for Windows installations.
dist-hook: dist-hook:
rm -rf `find $(distdir) -type d -name SCCS -print` rm -rf `find $(distdir) -type d -name SCCS -print`
rm -f `find $(distdir) -type l -print`
mkdir -p $(distdir)/win mkdir -p $(distdir)/win
scripts/mysql_install_db --no-defaults --windows \ scripts/mysql_install_db --no-defaults --windows \
--basedir=$(top_builddir) \ --basedir=$(top_builddir) \
@ -58,7 +66,8 @@ tags:
test test-force test-full test-force-full test-force-mem \ test test-force test-full test-force-full test-force-mem \
test-pl test-force-pl test-full-pl test-force-full-pl test-force-pl-mem \ test-pl test-force-pl test-full-pl test-force-full-pl test-force-pl-mem \
test-unit test-ps test-nr test-pr test-ns test-binlog-statement \ test-unit test-ps test-nr test-pr test-ns test-binlog-statement \
test-ext-funcs test-ext-rpl test-ext-partitions test-ext \ test-ext-funcs test-ext-rpl test-ext-partitions test-ext-jp \
test-ext-stress test-ext \
test-fast test-fast-cursor test-fast-view test-fast-prepare \ test-fast test-fast-cursor test-fast-view test-fast-prepare \
test-full-qa test-full-qa
@ -123,10 +132,33 @@ test-bt:
-cd mysql-test ; MTR_BUILD_THREAD=auto \ -cd mysql-test ; MTR_BUILD_THREAD=auto \
@PERL@ ./mysql-test-run.pl --comment=NDB --force --timer \ @PERL@ ./mysql-test-run.pl --comment=NDB --force --timer \
--with-ndbcluster-only --with-ndbcluster-only
-if [ -e bin/mysqltest_embedded -o -e libmysqld/examples/mysqltest_embedded ] ; then \
cd mysql-test ; MTR_BUILD_THREAD=auto \
@PERL@ ./mysql-test-run.pl --comment=embedded --force --timer \
--embedded-server --skip-rpl --skip-ndbcluster ; \
fi
-cd mysql-test ; MTR_BUILD_THREAD=auto \ -cd mysql-test ; MTR_BUILD_THREAD=auto \
@PERL@ ./mysql-test-run.pl --force --comment=funcs1_ps --ps-protocol --suite=funcs_1 @PERL@ ./mysql-test-run.pl --force --comment=funcs1_ps --ps-protocol --suite=funcs_1
-cd mysql-test ; MTR_BUILD_THREAD=auto \ -cd mysql-test ; MTR_BUILD_THREAD=auto \
@PERL@ ./mysql-test-run.pl --force --comment=funcs2 --suite=funcs_2 @PERL@ ./mysql-test-run.pl --force --comment=funcs2 --suite=funcs_2
-cd mysql-test ; MTR_BUILD_THREAD=auto \
@PERL@ ./mysql-test-run.pl --force --comment=rpl --suite=rpl
-cd mysql-test ; MTR_BUILD_THREAD=auto \
@PERL@ ./mysql-test-run.pl --force --comment=partitions --suite=parts
-if [ -d mysql-test/suite/nist ] ; then \
cd mysql-test ; MTR_BUILD_THREAD=auto \
@PERL@ ./mysql-test-run.pl --comment=NIST+normal --force --suite=nist ; \
fi
-if [ -d mysql-test/suite/nist ] ; then \
cd mysql-test ; MTR_BUILD_THREAD=auto \
@PERL@ ./mysql-test-run.pl --comment=NIST+ps --force --suite=nist --ps-protocol ; \
fi
-cd mysql-test ; MTR_BUILD_THREAD=auto \
@PERL@ ./mysql-test-run.pl --force --comment=stress --suite=stress
# Re-enable the "jp" suite when bug#28563 is fixed
# -cd mysql-test ; MTR_BUILD_THREAD=auto \
# @PERL@ ./mysql-test-run.pl --force --comment=jp --suite=jp
test-bt-debug: test-bt-debug:
-cd mysql-test ; MTR_BUILD_THREAD=auto \ -cd mysql-test ; MTR_BUILD_THREAD=auto \
@ -151,18 +183,23 @@ test-ext-rpl:
test-ext-partitions: test-ext-partitions:
cd mysql-test ; \ cd mysql-test ; \
@PERL@ ./mysql-test-run.pl --force --suite=partitions @PERL@ ./mysql-test-run.pl --force --suite=parts
test-ext-jp: test-ext-jp:
cd mysql-test ; \ cd mysql-test ; \
@PERL@ ./mysql-test-run.pl --force --suite=jp @PERL@ ./mysql-test-run.pl --force --suite=jp
test-ext: test-ext-funcs test-ext-rpl test-ext-partitions test-ext-jp test-ext-stress:
cd mysql-test ; \
@PERL@ ./mysql-test-run.pl --force --big-test --suite=stress
test-ext: test-ext-funcs test-ext-rpl test-ext-partitions test-ext-jp test-ext-stress
test-fast: test-fast:
cd mysql-test ; \ cd mysql-test ; \
@PERL@ ./mysql-test-run.pl $(subset) --force --skip-ndb --skip-innodb --skip-im --skip-rpl ; \ @PERL@ ./mysql-test-run.pl $(subset) --force --skip-ndb --skip-innodb --skip-im --skip-rpl ; \
@PERL@ ./mysql-test-run.pl $(subset) --force --suite=funcs_1 --do-test=myisam @PERL@ ./mysql-test-run.pl $(subset) --force --suite=funcs_1 --do-test=myisam ; \
@PERL@ ./mysql-test-run.pl $(subset) --force --suite=stress --do-test=ddl_myisam
test-fast-view: test-fast-view:
$(MAKE) subset=--view-protocol test-fast $(MAKE) subset=--view-protocol test-fast

88
client/CMakeLists.txt Normal file → Executable file
View File

@ -14,91 +14,58 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
# We use the "mysqlclient_notls" library here just as safety, in case
# any of the clients here would go beond the client API and access the
# Thread Local Storage directly.
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
# The old Windows build method used renamed (.cc -> .cpp) source files, fails INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
# in #include in mysqlbinlog.cc. So disable that using the USING_CMAKE define. ${CMAKE_SOURCE_DIR}/zlib
ADD_DEFINITIONS(-DUSING_CMAKE) ${CMAKE_SOURCE_DIR}/extra/yassl/include
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/zlib
${CMAKE_SOURCE_DIR}/extra/yassl/include
${CMAKE_SOURCE_DIR}/libmysql ${CMAKE_SOURCE_DIR}/libmysql
${CMAKE_SOURCE_DIR}/regex ${CMAKE_SOURCE_DIR}/regex
${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/sql
${CMAKE_SOURCE_DIR}/strings) ${CMAKE_SOURCE_DIR}/strings)
ADD_LIBRARY(mysqlclient ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc ../mysys/my_conio.c)
../strings/bmove_upp.c ../mysys/charset-def.c ../mysys/charset.c TARGET_LINK_LIBRARIES(mysql mysqlclient_notls wsock32)
../sql-common/client.c ../strings/ctype-big5.c ../strings/ctype-bin.c
../strings/ctype-cp932.c ../strings/ctype-czech.c ../strings/ctype-euc_kr.c
../strings/ctype-eucjpms.c ../strings/ctype-extra.c ../strings/ctype-gb2312.c
../strings/ctype-gbk.c ../strings/ctype-latin1.c ../strings/ctype-mb.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-utf8.c ../strings/ctype-win1250ch.c ../strings/ctype.c
../mysys/default.c ../libmysql/errmsg.c ../mysys/errors.c
../libmysql/get_password.c ../strings/int2str.c ../strings/is_prefix.c
../libmysql/libmysql.c ../mysys/list.c ../strings/llstr.c
../strings/longlong2str.c ../libmysql/manager.c ../mysys/mf_cache.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_pack.c ../mysys/mf_path.c ../mysys/mf_tempfile.c ../mysys/mf_unixpath.c
../mysys/mf_wcomp.c ../mysys/mulalloc.c ../mysys/my_access.c ../mysys/my_alloc.c
../mysys/my_chsize.c ../mysys/my_compress.c ../mysys/my_create.c
../mysys/my_delete.c ../mysys/my_div.c ../mysys/my_error.c ../mysys/my_file.c
../mysys/my_fopen.c ../mysys/my_fstream.c ../mysys/my_gethostbyname.c
../mysys/my_getopt.c ../mysys/my_getwd.c ../mysys/my_init.c ../mysys/my_lib.c
../mysys/my_malloc.c ../mysys/my_messnc.c ../mysys/my_net.c ../mysys/my_once.c
../mysys/my_open.c ../mysys/my_pread.c ../mysys/my_pthread.c ../mysys/my_read.c
../mysys/my_realloc.c ../mysys/my_rename.c ../mysys/my_seek.c
../mysys/my_static.c ../strings/my_strtoll10.c ../mysys/my_symlink.c
../mysys/my_symlink2.c ../mysys/my_thr_init.c ../sql-common/my_time.c
../strings/my_vsnprintf.c ../mysys/my_wincond.c ../mysys/my_winthread.c
../mysys/my_write.c ../sql/net_serv.cc ../sql-common/pack.c ../sql/password.c
../mysys/safemalloc.c ../mysys/sha1.c ../strings/str2int.c
../strings/str_alloc.c ../strings/strcend.c ../strings/strcont.c ../strings/strend.c
../strings/strfill.c ../mysys/string.c ../strings/strinstr.c ../strings/strmake.c
../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c
../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c
../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c
../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c)
ADD_DEPENDENCIES(mysqlclient GenError) ADD_EXECUTABLE(mysqltest mysqltest.c ../mysys/my_getsystime.c ../mysys/my_copy.c)
ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc) TARGET_LINK_LIBRARIES(mysqltest mysqlclient_notls regex wsock32)
LINK_DIRECTORIES(${MYSQL_BINARY_DIR}/mysys ${MYSQL_BINARY_DIR}/zlib)
TARGET_LINK_LIBRARIES(mysql mysqlclient mysys yassl taocrypt zlib dbug wsock32)
ADD_EXECUTABLE(mysqltest mysqltest.c)
TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys yassl taocrypt zlib dbug regex wsock32)
ADD_EXECUTABLE(mysqlcheck mysqlcheck.c) ADD_EXECUTABLE(mysqlcheck mysqlcheck.c)
TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient dbug yassl taocrypt zlib wsock32) TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient_notls wsock32)
ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c) ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c ../mysys/mf_getdate.c)
TARGET_LINK_LIBRARIES(mysqldump mysqlclient mysys dbug yassl taocrypt zlib wsock32) TARGET_LINK_LIBRARIES(mysqldump mysqlclient_notls wsock32)
ADD_EXECUTABLE(mysqlimport mysqlimport.c) ADD_EXECUTABLE(mysqlimport mysqlimport.c)
TARGET_LINK_LIBRARIES(mysqlimport mysqlclient mysys dbug yassl taocrypt zlib wsock32) TARGET_LINK_LIBRARIES(mysqlimport mysqlclient_notls wsock32)
ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c ../mysys/my_getpagesize.c) ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c ../mysys/my_getpagesize.c)
TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient dbug yassl taocrypt zlib wsock32) TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient_notls wsock32)
ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs) ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs)
ADD_EXECUTABLE(mysqlshow mysqlshow.c) ADD_EXECUTABLE(mysqlshow mysqlshow.c)
TARGET_LINK_LIBRARIES(mysqlshow mysqlclient mysys dbug yassl taocrypt zlib wsock32) TARGET_LINK_LIBRARIES(mysqlshow mysqlclient_notls wsock32)
ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc ../mysys/mf_tempdir.c ../mysys/my_new.cc ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc
../mysys/my_bit.c ../mysys/my_bitmap.c ../mysys/my_vle.c ../mysys/mf_tempdir.c
../mysys/base64.c) ../mysys/my_new.cc
TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient dbug yassl taocrypt zlib wsock32) ../mysys/my_bit.c
../mysys/my_bitmap.c
../mysys/my_vle.c
../mysys/base64.c)
TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient_notls wsock32)
ADD_EXECUTABLE(mysqladmin mysqladmin.cc) ADD_EXECUTABLE(mysqladmin mysqladmin.cc)
TARGET_LINK_LIBRARIES(mysqladmin mysqlclient mysys dbug yassl taocrypt zlib wsock32) TARGET_LINK_LIBRARIES(mysqladmin mysqlclient_notls wsock32)
ADD_EXECUTABLE(mysqlslap mysqlslap.c) ADD_EXECUTABLE(mysqlslap mysqlslap.c)
SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS") SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS")
TARGET_LINK_LIBRARIES(mysqlslap mysqlclient mysys yassl taocrypt zlib wsock32 dbug) TARGET_LINK_LIBRARIES(mysqlslap mysqlclient mysys zlib wsock32 dbug)
ADD_EXECUTABLE(echo echo.c) ADD_EXECUTABLE(echo echo.c)
@ -114,3 +81,4 @@ IF(EMBED_MANIFESTS)
MYSQL_EMBED_MANIFEST("mysqladmin" "asInvoker") MYSQL_EMBED_MANIFEST("mysqladmin" "asInvoker")
MYSQL_EMBED_MANIFEST("echo" "asInvoker") MYSQL_EMBED_MANIFEST("echo" "asInvoker")
ENDIF(EMBED_MANIFESTS) ENDIF(EMBED_MANIFESTS)

View File

@ -48,7 +48,7 @@ enum options_client
OPT_PROMPT, OPT_IGN_LINES,OPT_TRANSACTION,OPT_MYSQL_PROTOCOL, OPT_PROMPT, OPT_IGN_LINES,OPT_TRANSACTION,OPT_MYSQL_PROTOCOL,
OPT_SHARED_MEMORY_BASE_NAME, OPT_FRM, OPT_SKIP_OPTIMIZATION, OPT_SHARED_MEMORY_BASE_NAME, OPT_FRM, OPT_SKIP_OPTIMIZATION,
OPT_COMPATIBLE, OPT_RECONNECT, OPT_DELIMITER, OPT_SECURE_AUTH, OPT_COMPATIBLE, OPT_RECONNECT, OPT_DELIMITER, OPT_SECURE_AUTH,
OPT_OPEN_FILES_LIMIT, OPT_SET_CHARSET, OPT_CREATE_OPTIONS, OPT_OPEN_FILES_LIMIT, OPT_SET_CHARSET, OPT_CREATE_OPTIONS, OPT_SERVER_ARG,
OPT_START_POSITION, OPT_STOP_POSITION, OPT_START_DATETIME, OPT_STOP_DATETIME, OPT_START_POSITION, OPT_STOP_POSITION, OPT_START_DATETIME, OPT_STOP_DATETIME,
OPT_SIGINT_IGNORE, OPT_HEXBLOB, OPT_ORDER_BY_PRIMARY, OPT_COUNT, OPT_SIGINT_IGNORE, OPT_HEXBLOB, OPT_ORDER_BY_PRIMARY, OPT_COUNT,
#ifdef HAVE_NDBCLUSTER_DB #ifdef HAVE_NDBCLUSTER_DB
@ -73,8 +73,12 @@ enum options_client
OPT_SLAP_AUTO_GENERATE_UNIQUE_QUERY_NUM, OPT_SLAP_AUTO_GENERATE_UNIQUE_QUERY_NUM,
OPT_SLAP_PRE_QUERY, OPT_SLAP_PRE_QUERY,
OPT_SLAP_POST_QUERY, OPT_SLAP_POST_QUERY,
OPT_SLAP_PRE_SYSTEM,
OPT_SLAP_POST_SYSTEM,
OPT_SLAP_COMMIT,
OPT_SLAP_DETACH,
OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT, OPT_SERVER_ID, OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT, OPT_SERVER_ID,
OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT, OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
OPT_DEBUG_INFO, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE, OPT_WRITE_BINLOG, OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE,
OPT_MAX_CLIENT_OPTION OPT_WRITE_BINLOG, OPT_MAX_CLIENT_OPTION
}; };

View File

@ -213,7 +213,7 @@ void completion_hash_clean(HashTable *ht)
void completion_hash_free(HashTable *ht) void completion_hash_free(HashTable *ht)
{ {
completion_hash_clean(ht); completion_hash_clean(ht);
my_free((gptr) ht->arBuckets,MYF(0)); my_free(ht->arBuckets, MYF(0));
} }

View File

@ -28,6 +28,6 @@ typedef struct st_line_buffer
} LINE_BUFFER; } LINE_BUFFER;
extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file); extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file);
extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, my_string str); extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, char * str);
extern char *batch_readline(LINE_BUFFER *buffer); extern char *batch_readline(LINE_BUFFER *buffer);
extern void batch_readline_end(LINE_BUFFER *buffer); extern void batch_readline_end(LINE_BUFFER *buffer);

View File

@ -43,7 +43,7 @@
#include <locale.h> #include <locale.h>
#endif #endif
const char *VER= "14.13"; const char *VER= "14.14";
/* Don't try to make a nice table if the data is too big */ /* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH 1024 #define MAX_COLUMN_LENGTH 1024
@ -51,7 +51,10 @@ const char *VER= "14.13";
/* Buffer to hold 'version' and 'version_comment' */ /* Buffer to hold 'version' and 'version_comment' */
#define MAX_SERVER_VERSION_LENGTH 128 #define MAX_SERVER_VERSION_LENGTH 128
gptr sql_alloc(unsigned size); // Don't use mysqld alloc for these /* Array of options to pass to libemysqld */
#define MAX_SERVER_ARGS 64
void* sql_alloc(unsigned size); // Don't use mysqld alloc for these
void sql_element_free(void *ptr); void sql_element_free(void *ptr);
#include "sql_string.h" #include "sql_string.h"
@ -129,7 +132,7 @@ enum enum_info_type { INFO_INFO,INFO_ERROR,INFO_RESULT};
typedef enum enum_info_type INFO_TYPE; typedef enum enum_info_type INFO_TYPE;
static MYSQL mysql; /* The connection */ static MYSQL mysql; /* The connection */
static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0, static my_bool ignore_errors=0,wait_flag=0,quick=0,
connected=0,opt_raw_data=0,unbuffered=0,output_tables=0, connected=0,opt_raw_data=0,unbuffered=0,output_tables=0,
opt_rehash=1,skip_updates=0,safe_updates=0,one_database=0, opt_rehash=1,skip_updates=0,safe_updates=0,one_database=0,
opt_compress=0, using_opt_local_infile=0, opt_compress=0, using_opt_local_infile=0,
@ -139,10 +142,12 @@ static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0,
default_charset_used= 0, opt_secure_auth= 0, default_charset_used= 0, opt_secure_auth= 0,
default_pager_set= 0, opt_sigint_ignore= 0, default_pager_set= 0, opt_sigint_ignore= 0,
show_warnings= 0, executing_query= 0, interrupted_query= 0; show_warnings= 0, executing_query= 0, interrupted_query= 0;
static my_bool debug_info_flag, debug_check_flag;
static my_bool column_types_flag; static my_bool column_types_flag;
static ulong opt_max_allowed_packet, opt_net_buffer_length; static ulong opt_max_allowed_packet, opt_net_buffer_length;
static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0; static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0;
static my_string opt_mysql_unix_port=0; static uint my_end_arg;
static char * opt_mysql_unix_port=0;
static int connect_flag=CLIENT_INTERACTIVE; static int connect_flag=CLIENT_INTERACTIVE;
static char *current_host,*current_db,*current_user=0,*opt_password=0, static char *current_host,*current_db,*current_user=0,*opt_password=0,
*current_prompt=0, *delimiter_str= 0, *current_prompt=0, *delimiter_str= 0,
@ -191,6 +196,8 @@ void tee_putc(int c, FILE *file);
static void tee_print_sized_data(const char *, unsigned int, unsigned int, bool); static void tee_print_sized_data(const char *, unsigned int, unsigned int, bool);
/* The names of functions that actually do the manipulation. */ /* The names of functions that actually do the manipulation. */
static int get_options(int argc,char **argv); static int get_options(int argc,char **argv);
extern "C" my_bool get_one_option(int optid, const struct my_option *opt,
char *argument);
static int com_quit(String *str,char*), static int com_quit(String *str,char*),
com_go(String *str,char*), com_ego(String *str,char*), com_go(String *str,char*), com_ego(String *str,char*),
com_print(String *str,char*), com_print(String *str,char*),
@ -302,7 +309,10 @@ static COMMANDS commands[] = {
}; };
static const char *load_default_groups[]= { "mysql","client",0 }; static const char *load_default_groups[]= { "mysql","client",0 };
static const char *server_default_groups[]=
static int embedded_server_arg_count= 0;
static char *embedded_server_args[MAX_SERVER_ARGS];
static const char *embedded_server_groups[]=
{ "server", "embedded", "mysql_SERVER", 0 }; { "server", "embedded", "mysql_SERVER", 0 };
#ifdef HAVE_READLINE #ifdef HAVE_READLINE
@ -341,21 +351,12 @@ static ulong start_timer(void);
static void end_timer(ulong start_time,char *buff); static void end_timer(ulong start_time,char *buff);
static void mysql_end_timer(ulong start_time,char *buff); static void mysql_end_timer(ulong start_time,char *buff);
static void nice_time(double sec,char *buff,bool part_second); static void nice_time(double sec,char *buff,bool part_second);
static sig_handler mysql_end(int sig); extern "C" sig_handler mysql_end(int sig);
static sig_handler handle_sigint(int sig); extern "C" sig_handler handle_sigint(int sig);
int main(int argc,char *argv[]) int main(int argc,char *argv[])
{ {
char buff[80]; char buff[80];
char *defaults, *extra_defaults, *group_suffix;
char *emb_argv[4];
int emb_argc;
/* Get --defaults-xxx args for mysql_server_init() */
emb_argc= get_defaults_options(argc, argv, &defaults, &extra_defaults,
&group_suffix)+1;
memcpy((char*) emb_argv, (char*) argv, emb_argc * sizeof(*argv));
emb_argv[emb_argc]= 0;
MY_INIT(argv[0]); MY_INIT(argv[0]);
DBUG_ENTER("main"); DBUG_ENTER("main");
@ -416,7 +417,8 @@ int main(int argc,char *argv[])
my_end(0); my_end(0);
exit(1); exit(1);
} }
if (mysql_server_init(emb_argc, emb_argv, (char**) server_default_groups)) if (mysql_server_init(embedded_server_arg_count, embedded_server_args,
(char**) embedded_server_groups))
{ {
free_defaults(defaults_argv); free_defaults(defaults_argv);
my_end(0); my_end(0);
@ -539,9 +541,11 @@ sig_handler mysql_end(int sig)
my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
#endif #endif
my_free(current_prompt,MYF(MY_ALLOW_ZERO_PTR)); my_free(current_prompt,MYF(MY_ALLOW_ZERO_PTR));
while (embedded_server_arg_count > 1)
my_free(embedded_server_args[--embedded_server_arg_count],MYF(0));
mysql_server_end(); mysql_server_end();
free_defaults(defaults_argv); free_defaults(defaults_argv);
my_end(info_flag ? MY_CHECK_ERROR : 0); my_end(my_end_arg);
exit(status.exit_status); exit(status.exit_status);
} }
@ -587,7 +591,7 @@ static struct my_option my_long_options[] =
#endif #endif
{"auto-rehash", OPT_AUTO_REHASH, {"auto-rehash", OPT_AUTO_REHASH,
"Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash.", "Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash.",
(gptr*) &opt_rehash, (gptr*) &opt_rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, (uchar**) &opt_rehash, (uchar**) &opt_rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0,
0, 0}, 0, 0},
{"no-auto-rehash", 'A', {"no-auto-rehash", 'A',
"No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead.", "No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead.",
@ -595,42 +599,45 @@ static struct my_option my_long_options[] =
{"batch", 'B', {"batch", 'B',
"Don't use history file. Disable interactive behavior. (Enables --silent)", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, "Don't use history file. Disable interactive behavior. (Enables --silent)", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"character-sets-dir", OPT_CHARSETS_DIR, {"character-sets-dir", OPT_CHARSETS_DIR,
"Directory where character sets are.", (gptr*) &charsets_dir, "Directory where character sets are.", (uchar**) &charsets_dir,
(gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"column-type-info", OPT_COLUMN_TYPES, "Display column type information.", {"column-type-info", OPT_COLUMN_TYPES, "Display column type information.",
(gptr*) &column_types_flag, (gptr*) &column_types_flag, (uchar**) &column_types_flag, (uchar**) &column_types_flag,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"compress", 'C', "Use compression in server/client protocol.", {"compress", 'C', "Use compression in server/client protocol.",
(gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
#ifdef DBUG_OFF #ifdef DBUG_OFF
{"debug", '#', "This is a non-debug version. Catch this and exit", {"debug", '#', "This is a non-debug version. Catch this and exit",
0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, 0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
#else #else
{"debug", '#', "Output debug log", (gptr*) &default_dbug_option, {"debug", '#', "Output debug log", (uchar**) &default_dbug_option,
(gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"debug-info", 'T', "Print some debug info at exit.", (gptr*) &info_flag, {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .",
(gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0,
{"database", 'D', "Database to use.", (gptr*) &current_db, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
(gptr*) &current_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"debug-info", 'T', "Print some debug info at exit.", (uchar**) &debug_info_flag,
(uchar**) &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"database", 'D', "Database to use.", (uchar**) &current_db,
(uchar**) &current_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"default-character-set", OPT_DEFAULT_CHARSET, {"default-character-set", OPT_DEFAULT_CHARSET,
"Set the default character set.", (gptr*) &default_charset, "Set the default character set.", (uchar**) &default_charset,
(gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"delimiter", OPT_DELIMITER, "Delimiter to be used.", (gptr*) &delimiter_str, {"delimiter", OPT_DELIMITER, "Delimiter to be used.", (uchar**) &delimiter_str,
(gptr*) &delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"execute", 'e', "Execute command and quit. (Disables --force and history file)", 0, {"execute", 'e', "Execute command and quit. (Disables --force and history file)", 0,
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"vertical", 'E', "Print the output of a query (rows) vertically.", {"vertical", 'E', "Print the output of a query (rows) vertically.",
(gptr*) &vertical, (gptr*) &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, (uchar**) &vertical, (uchar**) &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
0}, 0},
{"force", 'f', "Continue even if we get an sql error.", {"force", 'f', "Continue even if we get an sql error.",
(gptr*) &ignore_errors, (gptr*) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, (uchar**) &ignore_errors, (uchar**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0,
0, 0, 0, 0}, 0, 0, 0, 0},
{"named-commands", 'G', {"named-commands", 'G',
"Enable named commands. Named commands mean this program's internal commands; see mysql> help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter. Disable with --disable-named-commands. This option is disabled by default.", "Enable named commands. Named commands mean this program's internal commands; see mysql> help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter. Disable with --disable-named-commands. This option is disabled by default.",
(gptr*) &named_cmds, (gptr*) &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, (uchar**) &named_cmds, (uchar**) &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
{"no-named-commands", 'g', {"no-named-commands", 'g',
"Named commands are disabled. Use \\* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option deprecated; use --disable-named-commands instead.", "Named commands are disabled. Use \\* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option deprecated; use --disable-named-commands instead.",
@ -638,25 +645,25 @@ static struct my_option my_long_options[] =
{"ignore-spaces", 'i', "Ignore space after function names.", 0, 0, 0, {"ignore-spaces", 'i', "Ignore space after function names.", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"local-infile", OPT_LOCAL_INFILE, "Enable/disable LOAD DATA LOCAL INFILE.", {"local-infile", OPT_LOCAL_INFILE, "Enable/disable LOAD DATA LOCAL INFILE.",
(gptr*) &opt_local_infile, (uchar**) &opt_local_infile,
(gptr*) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"no-beep", 'b', "Turn off beep on error.", (gptr*) &opt_nobeep, {"no-beep", 'b', "Turn off beep on error.", (uchar**) &opt_nobeep,
(gptr*) &opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", (gptr*) &current_host, {"host", 'h', "Connect to host.", (uchar**) &current_host,
(gptr*) &current_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &current_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"html", 'H', "Produce HTML output.", (gptr*) &opt_html, (gptr*) &opt_html, {"html", 'H', "Produce HTML output.", (uchar**) &opt_html, (uchar**) &opt_html,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"xml", 'X', "Produce XML output", (gptr*) &opt_xml, (gptr*) &opt_xml, 0, {"xml", 'X', "Produce XML output", (uchar**) &opt_xml, (uchar**) &opt_xml, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"line-numbers", OPT_LINE_NUMBERS, "Write line numbers for errors.", {"line-numbers", OPT_LINE_NUMBERS, "Write line numbers for errors.",
(gptr*) &line_numbers, (gptr*) &line_numbers, 0, GET_BOOL, (uchar**) &line_numbers, (uchar**) &line_numbers, 0, GET_BOOL,
NO_ARG, 1, 0, 0, 0, 0, 0}, NO_ARG, 1, 0, 0, 0, 0, 0},
{"skip-line-numbers", 'L', "Don't write line number for errors. WARNING: -L is deprecated, use long version of this option instead.", 0, 0, 0, GET_NO_ARG, {"skip-line-numbers", 'L', "Don't write line number for errors. WARNING: -L is deprecated, use long version of this option instead.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"unbuffered", 'n', "Flush buffer after each query.", (gptr*) &unbuffered, {"unbuffered", 'n', "Flush buffer after each query.", (uchar**) &unbuffered,
(gptr*) &unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"column-names", OPT_COLUMN_NAMES, "Write column names in results.", {"column-names", OPT_COLUMN_NAMES, "Write column names in results.",
(gptr*) &column_names, (gptr*) &column_names, 0, GET_BOOL, (uchar**) &column_names, (uchar**) &column_names, 0, GET_BOOL,
NO_ARG, 1, 0, 0, 0, 0, 0}, NO_ARG, 1, 0, 0, 0, 0, 0},
{"skip-column-names", 'N', {"skip-column-names", 'N',
"Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead.", "Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead.",
@ -665,7 +672,7 @@ static struct my_option my_long_options[] =
"Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.", "Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"sigint-ignore", OPT_SIGINT_IGNORE, "Ignore SIGINT (CTRL-C)", {"sigint-ignore", OPT_SIGINT_IGNORE, "Ignore SIGINT (CTRL-C)",
(gptr*) &opt_sigint_ignore, (gptr*) &opt_sigint_ignore, 0, GET_BOOL, (uchar**) &opt_sigint_ignore, (uchar**) &opt_sigint_ignore, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"one-database", 'o', {"one-database", 'o',
"Only update the default database. This is useful for skipping updates to other database in the update log.", "Only update the default database. This is useful for skipping updates to other database in the update log.",
@ -685,49 +692,49 @@ static struct my_option my_long_options[] =
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, {"port", 'P', "Port number to use for connection.", (uchar**) &opt_mysql_port,
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, (uchar**) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
0}, 0},
{"prompt", OPT_PROMPT, "Set the mysql prompt to this value.", {"prompt", OPT_PROMPT, "Set the mysql prompt to this value.",
(gptr*) &current_prompt, (gptr*) &current_prompt, 0, GET_STR_ALLOC, (uchar**) &current_prompt, (uchar**) &current_prompt, 0, GET_STR_ALLOC,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"quick", 'q', {"quick", 'q',
"Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file.", "Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file.",
(gptr*) &quick, (gptr*) &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &quick, (uchar**) &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"raw", 'r', "Write fields without conversion. Used with --batch.", {"raw", 'r', "Write fields without conversion. Used with --batch.",
(gptr*) &opt_raw_data, (gptr*) &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, (uchar**) &opt_raw_data, (uchar**) &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
{"reconnect", OPT_RECONNECT, "Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default.", {"reconnect", OPT_RECONNECT, "Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default.",
(gptr*) &opt_reconnect, (gptr*) &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, (uchar**) &opt_reconnect, (uchar**) &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"silent", 's', "Be more silent. Print results with a tab as separator, each row on new line.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, {"silent", 's', "Be more silent. Print results with a tab as separator, each row on new line.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
"Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, "Base name of shared memory.", (uchar**) &shared_memory_base_name, (uchar**) &shared_memory_base_name,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"socket", 'S', "Socket file to use for connection.", {"socket", 'S', "Socket file to use for connection.",
(gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR_ALLOC, (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR_ALLOC,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#include "sslopt-longopts.h" #include "sslopt-longopts.h"
{"table", 't', "Output in table format.", (gptr*) &output_tables, {"table", 't', "Output in table format.", (uchar**) &output_tables,
(gptr*) &output_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &output_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"tee", OPT_TEE, {"tee", OPT_TEE,
"Append everything into outfile. See interactive help (\\h) also. Does not work in batch mode. Disable with --disable-tee. This option is disabled by default.", "Append everything into outfile. See interactive help (\\h) also. Does not work in batch mode. Disable with --disable-tee. This option is disabled by default.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"no-tee", OPT_NOTEE, "Disable outfile. See interactive help (\\h) also. WARNING: option deprecated; use --disable-tee instead", 0, 0, 0, GET_NO_ARG, {"no-tee", OPT_NOTEE, "Disable outfile. See interactive help (\\h) also. WARNING: option deprecated; use --disable-tee instead", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
#ifndef DONT_ALLOW_USER_CHANGE #ifndef DONT_ALLOW_USER_CHANGE
{"user", 'u', "User for login if not current user.", (gptr*) &current_user, {"user", 'u', "User for login if not current user.", (uchar**) &current_user,
(gptr*) &current_user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &current_user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"safe-updates", 'U', "Only allow UPDATE and DELETE that uses keys.", {"safe-updates", 'U', "Only allow UPDATE and DELETE that uses keys.",
(gptr*) &safe_updates, (gptr*) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0, (uchar**) &safe_updates, (uchar**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
0, 0, 0, 0}, 0, 0, 0, 0},
{"i-am-a-dummy", 'U', "Synonym for option --safe-updates, -U.", {"i-am-a-dummy", 'U', "Synonym for option --safe-updates, -U.",
(gptr*) &safe_updates, (gptr*) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0, (uchar**) &safe_updates, (uchar**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
0, 0, 0, 0}, 0, 0, 0, 0},
{"verbose", 'v', "Write more. (-v -v -v gives the table output format).", 0, {"verbose", 'v', "Write more. (-v -v -v gives the table output format).", 0,
0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
@ -737,32 +744,34 @@ static struct my_option my_long_options[] =
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"connect_timeout", OPT_CONNECT_TIMEOUT, {"connect_timeout", OPT_CONNECT_TIMEOUT,
"Number of seconds before connection timeout.", "Number of seconds before connection timeout.",
(gptr*) &opt_connect_timeout, (uchar**) &opt_connect_timeout,
(gptr*) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 3600*12, 0, (uchar**) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 3600*12, 0,
0, 1}, 0, 0},
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
"Max packet length to send to, or receive from server", "Max packet length to send to, or receive from server",
(gptr*) &opt_max_allowed_packet, (gptr*) &opt_max_allowed_packet, 0, GET_ULONG, (uchar**) &opt_max_allowed_packet, (uchar**) &opt_max_allowed_packet, 0, GET_ULONG,
REQUIRED_ARG, 16 *1024L*1024L, 4096, (longlong) 2*1024L*1024L*1024L, REQUIRED_ARG, 16 *1024L*1024L, 4096, (longlong) 2*1024L*1024L*1024L,
MALLOC_OVERHEAD, 1024, 0}, MALLOC_OVERHEAD, 1024, 0},
{"net_buffer_length", OPT_NET_BUFFER_LENGTH, {"net_buffer_length", OPT_NET_BUFFER_LENGTH,
"Buffer for TCP/IP and socket communication", "Buffer for TCP/IP and socket communication",
(gptr*) &opt_net_buffer_length, (gptr*) &opt_net_buffer_length, 0, GET_ULONG, (uchar**) &opt_net_buffer_length, (uchar**) &opt_net_buffer_length, 0, GET_ULONG,
REQUIRED_ARG, 16384, 1024, 512*1024*1024L, MALLOC_OVERHEAD, 1024, 0}, REQUIRED_ARG, 16384, 1024, 512*1024*1024L, MALLOC_OVERHEAD, 1024, 0},
{"select_limit", OPT_SELECT_LIMIT, {"select_limit", OPT_SELECT_LIMIT,
"Automatic limit for SELECT when using --safe-updates", "Automatic limit for SELECT when using --safe-updates",
(gptr*) &select_limit, (uchar**) &select_limit,
(gptr*) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ~0L, 0, 1, 0}, (uchar**) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ~0L, 0, 1, 0},
{"max_join_size", OPT_MAX_JOIN_SIZE, {"max_join_size", OPT_MAX_JOIN_SIZE,
"Automatic limit for rows in a join when using --safe-updates", "Automatic limit for rows in a join when using --safe-updates",
(gptr*) &max_join_size, (uchar**) &max_join_size,
(gptr*) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ~0L, 0, 1, (uchar**) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ~0L, 0, 1,
0}, 0},
{"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it" {"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
" uses old (pre-4.1.1) protocol", (gptr*) &opt_secure_auth, " uses old (pre-4.1.1) protocol", (uchar**) &opt_secure_auth,
(gptr*) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"server-arg", OPT_SERVER_ARG, "Send embedded server this as a parameter.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"show-warnings", OPT_SHOW_WARNINGS, "Show warnings after every statement.", {"show-warnings", OPT_SHOW_WARNINGS, "Show warnings after every statement.",
(gptr*) &show_warnings, (gptr*) &show_warnings, 0, GET_BOOL, NO_ARG, (uchar**) &show_warnings, (uchar**) &show_warnings, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
@ -807,7 +816,7 @@ and you are welcome to modify and redistribute it under the GPL license\n");
} }
static my_bool my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
@ -888,7 +897,29 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
opt->name); opt->name);
break; break;
break; case OPT_SERVER_ARG:
#ifdef EMBEDDED_LIBRARY
/*
When the embedded server is being tested, the client needs to be
able to pass command-line arguments to the embedded server so it can
locate the language files and data directory.
*/
if (!embedded_server_arg_count)
{
embedded_server_arg_count= 1;
embedded_server_args[0]= (char*) "";
}
if (embedded_server_arg_count == MAX_SERVER_ARGS-1 ||
!(embedded_server_args[embedded_server_arg_count++]=
my_strdup(argument, MYF(MY_FAE))))
{
put_info("Can't use server argument", INFO_ERROR);
return 0;
}
#else /*EMBEDDED_LIBRARY */
printf("WARNING: --server-arg option not supported in this configuration.\n");
#endif
break;
case 'A': case 'A':
opt_rehash= 0; opt_rehash= 0;
break; break;
@ -927,7 +958,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break; break;
case '#': case '#':
DBUG_PUSH(argument ? argument : default_dbug_option); DBUG_PUSH(argument ? argument : default_dbug_option);
info_flag= 1; debug_info_flag= 1;
break; break;
case 's': case 's':
if (argument == disabled_my_option) if (argument == disabled_my_option)
@ -1021,6 +1052,10 @@ static int get_options(int argc, char **argv)
} }
if (tty_password) if (tty_password)
opt_password= get_tty_password(NullS); opt_password= get_tty_password(NullS);
if (debug_info_flag)
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
if (debug_check_flag)
my_end_arg= MY_CHECK_ERROR;
return(0); return(0);
} }
@ -1079,7 +1114,7 @@ static int read_and_execute(bool interactive)
tmpbuf.alloc(65535); tmpbuf.alloc(65535);
tmpbuf.length(0); tmpbuf.length(0);
buffer.length(0); buffer.length(0);
unsigned long clen; size_t clen;
do do
{ {
line= my_cgets((char*)tmpbuf.ptr(), tmpbuf.alloced_length()-1, &clen); line= my_cgets((char*)tmpbuf.ptr(), tmpbuf.alloced_length()-1, &clen);
@ -1089,7 +1124,12 @@ static int read_and_execute(bool interactive)
something else is still in console input buffer something else is still in console input buffer
*/ */
} while (tmpbuf.alloced_length() <= clen); } while (tmpbuf.alloced_length() <= clen);
line= buffer.c_ptr(); /*
An empty line is returned from my_cgets when there's error reading :
Ctrl-c for example
*/
if (line)
line= buffer.c_ptr();
#endif /* __NETWARE__ */ #endif /* __NETWARE__ */
#else #else
if (opt_outfile) if (opt_outfile)
@ -1223,6 +1263,7 @@ static bool add_line(String &buffer,char *line,char *in_string,
char buff[80], *pos, *out; char buff[80], *pos, *out;
COMMANDS *com; COMMANDS *com;
bool need_space= 0; bool need_space= 0;
bool ss_comment= 0;
DBUG_ENTER("add_line"); DBUG_ENTER("add_line");
if (!line[0] && buffer.is_empty()) if (!line[0] && buffer.is_empty())
@ -1271,22 +1312,36 @@ static bool add_line(String &buffer,char *line,char *in_string,
} }
if ((com=find_command(NullS,(char) inchar))) if ((com=find_command(NullS,(char) inchar)))
{ {
const String tmp(line,(uint) (out-line), charset_info); const String tmp(line,(uint) (out-line), charset_info);
buffer.append(tmp); buffer.append(tmp);
if ((*com->func)(&buffer,pos-1) > 0) if ((*com->func)(&buffer,pos-1) > 0)
DBUG_RETURN(1); // Quit DBUG_RETURN(1); // Quit
if (com->takes_params) if (com->takes_params)
{ {
for (pos++ ; if (ss_comment)
*pos && (*pos != *delimiter || {
!is_prefix(pos + 1, delimiter + 1)) ; pos++) /*
; // Remove parameters If a client-side macro appears inside a server-side comment,
if (!*pos) discard all characters in the comment after the macro (that is,
pos--; until the end of the comment rather than the next delimiter)
else */
pos+= delimiter_length - 1; // Point at last delim char for (pos++; *pos && (*pos != '*' || *(pos + 1) != '/'); pos++)
} ;
out=line; pos--;
}
else
{
for (pos++ ;
*pos && (*pos != *delimiter ||
!is_prefix(pos + 1, delimiter + 1)) ; pos++)
; // Remove parameters
if (!*pos)
pos--;
else
pos+= delimiter_length - 1; // Point at last delim char
}
}
out=line;
} }
else else
{ {
@ -1346,7 +1401,7 @@ static bool add_line(String &buffer,char *line,char *in_string,
out=line; out=line;
} }
} }
else if (*ml_comment && inchar == '*' && *(pos + 1) == '/') else if (*ml_comment && !ss_comment && inchar == '*' && *(pos + 1) == '/')
{ {
pos++; pos++;
*ml_comment= 0; *ml_comment= 0;
@ -1354,6 +1409,11 @@ static bool add_line(String &buffer,char *line,char *in_string,
} }
else else
{ // Add found char to buffer { // Add found char to buffer
if (!*in_string && inchar == '/' && *(pos + 1) == '*' &&
*(pos + 2) == '!')
ss_comment= 1;
else if (!*in_string && ss_comment && inchar == '*' && *(pos + 1) == '/')
ss_comment= 0;
if (inchar == *in_string) if (inchar == *in_string)
*in_string= 0; *in_string= 0;
else if (!*ml_comment && !*in_string && else if (!*ml_comment && !*in_string &&
@ -1389,7 +1449,7 @@ static bool add_line(String &buffer,char *line,char *in_string,
#ifdef HAVE_READLINE #ifdef HAVE_READLINE
static char *new_command_generator(const char *text, int); static char *new_command_generator(const char *text, int);
static char **new_mysql_completion (const char *text, int start, int end); extern "C" char **new_mysql_completion (const char *text, int start, int end);
/* /*
Tell the GNU Readline library how to complete. We want to try to complete Tell the GNU Readline library how to complete. We want to try to complete
@ -1398,9 +1458,9 @@ static char **new_mysql_completion (const char *text, int start, int end);
*/ */
#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_LIBEDIT_INTERFACE) #if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_LIBEDIT_INTERFACE)
char *no_completion(const char*,int) extern "C" char *no_completion(const char*,int)
#else #else
char *no_completion() extern "C" char *no_completion()
#endif #endif
{ {
return 0; /* No filename completion */ return 0; /* No filename completion */
@ -1502,9 +1562,9 @@ static void initialize_readline (char *name)
array of matches, or NULL if there aren't any. array of matches, or NULL if there aren't any.
*/ */
static char **new_mysql_completion (const char *text, char **new_mysql_completion (const char *text,
int start __attribute__((unused)), int start __attribute__((unused)),
int end __attribute__((unused))) int end __attribute__((unused)))
{ {
if (!status.batch && !quick) if (!status.batch && !quick)
#if defined(USE_NEW_READLINE_INTERFACE) #if defined(USE_NEW_READLINE_INTERFACE)
@ -2443,7 +2503,7 @@ print_table_data(MYSQL_RES *result)
(void) tee_fputs("\n", PAGER); (void) tee_fputs("\n", PAGER);
} }
tee_puts((char*) separator.ptr(), PAGER); tee_puts((char*) separator.ptr(), PAGER);
my_afree((gptr) num_flag); my_afree((uchar*) num_flag);
} }
@ -2842,10 +2902,10 @@ com_edit(String *buffer,char *line __attribute__((unused)))
MYF(MY_WME))) < 0) MYF(MY_WME))) < 0)
goto err; goto err;
if (buffer->is_empty() && !old_buffer.is_empty()) if (buffer->is_empty() && !old_buffer.is_empty())
(void) my_write(fd,(byte*) old_buffer.ptr(),old_buffer.length(), (void) my_write(fd,(uchar*) old_buffer.ptr(),old_buffer.length(),
MYF(MY_WME)); MYF(MY_WME));
else else
(void) my_write(fd,(byte*) buffer->ptr(),buffer->length(),MYF(MY_WME)); (void) my_write(fd,(uchar*) buffer->ptr(),buffer->length(),MYF(MY_WME));
(void) my_close(fd,MYF(0)); (void) my_close(fd,MYF(0));
if (!(editor = (char *)getenv("EDITOR")) && if (!(editor = (char *)getenv("EDITOR")) &&
@ -3283,7 +3343,7 @@ sql_real_connect(char *host,char *database,char *user,char *password,
} }
connected=1; connected=1;
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
mysql.reconnect=info_flag ? 1 : 0; // We want to know if this happens mysql.reconnect= debug_info_flag; // We want to know if this happens
#else #else
mysql.reconnect= 1; mysql.reconnect= 1;
#endif #endif
@ -3893,13 +3953,13 @@ static int com_prompt(String *buffer, char *line)
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
/* Keep sql_string library happy */ /* Keep sql_string library happy */
gptr sql_alloc(unsigned int Size) void *sql_alloc(size_t Size)
{ {
return my_malloc(Size,MYF(MY_WME)); return my_malloc(Size,MYF(MY_WME));
} }
void sql_element_free(void *ptr) void sql_element_free(void *ptr)
{ {
my_free((gptr) ptr,MYF(0)); my_free(ptr,MYF(0));
} }
#endif /* EMBEDDED_LIBRARY */ #endif /* EMBEDDED_LIBRARY */

View File

@ -17,6 +17,8 @@
#include <sslopt-vars.h> #include <sslopt-vars.h>
#include "../scripts/mysql_fix_privilege_tables_sql.c" #include "../scripts/mysql_fix_privilege_tables_sql.c"
#define VER "1.1"
#ifdef HAVE_SYS_WAIT_H #ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h> #include <sys/wait.h>
#endif #endif
@ -32,7 +34,8 @@
static char mysql_path[FN_REFLEN]; static char mysql_path[FN_REFLEN];
static char mysqlcheck_path[FN_REFLEN]; static char mysqlcheck_path[FN_REFLEN];
static my_bool opt_force, opt_verbose; static my_bool opt_force, opt_verbose, debug_info_flag, debug_check_flag;
static uint my_end_arg= 0;
static char *opt_user= (char*)"root"; static char *opt_user= (char*)"root";
static DYNAMIC_STRING ds_args; static DYNAMIC_STRING ds_args;
@ -56,6 +59,11 @@ static struct my_option my_long_options[]=
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"basedir", 'b', "Not used by mysql_upgrade. Only for backward compatibilty", {"basedir", 'b', "Not used by mysql_upgrade. Only for backward compatibilty",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"character-sets-dir", OPT_CHARSETS_DIR,
"Directory where character sets are.", 0,
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"compress", OPT_COMPRESS, "Use compression in server/client protocol.",
(uchar**)&not_used, (uchar**)&not_used, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"datadir", 'd', {"datadir", 'd',
"Not used by mysql_upgrade. Only for backward compatibilty", "Not used by mysql_upgrade. Only for backward compatibilty",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@ -63,26 +71,26 @@ static struct my_option my_long_options[]=
{"debug", '#', "This is a non-debug version. Catch this and exit", {"debug", '#', "This is a non-debug version. Catch this and exit",
0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
#else #else
{"debug", '#', "Output debug log", (gptr *) & default_dbug_option, {"debug", '#', "Output debug log", (uchar* *) & default_dbug_option,
(gptr *) & default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, (uchar* *) & default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .",
(uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"debug-info", 'T', "Print some debug info at exit.", (uchar**) &debug_info_flag,
(uchar**) &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"default-character-set", OPT_DEFAULT_CHARSET, {"default-character-set", OPT_DEFAULT_CHARSET,
"Set the default character set.", 0, "Set the default character set.", 0,
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"character-sets-dir", OPT_CHARSETS_DIR,
"Directory where character sets are.", 0,
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"compress", OPT_COMPRESS, "Use compression in server/client protocol.",
(gptr*)&not_used, (gptr*)&not_used, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"force", 'f', "Force execution of mysqlcheck even if mysql_upgrade " {"force", 'f', "Force execution of mysqlcheck even if mysql_upgrade "
"has already been executed for the current version of MySQL.", "has already been executed for the current version of MySQL.",
(gptr*)&opt_force, (gptr*)&opt_force, 0, (uchar**)&opt_force, (uchar**)&opt_force, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"host",'h', "Connect to host.", 0, {"host",'h', "Connect to host.", 0,
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p', {"password", 'p',
"Password to use when connecting to server. If password is not given" "Password to use when connecting to server. If password is not given"
" it's solicited on the tty.", (gptr*) &opt_password,(gptr*) &opt_password, " it's solicited on the tty.", (uchar**) &opt_password,(uchar**) &opt_password,
0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#ifdef __WIN__ #ifdef __WIN__
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0,
@ -100,11 +108,11 @@ static struct my_option my_long_options[]=
#endif #endif
{"socket", 'S', "Socket file to use for connection.", {"socket", 'S', "Socket file to use for connection.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"user", 'u', "User for login if not current user.", (gptr*) &opt_user, {"user", 'u', "User for login if not current user.", (uchar**) &opt_user,
(gptr*) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#include <sslopt-longopts.h> #include <sslopt-longopts.h>
{"verbose", 'v', "Display more output about the process", {"verbose", 'v', "Display more output about the process",
(gptr*) &opt_verbose, (gptr*) &opt_verbose, 0, (uchar**) &opt_verbose, (uchar**) &opt_verbose, 0,
GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
@ -138,7 +146,7 @@ static void die(const char *fmt, ...)
va_end(args); va_end(args);
free_used_memory(); free_used_memory();
my_end(MY_CHECK_ERROR); my_end(my_end_arg);
exit(1); exit(1);
} }
@ -200,8 +208,9 @@ get_one_option(int optid, const struct my_option *opt,
switch (optid) { switch (optid) {
case '?': case '?':
printf("MySQL utility for upgrading database to MySQL version %s\n", printf("%s Ver %s Distrib %s, for %s (%s)\n",
MYSQL_SERVER_VERSION); my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
puts("MySQL utility for upgrading databases to new MySQL versions\n");
my_print_help(my_long_options); my_print_help(my_long_options);
exit(0); exit(0);
break; break;
@ -209,6 +218,7 @@ get_one_option(int optid, const struct my_option *opt,
case '#': case '#':
DBUG_PUSH(argument ? argument : default_dbug_option); DBUG_PUSH(argument ? argument : default_dbug_option);
add_option= FALSE; add_option= FALSE;
debug_check_flag= 1;
break; break;
case 'p': case 'p':
@ -342,16 +352,11 @@ static my_bool get_full_path_to_executable(char* path)
/* /*
Look for the tool in the same directory as mysql_upgrade. Look for the tool in the same directory as mysql_upgrade.
When running in a not yet installed build the the program
will exist but it need to be invoked via it's libtool wrapper.
Check if the found tool can executed and if not look in the
directory one step higher up where the libtool wrapper normally
is found
*/ */
static void find_tool(char *tool_path, const char *tool_name) static void find_tool(char *tool_path, const char *tool_name)
{ {
size_t path_len;
char path[FN_REFLEN]; char path[FN_REFLEN];
DYNAMIC_STRING ds_tmp; DYNAMIC_STRING ds_tmp;
DBUG_ENTER("find_tool"); DBUG_ENTER("find_tool");
@ -385,37 +390,52 @@ static void find_tool(char *tool_path, const char *tool_name)
path[0]= 0; path[0]= 0;
} }
} }
do
DBUG_PRINT("info", ("path: '%s'", path));
/* Chop off binary name (i.e mysql-upgrade) from path */
dirname_part(path, path, &path_len);
/*
When running in a not yet installed build and using libtool,
the program(mysql_upgrade) will be in .libs/ and executed
through a libtool wrapper in order to use the dynamic libraries
from this build. The same must be done for the tools(mysql and
mysqlcheck). Thus if path ends in .libs/, step up one directory
and execute the tools from there
*/
path[max(path_len-1, 0)]= 0; /* Chop off last / */
if (strncmp(path + dirname_length(path), ".libs", 5) == 0)
{ {
DBUG_PRINT("enter", ("path: %s", path)); DBUG_PRINT("info", ("Chopping off .libs from '%s'", path));
/* Chop off last char(since it might be a /) */ /* Chop off .libs */
path[max((strlen(path)-1), 0)]= 0; dirname_part(path, path, &path_len);
/* Chop off last dir part */
dirname_part(path, path);
/* Format name of the tool to search for */
fn_format(tool_path, tool_name,
path, "", MYF(MY_REPLACE_DIR));
verbose("Looking for '%s' in: %s", tool_name, tool_path);
/* Make sure the tool exists */
if (my_access(tool_path, F_OK) != 0)
die("Can't find '%s'", tool_path);
/*
Make sure it can be executed, otherwise try again
in higher level directory
*/
} }
while(run_tool(tool_path,
&ds_tmp, /* Get output from command, discard*/
"--help", DBUG_PRINT("info", ("path: '%s'", path));
"2>&1",
IF_WIN("> NUL", "> /dev/null"), /* Format name of the tool to search for */
NULL)); fn_format(tool_path, tool_name,
path, "", MYF(MY_REPLACE_DIR));
verbose("Looking for '%s' in: %s", tool_name, tool_path);
/* Make sure the tool exists */
if (my_access(tool_path, F_OK) != 0)
die("Can't find '%s'", tool_path);
/*
Make sure it can be executed
*/
if (run_tool(tool_path,
&ds_tmp, /* Get output from command, discard*/
"--help",
"2>&1",
IF_WIN("> NUL", "> /dev/null"),
NULL))
die("Can't execute '%s'", tool_path);
dynstr_free(&ds_tmp); dynstr_free(&ds_tmp);
@ -440,12 +460,13 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res,
MYF(MY_WME))) < 0) MYF(MY_WME))) < 0)
die("Failed to create temporary file for defaults"); die("Failed to create temporary file for defaults");
if (my_write(fd, query, strlen(query), if (my_write(fd, (uchar*) query, strlen(query),
MYF(MY_FNABP | MY_WME))) MYF(MY_FNABP | MY_WME)))
die("Failed to write to '%s'", query_file_path); die("Failed to write to '%s'", query_file_path);
ret= run_tool(mysql_path, ret= run_tool(mysql_path,
ds_res, ds_res,
"--no-defaults",
ds_args.str, ds_args.str,
"--database=mysql", "--database=mysql",
"--batch", /* Turns off pager etc. */ "--batch", /* Turns off pager etc. */
@ -457,6 +478,7 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res,
NULL); NULL);
my_close(fd, MYF(0)); my_close(fd, MYF(0));
my_delete(query_file_path, MYF(0));
DBUG_RETURN(ret); DBUG_RETURN(ret);
} }
@ -607,6 +629,7 @@ static int run_mysqlcheck_upgrade(void)
verbose("Running 'mysqlcheck'..."); verbose("Running 'mysqlcheck'...");
return run_tool(mysqlcheck_path, return run_tool(mysqlcheck_path,
NULL, /* Send output from mysqlcheck directly to screen */ NULL, /* Send output from mysqlcheck directly to screen */
"--no-defaults",
ds_args.str, ds_args.str,
"--check-upgrade", "--check-upgrade",
"--all-databases", "--all-databases",
@ -731,6 +754,10 @@ int main(int argc, char **argv)
if (handle_options(&argc, &argv, my_long_options, get_one_option)) if (handle_options(&argc, &argv, my_long_options, get_one_option))
die(NULL); die(NULL);
if (debug_info_flag)
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
if (debug_check_flag)
my_end_arg= MY_CHECK_ERROR;
if (tty_password) if (tty_password)
{ {
@ -779,7 +806,7 @@ int main(int argc, char **argv)
create_mysql_upgrade_info_file(); create_mysql_upgrade_info_file();
free_used_memory(); free_used_memory();
my_end(MY_CHECK_ERROR); my_end(my_end_arg);
exit(0); exit(0);
} }

View File

@ -40,11 +40,12 @@ ulonglong last_values[MAX_MYSQL_VAR];
static int interval=0; static int interval=0;
static my_bool option_force=0,interrupted=0,new_line=0, static my_bool option_force=0,interrupted=0,new_line=0,
opt_compress=0, opt_relative=0, opt_verbose=0, opt_vertical=0, opt_compress=0, opt_relative=0, opt_verbose=0, opt_vertical=0,
tty_password= 0, info_flag= 0, opt_nobeep; tty_password= 0, opt_nobeep;
static uint tcp_port = 0, option_wait = 0, option_silent=0, nr_iterations, static my_bool debug_info_flag= 0, debug_check_flag= 0;
opt_count_iterations= 0; static uint tcp_port = 0, option_wait = 0, option_silent=0, nr_iterations;
static uint opt_count_iterations= 0, my_end_arg;
static ulong opt_connect_timeout, opt_shutdown_timeout; static ulong opt_connect_timeout, opt_shutdown_timeout;
static my_string unix_port=0; static char * unix_port=0;
#ifdef LATER_HAVE_NDBCLUSTER_DB #ifdef LATER_HAVE_NDBCLUSTER_DB
static my_bool opt_ndbcluster=0; static my_bool opt_ndbcluster=0;
static char *opt_ndb_connectstring=0; static char *opt_ndb_connectstring=0;
@ -70,10 +71,12 @@ static uint ex_var_count, max_var_length, max_val_length;
static void print_version(void); static void print_version(void);
static void usage(void); static void usage(void);
extern "C" my_bool get_one_option(int optid, const struct my_option *opt,
char *argument);
static my_bool sql_connect(MYSQL *mysql, uint wait); static my_bool sql_connect(MYSQL *mysql, uint wait);
static int execute_commands(MYSQL *mysql,int argc, char **argv); static int execute_commands(MYSQL *mysql,int argc, char **argv);
static int drop_db(MYSQL *mysql,const char *db); static int drop_db(MYSQL *mysql,const char *db);
static sig_handler endprog(int signal_number); extern "C" sig_handler endprog(int signal_number);
static void nice_time(ulong sec,char *buff); static void nice_time(ulong sec,char *buff);
static void print_header(MYSQL_RES *result); static void print_header(MYSQL_RES *result);
static void print_top(MYSQL_RES *result); static void print_top(MYSQL_RES *result);
@ -132,31 +135,37 @@ static struct my_option my_long_options[] =
#endif #endif
{"count", 'c', {"count", 'c',
"Number of iterations to make. This works with -i (--sleep) only.", "Number of iterations to make. This works with -i (--sleep) only.",
(gptr*) &nr_iterations, (gptr*) &nr_iterations, 0, GET_UINT, (uchar**) &nr_iterations, (uchar**) &nr_iterations, 0, GET_UINT,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#ifndef DBUG_OFF
{"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (gptr*) &info_flag, #endif
(gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .",
(uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
(uchar**) &debug_info_flag, (uchar**) &debug_info_flag,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"force", 'f', {"force", 'f',
"Don't ask for confirmation on drop database; with multiple commands, continue even if an error occurs.", "Don't ask for confirmation on drop database; with multiple commands, continue even if an error occurs.",
(gptr*) &option_force, (gptr*) &option_force, 0, GET_BOOL, NO_ARG, 0, 0, (uchar**) &option_force, (uchar**) &option_force, 0, GET_BOOL, NO_ARG, 0, 0,
0, 0, 0, 0}, 0, 0, 0, 0},
{"compress", 'C', "Use compression in server/client protocol.", {"compress", 'C', "Use compression in server/client protocol.",
(gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
{"character-sets-dir", OPT_CHARSETS_DIR, {"character-sets-dir", OPT_CHARSETS_DIR,
"Directory where character sets are.", (gptr*) &charsets_dir, "Directory where character sets are.", (uchar**) &charsets_dir,
(gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"default-character-set", OPT_DEFAULT_CHARSET, {"default-character-set", OPT_DEFAULT_CHARSET,
"Set the default character set.", (gptr*) &default_charset, "Set the default character set.", (uchar**) &default_charset,
(gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", (gptr*) &host, (gptr*) &host, 0, GET_STR, {"host", 'h', "Connect to host.", (uchar**) &host, (uchar**) &host, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"no-beep", 'b', "Turn off beep on error.", (gptr*) &opt_nobeep, {"no-beep", 'b', "Turn off beep on error.", (uchar**) &opt_nobeep,
(gptr*) &opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p', {"password", 'p',
"Password to use when connecting to server. If password is not given it's asked from the tty.", "Password to use when connecting to server. If password is not given it's asked from the tty.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
@ -164,58 +173,58 @@ static struct my_option my_long_options[] =
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"port", 'P', "Port number to use for connection.", (gptr*) &tcp_port, {"port", 'P', "Port number to use for connection.", (uchar**) &tcp_port,
(gptr*) &tcp_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &tcp_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"relative", 'r', {"relative", 'r',
"Show difference between current and previous values when used with -i. Currently works only with extended-status.", "Show difference between current and previous values when used with -i. Currently works only with extended-status.",
(gptr*) &opt_relative, (gptr*) &opt_relative, 0, GET_BOOL, NO_ARG, 0, 0, 0, (uchar**) &opt_relative, (uchar**) &opt_relative, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
{"set-variable", 'O', {"set-variable", 'O',
"Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.", "Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
"Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, "Base name of shared memory.", (uchar**) &shared_memory_base_name, (uchar**) &shared_memory_base_name,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"silent", 's', "Silently exit if one can't connect to server.", {"silent", 's', "Silently exit if one can't connect to server.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"socket", 'S', "Socket file to use for connection.", {"socket", 'S', "Socket file to use for connection.",
(gptr*) &unix_port, (gptr*) &unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, (uchar**) &unix_port, (uchar**) &unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
{"sleep", 'i', "Execute commands again and again with a sleep between.", {"sleep", 'i', "Execute commands again and again with a sleep between.",
(gptr*) &interval, (gptr*) &interval, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, (uchar**) &interval, (uchar**) &interval, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
#include <sslopt-longopts.h> #include <sslopt-longopts.h>
#ifndef DONT_ALLOW_USER_CHANGE #ifndef DONT_ALLOW_USER_CHANGE
{"user", 'u', "User for login if not current user.", (gptr*) &user, {"user", 'u', "User for login if not current user.", (uchar**) &user,
(gptr*) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"verbose", 'v', "Write more information.", (gptr*) &opt_verbose, {"verbose", 'v', "Write more information.", (uchar**) &opt_verbose,
(gptr*) &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"vertical", 'E', {"vertical", 'E',
"Print output vertically. Is similar to --relative, but prints output vertically.", "Print output vertically. Is similar to --relative, but prints output vertically.",
(gptr*) &opt_vertical, (gptr*) &opt_vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, (uchar**) &opt_vertical, (uchar**) &opt_vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
{"wait", 'w', "Wait and retry if connection is down.", 0, 0, 0, GET_UINT, {"wait", 'w', "Wait and retry if connection is down.", 0, 0, 0, GET_UINT,
OPT_ARG, 0, 0, 0, 0, 0, 0}, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"connect_timeout", OPT_CONNECT_TIMEOUT, "", (gptr*) &opt_connect_timeout, {"connect_timeout", OPT_CONNECT_TIMEOUT, "", (uchar**) &opt_connect_timeout,
(gptr*) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 3600*12, 0, (uchar**) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 3600*12, 0,
3600*12, 0, 1, 0}, 3600*12, 0, 1, 0},
{"shutdown_timeout", OPT_SHUTDOWN_TIMEOUT, "", (gptr*) &opt_shutdown_timeout, {"shutdown_timeout", OPT_SHUTDOWN_TIMEOUT, "", (uchar**) &opt_shutdown_timeout,
(gptr*) &opt_shutdown_timeout, 0, GET_ULONG, REQUIRED_ARG, (uchar**) &opt_shutdown_timeout, 0, GET_ULONG, REQUIRED_ARG,
SHUTDOWN_DEF_TIMEOUT, 0, 3600*12, 0, 1, 0}, SHUTDOWN_DEF_TIMEOUT, 0, 3600*12, 0, 1, 0},
#ifdef LATER_HAVE_NDBCLUSTER_DB #ifdef LATER_HAVE_NDBCLUSTER_DB
{"ndbcluster", OPT_NDBCLUSTER, "" {"ndbcluster", OPT_NDBCLUSTER, ""
"", (gptr*) &opt_ndbcluster, "", (uchar**) &opt_ndbcluster,
(gptr*) &opt_ndbcluster, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &opt_ndbcluster, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"ndb-connectstring", OPT_NDB_CONNECTSTRING, "" {"ndb-connectstring", OPT_NDB_CONNECTSTRING, ""
"", (gptr*) &opt_ndb_connectstring, "", (uchar**) &opt_ndb_connectstring,
(gptr*) &opt_ndb_connectstring, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &opt_ndb_connectstring, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
@ -223,7 +232,7 @@ static struct my_option my_long_options[] =
static const char *load_default_groups[]= { "mysqladmin","client",0 }; static const char *load_default_groups[]= { "mysqladmin","client",0 };
static my_bool my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
@ -315,6 +324,10 @@ int main(int argc,char *argv[])
free_defaults(save_argv); free_defaults(save_argv);
exit(ho_error); exit(ho_error);
} }
if (debug_info_flag)
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
if (debug_check_flag)
my_end_arg= MY_CHECK_ERROR;
if (argc == 0) if (argc == 0)
{ {
@ -413,13 +426,13 @@ int main(int argc,char *argv[])
my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
#endif #endif
free_defaults(save_argv); free_defaults(save_argv);
my_end(info_flag ? MY_CHECK_ERROR : 0); my_end(my_end_arg);
exit(error ? 1 : 0); exit(error ? 1 : 0);
return 0; return 0;
} }
static sig_handler endprog(int signal_number __attribute__((unused))) sig_handler endprog(int signal_number __attribute__((unused)))
{ {
interrupted=1; interrupted=1;
} }

View File

@ -65,11 +65,13 @@ static bool one_database=0, to_last_remote_log= 0, disable_log_bin= 0;
static bool opt_hexdump= 0; static bool opt_hexdump= 0;
static bool opt_base64_output= 0; static bool opt_base64_output= 0;
static const char* database= 0; static const char* database= 0;
static my_bool force_opt= 0, short_form= 0, remote_opt= 0, info_flag; static my_bool force_opt= 0, short_form= 0, remote_opt= 0;
static my_bool debug_info_flag, debug_check_flag;
static my_bool force_if_open_opt= 1; static my_bool force_if_open_opt= 1;
static ulonglong offset = 0; static ulonglong offset = 0;
static const char* host = 0; static const char* host = 0;
static int port= 0; static int port= 0;
static uint my_end_arg;
static const char* sock= 0; static const char* sock= 0;
static const char* user = 0; static const char* user = 0;
static char* pass = 0; static char* pass = 0;
@ -296,7 +298,7 @@ File Load_log_processor::prepare_new_file_for_old_format(Load_log_event *le,
int Load_log_processor::load_old_format_file(NET* net, const char*server_fname, int Load_log_processor::load_old_format_file(NET* net, const char*server_fname,
uint server_fname_len, File file) uint server_fname_len, File file)
{ {
char buf[FN_REFLEN+1]; uchar buf[FN_REFLEN+1];
buf[0] = 0; buf[0] = 0;
memcpy(buf + 1, server_fname, server_fname_len + 1); memcpy(buf + 1, server_fname, server_fname_len + 1);
if (my_net_write(net, buf, server_fname_len +2) || net_flush(net)) if (my_net_write(net, buf, server_fname_len +2) || net_flush(net))
@ -310,7 +312,7 @@ int Load_log_processor::load_old_format_file(NET* net, const char*server_fname,
ulong packet_len = my_net_read(net); ulong packet_len = my_net_read(net);
if (packet_len == 0) if (packet_len == 0)
{ {
if (my_net_write(net, "", 0) || net_flush(net)) if (my_net_write(net, (uchar*) "", 0) || net_flush(net))
{ {
sql_print_error("Failed sending the ack packet"); sql_print_error("Failed sending the ack packet");
return -1; return -1;
@ -334,7 +336,7 @@ int Load_log_processor::load_old_format_file(NET* net, const char*server_fname,
sql_print_error("Illegal length of packet read from net"); sql_print_error("Illegal length of packet read from net");
return -1; return -1;
} }
if (my_write(file, (byte*) net->read_pos, if (my_write(file, (uchar*) net->read_pos,
(uint) packet_len, MYF(MY_WME|MY_NABP))) (uint) packet_len, MYF(MY_WME|MY_NABP)))
return -1; return -1;
} }
@ -379,7 +381,7 @@ int Load_log_processor::process_first_event(const char *bname, uint blen,
File_name_record rec; File_name_record rec;
DBUG_ENTER("Load_log_processor::process_first_event"); DBUG_ENTER("Load_log_processor::process_first_event");
if (!(fname= my_malloc(full_len,MYF(MY_WME)))) if (!(fname= (char*) my_malloc(full_len,MYF(MY_WME))))
DBUG_RETURN(-1); DBUG_RETURN(-1);
memcpy(fname, target_dir_name, target_dir_name_len); memcpy(fname, target_dir_name, target_dir_name_len);
@ -398,7 +400,7 @@ int Load_log_processor::process_first_event(const char *bname, uint blen,
rec.fname= fname; rec.fname= fname;
rec.event= ce; rec.event= ce;
if (set_dynamic(&file_names, (gptr)&rec, file_id)) if (set_dynamic(&file_names, (uchar*)&rec, file_id))
{ {
sql_print_error("Could not construct local filename %s%s", sql_print_error("Could not construct local filename %s%s",
target_dir_name, bname); target_dir_name, bname);
@ -408,7 +410,7 @@ int Load_log_processor::process_first_event(const char *bname, uint blen,
if (ce) if (ce)
ce->set_fname_outside_temp_buf(fname, strlen(fname)); ce->set_fname_outside_temp_buf(fname, strlen(fname));
if (my_write(file, (byte*)block, block_len, MYF(MY_WME|MY_NABP))) if (my_write(file, (uchar*)block, block_len, MYF(MY_WME|MY_NABP)))
error= -1; error= -1;
if (my_close(file, MYF(MY_WME))) if (my_close(file, MYF(MY_WME)))
error= -1; error= -1;
@ -447,7 +449,7 @@ int Load_log_processor::process(Append_block_log_event *ae)
if (((file= my_open(fname, if (((file= my_open(fname,
O_APPEND|O_BINARY|O_WRONLY,MYF(MY_WME))) < 0)) O_APPEND|O_BINARY|O_WRONLY,MYF(MY_WME))) < 0))
DBUG_RETURN(-1); DBUG_RETURN(-1);
if (my_write(file,(byte*)ae->block,ae->block_len,MYF(MY_WME|MY_NABP))) if (my_write(file,(uchar*)ae->block,ae->block_len,MYF(MY_WME|MY_NABP)))
error= -1; error= -1;
if (my_close(file,MYF(MY_WME))) if (my_close(file,MYF(MY_WME)))
error= -1; error= -1;
@ -635,6 +637,7 @@ Create_file event for file_id: %u\n",exv->file_id);
print_event_info->common_header_len= print_event_info->common_header_len=
glob_description_event->common_header_len; glob_description_event->common_header_len;
ev->print(result_file, print_event_info); ev->print(result_file, print_event_info);
ev->temp_buf= 0; // as the event ref is zeroed
/* /*
We don't want this event to be deleted now, so let's hide it (I We don't want this event to be deleted now, so let's hide it (I
(Guilhem) should later see if this triggers a non-serious Valgrind (Guilhem) should later see if this triggers a non-serious Valgrind
@ -682,8 +685,16 @@ Begin_load_query event for file_id: %u\n", exlq->file_id);
end: end:
rec_count++; rec_count++;
/*
Destroy the log_event object. If reading from a remote host,
set the temp_buf to NULL so that memory isn't freed twice.
*/
if (ev) if (ev)
{
if (remote_opt)
ev->temp_buf= 0;
delete ev; delete ev;
}
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -700,7 +711,7 @@ static struct my_option my_long_options[] =
"Print all binlog entries using base64 encoding. " "Print all binlog entries using base64 encoding. "
"This is for debugging only. Logs produced using this option " "This is for debugging only. Logs produced using this option "
"should not be applied on production systems.", "should not be applied on production systems.",
(gptr*) &opt_base64_output, (gptr*) &opt_base64_output, 0, GET_BOOL, (uchar**) &opt_base64_output, (uchar**) &opt_base64_output, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
/* /*
mysqlbinlog needs charsets knowledge, to be able to convert a charset mysqlbinlog needs charsets knowledge, to be able to convert a charset
@ -709,47 +720,51 @@ static struct my_option my_long_options[] =
SET @`a`:=_cp850 0x4DFC6C6C6572 COLLATE `cp850_general_ci`; SET @`a`:=_cp850 0x4DFC6C6C6572 COLLATE `cp850_general_ci`;
*/ */
{"character-sets-dir", OPT_CHARSETS_DIR, {"character-sets-dir", OPT_CHARSETS_DIR,
"Directory where character sets are.", (gptr*) &charsets_dir, "Directory where character sets are.", (uchar**) &charsets_dir,
(gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"database", 'd', "List entries for just this database (local log only).", {"database", 'd', "List entries for just this database (local log only).",
(gptr*) &database, (gptr*) &database, 0, GET_STR_ALLOC, REQUIRED_ARG, (uchar**) &database, (uchar**) &database, 0, GET_STR_ALLOC, REQUIRED_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
#ifndef DBUG_OFF #ifndef DBUG_OFF
{"debug", '#', "Output debug log.", (gptr*) &default_dbug_option, {"debug", '#', "Output debug log.", (uchar**) &default_dbug_option,
(gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (gptr*) &info_flag, {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .",
(gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
(uchar**) &debug_info_flag, (uchar**) &debug_info_flag,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"disable-log-bin", 'D', "Disable binary log. This is useful, if you " {"disable-log-bin", 'D', "Disable binary log. This is useful, if you "
"enabled --to-last-log and are sending the output to the same MySQL server. " "enabled --to-last-log and are sending the output to the same MySQL server. "
"This way you could avoid an endless loop. You would also like to use it " "This way you could avoid an endless loop. You would also like to use it "
"when restoring after a crash to avoid duplication of the statements you " "when restoring after a crash to avoid duplication of the statements you "
"already have. NOTE: you will need a SUPER privilege to use this option.", "already have. NOTE: you will need a SUPER privilege to use this option.",
(gptr*) &disable_log_bin, (gptr*) &disable_log_bin, 0, GET_BOOL, (uchar**) &disable_log_bin, (uchar**) &disable_log_bin, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"force-if-open", 'F', "Force if binlog was not closed properly.", {"force-if-open", 'F', "Force if binlog was not closed properly.",
(gptr*) &force_if_open_opt, (gptr*) &force_if_open_opt, 0, GET_BOOL, NO_ARG, (uchar**) &force_if_open_opt, (uchar**) &force_if_open_opt, 0, GET_BOOL, NO_ARG,
1, 0, 0, 0, 0, 0}, 1, 0, 0, 0, 0, 0},
{"force-read", 'f', "Force reading unknown binlog events.", {"force-read", 'f', "Force reading unknown binlog events.",
(gptr*) &force_opt, (gptr*) &force_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, (uchar**) &force_opt, (uchar**) &force_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
{"hexdump", 'H', "Augment output with hexadecimal and ASCII event dump.", {"hexdump", 'H', "Augment output with hexadecimal and ASCII event dump.",
(gptr*) &opt_hexdump, (gptr*) &opt_hexdump, 0, GET_BOOL, NO_ARG, (uchar**) &opt_hexdump, (uchar**) &opt_hexdump, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Get the binlog from server.", (gptr*) &host, (gptr*) &host, {"host", 'h', "Get the binlog from server.", (uchar**) &host, (uchar**) &host,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"local-load", 'l', "Prepare local temporary files for LOAD DATA INFILE in the specified directory.", {"local-load", 'l', "Prepare local temporary files for LOAD DATA INFILE in the specified directory.",
(gptr*) &dirname_for_local_load, (gptr*) &dirname_for_local_load, 0, (uchar**) &dirname_for_local_load, (uchar**) &dirname_for_local_load, 0,
GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"offset", 'o', "Skip the first N entries.", (gptr*) &offset, (gptr*) &offset, {"offset", 'o', "Skip the first N entries.", (uchar**) &offset, (uchar**) &offset,
0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p', "Password to connect to remote server.", {"password", 'p', "Password to connect to remote server.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Use port to connect to the remote server.", {"port", 'P', "Use port to connect to the remote server.",
(gptr*) &port, (gptr*) &port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, (uchar**) &port, (uchar**) &port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
{"position", 'j', "Deprecated. Use --start-position instead.", {"position", 'j', "Deprecated. Use --start-position instead.",
(gptr*) &start_position, (gptr*) &start_position, 0, GET_ULL, (uchar**) &start_position, (uchar**) &start_position, 0, GET_ULL,
REQUIRED_ARG, BIN_LOG_HEADER_SIZE, BIN_LOG_HEADER_SIZE, REQUIRED_ARG, BIN_LOG_HEADER_SIZE, BIN_LOG_HEADER_SIZE,
/* COM_BINLOG_DUMP accepts only 4 bytes for the position */ /* COM_BINLOG_DUMP accepts only 4 bytes for the position */
(ulonglong)(~(uint32)0), 0, 0, 0}, (ulonglong)(~(uint32)0), 0, 0, 0},
@ -757,22 +772,22 @@ static struct my_option my_long_options[] =
"The protocol of connection (tcp,socket,pipe,memory).", "The protocol of connection (tcp,socket,pipe,memory).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"read-from-remote-server", 'R', "Read binary logs from a MySQL server", {"read-from-remote-server", 'R', "Read binary logs from a MySQL server",
(gptr*) &remote_opt, (gptr*) &remote_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, (uchar**) &remote_opt, (uchar**) &remote_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
{"result-file", 'r', "Direct output to a given file.", 0, 0, 0, GET_STR, {"result-file", 'r', "Direct output to a given file.", 0, 0, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"server-id", OPT_SERVER_ID, {"server-id", OPT_SERVER_ID,
"Extract only binlog entries created by the server having the given id.", "Extract only binlog entries created by the server having the given id.",
(gptr*) &server_id, (gptr*) &server_id, 0, GET_ULONG, (uchar**) &server_id, (uchar**) &server_id, 0, GET_ULONG,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"set-charset", OPT_SET_CHARSET, {"set-charset", OPT_SET_CHARSET,
"Add 'SET NAMES character_set' to the output.", (gptr*) &charset, "Add 'SET NAMES character_set' to the output.", (uchar**) &charset,
(gptr*) &charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"short-form", 's', "Just show the queries, no extra info.", {"short-form", 's', "Just show the queries, no extra info.",
(gptr*) &short_form, (gptr*) &short_form, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, (uchar**) &short_form, (uchar**) &short_form, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
{"socket", 'S', "Socket file to use for connection.", {"socket", 'S', "Socket file to use for connection.",
(gptr*) &sock, (gptr*) &sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, (uchar**) &sock, (uchar**) &sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
{"start-datetime", OPT_START_DATETIME, {"start-datetime", OPT_START_DATETIME,
"Start reading the binlog at first event having a datetime equal or " "Start reading the binlog at first event having a datetime equal or "
@ -780,12 +795,12 @@ static struct my_option my_long_options[] =
"in the local time zone, in any format accepted by the MySQL server " "in the local time zone, in any format accepted by the MySQL server "
"for DATETIME and TIMESTAMP types, for example: 2004-12-25 11:25:56 " "for DATETIME and TIMESTAMP types, for example: 2004-12-25 11:25:56 "
"(you should probably use quotes for your shell to set it properly).", "(you should probably use quotes for your shell to set it properly).",
(gptr*) &start_datetime_str, (gptr*) &start_datetime_str, (uchar**) &start_datetime_str, (uchar**) &start_datetime_str,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"start-position", OPT_START_POSITION, {"start-position", OPT_START_POSITION,
"Start reading the binlog at position N. Applies to the first binlog " "Start reading the binlog at position N. Applies to the first binlog "
"passed on the command line.", "passed on the command line.",
(gptr*) &start_position, (gptr*) &start_position, 0, GET_ULL, (uchar**) &start_position, (uchar**) &start_position, 0, GET_ULL,
REQUIRED_ARG, BIN_LOG_HEADER_SIZE, BIN_LOG_HEADER_SIZE, REQUIRED_ARG, BIN_LOG_HEADER_SIZE, BIN_LOG_HEADER_SIZE,
/* COM_BINLOG_DUMP accepts only 4 bytes for the position */ /* COM_BINLOG_DUMP accepts only 4 bytes for the position */
(ulonglong)(~(uint32)0), 0, 0, 0}, (ulonglong)(~(uint32)0), 0, 0, 0},
@ -795,28 +810,28 @@ static struct my_option my_long_options[] =
"in the local time zone, in any format accepted by the MySQL server " "in the local time zone, in any format accepted by the MySQL server "
"for DATETIME and TIMESTAMP types, for example: 2004-12-25 11:25:56 " "for DATETIME and TIMESTAMP types, for example: 2004-12-25 11:25:56 "
"(you should probably use quotes for your shell to set it properly).", "(you should probably use quotes for your shell to set it properly).",
(gptr*) &stop_datetime_str, (gptr*) &stop_datetime_str, (uchar**) &stop_datetime_str, (uchar**) &stop_datetime_str,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"stop-position", OPT_STOP_POSITION, {"stop-position", OPT_STOP_POSITION,
"Stop reading the binlog at position N. Applies to the last binlog " "Stop reading the binlog at position N. Applies to the last binlog "
"passed on the command line.", "passed on the command line.",
(gptr*) &stop_position, (gptr*) &stop_position, 0, GET_ULL, (uchar**) &stop_position, (uchar**) &stop_position, 0, GET_ULL,
REQUIRED_ARG, (ulonglong)(~(my_off_t)0), BIN_LOG_HEADER_SIZE, REQUIRED_ARG, (ulonglong)(~(my_off_t)0), BIN_LOG_HEADER_SIZE,
(ulonglong)(~(my_off_t)0), 0, 0, 0}, (ulonglong)(~(my_off_t)0), 0, 0, 0},
{"to-last-log", 't', "Requires -R. Will not stop at the end of the \ {"to-last-log", 't', "Requires -R. Will not stop at the end of the \
requested binlog but rather continue printing until the end of the last \ requested binlog but rather continue printing until the end of the last \
binlog of the MySQL server. If you send the output to the same MySQL server, \ binlog of the MySQL server. If you send the output to the same MySQL server, \
that may lead to an endless loop.", that may lead to an endless loop.",
(gptr*) &to_last_remote_log, (gptr*) &to_last_remote_log, 0, GET_BOOL, (uchar**) &to_last_remote_log, (uchar**) &to_last_remote_log, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"user", 'u', "Connect to the remote server as username.", {"user", 'u', "Connect to the remote server as username.",
(gptr*) &user, (gptr*) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, (uchar**) &user, (uchar**) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
{"version", 'V', "Print version and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, {"version", 'V', "Print version and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
0, 0, 0, 0, 0}, 0, 0, 0, 0, 0},
{"open_files_limit", OPT_OPEN_FILES_LIMIT, {"open_files_limit", OPT_OPEN_FILES_LIMIT,
"Used to reserve file descriptors for usage by this program", "Used to reserve file descriptors for usage by this program",
(gptr*) &open_files_limit, (gptr*) &open_files_limit, 0, GET_ULONG, (uchar**) &open_files_limit, (uchar**) &open_files_limit, 0, GET_ULONG,
REQUIRED_ARG, MY_NFILE, 8, OS_FILE_LIMIT, 0, 1, 0}, REQUIRED_ARG, MY_NFILE, 8, OS_FILE_LIMIT, 0, 1, 0},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
@ -851,7 +866,7 @@ static void die(const char* fmt, ...)
va_end(args); va_end(args);
cleanup(); cleanup();
/* We cannot free DBUG, it is used in global destructors after exit(). */ /* We cannot free DBUG, it is used in global destructors after exit(). */
my_end((info_flag ? MY_CHECK_ERROR : 0) | MY_DONT_FREE_DBUG); my_end(my_end_arg | MY_DONT_FREE_DBUG);
exit(1); exit(1);
} }
@ -859,7 +874,7 @@ static void die(const char* fmt, ...)
static void print_version() static void print_version()
{ {
printf("%s Ver 3.2 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); printf("%s Ver 3.3 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
NETWARE_SET_SCREEN_MODE(1); NETWARE_SET_SCREEN_MODE(1);
} }
@ -975,7 +990,10 @@ static int parse_args(int *argc, char*** argv)
load_defaults("my",load_default_groups,argc,argv); load_defaults("my",load_default_groups,argc,argv);
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
if (debug_info_flag)
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
if (debug_check_flag)
my_end_arg= MY_CHECK_ERROR;
return 0; return 0;
} }
@ -1012,14 +1030,14 @@ static int dump_log_entries(const char* logname)
like CREATE PROCEDURE safely like CREATE PROCEDURE safely
*/ */
fprintf(result_file, "DELIMITER /*!*/;\n"); fprintf(result_file, "DELIMITER /*!*/;\n");
strcpy(print_event_info.delimiter, "/*!*/;"); strmov(print_event_info.delimiter, "/*!*/;");
rc= (remote_opt ? dump_remote_log_entries(&print_event_info, logname) : rc= (remote_opt ? dump_remote_log_entries(&print_event_info, logname) :
dump_local_log_entries(&print_event_info, logname)); dump_local_log_entries(&print_event_info, logname));
/* Set delimiter back to semicolon */ /* Set delimiter back to semicolon */
fprintf(result_file, "DELIMITER ;\n"); fprintf(result_file, "DELIMITER ;\n");
strcpy(print_event_info.delimiter, ";"); strmov(print_event_info.delimiter, ";");
return rc; return rc;
} }
@ -1069,6 +1087,7 @@ static int check_master_version(MYSQL *mysql_arg,
break; break;
case '4': case '4':
*description_event= new Format_description_log_event(3); *description_event= new Format_description_log_event(3);
break;
case '5': case '5':
/* /*
The server is soon going to send us its Format_description log The server is soon going to send us its Format_description log
@ -1094,7 +1113,7 @@ static int dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
const char* logname) const char* logname)
{ {
char buf[128]; uchar buf[128];
ulong len; ulong len;
uint logname_len; uint logname_len;
NET* net; NET* net;
@ -1130,7 +1149,7 @@ could be out of memory");
int4store(buf, (uint32)start_position); int4store(buf, (uint32)start_position);
int2store(buf + BIN_LOG_HEADER_SIZE, binlog_flags); int2store(buf + BIN_LOG_HEADER_SIZE, binlog_flags);
size_s tlen = strlen(logname); size_t tlen = strlen(logname);
if (tlen > UINT_MAX) if (tlen > UINT_MAX)
{ {
fprintf(stderr,"Log name too long\n"); fprintf(stderr,"Log name too long\n");
@ -1172,6 +1191,12 @@ could be out of memory");
error= 1; error= 1;
goto err; goto err;
} }
/*
If reading from a remote host, ensure the temp_buf for the
Log_event class is pointing to the incoming stream.
*/
if (remote_opt)
ev->register_temp_buf((char*) net->read_pos + 1);
Log_event_type type= ev->get_type_code(); Log_event_type type= ev->get_type_code();
if (glob_description_event->binlog_version >= 3 || if (glob_description_event->binlog_version >= 3 ||
@ -1278,17 +1303,23 @@ err:
static void check_header(IO_CACHE* file, static void check_header(IO_CACHE* file,
Format_description_log_event **description_event) Format_description_log_event **description_event)
{ {
byte header[BIN_LOG_HEADER_SIZE]; uchar header[BIN_LOG_HEADER_SIZE];
byte buf[PROBE_HEADER_LEN]; uchar buf[PROBE_HEADER_LEN];
my_off_t tmp_pos, pos; my_off_t tmp_pos, pos;
*description_event= new Format_description_log_event(3); *description_event= new Format_description_log_event(3);
pos= my_b_tell(file); pos= my_b_tell(file);
my_b_seek(file, (my_off_t)0); my_b_seek(file, (my_off_t)0);
if (my_b_read(file, header, sizeof(header))) if (my_b_read(file, header, sizeof(header)))
{
delete *description_event;
die("Failed reading header; Probably an empty file"); die("Failed reading header; Probably an empty file");
}
if (memcmp(header, BINLOG_MAGIC, sizeof(header))) if (memcmp(header, BINLOG_MAGIC, sizeof(header)))
{
delete *description_event;
die("File is not a binary log file"); die("File is not a binary log file");
}
/* /*
Imagine we are running with --start-position=1000. We still need Imagine we are running with --start-position=1000. We still need
@ -1309,9 +1340,12 @@ static void check_header(IO_CACHE* file,
if (my_b_read(file, buf, sizeof(buf))) if (my_b_read(file, buf, sizeof(buf)))
{ {
if (file->error) if (file->error)
{
delete *description_event;
die("\ die("\
Could not read entry at offset %lu : Error in log format or read error", Could not read entry at offset %lu : Error in log format or read error",
tmp_pos); tmp_pos);
}
/* /*
Otherwise this is just EOF : this log currently contains 0-2 Otherwise this is just EOF : this log currently contains 0-2
events. Maybe it's going to be filled in the next events. Maybe it's going to be filled in the next
@ -1347,13 +1381,19 @@ Could not read entry at offset %lu : Error in log format or read error",
break; break;
else if (buf[4] == FORMAT_DESCRIPTION_EVENT) /* This is 5.0 */ else if (buf[4] == FORMAT_DESCRIPTION_EVENT) /* This is 5.0 */
{ {
Format_description_log_event *new_description_event;
my_b_seek(file, tmp_pos); /* seek back to event's start */ my_b_seek(file, tmp_pos); /* seek back to event's start */
if (!(*description_event= (Format_description_log_event*) if (!(new_description_event= (Format_description_log_event*)
Log_event::read_log_event(file, *description_event))) Log_event::read_log_event(file, *description_event)))
/* EOF can't be hit here normally, so it's a real error */ /* EOF can't be hit here normally, so it's a real error */
{
delete *description_event;
die("Could not read a Format_description_log_event event \ die("Could not read a Format_description_log_event event \
at offset %lu ; this could be a log format error or read error", at offset %lu ; this could be a log format error or read error",
tmp_pos); tmp_pos);
}
delete *description_event;
*description_event= new_description_event;
DBUG_PRINT("info",("Setting description_event")); DBUG_PRINT("info",("Setting description_event"));
} }
else if (buf[4] == ROTATE_EVENT) else if (buf[4] == ROTATE_EVENT)
@ -1362,8 +1402,11 @@ at offset %lu ; this could be a log format error or read error",
my_b_seek(file, tmp_pos); /* seek back to event's start */ my_b_seek(file, tmp_pos); /* seek back to event's start */
if (!(ev= Log_event::read_log_event(file, *description_event))) if (!(ev= Log_event::read_log_event(file, *description_event)))
/* EOF can't be hit here normally, so it's a real error */ /* EOF can't be hit here normally, so it's a real error */
{
delete *description_event;
die("Could not read a Rotate_log_event event at offset %lu ;" die("Could not read a Rotate_log_event event at offset %lu ;"
" this could be a log format error or read error", tmp_pos); " this could be a log format error or read error", tmp_pos);
}
delete ev; delete ev;
} }
else else
@ -1379,7 +1422,7 @@ static int dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
{ {
File fd = -1; File fd = -1;
IO_CACHE cache,*file= &cache; IO_CACHE cache,*file= &cache;
byte tmp_buff[BIN_LOG_HEADER_SIZE]; uchar tmp_buff[BIN_LOG_HEADER_SIZE];
int error= 0; int error= 0;
if (logname && logname[0] != '-') if (logname && logname[0] != '-')
@ -1418,7 +1461,7 @@ static int dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
if (start_position) if (start_position)
{ {
/* skip 'start_position' characters from stdin */ /* skip 'start_position' characters from stdin */
byte buff[IO_SIZE]; uchar buff[IO_SIZE];
my_off_t length,tmp; my_off_t length,tmp;
for (length= start_position_mot ; length > 0 ; length-=tmp) for (length= start_position_mot ; length > 0 ; length-=tmp)
{ {
@ -1433,7 +1476,10 @@ static int dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
} }
if (!glob_description_event || !glob_description_event->is_valid()) if (!glob_description_event || !glob_description_event->is_valid())
{
delete glob_description_event;
die("Invalid Format_description log event; could be out of memory"); die("Invalid Format_description log event; could be out of memory");
}
if (!start_position && my_b_read(file, tmp_buff, BIN_LOG_HEADER_SIZE)) if (!start_position && my_b_read(file, tmp_buff, BIN_LOG_HEADER_SIZE))
{ {
@ -1582,7 +1628,7 @@ int main(int argc, char** argv)
my_free_open_file_info(); my_free_open_file_info();
load_processor.destroy(); load_processor.destroy();
/* We cannot free DBUG, it is used in global destructors after exit(). */ /* We cannot free DBUG, it is used in global destructors after exit(). */
my_end((info_flag ? MY_CHECK_ERROR : 0) | MY_DONT_FREE_DBUG); my_end(my_end_arg | MY_DONT_FREE_DBUG);
if (file_not_closed_error) if (file_not_closed_error)
{ {
@ -1602,17 +1648,9 @@ int main(int argc, char** argv)
the server the server
*/ */
#if defined(__WIN__) && !defined(USING_CMAKE)
#include "my_decimal.h"
#include "decimal.c"
#include "my_decimal.cpp"
#include "log_event.cpp"
#include "log_event_old.cpp"
#else
#include "my_decimal.h" #include "my_decimal.h"
#include "decimal.c" #include "decimal.c"
#include "my_decimal.cc" #include "my_decimal.cc"
#include "log_event.cc" #include "log_event.cc"
#include "log_event_old.cc" #include "log_event_old.cc"
#endif

View File

@ -15,7 +15,7 @@
/* By Jani Tolonen, 2001-04-20, MySQL Development Team */ /* By Jani Tolonen, 2001-04-20, MySQL Development Team */
#define CHECK_VERSION "2.4.5" #define CHECK_VERSION "2.5.0"
#include "client_priv.h" #include "client_priv.h"
#include <m_ctype.h> #include <m_ctype.h>
@ -33,11 +33,12 @@ static my_bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0,
opt_compress = 0, opt_databases = 0, opt_fast = 0, opt_compress = 0, opt_databases = 0, opt_fast = 0,
opt_medium_check = 0, opt_quick = 0, opt_all_in_1 = 0, opt_medium_check = 0, opt_quick = 0, opt_all_in_1 = 0,
opt_silent = 0, opt_auto_repair = 0, ignore_errors = 0, opt_silent = 0, opt_auto_repair = 0, ignore_errors = 0,
tty_password= 0, opt_frm= 0, info_flag= 0, tty_password= 0, opt_frm= 0, debug_info_flag= 0, debug_check_flag= 0,
opt_fix_table_names= 0, opt_fix_db_names= 0, opt_upgrade= 0, opt_fix_table_names= 0, opt_fix_db_names= 0, opt_upgrade= 0,
opt_write_binlog= 1; opt_write_binlog= 1;
static uint verbose = 0, opt_mysql_port=0; static uint verbose = 0, opt_mysql_port=0;
static my_string opt_mysql_unix_port = 0; static int my_end_arg;
static char * opt_mysql_unix_port = 0;
static char *opt_password = 0, *current_user = 0, static char *opt_password = 0, *current_user = 0,
*default_charset = (char *)MYSQL_DEFAULT_CHARSET_NAME, *default_charset = (char *)MYSQL_DEFAULT_CHARSET_NAME,
*current_host = 0; *current_host = 0;
@ -55,13 +56,13 @@ static struct my_option my_long_options[] =
{ {
{"all-databases", 'A', {"all-databases", 'A',
"Check all the databases. This will be same as --databases with all databases selected.", "Check all the databases. This will be same as --databases with all databases selected.",
(gptr*) &opt_alldbs, (gptr*) &opt_alldbs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, (uchar**) &opt_alldbs, (uchar**) &opt_alldbs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
{"analyze", 'a', "Analyze given tables.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, {"analyze", 'a', "Analyze given tables.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
0, 0, 0, 0}, 0, 0, 0, 0},
{"all-in-1", '1', {"all-in-1", '1',
"Instead of issuing one query for each table, use one query per database, naming all tables in the database in a comma-separated list.", "Instead of issuing one query for each table, use one query per database, naming all tables in the database in a comma-separated list.",
(gptr*) &opt_all_in_1, (gptr*) &opt_all_in_1, 0, GET_BOOL, NO_ARG, 0, 0, 0, (uchar**) &opt_all_in_1, (uchar**) &opt_all_in_1, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
#ifdef __NETWARE__ #ifdef __NETWARE__
{"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.",
@ -69,11 +70,11 @@ static struct my_option my_long_options[] =
#endif #endif
{"auto-repair", OPT_AUTO_REPAIR, {"auto-repair", OPT_AUTO_REPAIR,
"If a checked table is corrupted, automatically fix it. Repairing will be done after all tables have been checked, if corrupted ones were found.", "If a checked table is corrupted, automatically fix it. Repairing will be done after all tables have been checked, if corrupted ones were found.",
(gptr*) &opt_auto_repair, (gptr*) &opt_auto_repair, 0, GET_BOOL, NO_ARG, 0, (uchar**) &opt_auto_repair, (uchar**) &opt_auto_repair, 0, GET_BOOL, NO_ARG, 0,
0, 0, 0, 0, 0}, 0, 0, 0, 0, 0},
{"character-sets-dir", OPT_CHARSETS_DIR, {"character-sets-dir", OPT_CHARSETS_DIR,
"Directory where character sets are.", (gptr*) &charsets_dir, "Directory where character sets are.", (uchar**) &charsets_dir,
(gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"check", 'c', "Check table for errors.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, {"check", 'c', "Check table for errors.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
0, 0, 0, 0}, 0, 0, 0, 0},
{"check-only-changed", 'C', {"check-only-changed", 'C',
@ -83,11 +84,11 @@ static struct my_option my_long_options[] =
"Check tables for version-dependent changes. May be used with --auto-repair to correct tables requiring version-dependent updates.", "Check tables for version-dependent changes. May be used with --auto-repair to correct tables requiring version-dependent updates.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"compress", OPT_COMPRESS, "Use compression in server/client protocol.", {"compress", OPT_COMPRESS, "Use compression in server/client protocol.",
(gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
{"databases", 'B', {"databases", 'B',
"To check several databases. Note the difference in usage; In this case no tables are given. All name arguments are regarded as databasenames.", "To check several databases. Note the difference in usage; In this case no tables are given. All name arguments are regarded as databasenames.",
(gptr*) &opt_databases, (gptr*) &opt_databases, 0, GET_BOOL, NO_ARG, (uchar**) &opt_databases, (uchar**) &opt_databases, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
#ifdef DBUG_OFF #ifdef DBUG_OFF
{"debug", '#', "This is a non-debug version. Catch this and exit.", {"debug", '#', "This is a non-debug version. Catch this and exit.",
@ -96,37 +97,41 @@ static struct my_option my_long_options[] =
{"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (gptr*) &info_flag, {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .",
(gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
(uchar**) &debug_info_flag, (uchar**) &debug_info_flag,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"default-character-set", OPT_DEFAULT_CHARSET, {"default-character-set", OPT_DEFAULT_CHARSET,
"Set the default character set.", (gptr*) &default_charset, "Set the default character set.", (uchar**) &default_charset,
(gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"fast",'F', "Check only tables that haven't been closed properly.", {"fast",'F', "Check only tables that haven't been closed properly.",
(gptr*) &opt_fast, (gptr*) &opt_fast, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, (uchar**) &opt_fast, (uchar**) &opt_fast, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
0}, 0},
{"fix-db-names", OPT_FIX_DB_NAMES, "Fix database names.", {"fix-db-names", OPT_FIX_DB_NAMES, "Fix database names.",
(gptr*) &opt_fix_db_names, (gptr*) &opt_fix_db_names, (uchar**) &opt_fix_db_names, (uchar**) &opt_fix_db_names,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"fix-table-names", OPT_FIX_TABLE_NAMES, "Fix table names.", {"fix-table-names", OPT_FIX_TABLE_NAMES, "Fix table names.",
(gptr*) &opt_fix_table_names, (gptr*) &opt_fix_table_names, (uchar**) &opt_fix_table_names, (uchar**) &opt_fix_table_names,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"force", 'f', "Continue even if we get an sql-error.", {"force", 'f', "Continue even if we get an sql-error.",
(gptr*) &ignore_errors, (gptr*) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, (uchar**) &ignore_errors, (uchar**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0,
0, 0, 0, 0}, 0, 0, 0, 0},
{"extended", 'e', {"extended", 'e',
"If you are using this option with CHECK TABLE, it will ensure that the table is 100 percent consistent, but will take a long time. If you are using this option with REPAIR TABLE, it will force using old slow repair with keycache method, instead of much faster repair by sorting.", "If you are using this option with CHECK TABLE, it will ensure that the table is 100 percent consistent, but will take a long time. If you are using this option with REPAIR TABLE, it will force using old slow repair with keycache method, instead of much faster repair by sorting.",
(gptr*) &opt_extended, (gptr*) &opt_extended, 0, GET_BOOL, NO_ARG, 0, 0, 0, (uchar**) &opt_extended, (uchar**) &opt_extended, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
{"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG, {"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"host",'h', "Connect to host.", (gptr*) &current_host, {"host",'h', "Connect to host.", (uchar**) &current_host,
(gptr*) &current_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &current_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"medium-check", 'm', {"medium-check", 'm',
"Faster than extended-check, but only finds 99.99 percent of all errors. Should be good enough for most cases.", "Faster than extended-check, but only finds 99.99 percent of all errors. Should be good enough for most cases.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"write-binlog", OPT_WRITE_BINLOG, {"write-binlog", OPT_WRITE_BINLOG,
"Log ANALYZE, OPTIMIZE and REPAIR TABLE commands. Enabled by default; use --skip-write-binlog when commands should not be sent to replication slaves.", "Log ANALYZE, OPTIMIZE and REPAIR TABLE commands. Enabled by default; use --skip-write-binlog when commands should not be sent to replication slaves.",
(gptr*) &opt_write_binlog, (gptr*) &opt_write_binlog, 0, GET_BOOL, NO_ARG, (uchar**) &opt_write_binlog, (uchar**) &opt_write_binlog, 0, GET_BOOL, NO_ARG,
1, 0, 0, 0, 0, 0}, 1, 0, 0, 0, 0, 0},
{"optimize", 'o', "Optimize table.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, {"optimize", 'o', "Optimize table.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
@ -137,38 +142,38 @@ static struct my_option my_long_options[] =
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, {"port", 'P', "Port number to use for connection.", (uchar**) &opt_mysql_port,
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, (uchar**) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
0}, 0},
{"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"quick", 'q', {"quick", 'q',
"If you are using this option with CHECK TABLE, it prevents the check from scanning the rows to check for wrong links. This is the fastest check. If you are using this option with REPAIR TABLE, it will try to repair only the index tree. This is the fastest repair method for a table.", "If you are using this option with CHECK TABLE, it prevents the check from scanning the rows to check for wrong links. This is the fastest check. If you are using this option with REPAIR TABLE, it will try to repair only the index tree. This is the fastest repair method for a table.",
(gptr*) &opt_quick, (gptr*) &opt_quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, (uchar**) &opt_quick, (uchar**) &opt_quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
0}, 0},
{"repair", 'r', {"repair", 'r',
"Can fix almost anything except unique keys that aren't unique.", "Can fix almost anything except unique keys that aren't unique.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
"Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, "Base name of shared memory.", (uchar**) &shared_memory_base_name, (uchar**) &shared_memory_base_name,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"silent", 's', "Print only error messages.", (gptr*) &opt_silent, {"silent", 's', "Print only error messages.", (uchar**) &opt_silent,
(gptr*) &opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"socket", 'S', "Socket file to use for connection.", {"socket", 'S', "Socket file to use for connection.",
(gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR, (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#include <sslopt-longopts.h> #include <sslopt-longopts.h>
{"tables", OPT_TABLES, "Overrides option --databases (-B).", 0, 0, 0, {"tables", OPT_TABLES, "Overrides option --databases (-B).", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"use-frm", OPT_FRM, {"use-frm", OPT_FRM,
"When used with REPAIR, get table structure from .frm file, so the table can be repaired even if .MYI header is corrupted.", "When used with REPAIR, get table structure from .frm file, so the table can be repaired even if .MYI header is corrupted.",
(gptr*) &opt_frm, (gptr*) &opt_frm, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, (uchar**) &opt_frm, (uchar**) &opt_frm, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
0}, 0},
#ifndef DONT_ALLOW_USER_CHANGE #ifndef DONT_ALLOW_USER_CHANGE
{"user", 'u', "User for login if not current user.", (gptr*) &current_user, {"user", 'u', "User for login if not current user.", (uchar**) &current_user,
(gptr*) &current_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &current_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"verbose", 'v', "Print info about the various stages.", 0, 0, 0, GET_NO_ARG, {"verbose", 'v', "Print info about the various stages.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
@ -305,6 +310,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break; break;
case '#': case '#':
DBUG_PUSH(argument ? argument : "d:t:o"); DBUG_PUSH(argument ? argument : "d:t:o");
debug_check_flag= 1;
break; break;
#include <sslopt-case.h> #include <sslopt-case.h>
case OPT_TABLES: case OPT_TABLES:
@ -375,6 +381,10 @@ static int get_options(int *argc, char ***argv)
} }
if (tty_password) if (tty_password)
opt_password = get_tty_password(NullS); opt_password = get_tty_password(NullS);
if (debug_info_flag)
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
if (debug_check_flag)
my_end_arg= MY_CHECK_ERROR;
return(0); return(0);
} /* get_options */ } /* get_options */
@ -670,7 +680,7 @@ static void print_result()
*/ */
if (found_error && opt_auto_repair && what_to_do != DO_REPAIR && if (found_error && opt_auto_repair && what_to_do != DO_REPAIR &&
strcmp(row[3],"OK")) strcmp(row[3],"OK"))
insert_dynamic(&tables4repair, prev); insert_dynamic(&tables4repair, (uchar*) prev);
found_error=0; found_error=0;
if (opt_silent) if (opt_silent)
continue; continue;
@ -690,7 +700,7 @@ static void print_result()
} }
/* add the last table to be repaired to the list */ /* add the last table to be repaired to the list */
if (found_error && opt_auto_repair && what_to_do != DO_REPAIR) if (found_error && opt_auto_repair && what_to_do != DO_REPAIR)
insert_dynamic(&tables4repair, prev); insert_dynamic(&tables4repair, (uchar*) prev);
mysql_free_result(res); mysql_free_result(res);
} }
@ -765,7 +775,7 @@ int main(int argc, char **argv)
*/ */
if (get_options(&argc, &argv)) if (get_options(&argc, &argv))
{ {
my_end(info_flag ? MY_CHECK_ERROR : 0); my_end(my_end_arg);
exit(EX_USAGE); exit(EX_USAGE);
} }
if (dbConnect(current_host, current_user, opt_password)) if (dbConnect(current_host, current_user, opt_password))
@ -807,6 +817,6 @@ int main(int argc, char **argv)
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
#endif #endif
my_end(info_flag ? MY_CHECK_ERROR : 0); my_end(my_end_arg);
return(first_error!=0); return(first_error!=0);
} /* main */ } /* main */

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@
** * * ** * *
** ************************* ** *************************
*/ */
#define IMPORT_VERSION "3.6" #define IMPORT_VERSION "3.7"
#include "client_priv.h" #include "client_priv.h"
#include "mysql_version.h" #include "mysql_version.h"
@ -49,15 +49,15 @@ static char *add_load_option(char *ptr,const char *object,
static my_bool verbose=0,lock_tables=0,ignore_errors=0,opt_delete=0, static my_bool verbose=0,lock_tables=0,ignore_errors=0,opt_delete=0,
replace=0,silent=0,ignore=0,opt_compress=0, replace=0,silent=0,ignore=0,opt_compress=0,
opt_low_priority= 0, tty_password= 0; opt_low_priority= 0, tty_password= 0;
static my_bool info_flag= 0; static my_bool debug_info_flag= 0, debug_check_flag= 0;
static uint opt_use_threads=0, opt_local_file=0; static uint opt_use_threads=0, opt_local_file=0, my_end_arg= 0;
static char *opt_password=0, *current_user=0, static char *opt_password=0, *current_user=0,
*current_host=0, *current_db=0, *fields_terminated=0, *current_host=0, *current_db=0, *fields_terminated=0,
*lines_terminated=0, *enclosed=0, *opt_enclosed=0, *lines_terminated=0, *enclosed=0, *opt_enclosed=0,
*escaped=0, *opt_columns=0, *escaped=0, *opt_columns=0,
*default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME; *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
static uint opt_mysql_port= 0, opt_protocol= 0; static uint opt_mysql_port= 0, opt_protocol= 0;
static my_string opt_mysql_unix_port=0; static char * opt_mysql_unix_port=0;
static longlong opt_ignore_lines= -1; static longlong opt_ignore_lines= -1;
static CHARSET_INFO *charset_info= &my_charset_latin1; static CHARSET_INFO *charset_info= &my_charset_latin1;
#include <sslopt-vars.h> #include <sslopt-vars.h>
@ -73,59 +73,63 @@ static struct my_option my_long_options[] =
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"character-sets-dir", OPT_CHARSETS_DIR, {"character-sets-dir", OPT_CHARSETS_DIR,
"Directory where character sets are.", (gptr*) &charsets_dir, "Directory where character sets are.", (uchar**) &charsets_dir,
(gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"default-character-set", OPT_DEFAULT_CHARSET, {"default-character-set", OPT_DEFAULT_CHARSET,
"Set the default character set.", (gptr*) &default_charset, "Set the default character set.", (uchar**) &default_charset,
(gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"columns", 'c', {"columns", 'c',
"Use only these columns to import the data to. Give the column names in a comma separated list. This is same as giving columns to LOAD DATA INFILE.", "Use only these columns to import the data to. Give the column names in a comma separated list. This is same as giving columns to LOAD DATA INFILE.",
(gptr*) &opt_columns, (gptr*) &opt_columns, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, (uchar**) &opt_columns, (uchar**) &opt_columns, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
{"compress", 'C', "Use compression in server/client protocol.", {"compress", 'C', "Use compression in server/client protocol.",
(gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
{"debug",'#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, {"debug",'#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0,
GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (gptr*) &info_flag, {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .",
(gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0,
{"delete", 'd', "First delete all rows from table.", (gptr*) &opt_delete, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
(gptr*) &opt_delete, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
(uchar**) &debug_info_flag, (uchar**) &debug_info_flag,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"delete", 'd', "First delete all rows from table.", (uchar**) &opt_delete,
(uchar**) &opt_delete, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"fields-terminated-by", OPT_FTB, {"fields-terminated-by", OPT_FTB,
"Fields in the textfile are terminated by ...", (gptr*) &fields_terminated, "Fields in the textfile are terminated by ...", (uchar**) &fields_terminated,
(gptr*) &fields_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &fields_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"fields-enclosed-by", OPT_ENC, {"fields-enclosed-by", OPT_ENC,
"Fields in the importfile are enclosed by ...", (gptr*) &enclosed, "Fields in the importfile are enclosed by ...", (uchar**) &enclosed,
(gptr*) &enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"fields-optionally-enclosed-by", OPT_O_ENC, {"fields-optionally-enclosed-by", OPT_O_ENC,
"Fields in the i.file are opt. enclosed by ...", (gptr*) &opt_enclosed, "Fields in the i.file are opt. enclosed by ...", (uchar**) &opt_enclosed,
(gptr*) &opt_enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &opt_enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"fields-escaped-by", OPT_ESC, "Fields in the i.file are escaped by ...", {"fields-escaped-by", OPT_ESC, "Fields in the i.file are escaped by ...",
(gptr*) &escaped, (gptr*) &escaped, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, (uchar**) &escaped, (uchar**) &escaped, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
{"force", 'f', "Continue even if we get an sql-error.", {"force", 'f', "Continue even if we get an sql-error.",
(gptr*) &ignore_errors, (gptr*) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, (uchar**) &ignore_errors, (uchar**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0,
0, 0, 0, 0}, 0, 0, 0, 0},
{"help", '?', "Displays this help and exits.", 0, 0, 0, GET_NO_ARG, NO_ARG, {"help", '?', "Displays this help and exits.", 0, 0, 0, GET_NO_ARG, NO_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", (gptr*) &current_host, {"host", 'h', "Connect to host.", (uchar**) &current_host,
(gptr*) &current_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &current_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"ignore", 'i', "If duplicate unique key was found, keep old row.", {"ignore", 'i', "If duplicate unique key was found, keep old row.",
(gptr*) &ignore, (gptr*) &ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &ignore, (uchar**) &ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"ignore-lines", OPT_IGN_LINES, "Ignore first n lines of data infile.", {"ignore-lines", OPT_IGN_LINES, "Ignore first n lines of data infile.",
(gptr*) &opt_ignore_lines, (gptr*) &opt_ignore_lines, 0, GET_LL, (uchar**) &opt_ignore_lines, (uchar**) &opt_ignore_lines, 0, GET_LL,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...", {"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...",
(gptr*) &lines_terminated, (gptr*) &lines_terminated, 0, GET_STR, (uchar**) &lines_terminated, (uchar**) &lines_terminated, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"local", 'L', "Read all files through the client.", (gptr*) &opt_local_file, {"local", 'L', "Read all files through the client.", (uchar**) &opt_local_file,
(gptr*) &opt_local_file, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &opt_local_file, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"lock-tables", 'l', "Lock all tables for write (this disables threads).", {"lock-tables", 'l', "Lock all tables for write (this disables threads).",
(gptr*) &lock_tables, (gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, (uchar**) &lock_tables, (uchar**) &lock_tables, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"low-priority", OPT_LOW_PRIORITY, {"low-priority", OPT_LOW_PRIORITY,
"Use LOW_PRIORITY when updating the table.", (gptr*) &opt_low_priority, "Use LOW_PRIORITY when updating the table.", (uchar**) &opt_low_priority,
(gptr*) &opt_low_priority, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &opt_low_priority, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p', {"password", 'p',
"Password to use when connecting to server. If password is not given it's asked from the tty.", "Password to use when connecting to server. If password is not given it's asked from the tty.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
@ -133,35 +137,35 @@ static struct my_option my_long_options[] =
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, {"port", 'P', "Port number to use for connection.", (uchar**) &opt_mysql_port,
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, (uchar**) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
0}, 0},
{"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"replace", 'r', "If duplicate unique key was found, replace old row.", {"replace", 'r', "If duplicate unique key was found, replace old row.",
(gptr*) &replace, (gptr*) &replace, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &replace, (uchar**) &replace, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
"Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, "Base name of shared memory.", (uchar**) &shared_memory_base_name, (uchar**) &shared_memory_base_name,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"silent", 's', "Be more silent.", (gptr*) &silent, (gptr*) &silent, 0, {"silent", 's', "Be more silent.", (uchar**) &silent, (uchar**) &silent, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"socket", 'S', "Socket file to use for connection.", {"socket", 'S', "Socket file to use for connection.",
(gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR, (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#include <sslopt-longopts.h> #include <sslopt-longopts.h>
{"use-threads", OPT_USE_THREADS, {"use-threads", OPT_USE_THREADS,
"Load files in parallel. The argument is the number " "Load files in parallel. The argument is the number "
"of threads to use for loading data.", "of threads to use for loading data.",
(gptr*) &opt_use_threads, (gptr*) &opt_use_threads, 0, (uchar**) &opt_use_threads, (uchar**) &opt_use_threads, 0,
GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#ifndef DONT_ALLOW_USER_CHANGE #ifndef DONT_ALLOW_USER_CHANGE
{"user", 'u', "User for login if not current user.", (gptr*) &current_user, {"user", 'u', "User for login if not current user.", (uchar**) &current_user,
(gptr*) &current_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &current_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"verbose", 'v', "Print info about the various stages.", (gptr*) &verbose, {"verbose", 'v', "Print info about the various stages.", (uchar**) &verbose,
(gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
@ -236,6 +240,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break; break;
case '#': case '#':
DBUG_PUSH(argument ? argument : "d:t:o"); DBUG_PUSH(argument ? argument : "d:t:o");
debug_check_flag= 1;
break; break;
#include <sslopt-case.h> #include <sslopt-case.h>
case 'V': print_version(); exit(0); case 'V': print_version(); exit(0);
@ -254,6 +259,10 @@ static int get_options(int *argc, char ***argv)
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
if (debug_info_flag)
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
if (debug_check_flag)
my_end_arg= MY_CHECK_ERROR;
if (enclosed && opt_enclosed) if (enclosed && opt_enclosed)
{ {
@ -659,6 +668,6 @@ int main(int argc, char **argv)
my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
#endif #endif
free_defaults(argv_to_free); free_defaults(argv_to_free);
my_end(info_flag ? MY_CHECK_ERROR : 0); my_end(my_end_arg);
return(exitcode); return(exitcode);
} }

View File

@ -15,7 +15,7 @@
/* Show databases, tables or columns */ /* Show databases, tables or columns */
#define SHOW_VERSION "9.6" #define SHOW_VERSION "9.10"
#include "client_priv.h" #include "client_priv.h"
#include <my_sys.h> #include <my_sys.h>
@ -26,9 +26,11 @@
#include <stdarg.h> #include <stdarg.h>
#include <sslopt-vars.h> #include <sslopt-vars.h>
static my_string host=0,opt_password=0,user=0; static char * host=0, *opt_password=0, *user=0;
static my_bool opt_show_keys= 0, opt_compress= 0, opt_count=0, opt_status= 0; static my_bool opt_show_keys= 0, opt_compress= 0, opt_count=0, opt_status= 0;
static my_bool tty_password= 0, opt_table_type= 0, info_flag= 0; static my_bool tty_password= 0, opt_table_type= 0;
static my_bool debug_info_flag= 0, debug_check_flag= 0;
static uint my_end_arg= 0;
static uint opt_verbose=0; static uint opt_verbose=0;
static char *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME; static char *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
@ -52,7 +54,7 @@ static void print_res_top(MYSQL_RES *result);
static void print_res_row(MYSQL_RES *result,MYSQL_ROW cur); static void print_res_row(MYSQL_RES *result,MYSQL_ROW cur);
static const char *load_default_groups[]= { "mysqlshow","client",0 }; static const char *load_default_groups[]= { "mysqlshow","client",0 };
static my_string opt_mysql_unix_port=0; static char * opt_mysql_unix_port=0;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
@ -120,7 +122,8 @@ int main(int argc, char **argv)
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset); mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
if (!(mysql_real_connect(&mysql,host,user,opt_password, if (!(mysql_real_connect(&mysql,host,user,opt_password,
(first_argument_uses_wildcards) ? "" : argv[0],opt_mysql_port,opt_mysql_unix_port, (first_argument_uses_wildcards) ? "" :
argv[0],opt_mysql_port,opt_mysql_unix_port,
0))) 0)))
{ {
fprintf(stderr,"%s: %s\n",my_progname,mysql_error(&mysql)); fprintf(stderr,"%s: %s\n",my_progname,mysql_error(&mysql));
@ -149,7 +152,7 @@ int main(int argc, char **argv)
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
#endif #endif
my_end(info_flag ? MY_CHECK_ERROR : 0); my_end(my_end_arg);
exit(error ? 1 : 0); exit(error ? 1 : 0);
return 0; /* No compiler warnings */ return 0; /* No compiler warnings */
} }
@ -161,36 +164,40 @@ static struct my_option my_long_options[] =
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"character-sets-dir", 'c', "Directory where character sets are.", {"character-sets-dir", 'c', "Directory where character sets are.",
(gptr*) &charsets_dir, (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, (uchar**) &charsets_dir, (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0,
0, 0, 0, 0, 0}, 0, 0, 0, 0, 0},
{"default-character-set", OPT_DEFAULT_CHARSET, {"default-character-set", OPT_DEFAULT_CHARSET,
"Set the default character set.", (gptr*) &default_charset, "Set the default character set.", (uchar**) &default_charset,
(gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"count", OPT_COUNT, {"count", OPT_COUNT,
"Show number of rows per table (may be slow for not MyISAM tables)", "Show number of rows per table (may be slow for not MyISAM tables)",
(gptr*) &opt_count, (gptr*) &opt_count, 0, GET_BOOL, NO_ARG, 0, 0, 0, (uchar**) &opt_count, (uchar**) &opt_count, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
{"compress", 'C', "Use compression in server/client protocol.", {"compress", 'C', "Use compression in server/client protocol.",
(gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
{"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (gptr*) &info_flag, {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .",
(gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
(uchar**) &debug_info_flag, (uchar**) &debug_info_flag,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", (gptr*) &host, (gptr*) &host, 0, GET_STR, {"host", 'h', "Connect to host.", (uchar**) &host, (uchar**) &host, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"status", 'i', "Shows a lot of extra information about each table.", {"status", 'i', "Shows a lot of extra information about each table.",
(gptr*) &opt_status, (gptr*) &opt_status, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, (uchar**) &opt_status, (uchar**) &opt_status, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
{"keys", 'k', "Show keys for table.", (gptr*) &opt_show_keys, {"keys", 'k', "Show keys for table.", (uchar**) &opt_show_keys,
(gptr*) &opt_show_keys, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &opt_show_keys, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p', {"password", 'p',
"Password to use when connecting to server. If password is not given it's asked from the tty.", "Password to use when connecting to server. If password is not given it's asked from the tty.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, {"port", 'P', "Port number to use for connection.", (uchar**) &opt_mysql_port,
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, (uchar**) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
0}, 0},
#ifdef __WIN__ #ifdef __WIN__
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
@ -200,19 +207,19 @@ static struct my_option my_long_options[] =
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
"Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, "Base name of shared memory.", (uchar**) &shared_memory_base_name, (uchar**) &shared_memory_base_name,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"show-table-type", 't', "Show table type column.", {"show-table-type", 't', "Show table type column.",
(gptr*) &opt_table_type, (gptr*) &opt_table_type, 0, GET_BOOL, (uchar**) &opt_table_type, (uchar**) &opt_table_type, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"socket", 'S', "Socket file to use for connection.", {"socket", 'S', "Socket file to use for connection.",
(gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR, (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#include <sslopt-longopts.h> #include <sslopt-longopts.h>
#ifndef DONT_ALLOW_USER_CHANGE #ifndef DONT_ALLOW_USER_CHANGE
{"user", 'u', "User for login if not current user.", (gptr*) &user, {"user", 'u', "User for login if not current user.", (uchar**) &user,
(gptr*) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"verbose", 'v', {"verbose", 'v',
"More verbose output; You can use this multiple times to get even more verbose output.", "More verbose output; You can use this multiple times to get even more verbose output.",
@ -292,6 +299,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break; break;
case '#': case '#':
DBUG_PUSH(argument ? argument : "d:t:o"); DBUG_PUSH(argument ? argument : "d:t:o");
debug_check_flag= 1;
break; break;
#include <sslopt-case.h> #include <sslopt-case.h>
case 'V': case 'V':
@ -325,6 +333,10 @@ get_options(int *argc,char ***argv)
*/ */
opt_verbose= 2; opt_verbose= 2;
} }
if (debug_info_flag)
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
if (debug_check_flag)
my_end_arg= MY_CHECK_ERROR;
return; return;
} }
@ -733,7 +745,7 @@ print_header(const char *header,uint head_length,...)
for (i=0 ; i < length+2 ; i++) for (i=0 ; i < length+2 ; i++)
putchar('-'); putchar('-');
putchar('+'); putchar('+');
if (!(field=va_arg(args,my_string))) if (!(field=va_arg(args,char *)))
break; break;
length=va_arg(args,uint); length=va_arg(args,uint);
} }
@ -757,7 +769,7 @@ print_header(const char *header,uint head_length,...)
for (i=0 ; i < length ; i++) for (i=0 ; i < length ; i++)
putchar(' '); putchar(' ');
putchar('|'); putchar('|');
if (!(field=va_arg(args,my_string))) if (!(field=va_arg(args,char *)))
break; break;
length=va_arg(args,uint); length=va_arg(args,uint);
} }
@ -772,7 +784,7 @@ print_header(const char *header,uint head_length,...)
for (i=0 ; i < length+2 ; i++) for (i=0 ; i < length+2 ; i++)
putchar('-'); putchar('-');
putchar('+'); putchar('+');
if (!(field=va_arg(args,my_string))) if (!(field=va_arg(args,char *)))
break; break;
length=va_arg(args,uint); length=va_arg(args,uint);
} }
@ -798,7 +810,7 @@ print_row(const char *header,uint head_length,...)
field_length=(uint) strlen(field); field_length=(uint) strlen(field);
for (i=field_length ; i <= length ; i++) for (i=field_length ; i <= length ; i++)
putchar(' '); putchar(' ');
if (!(field=va_arg(args,my_string))) if (!(field=va_arg(args,char *)))
break; break;
length=va_arg(args,uint); length=va_arg(args,uint);
} }

View File

@ -35,7 +35,8 @@
Supply your own create and query SQL statements, with 50 clients Supply your own create and query SQL statements, with 50 clients
querying (200 selects for each): querying (200 selects for each):
mysqlslap --create="CREATE TABLE A (a int);INSERT INTO A (23)" \ mysqlslap --delimiter=";" \
--create="CREATE TABLE A (a int);INSERT INTO A VALUES (23)" \
--query="SELECT * FROM A" --concurrency=50 --iterations=200 --query="SELECT * FROM A" --concurrency=50 --iterations=200
Let the program build the query SQL statement with a table of two int Let the program build the query SQL statement with a table of two int
@ -68,7 +69,7 @@ TODO:
*/ */
#define SHOW_VERSION "0.9" #define SLAP_VERSION "1.0"
#define HUGE_STRING_LENGTH 8196 #define HUGE_STRING_LENGTH 8196
#define RAND_STRING_SIZE 126 #define RAND_STRING_SIZE 126
@ -80,6 +81,7 @@ TODO:
#define UPDATE_TYPE_REQUIRES_PREFIX 3 #define UPDATE_TYPE_REQUIRES_PREFIX 3
#define CREATE_TABLE_TYPE 4 #define CREATE_TABLE_TYPE 4
#define SELECT_TYPE_REQUIRES_PREFIX 5 #define SELECT_TYPE_REQUIRES_PREFIX 5
#define DELETE_TYPE_REQUIRES_PREFIX 6
#include "client_priv.h" #include "client_priv.h"
#include <mysqld_error.h> #include <mysqld_error.h>
@ -121,16 +123,16 @@ static char *host= NULL, *opt_password= NULL, *user= NULL,
*user_supplied_pre_statements= NULL, *user_supplied_pre_statements= NULL,
*user_supplied_post_statements= NULL, *user_supplied_post_statements= NULL,
*default_engine= NULL, *default_engine= NULL,
*pre_system= NULL,
*post_system= NULL,
*opt_mysql_unix_port= NULL; *opt_mysql_unix_port= NULL;
const char *delimiter= "\n"; const char *delimiter= "\n";
const char *create_schema_string= "mysqlslap"; const char *create_schema_string= "mysqlslap";
static my_bool opt_preserve; static my_bool opt_preserve= 0, debug_info_flag= 0, debug_check_flag= 0;
static my_bool opt_only_print= FALSE; static my_bool opt_only_print= FALSE;
static my_bool opt_compress= FALSE, tty_password= FALSE, static my_bool opt_compress= FALSE, tty_password= FALSE,
opt_silent= FALSE, opt_silent= FALSE,
auto_generate_sql_autoincrement= FALSE, auto_generate_sql_autoincrement= FALSE,
@ -141,15 +143,18 @@ const char *auto_generate_sql_type= "mixed";
static unsigned long connect_flags= CLIENT_MULTI_RESULTS; static unsigned long connect_flags= CLIENT_MULTI_RESULTS;
static int verbose, delimiter_length; static int verbose, delimiter_length;
static uint commit_rate;
static uint detach_rate;
const char *num_int_cols_opt; const char *num_int_cols_opt;
const char *num_char_cols_opt; const char *num_char_cols_opt;
/* Yes, we do set defaults here */ /* Yes, we do set defaults here */
static unsigned int num_int_cols= 1; static unsigned int num_int_cols= 1;
static unsigned int num_char_cols= 1; static unsigned int num_char_cols= 1;
static unsigned int num_int_cols_index= 0; static unsigned int num_int_cols_index= 0;
static unsigned int num_char_cols_index= 0; static unsigned int num_char_cols_index= 0;
static unsigned int iterations; static unsigned int iterations;
static uint my_end_arg= 0;
static char *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME; static char *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
static ulonglong actual_queries= 0; static ulonglong actual_queries= 0;
static ulonglong auto_actual_queries; static ulonglong auto_actual_queries;
@ -253,6 +258,8 @@ void statement_cleanup(statement *stmt);
void option_cleanup(option_string *stmt); void option_cleanup(option_string *stmt);
void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr); void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr);
static int run_statements(MYSQL *mysql, statement *stmt); static int run_statements(MYSQL *mysql, statement *stmt);
int slap_connect(MYSQL *mysql);
static int run_query(MYSQL *mysql, const char *query, int len);
static const char ALPHANUMERICS[]= static const char ALPHANUMERICS[]=
"0123456789ABCDEFGHIJKLMNOPQRSTWXYZabcdefghijklmnopqrstuvwxyz"; "0123456789ABCDEFGHIJKLMNOPQRSTWXYZabcdefghijklmnopqrstuvwxyz";
@ -387,9 +394,9 @@ int main(int argc, char **argv)
/* now free all the strings we created */ /* now free all the strings we created */
if (opt_password) if (opt_password)
my_free((gptr)opt_password, MYF(0)); my_free(opt_password, MYF(0));
my_free((gptr)concurrency, MYF(0)); my_free(concurrency, MYF(0));
statement_cleanup(create_statements); statement_cleanup(create_statements);
statement_cleanup(query_statements); statement_cleanup(query_statements);
@ -399,10 +406,10 @@ int main(int argc, char **argv)
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
if (shared_memory_base_name) if (shared_memory_base_name)
my_free((gptr)shared_memory_base_name, MYF(MY_ALLOW_ZERO_PTR)); my_free(shared_memory_base_name, MYF(MY_ALLOW_ZERO_PTR));
#endif #endif
free_defaults(defaults_argv); free_defaults(defaults_argv);
my_end(0); my_end(my_end_arg);
return 0; return 0;
} }
@ -450,6 +457,16 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr)
if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary) if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary)
generate_primary_key_list(mysql, eptr); generate_primary_key_list(mysql, eptr);
if (commit_rate)
run_query(mysql, "SET AUTOCOMMIT=0", strlen("SET AUTOCOMMIT=0"));
if (pre_system)
system(pre_system);
/*
Pre statements are always run after all other logic so they can
correct/adjust any item that they want.
*/
if (pre_statements) if (pre_statements)
run_statements(mysql, pre_statements); run_statements(mysql, pre_statements);
@ -458,6 +475,9 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr)
if (post_statements) if (post_statements)
run_statements(mysql, post_statements); run_statements(mysql, post_statements);
if (post_system)
system(post_system);
/* We are finished with this run */ /* We are finished with this run */
if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary) if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary)
drop_primary_key_list(); drop_primary_key_list();
@ -473,7 +493,7 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr)
if (opt_csv_str) if (opt_csv_str)
print_conclusions_csv(&conclusion); print_conclusions_csv(&conclusion);
my_free((gptr)head_sptr, MYF(0)); my_free(head_sptr, MYF(0));
} }
@ -484,94 +504,105 @@ static struct my_option my_long_options[] =
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"auto-generate-sql", 'a', {"auto-generate-sql", 'a',
"Generate SQL where not supplied by file or command line.", "Generate SQL where not supplied by file or command line.",
(gptr*) &auto_generate_sql, (gptr*) &auto_generate_sql, (uchar**) &auto_generate_sql, (uchar**) &auto_generate_sql,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"auto-generate-sql-add-autoincrement", OPT_SLAP_AUTO_GENERATE_ADD_AUTO, {"auto-generate-sql-add-autoincrement", OPT_SLAP_AUTO_GENERATE_ADD_AUTO,
"Add autoincrement to auto-generated tables.", "Add autoincrement to auto-generated tables.",
(gptr*) &auto_generate_sql_autoincrement, (uchar**) &auto_generate_sql_autoincrement,
(gptr*) &auto_generate_sql_autoincrement, (uchar**) &auto_generate_sql_autoincrement,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"auto-generate-sql-execute-number", OPT_SLAP_AUTO_GENERATE_EXECUTE_QUERIES, {"auto-generate-sql-execute-number", OPT_SLAP_AUTO_GENERATE_EXECUTE_QUERIES,
"Set this number to generate a set number of queries to run.\n", "Set this number to generate a set number of queries to run.\n",
(gptr*) &auto_actual_queries, (gptr*) &auto_actual_queries, (uchar**) &auto_actual_queries, (uchar**) &auto_actual_queries,
0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"auto-generate-sql-guid-primary", OPT_SLAP_AUTO_GENERATE_GUID_PRIMARY, {"auto-generate-sql-guid-primary", OPT_SLAP_AUTO_GENERATE_GUID_PRIMARY,
"Add GUID based primary keys to auto-generated tables.", "Add GUID based primary keys to auto-generated tables.",
(gptr*) &auto_generate_sql_guid_primary, (uchar**) &auto_generate_sql_guid_primary,
(gptr*) &auto_generate_sql_guid_primary, (uchar**) &auto_generate_sql_guid_primary,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"auto-generate-sql-load-type", OPT_SLAP_AUTO_GENERATE_SQL_LOAD_TYPE, {"auto-generate-sql-load-type", OPT_SLAP_AUTO_GENERATE_SQL_LOAD_TYPE,
"Load types are mixed, update, write, key, or read. Default is mixed\n", "Load types are mixed, update, write, key, or read. Default is mixed\n",
(gptr*) &auto_generate_sql_type, (gptr*) &auto_generate_sql_type, (uchar**) &auto_generate_sql_type, (uchar**) &auto_generate_sql_type,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"auto-generate-sql-secondary-indexes", {"auto-generate-sql-secondary-indexes",
OPT_SLAP_AUTO_GENERATE_SECONDARY_INDEXES, OPT_SLAP_AUTO_GENERATE_SECONDARY_INDEXES,
"Number of secondary indexes to add auto-generated tables.", "Number of secondary indexes to add auto-generated tables.",
(gptr*) &auto_generate_sql_secondary_indexes, (uchar**) &auto_generate_sql_secondary_indexes,
(gptr*) &auto_generate_sql_secondary_indexes, 0, (uchar**) &auto_generate_sql_secondary_indexes, 0,
GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"auto-generate-sql-unique-query-number", {"auto-generate-sql-unique-query-number",
OPT_SLAP_AUTO_GENERATE_UNIQUE_QUERY_NUM, OPT_SLAP_AUTO_GENERATE_UNIQUE_QUERY_NUM,
"Number of unique queries auto tests", "Number of unique queries auto tests",
(gptr*) &auto_generate_sql_unique_query_number, (uchar**) &auto_generate_sql_unique_query_number,
(gptr*) &auto_generate_sql_unique_query_number, (uchar**) &auto_generate_sql_unique_query_number,
0, GET_ULL, REQUIRED_ARG, 10, 0, 0, 0, 0, 0}, 0, GET_ULL, REQUIRED_ARG, 10, 0, 0, 0, 0, 0},
{"auto-generate-sql-unique-write-number", {"auto-generate-sql-unique-write-number",
OPT_SLAP_AUTO_GENERATE_UNIQUE_WRITE_NUM, OPT_SLAP_AUTO_GENERATE_UNIQUE_WRITE_NUM,
"Number of unique queries for auto-generate-sql-write-number", "Number of unique queries for auto-generate-sql-write-number",
(gptr*) &auto_generate_sql_unique_write_number, (uchar**) &auto_generate_sql_unique_write_number,
(gptr*) &auto_generate_sql_unique_write_number, (uchar**) &auto_generate_sql_unique_write_number,
0, GET_ULL, REQUIRED_ARG, 10, 0, 0, 0, 0, 0}, 0, GET_ULL, REQUIRED_ARG, 10, 0, 0, 0, 0, 0},
{"auto-generate-sql-write-number", OPT_SLAP_AUTO_GENERATE_WRITE_NUM, {"auto-generate-sql-write-number", OPT_SLAP_AUTO_GENERATE_WRITE_NUM,
"Number of rows to insert to used in read and write loads (default is 100).\n", "Number of rows to insert to used in read and write loads (default is 100).\n",
(gptr*) &auto_generate_sql_number, (gptr*) &auto_generate_sql_number, (uchar**) &auto_generate_sql_number, (uchar**) &auto_generate_sql_number,
0, GET_ULL, REQUIRED_ARG, 100, 0, 0, 0, 0, 0}, 0, GET_ULL, REQUIRED_ARG, 100, 0, 0, 0, 0, 0},
{"commit", OPT_SLAP_COMMIT, "Commit records after X number of statements.",
(uchar**) &commit_rate, (uchar**) &commit_rate, 0, GET_UINT, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"compress", 'C', "Use compression in server/client protocol.", {"compress", 'C', "Use compression in server/client protocol.",
(gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
{"concurrency", 'c', "Number of clients to simulate for query to run.", {"concurrency", 'c', "Number of clients to simulate for query to run.",
(gptr*) &concurrency_str, (gptr*) &concurrency_str, 0, GET_STR, (uchar**) &concurrency_str, (uchar**) &concurrency_str, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"create", OPT_SLAP_CREATE_STRING, "File or string to use create tables.", {"create", OPT_SLAP_CREATE_STRING, "File or string to use create tables.",
(gptr*) &create_string, (gptr*) &create_string, 0, GET_STR, REQUIRED_ARG, (uchar**) &create_string, (uchar**) &create_string, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"create-schema", OPT_CREATE_SLAP_SCHEMA, "Schema to run tests in.", {"create-schema", OPT_CREATE_SLAP_SCHEMA, "Schema to run tests in.",
(gptr*) &create_schema_string, (gptr*) &create_schema_string, 0, GET_STR, (uchar**) &create_schema_string, (uchar**) &create_schema_string, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"csv", OPT_SLAP_CSV, {"csv", OPT_SLAP_CSV,
"Generate CSV output to named file or to stdout if no file is named.", "Generate CSV output to named file or to stdout if no file is named.",
(gptr*) &opt_csv_str, (gptr*) &opt_csv_str, 0, GET_STR, (uchar**) &opt_csv_str, (uchar**) &opt_csv_str, 0, GET_STR,
OPT_ARG, 0, 0, 0, 0, 0, 0}, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.",
(gptr*) &default_dbug_option, (gptr*) &default_dbug_option, 0, GET_STR, (uchar**) &default_dbug_option, (uchar**) &default_dbug_option, 0, GET_STR,
OPT_ARG, 0, 0, 0, 0, 0, 0}, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .",
(uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"debug-info", 'T', "Print some debug info at exit.", (uchar**) &debug_info_flag,
(uchar**) &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"delimiter", 'F', {"delimiter", 'F',
"Delimiter to use in SQL statements supplied in file or command line.", "Delimiter to use in SQL statements supplied in file or command line.",
(gptr*) &delimiter, (gptr*) &delimiter, 0, GET_STR, REQUIRED_ARG, (uchar**) &delimiter, (uchar**) &delimiter, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"detach", OPT_SLAP_DETACH, "Detach connections after X number of requests.",
(uchar**) &detach_rate, (uchar**) &detach_rate, 0, GET_UINT, REQUIRED_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"engine", 'e', "Storage engine to use for creating the table.", {"engine", 'e', "Storage engine to use for creating the table.",
(gptr*) &default_engine, (gptr*) &default_engine, 0, (uchar**) &default_engine, (uchar**) &default_engine, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", (gptr*) &host, (gptr*) &host, 0, GET_STR, {"host", 'h', "Connect to host.", (uchar**) &host, (uchar**) &host, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"iterations", 'i', "Number of times too run the tests.", (gptr*) &iterations, {"iterations", 'i', "Number of times to run the tests.", (uchar**) &iterations,
(gptr*) &iterations, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0}, (uchar**) &iterations, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0},
{"number-char-cols", 'x', {"number-char-cols", 'x',
"Number of VARCHAR columns to create table with if specifying --auto-generate-sql ", "Number of VARCHAR columns to create table with if specifying --auto-generate-sql ",
(gptr*) &num_char_cols_opt, (gptr*) &num_char_cols_opt, 0, GET_STR, REQUIRED_ARG, (uchar**) &num_char_cols_opt, (uchar**) &num_char_cols_opt, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"number-int-cols", 'y', {"number-int-cols", 'y',
"Number of INT columns to create table with if specifying --auto-generate-sql.", "Number of INT columns to create table with if specifying --auto-generate-sql.",
(gptr*) &num_int_cols_opt, (gptr*) &num_int_cols_opt, 0, GET_STR, REQUIRED_ARG, (uchar**) &num_int_cols_opt, (uchar**) &num_int_cols_opt, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"number-of-queries", OPT_MYSQL_NUMBER_OF_QUERY, {"number-of-queries", OPT_MYSQL_NUMBER_OF_QUERY,
"Limit each client to this number of queries (this is not exact).", "Limit each client to this number of queries (this is not exact).",
(gptr*) &num_of_query, (gptr*) &num_of_query, 0, (uchar**) &num_of_query, (uchar**) &num_of_query, 0,
GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"only-print", OPT_MYSQL_ONLY_PRINT, {"only-print", OPT_MYSQL_ONLY_PRINT,
"This causes mysqlslap to not connect to the databases, but instead print " "This causes mysqlslap to not connect to the databases, but instead print "
"out what it would have done instead.", "out what it would have done instead.",
(gptr*) &opt_only_print, (gptr*) &opt_only_print, 0, GET_BOOL, NO_ARG, (uchar**) &opt_only_print, (uchar**) &opt_only_print, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"password", 'p', {"password", 'p',
"Password to use when connecting to server. If password is not given it's " "Password to use when connecting to server. If password is not given it's "
@ -580,50 +611,60 @@ static struct my_option my_long_options[] =
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, {"port", 'P', "Port number to use for connection.", (uchar**) &opt_mysql_port,
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, (uchar**) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
0}, 0},
{"post-query", OPT_SLAP_POST_QUERY, {"post-query", OPT_SLAP_POST_QUERY,
"Query to run or file containing query to run after executing.", "Query to run or file containing query to run after executing.",
(gptr*) &user_supplied_post_statements, (uchar**) &user_supplied_post_statements,
(gptr*) &user_supplied_post_statements, (uchar**) &user_supplied_post_statements,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"post-system", OPT_SLAP_POST_SYSTEM,
"System() string to run after the load has completed.",
(uchar**) &post_system,
(uchar**) &post_system,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"pre-query", OPT_SLAP_PRE_QUERY, {"pre-query", OPT_SLAP_PRE_QUERY,
"Query to run or file containing query to run before executing.", "Query to run or file containing query to run before executing.",
(gptr*) &user_supplied_pre_statements, (uchar**) &user_supplied_pre_statements,
(gptr*) &user_supplied_pre_statements, (uchar**) &user_supplied_pre_statements,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"pre-system", OPT_SLAP_PRE_SYSTEM,
"System() string to before load has completed.",
(uchar**) &pre_system,
(uchar**) &pre_system,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"preserve-schema", OPT_MYSQL_PRESERVE_SCHEMA, {"preserve-schema", OPT_MYSQL_PRESERVE_SCHEMA,
"Preserve the schema from the mysqlslap run, this happens unless " "Preserve the schema from the mysqlslap run, this happens unless "
"--auto-generate-sql or --create are used.", "--auto-generate-sql or --create are used.",
(gptr*) &opt_preserve, (gptr*) &opt_preserve, 0, GET_BOOL, (uchar**) &opt_preserve, (uchar**) &opt_preserve, 0, GET_BOOL,
NO_ARG, TRUE, 0, 0, 0, 0, 0}, NO_ARG, TRUE, 0, 0, 0, 0, 0},
{"protocol", OPT_MYSQL_PROTOCOL, {"protocol", OPT_MYSQL_PROTOCOL,
"The protocol of connection (tcp,socket,pipe,memory).", "The protocol of connection (tcp,socket,pipe,memory).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"query", 'q', "Query to run or file containing query to run.", {"query", 'q', "Query to run or file containing query to run.",
(gptr*) &user_supplied_query, (gptr*) &user_supplied_query, (uchar**) &user_supplied_query, (uchar**) &user_supplied_query,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
"Base name of shared memory.", (gptr*) &shared_memory_base_name, "Base name of shared memory.", (uchar**) &shared_memory_base_name,
(gptr*) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, (uchar**) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
#endif #endif
{"silent", 's', "Run program in silent mode - no output.", {"silent", 's', "Run program in silent mode - no output.",
(gptr*) &opt_silent, (gptr*) &opt_silent, 0, GET_BOOL, NO_ARG, (uchar**) &opt_silent, (uchar**) &opt_silent, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"socket", 'S', "Socket file to use for connection.", {"socket", 'S', "Socket file to use for connection.",
(gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR, (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#include <sslopt-longopts.h> #include <sslopt-longopts.h>
#ifndef DONT_ALLOW_USER_CHANGE #ifndef DONT_ALLOW_USER_CHANGE
{"user", 'u', "User for login if not current user.", (gptr*) &user, {"user", 'u', "User for login if not current user.", (uchar**) &user,
(gptr*) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"verbose", 'v', {"verbose", 'v',
"More verbose output; You can use this multiple times to get even more " "More verbose output; You can use this multiple times to get even more "
"verbose output.", (gptr*) &verbose, (gptr*) &verbose, 0, "verbose output.", (uchar**) &verbose, (uchar**) &verbose, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
@ -635,7 +676,7 @@ static struct my_option my_long_options[] =
static void print_version(void) static void print_version(void)
{ {
printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,SHOW_VERSION, printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname, SLAP_VERSION,
MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
} }
@ -673,7 +714,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
if (argument) if (argument)
{ {
char *start= argument; char *start= argument;
my_free((gptr)opt_password, MYF(MY_ALLOW_ZERO_PTR)); my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
opt_password= my_strdup(argument,MYF(MY_FAE)); opt_password= my_strdup(argument,MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */ while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start) if (*start)
@ -694,6 +735,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break; break;
case '#': case '#':
DBUG_PUSH(argument ? argument : default_dbug_option); DBUG_PUSH(argument ? argument : default_dbug_option);
debug_check_flag= 1;
break; break;
#include <sslopt-case.h> #include <sslopt-case.h>
case 'V': case 'V':
@ -1089,6 +1131,10 @@ get_options(int *argc,char ***argv)
DBUG_ENTER("get_options"); DBUG_ENTER("get_options");
if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option))) if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
if (debug_info_flag)
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
if (debug_check_flag)
my_end_arg= MY_CHECK_ERROR;
if (!user) if (!user)
user= (char *)"root"; user= (char *)"root";
@ -1308,11 +1354,11 @@ get_options(int *argc,char ***argv)
} }
tmp_string= (char *)my_malloc(sbuf.st_size + 1, tmp_string= (char *)my_malloc(sbuf.st_size + 1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME)); MYF(MY_ZEROFILL|MY_FAE|MY_WME));
my_read(data_file, tmp_string, sbuf.st_size, MYF(0)); my_read(data_file, (uchar*) tmp_string, sbuf.st_size, MYF(0));
tmp_string[sbuf.st_size]= '\0'; tmp_string[sbuf.st_size]= '\0';
my_close(data_file,MYF(0)); my_close(data_file,MYF(0));
parse_delimiter(tmp_string, &create_statements, delimiter[0]); parse_delimiter(tmp_string, &create_statements, delimiter[0]);
my_free((gptr)tmp_string, MYF(0)); my_free(tmp_string, MYF(0));
} }
else if (create_string) else if (create_string)
{ {
@ -1335,13 +1381,13 @@ get_options(int *argc,char ***argv)
} }
tmp_string= (char *)my_malloc(sbuf.st_size + 1, tmp_string= (char *)my_malloc(sbuf.st_size + 1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME)); MYF(MY_ZEROFILL|MY_FAE|MY_WME));
my_read(data_file, tmp_string, sbuf.st_size, MYF(0)); my_read(data_file, (uchar*) tmp_string, sbuf.st_size, MYF(0));
tmp_string[sbuf.st_size]= '\0'; tmp_string[sbuf.st_size]= '\0';
my_close(data_file,MYF(0)); my_close(data_file,MYF(0));
if (user_supplied_query) if (user_supplied_query)
actual_queries= parse_delimiter(tmp_string, &query_statements, actual_queries= parse_delimiter(tmp_string, &query_statements,
delimiter[0]); delimiter[0]);
my_free((gptr)tmp_string, MYF(0)); my_free(tmp_string, MYF(0));
} }
else if (user_supplied_query) else if (user_supplied_query)
{ {
@ -1366,18 +1412,19 @@ get_options(int *argc,char ***argv)
} }
tmp_string= (char *)my_malloc(sbuf.st_size + 1, tmp_string= (char *)my_malloc(sbuf.st_size + 1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME)); MYF(MY_ZEROFILL|MY_FAE|MY_WME));
my_read(data_file, tmp_string, sbuf.st_size, MYF(0)); my_read(data_file, (uchar*) tmp_string, sbuf.st_size, MYF(0));
tmp_string[sbuf.st_size]= '\0'; tmp_string[sbuf.st_size]= '\0';
my_close(data_file,MYF(0)); my_close(data_file,MYF(0));
if (user_supplied_pre_statements) if (user_supplied_pre_statements)
actual_queries= parse_delimiter(tmp_string, &pre_statements, (void)parse_delimiter(tmp_string, &pre_statements,
delimiter[0]); delimiter[0]);
my_free((gptr)tmp_string, MYF(0)); my_free(tmp_string, MYF(0));
} }
else if (user_supplied_pre_statements) else if (user_supplied_pre_statements)
{ {
actual_queries= parse_delimiter(user_supplied_pre_statements, &pre_statements, (void)parse_delimiter(user_supplied_pre_statements,
delimiter[0]); &pre_statements,
delimiter[0]);
} }
if (user_supplied_post_statements && my_stat(user_supplied_post_statements, &sbuf, MYF(0))) if (user_supplied_post_statements && my_stat(user_supplied_post_statements, &sbuf, MYF(0)))
@ -1396,18 +1443,18 @@ get_options(int *argc,char ***argv)
} }
tmp_string= (char *)my_malloc(sbuf.st_size + 1, tmp_string= (char *)my_malloc(sbuf.st_size + 1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME)); MYF(MY_ZEROFILL|MY_FAE|MY_WME));
my_read(data_file, tmp_string, sbuf.st_size, MYF(0)); my_read(data_file, (uchar*) tmp_string, sbuf.st_size, MYF(0));
tmp_string[sbuf.st_size]= '\0'; tmp_string[sbuf.st_size]= '\0';
my_close(data_file,MYF(0)); my_close(data_file,MYF(0));
if (user_supplied_post_statements) if (user_supplied_post_statements)
parse_delimiter(tmp_string, &post_statements, (void)parse_delimiter(tmp_string, &post_statements,
delimiter[0]); delimiter[0]);
my_free((gptr)tmp_string, MYF(0)); my_free(tmp_string, MYF(0));
} }
else if (user_supplied_post_statements) else if (user_supplied_post_statements)
{ {
parse_delimiter(user_supplied_post_statements, &post_statements, (void)parse_delimiter(user_supplied_post_statements, &post_statements,
delimiter[0]); delimiter[0]);
} }
if (verbose >= 2) if (verbose >= 2)
@ -1499,9 +1546,9 @@ drop_primary_key_list(void)
if (primary_keys_number_of) if (primary_keys_number_of)
{ {
for (counter= 0; counter < primary_keys_number_of; counter++) for (counter= 0; counter < primary_keys_number_of; counter++)
my_free((gptr)primary_keys[counter], MYF(0)); my_free(primary_keys[counter], MYF(0));
my_free((gptr)primary_keys, MYF(0)); my_free(primary_keys, MYF(0));
} }
return 0; return 0;
@ -1626,6 +1673,7 @@ static int
run_statements(MYSQL *mysql, statement *stmt) run_statements(MYSQL *mysql, statement *stmt)
{ {
statement *ptr; statement *ptr;
MYSQL_RES *result;
DBUG_ENTER("run_statements"); DBUG_ENTER("run_statements");
for (ptr= stmt; ptr && ptr->length; ptr= ptr->next) for (ptr= stmt; ptr && ptr->length; ptr= ptr->next)
@ -1636,6 +1684,11 @@ run_statements(MYSQL *mysql, statement *stmt)
my_progname, (uint)ptr->length, ptr->string, mysql_error(mysql)); my_progname, (uint)ptr->length, ptr->string, mysql_error(mysql));
exit(1); exit(1);
} }
if (mysql_field_count(mysql))
{
result= mysql_store_result(mysql);
mysql_free_result(result);
}
} }
DBUG_RETURN(0); DBUG_RETURN(0);
@ -1713,6 +1766,7 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
pthread_handler_t run_task(void *p) pthread_handler_t run_task(void *p)
{ {
ulonglong counter= 0, queries; ulonglong counter= 0, queries;
ulonglong trans_counter;
MYSQL *mysql; MYSQL *mysql;
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row; MYSQL_ROW row;
@ -1747,38 +1801,35 @@ pthread_handler_t run_task(void *p)
if (!opt_only_print) if (!opt_only_print)
{ {
/* Connect to server */ if (slap_connect(mysql))
static ulong connection_retry_sleep= 100000; /* Microseconds */
int i, connect_error= 1;
for (i= 0; i < 10; i++)
{
if (mysql_real_connect(mysql, host, user, opt_password,
create_schema_string,
opt_mysql_port,
opt_mysql_unix_port,
connect_flags))
{
/* Connect suceeded */
connect_error= 0;
break;
}
my_sleep(connection_retry_sleep);
}
if (connect_error)
{
fprintf(stderr,"%s: Error when connecting to server: %d %s\n",
my_progname, mysql_errno(mysql), mysql_error(mysql));
goto end; goto end;
}
} }
DBUG_PRINT("info", ("connected.")); DBUG_PRINT("info", ("connected."));
if (verbose >= 3) if (verbose >= 3)
printf("connected!\n"); printf("connected!\n");
queries= 0; queries= 0;
limit_not_met: limit_not_met:
for (ptr= con->stmt; ptr && ptr->length; ptr= ptr->next) for (ptr= con->stmt, trans_counter= 0;
ptr && ptr->length;
ptr= ptr->next, trans_counter++)
{ {
if (!opt_only_print && detach_rate && !(trans_counter % detach_rate))
{
mysql_close(mysql);
if (!(mysql= mysql_init(NULL)))
{
fprintf(stderr,"%s: mysql_init() failed ERROR : %s\n",
my_progname, mysql_error(mysql));
exit(0);
}
if (slap_connect(mysql))
goto end;
}
/* /*
We have to execute differently based on query type. This should become a function. We have to execute differently based on query type. This should become a function.
*/ */
@ -1835,6 +1886,9 @@ limit_not_met:
} }
queries++; queries++;
if (commit_rate && commit_rate <= trans_counter)
run_query(mysql, "COMMIT", strlen("COMMIT"));
if (con->limit && queries == con->limit) if (con->limit && queries == con->limit)
goto end; goto end;
} }
@ -1843,6 +1897,8 @@ limit_not_met:
goto limit_not_met; goto limit_not_met;
end: end:
if (commit_rate)
run_query(mysql, "COMMIT", strlen("COMMIT"));
if (!opt_only_print) if (!opt_only_print)
mysql_close(mysql); mysql_close(mysql);
@ -1959,7 +2015,6 @@ parse_delimiter(const char *script, statement **stmt, char delm)
ptr+= retstr - ptr + 1; ptr+= retstr - ptr + 1;
if (isspace(*ptr)) if (isspace(*ptr))
ptr++; ptr++;
count++;
} }
if (ptr != script+length) if (ptr != script+length)
@ -2033,7 +2088,7 @@ print_conclusions_csv(conclusions *con)
con->users, /* Children used */ con->users, /* Children used */
con->avg_rows /* Queries run */ con->avg_rows /* Queries run */
); );
my_write(csv_file, buffer, (uint)strlen(buffer), MYF(0)); my_write(csv_file, (uchar*) buffer, (uint)strlen(buffer), MYF(0));
} }
void void
@ -2080,10 +2135,10 @@ option_cleanup(option_string *stmt)
{ {
nptr= ptr->next; nptr= ptr->next;
if (ptr->string) if (ptr->string)
my_free((gptr)ptr->string, MYF(0)); my_free(ptr->string, MYF(0));
if (ptr->option) if (ptr->option)
my_free((gptr)ptr->option, MYF(0)); my_free(ptr->option, MYF(0));
my_free((gptr)(byte *)ptr, MYF(0)); my_free(ptr, MYF(0));
} }
} }
@ -2098,7 +2153,38 @@ statement_cleanup(statement *stmt)
{ {
nptr= ptr->next; nptr= ptr->next;
if (ptr->string) if (ptr->string)
my_free((gptr)ptr->string, MYF(0)); my_free(ptr->string, MYF(0));
my_free((gptr)(byte *)ptr, MYF(0)); my_free(ptr, MYF(0));
} }
} }
int
slap_connect(MYSQL *mysql)
{
/* Connect to server */
static ulong connection_retry_sleep= 100000; /* Microseconds */
int x, connect_error= 1;
for (x= 0; x < 10; x++)
{
if (mysql_real_connect(mysql, host, user, opt_password,
create_schema_string,
opt_mysql_port,
opt_mysql_unix_port,
connect_flags))
{
/* Connect suceeded */
connect_error= 0;
break;
}
my_sleep(connection_retry_sleep);
}
if (connect_error)
{
fprintf(stderr,"%s: Error when connecting to server: %d %s\n",
my_progname, mysql_errno(mysql), mysql_error(mysql));
return 1;
}
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -22,8 +22,8 @@
static bool init_line_buffer(LINE_BUFFER *buffer,File file,ulong size, static bool init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,
ulong max_size); ulong max_size);
static bool init_line_buffer_from_string(LINE_BUFFER *buffer,my_string str); static bool init_line_buffer_from_string(LINE_BUFFER *buffer,char * str);
static uint fill_buffer(LINE_BUFFER *buffer); static size_t fill_buffer(LINE_BUFFER *buffer);
static char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length); static char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length);
@ -35,7 +35,7 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
return 0; return 0;
if (init_line_buffer(line_buff,fileno(file),IO_SIZE,max_size)) if (init_line_buffer(line_buff,fileno(file),IO_SIZE,max_size))
{ {
my_free((char*) line_buff,MYF(0)); my_free(line_buff,MYF(0));
return 0; return 0;
} }
return line_buff; return line_buff;
@ -62,13 +62,13 @@ void batch_readline_end(LINE_BUFFER *line_buff)
{ {
if (line_buff) if (line_buff)
{ {
my_free((gptr) line_buff->buffer,MYF(MY_ALLOW_ZERO_PTR)); my_free(line_buff->buffer,MYF(MY_ALLOW_ZERO_PTR));
my_free((char*) line_buff,MYF(0)); my_free(line_buff,MYF(0));
} }
} }
LINE_BUFFER *batch_readline_command(LINE_BUFFER *line_buff, my_string str) LINE_BUFFER *batch_readline_command(LINE_BUFFER *line_buff, char * str)
{ {
if (!line_buff) if (!line_buff)
if (!(line_buff=(LINE_BUFFER*) if (!(line_buff=(LINE_BUFFER*)
@ -76,7 +76,7 @@ LINE_BUFFER *batch_readline_command(LINE_BUFFER *line_buff, my_string str)
return 0; return 0;
if (init_line_buffer_from_string(line_buff,str)) if (init_line_buffer_from_string(line_buff,str))
{ {
my_free((char*) line_buff,MYF(0)); my_free(line_buff,MYF(0));
return 0; return 0;
} }
return line_buff; return line_buff;
@ -106,13 +106,13 @@ init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,ulong max_buffer)
several times. the resulting buffer will contain a several times. the resulting buffer will contain a
concatenation of all strings separated by spaces concatenation of all strings separated by spaces
*/ */
static bool init_line_buffer_from_string(LINE_BUFFER *buffer,my_string str) static bool init_line_buffer_from_string(LINE_BUFFER *buffer,char * str)
{ {
uint old_length=(uint)(buffer->end - buffer->buffer); uint old_length=(uint)(buffer->end - buffer->buffer);
uint length= (uint) strlen(str); uint length= (uint) strlen(str);
if (!(buffer->buffer= buffer->start_of_line= buffer->end_of_line= if (!(buffer->buffer= buffer->start_of_line= buffer->end_of_line=
(char*)my_realloc(buffer->buffer, old_length+length+2, (char*) my_realloc((uchar*) buffer->buffer, old_length+length+2,
MYF(MY_FAE|MY_ALLOW_ZERO_PTR)))) MYF(MY_FAE|MY_ALLOW_ZERO_PTR))))
return 1; return 1;
buffer->end= buffer->buffer + old_length; buffer->end= buffer->buffer + old_length;
if (old_length) if (old_length)
@ -133,9 +133,9 @@ static bool init_line_buffer_from_string(LINE_BUFFER *buffer,my_string str)
bytes read from disk. bytes read from disk.
*/ */
static uint fill_buffer(LINE_BUFFER *buffer) static size_t fill_buffer(LINE_BUFFER *buffer)
{ {
uint read_count; size_t read_count;
uint bufbytes= (uint) (buffer->end - buffer->start_of_line); uint bufbytes= (uint) (buffer->end - buffer->start_of_line);
if (buffer->eof) if (buffer->eof)
@ -166,11 +166,11 @@ static uint fill_buffer(LINE_BUFFER *buffer)
} }
/* Read in new stuff. */ /* Read in new stuff. */
if ((read_count= my_read(buffer->file, (byte*) buffer->end, read_count, if ((read_count= my_read(buffer->file, (uchar*) buffer->end, read_count,
MYF(MY_WME))) == MY_FILE_ERROR) MYF(MY_WME))) == MY_FILE_ERROR)
return read_count; return (size_t) -1;
DBUG_PRINT("fill_buff", ("Got %d bytes", read_count)); DBUG_PRINT("fill_buff", ("Got %lu bytes", (ulong) read_count));
/* Kludge to pretend every nonempty file ends with a newline. */ /* Kludge to pretend every nonempty file ends with a newline. */
if (!read_count && bufbytes && buffer->end[-1] != '\n') if (!read_count && bufbytes && buffer->end[-1] != '\n')
@ -189,7 +189,7 @@ static uint fill_buffer(LINE_BUFFER *buffer)
char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length) char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length)
{ {
char *pos; char *pos;
uint length; size_t length;
DBUG_ENTER("intern_read_line"); DBUG_ENTER("intern_read_line");
buffer->start_of_line=buffer->end_of_line; buffer->start_of_line=buffer->end_of_line;
@ -202,7 +202,7 @@ char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length)
{ {
if ((uint) (pos - buffer->start_of_line) < buffer->max_size) if ((uint) (pos - buffer->start_of_line) < buffer->max_size)
{ {
if (!(length=fill_buffer(buffer)) || length == (uint) -1) if (!(length=fill_buffer(buffer)) || length == (size_t) -1)
DBUG_RETURN(0); DBUG_RETURN(0);
continue; continue;
} }

View File

@ -32,7 +32,7 @@
required by the string function required by the string function
*/ */
extern gptr sql_alloc(unsigned size); extern void sql_alloc(size_t size);
extern void sql_element_free(void *ptr); extern void sql_element_free(void *ptr);
#include "sql_string.h" #include "sql_string.h"
@ -506,7 +506,7 @@ bool String::append(FILE* file, uint32 arg_length, myf my_flags)
{ {
if (realloc(str_length+arg_length)) if (realloc(str_length+arg_length))
return TRUE; return TRUE;
if (my_fread(file, (byte*) Ptr + str_length, arg_length, my_flags)) if (my_fread(file, (uchar*) Ptr + str_length, arg_length, my_flags))
{ {
shrink(str_length); shrink(str_length);
return TRUE; return TRUE;
@ -520,7 +520,7 @@ bool String::append(IO_CACHE* file, uint32 arg_length)
{ {
if (realloc(str_length+arg_length)) if (realloc(str_length+arg_length))
return TRUE; return TRUE;
if (my_b_read(file, (byte*) Ptr + str_length, arg_length)) if (my_b_read(file, (uchar*) Ptr + str_length, arg_length))
{ {
shrink(str_length); shrink(str_length);
return TRUE; return TRUE;
@ -645,7 +645,7 @@ bool String::replace(uint32 offset,uint32 arg_length,
{ {
if (realloc(str_length+(uint32) diff)) if (realloc(str_length+(uint32) diff))
return TRUE; return TRUE;
bmove_upp(Ptr+str_length+diff,Ptr+str_length, bmove_upp((uchar*) Ptr+str_length+diff, (uchar*) Ptr+str_length,
str_length-offset-arg_length); str_length-offset-arg_length);
} }
if (to_length) if (to_length)
@ -805,10 +805,8 @@ copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
const uchar *from_end= (const uchar*) from+from_length; const uchar *from_end= (const uchar*) from+from_length;
char *to_start= to; char *to_start= to;
uchar *to_end= (uchar*) to+to_length; uchar *to_end= (uchar*) to+to_length;
int (*mb_wc)(struct charset_info_st *, my_wc_t *, const uchar *, my_charset_conv_mb_wc mb_wc= from_cs->cset->mb_wc;
const uchar *) = from_cs->cset->mb_wc; my_charset_conv_wc_mb wc_mb= to_cs->cset->wc_mb;
int (*wc_mb)(struct charset_info_st *, my_wc_t, uchar *s, uchar *e)=
to_cs->cset->wc_mb;
uint error_count= 0; uint error_count= 0;
while (1) while (1)

View File

@ -5,8 +5,8 @@
ASRC = $(srcdir)/vi.c $(srcdir)/emacs.c $(srcdir)/common.c ASRC = $(srcdir)/vi.c $(srcdir)/emacs.c $(srcdir)/common.c
AHDR = vi.h emacs.h common.h AHDR = vi.h emacs.h common.h
INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ # Make sure to include stuff from this directory first, to get right "config.h"
-I$(srcdir)/../.. -I.. INCLUDES = -I. -I$(top_builddir)/include -I$(top_srcdir)/include
noinst_LIBRARIES = libedit.a noinst_LIBRARIES = libedit.a
@ -21,9 +21,9 @@ EXTRA_libedit_a_SOURCES = np/unvis.c np/strlcpy.c np/vis.c np/strlcat.c \
libedit_a_LIBADD = @LIBEDIT_LOBJECTS@ libedit_a_LIBADD = @LIBEDIT_LOBJECTS@
libedit_a_DEPENDENCIES = @LIBEDIT_LOBJECTS@ libedit_a_DEPENDENCIES = @LIBEDIT_LOBJECTS@
pkginclude_HEADERS = readline/readline.h noinst_HEADERS = readline/readline.h \
\
noinst_HEADERS = chared.h el.h el_term.h histedit.h key.h parse.h refresh.h sig.h \ chared.h el.h el_term.h histedit.h key.h parse.h refresh.h sig.h \
sys.h tokenizer.h config.h hist.h map.h prompt.h read.h \ sys.h tokenizer.h config.h hist.h map.h prompt.h read.h \
search.h tty.h libedit_term.h vis.h search.h tty.h libedit_term.h vis.h

View File

@ -90,6 +90,16 @@ extern char* tgoto(const char*, int, int);
extern char* tgetstr(char*, char**); extern char* tgetstr(char*, char**);
#endif #endif
#if !HAVE_DECL_TGOTO
/*
'tgoto' is not declared in the system header files, this causes
problems on 64-bit systems. The function returns a 64 bit pointer
but caller see it as "int" and it's thus truncated to 32-bit
*/
extern char* tgoto(const char*, int, int);
#endif
protected void term_move_to_line(EditLine *, int); protected void term_move_to_line(EditLine *, int);
protected void term_move_to_char(EditLine *, int); protected void term_move_to_char(EditLine *, int);
protected void term_clear_EOL(EditLine *, int); protected void term_clear_EOL(EditLine *, int);

View File

@ -20,11 +20,11 @@ libreadline_a_SOURCES = readline.c funmap.c keymaps.c \
shell.c tilde.c misc.c text.c mbutil.c \ shell.c tilde.c misc.c text.c mbutil.c \
compat.c savestring.c compat.c savestring.c
pkginclude_HEADERS = readline.h chardefs.h keymaps.h \ noinst_HEADERS = readline.h chardefs.h keymaps.h \
history.h tilde.h rlmbutil.h rltypedefs.h rlprivate.h \ history.h tilde.h rlmbutil.h rltypedefs.h rlprivate.h \
rlshell.h xmalloc.h rlshell.h xmalloc.h \
\
noinst_HEADERS = config_readline.h rldefs.h histlib.h rlwinsize.h \ config_readline.h rldefs.h histlib.h rlwinsize.h \
posixstat.h posixdir.h posixjmp.h \ posixstat.h posixdir.h posixjmp.h \
tilde.h rlconf.h rltty.h ansi_stdlib.h \ tilde.h rlconf.h rltty.h ansi_stdlib.h \
tcap.h rlstdc.h tcap.h rlstdc.h

View File

@ -139,8 +139,7 @@ static int ksrflow;
/* Dummy call to force a backgrounded readline to stop before it tries /* Dummy call to force a backgrounded readline to stop before it tries
to get the tty settings. */ to get the tty settings. */
static void static void
set_winsize (tty) set_winsize (int tty __attribute__((unused)))
int tty;
{ {
#if defined (TIOCGWINSZ) #if defined (TIOCGWINSZ)
struct winsize w; struct winsize w;

View File

@ -7,7 +7,7 @@ AC_DEFUN([AC_SYS_COMPILER_FLAG],
AC_CACHE_VAL(mysql_cv_option_$2, AC_CACHE_VAL(mysql_cv_option_$2,
[ [
CFLAGS="[$]OLD_CFLAGS $1" CFLAGS="[$]OLD_CFLAGS $1"
AC_TRY_RUN([int main(){exit(0);}],mysql_cv_option_$2=yes,mysql_cv_option_$2=no,mysql_cv_option_$2=no) AC_TRY_LINK([int main(){exit(0);}],mysql_cv_option_$2=yes,mysql_cv_option_$2=no,mysql_cv_option_$2=no)
]) ])
CFLAGS="[$]OLD_CFLAGS" CFLAGS="[$]OLD_CFLAGS"

View File

@ -43,7 +43,7 @@ AC_DEFUN([MYSQL_CHECK_NDB_OPTIONS], [
if test -f "$mysql_sci_dir/lib/libsisci.a" -a \ if test -f "$mysql_sci_dir/lib/libsisci.a" -a \
-f "$mysql_sci_dir/include/sisci_api.h"; then -f "$mysql_sci_dir/include/sisci_api.h"; then
NDB_SCI_INCLUDES="-I$mysql_sci_dir/include" NDB_SCI_INCLUDES="-I$mysql_sci_dir/include"
NDB_SCI_LIBS="-L$mysql_sci_dir/lib -lsisci" NDB_SCI_LIBS="$mysql_sci_dir/lib/libsisci.a"
AC_MSG_RESULT([-- including sci transporter]) AC_MSG_RESULT([-- including sci transporter])
AC_DEFINE([NDB_SCI_TRANSPORTER], [1], AC_DEFINE([NDB_SCI_TRANSPORTER], [1],
[Including Ndb Cluster DB sci transporter]) [Including Ndb Cluster DB sci transporter])
@ -197,7 +197,6 @@ AC_DEFUN([MYSQL_SETUP_NDBCLUSTER], [
MAKE_BINARY_DISTRIBUTION_OPTIONS="$MAKE_BINARY_DISTRIBUTION_OPTIONS --with-ndbcluster" MAKE_BINARY_DISTRIBUTION_OPTIONS="$MAKE_BINARY_DISTRIBUTION_OPTIONS --with-ndbcluster"
CXXFLAGS="$CXXFLAGS \$(NDB_CXXFLAGS)"
if test "$have_ndb_debug" = "default" if test "$have_ndb_debug" = "default"
then then
have_ndb_debug=$with_debug have_ndb_debug=$with_debug
@ -278,6 +277,13 @@ AC_DEFUN([MYSQL_SETUP_NDBCLUSTER], [
ndb_bin_am_ldflags="" ndb_bin_am_ldflags=""
fi fi
# building dynamic breaks on AIX. (If you want to try it and get unresolved
# __vec__delete2 and some such, try linking against libhC.)
case "$host_os" in
aix3.* | aix4.0.* | aix4.1.*) ;;
*) ndb_bin_am_ldflags="-static";;
esac
# libndbclient versioning when linked with GNU ld. # libndbclient versioning when linked with GNU ld.
if $LD --version 2>/dev/null|grep -q GNU; then if $LD --version 2>/dev/null|grep -q GNU; then
NDB_LD_VERSION_SCRIPT="-Wl,--version-script=\$(top_builddir)/storage/ndb/src/libndb.ver" NDB_LD_VERSION_SCRIPT="-Wl,--version-script=\$(top_builddir)/storage/ndb/src/libndb.ver"

View File

@ -127,14 +127,9 @@ AC_DEFUN([MYSQL_SYS_LARGEFILE],
hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*) hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
ac_cv_sys_largefile_source=1 ;; ac_cv_sys_largefile_source=1 ;;
esac]) esac])
AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES,
ac_cv_sys_large_files, # AIX 4.2 and later -- do nothing, include standards.h instead.
[Large files support on AIX-style hosts.], # this goes for both GNU and IBM C and C++ compilers.
[case "$host_os" in
# AIX 4.2 and later
aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*)
ac_cv_sys_large_files=1 ;;
esac])
fi fi
]) ])

View File

@ -469,7 +469,7 @@ AC_DEFUN([MYSQL_STACK_DIRECTION],
{ {
exit (find_stack_direction() < 0); exit (find_stack_direction() < 0);
}], ac_cv_c_stack_direction=1, ac_cv_c_stack_direction=-1, }], ac_cv_c_stack_direction=1, ac_cv_c_stack_direction=-1,
ac_cv_c_stack_direction=0)]) ac_cv_c_stack_direction=)])
AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction) AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
])dnl ])dnl
@ -479,7 +479,7 @@ AC_MSG_CHECKING(if conversion of longlong to float works)
AC_CACHE_VAL(ac_cv_conv_longlong_to_float, AC_CACHE_VAL(ac_cv_conv_longlong_to_float,
[AC_TRY_RUN([#include <stdio.h> [AC_TRY_RUN([#include <stdio.h>
typedef long long longlong; typedef long long longlong;
main() int main()
{ {
longlong ll=1; longlong ll=1;
float f; float f;
@ -487,8 +487,10 @@ main()
f = (float) ll; f = (float) ll;
fprintf(file,"%g\n",f); fprintf(file,"%g\n",f);
fclose(file); fclose(file);
exit (0); return (0);
}], ac_cv_conv_longlong_to_float=`cat conftestval`, ac_cv_conv_longlong_to_float=0, ifelse([$2], , , ac_cv_conv_longlong_to_float=$2))])dnl }], ac_cv_conv_longlong_to_float=`cat conftestval`,
ac_cv_conv_longlong_to_float=0,
ac_cv_conv_longlong_to_float="yes")])dnl # Cross compiling, assume can convert
if test "$ac_cv_conv_longlong_to_float" = "1" -o "$ac_cv_conv_longlong_to_float" = "yes" if test "$ac_cv_conv_longlong_to_float" = "1" -o "$ac_cv_conv_longlong_to_float" = "yes"
then then
ac_cv_conv_longlong_to_float=yes ac_cv_conv_longlong_to_float=yes
@ -636,7 +638,6 @@ AC_SUBST(CXX_VERSION)
]) ])
AC_DEFUN([MYSQL_PROG_AR], [ AC_DEFUN([MYSQL_PROG_AR], [
AC_REQUIRE([MYSQL_CHECK_CXX_VERSION])
case $CXX_VERSION in case $CXX_VERSION in
MIPSpro*) MIPSpro*)
AR=$CXX AR=$CXX
@ -647,11 +648,8 @@ case $CXX_VERSION in
ARFLAGS="-xar -o" ARFLAGS="-xar -o"
;; ;;
*) *)
if test -z "$AR" AC_CHECK_PROG([AR], [ar], [ar])
then if test -z "$AR" || test "$AR" = "false"
AC_CHECK_PROG([AR], [ar], [ar])
fi
if test -z "$AR"
then then
AC_MSG_ERROR([You need ar to build the library]) AC_MSG_ERROR([You need ar to build the library])
fi fi

View File

@ -15,14 +15,6 @@ dnl Add defines so yassl is built and linked with
dnl --------------------------------------------------------------------------- dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_USE_BUNDLED_YASSL], [ AC_DEFUN([MYSQL_USE_BUNDLED_YASSL], [
AC_CONFIG_FILES(extra/yassl/Makefile dnl
extra/yassl/taocrypt/Makefile dnl
extra/yassl/taocrypt/benchmark/Makefile dnl
extra/yassl/taocrypt/src/Makefile dnl
extra/yassl/taocrypt/test/Makefile dnl
extra/yassl/src/Makefile dnl
extra/yassl/testsuite/Makefile)
with_bundled_yassl="yes" with_bundled_yassl="yes"
yassl_dir="yassl" yassl_dir="yassl"
@ -104,7 +96,7 @@ AC_DEFUN([MYSQL_FIND_OPENSSL], [
# compiler warnings when using gcc 3.x # compiler warnings when using gcc 3.x
if test "$openssl_include" != "/usr/include" if test "$openssl_include" != "/usr/include"
then then
openssl_includes="-I$ssl_include" openssl_includes="-I$openssl_include"
fi fi
# #
@ -167,6 +159,15 @@ dnl macro bails out with error.
dnl dnl
dnl ------------------------------------------------------------------------ dnl ------------------------------------------------------------------------
AC_DEFUN([MYSQL_CHECK_SSL], [ AC_DEFUN([MYSQL_CHECK_SSL], [
AC_CONFIG_FILES(extra/yassl/Makefile dnl
extra/yassl/taocrypt/Makefile dnl
extra/yassl/taocrypt/benchmark/Makefile dnl
extra/yassl/taocrypt/src/Makefile dnl
extra/yassl/taocrypt/test/Makefile dnl
extra/yassl/src/Makefile dnl
extra/yassl/testsuite/Makefile)
AC_MSG_CHECKING(for SSL) AC_MSG_CHECKING(for SSL)
AC_ARG_WITH([ssl], AC_ARG_WITH([ssl],
[ --with-ssl[=DIR] Include SSL support], [ --with-ssl[=DIR] Include SSL support],

View File

@ -64,6 +64,9 @@ dnl installation dir ($pkglibdir), so ZLIB_DEPS is set to point to
dnl $pkglibdir. dnl $pkglibdir.
AC_DEFUN([MYSQL_CHECK_ZLIB_WITH_COMPRESS], [ AC_DEFUN([MYSQL_CHECK_ZLIB_WITH_COMPRESS], [
AC_CONFIG_FILES(zlib/Makefile)
AC_MSG_CHECKING([for zlib compression library]) AC_MSG_CHECKING([for zlib compression library])
case $SYSTEM_TYPE in case $SYSTEM_TYPE in
*netware* | *modesto*) *netware* | *modesto*)
@ -124,10 +127,6 @@ case $SYSTEM_TYPE in
fi fi
;; ;;
esac esac
if test -n "$zlib_dir"
then
AC_CONFIG_FILES(zlib/Makefile)
fi
]) ])
dnl ------------------------------------------------------------------------ dnl ------------------------------------------------------------------------

View File

@ -10,14 +10,14 @@ AC_CANONICAL_SYSTEM
# #
# When changing major version number please also check switch statement # When changing major version number please also check switch statement
# in mysqlbinlog::check_master_version(). # in mysqlbinlog::check_master_version().
AM_INIT_AUTOMAKE(mysql, 5.1.18-beta) AM_INIT_AUTOMAKE(mysql, 5.1.23-beta)
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER([include/config.h:config.h.in])
is_this_community_tree=no is_this_community_tree=no
PROTOCOL_VERSION=10 PROTOCOL_VERSION=10
DOT_FRM_VERSION=6 DOT_FRM_VERSION=6
# See the libtool docs for information on how to do shared lib versions. # See the libtool docs for information on how to do shared lib versions.
SHARED_LIB_MAJOR_VERSION=15 SHARED_LIB_MAJOR_VERSION=16
SHARED_LIB_VERSION=$SHARED_LIB_MAJOR_VERSION:0:0 SHARED_LIB_VERSION=$SHARED_LIB_MAJOR_VERSION:0:0
NDB_SHARED_LIB_MAJOR_VERSION=3 NDB_SHARED_LIB_MAJOR_VERSION=3
NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0 NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0
@ -72,14 +72,22 @@ AC_SUBST(AVAILABLE_LANGUAGES)
# Canonicalize the configuration name. # Canonicalize the configuration name.
SYSTEM_TYPE="$host_vendor-$host_os"
MACHINE_TYPE="$host_cpu" # Check whether --with-system-type or --without-system-type was given.
AC_ARG_WITH(system-type,
[ --with-system-type Set the system type, like "sun-solaris10"],
[SYSTEM_TYPE="$withval"],
[SYSTEM_TYPE="$host_vendor-$host_os"])
AC_ARG_WITH(machine-type,
[ --with-machine-type Set the machine type, like "powerpc"],
[MACHINE_TYPE="$withval"],
[MACHINE_TYPE="$host_cpu"])
AC_SUBST(SYSTEM_TYPE) AC_SUBST(SYSTEM_TYPE)
AC_DEFINE_UNQUOTED([SYSTEM_TYPE], ["$SYSTEM_TYPE"], AC_DEFINE_UNQUOTED([SYSTEM_TYPE], ["$SYSTEM_TYPE"],
[Name of system, eg solaris]) [Name of system, eg sun-solaris])
AC_SUBST(MACHINE_TYPE) AC_SUBST(MACHINE_TYPE)
AC_DEFINE_UNQUOTED([MACHINE_TYPE], ["$MACHINE_TYPE"], AC_DEFINE_UNQUOTED([MACHINE_TYPE], ["$MACHINE_TYPE"],
[Machine type name, eg sun10]) [Machine type name, eg sparc])
# Detect intel x86 like processor # Detect intel x86 like processor
BASE_MACHINE_TYPE=$MACHINE_TYPE BASE_MACHINE_TYPE=$MACHINE_TYPE
@ -231,14 +239,8 @@ AC_CHECK_PROGS(YACC, ['bison -y -p MYSQL'])
AC_CHECK_PROG(PDFMANUAL, pdftex, manual.pdf) AC_CHECK_PROG(PDFMANUAL, pdftex, manual.pdf)
AC_CHECK_PROG(DVIS, tex, manual.dvi) AC_CHECK_PROG(DVIS, tex, manual.dvi)
AC_MSG_CHECKING("return type of sprintf")
#check the return type of sprintf #check the return type of sprintf
case $SYSTEM_TYPE in AC_MSG_CHECKING("return type of sprintf")
*netware*)
AC_DEFINE(SPRINTF_RETURNS_INT, [1]) AC_MSG_RESULT("int")
;;
*)
AC_TRY_RUN([ AC_TRY_RUN([
int main() int main()
{ {
@ -264,10 +266,12 @@ AC_TRY_RUN([
[AC_DEFINE(SPRINTF_RETURNS_PTR, [1], [Broken sprintf]) [AC_DEFINE(SPRINTF_RETURNS_PTR, [1], [Broken sprintf])
AC_MSG_RESULT("ptr")], AC_MSG_RESULT("ptr")],
[AC_DEFINE(SPRINTF_RETURNS_GARBAGE, [1], [Broken sprintf]) [AC_DEFINE(SPRINTF_RETURNS_GARBAGE, [1], [Broken sprintf])
AC_MSG_RESULT("garbage")]) AC_MSG_RESULT("garbage")]
]) )],
;; # Cross compile, assume POSIX
esac [AC_DEFINE(SPRINTF_RETURNS_INT, [1], [POSIX sprintf])
AC_MSG_RESULT("int (we assume)")]
)
AC_PATH_PROG(uname_prog, uname, no) AC_PATH_PROG(uname_prog, uname, no)
@ -777,7 +781,8 @@ AC_CHECK_HEADERS(fcntl.h float.h floatingpoint.h ieeefp.h limits.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 \
sys/ioctl.h malloc.h sys/malloc.h sys/ipc.h sys/shm.h linux/config.h \ sys/ioctl.h malloc.h sys/malloc.h sys/ipc.h sys/shm.h linux/config.h \
sys/resource.h sys/param.h port.h) sys/prctl.h \
sys/resource.h sys/param.h port.h ieeefp.h)
AC_CHECK_HEADERS([xfs/xfs.h]) AC_CHECK_HEADERS([xfs/xfs.h])
@ -791,6 +796,7 @@ AC_CHECK_LIB(m, floor, [], AC_CHECK_LIB(m, __infinity))
AC_CHECK_LIB(nsl_r, gethostbyname_r, [], AC_CHECK_LIB(nsl_r, gethostbyname_r, [],
AC_CHECK_LIB(nsl, gethostbyname_r)) AC_CHECK_LIB(nsl, gethostbyname_r))
AC_CHECK_FUNC(gethostbyname_r) AC_CHECK_FUNC(gethostbyname_r)
AC_CHECK_LIB(mtmalloc, malloc)
AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt)) AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
AC_CHECK_FUNC(yp_get_default_domain, , AC_CHECK_FUNC(yp_get_default_domain, ,
@ -872,7 +878,7 @@ if test "$TARGET_LINUX" = "true"; then
[ USE_PSTACK=$withval ], [ USE_PSTACK=$withval ],
[ USE_PSTACK=no ]) [ USE_PSTACK=no ])
pstack_libs= pstack_libs=
pstack_dirs= pstack_dir=
if test "$USE_PSTACK" = yes -a "$TARGET_LINUX" = "true" -a "$BASE_MACHINE_TYPE" = "i386" if test "$USE_PSTACK" = yes -a "$TARGET_LINUX" = "true" -a "$BASE_MACHINE_TYPE" = "i386"
then then
have_libiberty= have_libbfd= have_libiberty= have_libbfd=
@ -885,11 +891,11 @@ dnl I have no idea if this is a good test - can not find docs for libiberty
if test x"$have_libiberty" = xyes -a x"$have_libbfd" = xyes if test x"$have_libiberty" = xyes -a x"$have_libbfd" = xyes
then then
pstack_dirs='$(top_srcdir)'/pstack pstack_dir="pstack"
pstack_libs="../pstack/libpstack.a -lbfd -liberty" pstack_libs="../pstack/libpstack.a -lbfd -liberty"
# We must link staticly when using pstack # We must link staticly when using pstack
with_mysqld_ldflags="-all-static" with_mysqld_ldflags="-all-static"
AC_SUBST([pstack_dirs]) AC_SUBST([pstack_dir])
AC_SUBST([pstack_libs]) AC_SUBST([pstack_libs])
AC_DEFINE([USE_PSTACK], [1], [the pstack backtrace library]) AC_DEFINE([USE_PSTACK], [1], [the pstack backtrace library])
dnl This check isn't needed, but might be nice to give some feedback.... dnl This check isn't needed, but might be nice to give some feedback....
@ -903,7 +909,6 @@ dnl have_libiberty_h=no)
USE_PSTACK="no" USE_PSTACK="no"
fi fi
fi fi
AM_CONDITIONAL(COMPILE_PSTACK, test "$USE_PSTACK" = "yes")
AC_MSG_CHECKING([if we should use pstack]) AC_MSG_CHECKING([if we should use pstack])
AC_MSG_RESULT([$USE_PSTACK]) AC_MSG_RESULT([$USE_PSTACK])
@ -1703,6 +1708,12 @@ AC_ARG_WITH(client-ldflags,
[CLIENT_EXTRA_LDFLAGS=]) [CLIENT_EXTRA_LDFLAGS=])
AC_SUBST(CLIENT_EXTRA_LDFLAGS) AC_SUBST(CLIENT_EXTRA_LDFLAGS)
AC_ARG_WITH(mysqld-libs,
[ --with-mysqld-libs Extra libraries to link with for mysqld],
[MYSQLD_EXTRA_LIBS=$withval],
[MYSQLD_EXTRA_LIBS=])
AC_SUBST(MYSQLD_EXTRA_LIBS)
AC_ARG_WITH(lib-ccflags, AC_ARG_WITH(lib-ccflags,
[ --with-lib-ccflags Extra CC options for libraries], [ --with-lib-ccflags Extra CC options for libraries],
[LIB_EXTRA_CCFLAGS=$withval], [LIB_EXTRA_CCFLAGS=$withval],
@ -1903,6 +1914,19 @@ else
fi fi
AC_SUBST(TERMCAP_LIB) AC_SUBST(TERMCAP_LIB)
# Check if the termcap function 'tgoto' is already declared in
# system header files or if it need to be declared locally
AC_CHECK_DECLS(tgoto,,,[
#ifdef HAVE_CURSES_H
# include <curses.h>
#elif HAVE_NCURSES_H
# include <ncurses.h>
#endif
#ifdef HAVE_TERM_H
# include <term.h>
#endif
])
LIBEDIT_LOBJECTS="" LIBEDIT_LOBJECTS=""
AC_CHECK_FUNC(strunvis, ,[LIBEDIT_LOBJECTS="$LIBEDIT_LOBJECTS unvis.o"]) AC_CHECK_FUNC(strunvis, ,[LIBEDIT_LOBJECTS="$LIBEDIT_LOBJECTS unvis.o"])
AC_CHECK_FUNC(strvis, ,[LIBEDIT_LOBJECTS="$LIBEDIT_LOBJECTS vis.o"]) AC_CHECK_FUNC(strvis, ,[LIBEDIT_LOBJECTS="$LIBEDIT_LOBJECTS vis.o"])
@ -1937,8 +1961,9 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \
chsize cuserid fchmod fcntl \ chsize cuserid fchmod fcntl \
fconvert fdatasync finite fpresetsticky fpsetmask fsync ftruncate \ fconvert fdatasync finite fpresetsticky fpsetmask fsync ftruncate \
getcwd gethostbyaddr_r gethostbyname_r getpass getpassphrase getpwnam \ getcwd gethostbyaddr_r gethostbyname_r getpass getpassphrase getpwnam \
getpwuid getrlimit getrusage getwd gmtime_r index initgroups isnan \ getpwuid getrlimit getrusage getwd index initgroups isnan \
localtime_r locking longjmp lrand48 madvise mallinfo memcpy memmove \ localtime_r gethrtime gmtime_r \
locking longjmp lrand48 madvise mallinfo memcpy memmove \
mkstemp mlockall perror poll pread pthread_attr_create mmap mmap64 getpagesize \ mkstemp mlockall perror poll pread pthread_attr_create mmap mmap64 getpagesize \
pthread_attr_getstacksize pthread_attr_setprio pthread_attr_setschedparam \ pthread_attr_getstacksize pthread_attr_setprio pthread_attr_setschedparam \
pthread_attr_setstacksize pthread_condattr_create pthread_getsequence_np \ pthread_attr_setstacksize pthread_condattr_create pthread_getsequence_np \
@ -1965,12 +1990,20 @@ case "$target" in
;; ;;
esac esac
# isinf() could be a function or a macro (HPUX) # Check that isinf() is available in math.h and can be used in both C and C++
AC_MSG_CHECKING(for isinf with <math.h>) # code
AC_MSG_CHECKING(for isinf in <math.h>)
AC_TRY_LINK([#include <math.h>], [float f = 0.0; int r = isinf(f); return r], AC_TRY_LINK([#include <math.h>], [float f = 0.0; int r = isinf(f); return r],
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_ISINF, [1], [isinf() macro or function]), AC_MSG_CHECKING(whether isinf() can be used in C++ code)
AC_MSG_RESULT(no)) AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_LINK([#include <math.h>], [float f = 0.0; int r = isinf(f); return r],
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_ISINF, [1], [isinf() macro or function]),
AC_MSG_RESULT(no))
AC_LANG_RESTORE,
AC_MSG_RESULT(no))
CFLAGS="$ORG_CFLAGS" CFLAGS="$ORG_CFLAGS"
@ -2311,8 +2344,7 @@ AC_ARG_WITH([mysqlmanager],
if test "$with_mysqlmanager" = "yes" -o \ if test "$with_mysqlmanager" = "yes" -o \
'(' "$with_mysqlmanager:$with_server" = ":yes" -a \ '(' "$with_mysqlmanager:$with_server" = ":yes" -a \
-d "$srcdir/server-tools" ')' ; then -d "$srcdir/server-tools" ')' ; then
tools_dirs="$tools_dirs server-tools" tools_dirs="server-tools"
AC_CONFIG_FILES(server-tools/Makefile server-tools/instance-manager/Makefile)
fi fi
AC_SUBST(tools_dirs) AC_SUBST(tools_dirs)
@ -2324,7 +2356,6 @@ if test "$with_embedded_server" = "yes"
then then
libmysqld_dirs=libmysqld libmysqld_dirs=libmysqld
AC_CONFIG_FILES(libmysqld/Makefile libmysqld/examples/Makefile)
# We can't build embedded library without building the server, because # We can't build embedded library without building the server, because
# we depend on libmysys, libmystrings, libmyisam, etc. # we depend on libmysys, libmystrings, libmyisam, etc.
with_server=yes with_server=yes
@ -2409,70 +2440,58 @@ then
# For NetWare, do not need readline # For NetWare, do not need readline
echo "Skipping readline" echo "Skipping readline"
else else
if [test "$with_libedit" = "yes"] || [test "$with_libedit" = "undefined"] && [test "$with_readline" = "undefined"]
if [test "$with_libedit" = "yes"] || [test "$with_libedit" = "undefined"] && [test "$with_readline" = "undefined"]
then
readline_topdir="cmd-line-utils"
readline_basedir="libedit"
readline_dir="$readline_topdir/$readline_basedir"
readline_link="\$(top_builddir)/cmd-line-utils/libedit/libedit.a"
readline_h_ln_cmd="\$(LN) -s \$(top_srcdir)/cmd-line-utils/libedit/readline readline"
compile_libedit=yes
AC_DEFINE_UNQUOTED(HAVE_HIST_ENTRY, 1)
AC_DEFINE_UNQUOTED(USE_LIBEDIT_INTERFACE, 1)
elif test "$with_readline" = "yes"
then
readline_topdir="cmd-line-utils"
readline_basedir="readline"
readline_dir="$readline_topdir/$readline_basedir"
readline_link="\$(top_builddir)/cmd-line-utils/readline/libreadline.a"
readline_h_ln_cmd="\$(LN) -s \$(top_srcdir)/cmd-line-utils/readline readline"
compile_readline=yes
want_to_use_readline="yes"
AC_DEFINE_UNQUOTED(USE_NEW_READLINE_INTERFACE, 1)
else
# Use system readline library
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
MYSQL_CHECK_LIBEDIT_INTERFACE
MYSQL_CHECK_NEW_RL_INTERFACE
MYSQL_CHECK_READLINE_DECLARES_HIST_ENTRY
AC_LANG_RESTORE
if [test "$mysql_cv_new_rl_interface" = "yes"] && [test -d "./cmd-line-utils/readline"]
then then
# Use the new readline interface, but only if the package includes a bundled libreadline readline_topdir="cmd-line-utils"
# this way we avoid linking commercial source with GPL readline readline_basedir="libedit"
readline_link="-lreadline" readline_dir="$readline_topdir/$readline_basedir"
want_to_use_readline="yes" readline_link="\$(top_builddir)/cmd-line-utils/libedit/libedit.a"
elif [test "$mysql_cv_libedit_interface" = "yes"] readline_h_ln_cmd="\$(LN) -s \$(top_srcdir)/cmd-line-utils/libedit/readline readline"
compile_libedit=yes
AC_DEFINE_UNQUOTED(HAVE_HIST_ENTRY, 1)
AC_DEFINE_UNQUOTED(USE_LIBEDIT_INTERFACE, 1)
elif test "$with_readline" = "yes"
then then
# Use libedit readline_topdir="cmd-line-utils"
readline_link="-ledit" readline_basedir="readline"
readline_dir="$readline_topdir/$readline_basedir"
readline_link="\$(top_builddir)/cmd-line-utils/readline/libreadline.a"
readline_h_ln_cmd="\$(LN) -s \$(top_srcdir)/cmd-line-utils/readline readline"
compile_readline=yes
want_to_use_readline="yes"
AC_DEFINE_UNQUOTED(USE_NEW_READLINE_INTERFACE, 1)
else else
AC_MSG_ERROR([Could not find system readline or libedit libraries # Use system readline library
Use --with-readline or --with-libedit to use the bundled AC_LANG_SAVE
versions of libedit or readline]) AC_LANG_CPLUSPLUS
MYSQL_CHECK_LIBEDIT_INTERFACE
MYSQL_CHECK_NEW_RL_INTERFACE
MYSQL_CHECK_READLINE_DECLARES_HIST_ENTRY
AC_LANG_RESTORE
if [test "$mysql_cv_new_rl_interface" = "yes"] && [test -d "$srcdir/cmd-line-utils/readline"]
then
# Use the new readline interface, but only if the package includes a bundled libreadline
# this way we avoid linking commercial source with GPL readline
readline_link="-lreadline"
want_to_use_readline="yes"
elif [test "$mysql_cv_libedit_interface" = "yes"]
then
# Use libedit
readline_link="-ledit"
else
AC_MSG_ERROR([Could not find system readline or libedit libraries
Use --with-readline or --with-libedit to use the bundled
versions of libedit or readline])
fi
fi fi
fi
# if there is no readline, but we want to build with readline, we fail # if there is no readline, but we want to build with readline, we fail
if [test "$want_to_use_readline" = "yes"] && [test ! -d "./cmd-line-utils/readline"] if [test "$want_to_use_readline" = "yes"] && [test ! -d "./cmd-line-utils/readline"]
then then
AC_MSG_ERROR([This commercially licensed MySQL source package can't AC_MSG_ERROR([This commercially licensed MySQL source package can't
be built with libreadline. Please use --with-libedit to use be built with libreadline. Please use --with-libedit to use
the bundled version of libedit instead.]) the bundled version of libedit instead.])
fi fi
#
# if either readline or libedit is enabled - generate Makefile's for both
# (to make sure both are included in 'make dist')
#
if test -n "$readline_basedir"
then
AC_CONFIG_FILES(cmd-line-utils/Makefile dnl
cmd-line-utils/libedit/Makefile dnl
cmd-line-utils/readline/Makefile)
fi
fi fi
AC_SUBST(readline_dir) AC_SUBST(readline_dir)
@ -2541,7 +2560,6 @@ AC_SUBST(man8_files)
sql_server_dirs= sql_server_dirs=
sql_server= sql_server=
server_scripts= server_scripts=
thread_dirs=
dnl This probably should be cleaned up more - for now the threaded dnl This probably should be cleaned up more - for now the threaded
dnl client is just using plain-old libs. dnl client is just using plain-old libs.
@ -2552,7 +2570,6 @@ AM_CONDITIONAL(THREAD_SAFE_CLIENT, test "$THREAD_SAFE_CLIENT" != "no")
if test "$THREAD_SAFE_CLIENT" != "no" if test "$THREAD_SAFE_CLIENT" != "no"
then then
sql_client_dirs="$sql_client_dirs libmysql_r" sql_client_dirs="$sql_client_dirs libmysql_r"
AC_CONFIG_FILES(libmysql_r/Makefile)
AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should the client be thread safe]) AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should the client be thread safe])
fi fi
sql_client_dirs="$sql_client_dirs client" sql_client_dirs="$sql_client_dirs client"
@ -2584,7 +2601,7 @@ then
server_scripts="mysqld_safe mysql_install_db" server_scripts="mysqld_safe mysql_install_db"
sql_server_dirs="strings mysys dbug extra regex" sql_server_dirs="strings mysys dbug extra regex"
sql_server="$sql_server vio sql" sql_server="vio sql"
fi fi
# IMPORTANT - do not modify LIBS past this line - this hack is the only way # IMPORTANT - do not modify LIBS past this line - this hack is the only way
@ -2596,7 +2613,6 @@ LIBS="$LIBS $STATIC_NSS_FLAGS"
AC_SUBST(sql_server_dirs) AC_SUBST(sql_server_dirs)
AC_SUBST(sql_server) AC_SUBST(sql_server)
AC_SUBST(thread_dirs)
AC_SUBST(server_scripts) AC_SUBST(server_scripts)
AC_SUBST(mysql_plugin_dirs) AC_SUBST(mysql_plugin_dirs)
@ -2623,20 +2639,38 @@ AC_SUBST(CC)
AC_SUBST(GXX) AC_SUBST(GXX)
# Set configuration options for make_binary_distribution # Set configuration options for make_binary_distribution
case $SYSTEM_TYPE in
*netware*)
MAKE_BINARY_DISTRIBUTION_OPTIONS="$MAKE_BINARY_DISTRIBUTION_OPTIONS --no-strip"
;;
*)
: # no change for other platforms yet
;;
esac
AC_SUBST(MAKE_BINARY_DISTRIBUTION_OPTIONS) AC_SUBST(MAKE_BINARY_DISTRIBUTION_OPTIONS)
# Output results # Output results
if test -d "$srcdir/pstack" ; then
AC_CONFIG_FILES(pstack/Makefile pstack/aout/Makefile)
fi
if test -d "$srcdir/cmd-line-utils/readline" ; then
AC_CONFIG_FILES(cmd-line-utils/readline/Makefile)
fi
AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl
unittest/Makefile unittest/mytap/Makefile unittest/mytap/t/Makefile dnl unittest/Makefile unittest/mytap/Makefile unittest/mytap/t/Makefile dnl
unittest/mysys/Makefile unittest/examples/Makefile dnl unittest/mysys/Makefile unittest/examples/Makefile dnl
strings/Makefile regex/Makefile storage/Makefile dnl strings/Makefile regex/Makefile storage/Makefile dnl
man/Makefile BUILD/Makefile vio/Makefile dnl man/Makefile BUILD/Makefile vio/Makefile dnl
libmysql/Makefile client/Makefile dnl libmysql/Makefile libmysql_r/Makefile client/Makefile dnl
pstack/Makefile pstack/aout/Makefile sql/Makefile sql/share/Makefile dnl sql/Makefile sql/share/Makefile dnl
sql/sql_builtin.cc sql-common/Makefile dnl sql/sql_builtin.cc sql-common/Makefile dnl
dbug/Makefile scripts/Makefile include/Makefile dnl dbug/Makefile scripts/Makefile include/Makefile dnl
tests/Makefile Docs/Makefile support-files/Makefile dnl tests/Makefile Docs/Makefile support-files/Makefile dnl
support-files/MacOSX/Makefile support-files/RHEL4-SElinux/Makefile dnl support-files/MacOSX/Makefile support-files/RHEL4-SElinux/Makefile dnl
server-tools/Makefile server-tools/instance-manager/Makefile dnl
cmd-line-utils/Makefile cmd-line-utils/libedit/Makefile dnl
libmysqld/Makefile libmysqld/examples/Makefile dnl
mysql-test/Makefile dnl mysql-test/Makefile dnl
debian/Makefile debian/defs.mk debian/control dnl debian/Makefile debian/defs.mk debian/control dnl
mysql-test/ndb/Makefile netware/Makefile sql-bench/Makefile dnl mysql-test/ndb/Makefile netware/Makefile sql-bench/Makefile dnl

12
dbug/CMakeLists.txt Normal file → Executable file
View File

@ -13,8 +13,12 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -D__WIN32__") INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/dbug)
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) SET(DBUG_SOURCES dbug.c factorial.c sanity.c)
ADD_LIBRARY(dbug dbug.c factorial.c sanity.c)
IF(NOT SOURCE_SUBLIBS)
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
ADD_LIBRARY(dbug ${DBUG_SOURCES})
ENDIF(NOT SOURCE_SUBLIBS)

View File

@ -264,7 +264,7 @@ static BOOLEAN DoTrace(CODE_STATE *cs);
/* Test to see if file is writable */ /* Test to see if file is writable */
#if !(!defined(HAVE_ACCESS) || defined(MSDOS)) #if !(!defined(HAVE_ACCESS) || defined(MSDOS))
static BOOLEAN Writable(char *pathname); static BOOLEAN Writable(const char *pathname);
/* Change file owner and group */ /* Change file owner and group */
static void ChangeOwner(CODE_STATE *cs, char *pathname); static void ChangeOwner(CODE_STATE *cs, char *pathname);
/* Allocate memory for runtime support */ /* Allocate memory for runtime support */
@ -343,12 +343,12 @@ static CODE_STATE *code_state(void)
if (!(cs=(CODE_STATE *) tmp->dbug)) if (!(cs=(CODE_STATE *) tmp->dbug))
{ {
cs=(CODE_STATE*) DbugMalloc(sizeof(*cs)); cs=(CODE_STATE*) DbugMalloc(sizeof(*cs));
bzero((char*) cs,sizeof(*cs)); bzero((uchar*) cs,sizeof(*cs));
cs->process= db_process ? db_process : "dbug"; cs->process= db_process ? db_process : "dbug";
cs->func="?func"; cs->func="?func";
cs->file="?file"; cs->file="?file";
cs->stack=&init_settings; cs->stack=&init_settings;
tmp->dbug=(gptr) cs; tmp->dbug= (void*) cs;
} }
} }
return cs; return cs;
@ -715,7 +715,7 @@ void _db_push_(const char *control)
void _db_set_init_(const char *control) void _db_set_init_(const char *control)
{ {
CODE_STATE tmp_cs; CODE_STATE tmp_cs;
bzero((char*) &tmp_cs, sizeof(tmp_cs)); bzero((uchar*) &tmp_cs, sizeof(tmp_cs));
tmp_cs.stack= &init_settings; tmp_cs.stack= &init_settings;
_db_set_(&tmp_cs, control); _db_set_(&tmp_cs, control);
} }
@ -830,7 +830,7 @@ void _db_pop_()
} \ } \
} while (0) } while (0)
int _db_explain_ (CODE_STATE *cs, char *buf, int len) int _db_explain_ (CODE_STATE *cs, char *buf, size_t len)
{ {
char *start=buf, *end=buf+len-4; char *start=buf, *end=buf+len-4;
@ -887,10 +887,10 @@ overflow:
* see _db_explain_ * see _db_explain_
*/ */
int _db_explain_init_(char *buf, int len) int _db_explain_init_(char *buf, size_t len)
{ {
CODE_STATE cs; CODE_STATE cs;
bzero((char*) &cs,sizeof(cs)); bzero((uchar*) &cs,sizeof(cs));
cs.stack=&init_settings; cs.stack=&init_settings;
return _db_explain_(&cs, buf, len); return _db_explain_(&cs, buf, len);
} }
@ -1083,7 +1083,7 @@ void _db_pargs_(uint _line_, const char *keyword)
CODE_STATE *cs=0; CODE_STATE *cs=0;
get_code_state_or_return; get_code_state_or_return;
cs->u_line= _line_; cs->u_line= _line_;
cs->u_keyword= (char*) keyword; cs->u_keyword= keyword;
} }
@ -1160,7 +1160,8 @@ void _db_doprnt_(const char *format,...)
* Is used to examine corrputed memory or arrays. * Is used to examine corrputed memory or arrays.
*/ */
void _db_dump_(uint _line_, const char *keyword, const char *memory, uint length) void _db_dump_(uint _line_, const char *keyword,
const unsigned char *memory, size_t length)
{ {
int pos; int pos;
char dbuff[90]; char dbuff[90];
@ -1168,7 +1169,7 @@ void _db_dump_(uint _line_, const char *keyword, const char *memory, uint length
CODE_STATE *cs=0; CODE_STATE *cs=0;
get_code_state_or_return; get_code_state_or_return;
if (_db_keyword_(cs, (char*) keyword)) if (_db_keyword_(cs, keyword))
{ {
if (!cs->locked) if (!cs->locked)
pthread_mutex_lock(&THR_LOCK_dbug); pthread_mutex_lock(&THR_LOCK_dbug);
@ -1182,8 +1183,8 @@ void _db_dump_(uint _line_, const char *keyword, const char *memory, uint length
{ {
fprintf(cs->stack->out_file, "%s: ", cs->func); fprintf(cs->stack->out_file, "%s: ", cs->func);
} }
sprintf(dbuff,"%s: Memory: 0x%lx Bytes: (%d)\n", sprintf(dbuff,"%s: Memory: 0x%lx Bytes: (%ld)\n",
keyword,(ulong) memory, length); keyword, (ulong) memory, (long) length);
(void) fputs(dbuff,cs->stack->out_file); (void) fputs(dbuff,cs->stack->out_file);
pos=0; pos=0;
@ -1292,7 +1293,7 @@ static struct link *ListDel(struct link *head,
{ {
struct link *delme=*cur; struct link *delme=*cur;
*cur=(*cur)->next_link; *cur=(*cur)->next_link;
free((char*)delme); free((void*) delme);
} }
} while (*cur && *(cur=&((*cur)->next_link))); } while (*cur && *(cur=&((*cur)->next_link)));
} }
@ -1448,10 +1449,11 @@ static void FreeState(CODE_STATE *cs, struct settings *state, int free_state)
FreeList(state->p_functions); FreeList(state->p_functions);
if (!is_shared(state, out_file)) if (!is_shared(state, out_file))
DBUGCloseFile(cs, state->out_file); DBUGCloseFile(cs, state->out_file);
(void) fflush(cs->stack->out_file);
if (state->prof_file) if (state->prof_file)
DBUGCloseFile(cs, state->prof_file); DBUGCloseFile(cs, state->prof_file);
if (free_state) if (free_state)
free((char *) state); free((void*) state);
} }
@ -1696,7 +1698,7 @@ static void FreeList(struct link *linkp)
{ {
old= linkp; old= linkp;
linkp= linkp->next_link; linkp= linkp->next_link;
free((char *) old); free((void*) old);
} }
} }
@ -1815,7 +1817,7 @@ static void DBUGOpenFile(CODE_STATE *cs,
} }
else else
{ {
if (!Writable((char*)name)) if (!Writable(name))
{ {
(void) fprintf(stderr, ERR_OPEN, cs->process, name); (void) fprintf(stderr, ERR_OPEN, cs->process, name);
perror(""); perror("");
@ -1881,7 +1883,6 @@ static FILE *OpenProfile(CODE_STATE *cs, const char *name)
{ {
(void) fprintf(cs->stack->out_file, ERR_OPEN, cs->process, name); (void) fprintf(cs->stack->out_file, ERR_OPEN, cs->process, name);
perror(""); perror("");
dbug_flush(0);
(void) Delay(cs->stack->delay); (void) Delay(cs->stack->delay);
} }
else else
@ -1891,7 +1892,6 @@ static FILE *OpenProfile(CODE_STATE *cs, const char *name)
{ {
(void) fprintf(cs->stack->out_file, ERR_OPEN, cs->process, name); (void) fprintf(cs->stack->out_file, ERR_OPEN, cs->process, name);
perror(""); perror("");
dbug_flush(0);
} }
else else
{ {
@ -1930,7 +1930,7 @@ static void DBUGCloseFile(CODE_STATE *cs, FILE *fp)
pthread_mutex_lock(&THR_LOCK_dbug); pthread_mutex_lock(&THR_LOCK_dbug);
(void) fprintf(cs->stack->out_file, ERR_CLOSE, cs->process); (void) fprintf(cs->stack->out_file, ERR_CLOSE, cs->process);
perror(""); perror("");
dbug_flush(0); dbug_flush(cs);
} }
} }
@ -1988,7 +1988,7 @@ static char *DbugMalloc(size_t size)
{ {
register char *new_malloc; register char *new_malloc;
if (!(new_malloc= (char*) malloc((size_t) size))) if (!(new_malloc= (char*) malloc(size)))
DbugExit("out of memory"); DbugExit("out of memory");
return new_malloc; return new_malloc;
} }
@ -2062,7 +2062,7 @@ static const char *BaseName(const char *pathname)
#ifndef Writable #ifndef Writable
static BOOLEAN Writable(char *pathname) static BOOLEAN Writable(const char *pathname)
{ {
REGISTER BOOLEAN granted; REGISTER BOOLEAN granted;
REGISTER char *lastslash; REGISTER char *lastslash;

8
extra/CMakeLists.txt Normal file → Executable file
View File

@ -20,7 +20,7 @@ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
ADD_EXECUTABLE(comp_err comp_err.c) ADD_EXECUTABLE(comp_err comp_err.c)
TARGET_LINK_LIBRARIES(comp_err dbug mysys strings zlib wsock32) TARGET_LINK_LIBRARIES(comp_err debug dbug mysys strings zlib wsock32)
GET_TARGET_PROPERTY(COMP_ERR_EXE comp_err LOCATION) GET_TARGET_PROPERTY(COMP_ERR_EXE comp_err LOCATION)
@ -39,13 +39,13 @@ ADD_CUSTOM_TARGET(GenError
DEPENDS ${PROJECT_SOURCE_DIR}/include/mysqld_error.h) DEPENDS ${PROJECT_SOURCE_DIR}/include/mysqld_error.h)
ADD_EXECUTABLE(my_print_defaults my_print_defaults.c) ADD_EXECUTABLE(my_print_defaults my_print_defaults.c)
TARGET_LINK_LIBRARIES(my_print_defaults strings mysys dbug taocrypt wsock32) TARGET_LINK_LIBRARIES(my_print_defaults strings mysys debug dbug taocrypt wsock32)
ADD_EXECUTABLE(perror perror.c) ADD_EXECUTABLE(perror perror.c)
TARGET_LINK_LIBRARIES(perror strings mysys dbug wsock32) TARGET_LINK_LIBRARIES(perror strings mysys debug dbug wsock32)
ADD_EXECUTABLE(replace replace.c) ADD_EXECUTABLE(replace replace.c)
TARGET_LINK_LIBRARIES(replace strings mysys dbug wsock32) TARGET_LINK_LIBRARIES(replace strings mysys debug dbug wsock32)
IF(EMBED_MANIFESTS) IF(EMBED_MANIFESTS)
MYSQL_EMBED_MANIFEST("myTest" "asInvoker") MYSQL_EMBED_MANIFEST("myTest" "asInvoker")

View File

@ -24,6 +24,7 @@ BUILT_SOURCES= $(top_builddir)/include/mysqld_error.h \
pkginclude_HEADERS= $(BUILT_SOURCES) pkginclude_HEADERS= $(BUILT_SOURCES)
DISTCLEANFILES = $(BUILT_SOURCES) DISTCLEANFILES = $(BUILT_SOURCES)
SUBDIRS = @yassl_dir@ SUBDIRS = @yassl_dir@
DIST_SUBDIRS = yassl
# This will build mysqld_error.h, mysqld_ername.h and sql_state.h # This will build mysqld_error.h, mysqld_ername.h and sql_state.h
# NOTE Built files should depend on their sources to avoid # NOTE Built files should depend on their sources to avoid

View File

@ -99,31 +99,31 @@ static struct my_option my_long_options[]=
{"debug", '#', "This is a non-debug version. Catch this and exit", {"debug", '#', "This is a non-debug version. Catch this and exit",
0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
#else #else
{"debug", '#', "Output debug log", (gptr *) & default_dbug_option, {"debug", '#', "Output debug log", (uchar**) & default_dbug_option,
(gptr *) & default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) & default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"debug-info", 'T', "Print some debug info at exit.", (gptr *) & info_flag, {"debug-info", 'T', "Print some debug info at exit.", (uchar**) & info_flag,
(gptr *) & info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) & info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"help", '?', "Displays this help and exits.", 0, 0, 0, GET_NO_ARG, {"help", '?', "Displays this help and exits.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Prints version", 0, 0, 0, GET_NO_ARG, {"version", 'V', "Prints version", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"charset", 'C', "Charset dir", (gptr *) & charsets_dir, {"charset", 'C', "Charset dir", (uchar**) & charsets_dir,
(gptr *) & charsets_dir, (uchar**) & charsets_dir,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"in_file", 'F', "Input file", (gptr *) & TXTFILE, (gptr *) & TXTFILE, {"in_file", 'F', "Input file", (uchar**) & TXTFILE, (uchar**) & TXTFILE,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"out_dir", 'D', "Output base directory", (gptr *) & DATADIRECTORY, {"out_dir", 'D', "Output base directory", (uchar**) & DATADIRECTORY,
(gptr *) & DATADIRECTORY, (uchar**) & DATADIRECTORY,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"out_file", 'O', "Output filename (errmsg.sys)", (gptr *) & OUTFILE, {"out_file", 'O', "Output filename (errmsg.sys)", (uchar**) & OUTFILE,
(gptr *) & OUTFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) & OUTFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"header_file", 'H', "mysqld_error.h file ", (gptr *) & HEADERFILE, {"header_file", 'H', "mysqld_error.h file ", (uchar**) & HEADERFILE,
(gptr *) & HEADERFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) & HEADERFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"name_file", 'N', "mysqld_ername.h file ", (gptr *) & NAMEFILE, {"name_file", 'N', "mysqld_ername.h file ", (uchar**) & NAMEFILE,
(gptr *) & NAMEFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) & NAMEFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"state_file", 'S', "sql_state.h file", (gptr *) & STATEFILE, {"state_file", 'S', "sql_state.h file", (uchar**) & STATEFILE,
(gptr *) & STATEFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) & STATEFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
@ -241,7 +241,7 @@ static int create_header_files(struct errors *error_head)
/* generating sql_state.h file */ /* generating sql_state.h file */
if (tmp_error->sql_code1[0] || tmp_error->sql_code2[0]) if (tmp_error->sql_code1[0] || tmp_error->sql_code2[0])
fprintf(sql_statef, fprintf(sql_statef,
"%-40s,\"%s\", \"%s\",\n", tmp_error->er_name, "{ %-40s,\"%s\", \"%s\" },\n", tmp_error->er_name,
tmp_error->sql_code1, tmp_error->sql_code2); tmp_error->sql_code1, tmp_error->sql_code2);
/*generating er_name file */ /*generating er_name file */
fprintf(er_namef, "{ \"%s\", %d },\n", tmp_error->er_name, fprintf(er_namef, "{ \"%s\", %d },\n", tmp_error->er_name,
@ -329,21 +329,21 @@ static int create_sys_files(struct languages *lang_head,
/* continue with header of the errmsg.sys file */ /* continue with header of the errmsg.sys file */
length= ftell(to) - HEADER_LENGTH - row_count * 2; length= ftell(to) - HEADER_LENGTH - row_count * 2;
bzero((gptr) head, HEADER_LENGTH); bzero((uchar*) head, HEADER_LENGTH);
bmove((byte *) head, (byte *) file_head, 4); bmove((uchar *) head, (uchar *) file_head, 4);
head[4]= 1; head[4]= 1;
int2store(head + 6, length); int2store(head + 6, length);
int2store(head + 8, row_count); int2store(head + 8, row_count);
head[30]= csnum; head[30]= csnum;
my_fseek(to, 0l, MY_SEEK_SET, MYF(0)); my_fseek(to, 0l, MY_SEEK_SET, MYF(0));
if (my_fwrite(to, (byte*) head, HEADER_LENGTH, MYF(MY_WME | MY_FNABP))) if (my_fwrite(to, (uchar*) head, HEADER_LENGTH, MYF(MY_WME | MY_FNABP)))
goto err; goto err;
for (i= 0; i < row_count; i++) for (i= 0; i < row_count; i++)
{ {
int2store(head, file_pos[i]); int2store(head, file_pos[i]);
if (my_fwrite(to, (byte*) head, 2, MYF(MY_WME | MY_FNABP))) if (my_fwrite(to, (uchar*) head, 2, MYF(MY_WME | MY_FNABP)))
goto err; goto err;
} }
my_fclose(to, MYF(0)); my_fclose(to, MYF(0));
@ -362,7 +362,7 @@ static void clean_up(struct languages *lang_head, struct errors *error_head)
struct errors *tmp_error, *next_error; struct errors *tmp_error, *next_error;
uint count, i; uint count, i;
my_free((gptr) default_language, MYF(0)); my_free((uchar*) default_language, MYF(0));
for (tmp_lang= lang_head; tmp_lang; tmp_lang= next_language) for (tmp_lang= lang_head; tmp_lang; tmp_lang= next_language)
{ {
@ -370,7 +370,7 @@ static void clean_up(struct languages *lang_head, struct errors *error_head)
my_free(tmp_lang->lang_short_name, MYF(0)); my_free(tmp_lang->lang_short_name, MYF(0));
my_free(tmp_lang->lang_long_name, MYF(0)); my_free(tmp_lang->lang_long_name, MYF(0));
my_free(tmp_lang->charset, MYF(0)); my_free(tmp_lang->charset, MYF(0));
my_free((gptr) tmp_lang, MYF(0)); my_free((uchar*) tmp_lang, MYF(0));
} }
for (tmp_error= error_head; tmp_error; tmp_error= next_error) for (tmp_error= error_head; tmp_error; tmp_error= next_error)
@ -381,17 +381,17 @@ static void clean_up(struct languages *lang_head, struct errors *error_head)
{ {
struct message *tmp; struct message *tmp;
tmp= dynamic_element(&tmp_error->msg, i, struct message*); tmp= dynamic_element(&tmp_error->msg, i, struct message*);
my_free((gptr) tmp->lang_short_name, MYF(0)); my_free((uchar*) tmp->lang_short_name, MYF(0));
my_free((gptr) tmp->text, MYF(0)); my_free((uchar*) tmp->text, MYF(0));
} }
delete_dynamic(&tmp_error->msg); delete_dynamic(&tmp_error->msg);
if (tmp_error->sql_code1[0]) if (tmp_error->sql_code1[0])
my_free((gptr) tmp_error->sql_code1, MYF(0)); my_free((uchar*) tmp_error->sql_code1, MYF(0));
if (tmp_error->sql_code2[0]) if (tmp_error->sql_code2[0])
my_free((gptr) tmp_error->sql_code2, MYF(0)); my_free((uchar*) tmp_error->sql_code2, MYF(0));
my_free((gptr) tmp_error->er_name, MYF(0)); my_free((uchar*) tmp_error->er_name, MYF(0));
my_free((gptr) tmp_error, MYF(0)); my_free((uchar*) tmp_error, MYF(0));
} }
} }
@ -471,7 +471,7 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
current_error->er_name, current_message.lang_short_name); current_error->er_name, current_message.lang_short_name);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if (insert_dynamic(&current_error->msg, (byte *) & current_message)) if (insert_dynamic(&current_error->msg, (uchar *) & current_message))
DBUG_RETURN(0); DBUG_RETURN(0);
continue; continue;
} }
@ -534,7 +534,7 @@ static uint parse_error_offset(char *str)
end= 0; end= 0;
ioffset= (uint) my_strtoll10(soffset, &end, &error); ioffset= (uint) my_strtoll10(soffset, &end, &error);
my_free((gptr) soffset, MYF(0)); my_free((uchar*) soffset, MYF(0));
DBUG_RETURN(ioffset); DBUG_RETURN(ioffset);
} }

View File

@ -51,10 +51,10 @@
/* another argument to specify page ranges... seek to right spot and go from there */ /* another argument to specify page ranges... seek to right spot and go from there */
typedef unsigned long int ulint; typedef unsigned long int ulint;
typedef unsigned char byte; typedef unsigned char uchar;
/* innodb function in name; modified slightly to not have the ASM version (lots of #ifs that didn't apply) */ /* innodb function in name; modified slightly to not have the ASM version (lots of #ifs that didn't apply) */
ulint mach_read_from_4(byte *b) ulint mach_read_from_4(uchar *b)
{ {
return( ((ulint)(b[0]) << 24) return( ((ulint)(b[0]) << 24)
+ ((ulint)(b[1]) << 16) + ((ulint)(b[1]) << 16)
@ -78,7 +78,7 @@ ulint
ut_fold_binary( ut_fold_binary(
/*===========*/ /*===========*/
/* out: folded value */ /* out: folded value */
byte* str, /* in: string of bytes */ uchar* str, /* in: string of bytes */
ulint len) /* in: length */ ulint len) /* in: length */
{ {
ulint i; ulint i;
@ -98,7 +98,7 @@ ulint
buf_calc_page_new_checksum( buf_calc_page_new_checksum(
/*=======================*/ /*=======================*/
/* out: checksum */ /* out: checksum */
byte* page) /* in: buffer page */ uchar* page) /* in: buffer page */
{ {
ulint checksum; ulint checksum;
@ -123,7 +123,7 @@ ulint
buf_calc_page_old_checksum( buf_calc_page_old_checksum(
/*=======================*/ /*=======================*/
/* out: checksum */ /* out: checksum */
byte* page) /* in: buffer page */ uchar* page) /* in: buffer page */
{ {
ulint checksum; ulint checksum;
@ -138,7 +138,7 @@ buf_calc_page_old_checksum(
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
FILE *f; /* our input file */ FILE *f; /* our input file */
byte *p; /* storage of pages read */ uchar *p; /* storage of pages read */
int bytes; /* bytes read count */ int bytes; /* bytes read count */
ulint ct; /* current page number (0 based) */ ulint ct; /* current page number (0 based) */
int now; /* current time */ int now; /* current time */
@ -256,7 +256,7 @@ int main(int argc, char **argv)
} }
/* allocate buffer for reading (so we don't realloc every time) */ /* allocate buffer for reading (so we don't realloc every time) */
p= (byte *)malloc(UNIV_PAGE_SIZE); p= (uchar *)malloc(UNIV_PAGE_SIZE);
/* main checksumming loop */ /* main checksumming loop */
ct= start_page; ct= start_page;

View File

@ -47,30 +47,30 @@ static struct my_option my_long_options[] =
added if the file has no extension) added if the file has no extension)
*/ */
{"config-file", 'c', "Deprecated, please use --defaults-file instead. Name of config file to read; if no extension is given, default extension (e.g., .ini or .cnf) will be added", {"config-file", 'c', "Deprecated, please use --defaults-file instead. Name of config file to read; if no extension is given, default extension (e.g., .ini or .cnf) will be added",
(gptr*) &config_file, (gptr*) &config_file, 0, GET_STR, REQUIRED_ARG, (uchar**) &config_file, (uchar**) &config_file, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
#ifdef DBUG_OFF #ifdef DBUG_OFF
{"debug", '#', "This is a non-debug version. Catch this and exit", {"debug", '#', "This is a non-debug version. Catch this and exit",
0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, 0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
#else #else
{"debug", '#', "Output debug log", (gptr*) &default_dbug_option, {"debug", '#', "Output debug log", (uchar**) &default_dbug_option,
(gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"defaults-file", 'c', "Like --config-file, except: if first option, then read this file only, do not read global or per-user config files; should be the first option", {"defaults-file", 'c', "Like --config-file, except: if first option, then read this file only, do not read global or per-user config files; should be the first option",
(gptr*) &config_file, (gptr*) &config_file, 0, GET_STR, REQUIRED_ARG, (uchar**) &config_file, (uchar**) &config_file, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"defaults-extra-file", 'e', {"defaults-extra-file", 'e',
"Read this file after the global config file and before the config file in the users home directory; should be the first option", "Read this file after the global config file and before the config file in the users home directory; should be the first option",
(gptr*) &my_defaults_extra_file, (gptr*) &my_defaults_extra_file, 0, (uchar**) &my_defaults_extra_file, (uchar**) &my_defaults_extra_file, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"defaults-group-suffix", 'g', {"defaults-group-suffix", 'g',
"In addition to the given groups, read also groups with this suffix", "In addition to the given groups, read also groups with this suffix",
(gptr*) &my_defaults_group_suffix, (gptr*) &my_defaults_group_suffix, (uchar**) &my_defaults_group_suffix, (uchar**) &my_defaults_group_suffix,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"extra-file", 'e', {"extra-file", 'e',
"Deprecated. Synonym for --defaults-extra-file.", "Deprecated. Synonym for --defaults-extra-file.",
(gptr*) &my_defaults_extra_file, (uchar**) &my_defaults_extra_file,
(gptr*) &my_defaults_extra_file, 0, GET_STR, (uchar**) &my_defaults_extra_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"no-defaults", 'n', "Return an empty string (useful for scripts).", {"no-defaults", 'n', "Return an empty string (useful for scripts).",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},

View File

@ -38,7 +38,7 @@ static struct my_option my_long_options[] =
0, 0, 0, 0, 0}, 0, 0, 0, 0, 0},
{"verbose", 'v', {"verbose", 'v',
"Be more verbose. Give a warning, if kill can't handle signal 0.", "Be more verbose. Give a warning, if kill can't handle signal 0.",
(gptr*) &verbose, (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &verbose, (uchar**) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Print version information and exit.", 0, 0, 0, {"version", 'V', "Print version information and exit.", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}

View File

@ -25,6 +25,7 @@
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
#include "../storage/ndb/src/ndbapi/ndberror.c" #include "../storage/ndb/src/ndbapi/ndberror.c"
#include "../storage/ndb/src/kernel/error/ndbd_exit_codes.c" #include "../storage/ndb/src/kernel/error/ndbd_exit_codes.c"
#include "../storage/ndb/include/mgmapi/mgmapi_error.h"
#endif #endif
static my_bool verbose, print_all_codes; static my_bool verbose, print_all_codes;
@ -32,6 +33,20 @@ static my_bool verbose, print_all_codes;
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
static my_bool ndb_code; static my_bool ndb_code;
static char ndb_string[1024]; static char ndb_string[1024];
int mgmapi_error_string(int err_no, char *str, int size)
{
int i;
for (i= 0; i < ndb_mgm_noOfErrorMsgs; i++)
{
if ((int)ndb_mgm_error_msgs[i].code == err_no)
{
my_snprintf(str, size-1, "%s", ndb_mgm_error_msgs[i].msg);
str[size-1]= '\0';
return 0;
}
}
return -1;
}
#endif #endif
static struct my_option my_long_options[] = static struct my_option my_long_options[] =
@ -41,18 +56,18 @@ static struct my_option my_long_options[] =
{"info", 'I', "Synonym for --help.", 0, 0, 0, GET_NO_ARG, {"info", 'I', "Synonym for --help.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
{"ndb", 257, "Ndbcluster storage engine specific error codes.", (gptr*) &ndb_code, {"ndb", 257, "Ndbcluster storage engine specific error codes.", (uchar**) &ndb_code,
(gptr*) &ndb_code, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &ndb_code, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
#ifdef HAVE_SYS_ERRLIST #ifdef HAVE_SYS_ERRLIST
{"all", 'a', "Print all the error messages and the number.", {"all", 'a', "Print all the error messages and the number.",
(gptr*) &print_all_codes, (gptr*) &print_all_codes, 0, GET_BOOL, NO_ARG, (uchar**) &print_all_codes, (uchar**) &print_all_codes, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
#endif #endif
{"silent", 's', "Only print the error message.", 0, 0, 0, GET_NO_ARG, NO_ARG, {"silent", 's', "Only print the error message.", 0, 0, 0, GET_NO_ARG, NO_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"verbose", 'v', "Print error code and message (default).", (gptr*) &verbose, {"verbose", 'v', "Print error code and message (default).", (uchar**) &verbose,
(gptr*) &verbose, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, (uchar**) &verbose, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"version", 'V', "Displays version information and exits.", {"version", 'V', "Displays version information and exits.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
@ -238,8 +253,9 @@ int main(int argc,char *argv[])
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
if (ndb_code) if (ndb_code)
{ {
if ((ndb_error_string(code, ndb_string, sizeof(ndb_string)) < 0) && if ((ndb_error_string(code, ndb_string, sizeof(ndb_string)) < 0) &&
(ndbd_exit_string(code, ndb_string, sizeof(ndb_string)) < 0)) (ndbd_exit_string(code, ndb_string, sizeof(ndb_string)) < 0) &&
(mgmapi_error_string(code, ndb_string, sizeof(ndb_string)) < 0))
{ {
msg= 0; msg= 0;
} }

View File

@ -51,7 +51,7 @@
typedef struct st_pointer_array { /* when using array-strings */ typedef struct st_pointer_array { /* when using array-strings */
TYPELIB typelib; /* Pointer to strings */ TYPELIB typelib; /* Pointer to strings */
byte *str; /* Strings is here */ uchar *str; /* Strings is here */
int7 *flag; /* Flag about each var. */ int7 *flag; /* Flag about each var. */
uint array_allocs,max_count,length,max_length; uint array_allocs,max_count,length,max_length;
} POINTER_ARRAY; } POINTER_ARRAY;
@ -83,14 +83,14 @@ static int static_get_options(int *argc,char * * *argv);
static int get_replace_strings(int *argc,char * * *argv, static int get_replace_strings(int *argc,char * * *argv,
POINTER_ARRAY *from_array, POINTER_ARRAY *from_array,
POINTER_ARRAY *to_array); POINTER_ARRAY *to_array);
static int insert_pointer_name(POINTER_ARRAY *pa, my_string name); static int insert_pointer_name(POINTER_ARRAY *pa, char * name);
static void free_pointer_array(POINTER_ARRAY *pa); static void free_pointer_array(POINTER_ARRAY *pa);
static int convert_pipe(REPLACE *,FILE *,FILE *); static int convert_pipe(REPLACE *,FILE *,FILE *);
static int convert_file(REPLACE *, my_string); static int convert_file(REPLACE *, char *);
static REPLACE *init_replace(my_string *from, my_string *to,uint count, static REPLACE *init_replace(char * *from, char * *to,uint count,
my_string word_end_chars); char * word_end_chars);
static uint replace_strings(REPLACE *rep, my_string *start,uint *max_length, static uint replace_strings(REPLACE *rep, char * *start,uint *max_length,
my_string from); char * from);
static int initialize_buffer(void); static int initialize_buffer(void);
static void reset_buffer(void); static void reset_buffer(void);
static void free_buffer(void); static void free_buffer(void);
@ -245,10 +245,10 @@ POINTER_ARRAY *from_array,*to_array;
return 0; return 0;
} }
static int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name) static int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name)
{ {
uint i,length,old_count; uint i,length,old_count;
byte *new_pos; uchar *new_pos;
const char **new_array; const char **new_array;
DBUG_ENTER("insert_pointer_name"); DBUG_ENTER("insert_pointer_name");
@ -256,16 +256,16 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name)
{ {
if (!(pa->typelib.type_names=(const char **) if (!(pa->typelib.type_names=(const char **)
my_malloc(((PC_MALLOC-MALLOC_OVERHEAD)/ my_malloc(((PC_MALLOC-MALLOC_OVERHEAD)/
(sizeof(my_string)+sizeof(*pa->flag))* (sizeof(char *)+sizeof(*pa->flag))*
(sizeof(my_string)+sizeof(*pa->flag))),MYF(MY_WME)))) (sizeof(char *)+sizeof(*pa->flag))),MYF(MY_WME))))
DBUG_RETURN(-1); DBUG_RETURN(-1);
if (!(pa->str= (byte*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD), if (!(pa->str= (uchar*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD),
MYF(MY_WME)))) MYF(MY_WME))))
{ {
my_free((gptr) pa->typelib.type_names,MYF(0)); my_free((uchar*) pa->typelib.type_names,MYF(0));
DBUG_RETURN (-1); DBUG_RETURN (-1);
} }
pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(byte*)+ pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(uchar*)+
sizeof(*pa->flag)); sizeof(*pa->flag));
pa->flag= (int7*) (pa->typelib.type_names+pa->max_count); pa->flag= (int7*) (pa->typelib.type_names+pa->max_count);
pa->length=0; pa->length=0;
@ -277,7 +277,7 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name)
{ {
pa->max_length=(pa->length+length+MALLOC_OVERHEAD+PS_MALLOC-1)/PS_MALLOC; pa->max_length=(pa->length+length+MALLOC_OVERHEAD+PS_MALLOC-1)/PS_MALLOC;
pa->max_length=pa->max_length*PS_MALLOC-MALLOC_OVERHEAD; pa->max_length=pa->max_length*PS_MALLOC-MALLOC_OVERHEAD;
if (!(new_pos= (byte*) my_realloc((gptr) pa->str, if (!(new_pos= (uchar*) my_realloc((uchar*) pa->str,
(uint) pa->max_length, (uint) pa->max_length,
MYF(MY_WME)))) MYF(MY_WME))))
DBUG_RETURN(1); DBUG_RETURN(1);
@ -295,23 +295,23 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name)
int len; int len;
pa->array_allocs++; pa->array_allocs++;
len=(PC_MALLOC*pa->array_allocs - MALLOC_OVERHEAD); len=(PC_MALLOC*pa->array_allocs - MALLOC_OVERHEAD);
if (!(new_array=(const char **) my_realloc((gptr) pa->typelib.type_names, if (!(new_array=(const char **) my_realloc((uchar*) pa->typelib.type_names,
(uint) len/ (uint) len/
(sizeof(byte*)+sizeof(*pa->flag))* (sizeof(uchar*)+sizeof(*pa->flag))*
(sizeof(byte*)+sizeof(*pa->flag)), (sizeof(uchar*)+sizeof(*pa->flag)),
MYF(MY_WME)))) MYF(MY_WME))))
DBUG_RETURN(1); DBUG_RETURN(1);
pa->typelib.type_names=new_array; pa->typelib.type_names=new_array;
old_count=pa->max_count; old_count=pa->max_count;
pa->max_count=len/(sizeof(byte*) + sizeof(*pa->flag)); pa->max_count=len/(sizeof(uchar*) + sizeof(*pa->flag));
pa->flag= (int7*) (pa->typelib.type_names+pa->max_count); pa->flag= (int7*) (pa->typelib.type_names+pa->max_count);
memcpy((byte*) pa->flag,(my_string) (pa->typelib.type_names+old_count), memcpy((uchar*) pa->flag,(char *) (pa->typelib.type_names+old_count),
old_count*sizeof(*pa->flag)); old_count*sizeof(*pa->flag));
} }
pa->flag[pa->typelib.count]=0; /* Reset flag */ pa->flag[pa->typelib.count]=0; /* Reset flag */
pa->typelib.type_names[pa->typelib.count++]= pa->str+pa->length; pa->typelib.type_names[pa->typelib.count++]= (char*) (pa->str+pa->length);
pa->typelib.type_names[pa->typelib.count]= NullS; /* Put end-mark */ pa->typelib.type_names[pa->typelib.count]= NullS; /* Put end-mark */
VOID(strmov(pa->str+pa->length,name)); VOID(strmov((char*) pa->str + pa->length, name));
pa->length+=length; pa->length+=length;
DBUG_RETURN(0); DBUG_RETURN(0);
} /* insert_pointer_name */ } /* insert_pointer_name */
@ -324,9 +324,9 @@ static void free_pointer_array(reg1 POINTER_ARRAY *pa)
if (pa->typelib.count) if (pa->typelib.count)
{ {
pa->typelib.count=0; pa->typelib.count=0;
my_free((gptr) pa->typelib.type_names,MYF(0)); my_free((uchar*) pa->typelib.type_names,MYF(0));
pa->typelib.type_names=0; pa->typelib.type_names=0;
my_free((gptr) pa->str,MYF(0)); my_free((uchar*) pa->str,MYF(0));
} }
return; return;
} /* free_pointer_array */ } /* free_pointer_array */
@ -380,23 +380,23 @@ static int get_next_bit(REP_SET *set,uint lastpos);
static short find_set(REP_SETS *sets,REP_SET *find); static short find_set(REP_SETS *sets,REP_SET *find);
static short find_found(FOUND_SET *found_set,uint table_offset, static short find_found(FOUND_SET *found_set,uint table_offset,
int found_offset); int found_offset);
static uint start_at_word(my_string pos); static uint start_at_word(char * pos);
static uint end_of_word(my_string pos); static uint end_of_word(char * pos);
static uint replace_len(my_string pos); static uint replace_len(char * pos);
static uint found_sets=0; static uint found_sets=0;
/* Init a replace structure for further calls */ /* Init a replace structure for further calls */
static REPLACE *init_replace(my_string *from, my_string *to,uint count, static REPLACE *init_replace(char * *from, char * *to,uint count,
my_string word_end_chars) char * word_end_chars)
{ {
uint i,j,states,set_nr,len,result_len,max_length,found_end,bits_set,bit_nr; uint i,j,states,set_nr,len,result_len,max_length,found_end,bits_set,bit_nr;
int used_sets,chr; int used_sets,chr;
short default_state; short default_state;
char used_chars[LAST_CHAR_CODE],is_word_end[256]; char used_chars[LAST_CHAR_CODE],is_word_end[256];
my_string pos,to_pos,*to_array; char * pos, *to_pos, **to_array;
REP_SETS sets; REP_SETS sets;
REP_SET *set,*start_states,*word_states,*new_set; REP_SET *set,*start_states,*word_states,*new_set;
FOLLOWS *follow,*follow_ptr; FOLLOWS *follow,*follow_ptr;
@ -441,7 +441,7 @@ static REPLACE *init_replace(my_string *from, my_string *to,uint count,
if (!(follow=(FOLLOWS*) my_malloc((states+2)*sizeof(FOLLOWS),MYF(MY_WME)))) if (!(follow=(FOLLOWS*) my_malloc((states+2)*sizeof(FOLLOWS),MYF(MY_WME))))
{ {
free_sets(&sets); free_sets(&sets);
my_free((gptr) found_set,MYF(0)); my_free((uchar*) found_set,MYF(0));
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -632,12 +632,12 @@ static REPLACE *init_replace(my_string *from, my_string *to,uint count,
if ((replace=(REPLACE*) my_malloc(sizeof(REPLACE)*(sets.count)+ if ((replace=(REPLACE*) my_malloc(sizeof(REPLACE)*(sets.count)+
sizeof(REPLACE_STRING)*(found_sets+1)+ sizeof(REPLACE_STRING)*(found_sets+1)+
sizeof(my_string)*count+result_len, sizeof(char *)*count+result_len,
MYF(MY_WME | MY_ZEROFILL)))) MYF(MY_WME | MY_ZEROFILL))))
{ {
rep_str=(REPLACE_STRING*) (replace+sets.count); rep_str=(REPLACE_STRING*) (replace+sets.count);
to_array=(my_string*) (rep_str+found_sets+1); to_array=(char **) (rep_str+found_sets+1);
to_pos=(my_string) (to_array+count); to_pos=(char *) (to_array+count);
for (i=0 ; i < count ; i++) for (i=0 ; i < count ; i++)
{ {
to_array[i]=to_pos; to_array[i]=to_pos;
@ -663,9 +663,9 @@ static REPLACE *init_replace(my_string *from, my_string *to,uint count,
replace[i].next[j]=(REPLACE*) (rep_str+(-sets.set[i].next[j]-1)); replace[i].next[j]=(REPLACE*) (rep_str+(-sets.set[i].next[j]-1));
} }
} }
my_free((gptr) follow,MYF(0)); my_free((uchar*) follow,MYF(0));
free_sets(&sets); free_sets(&sets);
my_free((gptr) found_set,MYF(0)); my_free((uchar*) found_set,MYF(0));
DBUG_PRINT("exit",("Replace table has %d states",sets.count)); DBUG_PRINT("exit",("Replace table has %d states",sets.count));
DBUG_RETURN(replace); DBUG_RETURN(replace);
} }
@ -681,7 +681,7 @@ static int init_sets(REP_SETS *sets,uint states)
if (!(sets->bit_buffer=(uint*) my_malloc(sizeof(uint)*sets->size_of_bits* if (!(sets->bit_buffer=(uint*) my_malloc(sizeof(uint)*sets->size_of_bits*
SET_MALLOC_HUNC,MYF(MY_WME)))) SET_MALLOC_HUNC,MYF(MY_WME))))
{ {
my_free((gptr) sets->set,MYF(0)); my_free((uchar*) sets->set,MYF(0));
return 1; return 1;
} }
return 0; return 0;
@ -713,13 +713,13 @@ static REP_SET *make_new_set(REP_SETS *sets)
return set; return set;
} }
count=sets->count+sets->invisible+SET_MALLOC_HUNC; count=sets->count+sets->invisible+SET_MALLOC_HUNC;
if (!(set=(REP_SET*) my_realloc((gptr) sets->set_buffer, if (!(set=(REP_SET*) my_realloc((uchar*) sets->set_buffer,
sizeof(REP_SET)*count, sizeof(REP_SET)*count,
MYF(MY_WME)))) MYF(MY_WME))))
return 0; return 0;
sets->set_buffer=set; sets->set_buffer=set;
sets->set=set+sets->invisible; sets->set=set+sets->invisible;
if (!(bit_buffer=(uint*) my_realloc((gptr) sets->bit_buffer, if (!(bit_buffer=(uint*) my_realloc((uchar*) sets->bit_buffer,
(sizeof(uint)*sets->size_of_bits)*count, (sizeof(uint)*sets->size_of_bits)*count,
MYF(MY_WME)))) MYF(MY_WME))))
return 0; return 0;
@ -742,8 +742,8 @@ static void free_last_set(REP_SETS *sets)
static void free_sets(REP_SETS *sets) static void free_sets(REP_SETS *sets)
{ {
my_free((gptr)sets->set_buffer,MYF(0)); my_free((uchar*)sets->set_buffer,MYF(0));
my_free((gptr)sets->bit_buffer,MYF(0)); my_free((uchar*)sets->bit_buffer,MYF(0));
return; return;
} }
@ -770,13 +770,13 @@ static void or_bits(REP_SET *to,REP_SET *from)
static void copy_bits(REP_SET *to,REP_SET *from) static void copy_bits(REP_SET *to,REP_SET *from)
{ {
memcpy((byte*) to->bits,(byte*) from->bits, memcpy((uchar*) to->bits,(uchar*) from->bits,
(size_t) (sizeof(uint) * to->size_of_bits)); (size_t) (sizeof(uint) * to->size_of_bits));
} }
static int cmp_bits(REP_SET *set1,REP_SET *set2) static int cmp_bits(REP_SET *set1,REP_SET *set2)
{ {
return bcmp((byte*) set1->bits,(byte*) set2->bits, return bcmp((uchar*) set1->bits,(uchar*) set2->bits,
sizeof(uint) * set1->size_of_bits); sizeof(uint) * set1->size_of_bits);
} }
@ -847,21 +847,21 @@ static short find_found(FOUND_SET *found_set,uint table_offset,
/* Return 1 if regexp starts with \b or ends with \b*/ /* Return 1 if regexp starts with \b or ends with \b*/
static uint start_at_word(my_string pos) static uint start_at_word(char * pos)
{ {
return (((!bcmp(pos,"\\b",2) && pos[2]) || !bcmp(pos,"\\^",2)) ? 1 : 0); return (((!bcmp(pos,"\\b",2) && pos[2]) || !bcmp(pos,"\\^",2)) ? 1 : 0);
} }
static uint end_of_word(my_string pos) static uint end_of_word(char * pos)
{ {
my_string end=strend(pos); char * end=strend(pos);
return ((end > pos+2 && !bcmp(end-2,"\\b",2)) || return ((end > pos+2 && !bcmp(end-2,"\\b",2)) ||
(end >= pos+2 && !bcmp(end-2,"\\$",2))) ? (end >= pos+2 && !bcmp(end-2,"\\$",2))) ?
1 : 0; 1 : 0;
} }
static uint replace_len(my_string str) static uint replace_len(char * str)
{ {
uint len=0; uint len=0;
while (*str) while (*str)
@ -877,12 +877,12 @@ static uint replace_len(my_string str)
/* The actual loop */ /* The actual loop */
static uint replace_strings(REPLACE *rep, my_string *start,uint *max_length, static uint replace_strings(REPLACE *rep, char **start, uint *max_length,
my_string from) char *from)
{ {
reg1 REPLACE *rep_pos; reg1 REPLACE *rep_pos;
reg2 REPLACE_STRING *rep_str; reg2 REPLACE_STRING *rep_str;
my_string to,end,pos,new; char *to, *end, *pos, *new;
end=(to= *start) + *max_length-1; end=(to= *start) + *max_length-1;
rep_pos=rep+1; rep_pos=rep+1;
@ -903,7 +903,7 @@ static uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
} }
if (!(rep_str = ((REPLACE_STRING*) rep_pos))->replace_string) if (!(rep_str = ((REPLACE_STRING*) rep_pos))->replace_string)
return (uint) (to - *start)-1; return (uint) (to - *start)-1;
updated=1; /* Some my_string is replaced */ updated=1; /* Some char * is replaced */
to-=rep_str->to_offset; to-=rep_str->to_offset;
for (pos=rep_str->replace_string; *pos ; pos++) for (pos=rep_str->replace_string; *pos ; pos++)
{ {
@ -988,7 +988,8 @@ int n;
return 0; return 0;
/* Read in new stuff. */ /* Read in new stuff. */
if ((i=(int) my_read(fd, buffer + bufbytes, (uint) bufread,MYF(MY_WME))) < 0) if ((i=(int) my_read(fd, (uchar*) buffer + bufbytes,
(size_t) bufread, MYF(MY_WME))) < 0)
return -1; return -1;
/* Kludge to pretend every nonempty file ends with a newline. */ /* Kludge to pretend every nonempty file ends with a newline. */
@ -1039,7 +1040,7 @@ FILE *in,*out;
return 1; return 1;
if (!my_eof) if (!my_eof)
out_buff[length++]=save_char; /* Don't write added newline */ out_buff[length++]=save_char; /* Don't write added newline */
if (my_fwrite(out,out_buff,length,MYF(MY_WME | MY_NABP))) if (my_fwrite(out, (uchar*) out_buff, length, MYF(MY_WME | MY_NABP)))
DBUG_RETURN(1); DBUG_RETURN(1);
} }
} }
@ -1047,7 +1048,7 @@ FILE *in,*out;
} }
static int convert_file(REPLACE *rep, my_string name) static int convert_file(REPLACE *rep, char * name)
{ {
int error; int error;
FILE *in,*out; FILE *in,*out;
@ -1056,6 +1057,7 @@ static int convert_file(REPLACE *rep, my_string name)
char link_name[FN_REFLEN]; char link_name[FN_REFLEN];
#endif #endif
File temp_file; File temp_file;
size_t dir_buff_length;
DBUG_ENTER("convert_file"); DBUG_ENTER("convert_file");
/* check if name is a symlink */ /* check if name is a symlink */
@ -1065,7 +1067,7 @@ static int convert_file(REPLACE *rep, my_string name)
#endif #endif
if (!(in= my_fopen(org_name,O_RDONLY,MYF(MY_WME)))) if (!(in= my_fopen(org_name,O_RDONLY,MYF(MY_WME))))
DBUG_RETURN(1); DBUG_RETURN(1);
dirname_part(dir_buff,org_name); dirname_part(dir_buff, org_name, &dir_buff_length);
if ((temp_file= create_temp_file(tempname, dir_buff, "PR", O_WRONLY, if ((temp_file= create_temp_file(tempname, dir_buff, "PR", O_WRONLY,
MYF(MY_WME))) < 0) MYF(MY_WME))) < 0)
{ {

View File

@ -53,10 +53,10 @@ static struct my_option my_long_options[] =
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.", {"version", 'V', "Output version information and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"symbols-file", 's', "Use specified symbols file.", (gptr*) &sym_fname, {"symbols-file", 's', "Use specified symbols file.", (uchar**) &sym_fname,
(gptr*) &sym_fname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (uchar**) &sym_fname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"numeric-dump-file", 'n', "Read the dump from specified file.", {"numeric-dump-file", 'n', "Read the dump from specified file.",
(gptr*) &dump_fname, (gptr*) &dump_fname, 0, GET_STR, REQUIRED_ARG, (uchar**) &dump_fname, (uchar**) &dump_fname, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
@ -235,7 +235,7 @@ static void init_sym_table()
SYM_ENTRY se; SYM_ENTRY se;
if (init_sym_entry(&se, buf)) if (init_sym_entry(&se, buf))
continue; continue;
if (insert_dynamic(&sym_table, (gptr)&se)) if (insert_dynamic(&sym_table, (uchar*)&se))
die("insert_dynamic() failed - looks like we are out of memory"); die("insert_dynamic() failed - looks like we are out of memory");
} }
@ -255,7 +255,7 @@ static void verify_sort()
for (i = 0; i < sym_table.elements; i++) for (i = 0; i < sym_table.elements; i++)
{ {
SYM_ENTRY se; SYM_ENTRY se;
get_dynamic(&sym_table, (gptr)&se, i); get_dynamic(&sym_table, (uchar*)&se, i);
if (se.addr < last) if (se.addr < last)
die("sym table does not appear to be sorted, did you forget \ die("sym table does not appear to be sorted, did you forget \
--numeric-sort arg to nm? trouble addr = %p, last = %p", se.addr, last); --numeric-sort arg to nm? trouble addr = %p, last = %p", se.addr, last);
@ -267,16 +267,16 @@ static void verify_sort()
static SYM_ENTRY* resolve_addr(uchar* addr, SYM_ENTRY* se) static SYM_ENTRY* resolve_addr(uchar* addr, SYM_ENTRY* se)
{ {
uint i; uint i;
get_dynamic(&sym_table, (gptr)se, 0); get_dynamic(&sym_table, (uchar*)se, 0);
if (addr < se->addr) if (addr < se->addr)
return 0; return 0;
for (i = 1; i < sym_table.elements; i++) for (i = 1; i < sym_table.elements; i++)
{ {
get_dynamic(&sym_table, (gptr)se, i); get_dynamic(&sym_table, (uchar*)se, i);
if (addr < se->addr) if (addr < se->addr)
{ {
get_dynamic(&sym_table, (gptr)se, i - 1); get_dynamic(&sym_table, (uchar*)se, i - 1);
return se; return se;
} }
} }

View File

@ -43,7 +43,7 @@ static struct my_option my_long_options[] =
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"info", 'I', "Synonym for --help.", {"info", 'I', "Synonym for --help.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"silent", 's', "Be more silent.", (gptr*) &silent, (gptr*) &silent, {"silent", 's', "Be more silent.", (uchar**) &silent, (uchar**) &silent,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Displays version information and exits.", {"version", 'V', "Displays version information and exits.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
@ -83,7 +83,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
return 0; return 0;
} }
/*static my_string load_default_groups[]= { "resolveip","client",0 }; */ /*static char * load_default_groups[]= { "resolveip","client",0 }; */
static int get_options(int *argc,char ***argv) static int get_options(int *argc,char ***argv)
{ {

12
extra/yassl/CMakeLists.txt Normal file → Executable file
View File

@ -13,9 +13,15 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
ADD_DEFINITIONS("-DWIN32 -D_LIB -DYASSL_PREFIX") INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/extra/yassl/include
${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/include
${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL)
INCLUDE_DIRECTORIES(include taocrypt/include taocrypt/mySTL) ADD_DEFINITIONS("-D_LIB -DYASSL_PREFIX")
ADD_LIBRARY(yassl src/buffer.cpp src/cert_wrapper.cpp src/crypto_wrapper.cpp src/handshake.cpp src/lock.cpp
SET(YASSL_SOURCES src/buffer.cpp src/cert_wrapper.cpp src/crypto_wrapper.cpp src/handshake.cpp src/lock.cpp
src/log.cpp src/socket_wrapper.cpp src/ssl.cpp src/timer.cpp src/yassl_error.cpp src/log.cpp src/socket_wrapper.cpp src/ssl.cpp src/timer.cpp src/yassl_error.cpp
src/yassl_imp.cpp src/yassl_int.cpp) src/yassl_imp.cpp src/yassl_int.cpp)
IF(NOT SOURCE_SUBLIBS)
ADD_LIBRARY(yassl ${YASSL_SOURCES})
ENDIF(NOT SOURCE_SUBLIBS)

View File

@ -9,6 +9,7 @@
const char* SSLeay_version(int type); const char* SSLeay_version(int type);
#define SSLEAY_NUMBER_DEFINED
#define SSLEAY_VERSION 0x0900L #define SSLEAY_VERSION 0x0900L
#define SSLEAY_VERSION_NUMBER SSLEAY_VERSION #define SSLEAY_VERSION_NUMBER SSLEAY_VERSION

View File

@ -0,0 +1 @@
/* des_old.h for openvn */

View File

@ -0,0 +1,10 @@
/* evp.h for openSSL */
#ifndef SSLEAY_NUMBER_DEFINED
#define SSLEAY_NUMBER_DEFINED
/* for OpenVPN */
#define SSLEAY_VERSION_NUMBER 0x0090700f
#endif /* SSLEAY_NUMBER_DEFINED */

View File

@ -0,0 +1 @@
/* hmac.h for openvpn */

View File

@ -0,0 +1 @@
/* objects.h for openvpn */

View File

@ -30,6 +30,7 @@
#define SSL_CTX_new yaSSL_CTX_new #define SSL_CTX_new yaSSL_CTX_new
#define SSL_new yaSSL_new #define SSL_new yaSSL_new
#define SSL_set_fd yaSSL_set_fd #define SSL_set_fd yaSSL_set_fd
#define SSL_get_fd yaSSL_get_fd
#define SSL_connect yaSSL_connect #define SSL_connect yaSSL_connect
#define SSL_write yaSSL_write #define SSL_write yaSSL_write
#define SSL_read yaSSL_read #define SSL_read yaSSL_read
@ -91,6 +92,8 @@
#define SSL_set_rfd yaSSL_set_rfd #define SSL_set_rfd yaSSL_set_rfd
#define SSL_set_wfd yaSSL_set_wfd #define SSL_set_wfd yaSSL_set_wfd
#define SSL_set_shutdown yaSSL_set_shutdown #define SSL_set_shutdown yaSSL_set_shutdown
#define SSL_set_quiet_shutdown yaSSL_set_quiet_shutdown
#define SSL_get_quiet_shutdown yaSSL_get_quiet_shutdown
#define SSL_want_read yaSSL_want_read #define SSL_want_read yaSSL_want_read
#define SSL_want_write yaSSL_want_write #define SSL_want_write yaSSL_want_write
#define SSL_pending yaSSL_pending #define SSL_pending yaSSL_pending

View File

@ -0,0 +1 @@
/* sha.h for openvpn */

View File

@ -34,7 +34,7 @@
#include "rsa.h" #include "rsa.h"
#define YASSL_VERSION "1.6.5" #define YASSL_VERSION "1.7.2"
#if defined(__cplusplus) #if defined(__cplusplus)
@ -201,6 +201,7 @@ typedef int YASSL_SOCKET_T;
SSL_CTX* SSL_CTX_new(SSL_METHOD*); SSL_CTX* SSL_CTX_new(SSL_METHOD*);
SSL* SSL_new(SSL_CTX*); SSL* SSL_new(SSL_CTX*);
int SSL_set_fd (SSL*, YASSL_SOCKET_T); int SSL_set_fd (SSL*, YASSL_SOCKET_T);
YASSL_SOCKET_T SSL_get_fd(const SSL*);
int SSL_connect(SSL*); int SSL_connect(SSL*);
int SSL_write(SSL*, const void*, int); int SSL_write(SSL*, const void*, int);
int SSL_read(SSL*, void*, int); int SSL_read(SSL*, void*, int);
@ -277,6 +278,8 @@ int SSL_session_reused(SSL*);
int SSL_set_rfd(SSL*, int); int SSL_set_rfd(SSL*, int);
int SSL_set_wfd(SSL*, int); int SSL_set_wfd(SSL*, int);
void SSL_set_shutdown(SSL*, int); void SSL_set_shutdown(SSL*, int);
void SSL_set_quiet_shutdown(SSL *ssl,int mode);
int SSL_get_quiet_shutdown(SSL *ssl);
int SSL_want_read(SSL*); int SSL_want_read(SSL*);
int SSL_want_write(SSL*); int SSL_want_write(SSL*);

View File

@ -584,6 +584,7 @@ class SSL {
Socket socket_; // socket wrapper Socket socket_; // socket wrapper
Buffers buffers_; // buffered handshakes and data Buffers buffers_; // buffered handshakes and data
Log log_; // logger Log log_; // logger
bool quietShutdown_;
// optimization variables // optimization variables
bool has_data_; // buffered data ready? bool has_data_; // buffered data ready?
@ -610,6 +611,7 @@ public:
Buffers& useBuffers(); Buffers& useBuffers();
bool HasData() const; bool HasData() const;
bool GetQuietShutdown() const;
// sets // sets
void set_pending(Cipher suite); void set_pending(Cipher suite);
@ -621,6 +623,7 @@ public:
void SetError(YasslError); void SetError(YasslError);
int SetCompression(); int SetCompression();
void UnSetCompression(); void UnSetCompression();
void SetQuietShutdown(bool mode);
// helpers // helpers
bool isTLS() const; bool isTLS() const;

View File

@ -719,6 +719,10 @@ int DoProcessReply(SSL& ssl)
// add new data // add new data
uint read = ssl.useSocket().receive(buffer.get_buffer() + buffSz, ready); uint read = ssl.useSocket().receive(buffer.get_buffer() + buffSz, ready);
if (read == static_cast<uint>(-1)) {
ssl.SetError(receive_error);
return 0;
}
buffer.add_size(read); buffer.add_size(read);
uint offset = 0; uint offset = 0;
const MessageFactory& mf = ssl.getFactory().getMessage(); const MessageFactory& mf = ssl.getFactory().getMessage();

View File

@ -114,8 +114,6 @@ uint Socket::send(const byte* buf, unsigned int sz, int flags) const
const byte* pos = buf; const byte* pos = buf;
const byte* end = pos + sz; const byte* end = pos + sz;
assert(socket_ != INVALID_SOCKET);
while (pos != end) { while (pos != end) {
int sent = ::send(socket_, reinterpret_cast<const char *>(pos), int sent = ::send(socket_, reinterpret_cast<const char *>(pos),
static_cast<int>(end - pos), flags); static_cast<int>(end - pos), flags);
@ -132,7 +130,6 @@ uint Socket::send(const byte* buf, unsigned int sz, int flags) const
uint Socket::receive(byte* buf, unsigned int sz, int flags) uint Socket::receive(byte* buf, unsigned int sz, int flags)
{ {
assert(socket_ != INVALID_SOCKET);
wouldBlock_ = false; wouldBlock_ = false;
int recvd = ::recv(socket_, reinterpret_cast<char *>(buf), sz, flags); int recvd = ::recv(socket_, reinterpret_cast<char *>(buf), sz, flags);
@ -163,7 +160,6 @@ bool Socket::wait()
void Socket::shutDown(int how) void Socket::shutDown(int how)
{ {
assert(socket_ != INVALID_SOCKET);
shutdown(socket_, how); shutdown(socket_, how);
} }

View File

@ -239,6 +239,12 @@ int SSL_set_fd(SSL* ssl, YASSL_SOCKET_T fd)
} }
YASSL_SOCKET_T SSL_get_fd(const SSL* ssl)
{
return ssl->getSocket().get_fd();
}
int SSL_connect(SSL* ssl) int SSL_connect(SSL* ssl)
{ {
if (ssl->GetError() == YasslError(SSL_ERROR_WANT_READ)) if (ssl->GetError() == YasslError(SSL_ERROR_WANT_READ))
@ -411,8 +417,10 @@ int SSL_clear(SSL* ssl)
int SSL_shutdown(SSL* ssl) int SSL_shutdown(SSL* ssl)
{ {
Alert alert(warning, close_notify); if (!ssl->GetQuietShutdown()) {
sendAlert(*ssl, alert); Alert alert(warning, close_notify);
sendAlert(*ssl, alert);
}
ssl->useLog().ShowTCP(ssl->getSocket().get_fd(), true); ssl->useLog().ShowTCP(ssl->getSocket().get_fd(), true);
GetErrors().Remove(); GetErrors().Remove();
@ -421,6 +429,18 @@ int SSL_shutdown(SSL* ssl)
} }
void SSL_set_quiet_shutdown(SSL *ssl,int mode)
{
ssl->SetQuietShutdown(mode != 0);
}
int SSL_get_quiet_shutdown(SSL *ssl)
{
return ssl->GetQuietShutdown();
}
/* on by default but allow user to turn off */ /* on by default but allow user to turn off */
long SSL_CTX_set_session_cache_mode(SSL_CTX* ctx, long mode) long SSL_CTX_set_session_cache_mode(SSL_CTX* ctx, long mode)
{ {

View File

@ -291,7 +291,7 @@ const ClientKeyFactory& sslFactory::getClientKey() const
SSL::SSL(SSL_CTX* ctx) SSL::SSL(SSL_CTX* ctx)
: secure_(ctx->getMethod()->getVersion(), crypto_.use_random(), : secure_(ctx->getMethod()->getVersion(), crypto_.use_random(),
ctx->getMethod()->getSide(), ctx->GetCiphers(), ctx, ctx->getMethod()->getSide(), ctx->GetCiphers(), ctx,
ctx->GetDH_Parms().set_), has_data_(false) ctx->GetDH_Parms().set_), quietShutdown_(false), has_data_(false)
{ {
if (int err = crypto_.get_random().GetError()) { if (int err = crypto_.get_random().GetError()) {
SetError(YasslError(err)); SetError(YasslError(err));
@ -774,6 +774,13 @@ void SSL::SetError(YasslError ye)
} }
// set the quiet shutdown mode (close_nofiy not sent or received on shutdown)
void SSL::SetQuietShutdown(bool mode)
{
quietShutdown_ = mode;
}
Buffers& SSL::useBuffers() Buffers& SSL::useBuffers()
{ {
return buffers_; return buffers_;
@ -1330,6 +1337,12 @@ YasslError SSL::GetError() const
} }
bool SSL::GetQuietShutdown() const
{
return quietShutdown_;
}
bool SSL::GetMultiProtocol() const bool SSL::GetMultiProtocol() const
{ {
return secure_.GetContext()->getMethod()->multipleProtocol(); return secure_.GetContext()->getMethod()->multipleProtocol();

8
extra/yassl/taocrypt/CMakeLists.txt Normal file → Executable file
View File

@ -13,9 +13,10 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
INCLUDE_DIRECTORIES(mySTL include) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL
${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/include)
ADD_LIBRARY(taocrypt src/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp src/asn.cpp src/coding.cpp SET(TAOCRYPT_SOURCES src/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp src/asn.cpp src/coding.cpp
src/des.cpp src/dh.cpp src/dsa.cpp src/file.cpp src/hash.cpp src/integer.cpp src/md2.cpp src/des.cpp src/dh.cpp src/dsa.cpp src/file.cpp src/hash.cpp src/integer.cpp src/md2.cpp
src/md4.cpp src/md5.cpp src/misc.cpp src/random.cpp src/ripemd.cpp src/rsa.cpp src/sha.cpp src/md4.cpp src/md5.cpp src/misc.cpp src/random.cpp src/ripemd.cpp src/rsa.cpp src/sha.cpp
include/aes.hpp include/algebra.hpp include/arc4.hpp include/asn.hpp include/block.hpp include/aes.hpp include/algebra.hpp include/arc4.hpp include/asn.hpp include/block.hpp
@ -23,3 +24,6 @@ ADD_LIBRARY(taocrypt src/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp
include/error.hpp include/file.hpp include/hash.hpp include/hmac.hpp include/integer.hpp include/error.hpp include/file.hpp include/hash.hpp include/hmac.hpp include/integer.hpp
include/md2.hpp include/md5.hpp include/misc.hpp include/modarith.hpp include/modes.hpp include/md2.hpp include/md5.hpp include/misc.hpp include/modarith.hpp include/modes.hpp
include/random.hpp include/ripemd.hpp include/rsa.hpp include/sha.hpp) include/random.hpp include/ripemd.hpp include/rsa.hpp include/sha.hpp)
IF(NOT SOURCE_SUBLIBS)
ADD_LIBRARY(taocrypt ${TAOCRYPT_SOURCES})
ENDIF(NOT SOURCE_SUBLIBS)

View File

@ -107,11 +107,12 @@ void HexDecoder::Decode()
// sanity checks // sanity checks
assert( b < sizeof(hexDecode)/sizeof(hexDecode[0]) ); assert( b < sizeof(hexDecode)/sizeof(hexDecode[0]) );
assert( b2 < sizeof(hexDecode)/sizeof(hexDecode[0]) ); assert( b2 < sizeof(hexDecode)/sizeof(hexDecode[0]) );
assert( b != bad && b2 != bad );
b = hexDecode[b]; b = hexDecode[b];
b2 = hexDecode[b2]; b2 = hexDecode[b2];
assert( b != bad && b2 != bad );
decoded_[i++] = (b << 4) | b2; decoded_[i++] = (b << 4) | b2;
bytes -= 2; bytes -= 2;
} }

View File

@ -26,6 +26,11 @@ extern "C" {
// locking handled internally by library // locking handled internally by library
char CRYPTO_lock() { return 0;} char CRYPTO_lock() { return 0;}
char CRYPTO_add_lock() { return 0;} char CRYPTO_add_lock() { return 0;}
// for openvpn, test are the signatures they use
char EVP_CIPHER_CTX_init() { return 0; }
char CRYPTO_mem_ctrl() { return 0; }
} // extern "C" } // extern "C"

View File

@ -15,25 +15,24 @@
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
# MA 02111-1307, USA # MA 02111-1307, USA
# FIXME 'abi_check' should be in BUILT_SOURCES, disabled for now
BUILT_SOURCES = $(HEADERS_GEN) link_sources BUILT_SOURCES = $(HEADERS_GEN) link_sources
HEADERS_GEN = mysql_version.h my_config.h HEADERS_GEN = mysql_version.h my_config.h
HEADERS_ABI = mysql.h mysql_com.h mysql_time.h \ HEADERS_ABI = mysql.h mysql_com.h mysql_time.h \
my_list.h my_alloc.h typelib.h my_list.h my_alloc.h typelib.h mysql/plugin.h
pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \ pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \
my_xml.h mysql_embed.h \ my_xml.h mysql_embed.h \
my_pthread.h my_no_pthread.h \ my_pthread.h my_no_pthread.h \
decimal.h errmsg.h my_global.h my_net.h \ decimal.h errmsg.h my_global.h my_net.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 mysql/plugin.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 \
heap.h my_bitmap.h my_uctype.h \ heap.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 \
my_aes.h my_tree.h my_trie.h hash.h thr_alarm.h \ my_aes.h my_tree.h my_trie.h hash.h thr_alarm.h \
thr_lock.h t_ctype.h violite.h md5.h base64.h \ thr_lock.h t_ctype.h violite.h my_md5.h base64.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 \
@ -53,8 +52,11 @@ link_sources:
@yassl_h_ln_cmd@ @yassl_h_ln_cmd@
echo timestamp > link_sources echo timestamp > link_sources
my_config.h: ../config.h # We want both "my_config.h" and "config.h" that are identical, as
$(CP) ../config.h my_config.h # MySQL sources assumes the name "my_config.h", and 3rd party sources
# assumes the name "config.h".
my_config.h: config.h
$(CP) config.h my_config.h
# These files should not be included in distributions since they are # These files should not be included in distributions since they are
# generated by configure from the .h.in files # generated by configure from the .h.in files
@ -69,9 +71,8 @@ dist-hook:
abi_check: $(HEADERS_ABI) mysql_version.h mysql_h.ic abi_check: $(HEADERS_ABI) mysql_version.h mysql_h.ic
@set -ex; \ @set -ex; \
if [ @ICHECK@ != no ] ; then \ if [ @ICHECK@ != no ] ; then \
@ICHECK@ --canonify --skip-from-re /usr/ -o $@.ic mysql.h; \ @ICHECK@ --canonify --skip-from-re /usr/ -o $@ $(HEADERS_ABI); \
@ICHECK@ --compare mysql_h.ic $@.ic; \ @ICHECK@ --compare mysql_h.ic $@; \
$(RM) -f $@.ic; \
fi; \ fi; \
touch abi_check; touch abi_check;

View File

@ -112,7 +112,7 @@ extern "C" {
/* signal by closing the sockets */ /* signal by closing the sockets */
#define SIGNAL_WITH_VIO_CLOSE 1 #define SIGNAL_WITH_VIO_CLOSE 1
/* On NetWare, stack grows towards lower address*/ /* On NetWare, stack grows towards lower address */
#define STACK_DIRECTION -1 #define STACK_DIRECTION -1
/* On NetWare, we need to set stack size for threads, otherwise default 16K is used */ /* On NetWare, we need to set stack size for threads, otherwise default 16K is used */

View File

@ -15,6 +15,8 @@
/* Defines for Win32 to make it compatible for MySQL */ /* Defines for Win32 to make it compatible for MySQL */
#define BIG_TABLES
#ifdef __WIN2000__ #ifdef __WIN2000__
/* We have to do this define before including windows.h to get the AWE API /* We have to do this define before including windows.h to get the AWE API
functions */ functions */
@ -313,10 +315,10 @@ inline double ulonglong2double(ulonglong value)
#define doublestore(T,V) do { *((long *) T) = *((long*) &V); \ #define doublestore(T,V) do { *((long *) T) = *((long*) &V); \
*(((long *) T)+1) = *(((long*) &V)+1); } while(0) *(((long *) T)+1) = *(((long*) &V)+1); } while(0)
#define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); } #define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); }
#define floatstore(T,V) memcpy((byte*)(T), (byte*)(&V), sizeof(float)) #define floatstore(T,V) memcpy((uchar*)(T), (uchar*)(&V), sizeof(float))
#define floatget(V,M) memcpy((byte*)(&V), (byte*)(M), sizeof(float)) #define floatget(V,M) memcpy((uchar*)(&V), (uchar*)(M), sizeof(float))
#define float8get(V,M) doubleget((V),(M)) #define float8get(V,M) doubleget((V),(M))
#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float)) #define float4store(V,M) memcpy((uchar*) V,(uchar*) (&M),sizeof(float))
#define float8store(V,M) doublestore((V),(M)) #define float8store(V,M) doublestore((V),(M))
#endif /* _WIN64 */ #endif /* _WIN64 */
@ -353,7 +355,10 @@ inline double ulonglong2double(ulonglong value)
#define SPRINTF_RETURNS_INT #define SPRINTF_RETURNS_INT
#define HAVE_SETFILEPOINTER #define HAVE_SETFILEPOINTER
#define HAVE_VIO_READ_BUFF #define HAVE_VIO_READ_BUFF
#if defined(_MSC_VER) && _MSC_VER >= 1400
/* strnlen() appeared in Studio 2005 */
#define HAVE_STRNLEN #define HAVE_STRNLEN
#endif
#define HAVE_WINSOCK2 #define HAVE_WINSOCK2
#define strcasecmp stricmp #define strcasecmp stricmp
@ -414,16 +419,7 @@ inline double ulonglong2double(ulonglong value)
#ifdef __NT__ /* This should also work on Win98 but .. */ #ifdef __NT__ /* This should also work on Win98 but .. */
#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C)) #define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C)) #define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
#else
#define thread_safe_add(V,C,L) \
pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L));
#define thread_safe_sub(V,C,L) \
pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L));
#define statistic_add(V,C,L) (V)+=(C)
#endif #endif
#define statistic_increment(V,L) thread_safe_increment((V),(L))
#define statistic_decrement(V,L) thread_safe_decrement((V),(L))
#define shared_memory_buffer_length 16000 #define shared_memory_buffer_length 16000
#define default_shared_memory_base_name "MYSQL" #define default_shared_memory_base_name "MYSQL"

View File

@ -39,8 +39,8 @@ int longlong2decimal(longlong from, decimal_t *to);
int decimal2double(decimal_t *from, double *to); int decimal2double(decimal_t *from, double *to);
int double2decimal(double from, decimal_t *to); int double2decimal(double from, decimal_t *to);
int decimal_actual_fraction(decimal_t *from); int decimal_actual_fraction(decimal_t *from);
int decimal2bin(decimal_t *from, char *to, int precision, int scale); int decimal2bin(decimal_t *from, uchar *to, int precision, int scale);
int bin2decimal(char *from, decimal_t *to, int precision, int scale); int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale);
int decimal_size(int precision, int scale); int decimal_size(int precision, int scale);
int decimal_bin_size(int precision, int scale); int decimal_bin_size(int precision, int scale);

View File

@ -32,7 +32,7 @@ typedef struct st_ft_info FT_INFO;
struct _ft_vft struct _ft_vft
{ {
int (*read_next)(FT_INFO *, char *); int (*read_next)(FT_INFO *, char *);
float (*find_relevance)(FT_INFO *, byte *, uint); float (*find_relevance)(FT_INFO *, uchar *, uint);
void (*close_search)(FT_INFO *); void (*close_search)(FT_INFO *);
float (*get_relevance)(FT_INFO *); float (*get_relevance)(FT_INFO *);
void (*reinit_search)(FT_INFO *); void (*reinit_search)(FT_INFO *);
@ -62,8 +62,8 @@ void ft_free_stopwords(void);
#define FT_SORTED 2 #define FT_SORTED 2
#define FT_EXPAND 4 /* query expansion */ #define FT_EXPAND 4 /* query expansion */
FT_INFO *ft_init_search(uint,void *, uint, byte *, uint,CHARSET_INFO *, byte *); FT_INFO *ft_init_search(uint,void *, uint, uchar *, uint,CHARSET_INFO *, uchar *);
my_bool ft_boolean_check_syntax_string(const byte *); my_bool ft_boolean_check_syntax_string(const uchar *);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -27,12 +27,16 @@ extern "C" {
*/ */
#define HASH_OVERHEAD (sizeof(char*)*2) #define HASH_OVERHEAD (sizeof(char*)*2)
typedef byte *(*hash_get_key)(const byte *,uint*,my_bool); /* flags for hash_init */
#define HASH_UNIQUE 1 /* hash_insert fails on duplicate key */
typedef uchar *(*hash_get_key)(const uchar *,size_t*,my_bool);
typedef void (*hash_free_key)(void *); typedef void (*hash_free_key)(void *);
typedef struct st_hash { typedef struct st_hash {
uint key_offset,key_length; /* Length of key if const length */ size_t key_offset,key_length; /* Length of key if const length */
uint records, blength; size_t blength;
ulong records;
uint flags; uint flags;
DYNAMIC_ARRAY array; /* Place for hash_keys */ DYNAMIC_ARRAY array; /* Place for hash_keys */
hash_get_key get_key; hash_get_key get_key;
@ -45,21 +49,21 @@ typedef uint HASH_SEARCH_STATE;
#define hash_init(A,B,C,D,E,F,G,H) _hash_init(A,B,C,D,E,F,G, H CALLER_INFO) #define hash_init(A,B,C,D,E,F,G,H) _hash_init(A,B,C,D,E,F,G, H CALLER_INFO)
my_bool _hash_init(HASH *hash, CHARSET_INFO *charset, my_bool _hash_init(HASH *hash, CHARSET_INFO *charset,
uint default_array_elements, uint key_offset, ulong default_array_elements, size_t key_offset,
uint key_length, hash_get_key get_key, size_t key_length, hash_get_key get_key,
void (*free_element)(void*), uint flags CALLER_INFO_PROTO); void (*free_element)(void*), uint flags CALLER_INFO_PROTO);
void hash_free(HASH *tree); void hash_free(HASH *tree);
void my_hash_reset(HASH *hash); void my_hash_reset(HASH *hash);
byte *hash_element(HASH *hash,uint idx); uchar *hash_element(HASH *hash,ulong idx);
gptr hash_search(const HASH *info, const byte *key, uint length); uchar *hash_search(const HASH *info, const uchar *key, size_t length);
gptr hash_first(const HASH *info, const byte *key, uint length, uchar *hash_first(const HASH *info, const uchar *key, size_t length,
HASH_SEARCH_STATE *state); HASH_SEARCH_STATE *state);
gptr hash_next(const HASH *info, const byte *key, uint length, uchar *hash_next(const HASH *info, const uchar *key, size_t length,
HASH_SEARCH_STATE *state); HASH_SEARCH_STATE *state);
my_bool my_hash_insert(HASH *info,const byte *data); my_bool my_hash_insert(HASH *info,const uchar *data);
my_bool hash_delete(HASH *hash,byte *record); my_bool hash_delete(HASH *hash,uchar *record);
my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length); my_bool hash_update(HASH *hash,uchar *record,uchar *old_key,size_t old_key_length);
void hash_replace(HASH *hash, HASH_SEARCH_STATE *state, byte *new_row); void hash_replace(HASH *hash, HASH_SEARCH_STATE *state, uchar *new_row);
my_bool hash_check(HASH *hash); /* Only in debug library */ my_bool hash_check(HASH *hash); /* Only in debug library */
#define hash_clear(H) bzero((char*) (H),sizeof(*(H))) #define hash_clear(H) bzero((char*) (H),sizeof(*(H)))

View File

@ -57,7 +57,7 @@ typedef struct st_heapinfo /* Struct from heap_info */
typedef struct st_heap_ptrs typedef struct st_heap_ptrs
{ {
byte *blocks[HP_PTRS_IN_NOD]; /* pointers to HP_PTRS or records */ uchar *blocks[HP_PTRS_IN_NOD]; /* pointers to HP_PTRS or records */
} HP_PTRS; } HP_PTRS;
struct st_level_info struct st_level_info
@ -70,7 +70,7 @@ struct st_level_info
of last_blocks array. For level 0 - 1, for level 1 - HP_PTRS_IN_NOD, for of last_blocks array. For level 0 - 1, for level 1 - HP_PTRS_IN_NOD, for
level 2 - HP_PTRS_IN_NOD^2 and so forth. level 2 - HP_PTRS_IN_NOD^2 and so forth.
*/ */
uint records_under_level; ulong records_under_level;
/* /*
Ptr to last allocated HP_PTRS (or records buffer for level 0) on this Ptr to last allocated HP_PTRS (or records buffer for level 0) on this
@ -123,10 +123,10 @@ typedef struct st_hp_keydef /* Key definition with open */
ha_rows hash_buckets; ha_rows hash_buckets;
TREE rb_tree; TREE rb_tree;
int (*write_key)(struct st_heap_info *info, struct st_hp_keydef *keyinfo, int (*write_key)(struct st_heap_info *info, struct st_hp_keydef *keyinfo,
const byte *record, byte *recpos); const uchar *record, uchar *recpos);
int (*delete_key)(struct st_heap_info *info, struct st_hp_keydef *keyinfo, int (*delete_key)(struct st_heap_info *info, struct st_hp_keydef *keyinfo,
const byte *record, byte *recpos, int flag); const uchar *record, uchar *recpos, int flag);
uint (*get_key_length)(struct st_hp_keydef *keydef, const byte *key); uint (*get_key_length)(struct st_hp_keydef *keydef, const uchar *key);
} HP_KEYDEF; } HP_KEYDEF;
typedef struct st_heap_share typedef struct st_heap_share
@ -144,8 +144,8 @@ typedef struct st_heap_share
uint keys,max_key_length; uint keys,max_key_length;
uint currently_disabled_keys; /* saved value from "keys" when disabled */ uint currently_disabled_keys; /* saved value from "keys" when disabled */
uint open_count; uint open_count;
byte *del_link; /* Link to next block with del. rec */ uchar *del_link; /* Link to next block with del. rec */
my_string name; /* Name of "memory-file" */ char * name; /* Name of "memory-file" */
#ifdef THREAD #ifdef THREAD
THR_LOCK lock; THR_LOCK lock;
pthread_mutex_t intern_lock; /* Locking for use with _locking */ pthread_mutex_t intern_lock; /* Locking for use with _locking */
@ -162,14 +162,14 @@ struct st_hp_hash_info;
typedef struct st_heap_info typedef struct st_heap_info
{ {
HP_SHARE *s; HP_SHARE *s;
byte *current_ptr; uchar *current_ptr;
struct st_hp_hash_info *current_hash_ptr; struct st_hp_hash_info *current_hash_ptr;
ulong current_record,next_block; ulong current_record,next_block;
int lastinx,errkey; int lastinx,errkey;
int mode; /* Mode of file (READONLY..) */ int mode; /* Mode of file (READONLY..) */
uint opt_flag,update; uint opt_flag,update;
byte *lastkey; /* Last used key with rkey */ uchar *lastkey; /* Last used key with rkey */
byte *recbuf; /* Record buffer for rb-tree keys */ uchar *recbuf; /* Record buffer for rb-tree keys */
enum ha_rkey_function last_find_flag; enum ha_rkey_function last_find_flag;
TREE_ELEMENT *parents[MAX_TREE_HEIGHT+1]; TREE_ELEMENT *parents[MAX_TREE_HEIGHT+1];
TREE_ELEMENT **last_pos; TREE_ELEMENT **last_pos;
@ -189,54 +189,57 @@ typedef struct st_heap_create_info
ulonglong max_table_size; ulonglong max_table_size;
ulonglong auto_increment; ulonglong auto_increment;
my_bool with_auto_increment; my_bool with_auto_increment;
my_bool internal_table;
} HP_CREATE_INFO; } HP_CREATE_INFO;
/* Prototypes for heap-functions */ /* Prototypes for heap-functions */
extern HP_INFO *heap_open(const char *name, int mode); extern HP_INFO *heap_open(const char *name, int mode);
extern HP_INFO *heap_open_from_share(HP_SHARE *share, int mode);
extern HP_INFO *heap_open_from_share_and_register(HP_SHARE *share, int mode);
extern int heap_close(HP_INFO *info); extern int heap_close(HP_INFO *info);
extern int heap_write(HP_INFO *info,const byte *buff); extern int heap_write(HP_INFO *info,const uchar *buff);
extern int heap_update(HP_INFO *info,const byte *old,const byte *newdata); extern int heap_update(HP_INFO *info,const uchar *old,const uchar *newdata);
extern int heap_rrnd(HP_INFO *info,byte *buf,byte *pos); extern int heap_rrnd(HP_INFO *info,uchar *buf,uchar *pos);
extern int heap_scan_init(HP_INFO *info); extern int heap_scan_init(HP_INFO *info);
extern int heap_scan(register HP_INFO *info, byte *record); extern int heap_scan(register HP_INFO *info, uchar *record);
extern int heap_delete(HP_INFO *info,const byte *buff); extern int heap_delete(HP_INFO *info,const uchar *buff);
extern int heap_info(HP_INFO *info,HEAPINFO *x,int flag); extern int heap_info(HP_INFO *info,HEAPINFO *x,int flag);
extern int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, extern int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
uint reclength, ulong max_records, ulong min_records, uint reclength, ulong max_records, ulong min_records,
HP_CREATE_INFO *create_info); HP_CREATE_INFO *create_info, HP_SHARE **share);
extern int heap_delete_table(const char *name); extern int heap_delete_table(const char *name);
extern void heap_drop_table(HP_INFO *info); extern void heap_drop_table(HP_INFO *info);
extern int heap_extra(HP_INFO *info,enum ha_extra_function function); extern int heap_extra(HP_INFO *info,enum ha_extra_function function);
extern int heap_reset(HP_INFO *info); extern int heap_reset(HP_INFO *info);
extern int heap_rename(const char *old_name,const char *new_name); extern int heap_rename(const char *old_name,const char *new_name);
extern int heap_panic(enum ha_panic_function flag); extern int heap_panic(enum ha_panic_function flag);
extern int heap_rsame(HP_INFO *info,byte *record,int inx); extern int heap_rsame(HP_INFO *info,uchar *record,int inx);
extern int heap_rnext(HP_INFO *info,byte *record); extern int heap_rnext(HP_INFO *info,uchar *record);
extern int heap_rprev(HP_INFO *info,byte *record); extern int heap_rprev(HP_INFO *info,uchar *record);
extern int heap_rfirst(HP_INFO *info,byte *record,int inx); extern int heap_rfirst(HP_INFO *info,uchar *record,int inx);
extern int heap_rlast(HP_INFO *info,byte *record,int inx); extern int heap_rlast(HP_INFO *info,uchar *record,int inx);
extern void heap_clear(HP_INFO *info); extern void heap_clear(HP_INFO *info);
extern void heap_clear_keys(HP_INFO *info); extern void heap_clear_keys(HP_INFO *info);
extern int heap_disable_indexes(HP_INFO *info); extern int heap_disable_indexes(HP_INFO *info);
extern int heap_enable_indexes(HP_INFO *info); extern int heap_enable_indexes(HP_INFO *info);
extern int heap_indexes_are_disabled(HP_INFO *info); extern int heap_indexes_are_disabled(HP_INFO *info);
extern void heap_update_auto_increment(HP_INFO *info, const byte *record); extern void heap_update_auto_increment(HP_INFO *info, const uchar *record);
ha_rows hp_rb_records_in_range(HP_INFO *info, int inx, key_range *min_key, ha_rows hp_rb_records_in_range(HP_INFO *info, int inx, key_range *min_key,
key_range *max_key); key_range *max_key);
int hp_panic(enum ha_panic_function flag); int hp_panic(enum ha_panic_function flag);
int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key, int heap_rkey(HP_INFO *info, uchar *record, int inx, const uchar *key,
key_part_map keypart_map, enum ha_rkey_function find_flag); key_part_map keypart_map, enum ha_rkey_function find_flag);
extern gptr heap_find(HP_INFO *info,int inx,const byte *key); extern uchar * heap_find(HP_INFO *info,int inx,const uchar *key);
extern int heap_check_heap(HP_INFO *info, my_bool print_status); extern int heap_check_heap(HP_INFO *info, my_bool print_status);
extern byte *heap_position(HP_INFO *info); extern uchar *heap_position(HP_INFO *info);
/* The following is for programs that uses the old HEAP interface where /* The following is for programs that uses the old HEAP interface where
pointer to rows where a long instead of a (byte*). pointer to rows where a long instead of a (uchar*).
*/ */
#if defined(WANT_OLD_HEAP_VERSION) || defined(OLD_HEAP_VERSION) #if defined(WANT_OLD_HEAP_VERSION) || defined(OLD_HEAP_VERSION)
extern int heap_rrnd_old(HP_INFO *info,byte *buf,ulong pos); extern int heap_rrnd_old(HP_INFO *info,uchar *buf,ulong pos);
extern ulong heap_position_old(HP_INFO *info); extern ulong heap_position_old(HP_INFO *info);
#endif #endif
#ifdef OLD_HEAP_VERSION #ifdef OLD_HEAP_VERSION
@ -244,7 +247,7 @@ typedef ulong HEAP_PTR;
#define heap_position(A) heap_position_old(A) #define heap_position(A) heap_position_old(A)
#define heap_rrnd(A,B,C) heap_rrnd_old(A,B,C) #define heap_rrnd(A,B,C) heap_rrnd_old(A,B,C)
#else #else
typedef byte *HEAP_PTR; typedef uchar *HEAP_PTR;
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -44,10 +44,10 @@ typedef struct st_keycache_wqueue
typedef struct st_key_cache typedef struct st_key_cache
{ {
my_bool key_cache_inited; my_bool key_cache_inited;
my_bool in_resize; /* true during resize operation */
my_bool resize_in_flush; /* true during flush of resize operation */ my_bool resize_in_flush; /* true during flush of resize operation */
my_bool can_be_used; /* usage of cache for read/write is allowed */ my_bool can_be_used; /* usage of cache for read/write is allowed */
uint key_cache_shift; size_t key_cache_mem_size; /* specified size of the cache memory */
ulong key_cache_mem_size; /* specified size of the cache memory */
uint key_cache_block_size; /* size of the page buffer of a cache block */ uint key_cache_block_size; /* size of the page buffer of a cache block */
ulong min_warm_blocks; /* min number of warm blocks; */ ulong min_warm_blocks; /* min number of warm blocks; */
ulong age_threshold; /* age threshold for hot blocks */ ulong age_threshold; /* age threshold for hot blocks */
@ -65,13 +65,18 @@ typedef struct st_key_cache
HASH_LINK **hash_root; /* arr. of entries into hash table buckets */ HASH_LINK **hash_root; /* arr. of entries into hash table buckets */
HASH_LINK *hash_link_root; /* memory for hash table links */ HASH_LINK *hash_link_root; /* memory for hash table links */
HASH_LINK *free_hash_list; /* list of free hash links */ HASH_LINK *free_hash_list; /* list of free hash links */
BLOCK_LINK *free_block_list; /* list of free blocks */ BLOCK_LINK *free_block_list; /* list of free blocks */
BLOCK_LINK *block_root; /* memory for block links */ BLOCK_LINK *block_root; /* memory for block links */
byte HUGE_PTR *block_mem; /* memory for block buffers */ uchar HUGE_PTR *block_mem; /* memory for block buffers */
BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */ BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */
BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */ BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */
pthread_mutex_t cache_lock; /* to lock access to the cache structure */ pthread_mutex_t cache_lock; /* to lock access to the cache structure */
KEYCACHE_WQUEUE resize_queue; /* threads waiting during resize operation */ KEYCACHE_WQUEUE resize_queue; /* threads waiting during resize operation */
/*
Waiting for a zero resize count. Using a queue for symmetry though
only one thread can wait here.
*/
KEYCACHE_WQUEUE waiting_for_resize_cnt;
KEYCACHE_WQUEUE waiting_for_hash_link; /* waiting for a free hash link */ KEYCACHE_WQUEUE waiting_for_hash_link; /* waiting for a free hash link */
KEYCACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */ KEYCACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */
BLOCK_LINK *changed_blocks[CHANGED_BLOCKS_HASH]; /* hash for dirty file bl.*/ BLOCK_LINK *changed_blocks[CHANGED_BLOCKS_HASH]; /* hash for dirty file bl.*/
@ -102,23 +107,23 @@ typedef struct st_key_cache
extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache; extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache;
extern int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, extern int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
ulong use_mem, uint division_limit, size_t use_mem, uint division_limit,
uint age_threshold); uint age_threshold);
extern int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, extern int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
ulong use_mem, uint division_limit, size_t use_mem, uint division_limit,
uint age_threshold); uint age_threshold);
extern void change_key_cache_param(KEY_CACHE *keycache, uint division_limit, extern void change_key_cache_param(KEY_CACHE *keycache, uint division_limit,
uint age_threshold); uint age_threshold);
extern byte *key_cache_read(KEY_CACHE *keycache, extern uchar *key_cache_read(KEY_CACHE *keycache,
File file, my_off_t filepos, int level, File file, my_off_t filepos, int level,
byte *buff, uint length, uchar *buff, uint length,
uint block_length,int return_buffer); uint block_length,int return_buffer);
extern int key_cache_insert(KEY_CACHE *keycache, extern int key_cache_insert(KEY_CACHE *keycache,
File file, my_off_t filepos, int level, File file, my_off_t filepos, int level,
byte *buff, uint length); uchar *buff, uint length);
extern int key_cache_write(KEY_CACHE *keycache, extern int key_cache_write(KEY_CACHE *keycache,
File file, my_off_t filepos, int level, File file, my_off_t filepos, int level,
byte *buff, uint length, uchar *buff, uint length,
uint block_length,int force_write); uint block_length,int force_write);
extern int flush_key_blocks(KEY_CACHE *keycache, extern int flush_key_blocks(KEY_CACHE *keycache,
int file, enum flush_type type); int file, enum flush_type type);
@ -127,8 +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(byte *key, uint length); extern KEY_CACHE *multi_key_cache_search(uchar *key, uint length);
extern my_bool multi_key_cache_set(const byte *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,
KEY_CACHE *new_data); KEY_CACHE *new_data);

View File

@ -51,8 +51,8 @@ extern MY_UNICASE_INFO *my_unicase_turkish[256];
typedef struct uni_ctype_st typedef struct uni_ctype_st
{ {
unsigned char pctype; uchar pctype;
unsigned char *ctype; uchar *ctype;
} MY_UNI_CTYPE; } MY_UNI_CTYPE;
extern MY_UNI_CTYPE my_uni_ctype[256]; extern MY_UNI_CTYPE my_uni_ctype[256];
@ -84,10 +84,16 @@ extern MY_UNI_CTYPE my_uni_ctype[256];
#define MY_CS_UNICODE 128 /* is a charset is full unicode */ #define MY_CS_UNICODE 128 /* is a charset is full unicode */
#define MY_CS_READY 256 /* if a charset is initialized */ #define MY_CS_READY 256 /* if a charset is initialized */
#define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/ #define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/
#define MY_CS_CSSORT 1024 /* if case sensitive sort order */ #define MY_CS_CSSORT 1024 /* if case sensitive sort order */
#define MY_CS_HIDDEN 2048 /* don't display in SHOW */ #define MY_CS_HIDDEN 2048 /* don't display in SHOW */
#define MY_CS_PUREASCII 4096 /* if a charset is pure ascii */
#define MY_CHARSET_UNDEFINED 0 #define MY_CHARSET_UNDEFINED 0
/* Character repertoire flags */
#define MY_REPERTOIRE_ASCII 1 /* Pure ASCII U+0000..U+007F */
#define MY_REPERTOIRE_EXTENDED 2 /* Extended characters: U+0080..U+FFFF */
#define MY_REPERTOIRE_UNICODE30 3 /* ASCII | EXTENDED: U+0000..U+FFFF */
typedef struct my_uni_idx_st typedef struct my_uni_idx_st
{ {
@ -125,22 +131,22 @@ struct charset_info_st;
/* See strings/CHARSET_INFO.txt for information about this structure */ /* See strings/CHARSET_INFO.txt for information about this structure */
typedef struct my_collation_handler_st typedef struct my_collation_handler_st
{ {
my_bool (*init)(struct charset_info_st *, void *(*alloc)(uint)); my_bool (*init)(struct charset_info_st *, void *(*alloc)(size_t));
/* Collation routines */ /* Collation routines */
int (*strnncoll)(struct charset_info_st *, int (*strnncoll)(struct charset_info_st *,
const uchar *, uint, const uchar *, uint, my_bool); const uchar *, size_t, const uchar *, size_t, my_bool);
int (*strnncollsp)(struct charset_info_st *, int (*strnncollsp)(struct charset_info_st *,
const uchar *, uint, const uchar *, uint, const uchar *, size_t, const uchar *, size_t,
my_bool diff_if_only_endspace_difference); my_bool diff_if_only_endspace_difference);
int (*strnxfrm)(struct charset_info_st *, size_t (*strnxfrm)(struct charset_info_st *,
uchar *, uint, const uchar *, uint); uchar *, size_t, const uchar *, size_t);
uint (*strnxfrmlen)(struct charset_info_st *, uint); size_t (*strnxfrmlen)(struct charset_info_st *, size_t);
my_bool (*like_range)(struct charset_info_st *, my_bool (*like_range)(struct charset_info_st *,
const char *s, uint s_length, const char *s, size_t s_length,
pchar w_prefix, pchar w_one, pchar w_many, pchar w_prefix, pchar w_one, pchar w_many,
uint res_length, size_t res_length,
char *min_str, char *max_str, char *min_str, char *max_str,
uint *min_len, uint *max_len); size_t *min_len, size_t *max_len);
int (*wildcmp)(struct charset_info_st *, int (*wildcmp)(struct charset_info_st *,
const char *str,const char *str_end, const char *str,const char *str_end,
const char *wildstr,const char *wildend, const char *wildstr,const char *wildend,
@ -149,14 +155,14 @@ typedef struct my_collation_handler_st
int (*strcasecmp)(struct charset_info_st *, const char *, const char *); int (*strcasecmp)(struct charset_info_st *, const char *, const char *);
uint (*instr)(struct charset_info_st *, uint (*instr)(struct charset_info_st *,
const char *b, uint b_length, const char *b, size_t b_length,
const char *s, uint s_length, const char *s, size_t s_length,
my_match_t *match, uint nmatch); my_match_t *match, uint nmatch);
/* Hash calculation */ /* Hash calculation */
void (*hash_sort)(struct charset_info_st *cs, const uchar *key, uint len, void (*hash_sort)(struct charset_info_st *cs, const uchar *key, size_t len,
ulong *nr1, ulong *nr2); ulong *nr1, ulong *nr2);
my_bool (*propagate)(struct charset_info_st *cs, const uchar *str, uint len); my_bool (*propagate)(struct charset_info_st *cs, const uchar *str, size_t len);
} MY_COLLATION_HANDLER; } MY_COLLATION_HANDLER;
extern MY_COLLATION_HANDLER my_collation_mb_bin_handler; extern MY_COLLATION_HANDLER my_collation_mb_bin_handler;
@ -164,68 +170,76 @@ extern MY_COLLATION_HANDLER my_collation_8bit_bin_handler;
extern MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler; extern MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler;
extern MY_COLLATION_HANDLER my_collation_ucs2_uca_handler; extern MY_COLLATION_HANDLER my_collation_ucs2_uca_handler;
/* Some typedef to make it easy for C++ to make function pointers */
typedef int (*my_charset_conv_mb_wc)(struct charset_info_st *, my_wc_t *,
const uchar *, const uchar *);
typedef int (*my_charset_conv_wc_mb)(struct charset_info_st *, my_wc_t,
uchar *, uchar *);
typedef size_t (*my_charset_conv_case)(struct charset_info_st *,
char *, size_t, char *, size_t);
/* See strings/CHARSET_INFO.txt about information on this structure */ /* See strings/CHARSET_INFO.txt about information on this structure */
typedef struct my_charset_handler_st typedef struct my_charset_handler_st
{ {
my_bool (*init)(struct charset_info_st *, void *(*alloc)(uint)); my_bool (*init)(struct charset_info_st *, void *(*alloc)(size_t));
/* Multibyte routines */ /* Multibyte routines */
int (*ismbchar)(struct charset_info_st *, const char *, const char *); uint (*ismbchar)(struct charset_info_st *, const char *, const char *);
int (*mbcharlen)(struct charset_info_st *, uint); uint (*mbcharlen)(struct charset_info_st *, uint c);
uint (*numchars)(struct charset_info_st *, const char *b, const char *e); size_t (*numchars)(struct charset_info_st *, const char *b, const char *e);
uint (*charpos)(struct charset_info_st *, const char *b, const char *e, uint pos); size_t (*charpos)(struct charset_info_st *, const char *b, const char *e,
uint (*well_formed_len)(struct charset_info_st *, size_t pos);
size_t (*well_formed_len)(struct charset_info_st *,
const char *b,const char *e, const char *b,const char *e,
uint nchars, int *error); size_t nchars, int *error);
uint (*lengthsp)(struct charset_info_st *, const char *ptr, uint length); size_t (*lengthsp)(struct charset_info_st *, const char *ptr, size_t length);
uint (*numcells)(struct charset_info_st *, const char *b, const char *e); size_t (*numcells)(struct charset_info_st *, const char *b, const char *e);
/* Unicode conversion */ /* Unicode conversion */
int (*mb_wc)(struct charset_info_st *cs,my_wc_t *wc, my_charset_conv_mb_wc mb_wc;
const unsigned char *s,const unsigned char *e); my_charset_conv_wc_mb wc_mb;
int (*wc_mb)(struct charset_info_st *cs,my_wc_t wc,
unsigned char *s,unsigned char *e);
/* CTYPE scanner */ /* CTYPE scanner */
int (*ctype)(struct charset_info_st *cs, int *ctype, int (*ctype)(struct charset_info_st *cs, int *ctype,
const unsigned char *s, const unsigned char *e); const uchar *s, const uchar *e);
/* Functions for case and sort conversion */ /* Functions for case and sort conversion */
uint (*caseup_str)(struct charset_info_st *, char *); size_t (*caseup_str)(struct charset_info_st *, char *);
uint (*casedn_str)(struct charset_info_st *, char *); size_t (*casedn_str)(struct charset_info_st *, char *);
uint (*caseup)(struct charset_info_st *, char *src, uint srclen,
char *dst, uint dstlen); my_charset_conv_case caseup;
uint (*casedn)(struct charset_info_st *, char *src, uint srclen, my_charset_conv_case casedn;
char *dst, uint dstlen);
/* Charset dependant snprintf() */ /* Charset dependant snprintf() */
int (*snprintf)(struct charset_info_st *, char *to, uint n, const char *fmt, size_t (*snprintf)(struct charset_info_st *, char *to, size_t n,
...) ATTRIBUTE_FORMAT_FPTR(printf, 4, 5); const char *fmt,
int (*long10_to_str)(struct charset_info_st *, char *to, uint n, int radix, ...) ATTRIBUTE_FORMAT_FPTR(printf, 4, 5);
long int val); size_t (*long10_to_str)(struct charset_info_st *, char *to, size_t n,
int (*longlong10_to_str)(struct charset_info_st *, char *to, uint n, int radix, long int val);
int radix, longlong val); size_t (*longlong10_to_str)(struct charset_info_st *, char *to, size_t n,
int radix, longlong val);
void (*fill)(struct charset_info_st *, char *to, uint len, int fill); void (*fill)(struct charset_info_st *, char *to, size_t len, int fill);
/* String-to-number conversion routines */ /* String-to-number conversion routines */
long (*strntol)(struct charset_info_st *, const char *s, uint l, long (*strntol)(struct charset_info_st *, const char *s, size_t l,
int base, char **e, int *err); int base, char **e, int *err);
ulong (*strntoul)(struct charset_info_st *, const char *s, uint l, ulong (*strntoul)(struct charset_info_st *, const char *s, size_t l,
int base, char **e, int *err); int base, char **e, int *err);
longlong (*strntoll)(struct charset_info_st *, const char *s, uint l, longlong (*strntoll)(struct charset_info_st *, const char *s, size_t l,
int base, char **e, int *err); int base, char **e, int *err);
ulonglong (*strntoull)(struct charset_info_st *, const char *s, uint l, ulonglong (*strntoull)(struct charset_info_st *, const char *s, size_t l,
int base, char **e, int *err); int base, char **e, int *err);
double (*strntod)(struct charset_info_st *, char *s, uint l, char **e, double (*strntod)(struct charset_info_st *, char *s, size_t l, char **e,
int *err); int *err);
longlong (*strtoll10)(struct charset_info_st *cs, longlong (*strtoll10)(struct charset_info_st *cs,
const char *nptr, char **endptr, int *error); const char *nptr, char **endptr, int *error);
ulonglong (*strntoull10rnd)(struct charset_info_st *cs, ulonglong (*strntoull10rnd)(struct charset_info_st *cs,
const char *str, uint length, int unsigned_fl, const char *str, size_t length,
int unsigned_fl,
char **endptr, int *error); char **endptr, int *error);
ulong (*scan)(struct charset_info_st *, const char *b, const char *e, size_t (*scan)(struct charset_info_st *, const char *b, const char *e,
int sq); int sq);
} MY_CHARSET_HANDLER; } MY_CHARSET_HANDLER;
extern MY_CHARSET_HANDLER my_charset_8bit_handler; extern MY_CHARSET_HANDLER my_charset_8bit_handler;
@ -293,44 +307,45 @@ extern CHARSET_INFO my_charset_tis620_thai_ci;
extern CHARSET_INFO my_charset_tis620_bin; extern CHARSET_INFO my_charset_tis620_bin;
extern CHARSET_INFO my_charset_ucs2_general_ci; extern CHARSET_INFO my_charset_ucs2_general_ci;
extern CHARSET_INFO my_charset_ucs2_bin; extern CHARSET_INFO my_charset_ucs2_bin;
extern CHARSET_INFO my_charset_ucs2_general_uca; extern CHARSET_INFO my_charset_ucs2_unicode_ci;
extern CHARSET_INFO my_charset_ujis_japanese_ci; extern CHARSET_INFO my_charset_ujis_japanese_ci;
extern CHARSET_INFO my_charset_ujis_bin; extern CHARSET_INFO my_charset_ujis_bin;
extern CHARSET_INFO my_charset_utf8_general_ci; extern CHARSET_INFO my_charset_utf8_general_ci;
extern CHARSET_INFO my_charset_utf8_unicode_ci;
extern CHARSET_INFO my_charset_utf8_bin; extern CHARSET_INFO my_charset_utf8_bin;
extern CHARSET_INFO my_charset_cp1250_czech_ci; extern CHARSET_INFO my_charset_cp1250_czech_ci;
extern CHARSET_INFO my_charset_filename; extern CHARSET_INFO my_charset_filename;
/* declarations for simple charsets */ /* declarations for simple charsets */
extern int my_strnxfrm_simple(CHARSET_INFO *, uchar *, uint, const uchar *, extern size_t my_strnxfrm_simple(CHARSET_INFO *, uchar *, size_t,
uint); const uchar *, size_t);
uint my_strnxfrmlen_simple(CHARSET_INFO *, uint); size_t my_strnxfrmlen_simple(CHARSET_INFO *, size_t);
extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, uint, extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, size_t,
const uchar *, uint, my_bool); const uchar *, size_t, my_bool);
extern int my_strnncollsp_simple(CHARSET_INFO *, const uchar *, uint, extern int my_strnncollsp_simple(CHARSET_INFO *, const uchar *, size_t,
const uchar *, uint, const uchar *, size_t,
my_bool diff_if_only_endspace_difference); my_bool diff_if_only_endspace_difference);
extern void my_hash_sort_simple(CHARSET_INFO *cs, extern void my_hash_sort_simple(CHARSET_INFO *cs,
const uchar *key, uint len, const uchar *key, size_t len,
ulong *nr1, ulong *nr2); ulong *nr1, ulong *nr2);
extern uint my_lengthsp_8bit(CHARSET_INFO *cs, const char *ptr, uint length); extern size_t my_lengthsp_8bit(CHARSET_INFO *cs, const char *ptr, size_t length);
extern uint my_instr_simple(struct charset_info_st *, extern uint my_instr_simple(struct charset_info_st *,
const char *b, uint b_length, const char *b, size_t b_length,
const char *s, uint s_length, const char *s, size_t s_length,
my_match_t *match, uint nmatch); my_match_t *match, uint nmatch);
/* Functions for 8bit */ /* Functions for 8bit */
extern uint my_caseup_str_8bit(CHARSET_INFO *, char *); extern size_t my_caseup_str_8bit(CHARSET_INFO *, char *);
extern uint my_casedn_str_8bit(CHARSET_INFO *, char *); extern size_t my_casedn_str_8bit(CHARSET_INFO *, char *);
extern uint my_caseup_8bit(CHARSET_INFO *, char *src, uint srclen, extern size_t my_caseup_8bit(CHARSET_INFO *, char *src, size_t srclen,
char *dst, uint dstlen); char *dst, size_t dstlen);
extern uint my_casedn_8bit(CHARSET_INFO *, char *src, uint srclen, extern size_t my_casedn_8bit(CHARSET_INFO *, char *src, size_t srclen,
char *dst, uint dstlen); char *dst, size_t dstlen);
extern int my_strcasecmp_8bit(CHARSET_INFO * cs, const char *, const char *); extern int my_strcasecmp_8bit(CHARSET_INFO * cs, const char *, const char *);
@ -340,26 +355,26 @@ int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc, uchar *s, uchar *e);
int my_mb_ctype_8bit(CHARSET_INFO *,int *, const uchar *,const uchar *); int my_mb_ctype_8bit(CHARSET_INFO *,int *, const uchar *,const uchar *);
int my_mb_ctype_mb(CHARSET_INFO *,int *, const uchar *,const uchar *); int my_mb_ctype_mb(CHARSET_INFO *,int *, const uchar *,const uchar *);
ulong my_scan_8bit(CHARSET_INFO *cs, const char *b, const char *e, int sq); size_t my_scan_8bit(CHARSET_INFO *cs, const char *b, const char *e, int sq);
int my_snprintf_8bit(struct charset_info_st *, char *to, uint n, size_t my_snprintf_8bit(struct charset_info_st *, char *to, size_t n,
const char *fmt, ...) const char *fmt, ...)
ATTRIBUTE_FORMAT(printf, 4, 5); ATTRIBUTE_FORMAT(printf, 4, 5);
long my_strntol_8bit(CHARSET_INFO *, const char *s, uint l, int base, long my_strntol_8bit(CHARSET_INFO *, const char *s, size_t l, int base,
char **e, int *err);
ulong my_strntoul_8bit(CHARSET_INFO *, const char *s, size_t l, int base,
char **e, int *err); char **e, int *err);
ulong my_strntoul_8bit(CHARSET_INFO *, const char *s, uint l, int base, longlong my_strntoll_8bit(CHARSET_INFO *, const char *s, size_t l, int base,
char **e, int *err); char **e, int *err);
longlong my_strntoll_8bit(CHARSET_INFO *, const char *s, uint l, int base, ulonglong my_strntoull_8bit(CHARSET_INFO *, const char *s, size_t l, int base,
char **e, int *err); char **e, int *err);
ulonglong my_strntoull_8bit(CHARSET_INFO *, const char *s, uint l, int base, double my_strntod_8bit(CHARSET_INFO *, char *s, size_t l,char **e,
char **e, int *err);
double my_strntod_8bit(CHARSET_INFO *, char *s, uint l,char **e,
int *err); int *err);
int my_long10_to_str_8bit(CHARSET_INFO *, char *to, uint l, int radix, size_t my_long10_to_str_8bit(CHARSET_INFO *, char *to, size_t l, int radix,
long int val); long int val);
int my_longlong10_to_str_8bit(CHARSET_INFO *, char *to, uint l, int radix, size_t my_longlong10_to_str_8bit(CHARSET_INFO *, char *to, size_t l, int radix,
longlong val); longlong val);
longlong my_strtoll10_8bit(CHARSET_INFO *cs, longlong my_strtoll10_8bit(CHARSET_INFO *cs,
const char *nptr, char **endptr, int *error); const char *nptr, char **endptr, int *error);
@ -367,34 +382,34 @@ longlong my_strtoll10_ucs2(CHARSET_INFO *cs,
const char *nptr, char **endptr, int *error); const char *nptr, char **endptr, int *error);
ulonglong my_strntoull10rnd_8bit(CHARSET_INFO *cs, ulonglong my_strntoull10rnd_8bit(CHARSET_INFO *cs,
const char *str, uint length, int unsigned_fl, const char *str, size_t length, int
char **endptr, int *error); unsigned_fl, char **endptr, int *error);
ulonglong my_strntoull10rnd_ucs2(CHARSET_INFO *cs, ulonglong my_strntoull10rnd_ucs2(CHARSET_INFO *cs,
const char *str, uint length, int unsigned_fl, const char *str, size_t length,
char **endptr, int *error); int unsigned_fl, char **endptr, int *error);
void my_fill_8bit(CHARSET_INFO *cs, char* to, uint l, int fill); void my_fill_8bit(CHARSET_INFO *cs, char* to, size_t l, int fill);
my_bool my_like_range_simple(CHARSET_INFO *cs, my_bool my_like_range_simple(CHARSET_INFO *cs,
const char *ptr, uint ptr_length, const char *ptr, size_t ptr_length,
pbool escape, pbool w_one, pbool w_many, pbool escape, pbool w_one, pbool w_many,
uint res_length, size_t res_length,
char *min_str, char *max_str, char *min_str, char *max_str,
uint *min_length, uint *max_length); size_t *min_length, size_t *max_length);
my_bool my_like_range_mb(CHARSET_INFO *cs, my_bool my_like_range_mb(CHARSET_INFO *cs,
const char *ptr, uint ptr_length, const char *ptr, size_t ptr_length,
pbool escape, pbool w_one, pbool w_many, pbool escape, pbool w_one, pbool w_many,
uint res_length, size_t res_length,
char *min_str, char *max_str, char *min_str, char *max_str,
uint *min_length, uint *max_length); size_t *min_length, size_t *max_length);
my_bool my_like_range_ucs2(CHARSET_INFO *cs, my_bool my_like_range_ucs2(CHARSET_INFO *cs,
const char *ptr, uint ptr_length, const char *ptr, size_t ptr_length,
pbool escape, pbool w_one, pbool w_many, pbool escape, pbool w_one, pbool w_many,
uint res_length, size_t res_length,
char *min_str, char *max_str, char *min_str, char *max_str,
uint *min_length, uint *max_length); size_t *min_length, size_t *max_length);
int my_wildcmp_8bit(CHARSET_INFO *, int my_wildcmp_8bit(CHARSET_INFO *,
@ -407,35 +422,35 @@ int my_wildcmp_bin(CHARSET_INFO *,
const char *wildstr,const char *wildend, const char *wildstr,const char *wildend,
int escape, int w_one, int w_many); int escape, int w_one, int w_many);
uint my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e); size_t my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e);
uint my_numcells_8bit(CHARSET_INFO *, const char *b, const char *e); size_t my_numcells_8bit(CHARSET_INFO *, const char *b, const char *e);
uint my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos); size_t my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, size_t pos);
uint my_well_formed_len_8bit(CHARSET_INFO *, const char *b, const char *e, size_t my_well_formed_len_8bit(CHARSET_INFO *, const char *b, const char *e,
uint pos, int *error); size_t pos, int *error);
int my_mbcharlen_8bit(CHARSET_INFO *, uint c); uint my_mbcharlen_8bit(CHARSET_INFO *, uint c);
/* Functions for multibyte charsets */ /* Functions for multibyte charsets */
extern uint my_caseup_str_mb(CHARSET_INFO *, char *); extern size_t my_caseup_str_mb(CHARSET_INFO *, char *);
extern uint my_casedn_str_mb(CHARSET_INFO *, char *); extern size_t my_casedn_str_mb(CHARSET_INFO *, char *);
extern uint my_caseup_mb(CHARSET_INFO *, char *src, uint srclen, extern size_t my_caseup_mb(CHARSET_INFO *, char *src, size_t srclen,
char *dst, uint dstlen); char *dst, size_t dstlen);
extern uint my_casedn_mb(CHARSET_INFO *, char *src, uint srclen, extern size_t my_casedn_mb(CHARSET_INFO *, char *src, size_t srclen,
char *dst, uint dstlen); char *dst, size_t dstlen);
extern int my_strcasecmp_mb(CHARSET_INFO * cs,const char *, const char *); extern int my_strcasecmp_mb(CHARSET_INFO * cs,const char *, const char *);
int my_wildcmp_mb(CHARSET_INFO *, int my_wildcmp_mb(CHARSET_INFO *,
const char *str,const char *str_end, const char *str,const char *str_end,
const char *wildstr,const char *wildend, const char *wildstr,const char *wildend,
int escape, int w_one, int w_many); int escape, int w_one, int w_many);
uint my_numchars_mb(CHARSET_INFO *, const char *b, const char *e); size_t my_numchars_mb(CHARSET_INFO *, const char *b, const char *e);
uint my_numcells_mb(CHARSET_INFO *, const char *b, const char *e); size_t my_numcells_mb(CHARSET_INFO *, const char *b, const char *e);
uint my_charpos_mb(CHARSET_INFO *, const char *b, const char *e, uint pos); size_t my_charpos_mb(CHARSET_INFO *, const char *b, const char *e, size_t pos);
uint my_well_formed_len_mb(CHARSET_INFO *, const char *b, const char *e, size_t my_well_formed_len_mb(CHARSET_INFO *, const char *b, const char *e,
uint pos, int *error); size_t pos, int *error);
uint my_instr_mb(struct charset_info_st *, uint my_instr_mb(struct charset_info_st *,
const char *b, uint b_length, const char *b, size_t b_length,
const char *s, uint s_length, const char *s, size_t s_length,
my_match_t *match, uint nmatch); my_match_t *match, uint nmatch);
int my_wildcmp_unicode(CHARSET_INFO *cs, int my_wildcmp_unicode(CHARSET_INFO *cs,
@ -444,13 +459,18 @@ int my_wildcmp_unicode(CHARSET_INFO *cs,
int escape, int w_one, int w_many, int escape, int w_one, int w_many,
MY_UNICASE_INFO **weights); MY_UNICASE_INFO **weights);
extern my_bool my_parse_charset_xml(const char *bug, uint len, extern my_bool my_parse_charset_xml(const char *bug, size_t len,
int (*add)(CHARSET_INFO *cs)); int (*add)(CHARSET_INFO *cs));
extern char *my_strchr(CHARSET_INFO *cs, const char *str, const char *end, extern char *my_strchr(CHARSET_INFO *cs, const char *str, const char *end,
pchar c); pchar c);
my_bool my_propagate_simple(CHARSET_INFO *cs, const uchar *str, uint len); my_bool my_propagate_simple(CHARSET_INFO *cs, const uchar *str, size_t len);
my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, uint len); my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, size_t len);
uint my_string_repertoire(CHARSET_INFO *cs, const char *str, ulong len);
my_bool my_charset_is_ascii_based(CHARSET_INFO *cs);
my_bool my_charset_is_8bit_pure_ascii(CHARSET_INFO *cs);
#define _MY_U 01 /* Upper case */ #define _MY_U 01 /* Upper case */

View File

@ -92,6 +92,9 @@ extern char *stpcpy(char *, const char *); /* For AIX with gcc 2.95.3 */
extern char NEAR _dig_vec_upper[]; extern char NEAR _dig_vec_upper[];
extern char NEAR _dig_vec_lower[]; extern char NEAR _dig_vec_lower[];
/* Defined in strtod.c */
extern const double log_10[309];
#ifdef BAD_STRING_COMPILER #ifdef BAD_STRING_COMPILER
#define strmov(A,B) (memccpy(A,B,0,INT_MAX)-1) #define strmov(A,B) (memccpy(A,B,0,INT_MAX)-1)
#else #else
@ -112,59 +115,59 @@ extern char NEAR _dig_vec_lower[];
/* Prototypes for string functions */ /* Prototypes for string functions */
#if !defined(bfill) && !defined(HAVE_BFILL) #if !defined(bfill) && !defined(HAVE_BFILL)
extern void bfill(gptr dst,uint len,pchar fill); extern void bfill(uchar *dst,size_t len,pchar fill);
#endif #endif
#if !defined(bzero) && !defined(HAVE_BZERO) #if !defined(bzero) && !defined(HAVE_BZERO)
extern void bzero(gptr dst,uint len); extern void bzero(uchar * dst,size_t len);
#endif #endif
#if !defined(bcmp) && !defined(HAVE_BCMP) #if !defined(bcmp) && !defined(HAVE_BCMP)
extern int bcmp(const char *s1,const char *s2,uint len); extern size_t bcmp(const uchar *s1,const uchar *s2,size_t len);
#endif #endif
#ifdef HAVE_purify #ifdef HAVE_purify
extern int my_bcmp(const char *s1,const char *s2,uint 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 #endif
#ifndef bmove512 #ifndef bmove512
extern void bmove512(gptr dst,const gptr src,uint len); extern void bmove512(uchar *dst,const uchar *src,size_t len);
#endif #endif
#if !defined(HAVE_BMOVE) && !defined(bmove) #if !defined(HAVE_BMOVE) && !defined(bmove)
extern void bmove(char *dst, const char *src,uint len); extern void bmove(uuchar *dst, const uchar *src,size_t len);
#endif #endif
extern void bmove_upp(char *dst,const char *src,uint len); extern void bmove_upp(uchar *dst,const uchar *src,size_t len);
extern void bchange(char *dst,uint old_len,const char *src, extern void bchange(uchar *dst,size_t old_len,const uchar *src,
uint new_len,uint tot_len); size_t new_len,size_t tot_len);
extern void strappend(char *s,uint len,pchar fill); extern void strappend(char *s,size_t len,pchar fill);
extern char *strend(const char *s); extern char *strend(const char *s);
extern char *strcend(const char *, pchar); extern char *strcend(const char *, pchar);
extern char *strfield(char *src,int fields,int chars,int blanks, extern char *strfield(char *src,int fields,int chars,int blanks,
int tabch); int tabch);
extern char *strfill(my_string s,uint len,pchar fill); extern char *strfill(char * s,size_t len,pchar fill);
extern uint strinstr(const char *str,const char *search); extern size_t strinstr(const char *str,const char *search);
extern uint r_strinstr(reg1 my_string str,int from, reg4 my_string search); extern size_t r_strinstr(const char *str, size_t from, const char *search);
extern char *strkey(char *dst,char *head,char *tail,char *flags); extern char *strkey(char *dst,char *head,char *tail,char *flags);
extern char *strmake(char *dst,const char *src,uint length); extern char *strmake(char *dst,const char *src,size_t length);
#ifndef strmake_overlapp #ifndef strmake_overlapp
extern char *strmake_overlapp(char *dst,const char *src, uint length); extern char *strmake_overlapp(char *dst,const char *src, size_t length);
#endif #endif
#ifndef strmov #ifndef strmov
extern char *strmov(char *dst,const char *src); extern char *strmov(char *dst,const char *src);
#endif #endif
extern char *strnmov(char *dst,const char *src,uint n); extern char *strnmov(char *dst,const char *src,size_t n);
extern char *strsuff(const char *src,const char *suffix); extern char *strsuff(const char *src,const char *suffix);
extern char *strcont(const char *src,const char *set); extern char *strcont(const char *src,const char *set);
extern char *strxcat _VARARGS((char *dst,const char *src, ...)); extern char *strxcat _VARARGS((char *dst,const char *src, ...));
extern char *strxmov _VARARGS((char *dst,const char *src, ...)); extern char *strxmov _VARARGS((char *dst,const char *src, ...));
extern char *strxcpy _VARARGS((char *dst,const char *src, ...)); extern char *strxcpy _VARARGS((char *dst,const char *src, ...));
extern char *strxncat _VARARGS((char *dst,uint len, const char *src, ...)); extern char *strxncat _VARARGS((char *dst,size_t len, const char *src, ...));
extern char *strxnmov _VARARGS((char *dst,uint len, const char *src, ...)); extern char *strxnmov _VARARGS((char *dst,size_t len, const char *src, ...));
extern char *strxncpy _VARARGS((char *dst,uint len, const char *src, ...)); extern char *strxncpy _VARARGS((char *dst,size_t len, const char *src, ...));
/* Prototypes of normal stringfunctions (with may ours) */ /* Prototypes of normal stringfunctions (with may ours) */
@ -179,7 +182,7 @@ extern size_t strlen(const char *);
#endif #endif
#endif #endif
#ifndef HAVE_STRNLEN #ifndef HAVE_STRNLEN
extern uint strnlen(const char *s, uint n); extern size_t strnlen(const char *s, size_t n);
#endif #endif
#if !defined(__cplusplus) #if !defined(__cplusplus)
@ -232,9 +235,9 @@ extern ulonglong strtoull(const char *str, char **ptr, int base);
/* my_vsnprintf.c */ /* my_vsnprintf.c */
extern int my_vsnprintf( char *str, size_t n, extern size_t my_vsnprintf(char *str, size_t n,
const char *format, va_list ap ); const char *format, va_list ap);
extern int my_snprintf(char *to, size_t n, const char *fmt, ...) extern size_t my_snprintf(char *to, size_t n, const char *fmt, ...)
ATTRIBUTE_FORMAT(printf, 3, 4); ATTRIBUTE_FORMAT(printf, 3, 4);
#if defined(__cplusplus) #if defined(__cplusplus)
@ -243,19 +246,20 @@ extern int my_snprintf(char *to, size_t n, const char *fmt, ...)
/* /*
LEX_STRING -- a pair of a C-string and its length. LEX_STRING -- a pair of a C-string and its length.
NOTE: this exactly form of declaration is required for some C-compilers
(for one, Sun C 5.7 2005/01/07). Unfortunatelt with such declaration
LEX_STRING can not be forward declared.
*/ */
typedef struct #ifndef _my_plugin_h
/* This definition must match the one given in mysql/plugin.h */
struct st_mysql_lex_string
{ {
char *str; char *str;
uint length; size_t length;
} LEX_STRING; };
#endif
typedef struct st_mysql_lex_string LEX_STRING;
#define STRING_WITH_LEN(X) (X), ((uint) (sizeof(X) - 1)) #define STRING_WITH_LEN(X) (X), ((size_t) (sizeof(X) - 1))
#define C_STRING_WITH_LEN(X) ((char *) (X)), ((uint) (sizeof(X) - 1)) #define USTRING_WITH_LEN(X) ((uchar*) X), ((size_t) (sizeof(X) - 1))
#define C_STRING_WITH_LEN(X) ((char *) (X)), ((size_t) (sizeof(X) - 1))
#endif #endif

View File

@ -37,8 +37,8 @@ typedef struct st_mem_root
USED_MEM *used; /* blocks almost without free memory */ USED_MEM *used; /* blocks almost without free memory */
USED_MEM *pre_alloc; /* preallocated block */ USED_MEM *pre_alloc; /* preallocated block */
/* if block have less memory it will be put in 'used' list */ /* if block have less memory it will be put in 'used' list */
unsigned int min_malloc; size_t min_malloc;
unsigned int block_size; /* initial block size */ size_t block_size; /* initial block size */
unsigned int block_num; /* allocated blocks counter */ unsigned int block_num; /* allocated blocks counter */
/* /*
first free block in queue test counter (if it exceed first free block in queue test counter (if it exceed

View File

@ -48,6 +48,8 @@
#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 */
/* Internal temp table, used for temporary results */
#define HA_OPEN_INTERNAL_TABLE 256
/* The following is parameter to ha_rkey() how to use key */ /* The following is parameter to ha_rkey() how to use key */
@ -180,7 +182,12 @@ enum ha_extra_function {
These flags are reset by the handler::extra(HA_EXTRA_RESET) call. These flags are reset by the handler::extra(HA_EXTRA_RESET) call.
*/ */
HA_EXTRA_DELETE_CANNOT_BATCH, HA_EXTRA_DELETE_CANNOT_BATCH,
HA_EXTRA_UPDATE_CANNOT_BATCH HA_EXTRA_UPDATE_CANNOT_BATCH,
/*
Inform handler that an "INSERT...ON DUPLICATE KEY UPDATE" will be
executed. This condition is unset by HA_EXTRA_NO_IGNORE_DUP_KEY.
*/
HA_EXTRA_INSERT_WITH_UPDATE
}; };
/* The following is parameter to ha_panic() */ /* The following is parameter to ha_panic() */
@ -294,6 +301,7 @@ enum ha_base_keytype {
#define HA_PACK_RECORD 2 /* Request packed record format */ #define HA_PACK_RECORD 2 /* Request packed record format */
#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_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
@ -396,7 +404,12 @@ enum ha_base_keytype {
#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_LAST 168 /*Copy last error nr.*/ #define HA_ERR_RECORD_IS_THE_SAME 169 /* row not actually updated :
new values same as the old values */
#define HA_ERR_LOGGING_IMPOSSIBLE 170 /* It is not possible to log this
statement */
#define HA_ERR_LAST 170 /*Copy last error nr.*/
/* Add error numbers before HA_ERR_LAST and change it accordingly. */ /* Add error numbers before HA_ERR_LAST and change it accordingly. */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1) #define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
@ -478,7 +491,7 @@ enum data_file_type {
typedef struct st_key_range typedef struct st_key_range
{ {
const byte *key; const uchar *key;
uint length; uint length;
key_part_map keypart_map; key_part_map keypart_map;
enum ha_rkey_function flag; enum ha_rkey_function flag;

View File

@ -41,6 +41,7 @@ typedef struct st_bitmap
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
extern void create_last_word_mask(MY_BITMAP *map);
extern my_bool bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint n_bits, extern my_bool bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint n_bits,
my_bool thread_safe); my_bool thread_safe);
extern my_bool bitmap_is_clear_all(const MY_BITMAP *map); extern my_bool bitmap_is_clear_all(const MY_BITMAP *map);
@ -103,6 +104,17 @@ extern void bitmap_lock_invert(MY_BITMAP *map);
&= ~ (1 << ((BIT) & 7))) &= ~ (1 << ((BIT) & 7)))
#define _bitmap_is_set(MAP, BIT) (uint) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \ #define _bitmap_is_set(MAP, BIT) (uint) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \
& (1 << ((BIT) & 7))) & (1 << ((BIT) & 7)))
/*
WARNING!
The below symbols are inline functions in DEBUG builds and macros in
non-DEBUG builds. The latter evaluate their 'bit' argument twice.
NEVER use an increment/decrement operator with the 'bit' argument.
It would work with DEBUG builds, but fails later in production builds!
FORBIDDEN: bitmap_set_bit($my_bitmap, (field++)->field_index);
*/
#ifndef DBUG_OFF #ifndef DBUG_OFF
static inline void static inline void
bitmap_set_bit(MY_BITMAP *map,uint bit) bitmap_set_bit(MY_BITMAP *map,uint bit)

View File

@ -23,8 +23,8 @@ extern "C" {
struct _db_code_state_; struct _db_code_state_;
extern int _db_keyword_(struct _db_code_state_ *cs, const char *keyword); extern int _db_keyword_(struct _db_code_state_ *cs, const char *keyword);
extern int _db_strict_keyword_(const char *keyword); extern int _db_strict_keyword_(const char *keyword);
extern int _db_explain_(struct _db_code_state_ *cs, char *buf, int len); extern int _db_explain_(struct _db_code_state_ *cs, char *buf, size_t len);
extern int _db_explain_init_(char *buf, int len); extern int _db_explain_init_(char *buf, size_t len);
extern void _db_setjmp_(void); extern void _db_setjmp_(void);
extern void _db_longjmp_(void); extern void _db_longjmp_(void);
extern void _db_process_(const char *name); extern void _db_process_(const char *name);
@ -40,8 +40,8 @@ extern void _db_return_(uint _line_,const char **_sfunc_,const char **_sfile_,
extern void _db_pargs_(uint _line_,const char *keyword); extern void _db_pargs_(uint _line_,const char *keyword);
extern void _db_doprnt_ _VARARGS((const char *format,...)) extern void _db_doprnt_ _VARARGS((const char *format,...))
ATTRIBUTE_FORMAT(printf, 1, 2); ATTRIBUTE_FORMAT(printf, 1, 2);
extern void _db_dump_(uint _line_,const char *keyword,const char *memory, extern void _db_dump_(uint _line_,const char *keyword,
uint length); const unsigned char *memory, size_t length);
extern void _db_end_(void); extern void _db_end_(void);
extern void _db_lock_file_(void); extern void _db_lock_file_(void);
extern void _db_unlock_file_(void); extern void _db_unlock_file_(void);

View File

@ -29,20 +29,25 @@ C_MODE_START
#define GET_STR 9 #define GET_STR 9
#define GET_STR_ALLOC 10 #define GET_STR_ALLOC 10
#define GET_DISABLED 11 #define GET_DISABLED 11
#define GET_ENUM 12
#define GET_SET 13
#define GET_DOUBLE 14
#define GET_ASK_ADDR 128 #define GET_ASK_ADDR 128
#define GET_TYPE_MASK 127 #define GET_TYPE_MASK 127
enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG }; enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG };
struct st_typelib;
struct my_option struct my_option
{ {
const char *name; /* Name of the option */ const char *name; /* Name of the option */
int id; /* unique id or short option */ int id; /* unique id or short option */
const char *comment; /* option comment, for autom. --help */ const char *comment; /* option comment, for autom. --help */
gptr *value; /* The variable value */ uchar **value; /* The variable value */
gptr *u_max_value; /* The user def. max variable value */ uchar **u_max_value; /* The user def. max variable value */
const char **str_values; /* Pointer to possible values */ struct st_typelib *typelib; /* Pointer to possible values */
ulong var_type; ulong var_type;
enum get_opt_arg_type arg_type; enum get_opt_arg_type arg_type;
longlong def_value; /* Default value */ longlong def_value; /* Default value */
@ -50,7 +55,7 @@ struct my_option
longlong max_value; /* Max allowed value */ longlong max_value; /* Max allowed value */
longlong sub_size; /* Subtract this from given value */ longlong sub_size; /* Subtract this from given value */
long block_size; /* Value should be a mult. of this */ long block_size; /* Value should be a mult. of this */
int app_type; /* To be used by an application */ void *app_type; /* To be used by an application */
}; };
typedef my_bool (* my_get_one_option) (int, const struct my_option *, char * ); typedef my_bool (* my_get_one_option) (int, const struct my_option *, char * );
@ -58,13 +63,14 @@ typedef void (* my_error_reporter) (enum loglevel level, const char *format, ...
extern char *disabled_my_option; extern char *disabled_my_option;
extern my_bool my_getopt_print_errors; extern my_bool my_getopt_print_errors;
extern my_bool my_getopt_skip_unknown;
extern my_error_reporter my_getopt_error_reporter; extern my_error_reporter my_getopt_error_reporter;
extern int handle_options (int *argc, char ***argv, extern int handle_options (int *argc, char ***argv,
const struct my_option *longopts, my_get_one_option); const struct my_option *longopts, my_get_one_option);
extern void my_print_help(const struct my_option *options); extern void my_print_help(const struct my_option *options);
extern void my_print_variables(const struct my_option *options); extern void my_print_variables(const struct my_option *options);
extern void my_getopt_register_get_addr(gptr* (*func_addr)(const char *, uint, extern void my_getopt_register_get_addr(uchar ** (*func_addr)(const char *, uint,
const struct my_option *)); const struct my_option *));
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp); ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp);

View File

@ -23,6 +23,17 @@
#define HAVE_EXTERNAL_CLIENT #define HAVE_EXTERNAL_CLIENT
#endif #endif
/*
InnoDB depends on some MySQL internals which other plugins should not
need. This is because of InnoDB's foreign key support, "safe" binlog
truncation, and other similar legacy features.
We define accessors for these internals unconditionally, but do not
expose them in mysql/plugin.h. They are declared in ha_innodb.h for
InnoDB's use.
*/
#define INNODB_COMPATIBILITY_HOOKS
#ifdef __CYGWIN__ #ifdef __CYGWIN__
/* We use a Unix API, so pretend it's not Windows */ /* We use a Unix API, so pretend it's not Windows */
#undef WIN #undef WIN
@ -441,17 +452,7 @@ C_MODE_END
#ifdef HAVE_ALLOCA_H #ifdef HAVE_ALLOCA_H
#include <alloca.h> #include <alloca.h>
#endif #endif
#ifdef HAVE_ATOMIC_ADD
#define new my_arg_new
#define need_to_restore_new 1
C_MODE_START
#include <asm/atomic.h>
C_MODE_END
#ifdef need_to_restore_new /* probably safer than #ifdef new */
#undef new
#undef need_to_restore_new
#endif
#endif
#include <errno.h> /* Recommended by debian */ #include <errno.h> /* Recommended by debian */
/* We need the following to go around a problem with openssl on solaris */ /* We need the following to go around a problem with openssl on solaris */
#if defined(HAVE_CRYPT_H) #if defined(HAVE_CRYPT_H)
@ -465,6 +466,18 @@ C_MODE_END
*/ */
#include <assert.h> #include <assert.h>
/* an assert that works at compile-time. only for constant expression */
#ifndef __GNUC__
#define compile_time_assert(X) do { } while(0)
#else
#define compile_time_assert(X) \
do \
{ \
char compile_time_assert[(X) ? 1 : -1] \
__attribute__ ((unused)); \
} while(0)
#endif
/* Go around some bugs in different OS and compilers */ /* Go around some bugs in different OS and compilers */
#if defined (HPUX11) && defined(_LARGEFILE_SOURCE) #if defined (HPUX11) && defined(_LARGEFILE_SOURCE)
#define _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE
@ -549,12 +562,6 @@ int __void__;
#define PURIFY_OR_LINT_INIT(var) #define PURIFY_OR_LINT_INIT(var)
#endif #endif
/* Define some useful general macros */
#if !defined(max)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#endif
#if !defined(HAVE_UINT) #if !defined(HAVE_UINT)
#undef HAVE_UINT #undef HAVE_UINT
#define HAVE_UINT #define HAVE_UINT
@ -791,6 +798,10 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define ulong_to_double(X) ((double) (ulong) (X)) #define ulong_to_double(X) ((double) (ulong) (X))
#define SET_STACK_SIZE(X) /* Not needed on real machines */ #define SET_STACK_SIZE(X) /* Not needed on real machines */
#ifndef STACK_DIRECTION
#error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
#endif
#if !defined(HAVE_STRTOK_R) #if !defined(HAVE_STRTOK_R)
#define strtok_r(A,B,C) strtok((A),(B)) #define strtok_r(A,B,C) strtok((A),(B))
#endif #endif
@ -855,12 +866,11 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define isnan(x) ((x) != (x)) #define isnan(x) ((x) != (x))
#endif #endif
#if !defined(HAVE_ISINF) #ifdef HAVE_ISINF
/* The configure check for "isinf with math.h" has failed */ /* isinf() can be used in both C and C++ code */
#ifdef isinf #define my_isinf(X) isinf(X)
#undef isinf #else
#endif #define my_isinf(X) (!finite(X) && !isnan(X))
#define isinf(X) (!finite(X) && !isnan(X))
#endif #endif
/* Define missing math constants. */ /* Define missing math constants. */
@ -884,21 +894,17 @@ typedef long my_ptrdiff_t;
typedef long long my_ptrdiff_t; typedef long long my_ptrdiff_t;
#endif #endif
/* We can't set my_size_t to size_t as we want my_size_t to be unsigned */
#if SIZEOF_CHARP <= SIZEOF_LONG
typedef unsigned long my_size_t;
#else
typedef unsigned long long my_size_t;
#endif
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1)) #define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double)) #define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
/* Size to make adressable obj. */ /* Size to make adressable obj. */
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t))) #define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
/* Offset of field f in structure t */ /* Offset of field f in structure t */
#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f) #define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
#define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size) #define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B)) #define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
/* /*
Custom version of standard offsetof() macro which can be used to get Custom version of standard offsetof() macro which can be used to get
@ -933,11 +939,6 @@ typedef unsigned long long my_size_t;
/* Typdefs for easyier portability */ /* Typdefs for easyier portability */
#if defined(VOIDTYPE)
typedef void *gptr; /* Generic pointer */
#else
typedef char *gptr; /* Generic pointer */
#endif
#ifndef HAVE_UCHAR #ifndef HAVE_UCHAR
typedef unsigned char uchar; /* Short for unsigned char */ typedef unsigned char uchar; /* Short for unsigned char */
#endif #endif
@ -976,7 +977,12 @@ typedef unsigned long uint32;
typedef unsigned long ulong; /* Short for unsigned long */ typedef unsigned long ulong; /* Short for unsigned long */
#endif #endif
#ifndef longlong_defined #ifndef longlong_defined
#if defined(HAVE_LONG_LONG) && SIZEOF_LONG != 8 /*
Using [unsigned] long long is preferable as [u]longlong because we use
[unsigned] long long unconditionally in many places,
for example in constants with [U]LL suffix.
*/
#if defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == 8
typedef unsigned long long int ulonglong; /* ulong or unsigned long long */ typedef unsigned long long int ulonglong; /* ulong or unsigned long long */
typedef long long int longlong; typedef long long int longlong;
#else #else
@ -1058,12 +1064,7 @@ typedef off_t os_off_t;
typedef uint8 int7; /* Most effective integer 0 <= x <= 127 */ typedef uint8 int7; /* Most effective integer 0 <= x <= 127 */
typedef short int15; /* Most effective integer 0 <= x <= 32767 */ typedef short int15; /* Most effective integer 0 <= x <= 32767 */
typedef char *my_string; /* String of characters */
typedef unsigned long size_s; /* Size of strings (In string-funcs) */
typedef int myf; /* Type of MyFlags in my_funcs */ typedef int myf; /* Type of MyFlags in my_funcs */
#ifndef byte_defined
typedef char byte; /* Smallest addressable unit */
#endif
typedef char my_bool; /* Small bool */ typedef char my_bool; /* Small bool */
#if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus)) #if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
typedef char bool; /* Ordinary boolean values 0 1 */ typedef char bool; /* Ordinary boolean values 0 1 */
@ -1209,9 +1210,9 @@ do { doubleget_union _tmp; \
} while (0) } while (0)
#define float4get(V,M) do { *((float *) &(V)) = *((float*) (M)); } while(0) #define float4get(V,M) do { *((float *) &(V)) = *((float*) (M)); } while(0)
#define float8get(V,M) doubleget((V),(M)) #define float8get(V,M) doubleget((V),(M))
#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float)) #define float4store(V,M) memcpy((uchar*) V,(uchar*) (&M),sizeof(float))
#define floatstore(T,V) memcpy((byte*)(T), (byte*)(&V),sizeof(float)) #define floatstore(T,V) memcpy((uchar*)(T), (uchar*)(&V),sizeof(float))
#define floatget(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(float)) #define floatget(V,M) memcpy((uchar*) &V,(uchar*) (M),sizeof(float))
#define float8store(V,M) doublestore((V),(M)) #define float8store(V,M) doublestore((V),(M))
#endif /* __i386__ */ #endif /* __i386__ */
@ -1294,59 +1295,59 @@ do { doubleget_union _tmp; \
int4store((T),def_temp); \ int4store((T),def_temp); \
int4store((T+4),def_temp2); } while(0) int4store((T+4),def_temp2); } while(0)
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
#define float4store(T,A) do { *(T)= ((byte *) &A)[3];\ #define float4store(T,A) do { *(T)= ((uchar *) &A)[3];\
*((T)+1)=(char) ((byte *) &A)[2];\ *((T)+1)=(char) ((uchar *) &A)[2];\
*((T)+2)=(char) ((byte *) &A)[1];\ *((T)+2)=(char) ((uchar *) &A)[1];\
*((T)+3)=(char) ((byte *) &A)[0]; } while(0) *((T)+3)=(char) ((uchar *) &A)[0]; } while(0)
#define float4get(V,M) do { float def_temp;\ #define float4get(V,M) do { float def_temp;\
((byte*) &def_temp)[0]=(M)[3];\ ((uchar*) &def_temp)[0]=(M)[3];\
((byte*) &def_temp)[1]=(M)[2];\ ((uchar*) &def_temp)[1]=(M)[2];\
((byte*) &def_temp)[2]=(M)[1];\ ((uchar*) &def_temp)[2]=(M)[1];\
((byte*) &def_temp)[3]=(M)[0];\ ((uchar*) &def_temp)[3]=(M)[0];\
(V)=def_temp; } while(0) (V)=def_temp; } while(0)
#define float8store(T,V) do { *(T)= ((byte *) &V)[7];\ #define float8store(T,V) do { *(T)= ((uchar *) &V)[7];\
*((T)+1)=(char) ((byte *) &V)[6];\ *((T)+1)=(char) ((uchar *) &V)[6];\
*((T)+2)=(char) ((byte *) &V)[5];\ *((T)+2)=(char) ((uchar *) &V)[5];\
*((T)+3)=(char) ((byte *) &V)[4];\ *((T)+3)=(char) ((uchar *) &V)[4];\
*((T)+4)=(char) ((byte *) &V)[3];\ *((T)+4)=(char) ((uchar *) &V)[3];\
*((T)+5)=(char) ((byte *) &V)[2];\ *((T)+5)=(char) ((uchar *) &V)[2];\
*((T)+6)=(char) ((byte *) &V)[1];\ *((T)+6)=(char) ((uchar *) &V)[1];\
*((T)+7)=(char) ((byte *) &V)[0]; } while(0) *((T)+7)=(char) ((uchar *) &V)[0]; } while(0)
#define float8get(V,M) do { double def_temp;\ #define float8get(V,M) do { double def_temp;\
((byte*) &def_temp)[0]=(M)[7];\ ((uchar*) &def_temp)[0]=(M)[7];\
((byte*) &def_temp)[1]=(M)[6];\ ((uchar*) &def_temp)[1]=(M)[6];\
((byte*) &def_temp)[2]=(M)[5];\ ((uchar*) &def_temp)[2]=(M)[5];\
((byte*) &def_temp)[3]=(M)[4];\ ((uchar*) &def_temp)[3]=(M)[4];\
((byte*) &def_temp)[4]=(M)[3];\ ((uchar*) &def_temp)[4]=(M)[3];\
((byte*) &def_temp)[5]=(M)[2];\ ((uchar*) &def_temp)[5]=(M)[2];\
((byte*) &def_temp)[6]=(M)[1];\ ((uchar*) &def_temp)[6]=(M)[1];\
((byte*) &def_temp)[7]=(M)[0];\ ((uchar*) &def_temp)[7]=(M)[0];\
(V) = def_temp; } while(0) (V) = def_temp; } while(0)
#else #else
#define float4get(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float)) #define float4get(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(float))
#define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float)) #define float4store(V,M) memcpy_fixed((uchar*) V,(uchar*) (&M),sizeof(float))
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) #if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((byte *) &V)[4];\ #define doublestore(T,V) do { *(((char*)T)+0)=(char) ((uchar *) &V)[4];\
*(((char*)T)+1)=(char) ((byte *) &V)[5];\ *(((char*)T)+1)=(char) ((uchar *) &V)[5];\
*(((char*)T)+2)=(char) ((byte *) &V)[6];\ *(((char*)T)+2)=(char) ((uchar *) &V)[6];\
*(((char*)T)+3)=(char) ((byte *) &V)[7];\ *(((char*)T)+3)=(char) ((uchar *) &V)[7];\
*(((char*)T)+4)=(char) ((byte *) &V)[0];\ *(((char*)T)+4)=(char) ((uchar *) &V)[0];\
*(((char*)T)+5)=(char) ((byte *) &V)[1];\ *(((char*)T)+5)=(char) ((uchar *) &V)[1];\
*(((char*)T)+6)=(char) ((byte *) &V)[2];\ *(((char*)T)+6)=(char) ((uchar *) &V)[2];\
*(((char*)T)+7)=(char) ((byte *) &V)[3]; }\ *(((char*)T)+7)=(char) ((uchar *) &V)[3]; }\
while(0) while(0)
#define doubleget(V,M) do { double def_temp;\ #define doubleget(V,M) do { double def_temp;\
((byte*) &def_temp)[0]=(M)[4];\ ((uchar*) &def_temp)[0]=(M)[4];\
((byte*) &def_temp)[1]=(M)[5];\ ((uchar*) &def_temp)[1]=(M)[5];\
((byte*) &def_temp)[2]=(M)[6];\ ((uchar*) &def_temp)[2]=(M)[6];\
((byte*) &def_temp)[3]=(M)[7];\ ((uchar*) &def_temp)[3]=(M)[7];\
((byte*) &def_temp)[4]=(M)[0];\ ((uchar*) &def_temp)[4]=(M)[0];\
((byte*) &def_temp)[5]=(M)[1];\ ((uchar*) &def_temp)[5]=(M)[1];\
((byte*) &def_temp)[6]=(M)[2];\ ((uchar*) &def_temp)[6]=(M)[2];\
((byte*) &def_temp)[7]=(M)[3];\ ((uchar*) &def_temp)[7]=(M)[3];\
(V) = def_temp; } while(0) (V) = def_temp; } while(0)
#endif /* __FLOAT_WORD_ORDER */ #endif /* __FLOAT_WORD_ORDER */
@ -1377,16 +1378,16 @@ do { doubleget_union _tmp; \
#define shortget(V,M) do { V = (short) (((short) ((uchar) (M)[1]))+\ #define shortget(V,M) do { V = (short) (((short) ((uchar) (M)[1]))+\
((short) ((short) (M)[0]) << 8)); } while(0) ((short) ((short) (M)[0]) << 8)); } while(0)
#define longget(V,M) do { int32 def_temp;\ #define longget(V,M) do { int32 def_temp;\
((byte*) &def_temp)[0]=(M)[0];\ ((uchar*) &def_temp)[0]=(M)[0];\
((byte*) &def_temp)[1]=(M)[1];\ ((uchar*) &def_temp)[1]=(M)[1];\
((byte*) &def_temp)[2]=(M)[2];\ ((uchar*) &def_temp)[2]=(M)[2];\
((byte*) &def_temp)[3]=(M)[3];\ ((uchar*) &def_temp)[3]=(M)[3];\
(V)=def_temp; } while(0) (V)=def_temp; } while(0)
#define ulongget(V,M) do { uint32 def_temp;\ #define ulongget(V,M) do { uint32 def_temp;\
((byte*) &def_temp)[0]=(M)[0];\ ((uchar*) &def_temp)[0]=(M)[0];\
((byte*) &def_temp)[1]=(M)[1];\ ((uchar*) &def_temp)[1]=(M)[1];\
((byte*) &def_temp)[2]=(M)[2];\ ((uchar*) &def_temp)[2]=(M)[2];\
((byte*) &def_temp)[3]=(M)[3];\ ((uchar*) &def_temp)[3]=(M)[3];\
(V)=def_temp; } while(0) (V)=def_temp; } while(0)
#define shortstore(T,A) do { uint def_temp=(uint) (A) ;\ #define shortstore(T,A) do { uint def_temp=(uint) (A) ;\
*(((char*)T)+1)=(char)(def_temp); \ *(((char*)T)+1)=(char)(def_temp); \
@ -1396,12 +1397,12 @@ do { doubleget_union _tmp; \
*(((char*)T)+1)=(((A) >> 16));\ *(((char*)T)+1)=(((A) >> 16));\
*(((char*)T)+0)=(((A) >> 24)); } while(0) *(((char*)T)+0)=(((A) >> 24)); } while(0)
#define floatget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float)) #define floatget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(float))
#define floatstore(T,V) memcpy_fixed((byte*) (T),(byte*)(&V),sizeof(float)) #define floatstore(T,V) memcpy_fixed((uchar*) (T),(uchar*)(&V),sizeof(float))
#define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double)) #define doubleget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(double))
#define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double)) #define doublestore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(double))
#define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong)) #define longlongget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(ulonglong))
#define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong)) #define longlongstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(ulonglong))
#else #else
@ -1412,15 +1413,15 @@ do { doubleget_union _tmp; \
#define shortstore(T,V) int2store(T,V) #define shortstore(T,V) int2store(T,V)
#define longstore(T,V) int4store(T,V) #define longstore(T,V) int4store(T,V)
#ifndef floatstore #ifndef floatstore
#define floatstore(T,V) memcpy_fixed((byte*) (T),(byte*) (&V),sizeof(float)) #define floatstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) (&V),sizeof(float))
#define floatget(V,M) memcpy_fixed((byte*) &V, (byte*) (M), sizeof(float)) #define floatget(V,M) memcpy_fixed((uchar*) &V, (uchar*) (M), sizeof(float))
#endif #endif
#ifndef doubleget #ifndef doubleget
#define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double)) #define doubleget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(double))
#define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double)) #define doublestore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(double))
#endif /* doubleget */ #endif /* doubleget */
#define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong)) #define longlongget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(ulonglong))
#define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong)) #define longlongstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(ulonglong))
#endif /* WORDS_BIGENDIAN */ #endif /* WORDS_BIGENDIAN */
@ -1437,10 +1438,13 @@ do { doubleget_union _tmp; \
#ifndef THREAD #ifndef THREAD
#define thread_safe_increment(V,L) (V)++ #define thread_safe_increment(V,L) (V)++
#define thread_safe_decrement(V,L) (V)--
#define thread_safe_add(V,C,L) (V)+=(C) #define thread_safe_add(V,C,L) (V)+=(C)
#define thread_safe_sub(V,C,L) (V)-=(C) #define thread_safe_sub(V,C,L) (V)-=(C)
#define statistic_increment(V,L) (V)++ #define statistic_increment(V,L) (V)++
#define statistic_decrement(V,L) (V)--
#define statistic_add(V,C,L) (V)+=(C) #define statistic_add(V,C,L) (V)+=(C)
#define statistic_sub(V,C,L) (V)-=(C)
#endif #endif
#ifdef HAVE_CHARSET_utf8 #ifdef HAVE_CHARSET_utf8
@ -1498,4 +1502,10 @@ inline void operator delete[](void*, void*) { /* Do nothing */ }
/* Length of decimal number represented by INT64. */ /* Length of decimal number represented by INT64. */
#define MY_INT64_NUM_DECIMAL_DIGITS 21 #define MY_INT64_NUM_DECIMAL_DIGITS 21
/* Define some useful general macros (should be done after all headers). */
#if !defined(max)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#endif
#endif /* my_global_h */ #endif /* my_global_h */

View File

@ -33,11 +33,11 @@ extern LIST *list_cons(void *data,LIST *root);
extern LIST *list_reverse(LIST *root); extern LIST *list_reverse(LIST *root);
extern void list_free(LIST *root,unsigned int free_data); extern void list_free(LIST *root,unsigned int free_data);
extern unsigned int list_length(LIST *); extern unsigned int list_length(LIST *);
extern int list_walk(LIST *,list_walk_action action,gptr argument); extern int list_walk(LIST *,list_walk_action action,unsigned char * argument);
#define list_rest(a) ((a)->next) #define list_rest(a) ((a)->next)
#define list_push(a,b) (a)=list_cons((b),(a)) #define list_push(a,b) (a)=list_cons((b),(a))
#define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; my_free((gptr) old,MYF(MY_FAE)); } #define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; my_free((unsigned char *) old,MYF(MY_FAE)); }
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -35,8 +35,9 @@ extern "C" {
#undef my_seek #undef my_seek
#define my_read(a,b,c,d) my_quick_read(a,b,c,d) #define my_read(a,b,c,d) my_quick_read(a,b,c,d)
#define my_write(a,b,c,d) my_quick_write(a,b,c) #define my_write(a,b,c,d) my_quick_write(a,b,c)
extern uint my_quick_read(File Filedes,byte *Buffer,uint Count,myf myFlags); extern size_t my_quick_read(File Filedes,uchar *Buffer,size_t Count,
extern uint my_quick_write(File Filedes,const byte *Buffer,uint Count); myf myFlags);
extern size_t my_quick_write(File Filedes,const uchar *Buffer,size_t Count);
#if !defined(SAFEMALLOC) && defined(USE_HALLOC) #if !defined(SAFEMALLOC) && defined(USE_HALLOC)
#define my_malloc(a,b) halloc(a,1) #define my_malloc(a,b) halloc(a,1)

View File

@ -29,25 +29,6 @@ extern "C" {
#define EXTERNC #define EXTERNC
#endif /* __cplusplus */ #endif /* __cplusplus */
/*
BUG#24507: Race conditions inside current NPTL pthread_exit() implementation.
If macro NPTL_PTHREAD_EXIT_HACK is defined then a hack described in the bug
report will be implemented inside my_thread_global_init() in my_thr_init.c.
This amounts to spawning a dummy thread which does nothing but executes
pthread_exit(0).
This bug is fixed in version 2.5 of glibc library.
TODO: Remove this code when fixed versions of glibc6 are in common use.
*/
#if defined(TARGET_OS_LINUX) && defined(HAVE_NPTL) && \
defined(__GLIBC__) && ( __GLIBC__ < 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ < 5 )
#define NPTL_PTHREAD_EXIT_BUG 1
#endif
#if defined(__WIN__) #if defined(__WIN__)
typedef CRITICAL_SECTION pthread_mutex_t; typedef CRITICAL_SECTION pthread_mutex_t;
typedef HANDLE pthread_t; typedef HANDLE pthread_t;
@ -179,10 +160,9 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
#define pthread_mutex_unlock(A) LeaveCriticalSection(A) #define pthread_mutex_unlock(A) LeaveCriticalSection(A)
#define pthread_mutex_destroy(A) DeleteCriticalSection(A) #define pthread_mutex_destroy(A) DeleteCriticalSection(A)
#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B)) #define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
#define pthread_kill(A,B) pthread_dummy(0) #define pthread_kill(A,B) pthread_dummy(ESRCH)
#define pthread_join(A,B) \ #define pthread_join(A,B) (WaitForSingleObject((A), INFINITE) != WAIT_OBJECT_0)
((WaitForSingleObject((A), INFINITE) != WAIT_OBJECT_0) || !CloseHandle(A))
/* Dummy defines for easier code */ /* Dummy defines for easier code */
#define pthread_attr_setdetachstate(A,B) pthread_dummy(0) #define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
@ -362,14 +342,14 @@ struct tm *gmtime_r(const time_t *clock, struct tm *res);
#define pthread_attr_setdetachstate(A,B) pthread_dummy(0) #define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
#define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D)) #define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D))
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
#define pthread_kill(A,B) pthread_dummy(0) #define pthread_kill(A,B) pthread_dummy(ESRCH)
#undef pthread_detach_this_thread #undef pthread_detach_this_thread
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); } #define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
#endif #endif
#ifdef HAVE_DARWIN5_THREADS #ifdef HAVE_DARWIN5_THREADS
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
#define pthread_kill(A,B) pthread_dummy(0) #define pthread_kill(A,B) pthread_dummy(ESRCH)
#define pthread_condattr_init(A) pthread_dummy(0) #define pthread_condattr_init(A) pthread_dummy(0)
#define pthread_condattr_destroy(A) pthread_dummy(0) #define pthread_condattr_destroy(A) pthread_dummy(0)
#undef pthread_detach_this_thread #undef pthread_detach_this_thread
@ -389,7 +369,7 @@ struct tm *gmtime_r(const time_t *clock, struct tm *res);
#ifndef pthread_sigmask #ifndef pthread_sigmask
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
#endif #endif
#define pthread_kill(A,B) pthread_dummy(0) #define pthread_kill(A,B) pthread_dummy(ESRCH)
#undef pthread_detach_this_thread #undef pthread_detach_this_thread
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); } #define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
#elif !defined(__NETWARE__) /* HAVE_PTHREAD_ATTR_CREATE && !HAVE_SIGWAIT */ #elif !defined(__NETWARE__) /* HAVE_PTHREAD_ATTR_CREATE && !HAVE_SIGWAIT */
@ -539,6 +519,7 @@ typedef struct st_my_pthread_fastmutex_t
pthread_mutex_t mutex; pthread_mutex_t mutex;
uint spins; uint spins;
} my_pthread_fastmutex_t; } my_pthread_fastmutex_t;
void fastmutex_global_init(void);
int my_pthread_fastmutex_init(my_pthread_fastmutex_t *mp, int my_pthread_fastmutex_init(my_pthread_fastmutex_t *mp,
const pthread_mutexattr_t *attr); const pthread_mutexattr_t *attr);
@ -647,6 +628,11 @@ extern pthread_mutexattr_t my_errorcheck_mutexattr;
#define MY_MUTEX_INIT_ERRCHK NULL #define MY_MUTEX_INIT_ERRCHK NULL
#endif #endif
#ifndef ESRCH
/* Define it to something */
#define ESRCH 1
#endif
typedef ulong my_thread_id; typedef ulong my_thread_id;
extern my_bool my_thread_global_init(void); extern my_bool my_thread_global_init(void);
@ -688,7 +674,7 @@ struct st_my_thread_var
struct st_my_thread_var *next,**prev; struct st_my_thread_var *next,**prev;
void *opt_info; void *opt_info;
#ifndef DBUG_OFF #ifndef DBUG_OFF
gptr dbug; void *dbug;
char name[THREAD_NAME_SIZE+1]; char name[THREAD_NAME_SIZE+1];
#endif #endif
}; };
@ -710,33 +696,68 @@ extern uint my_thread_end_wait_time;
extern uint thd_lib_detected; extern uint thd_lib_detected;
/* statistics_xxx functions are for not essential statistic */ /*
thread_safe_xxx functions are for critical statistic or counters.
The implementation is guaranteed to be thread safe, on all platforms.
Note that the calling code should *not* assume the counter is protected
by the mutex given, as the implementation of these helpers may change
to use my_atomic operations instead.
*/
/*
Warning:
When compiling without threads, this file is not included.
See the *other* declarations of thread_safe_xxx in include/my_global.h
Second warning:
See include/config-win.h, for yet another implementation.
*/
#ifdef THREAD
#ifndef thread_safe_increment #ifndef thread_safe_increment
#ifdef HAVE_ATOMIC_ADD
#define thread_safe_increment(V,L) atomic_inc((atomic_t*) &V)
#define thread_safe_decrement(V,L) atomic_dec((atomic_t*) &V)
#define thread_safe_add(V,C,L) atomic_add((C),(atomic_t*) &V)
#define thread_safe_sub(V,C,L) atomic_sub((C),(atomic_t*) &V)
#else
#define thread_safe_increment(V,L) \ #define thread_safe_increment(V,L) \
(pthread_mutex_lock((L)), (V)++, pthread_mutex_unlock((L))) (pthread_mutex_lock((L)), (V)++, pthread_mutex_unlock((L)))
#define thread_safe_decrement(V,L) \ #define thread_safe_decrement(V,L) \
(pthread_mutex_lock((L)), (V)--, pthread_mutex_unlock((L))) (pthread_mutex_lock((L)), (V)--, pthread_mutex_unlock((L)))
#define thread_safe_add(V,C,L) (pthread_mutex_lock((L)), (V)+=(C), pthread_mutex_unlock((L))) #endif
#ifndef thread_safe_add
#define thread_safe_add(V,C,L) \
(pthread_mutex_lock((L)), (V)+=(C), pthread_mutex_unlock((L)))
#define thread_safe_sub(V,C,L) \ #define thread_safe_sub(V,C,L) \
(pthread_mutex_lock((L)), (V)-=(C), pthread_mutex_unlock((L))) (pthread_mutex_lock((L)), (V)-=(C), pthread_mutex_unlock((L)))
#endif /* HAVE_ATOMIC_ADD */ #endif
#endif
/*
statistics_xxx functions are for non critical statistic,
maintained in global variables.
When compiling with SAFE_STATISTICS:
- race conditions can not occur.
- some locking occurs, which may cause performance degradation.
When compiling without SAFE_STATISTICS:
- race conditions can occur, making the result slightly inaccurate.
- the lock given is not honored.
*/
#ifdef SAFE_STATISTICS #ifdef SAFE_STATISTICS
#define statistic_increment(V,L) thread_safe_increment((V),(L)) #define statistic_increment(V,L) thread_safe_increment((V),(L))
#define statistic_decrement(V,L) thread_safe_decrement((V),(L)) #define statistic_decrement(V,L) thread_safe_decrement((V),(L))
#define statistic_add(V,C,L) thread_safe_add((V),(C),(L)) #define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
#define statistic_sub(V,C,L) thread_safe_sub((V),(C),(L))
#else #else
#define statistic_decrement(V,L) (V)-- #define statistic_decrement(V,L) (V)--
#define statistic_increment(V,L) (V)++ #define statistic_increment(V,L) (V)++
#define statistic_add(V,C,L) (V)+=(C) #define statistic_add(V,C,L) (V)+=(C)
#define statistic_sub(V,C,L) (V)-=(C)
#endif /* SAFE_STATISTICS */ #endif /* SAFE_STATISTICS */
#endif /* thread_safe_increment */
/*
No locking needed, the counter is owned by the thread
*/
#define status_var_increment(V) (V)++
#define status_var_decrement(V) (V)--
#define status_var_add(V,C) (V)+=(C)
#define status_var_sub(V,C) (V)-=(C)
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -41,7 +41,7 @@ extern int NEAR my_errno; /* Last error in mysys */
#define ERRMSGSIZE (SC_MAXWIDTH) /* Max length of a error message */ #define ERRMSGSIZE (SC_MAXWIDTH) /* Max length of a error message */
#define NRERRBUFFS (2) /* Buffers for parameters */ #define NRERRBUFFS (2) /* Buffers for parameters */
#define MY_FILE_ERROR ((uint) ~0) #define MY_FILE_ERROR ((size_t) -1)
/* General bitmaps for my_func's */ /* General bitmaps for my_func's */
#define MY_FFNF 1 /* Fatal if file not found */ #define MY_FFNF 1 /* Fatal if file not found */
@ -66,8 +66,8 @@ extern int NEAR my_errno; /* Last error in mysys */
#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_THREADSAFE 128 /* pread/pwrite: Don't allow interrupts */
#define MY_DONT_OVERWRITE_FILE 1024 /* my_copy: Don't overwrite file */ #define MY_DONT_OVERWRITE_FILE 1024 /* my_copy: Don't overwrite file */
#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 */
#define MY_GIVE_INFO 2 /* Give time info about process*/ #define MY_GIVE_INFO 2 /* Give time info about process*/
@ -150,16 +150,16 @@ extern ulonglong sf_malloc_mem_limit;
#else #else
#define my_checkmalloc() #define my_checkmalloc()
#undef TERMINATE #undef TERMINATE
#define TERMINATE(A) {} #define TERMINATE(A,B) {}
#define QUICK_SAFEMALLOC #define QUICK_SAFEMALLOC
#define NORMAL_SAFEMALLOC #define NORMAL_SAFEMALLOC
extern gptr my_malloc(uint Size,myf MyFlags); extern void *my_malloc(size_t Size,myf MyFlags);
#define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG ) #define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG )
extern gptr my_realloc(gptr oldpoint,uint Size,myf MyFlags); extern void *my_realloc(void *oldpoint, size_t Size, myf MyFlags);
extern void my_no_flags_free(gptr ptr); extern void my_no_flags_free(void *ptr);
extern gptr my_memdup(const byte *from,uint length,myf MyFlags); extern void *my_memdup(const void *from,size_t length,myf MyFlags);
extern char *my_strdup(const char *from,myf MyFlags); extern char *my_strdup(const char *from,myf MyFlags);
extern char *my_strndup(const char *from, uint length, extern char *my_strndup(const char *from, size_t length,
myf MyFlags); myf MyFlags);
/* we do use FG (as a no-op) in below so that a typo on FG is caught */ /* we do use FG (as a no-op) in below so that a typo on FG is caught */
#define my_free(PTR,FG) ((void)FG,my_no_flags_free(PTR)) #define my_free(PTR,FG) ((void)FG,my_no_flags_free(PTR))
@ -171,8 +171,8 @@ extern char *my_strndup(const char *from, uint length,
#ifdef HAVE_LARGE_PAGES #ifdef HAVE_LARGE_PAGES
extern uint my_get_large_page_size(void); extern uint my_get_large_page_size(void);
extern gptr my_large_malloc(uint size, myf my_flags); extern uchar * my_large_malloc(size_t size, myf my_flags);
extern void my_large_free(gptr ptr, myf my_flags); extern void my_large_free(uchar * ptr, myf my_flags);
#else #else
#define my_get_large_page_size() (0) #define my_get_large_page_size() (0)
#define my_large_malloc(A,B) my_malloc_lock((A),(B)) #define my_large_malloc(A,B) my_malloc_lock((A),(B))
@ -225,6 +225,7 @@ extern CHARSET_INFO compiled_charsets[];
/* statistics */ /* statistics */
extern ulong my_file_opened,my_stream_opened, my_tmp_file_created; extern ulong my_file_opened,my_stream_opened, my_tmp_file_created;
extern ulong my_file_total_opened;
extern uint mysys_usage_id; extern uint mysys_usage_id;
extern my_bool my_init_done; extern my_bool my_init_done;
@ -258,7 +259,7 @@ typedef struct wild_file_pack /* Struct to hold info when selecting files */
{ {
uint wilds; /* How many wildcards */ uint wilds; /* How many wildcards */
uint not_pos; /* Start of not-theese-files */ uint not_pos; /* Start of not-theese-files */
my_string *wild; /* Pointer to wildcards */ char * *wild; /* Pointer to wildcards */
} WF_PACK; } WF_PACK;
enum loglevel { enum loglevel {
@ -284,7 +285,7 @@ typedef struct st_record_cache /* Used when cacheing records */
int rc_seek,error,inited; int rc_seek,error,inited;
uint rc_length,read_length,reclength; uint rc_length,read_length,reclength;
my_off_t rc_record_pos,end_of_file; my_off_t rc_record_pos,end_of_file;
byte *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos; uchar *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos;
#ifdef HAVE_AIOWAIT #ifdef HAVE_AIOWAIT
int use_async_io; int use_async_io;
my_aio_result aio_result; my_aio_result aio_result;
@ -300,7 +301,7 @@ enum file_type
struct st_my_file_info struct st_my_file_info
{ {
my_string name; char * name;
enum file_type type; enum file_type type;
#if defined(THREAD) && !defined(HAVE_PREAD) #if defined(THREAD) && !defined(HAVE_PREAD)
pthread_mutex_t mutex; pthread_mutex_t mutex;
@ -311,7 +312,7 @@ extern struct st_my_file_info *my_file_info;
typedef struct st_dynamic_array typedef struct st_dynamic_array
{ {
char *buffer; uchar *buffer;
uint elements,max_element; uint elements,max_element;
uint alloc_increment; uint alloc_increment;
uint size_of_element; uint size_of_element;
@ -330,7 +331,7 @@ typedef struct st_my_tmpdir
typedef struct st_dynamic_string typedef struct st_dynamic_string
{ {
char *str; char *str;
uint length,max_length,alloc_increment; size_t length,max_length,alloc_increment;
} DYNAMIC_STRING; } DYNAMIC_STRING;
struct st_io_cache; struct st_io_cache;
@ -346,8 +347,8 @@ typedef struct st_io_cache_share
my_off_t pos_in_file; my_off_t pos_in_file;
/* If a synchronized write cache is the source of the data. */ /* If a synchronized write cache is the source of the data. */
struct st_io_cache *source_cache; struct st_io_cache *source_cache;
byte *buffer; /* The read buffer. */ uchar *buffer; /* The read buffer. */
byte *read_end; /* Behind last valid byte of buffer. */ uchar *read_end; /* Behind last valid byte of buffer. */
int running_threads; /* threads not in lock. */ int running_threads; /* threads not in lock. */
int total_threads; /* threads sharing the cache. */ int total_threads; /* threads sharing the cache. */
int error; /* Last error. */ int error; /* Last error. */
@ -360,7 +361,7 @@ typedef struct st_io_cache_share
typedef struct st_io_cache /* Used when cacheing files */ typedef struct st_io_cache /* Used when cacheing files */
{ {
/* Offset in file corresponding to the first byte of byte* buffer. */ /* Offset in file corresponding to the first byte of uchar* buffer. */
my_off_t pos_in_file; my_off_t pos_in_file;
/* /*
The offset of end of file for READ_CACHE and WRITE_CACHE. The offset of end of file for READ_CACHE and WRITE_CACHE.
@ -369,26 +370,26 @@ typedef struct st_io_cache /* Used when cacheing files */
*/ */
my_off_t end_of_file; my_off_t end_of_file;
/* Points to current read position in the buffer */ /* Points to current read position in the buffer */
byte *read_pos; uchar *read_pos;
/* the non-inclusive boundary in the buffer for the currently valid read */ /* the non-inclusive boundary in the buffer for the currently valid read */
byte *read_end; uchar *read_end;
byte *buffer; /* The read buffer */ uchar *buffer; /* The read buffer */
/* Used in ASYNC_IO */ /* Used in ASYNC_IO */
byte *request_pos; uchar *request_pos;
/* Only used in WRITE caches and in SEQ_READ_APPEND to buffer writes */ /* Only used in WRITE caches and in SEQ_READ_APPEND to buffer writes */
byte *write_buffer; uchar *write_buffer;
/* /*
Only used in SEQ_READ_APPEND, and points to the current read position Only used in SEQ_READ_APPEND, and points to the current read position
in the write buffer. Note that reads in SEQ_READ_APPEND caches can in the write buffer. Note that reads in SEQ_READ_APPEND caches can
happen from both read buffer (byte* buffer) and write buffer happen from both read buffer (uchar* buffer) and write buffer
(byte* write_buffer). (uchar* write_buffer).
*/ */
byte *append_read_pos; uchar *append_read_pos;
/* Points to current write position in the write buffer */ /* Points to current write position in the write buffer */
byte *write_pos; uchar *write_pos;
/* The non-inclusive boundary of the valid write area */ /* The non-inclusive boundary of the valid write area */
byte *write_end; uchar *write_end;
/* /*
Current_pos and current_end are convenience variables used by Current_pos and current_end are convenience variables used by
@ -396,7 +397,7 @@ typedef struct st_io_cache /* Used when cacheing files */
current_pos points to &write_pos, and current_end to &write_end in a current_pos points to &write_pos, and current_end to &write_end in a
WRITE_CACHE, and &read_pos and &read_end respectively otherwise WRITE_CACHE, and &read_pos and &read_end respectively otherwise
*/ */
byte **current_pos, **current_end; uchar **current_pos, **current_end;
#ifdef THREAD #ifdef THREAD
/* /*
The lock is for append buffer used in SEQ_READ_APPEND cache The lock is for append buffer used in SEQ_READ_APPEND cache
@ -420,12 +421,12 @@ typedef struct st_io_cache /* Used when cacheing files */
my_b_read() will call read_function to fetch the data. read_function my_b_read() will call read_function to fetch the data. read_function
must never be invoked directly. must never be invoked directly.
*/ */
int (*read_function)(struct st_io_cache *,byte *,uint); int (*read_function)(struct st_io_cache *,uchar *,size_t);
/* /*
Same idea as in the case of read_function, except my_b_write() needs to Same idea as in the case of read_function, except my_b_write() needs to
be replaced with my_b_append() for a SEQ_READ_APPEND cache be replaced with my_b_append() for a SEQ_READ_APPEND cache
*/ */
int (*write_function)(struct st_io_cache *,const byte *,uint); int (*write_function)(struct st_io_cache *,const uchar *,size_t);
/* /*
Specifies the type of the cache. Depending on the type of the cache Specifies the type of the cache. Depending on the type of the cache
certain operations might not be available and yield unpredicatable certain operations might not be available and yield unpredicatable
@ -460,9 +461,9 @@ typedef struct st_io_cache /* Used when cacheing files */
*/ */
int seek_not_done,error; int seek_not_done,error;
/* buffer_length is memory size allocated for buffer or write_buffer */ /* buffer_length is memory size allocated for buffer or write_buffer */
uint buffer_length; size_t buffer_length;
/* read_length is the same as buffer_length except when we use async io */ /* read_length is the same as buffer_length except when we use async io */
uint read_length; size_t read_length;
myf myflags; /* Flags used to my_read/my_write */ myf myflags; /* Flags used to my_read/my_write */
/* /*
alloced_buffer is 1 if the buffer was allocated by init_io_cache() and alloced_buffer is 1 if the buffer was allocated by init_io_cache() and
@ -518,14 +519,14 @@ typedef int (*qsort2_cmp)(const void *, const void *, const void *);
(((info)->read_end=(info)->read_pos),(*(info)->read_function)(info,0,0)) (((info)->read_end=(info)->read_pos),(*(info)->read_function)(info,0,0))
#define my_b_tell(info) ((info)->pos_in_file + \ #define my_b_tell(info) ((info)->pos_in_file + \
(uint) (*(info)->current_pos - (info)->request_pos)) (size_t) (*(info)->current_pos - (info)->request_pos))
/* tell write offset in the SEQ_APPEND cache */ /* tell write offset in the SEQ_APPEND cache */
int my_b_copy_to_file(IO_CACHE *cache, FILE *file); int my_b_copy_to_file(IO_CACHE *cache, FILE *file);
my_off_t my_b_append_tell(IO_CACHE* info); my_off_t my_b_append_tell(IO_CACHE* info);
my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */ my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */
#define my_b_bytes_in_cache(info) (uint) (*(info)->current_end - \ #define my_b_bytes_in_cache(info) (size_t) (*(info)->current_end - \
*(info)->current_pos) *(info)->current_pos)
typedef uint32 ha_checksum; typedef uint32 ha_checksum;
@ -542,13 +543,13 @@ typedef int (*Process_option_func)(void *ctx, const char *group_name,
extern int my_copy(const char *from,const char *to,myf MyFlags); extern int my_copy(const char *from,const char *to,myf MyFlags);
extern int my_append(const char *from,const char *to,myf MyFlags); extern int my_append(const char *from,const char *to,myf MyFlags);
extern int my_delete(const char *name,myf MyFlags); extern int my_delete(const char *name,myf MyFlags);
extern int my_getwd(my_string buf,uint size,myf MyFlags); extern int my_getwd(char * buf,size_t size,myf MyFlags);
extern int my_setwd(const char *dir,myf MyFlags); extern int my_setwd(const char *dir,myf MyFlags);
extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags); extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags);
extern gptr my_once_alloc(uint Size,myf MyFlags); extern void *my_once_alloc(size_t Size,myf MyFlags);
extern void my_once_free(void); extern void my_once_free(void);
extern char *my_once_strdup(const char *src,myf myflags); extern char *my_once_strdup(const char *src,myf myflags);
extern char *my_once_memdup(const char *src, uint len, myf myflags); extern void *my_once_memdup(const void *src, size_t len, myf myflags);
extern File my_open(const char *FileName,int Flags,myf MyFlags); extern File my_open(const char *FileName,int Flags,myf MyFlags);
extern File my_register_filename(File fd, const char *FileName, extern File my_register_filename(File fd, const char *FileName,
enum file_type type_of_file, enum file_type type_of_file,
@ -566,39 +567,39 @@ extern File my_create_with_symlink(const char *linkname, const char *filename,
extern int my_delete_with_symlink(const char *name, myf MyFlags); extern int my_delete_with_symlink(const char *name, myf MyFlags);
extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags); extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags);
extern int my_symlink(const char *content, const char *linkname, myf MyFlags); extern int my_symlink(const char *content, const char *linkname, myf MyFlags);
extern uint my_read(File Filedes,byte *Buffer,uint Count,myf MyFlags); extern size_t my_read(File Filedes,uchar *Buffer,size_t Count,myf MyFlags);
extern uint my_pread(File Filedes,byte *Buffer,uint Count,my_off_t offset, extern size_t my_pread(File Filedes,uchar *Buffer,size_t Count,my_off_t offset,
myf MyFlags); myf MyFlags);
extern int my_rename(const char *from,const char *to,myf MyFlags); extern int my_rename(const char *from,const char *to,myf MyFlags);
extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags); extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags);
extern my_off_t my_tell(File fd,myf MyFlags); extern my_off_t my_tell(File fd,myf MyFlags);
extern uint my_write(File Filedes,const byte *Buffer,uint Count, extern size_t my_write(File Filedes,const uchar *Buffer,size_t Count,
myf MyFlags); myf MyFlags);
extern uint my_pwrite(File Filedes,const byte *Buffer,uint Count, extern size_t my_pwrite(File Filedes,const uchar *Buffer,size_t Count,
my_off_t offset,myf MyFlags); my_off_t offset,myf MyFlags);
extern uint my_fread(FILE *stream,byte *Buffer,uint Count,myf MyFlags); extern size_t my_fread(FILE *stream,uchar *Buffer,size_t Count,myf MyFlags);
extern uint my_fwrite(FILE *stream,const byte *Buffer,uint Count, extern size_t my_fwrite(FILE *stream,const uchar *Buffer,size_t Count,
myf MyFlags); myf MyFlags);
extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags); extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
extern my_off_t my_ftell(FILE *stream,myf MyFlags); extern my_off_t my_ftell(FILE *stream,myf MyFlags);
extern gptr _mymalloc(uint uSize,const char *sFile, extern void *_mymalloc(size_t uSize,const char *sFile,
uint uLine, myf MyFlag); uint uLine, myf MyFlag);
extern gptr _myrealloc(gptr pPtr,uint uSize,const char *sFile, extern void *_myrealloc(void *pPtr,size_t uSize,const char *sFile,
uint uLine, myf MyFlag); uint uLine, myf MyFlag);
extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...)); extern void * my_multi_malloc _VARARGS((myf MyFlags, ...));
extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag); extern void _myfree(void *pPtr,const char *sFile,uint uLine, myf MyFlag);
extern int _sanity(const char *sFile,unsigned int uLine); extern int _sanity(const char *sFile, uint uLine);
extern gptr _my_memdup(const byte *from,uint length, extern void *_my_memdup(const void *from, size_t length,
const char *sFile, uint uLine,myf MyFlag); const char *sFile, uint uLine,myf MyFlag);
extern my_string _my_strdup(const char *from, const char *sFile, uint uLine, extern char * _my_strdup(const char *from, const char *sFile, uint uLine,
myf MyFlag); myf MyFlag);
extern char *_my_strndup(const char *from, uint length, extern char *_my_strndup(const char *from, size_t length,
const char *sFile, uint uLine, const char *sFile, uint uLine,
myf MyFlag); myf MyFlag);
/* implemented in my_memmem.c */ /* implemented in my_memmem.c */
extern void *my_memmem(const void *haystack, size_t haystacklen, extern void *my_memmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen); const void *needle, size_t needlelen);
#ifdef __WIN__ #ifdef __WIN__
@ -618,7 +619,7 @@ extern int nt_share_delete(const char *name,myf MyFlags);
#endif #endif
#ifndef TERMINATE #ifndef TERMINATE
extern void TERMINATE(FILE *file); extern void TERMINATE(FILE *file, uint flag);
#endif #endif
extern void init_glob_errs(void); extern void init_glob_errs(void);
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags); extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
@ -639,7 +640,7 @@ extern my_bool my_init(void);
extern void my_end(int infoflag); extern void my_end(int infoflag);
extern int my_redel(const char *from, const char *to, int MyFlags); extern int my_redel(const char *from, const char *to, int MyFlags);
extern int my_copystat(const char *from, const char *to, int MyFlags); extern int my_copystat(const char *from, const char *to, int MyFlags);
extern my_string my_filename(File fd); extern char * my_filename(File fd);
#ifndef THREAD #ifndef THREAD
extern void dont_break(void); extern void dont_break(void);
@ -660,116 +661,123 @@ 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 uint dirname_part(my_string to,const char *name); extern size_t dirname_part(char * to, const char *name, size_t *to_res_length);
extern uint 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);
extern my_bool has_path(const char *name); extern my_bool has_path(const char *name);
extern char *convert_dirname(char *to, const char *from, const char *from_end); extern char *convert_dirname(char *to, const char *from, const char *from_end);
extern void to_unix_path(my_string name); extern void to_unix_path(char * name);
extern my_string fn_ext(const char *name); extern char * fn_ext(const char *name);
extern my_string fn_same(my_string toname,const char *name,int flag); extern char * fn_same(char * toname,const char *name,int flag);
extern my_string fn_format(my_string to,const char *name,const char *dir, extern char * fn_format(char * to,const char *name,const char *dir,
const char *form, uint flag); const char *form, uint flag);
extern size_s strlength(const char *str); extern size_t strlength(const char *str);
extern void pack_dirname(my_string to,const char *from); extern void pack_dirname(char * to,const char *from);
extern uint unpack_dirname(my_string to,const char *from); extern size_t unpack_dirname(char * to,const char *from);
extern uint cleanup_dirname(my_string to,const char *from); extern size_t cleanup_dirname(char * to,const char *from);
extern uint system_filename(my_string to,const char *from); extern size_t system_filename(char * to,const char *from);
extern uint unpack_filename(my_string to,const char *from); extern size_t unpack_filename(char * to,const char *from);
extern my_string intern_filename(my_string to,const char *from); extern char * intern_filename(char * to,const char *from);
extern my_string directory_file_name(my_string dst, const char *src); extern char * directory_file_name(char * dst, const char *src);
extern int pack_filename(my_string to, const char *name, size_s max_length); extern int pack_filename(char * to, const char *name, size_t max_length);
extern my_string my_path(my_string to,const char *progname, extern char * my_path(char * to,const char *progname,
const char *own_pathname_part); const char *own_pathname_part);
extern my_string my_load_path(my_string to, const char *path, extern char * my_load_path(char * to, const char *path,
const char *own_path_prefix); const char *own_path_prefix);
extern int wild_compare(const char *str,const char *wildstr, extern int wild_compare(const char *str,const char *wildstr,
pbool str_is_pattern); pbool str_is_pattern);
extern WF_PACK *wf_comp(my_string str); extern WF_PACK *wf_comp(char * str);
extern int wf_test(struct wild_file_pack *wf_pack,const char *name); extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
extern void wf_end(struct wild_file_pack *buffer); extern void wf_end(struct wild_file_pack *buffer);
extern size_s strip_sp(my_string str); extern size_t strip_sp(char * str);
extern void get_date(my_string to,int timeflag,time_t use_time); extern void get_date(char * to,int timeflag,time_t use_time);
extern void soundex(CHARSET_INFO *, my_string out_pntr, my_string in_pntr, extern void soundex(CHARSET_INFO *, char * out_pntr, char * in_pntr,
pbool remove_garbage); pbool remove_garbage);
extern int init_record_cache(RECORD_CACHE *info,uint cachesize,File file, extern int init_record_cache(RECORD_CACHE *info,size_t cachesize,File file,
uint reclength,enum cache_type type, size_t reclength,enum cache_type type,
pbool use_async_io); pbool use_async_io);
extern int read_cache_record(RECORD_CACHE *info,byte *to); extern int read_cache_record(RECORD_CACHE *info,uchar *to);
extern int end_record_cache(RECORD_CACHE *info); extern int end_record_cache(RECORD_CACHE *info);
extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos, extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos,
const byte *record,uint length); const uchar *record,size_t length);
extern int flush_write_cache(RECORD_CACHE *info); extern int flush_write_cache(RECORD_CACHE *info);
extern long my_clock(void); extern long my_clock(void);
extern sig_handler sigtstp_handler(int signal_number); 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(void *base,uint items,size_s 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_s size_of_element,uchar *buffer[]); size_t size_of_element,uchar *buffer[]);
extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size, extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size,
qsort2_cmp cmp, void *cmp_argument); qsort2_cmp cmp, void *cmp_argument);
extern qsort2_cmp get_ptr_compare(uint); extern qsort2_cmp get_ptr_compare(size_t);
void my_store_ptr(byte *buff, uint pack_length, my_off_t pos); void my_store_ptr(uchar *buff, size_t pack_length, my_off_t pos);
my_off_t my_get_ptr(byte *ptr, uint pack_length); my_off_t my_get_ptr(uchar *ptr, size_t pack_length);
extern int init_io_cache(IO_CACHE *info,File file,uint cachesize, extern int init_io_cache(IO_CACHE *info,File file,size_t cachesize,
enum cache_type type,my_off_t seek_offset, enum cache_type type,my_off_t seek_offset,
pbool use_async_io, myf cache_myflags); pbool use_async_io, myf cache_myflags);
extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type, extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
my_off_t seek_offset,pbool use_async_io, my_off_t seek_offset,pbool use_async_io,
pbool clear_cache); pbool clear_cache);
extern void setup_io_cache(IO_CACHE* info); extern void setup_io_cache(IO_CACHE* info);
extern int _my_b_read(IO_CACHE *info,byte *Buffer,uint Count); extern int _my_b_read(IO_CACHE *info,uchar *Buffer,size_t Count);
#ifdef THREAD #ifdef THREAD
extern int _my_b_read_r(IO_CACHE *info,byte *Buffer,uint Count); extern int _my_b_read_r(IO_CACHE *info,uchar *Buffer,size_t Count);
extern void init_io_cache_share(IO_CACHE *read_cache, IO_CACHE_SHARE *cshare, extern void init_io_cache_share(IO_CACHE *read_cache, IO_CACHE_SHARE *cshare,
IO_CACHE *write_cache, uint num_threads); IO_CACHE *write_cache, uint num_threads);
extern void remove_io_thread(IO_CACHE *info); extern void remove_io_thread(IO_CACHE *info);
#endif #endif
extern int _my_b_seq_read(IO_CACHE *info,byte *Buffer,uint Count); extern int _my_b_seq_read(IO_CACHE *info,uchar *Buffer,size_t Count);
extern int _my_b_net_read(IO_CACHE *info,byte *Buffer,uint Count); extern int _my_b_net_read(IO_CACHE *info,uchar *Buffer,size_t Count);
extern int _my_b_get(IO_CACHE *info); extern int _my_b_get(IO_CACHE *info);
extern int _my_b_async_read(IO_CACHE *info,byte *Buffer,uint Count); extern int _my_b_async_read(IO_CACHE *info,uchar *Buffer,size_t Count);
extern int _my_b_write(IO_CACHE *info,const byte *Buffer,uint Count); extern int _my_b_write(IO_CACHE *info,const uchar *Buffer,size_t Count);
extern int my_b_append(IO_CACHE *info,const byte *Buffer,uint Count); extern int my_b_append(IO_CACHE *info,const uchar *Buffer,size_t Count);
extern int my_b_safe_write(IO_CACHE *info,const byte *Buffer,uint Count); extern int my_b_safe_write(IO_CACHE *info,const uchar *Buffer,size_t Count);
extern int my_block_write(IO_CACHE *info, const byte *Buffer, extern int my_block_write(IO_CACHE *info, const uchar *Buffer,
uint Count, my_off_t pos); size_t Count, my_off_t pos);
extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock); extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock);
#define flush_io_cache(info) my_b_flush_io_cache((info),1) #define flush_io_cache(info) my_b_flush_io_cache((info),1)
extern int end_io_cache(IO_CACHE *info); extern int end_io_cache(IO_CACHE *info);
extern uint my_b_fill(IO_CACHE *info); extern size_t my_b_fill(IO_CACHE *info);
extern void my_b_seek(IO_CACHE *info,my_off_t pos); extern void my_b_seek(IO_CACHE *info,my_off_t pos);
extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length); extern size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length);
extern my_off_t my_b_filelength(IO_CACHE *info); extern my_off_t my_b_filelength(IO_CACHE *info);
extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...); extern size_t my_b_printf(IO_CACHE *info, const char* fmt, ...);
extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap); extern size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
extern my_bool open_cached_file(IO_CACHE *cache,const char *dir, extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
const char *prefix, uint cache_size, const char *prefix, size_t cache_size,
myf cache_myflags); myf cache_myflags);
extern my_bool real_open_cached_file(IO_CACHE *cache); extern my_bool real_open_cached_file(IO_CACHE *cache);
extern void close_cached_file(IO_CACHE *cache); extern void close_cached_file(IO_CACHE *cache);
File create_temp_file(char *to, const char *dir, const char *pfx, File create_temp_file(char *to, const char *dir, const char *pfx,
int mode, myf MyFlags); int mode, myf MyFlags);
#define my_init_dynamic_array(A,B,C,D) init_dynamic_array(A,B,C,D CALLER_INFO) #define my_init_dynamic_array(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D CALLER_INFO)
#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array(A,B,C,D ORIG_CALLER_INFO) #define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D ORIG_CALLER_INFO)
#define my_init_dynamic_array2(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E CALLER_INFO)
#define my_init_dynamic_array2_ci(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E ORIG_CALLER_INFO)
extern my_bool init_dynamic_array2(DYNAMIC_ARRAY *array,uint element_size,
void *init_buffer, uint init_alloc,
uint alloc_increment
CALLER_INFO_PROTO);
/* init_dynamic_array() function is deprecated */
extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size, extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size,
uint init_alloc,uint alloc_increment uint init_alloc,uint alloc_increment
CALLER_INFO_PROTO); CALLER_INFO_PROTO);
extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,gptr element); extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,uchar * element);
extern byte *alloc_dynamic(DYNAMIC_ARRAY *array); extern uchar *alloc_dynamic(DYNAMIC_ARRAY *array);
extern byte *pop_dynamic(DYNAMIC_ARRAY*); extern uchar *pop_dynamic(DYNAMIC_ARRAY*);
extern my_bool set_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index); extern my_bool set_dynamic(DYNAMIC_ARRAY *array,uchar * element,uint array_index);
extern void get_dynamic(DYNAMIC_ARRAY *array,gptr 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);
extern void freeze_size(DYNAMIC_ARRAY *array); extern void freeze_size(DYNAMIC_ARRAY *array);
extern int get_index_dynamic(DYNAMIC_ARRAY *array, gptr element); extern int get_index_dynamic(DYNAMIC_ARRAY *array, uchar * element);
#define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element) #define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element)
#define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index)) #define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
#define push_dynamic(A,B) insert_dynamic((A),(B)) #define push_dynamic(A,B) insert_dynamic((A),(B))
@ -777,19 +785,19 @@ extern int get_index_dynamic(DYNAMIC_ARRAY *array, gptr element);
#define sort_dynamic(A,cmp) qsort((A)->buffer, (A)->elements, (A)->size_of_element, (cmp)) #define sort_dynamic(A,cmp) qsort((A)->buffer, (A)->elements, (A)->size_of_element, (cmp))
extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str, extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
uint init_alloc,uint alloc_increment); size_t init_alloc,size_t alloc_increment);
extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append); extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append);
my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append, my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
uint length); size_t length);
extern my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, extern my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append,
...); ...);
extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str); extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
extern my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size); extern my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size);
extern my_bool dynstr_trunc(DYNAMIC_STRING *str, int n); extern my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n);
extern void dynstr_free(DYNAMIC_STRING *str); extern void dynstr_free(DYNAMIC_STRING *str);
#ifdef HAVE_MLOCK #ifdef HAVE_MLOCK
extern byte *my_malloc_lock(uint length,myf flags); extern void *my_malloc_lock(size_t length,myf flags);
extern void my_free_lock(byte *ptr,myf flags); extern void my_free_lock(void *ptr,myf flags);
#else #else
#define my_malloc_lock(A,B) my_malloc((A),(B)) #define my_malloc_lock(A,B) my_malloc((A),(B))
#define my_free_lock(A,B) my_free((A),(B)) #define my_free_lock(A,B) my_free((A),(B))
@ -797,17 +805,17 @@ extern void my_free_lock(byte *ptr,myf flags);
#define alloc_root_inited(A) ((A)->min_malloc != 0) #define alloc_root_inited(A) ((A)->min_malloc != 0)
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8) #define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0) #define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size, extern void init_alloc_root(MEM_ROOT *mem_root, size_t block_size,
uint pre_alloc_size); size_t pre_alloc_size);
extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size); extern void *alloc_root(MEM_ROOT *mem_root, size_t Size);
extern gptr multi_alloc_root(MEM_ROOT *mem_root, ...); extern void *multi_alloc_root(MEM_ROOT *mem_root, ...);
extern void free_root(MEM_ROOT *root, myf MyFLAGS); extern void free_root(MEM_ROOT *root, myf MyFLAGS);
extern void set_prealloc_root(MEM_ROOT *root, char *ptr); extern void set_prealloc_root(MEM_ROOT *root, char *ptr);
extern void reset_root_defaults(MEM_ROOT *mem_root, uint block_size, extern void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
uint prealloc_size); size_t prealloc_size);
extern char *strdup_root(MEM_ROOT *root,const char *str); extern char *strdup_root(MEM_ROOT *root,const char *str);
extern char *strmake_root(MEM_ROOT *root,const char *str,uint len); extern char *strmake_root(MEM_ROOT *root,const char *str,size_t len);
extern char *memdup_root(MEM_ROOT *root,const char *str,uint len); extern void *memdup_root(MEM_ROOT *root,const void *str, size_t len);
extern int get_defaults_options(int argc, char **argv, extern int get_defaults_options(int argc, char **argv,
char **defaults, char **extra_defaults, char **defaults, char **extra_defaults,
char **group_suffix); char **group_suffix);
@ -822,23 +830,28 @@ extern int my_search_option_files(const char *conf_file, int *argc,
extern void free_defaults(char **argv); extern void free_defaults(char **argv);
extern void my_print_default_files(const char *conf_file); extern void my_print_default_files(const char *conf_file);
extern void print_defaults(const char *conf_file, const char **groups); extern void print_defaults(const char *conf_file, const char **groups);
extern my_bool my_compress(byte *, ulong *, ulong *); extern my_bool my_compress(uchar *, size_t *, size_t *);
extern my_bool my_uncompress(byte *, ulong *, ulong *); extern my_bool my_uncompress(uchar *, size_t , size_t *);
extern byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen); extern uchar *my_compress_alloc(const uchar *packet, size_t *len,
extern int packfrm(const void *, uint, const void **, uint *); size_t *complen);
extern int unpackfrm(const void **, uint *, const void *); extern int packfrm(uchar *, size_t, uchar **, size_t *);
extern int unpackfrm(uchar **, size_t *, const uchar *);
extern ha_checksum my_checksum(ha_checksum crc, const byte *mem, uint count); extern ha_checksum my_checksum(ha_checksum crc, const uchar *mem,
size_t count);
extern uint my_bit_log2(ulong value); extern uint my_bit_log2(ulong value);
extern uint32 my_round_up_to_next_power(uint32 v); extern uint32 my_round_up_to_next_power(uint32 v);
extern uint my_count_bits(ulonglong v); extern uint my_count_bits(ulonglong v);
extern uint my_count_bits_ushort(ushort 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);
extern time_t my_time(myf flags);
extern ulonglong my_getsystime(void); extern ulonglong my_getsystime(void);
extern ulonglong my_micro_time();
extern ulonglong my_micro_time_and_time(time_t *time_arg);
time_t my_time_possible_from_micro(ulonglong microtime);
extern my_bool my_gethwaddr(uchar *to); extern my_bool my_gethwaddr(uchar *to);
extern int my_getncpus(); extern int my_getncpus();
@ -896,22 +909,30 @@ extern CHARSET_INFO *get_charset(uint cs_number, myf flags);
extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags); extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
extern CHARSET_INFO *get_charset_by_csname(const char *cs_name, extern CHARSET_INFO *get_charset_by_csname(const char *cs_name,
uint cs_flags, myf my_flags); uint cs_flags, myf my_flags);
extern bool resolve_charset(const char *cs_name,
CHARSET_INFO *default_cs,
CHARSET_INFO **cs);
extern bool resolve_collation(const char *cl_name,
CHARSET_INFO *default_cl,
CHARSET_INFO **cl);
extern void free_charsets(void); extern void free_charsets(void);
extern char *get_charsets_dir(char *buf); extern char *get_charsets_dir(char *buf);
extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2); extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2);
extern my_bool init_compiled_charsets(myf flags); extern my_bool init_compiled_charsets(myf flags);
extern void add_compiled_collation(CHARSET_INFO *cs); extern void add_compiled_collation(CHARSET_INFO *cs);
extern ulong escape_string_for_mysql(CHARSET_INFO *charset_info, extern size_t escape_string_for_mysql(CHARSET_INFO *charset_info,
char *to, ulong to_length, char *to, size_t to_length,
const char *from, ulong length); const char *from, size_t length);
#ifdef __WIN__ #ifdef __WIN__
#define BACKSLASH_MBTAIL #define BACKSLASH_MBTAIL
/* File system character set */ /* File system character set */
extern CHARSET_INFO *fs_character_set(void); extern CHARSET_INFO *fs_character_set(void);
#endif #endif
extern ulong escape_quotes_for_mysql(CHARSET_INFO *charset_info, extern size_t escape_quotes_for_mysql(CHARSET_INFO *charset_info,
char *to, ulong to_length, char *to, size_t to_length,
const char *from, ulong length); const char *from, size_t length);
extern void thd_increment_bytes_sent(ulong length); extern void thd_increment_bytes_sent(ulong length);
extern void thd_increment_bytes_received(ulong length); extern void thd_increment_bytes_received(ulong length);
@ -928,7 +949,7 @@ int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror,
void my_security_attr_free(SECURITY_ATTRIBUTES *sa); void my_security_attr_free(SECURITY_ATTRIBUTES *sa);
/* implemented in my_conio.c */ /* implemented in my_conio.c */
char* my_cgets(char *string, unsigned long clen, unsigned long* plen); char* my_cgets(char *string, size_t clen, size_t* plen);
#endif #endif
#ifdef __NETWARE__ #ifdef __NETWARE__

View File

@ -25,10 +25,10 @@ extern "C" {
#define MAX_TREE_HEIGHT 64 #define MAX_TREE_HEIGHT 64
#define ELEMENT_KEY(tree,element)\ #define ELEMENT_KEY(tree,element)\
(tree->offset_to_key ? (void*)((byte*) element+tree->offset_to_key) :\ (tree->offset_to_key ? (void*)((uchar*) element+tree->offset_to_key) :\
*((void**) (element+1))) *((void**) (element+1)))
#define tree_set_pointer(element,ptr) *((byte **) (element+1))=((byte*) (ptr)) #define tree_set_pointer(element,ptr) *((uchar **) (element+1))=((uchar*) (ptr))
#define TREE_NO_DUPS 1 #define TREE_NO_DUPS 1

View File

@ -22,7 +22,7 @@ extern "C" {
typedef struct st_trie_node typedef struct st_trie_node
{ {
uint16 leaf; /* Depth from root node if match, 0 else */ uint16 leaf; /* Depth from root node if match, 0 else */
byte c; /* Label on this edge */ uchar c; /* Label on this edge */
struct st_trie_node *next; /* Next label */ struct st_trie_node *next; /* Next label */
struct st_trie_node *links; /* Array of edges leaving this node */ struct st_trie_node *links; /* Array of edges leaving this node */
struct st_trie_node *fail; /* AC failure function */ struct st_trie_node *fail; /* AC failure function */
@ -45,14 +45,14 @@ typedef struct st_ac_trie_state
extern TRIE *trie_init (TRIE *trie, CHARSET_INFO *charset); extern TRIE *trie_init (TRIE *trie, CHARSET_INFO *charset);
extern void trie_free (TRIE *trie); extern void trie_free (TRIE *trie);
extern my_bool trie_insert (TRIE *trie, const byte *key, uint keylen); extern my_bool trie_insert (TRIE *trie, const uchar *key, uint keylen);
extern my_bool ac_trie_prepare (TRIE *trie); extern my_bool ac_trie_prepare (TRIE *trie);
extern void ac_trie_init (TRIE *trie, AC_TRIE_STATE *state); extern void ac_trie_init (TRIE *trie, AC_TRIE_STATE *state);
/* `trie_goto' is internal function and shouldn't be used. */ /* `trie_goto' is internal function and shouldn't be used. */
static inline TRIE_NODE *trie_goto (TRIE_NODE *root, TRIE_NODE *node, byte c) static inline TRIE_NODE *trie_goto (TRIE_NODE *root, TRIE_NODE *node, uchar c)
{ {
TRIE_NODE *next; TRIE_NODE *next;
DBUG_ENTER("trie_goto"); DBUG_ENTER("trie_goto");
@ -67,7 +67,7 @@ static inline TRIE_NODE *trie_goto (TRIE_NODE *root, TRIE_NODE *node, byte c)
/* /*
SYNOPSIS SYNOPSIS
int ac_trie_next (AC_TRIE_STATE *state, byte *c); int ac_trie_next (AC_TRIE_STATE *state, uchar *c);
state - valid pointer to `AC_TRIE_STATE' state - valid pointer to `AC_TRIE_STATE'
c - character to lookup c - character to lookup
@ -79,7 +79,7 @@ static inline TRIE_NODE *trie_goto (TRIE_NODE *root, TRIE_NODE *node, byte c)
`ac_trie_next' returns length of matched word or 0. `ac_trie_next' returns length of matched word or 0.
*/ */
static inline int ac_trie_next (AC_TRIE_STATE *state, byte *c) static inline int ac_trie_next (AC_TRIE_STATE *state, uchar *c)
{ {
TRIE_NODE *root, *node; TRIE_NODE *root, *node;
DBUG_ENTER("ac_trie_next"); DBUG_ENTER("ac_trie_next");
@ -94,7 +94,7 @@ static inline int ac_trie_next (AC_TRIE_STATE *state, byte *c)
/* /*
SYNOPSIS SYNOPSIS
my_bool trie_search (TRIE *trie, const byte *key, uint keylen); my_bool trie_search (TRIE *trie, const uchar *key, uint keylen);
trie - valid pointer to `TRIE' trie - valid pointer to `TRIE'
key - valid pointer to key to insert key - valid pointer to key to insert
keylen - non-0 key length keylen - non-0 key length
@ -113,7 +113,7 @@ static inline int ac_trie_next (AC_TRIE_STATE *state, byte *c)
consecutive loop better (tested) consecutive loop better (tested)
*/ */
static inline my_bool trie_search (TRIE *trie, const byte *key, uint keylen) static inline my_bool trie_search (TRIE *trie, const uchar *key, uint keylen)
{ {
TRIE_NODE *node; TRIE_NODE *node;
uint k; uint k;
@ -123,7 +123,7 @@ static inline my_bool trie_search (TRIE *trie, const byte *key, uint keylen)
for (k= 0; k < keylen; k++) for (k= 0; k < keylen; k++)
{ {
byte p; uchar p;
if (! (node= node->links)) if (! (node= node->links))
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
p= key[k]; p= key[k];

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