merge
BitKeeper/etc/ignore: auto-union acinclude.m4: Auto merged Docs/manual.texi: Auto merged include/my_sys.h: Auto merged include/mysql.h: Auto merged libmysqld/libmysqld.c: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/t/count_distinct2.test: Auto merged mysql-test/t/flush.test: Auto merged mysql-test/t/rpl000017.test: Auto merged libmysql/libmysql.c: Auto merged mysys/Makefile.am: Auto merged sql/Makefile.am: Auto merged sql/handler.cc: Auto merged sql/item_func.cc: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged libmysqld/Makefile.am: Added back md5.c
This commit is contained in:
commit
515c747dcf
@ -7,6 +7,7 @@
|
|||||||
*.la
|
*.la
|
||||||
*.lo
|
*.lo
|
||||||
*.o
|
*.o
|
||||||
|
*.reject
|
||||||
*.spec
|
*.spec
|
||||||
*/*_pure_*warnings
|
*/*_pure_*warnings
|
||||||
*/.pure
|
*/.pure
|
||||||
@ -152,6 +153,7 @@ client/mysqlbinlog
|
|||||||
client/mysqlcheck
|
client/mysqlcheck
|
||||||
client/mysqldump
|
client/mysqldump
|
||||||
client/mysqlimport
|
client/mysqlimport
|
||||||
|
client/mysqlmanager-pwgen
|
||||||
client/mysqlmanagerc
|
client/mysqlmanagerc
|
||||||
client/mysqlshow
|
client/mysqlshow
|
||||||
client/mysqltest
|
client/mysqltest
|
||||||
@ -214,6 +216,7 @@ libmysqld/examples/mysqltest.c
|
|||||||
libmysqld/examples/readline.cc
|
libmysqld/examples/readline.cc
|
||||||
libmysqld/examples/sql_string.cc
|
libmysqld/examples/sql_string.cc
|
||||||
libmysqld/examples/sql_string.h
|
libmysqld/examples/sql_string.h
|
||||||
|
libmysqld/examples/test-gdbinit
|
||||||
libmysqld/field.cc
|
libmysqld/field.cc
|
||||||
libmysqld/field_conv.cc
|
libmysqld/field_conv.cc
|
||||||
libmysqld/filesort.cc
|
libmysqld/filesort.cc
|
||||||
@ -337,6 +340,7 @@ scripts/make_binary_distribution
|
|||||||
scripts/msql2mysql
|
scripts/msql2mysql
|
||||||
scripts/mysql_config
|
scripts/mysql_config
|
||||||
scripts/mysql_convert_table_format
|
scripts/mysql_convert_table_format
|
||||||
|
scripts/mysql_explain_log
|
||||||
scripts/mysql_find_rows
|
scripts/mysql_find_rows
|
||||||
scripts/mysql_fix_privilege_tables
|
scripts/mysql_fix_privilege_tables
|
||||||
scripts/mysql_install_db
|
scripts/mysql_install_db
|
||||||
@ -413,5 +417,3 @@ vio/test-ssl
|
|||||||
vio/test-sslclient
|
vio/test-sslclient
|
||||||
vio/test-sslserver
|
vio/test-sslserver
|
||||||
vio/viotest-ssl
|
vio/viotest-ssl
|
||||||
client/mysqlmanager-pwgen
|
|
||||||
*.reject
|
|
||||||
|
197
Docs/manual.texi
197
Docs/manual.texi
@ -34122,10 +34122,12 @@ detect duplicated @code{UNIQUE} keys.
|
|||||||
@item
|
@item
|
||||||
By using @code{DATA DIRECTORY="directory"} or @code{INDEX
|
By using @code{DATA DIRECTORY="directory"} or @code{INDEX
|
||||||
DIRECTORY="directory"} you can specify where the table handler should
|
DIRECTORY="directory"} you can specify where the table handler should
|
||||||
put it's table and index files. This only works for @code{MyISAM} tables
|
put it's table and index files. Note that the directory should be a full
|
||||||
in @code{MySQL} 4.0, when you are not using the @code{--skip-symlink}
|
path to the directory (not relative path).
|
||||||
option. @xref{Symbolic links to tables}.
|
|
||||||
|
|
||||||
|
This only works for @code{MyISAM} tables in @code{MySQL} 4.0, when you
|
||||||
|
are not using the @code{--skip-symlink} option. @xref{Symbolic links to
|
||||||
|
tables}.
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
|
|
||||||
@ -42012,7 +42014,7 @@ a stand-alone server without modifying any code.
|
|||||||
|
|
||||||
@findex @code{mysql_server_init()}
|
@findex @code{mysql_server_init()}
|
||||||
|
|
||||||
@code{int mysql_server_init(int argc, const char **argv, const char **groups)}
|
@code{int mysql_server_init(int argc, char **argv, char **groups)}
|
||||||
|
|
||||||
@subsubheading Description
|
@subsubheading Description
|
||||||
|
|
||||||
@ -42032,8 +42034,8 @@ command-line arguments for the server.
|
|||||||
The @code{NULL}-terminated list of strings in @code{groups}
|
The @code{NULL}-terminated list of strings in @code{groups}
|
||||||
selects which groups in the option files will be active.
|
selects which groups in the option files will be active.
|
||||||
@xref{Option files}. For convenience, @code{groups} may be
|
@xref{Option files}. For convenience, @code{groups} may be
|
||||||
@code{NULL}, in which case the @code{[server]} group will be
|
@code{NULL}, in which case the @code{[server]} and @code{[emedded]} groups
|
||||||
active.
|
will be active.
|
||||||
|
|
||||||
@subsubheading Example
|
@subsubheading Example
|
||||||
|
|
||||||
@ -42047,6 +42049,7 @@ static char *server_args[] = @{
|
|||||||
"--set-variable=key_buffer_size=32M"
|
"--set-variable=key_buffer_size=32M"
|
||||||
@};
|
@};
|
||||||
static char *server_groups[] = @{
|
static char *server_groups[] = @{
|
||||||
|
"embedded",
|
||||||
"server",
|
"server",
|
||||||
"this_program_SERVER",
|
"this_program_SERVER",
|
||||||
(char *)NULL
|
(char *)NULL
|
||||||
@ -42379,6 +42382,9 @@ included the thread libraries on the link/compile line.
|
|||||||
@menu
|
@menu
|
||||||
* libmysqld overview:: Overview of the Embedded MySQL Server Library
|
* libmysqld overview:: Overview of the Embedded MySQL Server Library
|
||||||
* libmysqld compiling:: Compiling Programs with @code{libmysqld}
|
* libmysqld compiling:: Compiling Programs with @code{libmysqld}
|
||||||
|
* libmysqld restrictions::
|
||||||
|
* libmysqld options::
|
||||||
|
* libmysqld TODO::
|
||||||
* libmysqld example:: A Simple Embedded Server Example
|
* libmysqld example:: A Simple Embedded Server Example
|
||||||
* libmysqld licensing:: Licensing the Embedded Server
|
* libmysqld licensing:: Licensing the Embedded Server
|
||||||
@end menu
|
@end menu
|
||||||
@ -42391,21 +42397,100 @@ full-featured MySQL server inside the client application. The
|
|||||||
main benefits are increased speed and more simple management for
|
main benefits are increased speed and more simple management for
|
||||||
embedded applications.
|
embedded applications.
|
||||||
|
|
||||||
@node libmysqld compiling, libmysqld example, libmysqld overview, libmysqld
|
The API is identical for the embedded MySQL version and MySQL
|
||||||
|
client/server version. To change an old threaded application to use the
|
||||||
|
embedded library, on normall only have to add calls to the following
|
||||||
|
functions:
|
||||||
|
|
||||||
|
@multitable @columnfractions .25 .7
|
||||||
|
@item @code{mysql_server_init()} @tab Should be called before any other other MySQL function is called, preferably early in the @code{main()} function.
|
||||||
|
@item @code{mysql_server_end()} @tab Should be called before doing an exit of your program.
|
||||||
|
@item @code{mysql_thread_init()} @tab Should be called in all threads you are created that will access MySQL.
|
||||||
|
@item @code{mysql_thread_end()} @tab Should be called before calling @code{pthread_exit()}
|
||||||
|
@end multitable
|
||||||
|
|
||||||
|
and link your code with @code{libmysqld.a} instead of @code{libmysqlclient.a}.
|
||||||
|
|
||||||
|
The above @code{mysql_server_xxx} functions are also included in
|
||||||
|
@code{libmysqld.a} to allow you to change between the embedded and the
|
||||||
|
client/server version by just linking your application with the right
|
||||||
|
library. @xref{mysql_server_init}.
|
||||||
|
|
||||||
|
|
||||||
|
@node libmysqld compiling, libmysqld restrictions, libmysqld overview, libmysqld
|
||||||
@subsubsection Compiling Programs with @code{libmysqld}
|
@subsubsection Compiling Programs with @code{libmysqld}
|
||||||
|
|
||||||
Currently, all of the support libraries must be explicitly
|
When you link your program with @code{libmysqld}, you must also include
|
||||||
listed when linking with @code{-lmysqld}. In the future,
|
the system specific @code{pthread} libraries and some libraries that
|
||||||
@code{mysql_config --libmysqld-libs} will name the libraries to
|
@code{mysqld} uses. You can get the full list of libraries by executing
|
||||||
make this easier. Also, all of the supporting libraries will
|
@code{mysql_config --libmysqld-libs}.
|
||||||
probably be incorporated into libmysqld at some time to simplify
|
|
||||||
this even more.
|
|
||||||
|
|
||||||
The correct flags for compiling and linking a threaded program
|
The correct flags for compiling and linking a threaded program
|
||||||
must be used, even if you do not directly call any thread
|
must be used, even if you do not directly call any thread
|
||||||
functions in your code.
|
functions in your code.
|
||||||
|
|
||||||
@node libmysqld example, libmysqld licensing, libmysqld compiling, libmysqld
|
@node libmysqld restrictions, libmysqld options, libmysqld compiling, libmysqld
|
||||||
|
@subsubsection Restrictions when using the Embedded MySQL Server
|
||||||
|
|
||||||
|
The embedded server has the following limitations:
|
||||||
|
(Some of these limitations can be changed by editing the @code{mysql_embed.h}
|
||||||
|
include files and recompiling MySQL)
|
||||||
|
|
||||||
|
@itemize @bullet
|
||||||
|
@item
|
||||||
|
No support for ISAM tables. (This is mainly done to make the library smaller)
|
||||||
|
@item
|
||||||
|
No UDF functions.
|
||||||
|
@item
|
||||||
|
No stack trace on core dump.
|
||||||
|
@item
|
||||||
|
No internal RAID support.
|
||||||
|
@end itemize
|
||||||
|
|
||||||
|
@node libmysqld options, libmysqld TODO, libmysqld restrictions, libmysqld
|
||||||
|
@subsubsection Using option files with the embedded server
|
||||||
|
|
||||||
|
The following is the recommended way to use option files to make it easy
|
||||||
|
to switch between a client/server application and one where MySQL is
|
||||||
|
embedded. @xref{Option files}.
|
||||||
|
|
||||||
|
@itemize @bullet
|
||||||
|
@item
|
||||||
|
Put common options in the @code{[server]} section. These will be read by
|
||||||
|
both MySQL versions.
|
||||||
|
@item
|
||||||
|
Put client/server specific options in the @code{[mysqld]} section.
|
||||||
|
@item
|
||||||
|
Put embedded MySQL specific options in the @code{[embedded]} section.
|
||||||
|
@item
|
||||||
|
Put application specific options in a @code{[ApplicationName_SERVER]}
|
||||||
|
section.
|
||||||
|
@end itemize
|
||||||
|
|
||||||
|
@node libmysqld TODO, libmysqld example, libmysqld options, libmysqld
|
||||||
|
@subsubsection Things left to do in Embedded Server (TODO)
|
||||||
|
|
||||||
|
@cindex TODO, embedded server
|
||||||
|
|
||||||
|
@itemize @bullet
|
||||||
|
@item
|
||||||
|
Currently we only provide a static version of the @code{mysqld} library,
|
||||||
|
in the future we will also provide a shared library for this.
|
||||||
|
@item
|
||||||
|
We are going to provide options to leave out some parts of MySQL to make
|
||||||
|
the library smaller.
|
||||||
|
@item
|
||||||
|
There is still a lot of speed optimization to do.
|
||||||
|
@item
|
||||||
|
Errors are written to stderr. We will add an option to specify a
|
||||||
|
filename for these.
|
||||||
|
@item
|
||||||
|
We have to change InnoDB to not be so verbose when using in the embedded
|
||||||
|
version.
|
||||||
|
@end itemize
|
||||||
|
|
||||||
|
|
||||||
|
@node libmysqld example, libmysqld licensing, libmysqld TODO, libmysqld
|
||||||
@subsubsection A Simple Embedded Server Example
|
@subsubsection A Simple Embedded Server Example
|
||||||
|
|
||||||
This example program and makefile should work without any
|
This example program and makefile should work without any
|
||||||
@ -42449,7 +42534,7 @@ main(int argc, char **argv)
|
|||||||
/* This must be called before any other mysql functions.
|
/* This must be called before any other mysql functions.
|
||||||
*
|
*
|
||||||
* You can use mysql_server_init(0, NULL, NULL), and it will
|
* You can use mysql_server_init(0, NULL, NULL), and it will
|
||||||
* initialize the server using groups = @{ "server", NULL @}.
|
* initialize the server using groups = @{ "server", "embedded", NULL @}.
|
||||||
*
|
*
|
||||||
* In your $HOME/.my.cnf file, you probably want to put:
|
* In your $HOME/.my.cnf file, you probably want to put:
|
||||||
|
|
||||||
@ -42647,79 +42732,9 @@ else
|
|||||||
LDLIBS += -lpthread
|
LDLIBS += -lpthread
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Standard libraries. This example assumes MySQL is in /usr/local/mysql
|
||||||
|
|
||||||
# Standard libraries
|
embed_libs := -L/usr/local/mysql/lib/mysql/ -lmysqld
|
||||||
|
|
||||||
embed_libs := \
|
|
||||||
$m/libmysqld/.libs/libmysqld.a \
|
|
||||||
$m/isam/libnisam.a \
|
|
||||||
$m/myisam/libmyisam.a \
|
|
||||||
$m/heap/libheap.a \
|
|
||||||
$m/merge/libmerge.a \
|
|
||||||
$m/myisammrg/libmyisammrg.a
|
|
||||||
|
|
||||||
|
|
||||||
# Optionally-built libraries
|
|
||||||
|
|
||||||
ifneq (,$(shell test -r $m/innobase/usr/libusr.a && echo "yes"))
|
|
||||||
embed_libs += \
|
|
||||||
$m/innobase/usr/libusr.a \
|
|
||||||
$m/innobase/odbc/libodbc.a \
|
|
||||||
$m/innobase/srv/libsrv.a \
|
|
||||||
$m/innobase/que/libque.a \
|
|
||||||
$m/innobase/srv/libsrv.a \
|
|
||||||
$m/innobase/dict/libdict.a \
|
|
||||||
$m/innobase/ibuf/libibuf.a \
|
|
||||||
$m/innobase/row/librow.a \
|
|
||||||
$m/innobase/pars/libpars.a \
|
|
||||||
$m/innobase/btr/libbtr.a \
|
|
||||||
$m/innobase/trx/libtrx.a \
|
|
||||||
$m/innobase/read/libread.a \
|
|
||||||
$m/innobase/usr/libusr.a \
|
|
||||||
$m/innobase/buf/libbuf.a \
|
|
||||||
$m/innobase/ibuf/libibuf.a \
|
|
||||||
$m/innobase/eval/libeval.a \
|
|
||||||
$m/innobase/log/liblog.a \
|
|
||||||
$m/innobase/fsp/libfsp.a \
|
|
||||||
$m/innobase/fut/libfut.a \
|
|
||||||
$m/innobase/fil/libfil.a \
|
|
||||||
$m/innobase/lock/liblock.a \
|
|
||||||
$m/innobase/mtr/libmtr.a \
|
|
||||||
$m/innobase/page/libpage.a \
|
|
||||||
$m/innobase/rem/librem.a \
|
|
||||||
$m/innobase/thr/libthr.a \
|
|
||||||
$m/innobase/com/libcom.a \
|
|
||||||
$m/innobase/sync/libsync.a \
|
|
||||||
$m/innobase/data/libdata.a \
|
|
||||||
$m/innobase/mach/libmach.a \
|
|
||||||
$m/innobase/ha/libha.a \
|
|
||||||
$m/innobase/dyn/libdyn.a \
|
|
||||||
$m/innobase/mem/libmem.a \
|
|
||||||
$m/innobase/sync/libsync.a \
|
|
||||||
$m/innobase/ut/libut.a \
|
|
||||||
$m/innobase/os/libos.a \
|
|
||||||
$m/innobase/ut/libut.a
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq (,$(shell test -r $m/bdb/build_unix/libdb.a && echo "yes"))
|
|
||||||
embed_libs += $m/bdb/build_unix/libdb.a
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
# Support libraries
|
|
||||||
|
|
||||||
embed_libs += \
|
|
||||||
$m/mysys/libmysys.a \
|
|
||||||
$m/strings/libmystrings.a \
|
|
||||||
$m/dbug/libdbug.a \
|
|
||||||
$m/regex/libregex.a
|
|
||||||
|
|
||||||
|
|
||||||
# Optionally built support libraries
|
|
||||||
|
|
||||||
ifneq (,$(shell test -r $m/readline/libreadline.a && echo "yes"))
|
|
||||||
embed_libs += $m/readline/libreadline.a
|
|
||||||
endif
|
|
||||||
|
|
||||||
# This works for simple one-file test programs
|
# This works for simple one-file test programs
|
||||||
sources := $(wildcard *.c)
|
sources := $(wildcard *.c)
|
||||||
@ -47449,6 +47464,8 @@ Changed @code{WEEK(#,0)} to match the calender in the USA.
|
|||||||
@item
|
@item
|
||||||
Speed up all internal list handling.
|
Speed up all internal list handling.
|
||||||
@item
|
@item
|
||||||
|
Speed up @code{IS NULL()} and some other internal primitives.
|
||||||
|
@item
|
||||||
Creating full text indexes are now much faster.
|
Creating full text indexes are now much faster.
|
||||||
@item
|
@item
|
||||||
Tree-like cache to speed up bulk inserts and
|
Tree-like cache to speed up bulk inserts and
|
||||||
@ -47496,6 +47513,12 @@ Allow ANSI SQL syntax @code{X'hexadecimal-number'}
|
|||||||
Cleaned up global lock handling for @code{FLUSH TABLES WITH READ LOCK}
|
Cleaned up global lock handling for @code{FLUSH TABLES WITH READ LOCK}
|
||||||
@item
|
@item
|
||||||
Fixed problem with @code{DATETIME = constant} in @code{WHERE} optimization.
|
Fixed problem with @code{DATETIME = constant} in @code{WHERE} optimization.
|
||||||
|
@item
|
||||||
|
Added options @code{--master-data} and @code{--no-autocommit} to
|
||||||
|
@code{mysqldump} (Thanks to Brian Aker for this).
|
||||||
|
@item
|
||||||
|
Added script @code{mysql_explain_log.sh} to distribution.
|
||||||
|
(Thanks to mobile.de).
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
|
|
||||||
|
@ -880,6 +880,7 @@ dnl echo "DBG2: [$mode] bdb='$bdb'; incl='$bdb_includes'; lib='$bdb_libs'"
|
|||||||
no )
|
no )
|
||||||
bdb_includes=
|
bdb_includes=
|
||||||
bdb_libs=
|
bdb_libs=
|
||||||
|
bdb_libs_with_path=
|
||||||
;;
|
;;
|
||||||
supplied-two )
|
supplied-two )
|
||||||
MYSQL_CHECK_INSTALLED_BDB([$bdb_includes], [$bdb_libs])
|
MYSQL_CHECK_INSTALLED_BDB([$bdb_includes], [$bdb_libs])
|
||||||
@ -909,6 +910,7 @@ dnl echo "DBG2: [$mode] bdb='$bdb'; incl='$bdb_includes'; lib='$bdb_libs'"
|
|||||||
esac
|
esac
|
||||||
bdb_includes=
|
bdb_includes=
|
||||||
bdb_libs=
|
bdb_libs=
|
||||||
|
bdb_libs_with_path=
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
@ -937,6 +939,7 @@ dnl echo "DBG3: [$mode] bdb='$bdb'; incl='$bdb_includes'; lib='$bdb_libs'"
|
|||||||
|
|
||||||
AC_SUBST(bdb_includes)
|
AC_SUBST(bdb_includes)
|
||||||
AC_SUBST(bdb_libs)
|
AC_SUBST(bdb_libs)
|
||||||
|
AC_SUBST(bdb_libs_with_path)
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_DEFUN([MYSQL_CHECK_INSTALLED_BDB], [
|
AC_DEFUN([MYSQL_CHECK_INSTALLED_BDB], [
|
||||||
@ -957,6 +960,7 @@ dnl echo ["MYSQL_CHECK_INSTALLED_BDB ($1) ($2)"]
|
|||||||
MYSQL_TOP_BUILDDIR([lib])
|
MYSQL_TOP_BUILDDIR([lib])
|
||||||
bdb_includes="-I$inc"
|
bdb_includes="-I$inc"
|
||||||
bdb_libs="-L$lib -ldb"
|
bdb_libs="-L$lib -ldb"
|
||||||
|
bdb_libs_with_path="$lib/libdb.a"
|
||||||
])
|
])
|
||||||
LDFLAGS="$save_LDFLAGS"
|
LDFLAGS="$save_LDFLAGS"
|
||||||
else
|
else
|
||||||
@ -985,6 +989,7 @@ dnl echo ["MYSQL_CHECK_BDB_DIR ($1)"]
|
|||||||
MYSQL_TOP_BUILDDIR([dir])
|
MYSQL_TOP_BUILDDIR([dir])
|
||||||
bdb_includes="-I$dir/build_unix"
|
bdb_includes="-I$dir/build_unix"
|
||||||
bdb_libs="-L$dir/build_unix -ldb"
|
bdb_libs="-L$dir/build_unix -ldb"
|
||||||
|
bdb_libs_with_path="$dir/build_unix/libdb.a"
|
||||||
else
|
else
|
||||||
bdb_dir_ok="$bdb_version_ok"
|
bdb_dir_ok="$bdb_version_ok"
|
||||||
fi
|
fi
|
||||||
@ -1096,6 +1101,7 @@ AC_DEFUN([MYSQL_CHECK_INNODB], [
|
|||||||
AC_DEFINE(HAVE_INNOBASE_DB)
|
AC_DEFINE(HAVE_INNOBASE_DB)
|
||||||
have_innodb="yes"
|
have_innodb="yes"
|
||||||
innodb_includes="-I../innobase/include"
|
innodb_includes="-I../innobase/include"
|
||||||
|
innodb_system_libs=""
|
||||||
dnl Some libs are listed several times, in order for gcc to sort out
|
dnl Some libs are listed several times, in order for gcc to sort out
|
||||||
dnl circular references.
|
dnl circular references.
|
||||||
innodb_libs="\
|
innodb_libs="\
|
||||||
@ -1136,7 +1142,7 @@ dnl circular references.
|
|||||||
\$(top_builddir)/innobase/os/libos.a\
|
\$(top_builddir)/innobase/os/libos.a\
|
||||||
\$(top_builddir)/innobase/ut/libut.a"
|
\$(top_builddir)/innobase/ut/libut.a"
|
||||||
|
|
||||||
AC_CHECK_LIB(rt, aio_read, [innodb_libs="$innodb_libs -lrt"])
|
AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"])
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
AC_MSG_RESULT([Not using Innodb])
|
AC_MSG_RESULT([Not using Innodb])
|
||||||
@ -1145,6 +1151,7 @@ dnl circular references.
|
|||||||
|
|
||||||
AC_SUBST(innodb_includes)
|
AC_SUBST(innodb_includes)
|
||||||
AC_SUBST(innodb_libs)
|
AC_SUBST(innodb_libs)
|
||||||
|
AC_SUBST(innodb_system_libs)
|
||||||
])
|
])
|
||||||
|
|
||||||
dnl ---------------------------------------------------------------------------
|
dnl ---------------------------------------------------------------------------
|
||||||
|
@ -47,10 +47,12 @@ int completion_hash_init(HashTable *ht, uint nSize)
|
|||||||
ht->arBuckets = (Bucket **) my_malloc(nSize* sizeof(Bucket *),
|
ht->arBuckets = (Bucket **) my_malloc(nSize* sizeof(Bucket *),
|
||||||
MYF(MY_ZEROFILL | MY_WME));
|
MYF(MY_ZEROFILL | MY_WME));
|
||||||
|
|
||||||
if (!ht->arBuckets) {
|
if (!ht->arBuckets)
|
||||||
|
{
|
||||||
ht->initialized = 0;
|
ht->initialized = 0;
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
init_alloc_root(&ht->mem_root, 8192, 0);
|
||||||
ht->pHashFunction = hashpjw;
|
ht->pHashFunction = hashpjw;
|
||||||
ht->nTableSize = nSize;
|
ht->nTableSize = nSize;
|
||||||
ht->initialized = 1;
|
ht->initialized = 1;
|
||||||
@ -78,8 +80,7 @@ int completion_hash_update(HashTable *ht, char *arKey, uint nKeyLength,
|
|||||||
if (!memcmp(p->arKey, arKey, nKeyLength)) {
|
if (!memcmp(p->arKey, arKey, nKeyLength)) {
|
||||||
entry *n;
|
entry *n;
|
||||||
|
|
||||||
n = (entry *) my_malloc(sizeof(entry),
|
n = (entry *) alloc_root(&ht->mem_root,sizeof(entry));
|
||||||
MYF(MY_WME));
|
|
||||||
n->pNext = p->pData;
|
n->pNext = p->pData;
|
||||||
n->str = str;
|
n->str = str;
|
||||||
p->pData = n;
|
p->pData = n;
|
||||||
@ -91,20 +92,16 @@ int completion_hash_update(HashTable *ht, char *arKey, uint nKeyLength,
|
|||||||
p = p->pNext;
|
p = p->pNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = (Bucket *) my_malloc(sizeof(Bucket),MYF(MY_WME));
|
if (!(p = (Bucket *) alloc_root(&ht->mem_root, sizeof(Bucket))))
|
||||||
|
|
||||||
if (!p) {
|
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
|
||||||
p->arKey = arKey;
|
p->arKey = arKey;
|
||||||
p->nKeyLength = nKeyLength;
|
p->nKeyLength = nKeyLength;
|
||||||
p->h = h;
|
p->h = h;
|
||||||
|
|
||||||
p->pData = (entry*) my_malloc(sizeof(entry),MYF(MY_WME));
|
if (!(p->pData = (entry*) alloc_root(&ht->mem_root, sizeof(entry))))
|
||||||
if (!p->pData) {
|
|
||||||
my_free((gptr) p,MYF(0));
|
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
|
||||||
p->pData->str = str;
|
p->pData->str = str;
|
||||||
p->pData->pNext = 0;
|
p->pData->pNext = 0;
|
||||||
p->count = 1;
|
p->count = 1;
|
||||||
@ -209,24 +206,7 @@ Bucket *find_longest_match(HashTable *ht, char *str, uint length,
|
|||||||
|
|
||||||
void completion_hash_clean(HashTable *ht)
|
void completion_hash_clean(HashTable *ht)
|
||||||
{
|
{
|
||||||
uint i;
|
free_root(&ht->mem_root,MYF(0));
|
||||||
entry *e, *t;
|
|
||||||
Bucket *b, *tmp;
|
|
||||||
|
|
||||||
for (i=0; i<ht->nTableSize; i++) {
|
|
||||||
b = ht->arBuckets[i];
|
|
||||||
while (b) {
|
|
||||||
e = b->pData;
|
|
||||||
while (e) {
|
|
||||||
t = e;
|
|
||||||
e = e->pNext;
|
|
||||||
my_free((gptr) t,MYF(0));
|
|
||||||
}
|
|
||||||
tmp = b;
|
|
||||||
b = b->pNext;
|
|
||||||
my_free((gptr) tmp,MYF(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bzero((char*) ht->arBuckets,ht->nTableSize*sizeof(Bucket *));
|
bzero((char*) ht->arBuckets,ht->nTableSize*sizeof(Bucket *));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,9 +221,7 @@ void completion_hash_free(HashTable *ht)
|
|||||||
void add_word(HashTable *ht,char *str)
|
void add_word(HashTable *ht,char *str)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int length= (int) strlen(str);
|
char *pos=str;
|
||||||
|
for (i=1; *pos; i++, pos++)
|
||||||
for (i=1; i<=length; i++) {
|
|
||||||
completion_hash_update(ht, str, i, str);
|
completion_hash_update(ht, str, i, str);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -22,13 +22,15 @@
|
|||||||
#define FAILURE 1
|
#define FAILURE 1
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <my_sys.h>
|
||||||
|
|
||||||
typedef struct _entry {
|
typedef struct _entry {
|
||||||
char *str;
|
char *str;
|
||||||
struct _entry *pNext;
|
struct _entry *pNext;
|
||||||
} entry;
|
} entry;
|
||||||
|
|
||||||
typedef struct bucket {
|
typedef struct bucket
|
||||||
|
{
|
||||||
uint h; /* Used for numeric indexing */
|
uint h; /* Used for numeric indexing */
|
||||||
char *arKey;
|
char *arKey;
|
||||||
uint nKeyLength;
|
uint nKeyLength;
|
||||||
@ -40,6 +42,7 @@ typedef struct bucket {
|
|||||||
typedef struct hashtable {
|
typedef struct hashtable {
|
||||||
uint nTableSize;
|
uint nTableSize;
|
||||||
uint initialized;
|
uint initialized;
|
||||||
|
MEM_ROOT mem_root;
|
||||||
uint(*pHashFunction) (char *arKey, uint nKeyLength);
|
uint(*pHashFunction) (char *arKey, uint nKeyLength);
|
||||||
Bucket **arBuckets;
|
Bucket **arBuckets;
|
||||||
} HashTable;
|
} HashTable;
|
||||||
|
@ -137,6 +137,7 @@ static const char *xmlmeta[] = {
|
|||||||
static char default_pager[FN_REFLEN];
|
static char default_pager[FN_REFLEN];
|
||||||
char pager[FN_REFLEN], outfile[FN_REFLEN];
|
char pager[FN_REFLEN], outfile[FN_REFLEN];
|
||||||
FILE *PAGER, *OUTFILE;
|
FILE *PAGER, *OUTFILE;
|
||||||
|
MEM_ROOT hash_mem_root;
|
||||||
|
|
||||||
#include "sslopt-vars.h"
|
#include "sslopt-vars.h"
|
||||||
|
|
||||||
@ -302,8 +303,9 @@ int main(int argc,char *argv[])
|
|||||||
!(status.line_buff=batch_readline_init(max_allowed_packet+512,stdin)))
|
!(status.line_buff=batch_readline_init(max_allowed_packet+512,stdin)))
|
||||||
exit(1);
|
exit(1);
|
||||||
glob_buffer.realloc(512);
|
glob_buffer.realloc(512);
|
||||||
mysql_server_init(0, NULL, server_default_groups);
|
mysql_server_init(0, NULL, (char**) server_default_groups);
|
||||||
completion_hash_init(&ht,50);
|
completion_hash_init(&ht, 128);
|
||||||
|
init_alloc_root(&hash_mem_root, 16384, 0);
|
||||||
bzero((char*) &mysql, sizeof(mysql));
|
bzero((char*) &mysql, sizeof(mysql));
|
||||||
if (sql_connect(current_host,current_db,current_user,opt_password,
|
if (sql_connect(current_host,current_db,current_user,opt_password,
|
||||||
opt_silent))
|
opt_silent))
|
||||||
@ -387,6 +389,8 @@ sig_handler mysql_end(int sig)
|
|||||||
}
|
}
|
||||||
batch_readline_end(status.line_buff);
|
batch_readline_end(status.line_buff);
|
||||||
completion_hash_free(&ht);
|
completion_hash_free(&ht);
|
||||||
|
free_root(&hash_mem_root,MYF(0));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
if (sig >= 0)
|
if (sig >= 0)
|
||||||
put_info(sig ? "Aborted" : "Bye", INFO_RESULT);
|
put_info(sig ? "Aborted" : "Bye", INFO_RESULT);
|
||||||
@ -1170,7 +1174,8 @@ static char *new_command_generator(char *text,int state)
|
|||||||
static void build_completion_hash(bool skip_rehash,bool write_info)
|
static void build_completion_hash(bool skip_rehash,bool write_info)
|
||||||
{
|
{
|
||||||
COMMANDS *cmd=commands;
|
COMMANDS *cmd=commands;
|
||||||
static MYSQL_RES *databases=0,*tables=0,*fields;
|
MYSQL_RES *databases=0,*tables=0;
|
||||||
|
MYSQL_RES *fields;
|
||||||
static char ***field_names= 0;
|
static char ***field_names= 0;
|
||||||
MYSQL_ROW database_row,table_row;
|
MYSQL_ROW database_row,table_row;
|
||||||
MYSQL_FIELD *sql_field;
|
MYSQL_FIELD *sql_field;
|
||||||
@ -1181,16 +1186,11 @@ static void build_completion_hash(bool skip_rehash,bool write_info)
|
|||||||
if (status.batch || quick || !current_db)
|
if (status.batch || quick || !current_db)
|
||||||
DBUG_VOID_RETURN; // We don't need completion in batches
|
DBUG_VOID_RETURN; // We don't need completion in batches
|
||||||
|
|
||||||
completion_hash_clean(&ht);
|
|
||||||
if (tables)
|
if (tables)
|
||||||
{
|
{
|
||||||
mysql_free_result(tables);
|
mysql_free_result(tables);
|
||||||
tables=0;
|
tables=0;
|
||||||
}
|
}
|
||||||
if (databases) {
|
|
||||||
mysql_free_result(databases);
|
|
||||||
databases=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* hash SQL commands */
|
/* hash SQL commands */
|
||||||
while (cmd->name) {
|
while (cmd->name) {
|
||||||
@ -1200,16 +1200,28 @@ static void build_completion_hash(bool skip_rehash,bool write_info)
|
|||||||
if (skip_rehash)
|
if (skip_rehash)
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
|
|
||||||
|
/* Free old used memory */
|
||||||
|
if (field_names)
|
||||||
|
field_names=0;
|
||||||
|
completion_hash_clean(&ht);
|
||||||
|
free_root(&hash_mem_root,MYF(0));
|
||||||
|
|
||||||
/* hash MySQL functions (to be implemented) */
|
/* hash MySQL functions (to be implemented) */
|
||||||
|
|
||||||
/* hash all database names */
|
/* hash all database names */
|
||||||
if (mysql_query(&mysql,"show databases")==0) {
|
if (mysql_query(&mysql,"show databases") == 0)
|
||||||
|
{
|
||||||
if (!(databases = mysql_store_result(&mysql)))
|
if (!(databases = mysql_store_result(&mysql)))
|
||||||
put_info(mysql_error(&mysql),INFO_INFO);
|
put_info(mysql_error(&mysql),INFO_INFO);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while ((database_row=mysql_fetch_row(databases)))
|
while ((database_row=mysql_fetch_row(databases)))
|
||||||
add_word(&ht,(char*) database_row[0]);
|
{
|
||||||
|
char *str=strdup_root(&hash_mem_root, (char*) database_row[0]);
|
||||||
|
if (str)
|
||||||
|
add_word(&ht,(char*) str);
|
||||||
|
}
|
||||||
|
mysql_free_result(databases);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* hash all table names */
|
/* hash all table names */
|
||||||
@ -1227,23 +1239,13 @@ You can turn off this feature to get a quicker startup with -A\n\n");
|
|||||||
}
|
}
|
||||||
while ((table_row=mysql_fetch_row(tables)))
|
while ((table_row=mysql_fetch_row(tables)))
|
||||||
{
|
{
|
||||||
if (!completion_hash_exists(&ht,(char*) table_row[0],
|
char *str=strdup_root(&hash_mem_root, (char*) table_row[0]);
|
||||||
(uint) strlen((const char*) table_row[0])))
|
if (str &&
|
||||||
add_word(&ht,table_row[0]);
|
!completion_hash_exists(&ht,(char*) str, (uint) strlen(str)))
|
||||||
|
add_word(&ht,str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* FIXME: free() on small chunks is sloooowwww. glibc bug */
|
|
||||||
if (field_names) {
|
|
||||||
for (i=0; field_names[i]; i++) {
|
|
||||||
for (j=0; field_names[i][j]; j++) {
|
|
||||||
my_free(field_names[i][j],MYF(0));
|
|
||||||
}
|
|
||||||
my_free((gptr) field_names[i],MYF(0));
|
|
||||||
}
|
|
||||||
my_free((gptr) field_names,MYF(0));
|
|
||||||
}
|
|
||||||
field_names=0;
|
|
||||||
|
|
||||||
/* hash all field names, both with the table prefix and without it */
|
/* hash all field names, both with the table prefix and without it */
|
||||||
if (!tables) /* no tables */
|
if (!tables) /* no tables */
|
||||||
@ -1251,36 +1253,37 @@ You can turn off this feature to get a quicker startup with -A\n\n");
|
|||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
mysql_data_seek(tables,0);
|
mysql_data_seek(tables,0);
|
||||||
field_names = (char ***) my_malloc(sizeof(char **) *
|
if (!(field_names= (char ***) alloc_root(&hash_mem_root,sizeof(char **) *
|
||||||
(uint) (mysql_num_rows(tables)+1),
|
(uint) (mysql_num_rows(tables)+1))))
|
||||||
MYF(MY_WME));
|
{
|
||||||
if (!field_names)
|
mysql_free_result(tables);
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
|
}
|
||||||
i=0;
|
i=0;
|
||||||
while ((table_row=mysql_fetch_row(tables)))
|
while ((table_row=mysql_fetch_row(tables)))
|
||||||
{
|
{
|
||||||
if ((fields=mysql_list_fields(&mysql,(const char*) table_row[0],NullS)))
|
if ((fields=mysql_list_fields(&mysql,(const char*) table_row[0],NullS)))
|
||||||
{
|
{
|
||||||
num_fields=mysql_num_fields(fields);
|
num_fields=mysql_num_fields(fields);
|
||||||
field_names[i] = (char **) my_malloc(sizeof(char *)*(num_fields*2+1),
|
if (!(field_names[i] = (char **) alloc_root(&hash_mem_root,
|
||||||
MYF(0));
|
sizeof(char *) *
|
||||||
if (!field_names[i])
|
(num_fields*2+1))))
|
||||||
{
|
break;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
field_names[i][num_fields*2]='\0';
|
field_names[i][num_fields*2]='\0';
|
||||||
j=0;
|
j=0;
|
||||||
while ((sql_field=mysql_fetch_field(fields)))
|
while ((sql_field=mysql_fetch_field(fields)))
|
||||||
{
|
{
|
||||||
sprintf(buf,"%s.%s",table_row[0],sql_field->name);
|
sprintf(buf,"%s.%s",table_row[0],sql_field->name);
|
||||||
field_names[i][j] = my_strdup(buf,MYF(0));
|
field_names[i][j] = strdup_root(&hash_mem_root,buf);
|
||||||
add_word(&ht,field_names[i][j]);
|
add_word(&ht,field_names[i][j]);
|
||||||
field_names[i][num_fields+j] = my_strdup(sql_field->name,MYF(0));
|
field_names[i][num_fields+j] = strdup_root(&hash_mem_root,
|
||||||
|
sql_field->name);
|
||||||
if (!completion_hash_exists(&ht,field_names[i][num_fields+j],
|
if (!completion_hash_exists(&ht,field_names[i][num_fields+j],
|
||||||
(uint) strlen(field_names[i][num_fields+j])))
|
(uint) strlen(field_names[i][num_fields+j])))
|
||||||
add_word(&ht,field_names[i][num_fields+j]);
|
add_word(&ht,field_names[i][num_fields+j]);
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
mysql_free_result(fields);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1290,6 +1293,7 @@ You can turn off this feature to get a quicker startup with -A\n\n");
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
mysql_free_result(tables);
|
||||||
field_names[i]=0; // End pointer
|
field_names[i]=0; // End pointer
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
@ -643,8 +643,7 @@ static uint getTableStructure(char *table, char* db)
|
|||||||
if (path)
|
if (path)
|
||||||
{
|
{
|
||||||
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
|
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
|
||||||
strmov(tmp_path,path);
|
convert_dirname(tmp_path,path,NullS);
|
||||||
convert_dirname(tmp_path);
|
|
||||||
sql_file= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4),
|
sql_file= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4),
|
||||||
O_WRONLY, MYF(MY_WME));
|
O_WRONLY, MYF(MY_WME));
|
||||||
if (!sql_file) /* If file couldn't be opened */
|
if (!sql_file) /* If file couldn't be opened */
|
||||||
@ -716,8 +715,7 @@ static uint getTableStructure(char *table, char* db)
|
|||||||
if (path)
|
if (path)
|
||||||
{
|
{
|
||||||
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
|
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
|
||||||
strmov(tmp_path,path);
|
convert_dirname(tmp_path,path,NullS);
|
||||||
convert_dirname(tmp_path);
|
|
||||||
sql_file= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4),
|
sql_file= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4),
|
||||||
O_WRONLY, MYF(MY_WME));
|
O_WRONLY, MYF(MY_WME));
|
||||||
if (!sql_file) /* If file couldn't be opened */
|
if (!sql_file) /* If file couldn't be opened */
|
||||||
@ -949,8 +947,7 @@ static void dumpTable(uint numFields, char *table)
|
|||||||
if (path)
|
if (path)
|
||||||
{
|
{
|
||||||
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
|
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
|
||||||
strmov(tmp_path, path);
|
convert_dirname(tmp_path,path,NullS);
|
||||||
convert_dirname(tmp_path);
|
|
||||||
my_load_path(tmp_path, tmp_path, NULL);
|
my_load_path(tmp_path, tmp_path, NULL);
|
||||||
fn_format(filename, table, tmp_path, ".txt", 4);
|
fn_format(filename, table, tmp_path, ".txt", 4);
|
||||||
my_delete(filename, MYF(0)); /* 'INTO OUTFILE' doesn't work, if
|
my_delete(filename, MYF(0)); /* 'INTO OUTFILE' doesn't work, if
|
||||||
|
@ -89,7 +89,7 @@ enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD,
|
|||||||
|
|
||||||
static int record = 0, verbose = 0, silent = 0, opt_sleep=0;
|
static int record = 0, verbose = 0, silent = 0, opt_sleep=0;
|
||||||
static char *db = 0, *pass=0;
|
static char *db = 0, *pass=0;
|
||||||
const char* user = 0, *host = 0, *unix_sock = 0;
|
const char* user = 0, *host = 0, *unix_sock = 0, *opt_basedir="./";
|
||||||
static int port = 0, opt_big_test=0, opt_compress=0;
|
static int port = 0, opt_big_test=0, opt_compress=0;
|
||||||
static uint start_lineno, *lineno;
|
static uint start_lineno, *lineno;
|
||||||
const char* manager_user="root",*manager_host="localhost";
|
const char* manager_user="root",*manager_host="localhost";
|
||||||
@ -134,6 +134,8 @@ typedef struct
|
|||||||
int read_lines,current_line;
|
int read_lines,current_line;
|
||||||
} PARSER;
|
} PARSER;
|
||||||
|
|
||||||
|
MYSQL_RES *last_result=0;
|
||||||
|
|
||||||
PARSER parser;
|
PARSER parser;
|
||||||
MASTER_POS master_pos;
|
MASTER_POS master_pos;
|
||||||
int* block_ok; /* set to 0 if the current block should not be executed */
|
int* block_ok; /* set to 0 if the current block should not be executed */
|
||||||
@ -235,6 +237,7 @@ void reject_dump(const char* record_file, char* buf, int size);
|
|||||||
int close_connection(struct st_query* q);
|
int close_connection(struct st_query* q);
|
||||||
VAR* var_get(const char* var_name, const char** var_name_end, int raw);
|
VAR* var_get(const char* var_name, const char** var_name_end, int raw);
|
||||||
int eval_expr(VAR* v, const char* p, const char** p_end);
|
int eval_expr(VAR* v, const char* p, const char** p_end);
|
||||||
|
static int read_server_arguments(const char* name);
|
||||||
|
|
||||||
/* Definitions for replace */
|
/* Definitions for replace */
|
||||||
|
|
||||||
@ -271,6 +274,19 @@ int mysql_rpl_parse_enabled(MYSQL* mysql __attribute__((unused))) { return 1; }
|
|||||||
int mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; }
|
int mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define MAX_SERVER_ARGS 20
|
||||||
|
|
||||||
|
static int embedded_server_arg_count=0;
|
||||||
|
static char *embedded_server_args[MAX_SERVER_ARGS];
|
||||||
|
|
||||||
|
static const char *embedded_server_groups[] = {
|
||||||
|
"server",
|
||||||
|
"embedded",
|
||||||
|
"mysqltest_SERVER",
|
||||||
|
NullS
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
|
static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
|
||||||
{
|
{
|
||||||
const char* p;
|
const char* p;
|
||||||
@ -314,6 +330,8 @@ static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
|
|||||||
static void close_cons()
|
static void close_cons()
|
||||||
{
|
{
|
||||||
DBUG_ENTER("close_cons");
|
DBUG_ENTER("close_cons");
|
||||||
|
if (last_result)
|
||||||
|
mysql_free_result(last_result);
|
||||||
for (--next_con; next_con >= cons; --next_con)
|
for (--next_con; next_con >= cons; --next_con)
|
||||||
{
|
{
|
||||||
mysql_close(&next_con->mysql);
|
mysql_close(&next_con->mysql);
|
||||||
@ -356,6 +374,8 @@ static void free_used_memory()
|
|||||||
if(var_reg[i].alloced_len)
|
if(var_reg[i].alloced_len)
|
||||||
my_free(var_reg[i].str_val, MYF(MY_WME));
|
my_free(var_reg[i].str_val, MYF(MY_WME));
|
||||||
}
|
}
|
||||||
|
while (embedded_server_arg_count > 1)
|
||||||
|
my_free(embedded_server_args[--embedded_server_arg_count],MYF(0));
|
||||||
delete_dynamic(&q_lines);
|
delete_dynamic(&q_lines);
|
||||||
dynstr_free(&ds_res);
|
dynstr_free(&ds_res);
|
||||||
my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
|
my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
|
||||||
@ -382,6 +402,8 @@ static void die(const char* fmt, ...)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Note that we will get some memory leaks when calling this! */
|
||||||
|
|
||||||
static void abort_not_supported_test()
|
static void abort_not_supported_test()
|
||||||
{
|
{
|
||||||
DBUG_ENTER("abort_not_supported_test");
|
DBUG_ENTER("abort_not_supported_test");
|
||||||
@ -436,13 +458,22 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char* fname)
|
|||||||
DYNAMIC_STRING res_ds;
|
DYNAMIC_STRING res_ds;
|
||||||
DBUG_ENTER("dyn_string_cmp");
|
DBUG_ENTER("dyn_string_cmp");
|
||||||
|
|
||||||
if (!my_stat(fname, &stat_info, MYF(MY_WME)))
|
if (!test_if_hard_path(fname))
|
||||||
|
{
|
||||||
|
strxmov(eval_file, opt_basedir, fname, NullS);
|
||||||
|
fn_format(eval_file, eval_file,"","",4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fn_format(eval_file, fname,"","",4);
|
||||||
|
|
||||||
|
if (!my_stat(eval_file, &stat_info, MYF(MY_WME)))
|
||||||
die(NullS);
|
die(NullS);
|
||||||
if (!eval_result && stat_info.st_size != ds->length)
|
if (!eval_result && stat_info.st_size != ds->length)
|
||||||
DBUG_RETURN(2);
|
DBUG_RETURN(2);
|
||||||
if (!(tmp = (char*) my_malloc(stat_info.st_size + 1, MYF(MY_WME))))
|
if (!(tmp = (char*) my_malloc(stat_info.st_size + 1, MYF(MY_WME))))
|
||||||
die(NullS);
|
die(NullS);
|
||||||
if ((fd = my_open(fname, O_RDONLY, MYF(MY_WME))) < 0)
|
|
||||||
|
if ((fd = my_open(eval_file, O_RDONLY, MYF(MY_WME))) < 0)
|
||||||
die(NullS);
|
die(NullS);
|
||||||
if (my_read(fd, (byte*)tmp, stat_info.st_size, MYF(MY_WME|MY_NABP)))
|
if (my_read(fd, (byte*)tmp, stat_info.st_size, MYF(MY_WME|MY_NABP)))
|
||||||
die(NullS);
|
die(NullS);
|
||||||
@ -591,9 +622,17 @@ int var_set(char* var_name, char* var_name_end, char* var_val,
|
|||||||
|
|
||||||
int open_file(const char* name)
|
int open_file(const char* name)
|
||||||
{
|
{
|
||||||
|
char buff[FN_REFLEN];
|
||||||
|
if (!test_if_hard_path(name))
|
||||||
|
{
|
||||||
|
strxmov(buff, opt_basedir, name, NullS);
|
||||||
|
name=buff;
|
||||||
|
}
|
||||||
|
fn_format(buff,name,"","",4);
|
||||||
|
|
||||||
if (*cur_file && cur_file == file_stack_end)
|
if (*cur_file && cur_file == file_stack_end)
|
||||||
die("Source directives are nesting too deep");
|
die("Source directives are nesting too deep");
|
||||||
if (!(*(cur_file+1) = my_fopen(name, O_RDONLY, MYF(MY_WME))))
|
if (!(*(cur_file+1) = my_fopen(buff, O_RDONLY, MYF(MY_WME))))
|
||||||
die(NullS);
|
die(NullS);
|
||||||
cur_file++;
|
cur_file++;
|
||||||
*++lineno=1;
|
*++lineno=1;
|
||||||
@ -818,14 +857,13 @@ int do_sync_with_master(struct st_query* q)
|
|||||||
die("At line %u: failed in %s: %d: %s", start_lineno, query_buf,
|
die("At line %u: failed in %s: %d: %s", start_lineno, query_buf,
|
||||||
mysql_errno(mysql), mysql_error(mysql));
|
mysql_errno(mysql), mysql_error(mysql));
|
||||||
|
|
||||||
if(!(res = mysql_store_result(mysql)))
|
if(!(last_result = res = mysql_store_result(mysql)))
|
||||||
die("line %u: mysql_store_result() retuned NULL", start_lineno);
|
die("line %u: mysql_store_result() retuned NULL", start_lineno);
|
||||||
if(!(row = mysql_fetch_row(res)))
|
if(!(row = mysql_fetch_row(res)))
|
||||||
die("line %u: empty result in %s", start_lineno, query_buf);
|
die("line %u: empty result in %s", start_lineno, query_buf);
|
||||||
if(!row[0])
|
if(!row[0])
|
||||||
die("Error on slave while syncing with master");
|
die("Error on slave while syncing with master");
|
||||||
mysql_free_result(res);
|
mysql_free_result(res); last_result=0;
|
||||||
|
|
||||||
if(rpl_parse)
|
if(rpl_parse)
|
||||||
mysql_enable_rpl_parse(mysql);
|
mysql_enable_rpl_parse(mysql);
|
||||||
|
|
||||||
@ -846,13 +884,13 @@ int do_save_master_pos()
|
|||||||
die("At line %u: failed in show master status: %d: %s", start_lineno,
|
die("At line %u: failed in show master status: %d: %s", start_lineno,
|
||||||
mysql_errno(mysql), mysql_error(mysql));
|
mysql_errno(mysql), mysql_error(mysql));
|
||||||
|
|
||||||
if(!(res = mysql_store_result(mysql)))
|
if(!(last_result =res = mysql_store_result(mysql)))
|
||||||
die("line %u: mysql_store_result() retuned NULL", start_lineno);
|
die("line %u: mysql_store_result() retuned NULL", start_lineno);
|
||||||
if(!(row = mysql_fetch_row(res)))
|
if(!(row = mysql_fetch_row(res)))
|
||||||
die("line %u: empty result in show master status", start_lineno);
|
die("line %u: empty result in show master status", start_lineno);
|
||||||
strncpy(master_pos.file, row[0], sizeof(master_pos.file));
|
strncpy(master_pos.file, row[0], sizeof(master_pos.file));
|
||||||
master_pos.pos = strtoul(row[1], (char**) 0, 10);
|
master_pos.pos = strtoul(row[1], (char**) 0, 10);
|
||||||
mysql_free_result(res);
|
mysql_free_result(res); last_result=0;
|
||||||
|
|
||||||
if(rpl_parse)
|
if(rpl_parse)
|
||||||
mysql_enable_rpl_parse(mysql);
|
mysql_enable_rpl_parse(mysql);
|
||||||
@ -1595,6 +1633,7 @@ struct option long_options[] =
|
|||||||
{
|
{
|
||||||
{"debug", optional_argument, 0, '#'},
|
{"debug", optional_argument, 0, '#'},
|
||||||
{"database", required_argument, 0, 'D'},
|
{"database", required_argument, 0, 'D'},
|
||||||
|
{"basedir", required_argument, 0, 'b'},
|
||||||
{"big-test", no_argument, 0, 'B'},
|
{"big-test", no_argument, 0, 'B'},
|
||||||
{"compress", no_argument, 0, 'C'},
|
{"compress", no_argument, 0, 'C'},
|
||||||
{"help", no_argument, 0, '?'},
|
{"help", no_argument, 0, '?'},
|
||||||
@ -1606,10 +1645,12 @@ struct option long_options[] =
|
|||||||
{"manager-wait-timeout",required_argument,0,OPT_MANAGER_WAIT_TIMEOUT},
|
{"manager-wait-timeout",required_argument,0,OPT_MANAGER_WAIT_TIMEOUT},
|
||||||
{"password", optional_argument, 0, 'p'},
|
{"password", optional_argument, 0, 'p'},
|
||||||
{"port", required_argument, 0, 'P'},
|
{"port", required_argument, 0, 'P'},
|
||||||
{"quiet", no_argument, 0, 'q'},
|
{"quiet", no_argument, 0, 's'},
|
||||||
{"record", no_argument, 0, 'r'},
|
{"record", no_argument, 0, 'r'},
|
||||||
{"result-file", required_argument, 0, 'R'},
|
{"result-file", required_argument, 0, 'R'},
|
||||||
{"silent", no_argument, 0, 'q'},
|
{"server-arg", required_argument, 0, 'A'},
|
||||||
|
{"server-file", required_argument, 0, 'F'},
|
||||||
|
{"silent", no_argument, 0, 's'},
|
||||||
{"sleep", required_argument, 0, 'T'},
|
{"sleep", required_argument, 0, 'T'},
|
||||||
{"socket", required_argument, 0, 'S'},
|
{"socket", required_argument, 0, 'S'},
|
||||||
{"test-file", required_argument, 0, 'x'},
|
{"test-file", required_argument, 0, 'x'},
|
||||||
@ -1645,10 +1686,14 @@ void usage()
|
|||||||
-u, --user=... User for login.\n\
|
-u, --user=... User for login.\n\
|
||||||
-p[password], --password[=...]\n\
|
-p[password], --password[=...]\n\
|
||||||
Password to use when connecting to server.\n\
|
Password to use when connecting to server.\n\
|
||||||
|
-b, --basedir=... Basedir for tests\n\
|
||||||
-B, --big-test Define BIG_TEST to 1\n\
|
-B, --big-test Define BIG_TEST to 1\n\
|
||||||
-C, --compress Use the compressed server/client protocol\n\
|
-C, --compress Use the compressed server/client protocol\n\
|
||||||
-D, --database=... Database to use.\n\
|
-D, --database=... Database to use.\n\
|
||||||
-P, --port=... Port number to use for connection.\n\
|
-P, --port=... Port number to use for connection.\n\
|
||||||
|
--server-arg=... Send enbedded server this as a paramenter\n\
|
||||||
|
--server-file=... Read embedded server arguments from file\n\
|
||||||
|
-s, --silent, --quiet Suppress all normal output.\n\
|
||||||
-S, --socket=... Socket file to use for connection.\n\
|
-S, --socket=... Socket file to use for connection.\n\
|
||||||
-t, --tmpdir=... Temporary directory where sockets are put\n\
|
-t, --tmpdir=... Temporary directory where sockets are put\n\
|
||||||
-T, --sleep=# Sleep always this many seconds on sleep commands\n\
|
-T, --sleep=# Sleep always this many seconds on sleep commands\n\
|
||||||
@ -1656,7 +1701,6 @@ void usage()
|
|||||||
-R, --result-file=... Read/Store result from/in this file.\n\
|
-R, --result-file=... Read/Store result from/in this file.\n\
|
||||||
-x, --test-file=... Read test from/in this file (default stdin).\n\
|
-x, --test-file=... Read test from/in this file (default stdin).\n\
|
||||||
-v, --verbose Write more.\n\
|
-v, --verbose Write more.\n\
|
||||||
-q, --quiet, --silent Suppress all normal output.\n\
|
|
||||||
-V, --version Output version information and exit.\n\
|
-V, --version Output version information and exit.\n\
|
||||||
--no-defaults Don't read default options from any options file.\n\n");
|
--no-defaults Don't read default options from any options file.\n\n");
|
||||||
}
|
}
|
||||||
@ -1669,12 +1713,12 @@ int parse_args(int argc, char **argv)
|
|||||||
load_defaults("my",load_default_groups,&argc,&argv);
|
load_defaults("my",load_default_groups,&argc,&argv);
|
||||||
default_argv= argv;
|
default_argv= argv;
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "h:p::u:BCP:D:S:R:x:t:T:#:?rvVq",
|
while ((c = getopt_long(argc, argv, "A:h:p::u:b:BCF:P:D:S:R:x:t:T:#:?rvVs",
|
||||||
long_options, &option_index)) != EOF)
|
long_options, &option_index)) != EOF)
|
||||||
{
|
{
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case '#':
|
case '#':
|
||||||
DBUG_PUSH(optarg ? optarg : "d:t:O,/tmp/mysqltest.trace");
|
DBUG_PUSH(optarg ? optarg : "d:t:i:O,/tmp/mysqltest.trace");
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose = 1;
|
verbose = 1;
|
||||||
@ -1706,9 +1750,18 @@ int parse_args(int argc, char **argv)
|
|||||||
result_file = optarg;
|
result_file = optarg;
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
if (!(*cur_file = my_fopen(optarg, O_RDONLY, MYF(MY_WME))))
|
{
|
||||||
|
char buff[FN_REFLEN];
|
||||||
|
if (!test_if_hard_path(optarg))
|
||||||
|
{
|
||||||
|
strxmov(buff, opt_basedir, optarg, NullS);
|
||||||
|
optarg=buff;
|
||||||
|
}
|
||||||
|
fn_format(buff,optarg,"","",4);
|
||||||
|
if (!(*++cur_file = my_fopen(buff, O_RDONLY, MYF(MY_WME))))
|
||||||
die("Could not open %s: errno = %d", optarg, errno);
|
die("Could not open %s: errno = %d", optarg, errno);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'p':
|
case 'p':
|
||||||
if (optarg)
|
if (optarg)
|
||||||
{
|
{
|
||||||
@ -1719,6 +1772,9 @@ int parse_args(int argc, char **argv)
|
|||||||
else
|
else
|
||||||
tty_password=1;
|
tty_password=1;
|
||||||
break;
|
break;
|
||||||
|
case 'b':
|
||||||
|
opt_basedir= optarg;
|
||||||
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
opt_big_test=1;
|
opt_big_test=1;
|
||||||
break;
|
break;
|
||||||
@ -1737,7 +1793,7 @@ int parse_args(int argc, char **argv)
|
|||||||
case 'h':
|
case 'h':
|
||||||
host = optarg;
|
host = optarg;
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 's':
|
||||||
silent = 1;
|
silent = 1;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
@ -1746,6 +1802,24 @@ int parse_args(int argc, char **argv)
|
|||||||
case 'T':
|
case 'T':
|
||||||
opt_sleep=atoi(optarg);
|
opt_sleep=atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'A':
|
||||||
|
if (!embedded_server_arg_count)
|
||||||
|
{
|
||||||
|
embedded_server_arg_count=1;
|
||||||
|
embedded_server_args[0]= (char*) "";
|
||||||
|
}
|
||||||
|
embedded_server_args[embedded_server_arg_count++]=
|
||||||
|
my_strdup(optarg,MYF(MY_FAE));
|
||||||
|
if (embedded_server_arg_count == MAX_SERVER_ARGS ||
|
||||||
|
!embedded_server_args[embedded_server_arg_count-1])
|
||||||
|
{
|
||||||
|
die("Can't use server argument");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'F':
|
||||||
|
if (read_server_arguments(optarg))
|
||||||
|
die(NullS);
|
||||||
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
print_version();
|
print_version();
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -1753,6 +1827,7 @@ int parse_args(int argc, char **argv)
|
|||||||
usage();
|
usage();
|
||||||
exit(1); /* Unknown option */
|
exit(1); /* Unknown option */
|
||||||
default:
|
default:
|
||||||
|
fprintf(stderr,"Unknown option '%c'\n",c);
|
||||||
usage();
|
usage();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -1785,9 +1860,17 @@ char* safe_str_append(char* buf, const char* str, int size)
|
|||||||
void str_to_file(const char* fname, char* str, int size)
|
void str_to_file(const char* fname, char* str, int size)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
if ((fd = my_open(fname, O_WRONLY | O_CREAT | O_TRUNC,
|
char buff[FN_REFLEN];
|
||||||
|
if (!test_if_hard_path(fname))
|
||||||
|
{
|
||||||
|
strxmov(buff, opt_basedir, fname, NullS);
|
||||||
|
fname=buff;
|
||||||
|
}
|
||||||
|
fn_format(buff,fname,"","",4);
|
||||||
|
|
||||||
|
if ((fd = my_open(buff, O_WRONLY | O_CREAT | O_TRUNC,
|
||||||
MYF(MY_WME | MY_FFNF))) < 0)
|
MYF(MY_WME | MY_FFNF))) < 0)
|
||||||
die("Could not open %s: errno = %d", fname, errno);
|
die("Could not open %s: errno = %d", buff, errno);
|
||||||
if (my_write(fd, (byte*)str, size, MYF(MY_WME|MY_FNABP)))
|
if (my_write(fd, (byte*)str, size, MYF(MY_WME|MY_FNABP)))
|
||||||
die("write failed");
|
die("write failed");
|
||||||
my_close(fd, MYF(0));
|
my_close(fd, MYF(0));
|
||||||
@ -1850,13 +1933,16 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
|
|||||||
dynstr_append_mem(ds,";\n",2);
|
dynstr_append_mem(ds,";\n",2);
|
||||||
}
|
}
|
||||||
if (!(flags & QUERY_REAP))
|
if (!(flags & QUERY_REAP))
|
||||||
return 0;
|
DBUG_RETURN(0);
|
||||||
|
|
||||||
if (mysql_read_query_result(mysql) ||
|
if (mysql_read_query_result(mysql) ||
|
||||||
(!(res = mysql_store_result(mysql)) && mysql_field_count(mysql)))
|
(!(last_result = res = mysql_store_result(mysql)) &&
|
||||||
|
mysql_field_count(mysql)))
|
||||||
{
|
{
|
||||||
if (q->require_file)
|
if (q->require_file)
|
||||||
|
{
|
||||||
abort_not_supported_test();
|
abort_not_supported_test();
|
||||||
|
}
|
||||||
if (q->abort_on_error)
|
if (q->abort_on_error)
|
||||||
die("At line %u: query '%s' failed: %d: %s", start_lineno, query,
|
die("At line %u: query '%s' failed: %d: %s", start_lineno, query,
|
||||||
mysql_errno(mysql), mysql_error(mysql));
|
mysql_errno(mysql), mysql_error(mysql));
|
||||||
@ -1961,6 +2047,7 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
|
|||||||
|
|
||||||
end:
|
end:
|
||||||
if (res) mysql_free_result(res);
|
if (res) mysql_free_result(res);
|
||||||
|
last_result=0;
|
||||||
if (ds == &ds_tmp)
|
if (ds == &ds_tmp)
|
||||||
dynstr_free(&ds_tmp);
|
dynstr_free(&ds_tmp);
|
||||||
if(q->type == Q_EVAL)
|
if(q->type == Q_EVAL)
|
||||||
@ -2059,17 +2146,6 @@ static void init_var_hash()
|
|||||||
var_from_env("BIG_TEST", opt_big_test ? "1" : "0");
|
var_from_env("BIG_TEST", opt_big_test ? "1" : "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *embedded_server_args[] = {
|
|
||||||
"", /* XXX: argv[0] is program name - we should fix the API */
|
|
||||||
"--datadir=.",
|
|
||||||
"--language=/usr/local/mysql/share/mysql/english",
|
|
||||||
"--skip-innodb",
|
|
||||||
NullS
|
|
||||||
};
|
|
||||||
static const char *embedded_server_groups[] = {
|
|
||||||
"mysql-test-server",
|
|
||||||
NullS
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
@ -2107,8 +2183,9 @@ int main(int argc, char** argv)
|
|||||||
*block_ok = 1;
|
*block_ok = 1;
|
||||||
init_dynamic_string(&ds_res, "", 0, 65536);
|
init_dynamic_string(&ds_res, "", 0, 65536);
|
||||||
parse_args(argc, argv);
|
parse_args(argc, argv);
|
||||||
if (mysql_server_init(sizeof(embedded_server_args) / sizeof(char *) - 1,
|
if (mysql_server_init(embedded_server_arg_count,
|
||||||
embedded_server_args, embedded_server_groups))
|
embedded_server_args,
|
||||||
|
(char**) embedded_server_groups))
|
||||||
die("Can't initialize MySQL server");
|
die("Can't initialize MySQL server");
|
||||||
init_var_hash();
|
init_var_hash();
|
||||||
if (cur_file == file_stack)
|
if (cur_file == file_stack)
|
||||||
@ -2265,6 +2342,51 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Read arguments for embedded server and put them into
|
||||||
|
embedded_server_args_count and embedded_server_args[]
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
static int read_server_arguments(const char* name)
|
||||||
|
{
|
||||||
|
char argument[1024],buff[FN_REFLEN], *str=0;
|
||||||
|
FILE *file;
|
||||||
|
|
||||||
|
if (!test_if_hard_path(name))
|
||||||
|
{
|
||||||
|
strxmov(buff, opt_basedir, name, NullS);
|
||||||
|
name=buff;
|
||||||
|
}
|
||||||
|
fn_format(buff,name,"","",4);
|
||||||
|
|
||||||
|
if (!embedded_server_arg_count)
|
||||||
|
{
|
||||||
|
embedded_server_arg_count=1;
|
||||||
|
embedded_server_args[0]= (char*) ""; /* Progname */
|
||||||
|
}
|
||||||
|
if (!(file=my_fopen(buff, O_RDONLY | O_BINARY, MYF(MY_WME))))
|
||||||
|
return 1;
|
||||||
|
while (embedded_server_arg_count < MAX_SERVER_ARGS &&
|
||||||
|
(str=fgets(argument,sizeof(argument), file)))
|
||||||
|
{
|
||||||
|
*(strend(str)-1)=0; /* Remove end newline */
|
||||||
|
if (!(embedded_server_args[embedded_server_arg_count]=
|
||||||
|
(char*) my_strdup(str,MYF(MY_WME))))
|
||||||
|
{
|
||||||
|
my_fclose(file,MYF(0));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
embedded_server_arg_count++;
|
||||||
|
}
|
||||||
|
my_fclose(file,MYF(0));
|
||||||
|
if (str)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"Too many arguments in option file: %s\n",name);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Handle replacement of strings
|
* Handle replacement of strings
|
||||||
|
@ -453,8 +453,7 @@ typedef SOCKET_SIZE_TYPE size_socket;
|
|||||||
/* Some things that this system doesn't have */
|
/* Some things that this system doesn't have */
|
||||||
|
|
||||||
#define ONLY_OWN_DATABASES /* We are using only databases by monty */
|
#define ONLY_OWN_DATABASES /* We are using only databases by monty */
|
||||||
#define NO_PISAM /* Not needed anymore */
|
#define HAVE_ISAM /* TO BE DELETED */
|
||||||
#define NO_MISAM /* Not needed anymore */
|
|
||||||
#define NO_HASH /* Not needed anymore */
|
#define NO_HASH /* Not needed anymore */
|
||||||
#ifdef __WIN__
|
#ifdef __WIN__
|
||||||
#define NO_DIR_LIBRARY /* Not standar dir-library */
|
#define NO_DIR_LIBRARY /* Not standar dir-library */
|
||||||
|
@ -93,6 +93,16 @@ extern int NEAR my_errno; /* Last error in mysys */
|
|||||||
#define ME_COLOUR2 ((2 << ME_HIGHBYTE))
|
#define ME_COLOUR2 ((2 << ME_HIGHBYTE))
|
||||||
#define ME_COLOUR3 ((3 << ME_HIGHBYTE))
|
#define ME_COLOUR3 ((3 << ME_HIGHBYTE))
|
||||||
|
|
||||||
|
/* Bits in last argument to fn_format */
|
||||||
|
#define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */
|
||||||
|
#define MY_REPLACE_EXT 2 /* replace extension with 'ext' */
|
||||||
|
#define MY_UNPACK_FILENAME 4 /* Unpack name (~ -> home) */
|
||||||
|
#define MY_PACK_FILENAME 8 /* Pack name (home -> ~) */
|
||||||
|
#define MY_RESOLVE_SYMLINKS 16 /* Resolve all symbolic links */
|
||||||
|
#define MY_RETURN_REAL_PATH 32 /* return full path for file */
|
||||||
|
#define MY_SAFE_PATH 64 /* Return NULL if too long path */
|
||||||
|
#define MY_RELATIVE_PATH 128 /* name is relative to 'dir' */
|
||||||
|
|
||||||
/* My seek flags */
|
/* My seek flags */
|
||||||
#define MY_SEEK_SET 0
|
#define MY_SEEK_SET 0
|
||||||
#define MY_SEEK_CUR 1
|
#define MY_SEEK_CUR 1
|
||||||
@ -472,12 +482,12 @@ extern uint dirname_part(my_string to,const char *name);
|
|||||||
extern uint dirname_length(const char *name);
|
extern uint 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 char *convert_dirname(my_string name);
|
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(my_string name);
|
||||||
extern my_string fn_ext(const char *name);
|
extern my_string fn_ext(const char *name);
|
||||||
extern my_string fn_same(my_string toname,const char *name,int flag);
|
extern my_string fn_same(my_string toname,const char *name,int flag);
|
||||||
extern my_string fn_format(my_string to,const char *name,const char *dsk,
|
extern my_string fn_format(my_string to,const char *name,const char *dir,
|
||||||
const char *form,int flag);
|
const char *form, uint flag);
|
||||||
extern size_s strlength(const char *str);
|
extern size_s strlength(const char *str);
|
||||||
extern void pack_dirname(my_string to,const char *from);
|
extern void pack_dirname(my_string to,const char *from);
|
||||||
extern uint unpack_dirname(my_string to,const char *from);
|
extern uint unpack_dirname(my_string to,const char *from);
|
||||||
|
@ -71,6 +71,8 @@ extern char *mysql_unix_port;
|
|||||||
typedef struct st_mysql_field {
|
typedef struct st_mysql_field {
|
||||||
char *name; /* Name of column */
|
char *name; /* Name of column */
|
||||||
char *table; /* Table of column if column was a field */
|
char *table; /* Table of column if column was a field */
|
||||||
|
char *org_table; /* Org table name if table was an alias */
|
||||||
|
char *db; /* Database for table */
|
||||||
char *def; /* Default value (set by mysql_list_fields) */
|
char *def; /* Default value (set by mysql_list_fields) */
|
||||||
unsigned long length; /* Width of column */
|
unsigned long length; /* Width of column */
|
||||||
unsigned long max_length; /* Max width of selected set */
|
unsigned long max_length; /* Max width of selected set */
|
||||||
@ -251,7 +253,7 @@ typedef struct st_mysql_manager
|
|||||||
/* Set up and bring down the server; to ensure that applications will
|
/* Set up and bring down the server; to ensure that applications will
|
||||||
* work when linked against either the standard client library or the
|
* work when linked against either the standard client library or the
|
||||||
* embedded server library, these functions should be called. */
|
* embedded server library, these functions should be called. */
|
||||||
int mysql_server_init(int argc, const char **argv, const char **groups);
|
int mysql_server_init(int argc, char **argv, char **groups);
|
||||||
void mysql_server_end(void);
|
void mysql_server_end(void);
|
||||||
|
|
||||||
/* Set up and bring down a thread; these function should be called
|
/* Set up and bring down a thread; these function should be called
|
||||||
@ -421,8 +423,8 @@ int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int simple_command(MYSQL *mysql,enum enum_server_command command,
|
int simple_command(MYSQL *mysql,enum enum_server_command command,
|
||||||
const char *arg, ulong length, my_bool skipp_check);
|
const char *arg, unsigned long length, my_bool skipp_check);
|
||||||
ulong net_safe_read(MYSQL* mysql);
|
unsigned long net_safe_read(MYSQL* mysql);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#undef HAVE_DLOPEN /* No udf functions */
|
#undef HAVE_DLOPEN /* No udf functions */
|
||||||
#undef HAVE_OPENSSL
|
#undef HAVE_OPENSSL
|
||||||
#undef HAVE_VIO
|
#undef HAVE_VIO
|
||||||
|
#undef HAVE_ISAM
|
||||||
|
|
||||||
#define DONT_USE_RAID
|
#define DONT_USE_RAID
|
||||||
#endif /* EMBEDDED_LIBRARY */
|
#endif /* EMBEDDED_LIBRARY */
|
||||||
|
@ -70,6 +70,7 @@ extern ulint srv_n_rows_read;
|
|||||||
extern ibool srv_print_innodb_monitor;
|
extern ibool srv_print_innodb_monitor;
|
||||||
extern ibool srv_print_innodb_lock_monitor;
|
extern ibool srv_print_innodb_lock_monitor;
|
||||||
extern ibool srv_print_innodb_tablespace_monitor;
|
extern ibool srv_print_innodb_tablespace_monitor;
|
||||||
|
extern ibool srv_print_verbose_log;
|
||||||
|
|
||||||
extern ulint srv_n_spin_wait_rounds;
|
extern ulint srv_n_spin_wait_rounds;
|
||||||
extern ulint srv_spin_wait_delay;
|
extern ulint srv_spin_wait_delay;
|
||||||
|
@ -2641,9 +2641,11 @@ logs_empty_and_mark_files_at_shutdown(void)
|
|||||||
dulint lsn;
|
dulint lsn;
|
||||||
ulint arch_log_no;
|
ulint arch_log_no;
|
||||||
|
|
||||||
|
if (srv_print_verbose_log)
|
||||||
|
{
|
||||||
ut_print_timestamp(stderr);
|
ut_print_timestamp(stderr);
|
||||||
fprintf(stderr, " InnoDB: Starting shutdown...\n");
|
fprintf(stderr, " InnoDB: Starting shutdown...\n");
|
||||||
|
}
|
||||||
/* Wait until the master thread and all other operations are idle: our
|
/* Wait until the master thread and all other operations are idle: our
|
||||||
algorithm only works if the server is idle at shutdown */
|
algorithm only works if the server is idle at shutdown */
|
||||||
loop:
|
loop:
|
||||||
@ -2732,9 +2734,12 @@ loop:
|
|||||||
|
|
||||||
fil_flush_file_spaces(FIL_TABLESPACE);
|
fil_flush_file_spaces(FIL_TABLESPACE);
|
||||||
|
|
||||||
|
if (srv_print_verbose_log)
|
||||||
|
{
|
||||||
ut_print_timestamp(stderr);
|
ut_print_timestamp(stderr);
|
||||||
fprintf(stderr, " InnoDB: Shutdown completed\n");
|
fprintf(stderr, " InnoDB: Shutdown completed\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**********************************************************
|
/**********************************************************
|
||||||
Checks by parsing that the catenated log segment for a single mtr is
|
Checks by parsing that the catenated log segment for a single mtr is
|
||||||
|
@ -120,6 +120,12 @@ ibool srv_print_innodb_monitor = FALSE;
|
|||||||
ibool srv_print_innodb_lock_monitor = FALSE;
|
ibool srv_print_innodb_lock_monitor = FALSE;
|
||||||
ibool srv_print_innodb_tablespace_monitor = FALSE;
|
ibool srv_print_innodb_tablespace_monitor = FALSE;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Set the following to 0 if you want InnoDB to write messages on
|
||||||
|
stderr on startup/shutdown
|
||||||
|
*/
|
||||||
|
ibool srv_print_verbose_log = TRUE;
|
||||||
|
|
||||||
/* The parameters below are obsolete: */
|
/* The parameters below are obsolete: */
|
||||||
|
|
||||||
ibool srv_print_parsed_sql = FALSE;
|
ibool srv_print_parsed_sql = FALSE;
|
||||||
|
@ -888,9 +888,11 @@ innobase_start_or_create_for_mysql(void)
|
|||||||
|
|
||||||
/* buf_debug_prints = TRUE; */
|
/* buf_debug_prints = TRUE; */
|
||||||
|
|
||||||
|
if (srv_print_verbose_log)
|
||||||
|
{
|
||||||
ut_print_timestamp(stderr);
|
ut_print_timestamp(stderr);
|
||||||
fprintf(stderr, " InnoDB: Started\n");
|
fprintf(stderr, " InnoDB: Started\n");
|
||||||
|
}
|
||||||
return((int) DB_SUCCESS);
|
return((int) DB_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,11 +400,7 @@ static int examine_log(my_string file_name, char **table_names)
|
|||||||
}
|
}
|
||||||
to=isam_file_name;
|
to=isam_file_name;
|
||||||
if (filepath)
|
if (filepath)
|
||||||
{
|
to=convert_dirname(isam_file_name, filepath, NullS);
|
||||||
strmov(isam_file_name,filepath);
|
|
||||||
convert_dirname(isam_file_name);
|
|
||||||
to=strend(isam_file_name);
|
|
||||||
}
|
|
||||||
strmov(to,pos);
|
strmov(to,pos);
|
||||||
fn_ext(isam_file_name)[0]=0; /* Remove extension */
|
fn_ext(isam_file_name)[0]=0; /* Remove extension */
|
||||||
}
|
}
|
||||||
|
@ -92,8 +92,8 @@ static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
|
|||||||
const char *from, ulong length);
|
const char *from, ulong length);
|
||||||
|
|
||||||
int mysql_server_init(int argc __attribute__((unused)),
|
int mysql_server_init(int argc __attribute__((unused)),
|
||||||
const char **argv __attribute__((unused)),
|
char **argv __attribute__((unused)),
|
||||||
const char **groups __attribute__((unused)))
|
char **groups __attribute__((unused)))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -873,7 +873,7 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
|
|||||||
|
|
||||||
for (row=data->data; row ; row = row->next,field++)
|
for (row=data->data; row ; row = row->next,field++)
|
||||||
{
|
{
|
||||||
field->table= strdup_root(alloc,(char*) row->data[0]);
|
field->org_table= field->table= strdup_root(alloc,(char*) row->data[0]);
|
||||||
field->name= strdup_root(alloc,(char*) row->data[1]);
|
field->name= strdup_root(alloc,(char*) row->data[1]);
|
||||||
field->length= (uint) uint3korr(row->data[2]);
|
field->length= (uint) uint3korr(row->data[2]);
|
||||||
field->type= (enum enum_field_types) (uchar) row->data[3][0];
|
field->type= (enum enum_field_types) (uchar) row->data[3][0];
|
||||||
|
@ -25,19 +25,15 @@ DEFS = -DEMBEDDED_LIBRARY -DMYSQL_SERVER \
|
|||||||
-DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \
|
-DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \
|
||||||
-DDATADIR="\"$(MYSQLDATAdir)\"" \
|
-DDATADIR="\"$(MYSQLDATAdir)\"" \
|
||||||
-DSHAREDIR="\"$(MYSQLSHAREdir)\""
|
-DSHAREDIR="\"$(MYSQLSHAREdir)\""
|
||||||
INCLUDES = @MT_INCLUDES@ @bdb_includes@ -I$(srcdir)/../include -I../include \
|
INCLUDES= @MT_INCLUDES@ @bdb_includes@ -I$(srcdir)/../include \
|
||||||
-I$(srcdir)/.. -I$(top_srcdir) -I.. -I../sql -I../regex
|
-I../include -I$(srcdir)/.. -I$(top_srcdir) -I.. \
|
||||||
|
-I../sql -I../regex
|
||||||
|
|
||||||
|
noinst_LIBRARIES = libmysqld_int.a
|
||||||
## XXX: should we use client or server LDFLAGS for libmysqld?
|
pkglib_LIBRARIES = libmysqld.a
|
||||||
LDADD = @CLIENT_EXTRA_LDFLAGS@ libmysqld.la
|
|
||||||
pkglib_LTLIBRARIES = libmysqld.la
|
|
||||||
SUBDIRS = . examples
|
SUBDIRS = . examples
|
||||||
libmysqld_la_SOURCES= libmysqld.c lib_sql.cc lib_load.cc
|
libmysqld_sources= libmysqld.c lib_sql.cc lib_load.cc
|
||||||
|
|
||||||
libmysqlsources = errmsg.c get_password.c password.c
|
libmysqlsources = errmsg.c get_password.c password.c
|
||||||
## XXX: we should not have to duplicate info from the sources list
|
|
||||||
libmysqlobjects = errmsg.lo get_password.lo password.lo
|
|
||||||
|
|
||||||
noinst_HEADERS = embedded_priv.h
|
noinst_HEADERS = embedded_priv.h
|
||||||
|
|
||||||
@ -47,7 +43,7 @@ sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \
|
|||||||
hostname.cc init.cc \
|
hostname.cc init.cc \
|
||||||
item.cc item_buff.cc item_cmpfunc.cc item_create.cc \
|
item.cc item_buff.cc item_cmpfunc.cc item_create.cc \
|
||||||
item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \
|
item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \
|
||||||
item_uniq.cc key.cc lock.cc log.cc log_event.cc \
|
item_uniq.cc key.cc lock.cc log.cc log_event.cc md5.c \
|
||||||
mini_client.cc net_pkg.cc net_serv.cc opt_ft.cc opt_range.cc \
|
mini_client.cc net_pkg.cc net_serv.cc opt_ft.cc opt_range.cc \
|
||||||
opt_sum.cc procedure.cc records.cc slave.cc sql_acl.cc \
|
opt_sum.cc procedure.cc records.cc slave.cc sql_acl.cc \
|
||||||
sql_analyse.cc sql_base.cc sql_cache.cc sql_class.cc \
|
sql_analyse.cc sql_base.cc sql_cache.cc sql_class.cc \
|
||||||
@ -58,37 +54,52 @@ sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \
|
|||||||
sql_update.cc sql_yacc.cc table.cc thr_malloc.cc time.cc \
|
sql_update.cc sql_yacc.cc table.cc thr_malloc.cc time.cc \
|
||||||
unireg.cc uniques.cc stacktrace.c sql_union.cc hash_filo.cc
|
unireg.cc uniques.cc stacktrace.c sql_union.cc hash_filo.cc
|
||||||
|
|
||||||
## XXX: we should not have to duplicate info from the sources list
|
|
||||||
sqlobjects = convert.lo derror.lo field.lo field_conv.lo filesort.lo \
|
|
||||||
ha_innobase.lo ha_berkeley.lo ha_heap.lo ha_isam.lo ha_isammrg.lo \
|
|
||||||
ha_myisam.lo ha_myisammrg.lo handler.lo sql_handler.lo \
|
|
||||||
hostname.lo init.lo \
|
|
||||||
item.lo item_buff.lo item_cmpfunc.lo item_create.lo \
|
|
||||||
item_func.lo item_strfunc.lo item_sum.lo item_timefunc.lo \
|
|
||||||
item_uniq.lo key.lo lock.lo log.lo log_event.lo \
|
|
||||||
mini_client.lo net_pkg.lo net_serv.lo opt_ft.lo opt_range.lo \
|
|
||||||
opt_sum.lo procedure.lo records.lo slave.lo sql_acl.lo \
|
|
||||||
sql_analyse.lo sql_base.lo sql_cache.lo sql_class.lo \
|
|
||||||
sql_crypt.lo sql_db.lo sql_delete.lo sql_insert.lo sql_lex.lo \
|
|
||||||
sql_list.lo sql_manager.lo sql_map.lo sql_parse.lo \
|
|
||||||
sql_rename.lo sql_repl.lo sql_select.lo sql_show.lo \
|
|
||||||
sql_string.lo sql_table.lo sql_test.lo sql_udf.lo \
|
|
||||||
sql_update.lo sql_yacc.lo table.lo thr_malloc.lo time.lo \
|
|
||||||
unireg.lo uniques.lo stacktrace.lo sql_union.lo hash_filo.lo
|
|
||||||
|
|
||||||
EXTRA_DIST = lib_vio.c
|
EXTRA_DIST = lib_vio.c
|
||||||
|
|
||||||
|
libmysqld_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources)
|
||||||
|
|
||||||
# automake misses these
|
# automake misses these
|
||||||
sql_yacc.cc sql_yacc.h: $(top_srcdir)/sql/sql_yacc.yy
|
sql_yacc.cc sql_yacc.h: $(top_srcdir)/sql/sql_yacc.yy
|
||||||
|
|
||||||
libmysqld_la_LIBADD = $(sqlobjects) $(libmysqlobjects)
|
# The following libraries should be included in libmysqld.a
|
||||||
|
INC_LIB= $(top_builddir)/regex/libregex.a \
|
||||||
|
$(top_builddir)/myisam/libmyisam.a \
|
||||||
|
$(top_builddir)/myisammrg/libmyisammrg.a \
|
||||||
|
$(top_builddir)/heap/libheap.a \
|
||||||
|
@innodb_libs@ @bdb_libs_with_path@ \
|
||||||
|
$(top_builddir)/mysys/libmysys.a \
|
||||||
|
$(top_builddir)/strings/libmystrings.a \
|
||||||
|
$(top_builddir)/dbug/libdbug.a \
|
||||||
|
$(top_builddir)/regex/libregex.a
|
||||||
|
|
||||||
|
#
|
||||||
|
# To make it easy for the end user to use the embedded library we
|
||||||
|
# generate a total libmysqld.a from all library files,
|
||||||
|
|
||||||
|
libmysqld.a: libmysqld_int.a $(INC_LIB)
|
||||||
|
if test ! -d tmp ; then mkdir tmp ; fi
|
||||||
|
rm -f $@ libmysqld_int2.a tmp/*.o tmp/*.a
|
||||||
|
cp $(INC_LIB) tmp
|
||||||
|
cp libmysqld_int.a libmysqld_int2.a ; \
|
||||||
|
cd tmp ; \
|
||||||
|
for file in *.a ; do \
|
||||||
|
bfile=`basename $$file .a` ; \
|
||||||
|
ar x $$file; \
|
||||||
|
for obj in *.o ; do mv $$obj $${bfile}_$$obj ; done ; \
|
||||||
|
ar q ../libmysqld_int2.a *.o ; \
|
||||||
|
rm *.o ; \
|
||||||
|
done
|
||||||
|
mv libmysqld_int2.a libmysqld.a
|
||||||
|
rm tmp/*
|
||||||
|
$(RANLIB) libmysqld.a
|
||||||
|
|
||||||
## XXX: any time the client interface changes, we'll need to bump
|
## XXX: any time the client interface changes, we'll need to bump
|
||||||
## the version info for libmysqld; however, it's possible for the
|
## the version info for libmysqld; however, it's possible for the
|
||||||
## libmysqld interface to change without affecting the standard
|
## libmysqld interface to change without affecting the standard
|
||||||
## libmysqlclient interface. Should we make a separate version
|
## libmysqlclient interface. Should we make a separate version
|
||||||
## string for the two?
|
## string for the two?
|
||||||
libmysqld_la_LDFLAGS = -version-info @SHARED_LIB_VERSION@
|
#libmysqld_la_LDFLAGS = -version-info @SHARED_LIB_VERSION@
|
||||||
CLEANFILES = $(libmysqld_la_LIBADD) libmysqld.la
|
#CLEANFILES = $(libmysqld_la_LIBADD) libmysqld.la
|
||||||
|
|
||||||
# This is called from the toplevel makefile
|
# This is called from the toplevel makefile
|
||||||
link_sources:
|
link_sources:
|
||||||
|
@ -11,19 +11,8 @@ DEFS = -DEMBEDDED_LIBRARY
|
|||||||
INCLUDES = -I$(top_srcdir)/include $(openssl_includes) \
|
INCLUDES = -I$(top_srcdir)/include $(openssl_includes) \
|
||||||
-I$(srcdir) -I$(top_srcdir) -I$(top_srcdir)/client
|
-I$(srcdir) -I$(top_srcdir) -I$(top_srcdir)/client
|
||||||
LIBS = @LIBS@
|
LIBS = @LIBS@
|
||||||
LDADD = $(top_builddir)/libmysqld/libmysqld.la \
|
LDADD = ../libmysqld.a @innodb_system_libs@ @LIBDL@
|
||||||
$(top_builddir)/isam/libnisam.a \
|
|
||||||
$(top_builddir)/myisam/libmyisam.a \
|
|
||||||
$(top_builddir)/heap/libheap.a \
|
|
||||||
$(top_builddir)/merge/libmerge.a \
|
|
||||||
$(top_builddir)/myisammrg/libmyisammrg.a \
|
|
||||||
@innodb_libs@ @bdb_libs@ @pstack_libs@ \
|
|
||||||
$(top_builddir)/mysys/libmysys.a \
|
|
||||||
$(top_builddir)/strings/libmystrings.a \
|
|
||||||
$(top_builddir)/dbug/libdbug.a \
|
|
||||||
$(top_builddir)/regex/libregex.a @LIBDL@
|
|
||||||
|
|
||||||
mysqltest_DEPENDENCIES = ../libmysqld.la
|
|
||||||
mysqltest_SOURCES = mysqltest.c
|
mysqltest_SOURCES = mysqltest.c
|
||||||
|
|
||||||
mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \
|
mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \
|
||||||
|
@ -6,26 +6,19 @@
|
|||||||
# that will run on all platforms (or incorporate it into the
|
# that will run on all platforms (or incorporate it into the
|
||||||
# standard mysql-test-run).
|
# standard mysql-test-run).
|
||||||
|
|
||||||
#test_data_dir=/tmp/mysql-data
|
|
||||||
test_data_dir=../../mysql-test/var/master-data
|
|
||||||
cd "$test_data_dir" || {
|
|
||||||
echo "can't cd to $test_data_dir" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# All paths below must be relative to $test_data_dir
|
# All paths below must be relative to $test_data_dir
|
||||||
#top_builddir=/home/tim/my/4
|
top_builddir=../..
|
||||||
top_builddir=../../..
|
|
||||||
mysql_test_dir=$top_builddir/mysql-test
|
mysql_test_dir=$top_builddir/mysql-test
|
||||||
examples=$top_builddir/libmysqld/examples
|
examples=$top_builddir/libmysqld/examples
|
||||||
mysqltest=$examples/mysqltest
|
mysqltest=$examples/mysqltest
|
||||||
testdir=./test
|
datadir=$mysql_test_dir/var/master-data
|
||||||
|
test_data_dir=test
|
||||||
gdb=0
|
gdb=0
|
||||||
list=0
|
list=0
|
||||||
run=
|
run=
|
||||||
tests=
|
tests=
|
||||||
start=
|
start=
|
||||||
|
clean=1
|
||||||
|
|
||||||
cr="
|
cr="
|
||||||
"
|
"
|
||||||
@ -35,6 +28,7 @@ usage () {
|
|||||||
cat <<EOF
|
cat <<EOF
|
||||||
usage: $0 [-g|-h|-r] [test-name ...]
|
usage: $0 [-g|-h|-r] [test-name ...]
|
||||||
|
|
||||||
|
-C | --noclean Do not remove old innodb and bdb files at start.
|
||||||
-g | --gdb run $mysqltest in gdb
|
-g | --gdb run $mysqltest in gdb
|
||||||
-h | --help show this help
|
-h | --help show this help
|
||||||
-l | --list ) list all available tests
|
-l | --list ) list all available tests
|
||||||
@ -58,6 +52,7 @@ do
|
|||||||
-l | --list ) list=1 ; shift ;;
|
-l | --list ) list=1 ; shift ;;
|
||||||
-r | --run ) run="${cr}run"; shift;;
|
-r | --run ) run="${cr}run"; shift;;
|
||||||
--debug) init_args="$init_args --debug" ; shift ;;
|
--debug) init_args="$init_args --debug" ; shift ;;
|
||||||
|
-C | --noclean) clean=0 ; shift ;;
|
||||||
-s | --start=* )
|
-s | --start=* )
|
||||||
test $argset -eq 0 && { shift; arg="$1"; }
|
test $argset -eq 0 && { shift; arg="$1"; }
|
||||||
start="$arg"
|
start="$arg"
|
||||||
@ -68,25 +63,30 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
test -d "$mysql_test_dir/t" -a -d "$mysql_test_dir/r" -a \
|
if test ! -d "$datadir/$test_data_dir"
|
||||||
-f $mysqltest -a -d $testdir || {
|
then
|
||||||
echo "bad setup (is '$testdir', from '$test_data_dir', missing?)" >&2
|
echo "bad setup (is '$datadir/$test_data_dir'', missing ?)" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
fi
|
||||||
|
|
||||||
test -n "$tests" ||
|
test -n "$tests" ||
|
||||||
tests=`/bin/ls -1 "$mysql_test_dir"/t/*.test | grep -v '^.*/rpl[^/]*$' | \
|
tests=`/bin/ls -1 "$mysql_test_dir"/t/*.test | grep -v '^.*/rpl[^/]*$' | \
|
||||||
sed -e 's,^.*/,,' -e 's,.test$,,'`
|
sed -e 's,^.*/,,' -e 's,.test$,,'`
|
||||||
|
|
||||||
echo "cleaning data directory '$test_data_dir'"
|
echo "cleaning data directory '$datadir/$test_data_dir'"
|
||||||
rm -f $test_data_dir/ib_* $test_data_dir/ibdata* log.*
|
if test $clean = 1
|
||||||
echo "cleaning test directory '$testdir'"
|
then
|
||||||
rm -f $testdir/*
|
rm -f $datadir/ib_* $datadir/ibdata*
|
||||||
|
rm -f $datadir/log.00*
|
||||||
|
fi
|
||||||
|
rm -f $datadir/../tmp/*
|
||||||
rm -f test-gdbinit
|
rm -f test-gdbinit
|
||||||
|
|
||||||
TZ=GMT-3; export TZ
|
TZ=GMT-3; export TZ
|
||||||
|
|
||||||
|
# At least one of the tests needs the following environment variable
|
||||||
|
MYSQL_TEST_DIR=`( cd $mysql_test_dir ; pwd )` ; export MYSQL_TEST_DIR
|
||||||
|
|
||||||
skip=1
|
skip=1
|
||||||
test -z "$start" && skip=0
|
test -z "$start" && skip=0
|
||||||
|
|
||||||
@ -96,16 +96,20 @@ do
|
|||||||
test $skip -eq 1 && test -n "$start" && test "$start" = "$b" && skip=0
|
test $skip -eq 1 && test -n "$start" && test "$start" = "$b" && skip=0
|
||||||
test $skip -eq 1 && { echo "skipping '$b'"; continue; }
|
test $skip -eq 1 && { echo "skipping '$b'"; continue; }
|
||||||
|
|
||||||
t="$mysql_test_dir/t/$b.test"
|
t="t/$b.test"
|
||||||
r="$mysql_test_dir/r/$b.result"
|
r="r/$b.result"
|
||||||
c="$mysql_test_dir/r/$b.reject"
|
|
||||||
|
|
||||||
# Only test if $t exists; there is no $r for some tests
|
# Only test if $t exists; there is no $r for some tests
|
||||||
test -f $t || {
|
test -f $mysql_test_dir/$t || {
|
||||||
echo "test '$b' doesn't exist" >&2
|
echo "test '$mysql_test_dir/$t' doesn't exist" >&2
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
args="$init_args -v -S /tmp/mysql.sock -R $r -x $t test"
|
args="$init_args -v --basedir=$mysql_test_dir/ -R $r -x $t --server-arg=--datadir=$datadir"
|
||||||
|
if test -f "$mysql_test_dir/t/$b-master.opt" ; then
|
||||||
|
args="$args --server-file=t/$b-master.opt"
|
||||||
|
fi
|
||||||
|
|
||||||
|
args="$args $test_data_dir" # Add database last
|
||||||
echo "set args $args$run" > test-gdbinit
|
echo "set args $args$run" > test-gdbinit
|
||||||
#if false && test -n "$run"
|
#if false && test -n "$run"
|
||||||
if test -n "$run" -o $gdb -eq 1
|
if test -n "$run" -o $gdb -eq 1
|
||||||
@ -129,5 +133,5 @@ do
|
|||||||
res=$?
|
res=$?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
test $res -eq 0 || echo "!!! error: $res"
|
test $res -eq 0 -o $res -eq 2 || echo "!!! error: $res"
|
||||||
done
|
done
|
||||||
|
@ -296,7 +296,7 @@ extern "C"
|
|||||||
|
|
||||||
static my_bool inited, org_my_init_done;
|
static my_bool inited, org_my_init_done;
|
||||||
|
|
||||||
int mysql_server_init(int argc, const char **argv, const char **groups)
|
int mysql_server_init(int argc, char **argv, char **groups)
|
||||||
{
|
{
|
||||||
char glob_hostname[FN_REFLEN];
|
char glob_hostname[FN_REFLEN];
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ int mysql_server_init(int argc, const char **argv, const char **groups)
|
|||||||
char ***argvp;
|
char ***argvp;
|
||||||
int fake_argc = 1;
|
int fake_argc = 1;
|
||||||
char *fake_argv[] = { (char *)"", 0 };
|
char *fake_argv[] = { (char *)"", 0 };
|
||||||
const char *fake_groups[] = { "server", 0 };
|
const char *fake_groups[] = { "server", "embedded", 0 };
|
||||||
if (argc)
|
if (argc)
|
||||||
{
|
{
|
||||||
argcp = &argc;
|
argcp = &argc;
|
||||||
@ -318,7 +318,7 @@ int mysql_server_init(int argc, const char **argv, const char **groups)
|
|||||||
argvp = (char ***) &fake_argv;
|
argvp = (char ***) &fake_argv;
|
||||||
}
|
}
|
||||||
if (!groups)
|
if (!groups)
|
||||||
groups = fake_groups;
|
groups = (char**) fake_groups;
|
||||||
|
|
||||||
my_umask=0660; // Default umask for new files
|
my_umask=0660; // Default umask for new files
|
||||||
my_umask_dir=0700; // Default umask for new directories
|
my_umask_dir=0700; // Default umask for new directories
|
||||||
@ -330,7 +330,9 @@ int mysql_server_init(int argc, const char **argv, const char **groups)
|
|||||||
org_my_init_done=my_init_done;
|
org_my_init_done=my_init_done;
|
||||||
}
|
}
|
||||||
if (!org_my_init_done)
|
if (!org_my_init_done)
|
||||||
|
{
|
||||||
MY_INIT((char *)"mysql_embedded"); // init my_sys library & pthreads
|
MY_INIT((char *)"mysql_embedded"); // init my_sys library & pthreads
|
||||||
|
}
|
||||||
|
|
||||||
tzset(); // Set tzname
|
tzset(); // Set tzname
|
||||||
|
|
||||||
@ -357,7 +359,7 @@ int mysql_server_init(int argc, const char **argv, const char **groups)
|
|||||||
strcat(server_version,"-debug");
|
strcat(server_version,"-debug");
|
||||||
#endif
|
#endif
|
||||||
strcat(server_version,"-embedded");
|
strcat(server_version,"-embedded");
|
||||||
load_defaults("my", groups, argcp, argvp);
|
load_defaults("my", (const char **) groups, argcp, argvp);
|
||||||
defaults_argv=*argvp;
|
defaults_argv=*argvp;
|
||||||
mysql_tmpdir=getenv("TMPDIR"); /* Use this if possible */
|
mysql_tmpdir=getenv("TMPDIR"); /* Use this if possible */
|
||||||
#if defined( __WIN__) || defined(OS2)
|
#if defined( __WIN__) || defined(OS2)
|
||||||
|
@ -79,11 +79,6 @@ static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
|
|||||||
#define set_sigpipe(mysql)
|
#define set_sigpipe(mysql)
|
||||||
#define reset_sigpipe(mysql)
|
#define reset_sigpipe(mysql)
|
||||||
|
|
||||||
static MYSQL* spawn_init(MYSQL* parent, const char* host,
|
|
||||||
unsigned int port,
|
|
||||||
const char* user,
|
|
||||||
const char* passwd);
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
** read a packet from server. Give error message if socket was down
|
** read a packet from server. Give error message if socket was down
|
||||||
** or packet is an error message
|
** or packet is an error message
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include
|
INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include
|
||||||
pkglib_LIBRARIES = libmerge.a
|
pkglib_LIBRARIES = libmerge.a
|
||||||
noinst_HEADERS = mrgdef.h
|
noinst_HEADERS = mrg_def.h
|
||||||
libmerge_a_SOURCES = open.c extra.c info.c _locking.c \
|
libmerge_a_SOURCES = mrg_open.c mrg_extra.c mrg_info.c mrg_locking.c \
|
||||||
rrnd.c update.c delete.c rsame.c panic.c \
|
mrg_rrnd.c mrg_update.c mrg_delete.c mrg_rsame.c \
|
||||||
close.c create.c static.c
|
mrg_panic.c mrg_close.c mrg_create.c mrg_static.c
|
||||||
|
|
||||||
OMIT_DEPENDENCIES = pthread.h stdio.h __stdio.h stdlib.h __stdlib.h math.h\
|
OMIT_DEPENDENCIES = pthread.h stdio.h __stdio.h stdlib.h __stdlib.h math.h\
|
||||||
__math.h time.h __time.h unistd.h __unistd.h types.h \
|
__math.h time.h __time.h unistd.h __unistd.h types.h \
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
/* close a isam-database */
|
/* close a isam-database */
|
||||||
|
|
||||||
#include "mrgdef.h"
|
#include "mrg_def.h"
|
||||||
|
|
||||||
int mrg_close(register MRG_INFO *info)
|
int mrg_close(register MRG_INFO *info)
|
||||||
{
|
{
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
/* Create a MERGE-file */
|
/* Create a MERGE-file */
|
||||||
|
|
||||||
#include "mrgdef.h"
|
#include "mrg_def.h"
|
||||||
|
|
||||||
/* create file named 'name' and save filenames in it
|
/* create file named 'name' and save filenames in it
|
||||||
table_names should be NULL or a vector of string-pointers with
|
table_names should be NULL or a vector of string-pointers with
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
/* Delete last read record */
|
/* Delete last read record */
|
||||||
|
|
||||||
#include "mrgdef.h"
|
#include "mrg_def.h"
|
||||||
|
|
||||||
int mrg_delete(MRG_INFO *info,const byte *record)
|
int mrg_delete(MRG_INFO *info,const byte *record)
|
||||||
{
|
{
|
@ -20,7 +20,7 @@
|
|||||||
record-cache-flags are set in mrg_rrnd when we are changing database.
|
record-cache-flags are set in mrg_rrnd when we are changing database.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mrgdef.h"
|
#include "mrg_def.h"
|
||||||
|
|
||||||
int mrg_extra(
|
int mrg_extra(
|
||||||
MRG_INFO *info,
|
MRG_INFO *info,
|
@ -14,7 +14,7 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
|
||||||
#include "mrgdef.h"
|
#include "mrg_def.h"
|
||||||
|
|
||||||
ulong mrg_position(MRG_INFO *info)
|
ulong mrg_position(MRG_INFO *info)
|
||||||
{
|
{
|
@ -18,7 +18,7 @@
|
|||||||
Lock databases against read or write.
|
Lock databases against read or write.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mrgdef.h"
|
#include "mrg_def.h"
|
||||||
|
|
||||||
int mrg_lock_database(MRG_INFO *info,int lock_type)
|
int mrg_lock_database(MRG_INFO *info,int lock_type)
|
||||||
{
|
{
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
/* open a MERGE-database */
|
/* open a MERGE-database */
|
||||||
|
|
||||||
#include "mrgdef.h"
|
#include "mrg_def.h"
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#ifdef VMS
|
#ifdef VMS
|
@ -14,7 +14,7 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
|
||||||
#include "mrgdef.h"
|
#include "mrg_def.h"
|
||||||
|
|
||||||
/* if flag == HA_PANIC_CLOSE then all misam files are closed */
|
/* if flag == HA_PANIC_CLOSE then all misam files are closed */
|
||||||
/* if flag == HA_PANIC_WRITE then all misam files are unlocked and
|
/* if flag == HA_PANIC_WRITE then all misam files are unlocked and
|
@ -19,7 +19,7 @@
|
|||||||
get by mrg_info(). The next record can be read with pos= -1 */
|
get by mrg_info(). The next record can be read with pos= -1 */
|
||||||
|
|
||||||
|
|
||||||
#include "mrgdef.h"
|
#include "mrg_def.h"
|
||||||
|
|
||||||
static MRG_TABLE *find_table(MRG_TABLE *start,MRG_TABLE *end,mrg_off_t pos);
|
static MRG_TABLE *find_table(MRG_TABLE *start,MRG_TABLE *end,mrg_off_t pos);
|
||||||
|
|
@ -14,7 +14,7 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
|
||||||
#include "mrgdef.h"
|
#include "mrg_def.h"
|
||||||
|
|
||||||
|
|
||||||
int mrg_rsame(
|
int mrg_rsame(
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef stdin
|
#ifndef stdin
|
||||||
#include "mrgdef.h"
|
#include "mrg_def.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LIST *mrg_open_list=0;
|
LIST *mrg_open_list=0;
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
/* Update last read record */
|
/* Update last read record */
|
||||||
|
|
||||||
#include "mrgdef.h"
|
#include "mrg_def.h"
|
||||||
|
|
||||||
int mrg_update(
|
int mrg_update(
|
||||||
register MRG_INFO *info,
|
register MRG_INFO *info,
|
@ -404,11 +404,7 @@ static int examine_log(my_string file_name, char **table_names)
|
|||||||
}
|
}
|
||||||
to=isam_file_name;
|
to=isam_file_name;
|
||||||
if (filepath)
|
if (filepath)
|
||||||
{
|
to=convert_dirname(isam_file_name,filepath,NullS);
|
||||||
strmov(isam_file_name,filepath);
|
|
||||||
convert_dirname(isam_file_name);
|
|
||||||
to=strend(isam_file_name);
|
|
||||||
}
|
|
||||||
strmov(to,pos);
|
strmov(to,pos);
|
||||||
fn_ext(isam_file_name)[0]=0; /* Remove extension */
|
fn_ext(isam_file_name)[0]=0; /* Remove extension */
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include
|
INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include
|
||||||
pkglib_LIBRARIES = libmyisammrg.a
|
pkglib_LIBRARIES = libmyisammrg.a
|
||||||
noinst_HEADERS = mymrgdef.h
|
noinst_HEADERS = myrg_def.h
|
||||||
libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
|
libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
|
||||||
myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \
|
myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \
|
||||||
myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \
|
myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
/* close a isam-database */
|
/* close a isam-database */
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
|
|
||||||
int myrg_close(MYRG_INFO *info)
|
int myrg_close(MYRG_INFO *info)
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
/* Create a MYMERGE_-file */
|
/* Create a MYMERGE_-file */
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
|
|
||||||
/* create file named 'name' and save filenames in it
|
/* create file named 'name' and save filenames in it
|
||||||
table_names should be NULL or a vector of string-pointers with
|
table_names should be NULL or a vector of string-pointers with
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
/* Delete last read record */
|
/* Delete last read record */
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
|
|
||||||
int myrg_delete(
|
int myrg_delete(
|
||||||
MYRG_INFO *info,
|
MYRG_INFO *info,
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
record-cache-flags are set in myrg_rrnd when we are changing database.
|
record-cache-flags are set in myrg_rrnd when we are changing database.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
|
|
||||||
int myrg_extra(MYRG_INFO *info,enum ha_extra_function function)
|
int myrg_extra(MYRG_INFO *info,enum ha_extra_function function)
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
|
|
||||||
ulonglong myrg_position(MYRG_INFO *info)
|
ulonglong myrg_position(MYRG_INFO *info)
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
Lock databases against read or write.
|
Lock databases against read or write.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
|
|
||||||
int myrg_lock_database(
|
int myrg_lock_database(
|
||||||
MYRG_INFO *info,
|
MYRG_INFO *info,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
/* open a MyISAM MERGE table */
|
/* open a MyISAM MERGE table */
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#ifdef VMS
|
#ifdef VMS
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
|
|
||||||
/* if flag == HA_PANIC_CLOSE then all misam files are closed */
|
/* if flag == HA_PANIC_CLOSE then all misam files are closed */
|
||||||
/* if flag == HA_PANIC_WRITE then all misam files are unlocked and
|
/* if flag == HA_PANIC_WRITE then all misam files are unlocked and
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
/* Read record based on a key */
|
/* Read record based on a key */
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
|
|
||||||
static int queue_key_cmp(void *keyseg, byte *a, byte *b)
|
static int queue_key_cmp(void *keyseg, byte *a, byte *b)
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
|
|
||||||
/* Read first row according to specific key */
|
/* Read first row according to specific key */
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
|
|
||||||
/* todo: we could store some additional info to speedup lookups:
|
/* todo: we could store some additional info to speedup lookups:
|
||||||
column (key, keyseg) can be constant per table
|
column (key, keyseg) can be constant per table
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
|
|
||||||
/* Read last row with the same key as the previous read. */
|
/* Read last row with the same key as the previous read. */
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Read next row with the same key as previous read
|
Read next row with the same key as previous read
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Read previous row with the same key as previous read
|
Read previous row with the same key as previous read
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
get by myrg_info(). The next record can be read with pos= -1 */
|
get by myrg_info(). The next record can be read with pos= -1 */
|
||||||
|
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
|
|
||||||
static MYRG_TABLE *find_table(MYRG_TABLE *start,MYRG_TABLE *end,ulonglong pos);
|
static MYRG_TABLE *find_table(MYRG_TABLE *start,MYRG_TABLE *end,ulonglong pos);
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
|
|
||||||
int myrg_rsame(MYRG_INFO *info,byte *record,int inx)
|
int myrg_rsame(MYRG_INFO *info,byte *record,int inx)
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef stdin
|
#ifndef stdin
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LIST *myrg_open_list=0;
|
LIST *myrg_open_list=0;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
/* Update last read record */
|
/* Update last read record */
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
|
|
||||||
int myrg_update(register MYRG_INFO *info,const byte *oldrec, byte *newrec)
|
int myrg_update(register MYRG_INFO *info,const byte *oldrec, byte *newrec)
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
/* Write a row to a MyISAM MERGE table */
|
/* Write a row to a MyISAM MERGE table */
|
||||||
|
|
||||||
#include "mymrgdef.h"
|
#include "myrg_def.h"
|
||||||
|
|
||||||
int myrg_write(register MYRG_INFO *info, byte *rec)
|
int myrg_write(register MYRG_INFO *info, byte *rec)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
connect (master,localhost,root,,test,0,mysql-master.sock);
|
connect (master,localhost,root,,test,0,master.sock);
|
||||||
connect (master1,localhost,root,,test,0,mysql-master.sock);
|
connect (master1,localhost,root,,test,0,master.sock);
|
||||||
connect (slave,localhost,root,,test,0,mysql-slave.sock);
|
connect (slave,localhost,root,,test,0,slave.sock);
|
||||||
connect (slave1,localhost,root,,test,0,mysql-slave.sock);
|
connect (slave1,localhost,root,,test,0,slave.sock);
|
||||||
connection slave;
|
connection slave;
|
||||||
!slave stop;
|
!slave stop;
|
||||||
@r/slave-stopped.result show status like 'Slave_running';
|
@r/slave-stopped.result show status like 'Slave_running';
|
||||||
|
3
mysql-test/include/not_embedded.inc
Normal file
3
mysql-test/include/not_embedded.inc
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
-- require r/not_embedded.require
|
||||||
|
select version() like "%embedded%" as "have_embedded";
|
||||||
|
|
@ -249,13 +249,13 @@ done
|
|||||||
|
|
||||||
MYRUN_DIR=$MYSQL_TEST_DIR/var/run
|
MYRUN_DIR=$MYSQL_TEST_DIR/var/run
|
||||||
MASTER_MYDDIR="$MYSQL_TEST_DIR/var/master-data"
|
MASTER_MYDDIR="$MYSQL_TEST_DIR/var/master-data"
|
||||||
MASTER_MYSOCK="$MYSQL_TMP_DIR/mysql-master.sock"
|
MASTER_MYSOCK="$MYSQL_TMP_DIR/master.sock"
|
||||||
MASTER_MYPID="$MYRUN_DIR/mysqld.pid"
|
MASTER_MYPID="$MYRUN_DIR/mysqld.pid"
|
||||||
MASTER_MYLOG="$MYSQL_TEST_DIR/var/log/mysqld.log"
|
MASTER_MYLOG="$MYSQL_TEST_DIR/var/log/mysqld.log"
|
||||||
MASTER_MYERR="$MYSQL_TEST_DIR/var/log/mysqld.err"
|
MASTER_MYERR="$MYSQL_TEST_DIR/var/log/mysqld.err"
|
||||||
|
|
||||||
SLAVE_MYDDIR="$MYSQL_TEST_DIR/var/slave-data"
|
SLAVE_MYDDIR="$MYSQL_TEST_DIR/var/slave-data"
|
||||||
SLAVE_MYSOCK="$MYSQL_TMP_DIR/mysql-slave.sock"
|
SLAVE_MYSOCK="$MYSQL_TMP_DIR/slave.sock"
|
||||||
SLAVE_MYPID="$MYRUN_DIR/mysqld-slave.pid"
|
SLAVE_MYPID="$MYRUN_DIR/mysqld-slave.pid"
|
||||||
SLAVE_MYLOG="$MYSQL_TEST_DIR/var/log/mysqld-slave.log"
|
SLAVE_MYLOG="$MYSQL_TEST_DIR/var/log/mysqld-slave.log"
|
||||||
SLAVE_MYERR="$MYSQL_TEST_DIR/var/log/mysqld-slave.err"
|
SLAVE_MYERR="$MYSQL_TEST_DIR/var/log/mysqld-slave.err"
|
||||||
|
@ -23,30 +23,6 @@ a b c
|
|||||||
8 8 8
|
8 8 8
|
||||||
9 9 9
|
9 9 9
|
||||||
drop table t1;
|
drop table t1;
|
||||||
create table t1 (a int not null auto_increment,b int, primary key (a)) type=isam;
|
|
||||||
insert into t1 values (1,1),(NULL,2),(3,3),(NULL,4);
|
|
||||||
delete from t1 where a=4 or a=2;
|
|
||||||
insert into t1 values (NULL,4),(NULL,5),(6,6);
|
|
||||||
select * from t1;
|
|
||||||
a b
|
|
||||||
1 1
|
|
||||||
5 5
|
|
||||||
3 3
|
|
||||||
4 4
|
|
||||||
6 6
|
|
||||||
delete from t1 where a=6;
|
|
||||||
replace t1 values (3,1);
|
|
||||||
replace t1 values (3,3);
|
|
||||||
ALTER TABLE t1 add c int;
|
|
||||||
insert into t1 values (NULL,6,6);
|
|
||||||
select * from t1;
|
|
||||||
a b c
|
|
||||||
1 1 NULL
|
|
||||||
5 5 NULL
|
|
||||||
3 3 NULL
|
|
||||||
4 4 NULL
|
|
||||||
6 6 6
|
|
||||||
drop table t1;
|
|
||||||
create table t1 (
|
create table t1 (
|
||||||
skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY,
|
skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY,
|
||||||
sval char(20)
|
sval char(20)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
select database(),user();
|
select database(),user() like "%@%";
|
||||||
database() user()
|
database() user()
|
||||||
test root@localhost
|
test 1
|
||||||
select version()>="3.23.29";
|
select version()>="3.23.29";
|
||||||
version()>="3.23.29"
|
version()>="3.23.29"
|
||||||
1
|
1
|
||||||
|
@ -15,4 +15,42 @@ test.t1 repair status OK
|
|||||||
check table t1;
|
check table t1;
|
||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
test.t1 check status OK
|
test.t1 check status OK
|
||||||
|
a b
|
||||||
|
1 1
|
||||||
|
5 5
|
||||||
|
3 3
|
||||||
|
4 4
|
||||||
|
6 6
|
||||||
|
a b c
|
||||||
|
1 1 NULL
|
||||||
|
5 5 NULL
|
||||||
|
3 3 NULL
|
||||||
|
4 4 NULL
|
||||||
|
6 6 6
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t1 optimize status OK
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t1 check status OK
|
||||||
|
test.t2 check error The handler for the table doesn't support check/repair
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t1 repair status OK
|
||||||
|
test.t2 repair error The handler for the table doesn't support check/repair
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t2 check error The handler for the table doesn't support check/repair
|
||||||
|
test.t1 check status OK
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t2 check error Table 't2' was not locked with LOCK TABLES
|
||||||
|
test.t1 check status OK
|
||||||
|
Field Type Null Key Default Extra
|
||||||
|
a int(11) PRI 0
|
||||||
|
b int(11) MUL 0
|
||||||
|
c int(11) 0
|
||||||
|
Field Type Null Key Default Extra Privileges
|
||||||
|
a int(11) PRI 0 select,insert,update,references
|
||||||
|
b int(11) MUL 0 select,insert,update,references
|
||||||
|
c int(11) 0 select,insert,update,references
|
||||||
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Comment
|
||||||
|
t1 0 PRIMARY 1 a A 4 NULL NULL
|
||||||
|
t1 1 b 1 b A 1 NULL NULL
|
||||||
|
t1 1 b 2 c A 4 NULL NULL
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
4
mysql-test/r/lock_multi.result
Normal file
4
mysql-test/r/lock_multi.result
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
n
|
||||||
|
4
|
||||||
|
n
|
||||||
|
1
|
2
mysql-test/r/not_embedded.require
Normal file
2
mysql-test/r/not_embedded.require
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
have_embedded
|
||||||
|
0
|
@ -1,45 +1,6 @@
|
|||||||
drop table if exists t1,t2;
|
drop table if exists t1,t2;
|
||||||
create table t1 (a int not null primary key, b int not null,c int not null, key(b,c));
|
create table t1 (a int not null primary key, b int not null,c int not null, key(b,c));
|
||||||
insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4);
|
insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4);
|
||||||
create table t2 type=isam select * from t1;
|
|
||||||
optimize table t1;
|
|
||||||
Table Op Msg_type Msg_text
|
|
||||||
test.t1 optimize status OK
|
|
||||||
check table t1,t2;
|
|
||||||
Table Op Msg_type Msg_text
|
|
||||||
test.t1 check status OK
|
|
||||||
test.t2 check error The handler for the table doesn't support check/repair
|
|
||||||
repair table t1,t2;
|
|
||||||
Table Op Msg_type Msg_text
|
|
||||||
test.t1 repair status OK
|
|
||||||
test.t2 repair error The handler for the table doesn't support check/repair
|
|
||||||
check table t2,t1;
|
|
||||||
Table Op Msg_type Msg_text
|
|
||||||
test.t2 check error The handler for the table doesn't support check/repair
|
|
||||||
test.t1 check status OK
|
|
||||||
lock tables t1 write;
|
|
||||||
check table t2,t1;
|
|
||||||
Table Op Msg_type Msg_text
|
|
||||||
test.t2 check error Table 't2' was not locked with LOCK TABLES
|
|
||||||
test.t1 check status OK
|
|
||||||
show columns from t1;
|
|
||||||
Field Type Null Key Default Extra
|
|
||||||
a int(11) PRI 0
|
|
||||||
b int(11) MUL 0
|
|
||||||
c int(11) 0
|
|
||||||
show full columns from t1;
|
|
||||||
Field Type Null Key Default Extra Privileges
|
|
||||||
a int(11) PRI 0 select,insert,update,references
|
|
||||||
b int(11) MUL 0 select,insert,update,references
|
|
||||||
c int(11) 0 select,insert,update,references
|
|
||||||
show index from t1;
|
|
||||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Comment
|
|
||||||
t1 0 PRIMARY 1 a A 4 NULL NULL
|
|
||||||
t1 1 b 1 b A 1 NULL NULL
|
|
||||||
t1 1 b 2 c A 4 NULL NULL
|
|
||||||
drop table t1,t2;
|
|
||||||
create table t1 (a int not null primary key, b int not null,c int not null, key(b,c));
|
|
||||||
insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4);
|
|
||||||
check table t1 type=fast;
|
check table t1 type=fast;
|
||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
test.t1 check status Table is already up to date
|
test.t1 check status Table is already up to date
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# Test of auto_increment; The test for BDB tables is in bdb.test
|
# Test of auto_increment; The test for BDB tables is in bdb.test
|
||||||
#
|
#
|
||||||
|
|
||||||
|
drop table if exists t1;
|
||||||
create table t1 (a int not null auto_increment,b int, primary key (a)) type=myisam auto_increment=3;
|
create table t1 (a int not null auto_increment,b int, primary key (a)) type=myisam auto_increment=3;
|
||||||
insert into t1 values (1,1),(NULL,3),(NULL,4);
|
insert into t1 values (1,1),(NULL,3),(NULL,4);
|
||||||
delete from t1 where a=4;
|
delete from t1 where a=4;
|
||||||
@ -18,20 +19,6 @@ insert into t1 values (NULL,9,9);
|
|||||||
select * from t1;
|
select * from t1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
create table t1 (a int not null auto_increment,b int, primary key (a)) type=isam;
|
|
||||||
insert into t1 values (1,1),(NULL,2),(3,3),(NULL,4);
|
|
||||||
delete from t1 where a=4 or a=2;
|
|
||||||
insert into t1 values (NULL,4),(NULL,5),(6,6);
|
|
||||||
select * from t1;
|
|
||||||
delete from t1 where a=6;
|
|
||||||
#show table status like "t1";
|
|
||||||
replace t1 values (3,1);
|
|
||||||
replace t1 values (3,3);
|
|
||||||
ALTER TABLE t1 add c int;
|
|
||||||
insert into t1 values (NULL,6,6);
|
|
||||||
select * from t1;
|
|
||||||
drop table t1;
|
|
||||||
|
|
||||||
create table t1 (
|
create table t1 (
|
||||||
skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY,
|
skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY,
|
||||||
sval char(20)
|
sval char(20)
|
||||||
|
@ -39,9 +39,3 @@ reap;
|
|||||||
unlock tables;
|
unlock tables;
|
||||||
connection con1;
|
connection con1;
|
||||||
reap;
|
reap;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
-O max_heap_table_size=16384
|
--set-variable=max_heap_table_size=16384
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
drop table if exists t1;
|
||||||
|
|
||||||
create table t1(n1 int, n2 int, s char(20), vs varchar(20), t text);
|
create table t1(n1 int, n2 int, s char(20), vs varchar(20), t text);
|
||||||
insert into t1 values (1,11, 'one','eleven', 'eleven'),
|
insert into t1 values (1,11, 'one','eleven', 'eleven'),
|
||||||
(1,11, 'one','eleven', 'eleven'),
|
(1,11, 'one','eleven', 'eleven'),
|
||||||
@ -44,7 +46,7 @@ select count(distinct n1), count(distinct n2) from t1;
|
|||||||
select count(distinct n2), n1 from t1 group by n1;
|
select count(distinct n2), n1 from t1 group by n1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
# test the converstion from tree to MyISAM
|
# test the conversion from tree to MyISAM
|
||||||
create table t1 (n int default NULL);
|
create table t1 (n int default NULL);
|
||||||
let $1=5000;
|
let $1=5000;
|
||||||
disable_query_log;
|
disable_query_log;
|
||||||
|
@ -25,14 +25,10 @@ drop table if exists t1,t2;
|
|||||||
!$1164 create table t1 (a int not null auto_increment,primary key (a)) type=heap;
|
!$1164 create table t1 (a int not null auto_increment,primary key (a)) type=heap;
|
||||||
!$1163 create table t1 (a int not null,b text) type=heap;
|
!$1163 create table t1 (a int not null,b text) type=heap;
|
||||||
!$1171 create table t1 (a int ,primary key(a)) type=heap;
|
!$1171 create table t1 (a int ,primary key(a)) type=heap;
|
||||||
!$1121 create table t1 (a int,b text, index(a)) type=isam;
|
|
||||||
!$1073 create table t1 (a int,b text, index(b)) type=isam;
|
|
||||||
drop table if exists t1;
|
drop table if exists t1;
|
||||||
|
|
||||||
!$1075 create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=isam;
|
|
||||||
!$1164 create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=heap;
|
!$1164 create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=heap;
|
||||||
!$1171 create table t1 (ordid int(8), primary key (ordid));
|
!$1171 create table t1 (ordid int(8), primary key (ordid));
|
||||||
!$1121 create table t1 (ordid int(8), unique (ordid)) type=isam;
|
|
||||||
|
|
||||||
-- error 1044,1
|
-- error 1044,1
|
||||||
create table not_existing_database.test (a int);
|
create table not_existing_database.test (a int);
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
# This test doesn't work with the embedded version as this code
|
||||||
|
# assumes that one query is running while we are doing queries on
|
||||||
|
# a second connection.
|
||||||
|
# This would work if mysqltest run would be threaded and handle each
|
||||||
|
# connection in a separate thread.
|
||||||
|
#
|
||||||
|
-- source include/not_embedded.inc
|
||||||
|
|
||||||
connect (con1,localhost,root,,);
|
connect (con1,localhost,root,,);
|
||||||
connect (con2,localhost,root,,);
|
connect (con2,localhost,root,,);
|
||||||
connection con1;
|
connection con1;
|
||||||
|
@ -2,5 +2,5 @@
|
|||||||
# system functions
|
# system functions
|
||||||
#
|
#
|
||||||
|
|
||||||
select database(),user();
|
select database(),user() like "%@%";
|
||||||
select version()>="3.23.29";
|
select version()>="3.23.29";
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
-- source include/have_isam.inc
|
||||||
|
|
||||||
|
drop table if exists t1,t2;
|
||||||
|
|
||||||
#
|
#
|
||||||
# Test possible problem with rows that are about 65535 bytes long
|
# Test possible problem with rows that are about 65535 bytes long
|
||||||
#
|
#
|
||||||
@ -20,3 +24,47 @@ repair table t1;
|
|||||||
check table t1;
|
check table t1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test of auto_increment; The test for BDB tables is in bdb.test
|
||||||
|
#
|
||||||
|
|
||||||
|
create table t1 (a int not null auto_increment,b int, primary key (a)) type=isam;
|
||||||
|
insert into t1 values (1,1),(NULL,2),(3,3),(NULL,4);
|
||||||
|
delete from t1 where a=4 or a=2;
|
||||||
|
insert into t1 values (NULL,4),(NULL,5),(6,6);
|
||||||
|
select * from t1;
|
||||||
|
delete from t1 where a=6;
|
||||||
|
#show table status like "t1";
|
||||||
|
replace t1 values (3,1);
|
||||||
|
replace t1 values (3,3);
|
||||||
|
ALTER TABLE t1 add c int;
|
||||||
|
insert into t1 values (NULL,6,6);
|
||||||
|
select * from t1;
|
||||||
|
drop table t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test of some CREATE TABLE's that should fail
|
||||||
|
#
|
||||||
|
!$1121 create table t1 (a int,b text, index(a)) type=isam;
|
||||||
|
!$1073 create table t1 (a int,b text, index(b)) type=isam;
|
||||||
|
!$1075 create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=isam;
|
||||||
|
!$1121 create table t1 (ordid int(8), unique (ordid)) type=isam;
|
||||||
|
drop table if exists t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test of some show commands
|
||||||
|
#
|
||||||
|
|
||||||
|
create table t1 (a int not null primary key, b int not null,c int not null, key(b,c));
|
||||||
|
insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4);
|
||||||
|
create table t2 type=isam select * from t1;
|
||||||
|
optimize table t1;
|
||||||
|
check table t1,t2;
|
||||||
|
repair table t1,t2;
|
||||||
|
check table t2,t1;
|
||||||
|
lock tables t1 write;
|
||||||
|
check table t2,t1;
|
||||||
|
show columns from t1;
|
||||||
|
show full columns from t1;
|
||||||
|
show index from t1;
|
||||||
|
drop table t1,t2;
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
# This test doesn't work with the embedded version as this code
|
||||||
|
# assumes that one query is running while we are doing queries on
|
||||||
|
# a second connection.
|
||||||
|
# This would work if mysqltest run would be threaded and handle each
|
||||||
|
# connection in a separate thread.
|
||||||
|
#
|
||||||
|
-- source include/not_embedded.inc
|
||||||
|
|
||||||
connect (con1, localhost, root,,);
|
connect (con1, localhost, root,,);
|
||||||
connect (con2, localhost, root,,);
|
connect (con2, localhost, root,,);
|
||||||
|
|
||||||
|
@ -53,45 +53,3 @@ lock tables t1 write;
|
|||||||
check table t2;
|
check table t2;
|
||||||
unlock tables;
|
unlock tables;
|
||||||
drop table t1,t2;
|
drop table t1,t2;
|
||||||
|
|
||||||
#test to see if select will get the lock ahead of low priority update
|
|
||||||
connect (locker,localhost,root,,);
|
|
||||||
connect (reader,localhost,root,,);
|
|
||||||
connect (writer,localhost,root,,);
|
|
||||||
|
|
||||||
connection locker;
|
|
||||||
create table t1(n int);
|
|
||||||
insert into t1 values (1);
|
|
||||||
lock tables t1 write;
|
|
||||||
connection writer;
|
|
||||||
send update low_priority t1 set n = 4;
|
|
||||||
connection reader;
|
|
||||||
--sleep 2
|
|
||||||
send select n from t1;
|
|
||||||
connection locker;
|
|
||||||
--sleep 2
|
|
||||||
unlock tables;
|
|
||||||
connection writer;
|
|
||||||
reap;
|
|
||||||
connection reader;
|
|
||||||
reap;
|
|
||||||
drop table t1;
|
|
||||||
|
|
||||||
connection locker;
|
|
||||||
create table t1(n int);
|
|
||||||
insert into t1 values (1);
|
|
||||||
lock tables t1 read;
|
|
||||||
connection writer;
|
|
||||||
send update low_priority t1 set n = 4;
|
|
||||||
connection reader;
|
|
||||||
--sleep 2
|
|
||||||
send select n from t1;
|
|
||||||
connection locker;
|
|
||||||
--sleep 2
|
|
||||||
unlock tables;
|
|
||||||
connection writer;
|
|
||||||
reap;
|
|
||||||
connection reader;
|
|
||||||
reap;
|
|
||||||
drop table t1;
|
|
||||||
|
|
||||||
|
49
mysql-test/t/lock_multi.test
Normal file
49
mysql-test/t/lock_multi.test
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# This test doesn't work with the embedded version as this code
|
||||||
|
# assumes that one query is running while we are doing queries on
|
||||||
|
# a second connection.
|
||||||
|
# This would work if mysqltest run would be threaded and handle each
|
||||||
|
# connection in a separate thread.
|
||||||
|
#
|
||||||
|
-- source include/not_embedded.inc
|
||||||
|
|
||||||
|
#test to see if select will get the lock ahead of low priority update
|
||||||
|
|
||||||
|
connect (locker,localhost,root,,);
|
||||||
|
connect (reader,localhost,root,,);
|
||||||
|
connect (writer,localhost,root,,);
|
||||||
|
|
||||||
|
connection locker;
|
||||||
|
create table t1(n int);
|
||||||
|
insert into t1 values (1);
|
||||||
|
lock tables t1 write;
|
||||||
|
connection writer;
|
||||||
|
send update low_priority t1 set n = 4;
|
||||||
|
connection reader;
|
||||||
|
--sleep 2
|
||||||
|
send select n from t1;
|
||||||
|
connection locker;
|
||||||
|
--sleep 2
|
||||||
|
unlock tables;
|
||||||
|
connection writer;
|
||||||
|
reap;
|
||||||
|
connection reader;
|
||||||
|
reap;
|
||||||
|
drop table t1;
|
||||||
|
|
||||||
|
connection locker;
|
||||||
|
create table t1(n int);
|
||||||
|
insert into t1 values (1);
|
||||||
|
lock tables t1 read;
|
||||||
|
connection writer;
|
||||||
|
send update low_priority t1 set n = 4;
|
||||||
|
connection reader;
|
||||||
|
--sleep 2
|
||||||
|
send select n from t1;
|
||||||
|
connection locker;
|
||||||
|
--sleep 2
|
||||||
|
unlock tables;
|
||||||
|
connection writer;
|
||||||
|
reap;
|
||||||
|
connection reader;
|
||||||
|
reap;
|
||||||
|
drop table t1;
|
@ -1 +1 @@
|
|||||||
-O sort_buffer=0
|
--set-variable=sort_buffer=0
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
connect (master,localhost,root,,test,0,mysql-master.sock);
|
connect (master,localhost,root,,test,0,master.sock);
|
||||||
connect (slave,localhost,root,,test,0, mysql-slave.sock);
|
connect (slave,localhost,root,,test,0, slave.sock);
|
||||||
eval_result;
|
eval_result;
|
||||||
connection master;
|
connection master;
|
||||||
reset master;
|
reset master;
|
||||||
@ -32,4 +32,3 @@ drop table t1;
|
|||||||
save_master_pos;
|
save_master_pos;
|
||||||
connection slave;
|
connection slave;
|
||||||
sync_with_master;
|
sync_with_master;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
connect (master,localhost,root,,test,0,mysql-master.sock);
|
connect (master,localhost,root,,test,0,master.sock);
|
||||||
connect (slave,localhost,root,,test,0,mysql-slave.sock);
|
connect (slave,localhost,root,,test,0,slave.sock);
|
||||||
eval_result;
|
eval_result;
|
||||||
system cat /dev/null > var/slave-data/master.info;
|
system cat /dev/null > var/slave-data/master.info;
|
||||||
system chmod 000 var/slave-data/master.info;
|
system chmod 000 var/slave-data/master.info;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
connect (master,localhost,root,,test,0,mysql-master.sock);
|
connect (master,localhost,root,,test,0,master.sock);
|
||||||
connect (slave,localhost,root,,test,0,mysql-slave.sock);
|
connect (slave,localhost,root,,test,0,slave.sock);
|
||||||
connection master;
|
connection master;
|
||||||
reset master;
|
reset master;
|
||||||
grant file on *.* to replicate@localhost identified by 'aaaaaaaaaaaaaaab';
|
grant file on *.* to replicate@localhost identified by 'aaaaaaaaaaaaaaab';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
connect (master,localhost,root,,test,0,mysql-master.sock);
|
connect (master,localhost,root,,test,0,master.sock);
|
||||||
connect (slave,localhost,root,,test,0,mysql-slave.sock);
|
connect (slave,localhost,root,,test,0,slave.sock);
|
||||||
server_stop master;
|
server_stop master;
|
||||||
server_start master;
|
server_start master;
|
||||||
connection slave;
|
connection slave;
|
||||||
|
@ -1,21 +1,8 @@
|
|||||||
#
|
#
|
||||||
# Test of some show commands
|
# Test of some show commands
|
||||||
#
|
#
|
||||||
drop table if exists t1,t2;
|
|
||||||
create table t1 (a int not null primary key, b int not null,c int not null, key(b,c));
|
|
||||||
insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4);
|
|
||||||
create table t2 type=isam select * from t1;
|
|
||||||
optimize table t1;
|
|
||||||
check table t1,t2;
|
|
||||||
repair table t1,t2;
|
|
||||||
check table t2,t1;
|
|
||||||
lock tables t1 write;
|
|
||||||
check table t2,t1;
|
|
||||||
show columns from t1;
|
|
||||||
show full columns from t1;
|
|
||||||
show index from t1;
|
|
||||||
drop table t1,t2;
|
|
||||||
|
|
||||||
|
drop table if exists t1,t2;
|
||||||
create table t1 (a int not null primary key, b int not null,c int not null, key(b,c));
|
create table t1 (a int not null primary key, b int not null,c int not null, key(b,c));
|
||||||
insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4);
|
insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4);
|
||||||
check table t1 type=fast;
|
check table t1 type=fast;
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
# This test doesn't work with the embedded version as this code
|
||||||
|
# assumes that one query is running while we are doing queries on
|
||||||
|
# a second connection.
|
||||||
|
# This would work if mysqltest run would be threaded and handle each
|
||||||
|
# connection in a separate thread.
|
||||||
|
#
|
||||||
|
-- source include/not_embedded.inc
|
||||||
|
|
||||||
connect (con1,localhost,root,,);
|
connect (con1,localhost,root,,);
|
||||||
connect (con2,localhost,root,,);
|
connect (con2,localhost,root,,);
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# Test of lock tables
|
# Test of lock tables
|
||||||
#
|
#
|
||||||
|
|
||||||
|
drop table if exists t1,t2;
|
||||||
create table t1 ( n int auto_increment primary key);
|
create table t1 ( n int auto_increment primary key);
|
||||||
lock tables t1 write;
|
lock tables t1 write;
|
||||||
insert into t1 values(NULL);
|
insert into t1 values(NULL);
|
||||||
@ -36,12 +37,10 @@ drop table t1;
|
|||||||
CREATE TABLE t1 (a int);
|
CREATE TABLE t1 (a int);
|
||||||
CREATE TABLE t2 (a int);
|
CREATE TABLE t2 (a int);
|
||||||
lock tables t1 write,t1 as b write, t2 write, t2 as c read;
|
lock tables t1 write,t1 as b write, t2 write, t2 as c read;
|
||||||
drop table t1;
|
drop table t1,t2;
|
||||||
drop table t2;
|
|
||||||
|
|
||||||
CREATE TABLE t1 (a int);
|
CREATE TABLE t1 (a int);
|
||||||
CREATE TABLE t2 (a int);
|
CREATE TABLE t2 (a int);
|
||||||
lock tables t1 write,t1 as b write, t2 write, t2 as c read;
|
lock tables t1 write,t1 as b write, t2 write, t2 as c read;
|
||||||
drop table t2;
|
drop table t2,t1;
|
||||||
drop table t1;
|
|
||||||
unlock tables;
|
unlock tables;
|
||||||
|
@ -34,7 +34,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\
|
|||||||
my_error.c errors.c my_div.c my_messnc.c \
|
my_error.c errors.c my_div.c my_messnc.c \
|
||||||
mf_format.c mf_same.c mf_dirname.c mf_fn_ext.c \
|
mf_format.c mf_same.c mf_dirname.c mf_fn_ext.c \
|
||||||
my_symlink.c my_symlink2.c \
|
my_symlink.c my_symlink2.c \
|
||||||
mf_pack.c mf_pack2.c mf_unixpath.c mf_stripp.c \
|
mf_pack.c mf_unixpath.c mf_stripp.c \
|
||||||
mf_casecnv.c mf_soundex.c mf_wcomp.c mf_wfile.c \
|
mf_casecnv.c mf_soundex.c mf_wcomp.c mf_wfile.c \
|
||||||
mf_qsort.c mf_qsort2.c mf_sort.c \
|
mf_qsort.c mf_qsort2.c mf_sort.c \
|
||||||
ptr_cmp.c mf_radix.c queues.c \
|
ptr_cmp.c mf_radix.c queues.c \
|
||||||
|
@ -103,7 +103,7 @@ char *get_charsets_dir(char *buf)
|
|||||||
strxmov(buf, DEFAULT_CHARSET_HOME, "/", sharedir, "/", CHARSET_DIR,
|
strxmov(buf, DEFAULT_CHARSET_HOME, "/", sharedir, "/", CHARSET_DIR,
|
||||||
NullS);
|
NullS);
|
||||||
}
|
}
|
||||||
convert_dirname(buf);
|
convert_dirname(buf,buf,NullS);
|
||||||
DBUG_PRINT("info",("charsets dir='%s'", buf));
|
DBUG_PRINT("info",("charsets dir='%s'", buf));
|
||||||
DBUG_RETURN(strend(buf));
|
DBUG_RETURN(strend(buf));
|
||||||
}
|
}
|
||||||
|
@ -231,11 +231,10 @@ static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
|
|||||||
return 0; /* Ignore wrong paths */
|
return 0; /* Ignore wrong paths */
|
||||||
if (dir)
|
if (dir)
|
||||||
{
|
{
|
||||||
strmov(name,dir);
|
end=convert_dirname(name, dir, NullS);
|
||||||
convert_dirname(name);
|
|
||||||
if (dir[0] == FN_HOMELIB) /* Add . to filenames in home */
|
if (dir[0] == FN_HOMELIB) /* Add . to filenames in home */
|
||||||
strcat(name,".");
|
*end++='.';
|
||||||
strxmov(strend(name),config_file,ext,NullS);
|
strxmov(end,config_file,ext,NullS);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -369,16 +368,18 @@ void print_defaults(const char *conf_file, const char **groups)
|
|||||||
#endif
|
#endif
|
||||||
for (dirs=default_directories ; *dirs; dirs++)
|
for (dirs=default_directories ; *dirs; dirs++)
|
||||||
{
|
{
|
||||||
|
const char *pos;
|
||||||
|
char *end;
|
||||||
if (**dirs)
|
if (**dirs)
|
||||||
strmov(name,*dirs);
|
pos= *dirs;
|
||||||
else if (defaults_extra_file)
|
else if (defaults_extra_file)
|
||||||
strmov(name,defaults_extra_file);
|
pos= defaults_extra_file;
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
convert_dirname(name);
|
end=convert_dirname(name, pos, NullS);
|
||||||
if (name[0] == FN_HOMELIB) /* Add . to filenames in home */
|
if (name[0] == FN_HOMELIB) /* Add . to filenames in home */
|
||||||
strcat(name,".");
|
*end++='.';
|
||||||
strxmov(strend(name),conf_file,default_ext," ",NullS);
|
strxmov(end,conf_file,default_ext," ",NullS);
|
||||||
fputs(name,stdout);
|
fputs(name,stdout);
|
||||||
}
|
}
|
||||||
puts("");
|
puts("");
|
||||||
|
@ -50,57 +50,69 @@ uint dirname_part(my_string to, const char *name)
|
|||||||
DBUG_PRINT("enter",("'%s'",name));
|
DBUG_PRINT("enter",("'%s'",name));
|
||||||
|
|
||||||
length=dirname_length(name);
|
length=dirname_length(name);
|
||||||
(void) strmake(to,(char*) name,min(length,FN_REFLEN-2));
|
convert_dirname(to, name, name+length);
|
||||||
convert_dirname(to); /* Convert chars */
|
|
||||||
DBUG_RETURN(length);
|
DBUG_RETURN(length);
|
||||||
} /* dirname */
|
} /* dirname */
|
||||||
|
|
||||||
|
|
||||||
/* convert dirname to use under this system */
|
/*
|
||||||
/* If MSDOS converts '/' to '\' */
|
Convert directory name to use under this system
|
||||||
/* If VMS converts '<' to '[' and '>' to ']' */
|
If MSDOS converts '/' to '\'
|
||||||
/* Adds a '/' to end if there isn't one and the last isn't a dev_char */
|
If VMS converts '<' to '[' and '>' to ']'
|
||||||
/* ARGSUSED */
|
Adds a FN_LIBCHAR to end if the result string if there isn't one
|
||||||
|
and the last isn't dev_char.
|
||||||
|
Copies data from 'from' until ASCII(0) for until from == from_end
|
||||||
|
If you want to use the whole 'from' string, just send NullS as the
|
||||||
|
last argument.
|
||||||
|
If the result string is larger than FN_REFLEN -1, then it's cut.
|
||||||
|
|
||||||
|
Returns pointer to end \0
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef FN_DEVCHAR
|
#ifndef FN_DEVCHAR
|
||||||
#define FN_DEVCHAR '\0' /* For easier code */
|
#define FN_DEVCHAR '\0' /* For easier code */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *convert_dirname(my_string to)
|
char *convert_dirname(char *to, const char *from, const char *from_end)
|
||||||
{
|
{
|
||||||
reg1 char *pos;
|
char *to_org=to;
|
||||||
#ifdef FN_UPPER_CASE
|
|
||||||
caseup_str(to);
|
/* We use -2 here, becasue we need place for the last FN_LIBCHAR */
|
||||||
#endif
|
if (!from_end || (from_end - from) > FN_REFLEN-2)
|
||||||
#ifdef FN_LOWER_CASE
|
from_end=from+FN_REFLEN -2;
|
||||||
casedn_str(to);
|
|
||||||
#endif
|
#if FN_LIBCHAR != '/' || defined(FN_C_BEFORE_DIR_2)
|
||||||
#if FN_LIBCHAR != '/'
|
|
||||||
{
|
{
|
||||||
pos=to-1; /* Change from '/' */
|
while (*from && *from != end)
|
||||||
while ((pos=strchr(pos+1,'/')) != 0)
|
{
|
||||||
*pos=FN_LIBCHAR;
|
if (*from == '/')
|
||||||
}
|
*to++= FN_LIBCHAR;
|
||||||
#endif
|
|
||||||
#ifdef FN_C_BEFORE_DIR_2
|
#ifdef FN_C_BEFORE_DIR_2
|
||||||
{
|
else if (*from == FN_C_BEFORE_DIR_2)
|
||||||
for (pos=to ; *pos ; pos++)
|
*to++= FN_C_BEFORE_DIR;
|
||||||
{
|
else if (*from == FN_C_AFTER_DIR_2)
|
||||||
if (*pos == FN_C_BEFORE_DIR_2)
|
*to++= FN_C_AFTER_DIR;
|
||||||
*pos=FN_C_BEFORE_DIR;
|
#endif
|
||||||
if (*pos == FN_C_AFTER_DIR_2)
|
else
|
||||||
*pos=FN_C_AFTER_DIR;
|
*to++= *from++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{ /* Append FN_LIBCHAR if not there */
|
/* This is ok even if to == from, becasue we need to cut the string */
|
||||||
pos=strend(to);
|
to= strmake(to, from, (uint) (from_end-from));
|
||||||
if (pos != to && (pos[-1] != FN_LIBCHAR && pos[-1] != FN_DEVCHAR))
|
|
||||||
{
|
|
||||||
*pos++=FN_LIBCHAR;
|
|
||||||
*pos=0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return pos; /* Pointer to end of dir */
|
|
||||||
|
/* Add FN_LIBCHAR to the end of directory path */
|
||||||
|
if (to != to_org && (to[-1] != FN_LIBCHAR && to[-1] != FN_DEVCHAR))
|
||||||
|
{
|
||||||
|
*to++=FN_LIBCHAR;
|
||||||
|
*to=0;
|
||||||
|
}
|
||||||
|
#ifdef FN_UPPER_CASE
|
||||||
|
caseup_str(to_org);
|
||||||
|
#endif
|
||||||
|
#ifdef FN_LOWER_CASE
|
||||||
|
casedn_str(to_org);
|
||||||
|
#endif
|
||||||
|
return to; /* Pointer to end of dir */
|
||||||
} /* convert_dirname */
|
} /* convert_dirname */
|
||||||
|
@ -18,64 +18,68 @@
|
|||||||
#include "mysys_priv.h"
|
#include "mysys_priv.h"
|
||||||
#include <m_string.h>
|
#include <m_string.h>
|
||||||
|
|
||||||
/* format a filename with replace of library and extension */
|
/*
|
||||||
/* params to and name may be identicall */
|
Formats a filename with possible replace of directory of extension
|
||||||
/* function doesn't change name if name != to */
|
Function can handle the case where 'to' == 'name'
|
||||||
/* Flag may be: 1 replace filenames library with 'dsk' */
|
For a description of the flag values, consult my_sys.h
|
||||||
/* 2 replace extension with 'form' */
|
The arguments should be in unix format.
|
||||||
/* 4 Unpack filename (replace ~ with home) */
|
*/
|
||||||
/* 8 Pack filename as short as possibly */
|
|
||||||
/* 16 Resolve symbolic links for filename */
|
|
||||||
/* 32 Resolve filename to full path */
|
|
||||||
/* 64 Return NULL if too long path */
|
|
||||||
|
|
||||||
|
|
||||||
my_string fn_format(my_string to, const char *name, const char *dsk,
|
my_string fn_format(my_string to, const char *name, const char *dir,
|
||||||
const char *form, int flag)
|
const char *extension, uint flag)
|
||||||
{
|
{
|
||||||
reg1 uint length;
|
reg1 uint length;
|
||||||
char dev[FN_REFLEN], buff[FN_REFLEN], *pos, *startpos;
|
char dev[FN_REFLEN], buff[FN_REFLEN], *pos, *startpos;
|
||||||
const char *ext;
|
const char *ext;
|
||||||
DBUG_ENTER("fn_format");
|
DBUG_ENTER("fn_format");
|
||||||
DBUG_PRINT("enter",("name: %s dsk: %s form: %s flag: %d",
|
DBUG_PRINT("enter",("name: %s dir: %s extension: %s flag: %d",
|
||||||
name,dsk,form,flag));
|
name,dir,extension,flag));
|
||||||
|
|
||||||
/* Kopiera & skippa enheten */
|
/* Copy and skip directory */
|
||||||
name+=(length=dirname_part(dev,(startpos=(my_string) name)));
|
name+=(length=dirname_part(dev,(startpos=(my_string) name)));
|
||||||
if (length == 0 || flag & 1)
|
if (length == 0 || (flag & MY_REPLACE_DIR))
|
||||||
{
|
{
|
||||||
(void) strmake(dev,dsk, sizeof(dev) - 2);
|
|
||||||
/* Use given directory */
|
/* Use given directory */
|
||||||
convert_dirname(dev); /* Fix to this OS */
|
convert_dirname(dev,dir,NullS); /* Fix to this OS */
|
||||||
}
|
}
|
||||||
if (flag & 8)
|
else if ((flag & MY_RELATIVE_PATH) && !test_if_hard_path(name))
|
||||||
|
{
|
||||||
|
/* Put 'dir' before the given path */
|
||||||
|
strmake(buff,dev,sizeof(buff)-1);
|
||||||
|
pos=convert_dirname(dev,dir,NullS);
|
||||||
|
strmake(pos,buff,sizeof(buff)-1- (int) (pos-dev));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag & MY_PACK_FILENAME)
|
||||||
pack_dirname(dev,dev); /* Put in ./.. and ~/.. */
|
pack_dirname(dev,dev); /* Put in ./.. and ~/.. */
|
||||||
if (flag & 4)
|
if (flag & MY_UNPACK_FILENAME)
|
||||||
(void) unpack_dirname(dev,dev); /* Replace ~/.. with dir */
|
(void) unpack_dirname(dev,dev); /* Replace ~/.. with dir */
|
||||||
if ((pos= (char*) strchr(name,FN_EXTCHAR)) != NullS)
|
if ((pos= (char*) strchr(name,FN_EXTCHAR)) != NullS)
|
||||||
{
|
{
|
||||||
if ((flag & 2) == 0) /* Skall vi byta extension ? */
|
if ((flag & MY_REPLACE_EXT) == 0) /* If we should keep old ext */
|
||||||
{
|
{
|
||||||
length=strlength(name); /* Old extension */
|
length=strlength(name); /* Use old extension */
|
||||||
ext = "";
|
ext = "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
length=(uint) (pos-(char*) name); /* Change extension */
|
length=(uint) (pos-(char*) name); /* Change extension */
|
||||||
ext= form;
|
ext= extension;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
length=strlength(name); /* Har ingen ext- tag nya */
|
length=strlength(name); /* No ext, use the now one */
|
||||||
ext=form;
|
ext=extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(dev)+length+strlen(ext) >= FN_REFLEN || length >= FN_LEN )
|
if (strlen(dev)+length+strlen(ext) >= FN_REFLEN || length >= FN_LEN )
|
||||||
{ /* To long path, return original */
|
{
|
||||||
|
/* To long path, return original or NULL */
|
||||||
uint tmp_length;
|
uint tmp_length;
|
||||||
if (flag & 64)
|
if (flag & MY_SAFE_PATH)
|
||||||
return 0;
|
return NullS;
|
||||||
tmp_length=strlength(startpos);
|
tmp_length=strlength(startpos);
|
||||||
DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %d",dev,ext,length));
|
DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %d",dev,ext,length));
|
||||||
(void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
|
(void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
|
||||||
@ -96,9 +100,14 @@ my_string fn_format(my_string to, const char *name, const char *dsk,
|
|||||||
#endif
|
#endif
|
||||||
(void) strmov(pos,ext); /* Don't convert extension */
|
(void) strmov(pos,ext); /* Don't convert extension */
|
||||||
}
|
}
|
||||||
if (flag & 32)
|
/*
|
||||||
(void) my_realpath(to, to, MYF(flag & 32 ? 0 : MY_RESOLVE_LINK));
|
If MY_RETURN_REAL_PATH and MY_RESOLVE_SYMLINK is given, only do
|
||||||
else if (flag & 16)
|
realpath if the file is a symbolic link
|
||||||
|
*/
|
||||||
|
if (flag & MY_RETURN_REAL_PATH)
|
||||||
|
(void) my_realpath(to, to, MYF(flag & MY_RESOLVE_SYMLINKS ?
|
||||||
|
MY_RESOLVE_LINK: 0));
|
||||||
|
else if (flag & MY_RESOLVE_SYMLINKS)
|
||||||
{
|
{
|
||||||
strmov(buff,to);
|
strmov(buff,to);
|
||||||
(void) my_readlink(to, buff, MYF(0));
|
(void) my_readlink(to, buff, MYF(0));
|
||||||
|
@ -459,8 +459,7 @@ my_string intern_filename(my_string to, const char *from)
|
|||||||
my_string pos,from_pos,to_pos,end_pos;
|
my_string pos,from_pos,to_pos,end_pos;
|
||||||
char buff[FN_REFLEN];
|
char buff[FN_REFLEN];
|
||||||
|
|
||||||
(void) strmov(buff,from);
|
convert_dirname(buff,from,NullS); /* change '<>' to '[]' */
|
||||||
convert_dirname(buff); /* change '<>' to '[]' */
|
|
||||||
from_pos=buff;
|
from_pos=buff;
|
||||||
if ((pos=strrchr(from_pos,FN_DEVCHAR))) /* Skipp device part */
|
if ((pos=strrchr(from_pos,FN_DEVCHAR))) /* Skipp device part */
|
||||||
{
|
{
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
|
||||||
License along with this library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
|
||||||
MA 02111-1307, USA */
|
|
||||||
|
|
||||||
#include "mysys_priv.h"
|
|
||||||
#include <m_string.h>
|
|
||||||
|
|
||||||
/* Pack a filename for output on screen */
|
|
||||||
/* Changes long paths to .../ */
|
|
||||||
/* Removes pathname and extension */
|
|
||||||
/* If not possibly to pack returns '?' in to and returns 1*/
|
|
||||||
|
|
||||||
int pack_filename(my_string to, const char *name, size_s max_length)
|
|
||||||
/* to may be name */
|
|
||||||
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
char buff[FN_REFLEN];
|
|
||||||
|
|
||||||
if (strlen(fn_format(to,name,"","",0)) <= max_length)
|
|
||||||
return 0;
|
|
||||||
if (strlen(fn_format(to,name,"","",8)) <= max_length)
|
|
||||||
return 0;
|
|
||||||
if (strlen(fn_format(buff,name,".../","",1)) <= max_length)
|
|
||||||
{
|
|
||||||
VOID(strmov(to,buff));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
for (i= 0 ; i < 3 ; i++)
|
|
||||||
{
|
|
||||||
if (strlen(fn_format(buff,to,"","", i == 0 ? 2 : i == 1 ? 1 : 3 ))
|
|
||||||
<= max_length)
|
|
||||||
{
|
|
||||||
VOID(strmov(to,buff));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
to[0]='?'; to[1]=0; /* Can't pack filename */
|
|
||||||
return 1;
|
|
||||||
} /* pack_filename */
|
|
@ -101,8 +101,7 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
|
|||||||
errno=my_errno= ENAMETOOLONG;
|
errno=my_errno= ENAMETOOLONG;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
strmov(to,dir);
|
strmov(convert_dirname(to,dir,NullS),prefix_buff);
|
||||||
strmov(convert_dirname(to),prefix_buff);
|
|
||||||
org_file=mkstemp(to);
|
org_file=mkstemp(to);
|
||||||
file=my_register_filename(org_file, to, FILE_BY_MKSTEMP,
|
file=my_register_filename(org_file, to, FILE_BY_MKSTEMP,
|
||||||
EE_CANTCREATEFILE, MyFlags);
|
EE_CANTCREATEFILE, MyFlags);
|
||||||
|
@ -28,6 +28,7 @@ bin_SCRIPTS = @server_scripts@ \
|
|||||||
mysql_find_rows \
|
mysql_find_rows \
|
||||||
mysqlhotcopy \
|
mysqlhotcopy \
|
||||||
mysqldumpslow \
|
mysqldumpslow \
|
||||||
|
mysql_explain_log \
|
||||||
mysqld_multi
|
mysqld_multi
|
||||||
|
|
||||||
EXTRA_SCRIPTS = make_binary_distribution.sh \
|
EXTRA_SCRIPTS = make_binary_distribution.sh \
|
||||||
@ -43,6 +44,7 @@ EXTRA_SCRIPTS = make_binary_distribution.sh \
|
|||||||
mysql_find_rows.sh \
|
mysql_find_rows.sh \
|
||||||
mysqlhotcopy.sh \
|
mysqlhotcopy.sh \
|
||||||
mysqldumpslow.sh \
|
mysqldumpslow.sh \
|
||||||
|
mysql_explain_log.sh \
|
||||||
mysqld_multi.sh \
|
mysqld_multi.sh \
|
||||||
mysqld_safe.sh
|
mysqld_safe.sh
|
||||||
|
|
||||||
@ -95,6 +97,8 @@ SUFFIXES = .sh
|
|||||||
-e 's!@''CXXFLAGS''@!@SAVE_CXXFLAGS@!'\
|
-e 's!@''CXXFLAGS''@!@SAVE_CXXFLAGS@!'\
|
||||||
-e 's!@''LDFLAGS''@!@SAVE_LDFLAGS@!'\
|
-e 's!@''LDFLAGS''@!@SAVE_LDFLAGS@!'\
|
||||||
-e 's!@''CLIENT_LIBS''@!@CLIENT_LIBS@!' \
|
-e 's!@''CLIENT_LIBS''@!@CLIENT_LIBS@!' \
|
||||||
|
-e 's!@''LIBS''@!@LIBS@!' \
|
||||||
|
-e 's!@''innodb_system_libs''@!@innodb_system_libs@!' \
|
||||||
-e 's!@''VERSION''@!@VERSION@!' \
|
-e 's!@''VERSION''@!@VERSION@!' \
|
||||||
-e 's!@''MYSQL_SERVER_SUFFIX''@!@MYSQL_SERVER_SUFFIX@!' \
|
-e 's!@''MYSQL_SERVER_SUFFIX''@!@MYSQL_SERVER_SUFFIX@!' \
|
||||||
-e 's!@''COMPILATION_COMMENT''@!@COMPILATION_COMMENT@!' \
|
-e 's!@''COMPILATION_COMMENT''@!@COMPILATION_COMMENT@!' \
|
||||||
|
383
scripts/explain_log.sh
Normal file
383
scripts/explain_log.sh
Normal file
@ -0,0 +1,383 @@
|
|||||||
|
#!@PERL@ -w
|
||||||
|
use strict;
|
||||||
|
use DBI;
|
||||||
|
|
||||||
|
use Getopt::Long;
|
||||||
|
$Getopt::Long::ignorecase=0;
|
||||||
|
|
||||||
|
print "explain_log provided by http://www.mobile.de\n";
|
||||||
|
print "=========== ================================\n";
|
||||||
|
|
||||||
|
my $Param={};
|
||||||
|
|
||||||
|
$Param->{host}='';
|
||||||
|
$Param->{user}='';
|
||||||
|
$Param->{password}='';
|
||||||
|
$Param->{PrintError}=0;
|
||||||
|
|
||||||
|
if (!GetOptions ('date|d:i' => \$Param->{ViewDate},
|
||||||
|
'host|h:s' => \$Param->{host},
|
||||||
|
'user|u:s' => \$Param->{user},
|
||||||
|
'password|p:s' => \$Param->{password},
|
||||||
|
'printerror|e:s' => \$Param->{PrintError},
|
||||||
|
)) {
|
||||||
|
ShowOptions();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$Param->{UpdateCount} = 0;
|
||||||
|
$Param->{SelectCount} = 0;
|
||||||
|
$Param->{IdxUseCount} = 0;
|
||||||
|
$Param->{LineCount} = 0;
|
||||||
|
|
||||||
|
$Param->{Init} = 0;
|
||||||
|
$Param->{Field} = 0;
|
||||||
|
$Param->{Refresh} = 0;
|
||||||
|
$Param->{QueryCount} = 0;
|
||||||
|
$Param->{Statistics} =0;
|
||||||
|
|
||||||
|
$Param->{Query} = undef;
|
||||||
|
$Param->{ALL} = undef ;
|
||||||
|
$Param->{Comment} = undef ;
|
||||||
|
|
||||||
|
@{$Param->{Rows}} = (qw|possible_keys key type|);
|
||||||
|
|
||||||
|
if ($Param->{ViewDate}) {
|
||||||
|
$Param->{View} = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$Param->{View} = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#print "Date=$Param->{ViewDate}, host=$Param->{host}, user=$Param->{user}, password=$Param->{password}\n";
|
||||||
|
|
||||||
|
$Param->{dbh}=DBI->connect("DBI:mysql:host=$Param->{host}",$Param->{user},$Param->{password},{PrintError=>0});
|
||||||
|
if (DBI::err()) {
|
||||||
|
print "Error: " . DBI::errstr() . "\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$Param->{Start} = time;
|
||||||
|
while(<STDIN>) {
|
||||||
|
$Param->{LineCount} ++ ;
|
||||||
|
|
||||||
|
if ($Param->{ViewDate} ) {
|
||||||
|
if (m/^(\d{6})\s+\d{1,2}:\d\d:\d\d\s.*$/) { # get date
|
||||||
|
#print "# $1 #\n";
|
||||||
|
if ($1 == $Param->{ViewDate}) {
|
||||||
|
$Param->{View} = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$Param->{View} = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($Param->{View} ) {
|
||||||
|
#print "->>>$_";
|
||||||
|
|
||||||
|
if (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Connect.+\s+on\s+(.*)$/i) { # get connection ID($2) and database($3)
|
||||||
|
#print "C-$1--$2--$3------\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
if (defined $3) {
|
||||||
|
$Param->{CID}->{$2} = $3 ;
|
||||||
|
#print "DB:$Param->{CID}->{$2} .. $2 .. $3 \n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Connect.+$/i) { # get connection ID($2) and database($3)
|
||||||
|
#print "\n <<<<<<<<<<<<<<<<<<----------------------------<<<<<<<<<<<<<<<< \n";
|
||||||
|
#print "Connect \n";
|
||||||
|
RunQuery($Param);
|
||||||
|
}
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Change user .*\s+on\s+(.*)$/i) { # get connection ID($2) and database($3)
|
||||||
|
#print "C-$1--$2--$3------\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
if (defined $3) {
|
||||||
|
$Param->{CID}->{$2} = $3 ;
|
||||||
|
#print "DB:$Param->{CID}->{$2} .. $2 .. $3 \n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Quit\s+$/i) { # remove connection ID($2) and querystring
|
||||||
|
#print "Q-$1--$2--------\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
delete $Param->{CID}->{$2} ;
|
||||||
|
}
|
||||||
|
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Query\s+(select.+)$/i) { # get connection ID($2) and querystring
|
||||||
|
#print "S1-$1--$2--$3------\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
unless ($Param->{CID}->{$2}) {
|
||||||
|
#print "Error: No Database for Handle: $2 found\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$Param->{DB}=$Param->{CID}->{$2};
|
||||||
|
|
||||||
|
my $s = "$3";
|
||||||
|
$s =~ s/from\s/from $Param->{DB}./i;
|
||||||
|
$Param->{Query}="EXPLAIN $s";
|
||||||
|
|
||||||
|
#$s =~ m/from\s+(\w+[.]\w+)/i;
|
||||||
|
#$Param->{tab} =$1;
|
||||||
|
#print "-- $Param->{tab} -- $s --\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Query\s+(update.+)$/i) { # get connection ID($2) and querystring
|
||||||
|
#print "S2--$1--$2--$3------\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
unless ($Param->{CID}->{$2}) {
|
||||||
|
#print "Error: No Database for Handle: $2 found\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$Param->{DB}=$Param->{CID}->{$2};
|
||||||
|
|
||||||
|
my $ud = $3;
|
||||||
|
$ud =~ m/^update\s+(\w+).+(where.+)$/i;
|
||||||
|
$Param->{Query} ="EXPLAIN SELECT * FROM $1 $2";
|
||||||
|
$Param->{Query} =~ s/from\s/from $Param->{DB}./i;
|
||||||
|
|
||||||
|
#$Param->{Query} =~ m/from\s+(\w+[.]\w+)/i;
|
||||||
|
#$Param->{tab} =$1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Statistics\s+(.*)$/i) { # get connection ID($2) and info?
|
||||||
|
$Param->{Statistics} ++;
|
||||||
|
#print "Statistics--$1--$2--$3------\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
}
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Query\s+(.+)$/i) { # get connection ID($2)
|
||||||
|
$Param->{QueryCount} ++;
|
||||||
|
#print "Query-NULL $3\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
}
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Refresh\s+(.+)$/i) { # get connection ID($2)
|
||||||
|
$Param->{Refresh} ++;
|
||||||
|
#print "Refresh\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
}
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Init\s+(.+)$/i) { # get connection ID($2)
|
||||||
|
$Param->{Init} ++;
|
||||||
|
#print "Init $3\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
}
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Field\s+(.+)$/i) { # get connection ID($2)
|
||||||
|
$Param->{Field} ++;
|
||||||
|
#print "Field $3\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
}
|
||||||
|
|
||||||
|
elsif (m/^\s+(.+)$/ ) { # command could be some lines ...
|
||||||
|
#print "multi-lined ($1)\n";
|
||||||
|
my ($A)=$1;
|
||||||
|
chomp $A;
|
||||||
|
$Param->{Query} .= " $1";
|
||||||
|
#print "multi-lined ($1)<<$Param->{Query}>>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$Param->{dbh}->disconnect();
|
||||||
|
|
||||||
|
if (1 == 0) {
|
||||||
|
print "\nunclosed handles----------------------------------------\n";
|
||||||
|
my $count=0;
|
||||||
|
foreach (sort keys %{$Param->{CID}}) {
|
||||||
|
print "$count | $_ : $Param->{CID}->{$_} \n";
|
||||||
|
$count ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print "\nIndex usage ------------------------------------\n";
|
||||||
|
foreach my $t (sort keys %{$Param->{Data}}) {
|
||||||
|
print "\nTable\t$t: ---\n";
|
||||||
|
foreach my $k (sort keys %{$Param->{Data}->{$t}}) {
|
||||||
|
print " count\t$k:\n";
|
||||||
|
my %h = %{$Param->{Data}->{$t}->{$k}};
|
||||||
|
foreach (sort {$h{$a} <=> $h{$b}} keys %h) {
|
||||||
|
print " $Param->{Data}->{$t}->{$k}->{$_}\t$_\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$Param->{AllCount}=0;
|
||||||
|
print "\nQueries causing table scans -------------------\n\n";
|
||||||
|
foreach (@{$Param->{ALL}}) {
|
||||||
|
$Param->{AllCount} ++;
|
||||||
|
print "$_\n";
|
||||||
|
}
|
||||||
|
print "Sum: $Param->{AllCount} table scans\n";
|
||||||
|
|
||||||
|
print "\nSummary ---------------------------------------\n\n";
|
||||||
|
print "Select: \t$Param->{SelectCount} queries\n";
|
||||||
|
print "Update: \t$Param->{UpdateCount} queries\n";
|
||||||
|
print "\n";
|
||||||
|
|
||||||
|
print "Init: \t$Param->{Init} times\n";
|
||||||
|
print "Field: \t$Param->{Field} times\n";
|
||||||
|
print "Refresh: \t$Param->{Refresh} times\n";
|
||||||
|
print "Query: \t$Param->{QueryCount} times\n";
|
||||||
|
print "Statistics:\t$Param->{Statistics} times\n";
|
||||||
|
print "\n";
|
||||||
|
|
||||||
|
print "Logfile: \t$Param->{LineCount} lines\n";
|
||||||
|
print "Started: \t".localtime($Param->{Start})."\n";
|
||||||
|
print "Finished: \t".localtime(time)."\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
sub RunQuery {
|
||||||
|
my $Param = shift ;
|
||||||
|
|
||||||
|
if (defined $Param->{Query}) {
|
||||||
|
if (defined $Param->{DB} ) {
|
||||||
|
|
||||||
|
$Param->{Query} =~ m/from\s+(\w+[.]\w+|\w+)/i;
|
||||||
|
$Param->{tab} =$1;
|
||||||
|
#print "||$Param->{tab} -- $Param->{Query}\n";
|
||||||
|
|
||||||
|
my $sth=$Param->{dbh}->prepare("USE $Param->{DB}");
|
||||||
|
if (DBI::err()) {
|
||||||
|
if ($Param->{PrintError}) {print "Error: ".DBI::errstr()."\n";}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sth->execute();
|
||||||
|
if (DBI::err()) {
|
||||||
|
if ($Param->{PrintError}) {print "Error: ".DBI::errstr()."\n";}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sth->finish();
|
||||||
|
|
||||||
|
$sth=$Param->{dbh}->prepare($Param->{Query});
|
||||||
|
if (DBI::err()) {
|
||||||
|
if ($Param->{PrintError}) {print "Error: ".DBI::errstr()."\n";}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#print "$Param->{Query}\n";
|
||||||
|
$sth->execute();
|
||||||
|
if (DBI::err()) {
|
||||||
|
if ($Param->{PrintError}) {print "[$Param->{LineCount}]<<$Param->{Query}>>\n";}
|
||||||
|
if ($Param->{PrintError}) {print "Error: ".DBI::errstr()."\n";}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
my $row = undef;
|
||||||
|
while ($row = $sth->fetchrow_hashref()) {
|
||||||
|
$Param->{SelectCount} ++;
|
||||||
|
|
||||||
|
if (defined $row->{Comment}) {
|
||||||
|
push (@{$Param->{Comment}}, "$row->{Comment}; $_; $Param->{DB}; $Param->{Query}");
|
||||||
|
}
|
||||||
|
foreach (@{$Param->{Rows}}) {
|
||||||
|
if (defined $row->{$_}) {
|
||||||
|
#if (($_ eq 'type' ) and ($row->{$_} eq 'ALL')) {
|
||||||
|
if ($row->{type} eq 'ALL') {
|
||||||
|
push (@{$Param->{ALL}}, "$row->{$_} $_ $Param->{DB} $Param->{Query}");
|
||||||
|
#print ">> $row->{$_} $_ $Param->{DB} $Param->{Query}\n";
|
||||||
|
}
|
||||||
|
$Param->{IdxUseCount} ++;
|
||||||
|
$Param->{Data}->{$Param->{tab}}->{$_}->{$row->{$_}} ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$sth->finish();
|
||||||
|
}
|
||||||
|
$Param->{Query} = undef ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
sub ShowOptions {
|
||||||
|
print <<EOF;
|
||||||
|
Usage: $0 [OPTIONS] < LOGFILE
|
||||||
|
|
||||||
|
--date=YYMMDD select only entrys of date
|
||||||
|
-d=YYMMDD
|
||||||
|
--host=HOSTNAME db-host to ask
|
||||||
|
-h=HOSTNAME
|
||||||
|
--user=USERNAME db-user
|
||||||
|
-u=USERNAME
|
||||||
|
--password=PASSWORD password of db-user
|
||||||
|
-p=PASSWORD
|
||||||
|
|
||||||
|
Read logfile from STDIN an try to EXPLAIN all SELECT statements. All UPDATE statements are rewritten to an EXPLAIN SELECT statement. The results of the EXPLAIN statement are collected and counted. All results with type=ALL are collected in an separete list. Results are printed to STDOUT.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=pod
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
explain_log.pl
|
||||||
|
|
||||||
|
Feed a mysqld general logfile (created with mysqld --log) back into mysql
|
||||||
|
and collect statistics about index usage with EXPLAIN.
|
||||||
|
|
||||||
|
=head1 DISCUSSION
|
||||||
|
|
||||||
|
To optimize your indices, you have to know which ones are actually
|
||||||
|
used and what kind of queries are causing table scans. Especially
|
||||||
|
if you are generating your queries dynamically and you have a huge
|
||||||
|
amount of queries going on, this isn't easy.
|
||||||
|
|
||||||
|
Use this tool to take a look at the effects of your real life queries.
|
||||||
|
Then add indices to avoid table scans and remove those which aren't used.
|
||||||
|
|
||||||
|
=head1 USAGE
|
||||||
|
|
||||||
|
explain_log.pl [--date=YYMMDD] --host=dbhost] [--user=dbuser] [--password=dbpw] < logfile
|
||||||
|
|
||||||
|
--date=YYMMDD select only entrys of date
|
||||||
|
|
||||||
|
-d=YYMMDD
|
||||||
|
|
||||||
|
--host=HOSTNAME db-host to ask
|
||||||
|
|
||||||
|
-h=HOSTNAME
|
||||||
|
|
||||||
|
--user=USERNAME db-user
|
||||||
|
|
||||||
|
-u=USERNAME
|
||||||
|
|
||||||
|
--password=PASSWORD password of db-user
|
||||||
|
|
||||||
|
-p=PASSWORD
|
||||||
|
|
||||||
|
=head1 EXAMPLE
|
||||||
|
|
||||||
|
explain_log.pl --host=localhost --user=foo --password=bar < /var/lib/mysql/mobile.log
|
||||||
|
|
||||||
|
=head1 AUTHOR
|
||||||
|
|
||||||
|
Stefan Nitz
|
||||||
|
Jan Willamowius <jan@mobile.de>, http://www.mobile.de
|
||||||
|
|
||||||
|
=head1 RECRUITING
|
||||||
|
|
||||||
|
If you are looking for a MySQL or Perl job, take a look at http://www.mobile.de
|
||||||
|
and send me an email with your resume (you must be speaking German!).
|
||||||
|
|
||||||
|
=head1 SEE ALSO
|
||||||
|
|
||||||
|
mysql documentation
|
||||||
|
|
||||||
|
=cut
|
@ -31,6 +31,7 @@ client_libs='@CLIENT_LIBS@'
|
|||||||
|
|
||||||
libs="$ldflags -L'$pkglibdir' -lmysqlclient $client_libs"
|
libs="$ldflags -L'$pkglibdir' -lmysqlclient $client_libs"
|
||||||
cflags="-I'$pkgincludedir'"
|
cflags="-I'$pkgincludedir'"
|
||||||
|
embedded_libs="$ldflags -L'$pkglibdir' -lmysqld @LIBS@ @innodb_system_libs@"
|
||||||
|
|
||||||
usage () {
|
usage () {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
@ -41,6 +42,7 @@ Options:
|
|||||||
--socket [$socket]
|
--socket [$socket]
|
||||||
--port [$port]
|
--port [$port]
|
||||||
--version [$version]
|
--version [$version]
|
||||||
|
--libmysqld-libs [$embedded_libs]
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@ -54,6 +56,7 @@ while test $# -gt 0; do
|
|||||||
--socket) echo "$socket" ;;
|
--socket) echo "$socket" ;;
|
||||||
--port) echo "$port" ;;
|
--port) echo "$port" ;;
|
||||||
--version) echo "$version" ;;
|
--version) echo "$version" ;;
|
||||||
|
--embedded-libs | --embedded | libmysqld-libs) echo "$embedded_libs" ;;
|
||||||
*) usage ;;
|
*) usage ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
383
scripts/mysql_explain_log.sh
Normal file
383
scripts/mysql_explain_log.sh
Normal file
@ -0,0 +1,383 @@
|
|||||||
|
#!@PERL@ -w
|
||||||
|
use strict;
|
||||||
|
use DBI;
|
||||||
|
|
||||||
|
use Getopt::Long;
|
||||||
|
$Getopt::Long::ignorecase=0;
|
||||||
|
|
||||||
|
print "explain_log provided by http://www.mobile.de\n";
|
||||||
|
print "=========== ================================\n";
|
||||||
|
|
||||||
|
my $Param={};
|
||||||
|
|
||||||
|
$Param->{host}='';
|
||||||
|
$Param->{user}='';
|
||||||
|
$Param->{password}='';
|
||||||
|
$Param->{PrintError}=0;
|
||||||
|
|
||||||
|
if (!GetOptions ('date|d:i' => \$Param->{ViewDate},
|
||||||
|
'host|h:s' => \$Param->{host},
|
||||||
|
'user|u:s' => \$Param->{user},
|
||||||
|
'password|p:s' => \$Param->{password},
|
||||||
|
'printerror|e:s' => \$Param->{PrintError},
|
||||||
|
)) {
|
||||||
|
ShowOptions();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$Param->{UpdateCount} = 0;
|
||||||
|
$Param->{SelectCount} = 0;
|
||||||
|
$Param->{IdxUseCount} = 0;
|
||||||
|
$Param->{LineCount} = 0;
|
||||||
|
|
||||||
|
$Param->{Init} = 0;
|
||||||
|
$Param->{Field} = 0;
|
||||||
|
$Param->{Refresh} = 0;
|
||||||
|
$Param->{QueryCount} = 0;
|
||||||
|
$Param->{Statistics} =0;
|
||||||
|
|
||||||
|
$Param->{Query} = undef;
|
||||||
|
$Param->{ALL} = undef ;
|
||||||
|
$Param->{Comment} = undef ;
|
||||||
|
|
||||||
|
@{$Param->{Rows}} = (qw|possible_keys key type|);
|
||||||
|
|
||||||
|
if ($Param->{ViewDate}) {
|
||||||
|
$Param->{View} = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$Param->{View} = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#print "Date=$Param->{ViewDate}, host=$Param->{host}, user=$Param->{user}, password=$Param->{password}\n";
|
||||||
|
|
||||||
|
$Param->{dbh}=DBI->connect("DBI:mysql:host=$Param->{host}",$Param->{user},$Param->{password},{PrintError=>0});
|
||||||
|
if (DBI::err()) {
|
||||||
|
print "Error: " . DBI::errstr() . "\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$Param->{Start} = time;
|
||||||
|
while(<STDIN>) {
|
||||||
|
$Param->{LineCount} ++ ;
|
||||||
|
|
||||||
|
if ($Param->{ViewDate} ) {
|
||||||
|
if (m/^(\d{6})\s+\d{1,2}:\d\d:\d\d\s.*$/) { # get date
|
||||||
|
#print "# $1 #\n";
|
||||||
|
if ($1 == $Param->{ViewDate}) {
|
||||||
|
$Param->{View} = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$Param->{View} = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($Param->{View} ) {
|
||||||
|
#print "->>>$_";
|
||||||
|
|
||||||
|
if (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Connect.+\s+on\s+(.*)$/i) { # get connection ID($2) and database($3)
|
||||||
|
#print "C-$1--$2--$3------\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
if (defined $3) {
|
||||||
|
$Param->{CID}->{$2} = $3 ;
|
||||||
|
#print "DB:$Param->{CID}->{$2} .. $2 .. $3 \n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Connect.+$/i) { # get connection ID($2) and database($3)
|
||||||
|
#print "\n <<<<<<<<<<<<<<<<<<----------------------------<<<<<<<<<<<<<<<< \n";
|
||||||
|
#print "Connect \n";
|
||||||
|
RunQuery($Param);
|
||||||
|
}
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Change user .*\s+on\s+(.*)$/i) { # get connection ID($2) and database($3)
|
||||||
|
#print "C-$1--$2--$3------\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
if (defined $3) {
|
||||||
|
$Param->{CID}->{$2} = $3 ;
|
||||||
|
#print "DB:$Param->{CID}->{$2} .. $2 .. $3 \n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Quit\s+$/i) { # remove connection ID($2) and querystring
|
||||||
|
#print "Q-$1--$2--------\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
delete $Param->{CID}->{$2} ;
|
||||||
|
}
|
||||||
|
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Query\s+(select.+)$/i) { # get connection ID($2) and querystring
|
||||||
|
#print "S1-$1--$2--$3------\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
unless ($Param->{CID}->{$2}) {
|
||||||
|
#print "Error: No Database for Handle: $2 found\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$Param->{DB}=$Param->{CID}->{$2};
|
||||||
|
|
||||||
|
my $s = "$3";
|
||||||
|
$s =~ s/from\s/from $Param->{DB}./i;
|
||||||
|
$Param->{Query}="EXPLAIN $s";
|
||||||
|
|
||||||
|
#$s =~ m/from\s+(\w+[.]\w+)/i;
|
||||||
|
#$Param->{tab} =$1;
|
||||||
|
#print "-- $Param->{tab} -- $s --\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Query\s+(update.+)$/i) { # get connection ID($2) and querystring
|
||||||
|
#print "S2--$1--$2--$3------\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
unless ($Param->{CID}->{$2}) {
|
||||||
|
#print "Error: No Database for Handle: $2 found\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$Param->{DB}=$Param->{CID}->{$2};
|
||||||
|
|
||||||
|
my $ud = $3;
|
||||||
|
$ud =~ m/^update\s+(\w+).+(where.+)$/i;
|
||||||
|
$Param->{Query} ="EXPLAIN SELECT * FROM $1 $2";
|
||||||
|
$Param->{Query} =~ s/from\s/from $Param->{DB}./i;
|
||||||
|
|
||||||
|
#$Param->{Query} =~ m/from\s+(\w+[.]\w+)/i;
|
||||||
|
#$Param->{tab} =$1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Statistics\s+(.*)$/i) { # get connection ID($2) and info?
|
||||||
|
$Param->{Statistics} ++;
|
||||||
|
#print "Statistics--$1--$2--$3------\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
}
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Query\s+(.+)$/i) { # get connection ID($2)
|
||||||
|
$Param->{QueryCount} ++;
|
||||||
|
#print "Query-NULL $3\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
}
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Refresh\s+(.+)$/i) { # get connection ID($2)
|
||||||
|
$Param->{Refresh} ++;
|
||||||
|
#print "Refresh\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
}
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Init\s+(.+)$/i) { # get connection ID($2)
|
||||||
|
$Param->{Init} ++;
|
||||||
|
#print "Init $3\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
}
|
||||||
|
elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Field\s+(.+)$/i) { # get connection ID($2)
|
||||||
|
$Param->{Field} ++;
|
||||||
|
#print "Field $3\n";
|
||||||
|
RunQuery($Param);
|
||||||
|
}
|
||||||
|
|
||||||
|
elsif (m/^\s+(.+)$/ ) { # command could be some lines ...
|
||||||
|
#print "multi-lined ($1)\n";
|
||||||
|
my ($A)=$1;
|
||||||
|
chomp $A;
|
||||||
|
$Param->{Query} .= " $1";
|
||||||
|
#print "multi-lined ($1)<<$Param->{Query}>>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$Param->{dbh}->disconnect();
|
||||||
|
|
||||||
|
if (1 == 0) {
|
||||||
|
print "\nunclosed handles----------------------------------------\n";
|
||||||
|
my $count=0;
|
||||||
|
foreach (sort keys %{$Param->{CID}}) {
|
||||||
|
print "$count | $_ : $Param->{CID}->{$_} \n";
|
||||||
|
$count ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print "\nIndex usage ------------------------------------\n";
|
||||||
|
foreach my $t (sort keys %{$Param->{Data}}) {
|
||||||
|
print "\nTable\t$t: ---\n";
|
||||||
|
foreach my $k (sort keys %{$Param->{Data}->{$t}}) {
|
||||||
|
print " count\t$k:\n";
|
||||||
|
my %h = %{$Param->{Data}->{$t}->{$k}};
|
||||||
|
foreach (sort {$h{$a} <=> $h{$b}} keys %h) {
|
||||||
|
print " $Param->{Data}->{$t}->{$k}->{$_}\t$_\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$Param->{AllCount}=0;
|
||||||
|
print "\nQueries causing table scans -------------------\n\n";
|
||||||
|
foreach (@{$Param->{ALL}}) {
|
||||||
|
$Param->{AllCount} ++;
|
||||||
|
print "$_\n";
|
||||||
|
}
|
||||||
|
print "Sum: $Param->{AllCount} table scans\n";
|
||||||
|
|
||||||
|
print "\nSummary ---------------------------------------\n\n";
|
||||||
|
print "Select: \t$Param->{SelectCount} queries\n";
|
||||||
|
print "Update: \t$Param->{UpdateCount} queries\n";
|
||||||
|
print "\n";
|
||||||
|
|
||||||
|
print "Init: \t$Param->{Init} times\n";
|
||||||
|
print "Field: \t$Param->{Field} times\n";
|
||||||
|
print "Refresh: \t$Param->{Refresh} times\n";
|
||||||
|
print "Query: \t$Param->{QueryCount} times\n";
|
||||||
|
print "Statistics:\t$Param->{Statistics} times\n";
|
||||||
|
print "\n";
|
||||||
|
|
||||||
|
print "Logfile: \t$Param->{LineCount} lines\n";
|
||||||
|
print "Started: \t".localtime($Param->{Start})."\n";
|
||||||
|
print "Finished: \t".localtime(time)."\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
sub RunQuery {
|
||||||
|
my $Param = shift ;
|
||||||
|
|
||||||
|
if (defined $Param->{Query}) {
|
||||||
|
if (defined $Param->{DB} ) {
|
||||||
|
|
||||||
|
$Param->{Query} =~ m/from\s+(\w+[.]\w+|\w+)/i;
|
||||||
|
$Param->{tab} =$1;
|
||||||
|
#print "||$Param->{tab} -- $Param->{Query}\n";
|
||||||
|
|
||||||
|
my $sth=$Param->{dbh}->prepare("USE $Param->{DB}");
|
||||||
|
if (DBI::err()) {
|
||||||
|
if ($Param->{PrintError}) {print "Error: ".DBI::errstr()."\n";}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sth->execute();
|
||||||
|
if (DBI::err()) {
|
||||||
|
if ($Param->{PrintError}) {print "Error: ".DBI::errstr()."\n";}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sth->finish();
|
||||||
|
|
||||||
|
$sth=$Param->{dbh}->prepare($Param->{Query});
|
||||||
|
if (DBI::err()) {
|
||||||
|
if ($Param->{PrintError}) {print "Error: ".DBI::errstr()."\n";}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#print "$Param->{Query}\n";
|
||||||
|
$sth->execute();
|
||||||
|
if (DBI::err()) {
|
||||||
|
if ($Param->{PrintError}) {print "[$Param->{LineCount}]<<$Param->{Query}>>\n";}
|
||||||
|
if ($Param->{PrintError}) {print "Error: ".DBI::errstr()."\n";}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
my $row = undef;
|
||||||
|
while ($row = $sth->fetchrow_hashref()) {
|
||||||
|
$Param->{SelectCount} ++;
|
||||||
|
|
||||||
|
if (defined $row->{Comment}) {
|
||||||
|
push (@{$Param->{Comment}}, "$row->{Comment}; $_; $Param->{DB}; $Param->{Query}");
|
||||||
|
}
|
||||||
|
foreach (@{$Param->{Rows}}) {
|
||||||
|
if (defined $row->{$_}) {
|
||||||
|
#if (($_ eq 'type' ) and ($row->{$_} eq 'ALL')) {
|
||||||
|
if ($row->{type} eq 'ALL') {
|
||||||
|
push (@{$Param->{ALL}}, "$row->{$_} $_ $Param->{DB} $Param->{Query}");
|
||||||
|
#print ">> $row->{$_} $_ $Param->{DB} $Param->{Query}\n";
|
||||||
|
}
|
||||||
|
$Param->{IdxUseCount} ++;
|
||||||
|
$Param->{Data}->{$Param->{tab}}->{$_}->{$row->{$_}} ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$sth->finish();
|
||||||
|
}
|
||||||
|
$Param->{Query} = undef ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
sub ShowOptions {
|
||||||
|
print <<EOF;
|
||||||
|
Usage: $0 [OPTIONS] < LOGFILE
|
||||||
|
|
||||||
|
--date=YYMMDD select only entrys of date
|
||||||
|
-d=YYMMDD
|
||||||
|
--host=HOSTNAME db-host to ask
|
||||||
|
-h=HOSTNAME
|
||||||
|
--user=USERNAME db-user
|
||||||
|
-u=USERNAME
|
||||||
|
--password=PASSWORD password of db-user
|
||||||
|
-p=PASSWORD
|
||||||
|
|
||||||
|
Read logfile from STDIN an try to EXPLAIN all SELECT statements. All UPDATE statements are rewritten to an EXPLAIN SELECT statement. The results of the EXPLAIN statement are collected and counted. All results with type=ALL are collected in an separete list. Results are printed to STDOUT.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=pod
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
explain_log.pl
|
||||||
|
|
||||||
|
Feed a mysqld general logfile (created with mysqld --log) back into mysql
|
||||||
|
and collect statistics about index usage with EXPLAIN.
|
||||||
|
|
||||||
|
=head1 DISCUSSION
|
||||||
|
|
||||||
|
To optimize your indices, you have to know which ones are actually
|
||||||
|
used and what kind of queries are causing table scans. Especially
|
||||||
|
if you are generating your queries dynamically and you have a huge
|
||||||
|
amount of queries going on, this isn't easy.
|
||||||
|
|
||||||
|
Use this tool to take a look at the effects of your real life queries.
|
||||||
|
Then add indices to avoid table scans and remove those which aren't used.
|
||||||
|
|
||||||
|
=head1 USAGE
|
||||||
|
|
||||||
|
explain_log.pl [--date=YYMMDD] --host=dbhost] [--user=dbuser] [--password=dbpw] < logfile
|
||||||
|
|
||||||
|
--date=YYMMDD select only entrys of date
|
||||||
|
|
||||||
|
-d=YYMMDD
|
||||||
|
|
||||||
|
--host=HOSTNAME db-host to ask
|
||||||
|
|
||||||
|
-h=HOSTNAME
|
||||||
|
|
||||||
|
--user=USERNAME db-user
|
||||||
|
|
||||||
|
-u=USERNAME
|
||||||
|
|
||||||
|
--password=PASSWORD password of db-user
|
||||||
|
|
||||||
|
-p=PASSWORD
|
||||||
|
|
||||||
|
=head1 EXAMPLE
|
||||||
|
|
||||||
|
explain_log.pl --host=localhost --user=foo --password=bar < /var/lib/mysql/mobile.log
|
||||||
|
|
||||||
|
=head1 AUTHOR
|
||||||
|
|
||||||
|
Stefan Nitz
|
||||||
|
Jan Willamowius <jan@mobile.de>, http://www.mobile.de
|
||||||
|
|
||||||
|
=head1 RECRUITING
|
||||||
|
|
||||||
|
If you are looking for a MySQL or Perl job, take a look at http://www.mobile.de
|
||||||
|
and send me an email with your resume (you must be speaking German!).
|
||||||
|
|
||||||
|
=head1 SEE ALSO
|
||||||
|
|
||||||
|
mysql documentation
|
||||||
|
|
||||||
|
=cut
|
@ -43,7 +43,7 @@ LDADD = ../isam/libnisam.a \
|
|||||||
|
|
||||||
mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \
|
mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \
|
||||||
@bdb_libs@ @innodb_libs@ @pstack_libs@ \
|
@bdb_libs@ @innodb_libs@ @pstack_libs@ \
|
||||||
@gemini_libs@ \
|
@gemini_libs@ @innodb_system_libs@ \
|
||||||
$(LDADD) $(CXXLDFLAGS) $(WRAPLIBS) @LIBDL@ @openssl_libs@
|
$(LDADD) $(CXXLDFLAGS) $(WRAPLIBS) @LIBDL@ @openssl_libs@
|
||||||
noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
|
noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
|
||||||
item_strfunc.h item_timefunc.h item_uniq.h \
|
item_strfunc.h item_timefunc.h item_uniq.h \
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user