client/Makefile.am:
  Auto merged
include/my_sys.h:
  Auto merged
include/mysql.h:
  Auto merged
include/mysql_com.h:
  Auto merged
libmysql/libmysql.c:
  Auto merged
mysql-test/mysql-test-run.sh:
  Auto merged
mysql-test/r/type_ranges.result:
  Auto merged
sql/lex.h:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
This commit is contained in:
unknown 2001-10-03 14:21:16 -06:00
commit 7968bc7f66
168 changed files with 2452 additions and 1848 deletions

View file

@ -8,6 +8,6 @@ c_warnings="$c_warnings $debug_extra_warnings"
cxx_warnings="$cxx_warnings $debug_extra_warnings" cxx_warnings="$cxx_warnings $debug_extra_warnings"
extra_configs="$pentium_configs $debug_configs" extra_configs="$pentium_configs $debug_configs"
extra_configs="$extra_configs --with-berkeley-db --with-innodb --with-vio --with-openssl --with-embedded-server" extra_configs="$extra_configs --with-berkeley-db --with-innodb --with-embedded-server"
. "$path/FINISH.sh" . "$path/FINISH.sh"

View file

@ -8,6 +8,6 @@ extra_configs="$pentium_configs"
strip=yes strip=yes
extra_configs="$extra_configs --with-innodb --with-berkeley-db \ extra_configs="$extra_configs --with-innodb --with-berkeley-db \
--enable-thread-safe-client" --enable-thread-safe-client --with-openssl --with-vio"
. "$path/FINISH.sh" . "$path/FINISH.sh"

View file

@ -1,3 +1,5 @@
Administrator@fred.
Miguel@light.local
Sinisa@sinisa.nasamreza.org Sinisa@sinisa.nasamreza.org
davida@isil.mysql.com davida@isil.mysql.com
heikki@donna.mysql.fi heikki@donna.mysql.fi
@ -26,6 +28,6 @@ tim@threads.polyesthetic.msg
tim@white.box tim@white.box
tim@work.mysql.com tim@work.mysql.com
tonu@hundin.mysql.fi tonu@hundin.mysql.fi
tonu@volk.internalnet
tonu@x153.internalnet tonu@x153.internalnet
tonu@x3.internalnet tonu@x3.internalnet
tonu@volk.internalnet

View file

@ -4,10 +4,10 @@ use Getopt::Long;
$opt_distribution=$opt_user=$opt_result=$opt_config_options=$opt_config_env=""; $opt_distribution=$opt_user=$opt_result=$opt_config_options=$opt_config_env="";
$opt_dbd_options=$opt_perl_options=$opt_suffix=""; $opt_dbd_options=$opt_perl_options=$opt_suffix="";
$opt_tmp=$version_suffix=""; $opt_tmp=$version_suffix="";
$opt_help=$opt_Information=$opt_no_delete=$opt_delete=$opt_debug=$opt_stage=$opt_rsh_mail=$opt_no_test=$opt_no_perl=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_no_mysqltest=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=0; $opt_help=$opt_Information=$opt_delete=$opt_debug=$opt_stage=$opt_rsh_mail=$opt_no_test=$opt_no_perl=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_no_mysqltest=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=0;
$opt_innodb=$opt_bdb=0; $opt_innodb=$opt_bdb=0;
GetOptions("Information","help","distribution=s","user=s","result=s","no-delete","delete","no-test","no-mysqltest","perl-files=s","debug","config-options=s","config-env=s","stage=i","rsh-mail","with-low-memory","fast-benchmark","tmp=s","static-client","static-server","static-perl","no-perl","local-perl","perl-options=s","sur","with-small-disk","dbd-options=s","tcpip","suffix=s","build-thread=i","innodb","bdb","use-old-distribution","enable-shared","no-crash-me","no-strip") || usage(); GetOptions("Information","help","distribution=s","user=s","result=s","delete","no-test","no-mysqltest","perl-files=s","debug","config-options=s","config-env=s","stage=i","rsh-mail","with-low-memory","fast-benchmark","tmp=s","static-client","static-server","static-perl","no-perl","local-perl","perl-options=s","sur","with-small-disk","dbd-options=s","tcpip","suffix=s","build-thread=i","innodb","bdb","use-old-distribution","enable-shared","no-crash-me","no-strip") || usage();
usage() if ($opt_help || $opt_Information); usage() if ($opt_help || $opt_Information);
usage() if (!$opt_distribution); usage() if (!$opt_distribution);
@ -113,6 +113,8 @@ if ($opt_stage <= 1)
$opt_config_options.=" --with-low-memory" if ($opt_with_low_memory); $opt_config_options.=" --with-low-memory" if ($opt_with_low_memory);
# Fix files if this is in another timezone than work.mysql.com # Fix files if this is in another timezone than work.mysql.com
unlink("config.cache"); unlink("config.cache");
unlink("bdb/build_unix/config.cache");
unlink("innobase/config.cache");
log_system("$make clean") if ($opt_use_old_distribution); log_system("$make clean") if ($opt_use_old_distribution);
if ($opt_static_server) if ($opt_static_server)
{ {
@ -143,7 +145,7 @@ if ($opt_stage <= 1)
if ($opt_stage <= 2) if ($opt_stage <= 2)
{ {
unlink($opt_distribution) if (!$opt_delete && !$opt_use_old_distribution); unlink($opt_distribution) if ($opt_delete && !$opt_use_old_distribution);
safe_system("$make"); safe_system("$make");
} }

View file

@ -210,7 +210,7 @@ if [ $? != 0 ]; then
tail $log tail $log
fi fi
if [ ! x$local_build=x1 ]; then if [ x$local_build != x1 ]; then
# Build perl RPM (we currently need to be root to do this and that is # Build perl RPM (we currently need to be root to do this and that is
# not possible) # not possible)
@ -228,5 +228,3 @@ if [ ! x$local_build=x1 ]; then
#scp $owner@$bmachine:$rpmdir/SRPMS/Perl*-*.rpm $bpath/NEW-RPMS #scp $owner@$bmachine:$rpmdir/SRPMS/Perl*-*.rpm $bpath/NEW-RPMS
fi fi
) > $log 2>&1 ) > $log 2>&1

Binary file not shown.

0
Docs/Flags/belgium.gif Executable file → Normal file
View file

Before

Width:  |  Height:  |  Size: 181 B

After

Width:  |  Height:  |  Size: 181 B

BIN
Docs/Flags/mexico.eps Executable file → Normal file

Binary file not shown.

0
Docs/Flags/mexico.gif Executable file → Normal file
View file

Before

Width:  |  Height:  |  Size: 269 B

After

Width:  |  Height:  |  Size: 269 B

BIN
Docs/Flags/philippines.eps Executable file → Normal file

Binary file not shown.

0
Docs/Flags/philippines.gif Executable file → Normal file
View file

Before

Width:  |  Height:  |  Size: 306 B

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

0
Docs/Flags/turkey.gif Executable file → Normal file
View file

Before

Width:  |  Height:  |  Size: 169 B

After

Width:  |  Height:  |  Size: 169 B

View file

@ -3187,7 +3187,7 @@ encounter per year, but we are as always very flexible towards our customers!
@c @image{Flags/estonia} Estonia [Tradenet] @ @c @image{Flags/estonia} Estonia [Tradenet] @
@c @uref{http://mysql.tradenet.ee, WWW} @c @uref{http://mysql.tradenet.ee, WWW}
@item @item
@c EMAIL: tonu@spamm.ee (Tonu Samuel) @c EMAIL: tonu@spam.ee (Tonu Samuel)
@image{Flags/estonia} Estonia [OKinteractive] @ @image{Flags/estonia} Estonia [OKinteractive] @
@uref{http://mysql.mirror.ok.ee, WWW} @uref{http://mysql.mirror.ok.ee, WWW}
@item @item

File diff suppressed because it is too large Load diff

View file

@ -715,6 +715,8 @@ AC_MSG_CHECKING(for OpenSSL)
[openssl="$withval"], [openssl="$withval"],
[openssl=no]) [openssl=no])
openssl_libs=""
openssl_includes=""
if test "$openssl" = "yes" if test "$openssl" = "yes"
then then
if test -n "$vio_dir" if test -n "$vio_dir"
@ -722,14 +724,12 @@ AC_MSG_CHECKING(for OpenSSL)
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)
openssl_libs="-L/usr/local/ssl/lib -lssl -lcrypto" openssl_libs="-L/usr/local/ssl/lib -lssl -lcrypto"
openssl_includes="-I/usr/local/ssl/include" openssl_includes="-I/usr/local/ssl/include"
else
AC_MSG_ERROR([OpenSSL requires Virtual IO support (--with-vio)])
fi
AC_DEFINE(HAVE_OPENSSL) AC_DEFINE(HAVE_OPENSSL)
else
AC_MSG_RESULT(disabled because --with-vio wasn not used)
fi
else else
AC_MSG_RESULT(no) AC_MSG_RESULT(no)
openssl_libs=""
openssl_includes=""
fi fi
NON_THREADED_CLIENT_LIBS="$NON_THREADED_CLIENT_LIBS $openssl_libs" NON_THREADED_CLIENT_LIBS="$NON_THREADED_CLIENT_LIBS $openssl_libs"
AC_SUBST(openssl_libs) AC_SUBST(openssl_libs)
@ -748,23 +748,27 @@ dnl Call MYSQL_CHECK_ORBIT even if mysqlfs == no, so that @orbit_*@
dnl get substituted. dnl get substituted.
MYSQL_CHECK_ORBIT MYSQL_CHECK_ORBIT
AC_MSG_CHECKING(if we should build MySQLFS)
fs_dirs=""
if test "$mysqlfs" = "yes" if test "$mysqlfs" = "yes"
then then
if test -n "$orbit_exec_prefix" if test -n "$orbit_exec_prefix"
then then
fs_dirs=fs fs_dirs=fs
AC_MSG_RESULT([yes])
else else
AC_MSG_ERROR([mysqlfs requires ORBit, the CORBA ORB]) AC_MSG_RESULT(disabled because ORBIT, the CORBA ORB, was not found)
fi fi
else else
fs_dirs= AC_MSG_RESULT([no])
fi fi
AC_SUBST([fs_dirs]) AC_SUBST([fs_dirs])
]) ])
AC_DEFUN(MYSQL_CHECK_ORBIT, [ AC_DEFUN(MYSQL_CHECK_ORBIT, [
AC_MSG_CHECKING(for ORBit) AC_MSG_CHECKING(for ORBit)
if test `which orbit-config` orbit_config_path=`which orbit-config`
if test -n "$orbit_config_path"
then then
orbit_exec_prefix=`orbit-config --exec-prefix` orbit_exec_prefix=`orbit-config --exec-prefix`
orbit_includes=`orbit-config --cflags server` orbit_includes=`orbit-config --cflags server`
@ -1051,9 +1055,9 @@ dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_CHECK_INNODB], [ AC_DEFUN([MYSQL_CHECK_INNODB], [
AC_ARG_WITH([innodb], AC_ARG_WITH([innodb],
[\ [\
--with-innodb Use Innodb], --without-innodb Do not include the InnoDB table handler],
[innodb="$withval"], [innodb="$withval"],
[innodb=no]) [innodb=yes])
AC_MSG_CHECKING([for Innodb]) AC_MSG_CHECKING([for Innodb])
@ -1248,7 +1252,7 @@ changequote([, ])dnl
AC_DEFUN(AC_SYS_LARGEFILE, AC_DEFUN(AC_SYS_LARGEFILE,
[AC_REQUIRE([AC_CANONICAL_HOST]) [AC_REQUIRE([AC_CANONICAL_HOST])
AC_ARG_ENABLE(largefile, AC_ARG_ENABLE(largefile,
[ --disable-large-files Omit support for large files]) [ --disable-largefile Omit support for large files])
if test "$enable_largefile" != no; then if test "$enable_largefile" != no; then
AC_CHECK_TOOL(GETCONF, getconf) AC_CHECK_TOOL(GETCONF, getconf)
AC_SYS_LARGEFILE_FLAGS(CFLAGS) AC_SYS_LARGEFILE_FLAGS(CFLAGS)

View file

@ -24,6 +24,7 @@
* Jani Tolonen <jani@mysql.com> * Jani Tolonen <jani@mysql.com>
* Matt Wagner <mwagner@mysql.com> * Matt Wagner <mwagner@mysql.com>
* Jeremy Cole <jcole@mysql.com> * Jeremy Cole <jcole@mysql.com>
* Tonu Samuel <tonu@mysql.com>
* *
**/ **/
@ -74,7 +75,6 @@ extern "C" {
#endif #endif
#undef bcmp // Fix problem with new readline #undef bcmp // Fix problem with new readline
#undef bzero
#if defined( __WIN__) || defined(OS2) #if defined( __WIN__) || defined(OS2)
#include <conio.h> #include <conio.h>
#else #else
@ -243,7 +243,8 @@ static COMMANDS commands[] = {
}; };
static const char *load_default_groups[]= { "mysql","client",0 }; static const char *load_default_groups[]= { "mysql","client",0 };
static const char *server_default_groups[]= { "server", "mysql_SERVER", 0 }; static const char *server_default_groups[]=
{ "server", "embedded", "mysql_SERVER", 0 };
#ifdef HAVE_READLINE #ifdef HAVE_READLINE
extern "C" void add_history(char *command); /* From readline directory */ extern "C" void add_history(char *command); /* From readline directory */
@ -271,7 +272,6 @@ int main(int argc,char *argv[])
{ {
char buff[80]; char buff[80];
mysql_server_init(0, NULL, server_default_groups);
MY_INIT(argv[0]); MY_INIT(argv[0]);
DBUG_ENTER("main"); DBUG_ENTER("main");
DBUG_PROCESS(argv[0]); DBUG_PROCESS(argv[0]);
@ -302,6 +302,7 @@ 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);
completion_hash_init(&ht,50); completion_hash_init(&ht,50);
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,
@ -368,7 +369,6 @@ int main(int argc,char *argv[])
if (opt_outfile) if (opt_outfile)
end_tee(); end_tee();
mysql_end(0); mysql_end(0);
mysql_server_end();
#ifndef _lint #ifndef _lint
DBUG_RETURN(0); // Keep compiler happy DBUG_RETURN(0); // Keep compiler happy
#endif #endif
@ -398,6 +398,7 @@ sig_handler mysql_end(int sig)
my_free(current_db,MYF(MY_ALLOW_ZERO_PTR)); my_free(current_db,MYF(MY_ALLOW_ZERO_PTR));
my_free(current_host,MYF(MY_ALLOW_ZERO_PTR)); my_free(current_host,MYF(MY_ALLOW_ZERO_PTR));
my_free(current_user,MYF(MY_ALLOW_ZERO_PTR)); my_free(current_user,MYF(MY_ALLOW_ZERO_PTR));
mysql_server_end();
my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
exit(status.exit_status); exit(status.exit_status);
} }
@ -967,7 +968,7 @@ static bool add_line(String &buffer,char *line,char *in_string)
{ // mSQL or postgreSQL style command ? { // mSQL or postgreSQL style command ?
if (!(inchar = (uchar) *++pos)) if (!(inchar = (uchar) *++pos))
break; // readline adds one '\' break; // readline adds one '\'
if (*in_string || inchar == 'N') if (*in_string || inchar == 'N') // \N is short for NULL
{ // Don't allow commands in string { // Don't allow commands in string
*out++='\\'; *out++='\\';
*out++= (char) inchar; *out++= (char) inchar;
@ -1232,6 +1233,7 @@ You can turn off this feature to get a quicker startup with -A\n\n");
} }
} }
} }
/* FIXME: free() on small chunks is sloooowwww. glibc bug */
if (field_names) { if (field_names) {
for (i=0; field_names[i]; i++) { for (i=0; field_names[i]; i++) {
for (j=0; field_names[i][j]; j++) { for (j=0; field_names[i][j]; j++) {
@ -2219,7 +2221,7 @@ sql_real_connect(char *host,char *database,char *user,char *password,
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if (opt_use_ssl) if (opt_use_ssl)
mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath); opt_ssl_capath, opt_ssl_cipher);
#endif #endif
if (safe_updates) if (safe_updates)
{ {

View file

@ -265,7 +265,7 @@ int main(int argc,char *argv[])
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if (opt_use_ssl) if (opt_use_ssl)
mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath); opt_ssl_capath, opt_ssl_cipher);
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
if (sql_connect(&mysql,host,user,opt_password,option_wait)) if (sql_connect(&mysql,host,user,opt_password,option_wait))
error = 1; error = 1;

View file

@ -591,7 +591,7 @@ static int dbConnect(char *host, char *user, char *passwd)
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if (opt_use_ssl) if (opt_use_ssl)
mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath); opt_ssl_capath, opt_ssl_cipher);
#endif #endif
if (!(sock = mysql_real_connect(&mysql_connection, host, user, passwd, if (!(sock = mysql_real_connect(&mysql_connection, host, user, passwd,
NULL, opt_mysql_port, opt_mysql_unix_port, 0))) NULL, opt_mysql_port, opt_mysql_unix_port, 0)))

View file

@ -523,7 +523,7 @@ static int dbConnect(char *host, char *user,char *passwd)
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if (opt_use_ssl) if (opt_use_ssl)
mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath); opt_ssl_capath, opt_ssl_cipher);
#endif #endif
if (!(sock= mysql_real_connect(&mysql_connection,host,user,passwd, if (!(sock= mysql_real_connect(&mysql_connection,host,user,passwd,
NULL,opt_mysql_port,opt_mysql_unix_port, NULL,opt_mysql_port,opt_mysql_unix_port,

View file

@ -400,7 +400,7 @@ static MYSQL *db_connect(char *host, char *database, char *user, char *passwd)
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if (opt_use_ssl) if (opt_use_ssl)
mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath); opt_ssl_capath, opt_ssl_cipher);
#endif #endif
if (!(sock= mysql_real_connect(&mysql_connection,host,user,passwd, if (!(sock= mysql_real_connect(&mysql_connection,host,user,passwd,
database,opt_mysql_port,opt_mysql_unix_port, database,opt_mysql_port,opt_mysql_unix_port,

View file

@ -87,7 +87,7 @@ int main(int argc, char **argv)
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if (opt_use_ssl) if (opt_use_ssl)
mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath); opt_ssl_capath, opt_ssl_cipher);
#endif #endif
if (!(mysql_real_connect(&mysql,host,user,opt_password, if (!(mysql_real_connect(&mysql,host,user,opt_password,
argv[0],opt_mysql_port,opt_mysql_unix_port, argv[0],opt_mysql_port,opt_mysql_unix_port,

View file

@ -324,11 +324,13 @@ static void close_cons()
static void close_files() static void close_files()
{ {
do DBUG_ENTER("close_files");
for (; cur_file != file_stack ; cur_file--)
{ {
if (*cur_file != stdin && *cur_file) if (*cur_file != stdin && *cur_file)
my_fclose(*cur_file,MYF(0)); my_fclose(*cur_file,MYF(0));
} while (cur_file-- != file_stack); }
DBUG_VOID_RETURN;
} }
static void free_used_memory() static void free_used_memory()
@ -356,6 +358,7 @@ static void free_used_memory()
dynstr_free(&ds_res); dynstr_free(&ds_res);
my_free(pass,MYF(MY_ALLOW_ZERO_PTR)); my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
free_defaults(default_argv); free_defaults(default_argv);
mysql_server_end();
my_end(MY_CHECK_ERROR); my_end(MY_CHECK_ERROR);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -1387,16 +1390,12 @@ int read_line(char* buf, int size)
{ {
if ((*cur_file) != stdin) if ((*cur_file) != stdin)
my_fclose(*cur_file,MYF(0)); my_fclose(*cur_file,MYF(0));
if (cur_file == file_stack)
return 1;
else
{
cur_file--; cur_file--;
lineno--; lineno--;
if (cur_file == file_stack)
return 1;
continue; continue;
} }
}
switch(state) { switch(state) {
case R_NORMAL: case R_NORMAL:
@ -2068,6 +2067,9 @@ int main(int argc, char** argv)
mysql_server_init(sizeof(embedded_server_args) / sizeof(char *) - 1, mysql_server_init(sizeof(embedded_server_args) / sizeof(char *) - 1,
embedded_server_args, embedded_server_groups); embedded_server_args, embedded_server_groups);
MY_INIT(argv[0]); MY_INIT(argv[0]);
{
DBUG_ENTER("main");
DBUG_PROCESS(argv[0]);
save_file[0]=0; save_file[0]=0;
TMPDIR[0]=0; TMPDIR[0]=0;
@ -2092,9 +2094,12 @@ 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,
embedded_server_args, embedded_server_groups))
die("Can't initialize MySQL server");
init_var_hash(); init_var_hash();
if (!*cur_file) if (cur_file == file_stack)
*cur_file = stdin; *++cur_file = stdin;
*lineno=1; *lineno=1;
init_manager(); init_manager();
@ -2240,6 +2245,7 @@ int main(int argc, char** argv)
exit(error ? 1 : 0); exit(error ? 1 : 0);
return error ? 1 : 0; /* Keep compiler happy */ return error ? 1 : 0; /* Keep compiler happy */
} }
}
/**************************************************************************** /****************************************************************************

View file

@ -1752,17 +1752,20 @@ AC_ARG_WITH(embedded-server,
) )
AC_ARG_WITH(extra-tools, AC_ARG_WITH(extra-tools,
[ --without-extra-tools Skip building utilites in the tools \ [ --without-extra-tools Skip building utilites in the tools directory.],
directory.],
[with_tools=$withval], [with_tools=$withval],
[with_tools=yes] [with_tools=yes]
) )
tools_dirs=""
if test "$with_tools" = "yes" if test "$with_tools" = "yes"
then then
tools_dirs="tools" if test "$THREAD_SAFE_CLIENT" = "no"
then
echo "Warning: extra-tools disabled because --enable-thread-safe-client wasn't used"
else else
tools_dirs="" tools_dirs="tools"
fi
fi fi
AC_SUBST(tools_dirs) AC_SUBST(tools_dirs)
@ -2178,7 +2181,17 @@ EOF
then then
sql_server_dirs="innobase $sql_server_dirs" sql_server_dirs="innobase $sql_server_dirs"
echo "CONFIGURING FOR INNODB" echo "CONFIGURING FOR INNODB"
(cd innobase && sh ./configure) \ if test ! -d "innobase"; then
# This should only happen when doing a VPATH build
echo "NOTICE: I have to make the Innobase directory: `pwd`/innobase"
mkdir "innobase" || exit 1
fi
rel_srcdir=
case "$srcdir" in
/* ) rel_srcdir="$srcdir" ;;
* ) rel_srcdir="../$srcdir" ;;
esac
(cd innobase && sh $rel_srcdir/innobase/configure) \
|| AC_MSG_ERROR([could not configure INNODB]) || AC_MSG_ERROR([could not configure INNODB])
echo "END OF INNODB CONFIGURATION" echo "END OF INNODB CONFIGURATION"

View file

@ -57,6 +57,8 @@ extern CHARSET_INFO *default_charset_info;
extern CHARSET_INFO *find_compiled_charset(uint cs_number); extern CHARSET_INFO *find_compiled_charset(uint cs_number);
extern CHARSET_INFO *find_compiled_charset_by_name(const char *name); extern CHARSET_INFO *find_compiled_charset_by_name(const char *name);
extern CHARSET_INFO compiled_charsets[]; extern CHARSET_INFO compiled_charsets[];
extern uint compiled_charset_number(const char *name);
extern const char *compiled_charset_name(uint charset_number);
#define MY_CHARSET_UNDEFINED 0 #define MY_CHARSET_UNDEFINED 0
#define MY_CHARSET_CURRENT (default_charset_info->number) #define MY_CHARSET_CURRENT (default_charset_info->number)

View file

@ -965,4 +965,13 @@ typedef union {
#define statistic_add(V,C,L) (V)+=(C) #define statistic_add(V,C,L) (V)+=(C)
#endif #endif
/* Macros to make switching between C and C++ mode easier */
#ifdef __cplusplus
#define C_MODE_START extern "C" {
#define C_MODE_END }
#else
#define C_MODE_START
#define C_MODE_END
#endif
#endif /* _global_h */ #endif /* _global_h */

View file

@ -109,7 +109,8 @@ extern int NEAR my_errno; /* Last error in mysys */
#define MY_WAIT_FOR_USER_TO_FIX_PANIC 60 /* in seconds */ #define MY_WAIT_FOR_USER_TO_FIX_PANIC 60 /* in seconds */
#define MY_WAIT_GIVE_USER_A_MESSAGE 10 /* Every 10 times of prev */ #define MY_WAIT_GIVE_USER_A_MESSAGE 10 /* Every 10 times of prev */
#define MIN_COMPRESS_LENGTH 50 /* Don't compress small bl. */ #define MIN_COMPRESS_LENGTH 50 /* Don't compress small bl. */
#define KEYCACHE_BLOCK_SIZE 1024 #define DEFAULT_KEYCACHE_BLOCK_SIZE 1024
#define MAX_KEYCACHE_BLOCK_SIZE 16384
/* root_alloc flags */ /* root_alloc flags */
#define MY_KEEP_PREALLOC 1 #define MY_KEEP_PREALLOC 1
@ -194,8 +195,9 @@ extern char *get_charsets_dir(char *buf);
extern ulong _my_cache_w_requests,_my_cache_write,_my_cache_r_requests, extern ulong _my_cache_w_requests,_my_cache_write,_my_cache_r_requests,
_my_cache_read; _my_cache_read;
extern ulong _my_blocks_used,_my_blocks_changed; extern ulong _my_blocks_used,_my_blocks_changed;
extern uint key_cache_block_size;
extern ulong my_file_opened,my_stream_opened, my_tmp_file_created; extern ulong my_file_opened,my_stream_opened, my_tmp_file_created;
extern my_bool key_cache_inited; extern my_bool key_cache_inited, my_init_done;
/* Point to current my_message() */ /* Point to current my_message() */
extern void (*my_sigtstp_cleanup)(void), extern void (*my_sigtstp_cleanup)(void),
@ -605,6 +607,7 @@ my_bool my_compress(byte *, ulong *, ulong *);
my_bool my_uncompress(byte *, ulong *, ulong *); my_bool my_uncompress(byte *, ulong *, ulong *);
byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen); byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen);
ulong checksum(const byte *mem, uint count); ulong checksum(const byte *mem, uint count);
uint my_bit_log2(ulong value);
#if defined(_MSC_VER) && !defined(__WIN__) #if defined(_MSC_VER) && !defined(__WIN__)
extern void sleep(int sec); extern void sleep(int sec);

View file

@ -46,6 +46,11 @@ extern "C" {
/* Max extra space to use when sorting keys */ /* Max extra space to use when sorting keys */
#define MI_MAX_TEMP_LENGTH 256*1024L*1024L #define MI_MAX_TEMP_LENGTH 256*1024L*1024L
/* Possible values for myisam_block_size (must be power of 2) */
#define MI_KEY_BLOCK_LENGTH 1024 /* default key block length */
#define MI_MIN_KEY_BLOCK_LENGTH 1024 /* Min key block length */
#define MI_MAX_KEY_BLOCK_LENGTH 16384
#define mi_portable_sizeof_char_ptr 8 #define mi_portable_sizeof_char_ptr 8
typedef uint32 ha_checksum; typedef uint32 ha_checksum;
@ -192,7 +197,7 @@ extern uint myisam_block_size;
extern my_bool myisam_flush,myisam_delay_key_write,myisam_single_user; extern my_bool myisam_flush,myisam_delay_key_write,myisam_single_user;
extern my_bool myisam_concurrent_insert; extern my_bool myisam_concurrent_insert;
extern my_off_t myisam_max_temp_length,myisam_max_extra_temp_length; extern my_off_t myisam_max_temp_length,myisam_max_extra_temp_length;
extern uint myisam_bulk_insert_tree_size; extern ulong myisam_bulk_insert_tree_size;
/* Prototypes for myisam-functions */ /* Prototypes for myisam-functions */

View file

@ -26,11 +26,9 @@
#undef __WIN__ #undef __WIN__
#endif #endif
#ifndef MYSQL_SERVER
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#endif
#ifndef _global_h /* If not standard header */ #ifndef _global_h /* If not standard header */
#include <sys/types.h> #include <sys/types.h>
@ -135,6 +133,7 @@ struct st_mysql_options {
char *ssl_cert; /* PEM cert file */ char *ssl_cert; /* PEM cert file */
char *ssl_ca; /* PEM CA file */ char *ssl_ca; /* PEM CA file */
char *ssl_capath; /* PEM directory of CA-s? */ char *ssl_capath; /* PEM directory of CA-s? */
char *ssl_cipher; /* cipher to use */
my_bool use_ssl; /* if to use SSL or not */ my_bool use_ssl; /* if to use SSL or not */
my_bool compress,named_pipe; my_bool compress,named_pipe;
/* /*
@ -252,7 +251,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. */
void mysql_server_init(int argc, const char **argv, const char **groups); int mysql_server_init(int argc, const char **argv, const char **groups);
void mysql_server_end(); void mysql_server_end();
/* Set up and bring down a thread; these function should be called /* Set up and bring down a thread; these function should be called
@ -286,7 +285,7 @@ const char * STDCALL mysql_character_set_name(MYSQL *mysql);
MYSQL * STDCALL mysql_init(MYSQL *mysql); MYSQL * STDCALL mysql_init(MYSQL *mysql);
int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key,
const char *cert, const char *ca, const char *cert, const char *ca,
const char *capath); const char *capath, const char *cipher);
int STDCALL mysql_ssl_clear(MYSQL *mysql); int STDCALL mysql_ssl_clear(MYSQL *mysql);
my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
const char *passwd, const char *db); const char *passwd, const char *db);
@ -416,10 +415,8 @@ int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
#define HAVE_MYSQL_REAL_CONNECT #define HAVE_MYSQL_REAL_CONNECT
#ifndef MYSQL_SERVER
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif
#endif #endif /* _mysql_h */

View file

@ -104,6 +104,8 @@ enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
struct st_vio; /* Only C */ struct st_vio; /* Only C */
typedef struct st_vio Vio; typedef struct st_vio Vio;
#define MAX_BLOB_WIDTH 8192 // Default width for blob
typedef struct st_net { typedef struct st_net {
Vio* vio; Vio* vio;
my_socket fd; /* For Perl DBI/dbd */ my_socket fd; /* For Perl DBI/dbd */

View file

@ -221,4 +221,7 @@
#define ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 1218 #define ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 1218
#define ER_CANT_UPDATE_WITH_READLOCK 1219 #define ER_CANT_UPDATE_WITH_READLOCK 1219
#define ER_MIXING_NOT_ALLOWED 1220 #define ER_MIXING_NOT_ALLOWED 1220
#define ER_ERROR_MESSAGES 221 #define ER_GRANT_DUPL_SUBJECT 1221
#define ER_GRANT_DUPL_ISSUER 1222
#define ER_GRANT_DUPL_CIPHER 1223
#define ER_ERROR_MESSAGES 224

View file

@ -39,4 +39,10 @@
my_free(opt_ssl_ca, MYF(MY_ALLOW_ZERO_PTR)); my_free(opt_ssl_ca, MYF(MY_ALLOW_ZERO_PTR));
opt_ssl_ca = my_strdup(optarg, MYF(0)); opt_ssl_ca = my_strdup(optarg, MYF(0));
break; break;
case OPT_SSL_CIPHER:
opt_use_ssl = 1; /* true */
my_free(opt_ssl_cipher, MYF(MY_ALLOW_ZERO_PTR));
opt_ssl_cipher = my_strdup(optarg, MYF(0));
break;
#endif #endif

View file

@ -22,10 +22,12 @@
#define OPT_SSL_CERT 202 #define OPT_SSL_CERT 202
#define OPT_SSL_CA 203 #define OPT_SSL_CA 203
#define OPT_SSL_CAPATH 204 #define OPT_SSL_CAPATH 204
#define OPT_SSL_CIPHER 205
{"ssl", no_argument, 0, OPT_SSL_SSL}, {"ssl", no_argument, 0, OPT_SSL_SSL},
{"ssl-key", required_argument, 0, OPT_SSL_KEY}, {"ssl-key", required_argument, 0, OPT_SSL_KEY},
{"ssl-cert", required_argument, 0, OPT_SSL_CERT}, {"ssl-cert", required_argument, 0, OPT_SSL_CERT},
{"ssl-ca", required_argument, 0, OPT_SSL_CA}, {"ssl-ca", required_argument, 0, OPT_SSL_CA},
{"ssl-capath", required_argument, 0, OPT_SSL_CAPATH}, {"ssl-capath", required_argument, 0, OPT_SSL_CAPATH},
{"ssl-cipher", required_argument, 0, OPT_SSL_CIPHER},
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */

View file

@ -21,5 +21,6 @@
--ssl-key X509 key in PEM format (implies --ssl)\n\ --ssl-key X509 key in PEM format (implies --ssl)\n\
--ssl-cert X509 cert in PEM format (implies --ssl)\n\ --ssl-cert X509 cert in PEM format (implies --ssl)\n\
--ssl-ca CA file in PEM format (check OpenSSL docs, implies --ssl)\n\ --ssl-ca CA file in PEM format (check OpenSSL docs, implies --ssl)\n\
--ssl-capath CA directory (check OpenSSL docs, implies --ssl)"); --ssl-capath CA directory (check OpenSSL docs, implies --ssl)\n\
--ssl-cipher SSL cipher to use (implies --ssl)");
#endif #endif

View file

@ -21,4 +21,5 @@ static char *opt_ssl_key = 0;
static char *opt_ssl_cert = 0; static char *opt_ssl_cert = 0;
static char *opt_ssl_ca = 0; static char *opt_ssl_ca = 0;
static char *opt_ssl_capath = 0; static char *opt_ssl_capath = 0;
static char *opt_ssl_cipher = 0;
#endif #endif

View file

@ -108,7 +108,6 @@ my_bool vio_poll_read(Vio *vio,uint timeout);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* vio_violite_h_ */
#if defined(HAVE_VIO) && !defined(DONT_MAP_VIO) #if defined(HAVE_VIO) && !defined(DONT_MAP_VIO)
#define vio_delete(vio) (vio)->viodelete(vio) #define vio_delete(vio) (vio)->viodelete(vio)
@ -169,9 +168,6 @@ struct st_VioSSLAcceptorFd
state_connect = 1, state_connect = 1,
state_accept = 2 state_accept = 2
}; };
// BIO* bio_;
// char desc_[100];
// Vio* sd_;
/* function pointers which are only once for SSL server /* function pointers which are only once for SSL server
Vio*(*sslaccept)(struct st_VioSSLAcceptorFd*,Vio*); */ Vio*(*sslaccept)(struct st_VioSSLAcceptorFd*,Vio*); */
@ -184,15 +180,17 @@ struct st_VioSSLConnectorFd
SSL_METHOD* ssl_method_; SSL_METHOD* ssl_method_;
/* function pointers which are only once for SSL client */ /* function pointers which are only once for SSL client */
}; };
void sslaccept(struct st_VioSSLAcceptorFd*, Vio*); void sslaccept(struct st_VioSSLAcceptorFd*, Vio*, long timeout);
void sslconnect(struct st_VioSSLConnectorFd*, Vio*); void sslconnect(struct st_VioSSLConnectorFd*, Vio*, long timeout);
struct st_VioSSLConnectorFd struct st_VioSSLConnectorFd
*new_VioSSLConnectorFd(const char* key_file, const char* cert_file, *new_VioSSLConnectorFd(const char* key_file, const char* cert_file,
const char* ca_file, const char* ca_path); const char* ca_file, const char* ca_path,
const char* cipher);
struct st_VioSSLAcceptorFd struct st_VioSSLAcceptorFd
*new_VioSSLAcceptorFd(const char* key_file, const char* cert_file, *new_VioSSLAcceptorFd(const char* key_file, const char* cert_file,
const char* ca_file,const char* ca_path); const char* ca_file,const char* ca_path,
const char* cipher);
Vio* new_VioSSL(struct st_VioSSLAcceptorFd* fd, Vio* sd,int state); Vio* new_VioSSL(struct st_VioSSLAcceptorFd* fd, Vio* sd,int state);
#ifdef __cplusplus #ifdef __cplusplus
@ -200,6 +198,9 @@ Vio* new_VioSSL(struct st_VioSSLAcceptorFd* fd, Vio* sd,int state);
#endif #endif
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
/* This enumerator is used in parser - should be always visible */
enum SSL_type {SSL_TYPE_NONE, SSL_TYPE_ANY, SSL_TYPE_X509, SSL_TYPE_SPECIFIED};
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
/* This structure is for every connection on both sides */ /* This structure is for every connection on both sides */
struct st_vio struct st_vio
@ -229,11 +230,10 @@ struct st_vio
my_bool (*poll_read)(Vio*,uint); my_bool (*poll_read)(Vio*,uint);
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
BIO* bio_;
SSL* ssl_; SSL* ssl_;
my_bool open_; my_bool open_;
char *ssl_cip_;
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
#endif /* HAVE_VIO */ #endif /* HAVE_VIO */
}; };
#endif /* EMBEDDED_LIBRARY */ #endif /* EMBEDDED_LIBRARY */
#endif /* vio_violite_h_ */

View file

@ -55,5 +55,7 @@ noinst_HEADERS = btr0btr.h btr0btr.ic btr0cur.h btr0cur.ic \
ut0dbg.h ut0lst.h ut0mem.h ut0mem.ic ut0rnd.h ut0rnd.ic \ ut0dbg.h ut0lst.h ut0mem.h ut0mem.ic ut0rnd.h ut0rnd.ic \
ut0sort.h ut0ut.h ut0ut.ic ut0sort.h ut0ut.h ut0ut.ic
EXTRA_DIST = Makefile.i
# Don't update the files from bitkeeper # Don't update the files from bitkeeper
%::SCCS/s.% %::SCCS/s.%

View file

@ -2,7 +2,7 @@
libsdir = ../libs libsdir = ../libs
INCLUDES = -I../../include -I../include INCLUDES = -I$(srcdir)/../include -I$(srcdir)/../../include -I../../include
# Don't update the files from bitkeeper # Don't update the files from bitkeeper
%::SCCS/s.% %::SCCS/s.%

View file

@ -71,11 +71,11 @@ link_sources:
# keep only the stubs for safemalloc.c and debug.c # keep only the stubs for safemalloc.c and debug.c
# #
# A list of needed headers collected from the deps information 000213 # A list of needed headers collected from the deps information 000213
nh = global.h config-win32.h dbug.h errmsg.h global.h \ nh = my_global.h config-win32.h dbug.h errmsg.h \
m_ctype.h m_string.h \ m_ctype.h m_string.h \
my_alarm.h my_config.h my_dir.h my_list.h my_net.h my_sys.h \ my_alarm.h my_config.h my_dir.h my_list.h my_net.h my_sys.h \
mysql.h mysql_com.h mysql_version.h mysqld_error.h mysys_err.h \ mysql.h mysql_com.h mysql_version.h mysqld_error.h \
my_pthread.h thr_alarm.h violite.h hash.h mysys_err.h my_pthread.h thr_alarm.h violite.h hash.h
# Get a list of the needed objects # Get a list of the needed objects
lobjs = $(mysysobjects1) $(dbugobjects) $(mystringsobjects) lobjs = $(mysysobjects1) $(dbugobjects) $(mystringsobjects)

View file

@ -91,10 +91,12 @@ static sig_handler pipe_sig_handler(int sig);
static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to, static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
const char *from, ulong length); const char *from, ulong length);
void mysql_server_init(int argc __attribute__((unused)), int mysql_server_init(int argc __attribute__((unused)),
const char **argv __attribute__((unused)), const char **argv __attribute__((unused)),
const char **groups __attribute__((unused))) const char **groups __attribute__((unused)))
{} {
return 0;
}
void mysql_server_end() void mysql_server_end()
{} {}
@ -695,7 +697,7 @@ mysql_free_result(MYSQL_RES *result)
static const char *default_options[]= static const char *default_options[]=
{"port","socket","compress","password","pipe", "timeout", "user", {"port","socket","compress","password","pipe", "timeout", "user",
"init-command", "host", "database", "debug", "return-found-rows", "init-command", "host", "database", "debug", "return-found-rows",
"ssl-key" ,"ssl-cert" ,"ssl-ca" ,"ssl-capath", "ssl-key" ,"ssl-cert" ,"ssl-ca" ,"ssl-capath", "ssl-cipher"
"character-set-dir", "default-character-set", "interactive-timeout", "character-set-dir", "default-character-set", "interactive-timeout",
"connect_timeout", "replication-probe", "enable-reads-from-master", "connect_timeout", "replication-probe", "enable-reads-from-master",
"repl-parse-query", "repl-parse-query",
@ -1368,15 +1370,17 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
const char *key __attribute__((unused)), const char *key __attribute__((unused)),
const char *cert __attribute__((unused)), const char *cert __attribute__((unused)),
const char *ca __attribute__((unused)), const char *ca __attribute__((unused)),
const char *capath __attribute__((unused))) const char *capath __attribute__((unused)),
const char *cipher __attribute__((unused)))
{ {
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
mysql->options.ssl_key = key==0 ? 0 : my_strdup(key,MYF(0)); mysql->options.ssl_key = key==0 ? 0 : my_strdup(key,MYF(0));
mysql->options.ssl_cert = cert==0 ? 0 : my_strdup(cert,MYF(0)); mysql->options.ssl_cert = cert==0 ? 0 : my_strdup(cert,MYF(0));
mysql->options.ssl_ca = ca==0 ? 0 : my_strdup(ca,MYF(0)); mysql->options.ssl_ca = ca==0 ? 0 : my_strdup(ca,MYF(0));
mysql->options.ssl_capath = capath==0 ? 0 : my_strdup(capath,MYF(0)); mysql->options.ssl_capath = capath==0 ? 0 : my_strdup(capath,MYF(0));
mysql->options.ssl_cipher = cipher==0 ? 0 : my_strdup(cipher,MYF(0));
mysql->options.use_ssl = TRUE; mysql->options.use_ssl = TRUE;
mysql->connector_fd = (gptr)new_VioSSLConnectorFd(key, cert, ca, capath); mysql->connector_fd = (gptr)new_VioSSLConnectorFd(key, cert, ca, capath, cipher);
DBUG_PRINT("info",("mysql_ssl_set, context: %p",((struct st_VioSSLConnectorFd *)(mysql->connector_fd))->ssl_context_)); DBUG_PRINT("info",("mysql_ssl_set, context: %p",((struct st_VioSSLConnectorFd *)(mysql->connector_fd))->ssl_context_));
#endif #endif
return 0; return 0;
@ -1396,10 +1400,12 @@ mysql_ssl_clear(MYSQL *mysql __attribute__((unused)))
my_free(mysql->options.ssl_cert, MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.ssl_cert, MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.ssl_ca, MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.ssl_ca, MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.ssl_capath, MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.ssl_capath, MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.ssl_cipher, MYF(MY_ALLOW_ZERO_PTR));
mysql->options.ssl_key = 0; mysql->options.ssl_key = 0;
mysql->options.ssl_cert = 0; mysql->options.ssl_cert = 0;
mysql->options.ssl_ca = 0; mysql->options.ssl_ca = 0;
mysql->options.ssl_capath = 0; mysql->options.ssl_capath = 0;
mysql->options.ssl_cipher= 0;
mysql->options.use_ssl = FALSE; mysql->options.use_ssl = FALSE;
my_free(mysql->connector_fd,MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->connector_fd,MYF(MY_ALLOW_ZERO_PTR));
mysql->connector_fd = 0; mysql->connector_fd = 0;
@ -1797,7 +1803,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
/* Do the SSL layering. */ /* Do the SSL layering. */
DBUG_PRINT("info", ("IO layer change in progress...")); DBUG_PRINT("info", ("IO layer change in progress..."));
DBUG_PRINT("info", ("IO context %p",((struct st_VioSSLConnectorFd*)mysql->connector_fd)->ssl_context_)); DBUG_PRINT("info", ("IO context %p",((struct st_VioSSLConnectorFd*)mysql->connector_fd)->ssl_context_));
sslconnect((struct st_VioSSLConnectorFd*)(mysql->connector_fd),mysql->net.vio); sslconnect((struct st_VioSSLConnectorFd*)(mysql->connector_fd),mysql->net.vio, (long)(mysql->options.connect_timeout));
DBUG_PRINT("info", ("IO layer change done!")); DBUG_PRINT("info", ("IO layer change done!"));
} }
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
@ -1887,7 +1893,7 @@ static my_bool mysql_reconnect(MYSQL *mysql)
if (!mysql->reconnect || if (!mysql->reconnect ||
(mysql->server_status & SERVER_STATUS_IN_TRANS) || !mysql->host_info) (mysql->server_status & SERVER_STATUS_IN_TRANS) || !mysql->host_info)
{ {
/* Allov reconnect next time */ /* Allow reconnect next time */
mysql->server_status&= ~SERVER_STATUS_IN_TRANS; mysql->server_status&= ~SERVER_STATUS_IN_TRANS;
DBUG_RETURN(1); DBUG_RETURN(1);
} }
@ -1995,13 +2001,13 @@ mysql_close(MYSQL *mysql)
my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.charset_dir,MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.charset_dir,MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.charset_name,MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.charset_name,MYF(MY_ALLOW_ZERO_PTR));
#ifdef HAVE_OPENSSL
mysql_ssl_clear(mysql);
#endif /* HAVE_OPENSSL */
/* Clear pointers for better safety */ /* Clear pointers for better safety */
mysql->host_info=mysql->user=mysql->passwd=mysql->db=0; mysql->host_info=mysql->user=mysql->passwd=mysql->db=0;
bzero((char*) &mysql->options,sizeof(mysql->options)); bzero((char*) &mysql->options,sizeof(mysql->options));
mysql->net.vio = 0; mysql->net.vio = 0;
#ifdef HAVE_OPENSSL
mysql_ssl_clear(mysql);
#endif /* HAVE_OPENSSL */
/* free/close slave list */ /* free/close slave list */
if (mysql->rpl_pivot) if (mysql->rpl_pivot)

View file

@ -39,6 +39,8 @@ libmysqlsources = errmsg.c get_password.c password.c
## XXX: we should not have to duplicate info from the sources list ## XXX: we should not have to duplicate info from the sources list
libmysqlobjects = errmsg.lo get_password.lo password.lo libmysqlobjects = errmsg.lo get_password.lo password.lo
noinst_HEADERS = embedded_priv.h
sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \ sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \
ha_innobase.cc ha_berkeley.cc ha_heap.cc ha_isam.cc ha_isammrg.cc \ ha_innobase.cc ha_berkeley.cc ha_heap.cc ha_isam.cc ha_isammrg.cc \
ha_myisam.cc ha_myisammrg.cc handler.cc sql_handler.cc \ ha_myisam.cc ha_myisammrg.cc handler.cc sql_handler.cc \

32
libmysqld/embedded_priv.h Normal file
View file

@ -0,0 +1,32 @@
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Prototypes for the embedded version of MySQL */
#include <my_global.h>
#include <mysql_embed.h>
#include <mysql.h>
#include <mysql_version.h>
#include <mysqld_error.h>
#include <my_pthread.h>
C_MODE_START
extern void start_embedded_connection(NET * net);
extern void end_embedded_connection(NET * net);
extern void lib_connection_phase(NET *net, int phase);
extern bool lib_dispatch_command(enum enum_server_command command, NET *net,
const char *arg, ulong length);
C_MODE_END

View file

@ -43,6 +43,7 @@ usage: $0 [-g|-h|-r] [test-name ...]
EOF EOF
} }
init_args=""
while test $# -gt 0 while test $# -gt 0
do do
arg= arg=
@ -56,6 +57,7 @@ do
-h | --help | -\? ) usage; exit 0;; -h | --help | -\? ) usage; exit 0;;
-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 ;;
-s | --start=* ) -s | --start=* )
test $argset -eq 0 && { shift; arg="$1"; } test $argset -eq 0 && { shift; arg="$1"; }
start="$arg" start="$arg"
@ -103,7 +105,7 @@ do
echo "test '$b' doesn't exist" >&2 echo "test '$b' doesn't exist" >&2
continue continue
} }
args="-v -S /tmp/mysql.sock -R $r -x $t test" args="$init_args -v -S /tmp/mysql.sock -R $r -x $t test"
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

View file

@ -12,20 +12,21 @@
* modified is included with the above copyright notice. * modified is included with the above copyright notice.
* *
*/ */
#include "my_global.h" #include "embedded_priv.h"
#include "mysql_embed.h"
#include "my_pthread.h"
#include "sys/types.h" #include "sys/types.h"
#include "../regex/regex.h" #include "../regex/regex.h"
#include "my_sys.h" #include "my_sys.h"
/*
The following is needed to not cause conflicts when we include mysqld.cc
*/
#define main main1 #define main main1
#define mysql_unix_port mysql_inix_port1 #define mysql_unix_port mysql_inix_port1
#define mysql_port mysql_port1 #define mysql_port mysql_port1
#define net_read_timeout net_read_timeout1 #define net_read_timeout net_read_timeout1
#define net_write_timeout net_write_timeout1 #define net_write_timeout net_write_timeout1
#define changeable_vars changeable_vars1 #define changeable_vars changeable_vars1
//#define mysql_tmpdir mysql_tmpdir1
extern "C" extern "C"
{ {
@ -36,38 +37,21 @@ extern "C"
class THD; class THD;
static int static int check_connections1(THD * thd);
check_connections1(THD * thd); static int check_connections2(THD * thd);
static bool check_user(THD *thd, enum_server_command command,
static bool const char *user, const char *passwd, const char *db,
check_user(THD *thd, enum_server_command command,const char *user, const char *passwd, const char *db, bool check_count); bool check_count);
static int
check_connections2(THD * thd);
extern void free_defaults(char ** argv);
void free_defaults_internal(char ** argv) {if (argv) free_defaults(argv);} void free_defaults_internal(char ** argv) {if (argv) free_defaults(argv);}
#define free_defaults free_defaults_internal #define free_defaults free_defaults_internal
char mysql_data_home[FN_REFLEN];
char * get_mysql_data_home(){return mysql_data_home;};
#define mysql_data_home mysql_data_home_internal
#include "../sql/mysqld.cc" #include "../sql/mysqld.cc"
#define SCRAMBLE_LENGTH 8 #define SCRAMBLE_LENGTH 8
extern "C" { C_MODE_START
/* char * get_mysql_home(){ return mysql_home;};
void char * get_mysql_real_data_home(){ return mysql_real_data_home;};
free_defaults(char ** argv) {};
void
load_defaults(const char *, const char **, int *, char ***) {};
*/
char *
get_mysql_home(){ return mysql_home;};
char *
get_mysql_real_data_home(){ return mysql_real_data_home;};
bool lib_dispatch_command(enum enum_server_command command, NET *net, bool lib_dispatch_command(enum enum_server_command command, NET *net,
@ -83,9 +67,7 @@ bool lib_dispatch_command(enum enum_server_command command, NET *net,
} }
void lib_connection_phase(NET * net, int phase)
void
lib_connection_phase(NET * net, int phase)
{ {
THD * thd; THD * thd;
thd = (THD *)(net->vio->dest_thd); thd = (THD *)(net->vio->dest_thd);
@ -99,7 +81,9 @@ lib_connection_phase(NET * net, int phase)
} }
} }
} }
} C_MODE_END
void start_embedded_conn1(NET * net) void start_embedded_conn1(NET * net)
{ {
THD * thd = new THD; THD * thd = new THD;
@ -117,7 +101,6 @@ void start_embedded_conn1(NET * net)
if (v) if (v)
{ {
v -> dest_thd = thd; v -> dest_thd = thd;
/* v -> dest_net = &thd->net; XXX: Probably not needed? */
} }
thd->net.vio = v; thd->net.vio = v;
if (thd->store_globals()) if (thd->store_globals())
@ -257,7 +240,7 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
send_error(net,ER_OUT_OF_RESOURCES); send_error(net,ER_OUT_OF_RESOURCES);
return 1; return 1;
} }
thd->master_access=acl_getroot(thd->host, thd->ip, thd->user, thd->master_access=acl_getroot(thd, thd->host, thd->ip, thd->user,
passwd, thd->scramble, &thd->priv_user, passwd, thd->scramble, &thd->priv_user,
protocol_version == 9 || protocol_version == 9 ||
!(thd->client_capabilities & !(thd->client_capabilities &
@ -308,10 +291,14 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
} }
extern "C"{ extern "C"
void mysql_server_init(int argc, const char **argv, const char **groups)
{ {
char hostname[FN_REFLEN];
static my_bool inited, org_my_init_done;
int mysql_server_init(int argc, const char **argv, const char **groups)
{
char glob_hostname[FN_REFLEN];
/* This mess is to allow people to call the init function without /* This mess is to allow people to call the init function without
* having to mess with a fake argv */ * having to mess with a fake argv */
@ -335,7 +322,16 @@ void mysql_server_init(int argc, const char **argv, const char **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
MY_INIT((char *)"mysqld_server"); // init my_sys library & pthreads
/* Only call MY_INIT() if it hasn't been called before */
if (!inited)
{
inited=1;
org_my_init_done=my_init_done;
}
if (!org_my_init_done)
MY_INIT((char *)"mysql_embedded"); // init my_sys library & pthreads
tzset(); // Set tzname tzset(); // Set tzname
start_time=time((time_t*) 0); start_time=time((time_t*) 0);
@ -344,49 +340,34 @@ void mysql_server_init(int argc, const char **argv, const char **groups)
{ {
struct tm tm_tmp; struct tm tm_tmp;
localtime_r(&start_time,&tm_tmp); localtime_r(&start_time,&tm_tmp);
strmov(time_zone,tzname[tm_tmp.tm_isdst == 1 ? 1 : 0]); strmov(time_zone,tzname[tm_tmp.tm_isdst != 0 ? 1 : 0]);
} }
#else #else
{ {
struct tm *start_tm; struct tm *start_tm;
start_tm=localtime(&start_time); start_tm=localtime(&start_time);
strmov(time_zone=tzname[start_tm->tm_isdst == 1 ? 1 : 0]); strmov(time_zone,tzname[start_tm->tm_isdst != 0 ? 1 : 0]);
} }
#endif #endif
#endif #endif
if (gethostname(hostname,sizeof(hostname)-4) < 0) if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0)
strmov(hostname,"mysql"); strmov(glob_hostname,"mysql");
strmov(pidfile_name,hostname);
strmov(strcend(pidfile_name,'.'),".pid"); // Add extension
#ifdef DEMO_VERSION
strcat(server_version,"-demo");
#endif
#ifdef SHAREWARE_VERSION
strcat(server_version,"-shareware");
#endif
#ifndef DBUG_OFF #ifndef DBUG_OFF
strcat(server_version,"-debug"); strcat(server_version,"-debug");
#endif #endif
strcat(server_version,"-library-ver"); strcat(server_version,"-embedded");
#ifdef _CUSTOMSTARTUPCONFIG_
if (_cust_check_startup())
{
/* _cust_check_startup will report startup failure error */
exit( 1 );
}
#endif
load_defaults("my", groups, argcp, argvp); load_defaults("my", 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 */
#ifdef __WIN__ #if defined( __WIN__) || defined(OS2)
if (!mysql_tmpdir) if (!mysql_tmpdir)
mysql_tmpdir=getenv("TEMP"); mysql_tmpdir=getenv("TEMP");
if (!mysql_tmpdir) if (!mysql_tmpdir)
mysql_tmpdir=getenv("TMP"); mysql_tmpdir=getenv("TMP");
#endif #endif
if (!mysql_tmpdir || !mysql_tmpdir[0]) if (!mysql_tmpdir || !mysql_tmpdir[0])
mysql_tmpdir=strdup((char*) P_tmpdir); mysql_tmpdir=(char*) P_tmpdir; /* purecov: inspected */
set_options(); set_options();
get_options(*argcp, *argvp); get_options(*argcp, *argvp);
@ -427,23 +408,20 @@ void mysql_server_init(int argc, const char **argv, const char **groups)
(void) pthread_cond_init(&COND_slave_start, NULL); (void) pthread_cond_init(&COND_slave_start, NULL);
if (set_default_charset_by_name(default_charset, MYF(MY_WME))) if (set_default_charset_by_name(default_charset, MYF(MY_WME)))
unireg_abort(1); {
mysql_server_end();
return 1;
}
charsets_list = list_charsets(MYF(MY_COMPILED_SETS|MY_CONFIG_SETS)); charsets_list = list_charsets(MYF(MY_COMPILED_SETS|MY_CONFIG_SETS));
if (!(opt_specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(),CONNECT_PRIOR);
/* Parameter for threads created for connections */ /* Parameter for threads created for connections */
(void) pthread_attr_init(&connection_attrib); (void) pthread_attr_init(&connection_attrib);
(void) pthread_attr_setdetachstate(&connection_attrib, (void) pthread_attr_setdetachstate(&connection_attrib,
PTHREAD_CREATE_DETACHED); PTHREAD_CREATE_DETACHED);
pthread_attr_setstacksize(&connection_attrib,thread_stack); pthread_attr_setstacksize(&connection_attrib,thread_stack);
if (!(opt_specialflag & SPECIAL_NO_PRIOR))
my_pthread_attr_setprio(&connection_attrib,WAIT_PRIOR);
pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM); pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM);
#ifdef SET_RLIMIT_NOFILE #if defined( SET_RLIMIT_NOFILE) || defined( OS2)
/* connections and databases neads lots of files */ /* connections and databases neads lots of files */
{ {
uint wanted_files=10+(uint) max(max_connections*5, uint wanted_files=10+(uint) max(max_connections*5,
@ -468,64 +446,57 @@ void mysql_server_init(int argc, const char **argv, const char **groups)
#ifdef USE_REGEX #ifdef USE_REGEX
regex_init(); regex_init();
#endif #endif
select_thread=pthread_self(); if (use_temp_pool && bitmap_init(&temp_pool,1024))
select_thread_in_use=1; {
mysql_server_end();
return 1;
}
/* /*
** We have enough space for fiddling with the argv, continue ** We have enough space for fiddling with the argv, continue
*/ */
umask(((~my_umask) & 0666)); umask(((~my_umask) & 0666));
// strcpy(mysql_real_data_home, "/usr/local");
//if (my_setwd(mysql_real_data_home,MYF(MY_WME)))
//{
// unireg_abort(1); /* purecov: inspected */
//}
//mysql_data_home[0]=FN_CURLIB; // all paths are relative from here
//mysql_data_home[1]=0;
strcpy(get_mysql_data_home(), mysql_real_data_home);
//server_init();
table_cache_init(); table_cache_init();
hostname_cache_init(); hostname_cache_init();
sql_cache_init(); sql_cache_init();
randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2); randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2);
reset_floating_point_exceptions(); reset_floating_point_exceptions();
init_thr_lock(); init_thr_lock();
init_slave_list();
/* Setup log files */ /* Setup log files */
if (opt_log) if (opt_log)
open_log(&mysql_log, hostname, opt_logname, ".log", LOG_NORMAL); open_log(&mysql_log, glob_hostname, opt_logname, ".log", LOG_NORMAL);
if (opt_update_log) if (opt_update_log)
open_log(&mysql_update_log, hostname, opt_update_logname, "",
LOG_NEW);
if (opt_bin_log)
{ {
if(server_id) open_log(&mysql_update_log, glob_hostname, opt_update_logname, "",
LOG_NEW);
using_update_log=1;
}
if (opt_bin_log)
{ {
if (!opt_bin_logname) if (!opt_bin_logname)
{ {
char tmp[FN_REFLEN]; char tmp[FN_REFLEN];
strnmov(tmp,hostname,FN_REFLEN-5); strmake(tmp,glob_hostname,FN_REFLEN-5);
strmov(strcend(tmp,'.'),"-bin"); strmov(strcend(tmp,'.'),"-bin");
opt_bin_logname=my_strdup(tmp,MYF(MY_WME)); opt_bin_logname=my_strdup(tmp,MYF(MY_WME));
} }
mysql_bin_log.set_index_file_name(opt_binlog_index_name); mysql_bin_log.set_index_file_name(opt_binlog_index_name);
open_log(&mysql_bin_log, hostname, opt_bin_logname, "-bin", open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
LOG_BIN); LOG_BIN);
} using_update_log=1;
else
sql_print_error("Server id is not set - binary logging disabled");
} }
if (opt_slow_log) if (opt_slow_log)
open_log(&mysql_slow_log, hostname, opt_slow_logname, "-slow.log", open_log(&mysql_slow_log, glob_hostname, opt_slow_logname, "-slow.log",
LOG_NORMAL); LOG_NORMAL);
if (ha_init()) if (ha_init())
{ {
sql_print_error("Can't init databases"); sql_print_error("Can't init databases");
exit(1); exit(1);
} }
ha_key_cache();
#ifdef HAVE_MLOCKALL #ifdef HAVE_MLOCKALL
if (locked_in_memory && !geteuid()) if (locked_in_memory && !geteuid())
{ {
@ -556,90 +527,46 @@ void mysql_server_init(int argc, const char **argv, const char **groups)
sql_print_error("Can't create thread-keys"); sql_print_error("Can't create thread-keys");
exit(1); exit(1);
} }
//init_signals(); opt_noacl = 1; // No permissions
opt_noacl = 1;
if (acl_init(opt_noacl)) if (acl_init(opt_noacl))
{ {
select_thread_in_use=0; mysql_server_end();
(void) pthread_kill(signal_thread,MYSQL_KILL_SIGNAL); return 1;
exit(1);
} }
if (!opt_noacl)
(void) grant_init();
#ifdef HAVE_DLOPEN #ifdef HAVE_DLOPEN
if (!opt_noacl) if (!opt_noacl)
udf_init(); udf_init();
#endif #endif
if (opt_bootstrap)
{
int error=bootstrap(stdin);
end_thr_alarm(); // Don't allow alarms
unireg_abort(error ? 1 : 0);
}
if (opt_init_file)
{
if (read_init_file(opt_init_file))
{
end_thr_alarm(); // Don't allow alarms
unireg_abort(1);
}
}
(void) thr_setconcurrency(concurrency); // 10 by default (void) thr_setconcurrency(concurrency); // 10 by default
if (flush_time && flush_time != ~(ulong) 0L) if (
#ifdef HAVE_BERKELEY_DB
!berkeley_skip ||
#endif
(flush_time && flush_time != ~(ulong) 0L))
{ {
pthread_t hThread; pthread_t hThread;
if (pthread_create(&hThread,&connection_attrib,handle_manager,0)) if (pthread_create(&hThread,&connection_attrib,handle_manager,0))
{
sql_print_error("Warning: Can't create thread to manage maintenance"); sql_print_error("Warning: Can't create thread to manage maintenance");
mysql_server_end();
return 1;
}
}
return 0;
} }
// slave thread
if(master_host)
{
if(server_id)
{
pthread_t hThread;
if(!opt_skip_slave_start &&
pthread_create(&hThread, &connection_attrib, handle_slave, 0))
sql_print_error("Warning: Can't create thread to handle slave");
}
else
sql_print_error("Server id is not set, slave thread will not be started");
}
//printf(ER(ER_READY),my_progname,server_version,"");
//printf("%s initialized.\n", server_version);
fflush(stdout);
}
void mysql_server_end() void mysql_server_end()
{ {
/* (void) pthread_attr_destroy(&connection_attrib); */ clean_up(0);
#ifdef THREAD
DBUG_PRINT("quit",("Exiting main thread")); /* Don't call my_thread_end() if the application is using MY_INIT() */
if (!org_my_init_done)
#ifdef EXTRA_DEBUG
sql_print_error("Before Lock_thread_count");
#endif
(void) pthread_mutex_lock(&LOCK_thread_count);
select_thread_in_use=0; // For close_connections
(void) pthread_cond_broadcast(&COND_thread_count);
(void) pthread_mutex_unlock(&LOCK_thread_count);
#ifdef EXTRA_DEBUG
sql_print_error("After lock_thread_count");
#endif
// /* Wait until cleanup is done */
// (void) pthread_mutex_lock(&LOCK_thread_count);
// while (!ready_to_exit)
// {
// pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
// }
// (void) pthread_mutex_unlock(&LOCK_thread_count);
unireg_end(0);
my_thread_end(); my_thread_end();
#endif
} }
my_bool mysql_thread_init() my_bool mysql_thread_init()
@ -662,14 +589,11 @@ void start_embedded_connection(NET * net)
{ {
start_embedded_conn1(net); start_embedded_conn1(net);
} }
//====================================================================
} void end_embedded_connection(NET * net)
int embedded_do_command(NET * net)
{ {
THD * thd = (THD *) net ->vio; THD *thd = (THD *) net->vio->dest_thd;
do_command(thd); delete thd;
return 0;
} }
} /* extern "C" */

View file

@ -15,15 +15,7 @@
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA */ MA 02111-1307, USA */
#include <my_global.h> #include "embedded_priv.h"
#if defined(__WIN__) || defined(_WIN32) || defined(_WIN64)
#include <winsock.h>
#include <odbcinst.h>
#endif
#include "mysql_embed.h"
#include "mysql.h"
#include "mysql_version.h"
#include "mysqld_error.h"
#include <my_sys.h> #include <my_sys.h>
#include <mysys_err.h> #include <mysys_err.h>
#include <m_string.h> #include <m_string.h>
@ -51,9 +43,6 @@
#ifdef HAVE_SYS_UN_H #ifdef HAVE_SYS_UN_H
# include <sys/un.h> # include <sys/un.h>
#endif #endif
#if defined(THREAD) && !defined(__WIN__)
#include <my_pthread.h> /* because of signal() */
#endif
#ifndef INADDR_NONE #ifndef INADDR_NONE
#define INADDR_NONE -1 #define INADDR_NONE -1
#endif #endif
@ -74,12 +63,6 @@ my_string mysql_unix_port=0;
#define closesocket(A) close(A) #define closesocket(A) close(A)
#endif #endif
/* XXX: this is real ugly... */
extern void start_embedded_connection(NET * net);
extern void lib_connection_phase(NET *net, int phase);
extern bool lib_dispatch_command(enum enum_server_command command, NET *net,
const char *arg, ulong length);
static void mysql_once_init(void); static void mysql_once_init(void);
static MYSQL_DATA *read_rows (MYSQL *mysql,MYSQL_FIELD *fields, static MYSQL_DATA *read_rows (MYSQL *mysql,MYSQL_FIELD *fields,
uint field_count); uint field_count);
@ -89,7 +72,6 @@ static void end_server(MYSQL *mysql);
static void read_user_name(char *name); static void read_user_name(char *name);
static void append_wild(char *to,char *end,const char *wild); static void append_wild(char *to,char *end,const char *wild);
static int send_file_to_server(MYSQL *mysql,const char *filename); static int send_file_to_server(MYSQL *mysql,const char *filename);
static sig_handler pipe_sig_handler(int sig);
static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to, static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
const char *from, ulong length); const char *from, ulong length);
@ -402,22 +384,6 @@ mysql_debug(const char *debug)
#endif #endif
} }
/**************************************************************************
** Close the server connection if we get a SIGPIPE
ARGSUSED
**************************************************************************/
static sig_handler
pipe_sig_handler(int sig __attribute__((unused)))
{
DBUG_PRINT("info",("Hit by signal %d",sig));
#ifdef DONT_REMEMBER_SIGNAL
(void) signal(SIGPIPE,pipe_sig_handler);
#endif
}
/************************************************************************** /**************************************************************************
** Shut down connection ** Shut down connection
**************************************************************************/ **************************************************************************/
@ -428,11 +394,7 @@ end_server(MYSQL *mysql)
DBUG_ENTER("end_server"); DBUG_ENTER("end_server");
if (mysql->net.vio != 0) if (mysql->net.vio != 0)
{ {
init_sigpipe_variables end_embedded_connection(&mysql->net);
DBUG_PRINT("info",("Net: %s", vio_description(mysql->net.vio)));
set_sigpipe(mysql);
vio_delete(mysql->net.vio);
reset_sigpipe(mysql);
mysql->net.vio= 0; /* Marker */ mysql->net.vio= 0; /* Marker */
} }
net_end(&mysql->net); net_end(&mysql->net);

View file

@ -173,7 +173,7 @@ int do_boolean(ALL_IN_ONE *aio, uint nested __attribute__((unused)),
aio->key_root); aio->key_root);
else else
r=_mi_search(aio->info, aio->keyinfo, aio->info->lastkey, r=_mi_search(aio->info, aio->keyinfo, aio->info->lastkey,
aio->info->lastkey_length, SEARCH_BIGGER, USE_WHOLE_KEY, SEARCH_BIGGER,
aio->key_root); aio->key_root);
} }
break; break;

View file

@ -126,7 +126,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio)
aio->key_root); aio->key_root);
else else
r=_mi_search(aio->info, aio->keyinfo, aio->info->lastkey, r=_mi_search(aio->info, aio->keyinfo, aio->info->lastkey,
aio->info->lastkey_length, SEARCH_BIGGER, USE_WHOLE_KEY, SEARCH_BIGGER,
aio->key_root); aio->key_root);
} }
if(doc_cnt) { if(doc_cnt) {

View file

@ -34,7 +34,7 @@ FT_DOCLIST *ft_init_search(void *info, uint keynr, byte *query,
/* black magic ON */ /* black magic ON */
if ((int) (keynr = _mi_check_index((MI_INFO *)info,keynr)) < 0) if ((int) (keynr = _mi_check_index((MI_INFO *)info,keynr)) < 0)
return NULL; return NULL;
if (_mi_readinfo((MI_INFO *)info,F_RDLCK,1)) if (fast_mi_readinfo((MI_INFO *) info))
return NULL; return NULL;
/* black magic OFF */ /* black magic OFF */

View file

@ -24,7 +24,7 @@ int mi_is_changed(MI_INFO *info)
{ {
int result; int result;
DBUG_ENTER("mi_is_changed"); DBUG_ENTER("mi_is_changed");
if (_mi_readinfo(info,F_RDLCK,1)) if (fast_mi_readinfo(info))
DBUG_RETURN(-1); DBUG_RETURN(-1);
VOID(_mi_writeinfo(info,0)); VOID(_mi_writeinfo(info,0));
result=(int) info->data_changed; result=(int) info->data_changed;

View file

@ -231,7 +231,7 @@ wrong:
static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr) static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr)
{ {
my_off_t next_link; my_off_t next_link;
uint block_size=(nr+1)*MI_KEY_BLOCK_LENGTH; uint block_size=(nr+1)*MI_MIN_KEY_BLOCK_LENGTH;
ha_rows records; ha_rows records;
char llbuff[21],*buff; char llbuff[21],*buff;
DBUG_ENTER("check_k_link"); DBUG_ENTER("check_k_link");
@ -1205,8 +1205,6 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
param->glob_crc=0; param->glob_crc=0;
if (param->testflag & T_CALC_CHECKSUM) if (param->testflag & T_CALC_CHECKSUM)
param->calc_checksum=1; param->calc_checksum=1;
if (!rep_quick)
share->state.checksum=0;
info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
for (i=0 ; i < info->s->base.keys ; i++) for (i=0 ; i < info->s->base.keys ; i++)
@ -1301,9 +1299,9 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
else else
{ {
info->state->data_file_length=sort_info->max_pos; info->state->data_file_length=sort_info->max_pos;
}
if (param->testflag & T_CALC_CHECKSUM) if (param->testflag & T_CALC_CHECKSUM)
share->state.checksum=param->glob_crc; share->state.checksum=param->glob_crc;
}
if (!(param->testflag & T_SILENT)) if (!(param->testflag & T_SILENT))
{ {
@ -1886,8 +1884,6 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
param->glob_crc=0; param->glob_crc=0;
if (param->testflag & T_CALC_CHECKSUM) if (param->testflag & T_CALC_CHECKSUM)
param->calc_checksum=1; param->calc_checksum=1;
if (! rep_quick)
share->state.checksum=0;
rec_per_key_part= param->rec_per_key_part; rec_per_key_part= param->rec_per_key_part;
for (sort_info->key=0 ; sort_info->key < share->base.keys ; for (sort_info->key=0 ; sort_info->key < share->base.keys ;
@ -2018,7 +2014,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
"Can't change size of datafile, error: %d", "Can't change size of datafile, error: %d",
my_errno); my_errno);
} }
else if (param->testflag & T_CALC_CHECKSUM) if (param->testflag & T_CALC_CHECKSUM)
share->state.checksum=param->glob_crc; share->state.checksum=param->glob_crc;
if (my_chsize(share->kfile,info->state->key_file_length,MYF(0))) if (my_chsize(share->kfile,info->state->key_file_length,MYF(0)))
@ -2115,6 +2111,7 @@ static int sort_key_read(SORT_INFO *sort_info, void *key)
DBUG_RETURN(sort_write_record(sort_info)); DBUG_RETURN(sort_write_record(sort_info));
} /* sort_key_read */ } /* sort_key_read */
static int sort_ft_key_read(SORT_INFO *sort_info, void *key) static int sort_ft_key_read(SORT_INFO *sort_info, void *key)
{ {
int error; int error;
@ -2540,7 +2537,7 @@ int sort_write_record(SORT_INFO *sort_info)
DBUG_RETURN(1); DBUG_RETURN(1);
} }
sort_info->filepos+=share->base.pack_reclength; sort_info->filepos+=share->base.pack_reclength;
info->s->state.checksum+=mi_static_checksum(info, sort_info->record); /* sort_info->param->glob_crc+=mi_static_checksum(info, sort_info->record); */
break; break;
case DYNAMIC_RECORD: case DYNAMIC_RECORD:
if (! info->blobs) if (! info->blobs)
@ -2564,7 +2561,7 @@ int sort_write_record(SORT_INFO *sort_info)
} }
info->checksum=mi_checksum(info,sort_info->record); info->checksum=mi_checksum(info,sort_info->record);
reclength=_mi_rec_pack(info,from,sort_info->record); reclength=_mi_rec_pack(info,from,sort_info->record);
info->s->state.checksum+=info->checksum; /* sort_info->param->glob_crc+=info->checksum; */
block_length=reclength+ 3 + test(reclength >= (65520-3)); block_length=reclength+ 3 + test(reclength >= (65520-3));
if (block_length < share->base.min_block_length) if (block_length < share->base.min_block_length)
block_length=share->base.min_block_length; block_length=share->base.min_block_length;
@ -2578,7 +2575,7 @@ int sort_write_record(SORT_INFO *sort_info)
DBUG_RETURN(1); DBUG_RETURN(1);
} }
sort_info->filepos+=block_length; sort_info->filepos+=block_length;
info->s->state.checksum+=info->checksum; /* sort_info->param->glob_crc+=info->checksum; */
break; break;
case COMPRESSED_RECORD: case COMPRESSED_RECORD:
reclength=info->packed_length; reclength=info->packed_length;
@ -2591,7 +2588,7 @@ int sort_write_record(SORT_INFO *sort_info)
mi_check_print_error(param,"%d when writing to datafile",my_errno); mi_check_print_error(param,"%d when writing to datafile",my_errno);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
info->s->state.checksum+=info->checksum; /* sort_info->param->glob_crc+=info->checksum; */
sort_info->filepos+=reclength+length; sort_info->filepos+=reclength+length;
break; break;
} }
@ -2808,8 +2805,8 @@ static int sort_delete_record(MI_CHECK *param)
DBUG_RETURN(1); DBUG_RETURN(1);
} }
} }
if (info->s->calc_checksum) if (param->calc_checksum)
info->s->state.checksum-=(*info->s->calc_checksum)(info, param->glob_crc-=(*info->s->calc_checksum)(info,
sort_info->record); sort_info->record);
} }
error=flush_io_cache(&info->rec_cache) || (*info->s->delete_record)(info); error=flush_io_cache(&info->rec_cache) || (*info->s->delete_record)(info);

View file

@ -227,7 +227,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
share.state.key_del=key_del; share.state.key_del=key_del;
if (uniques) if (uniques)
{ {
max_key_block_length= MI_KEY_BLOCK_LENGTH; max_key_block_length= myisam_block_size;
max_key_length= MI_UNIQUE_HASH_LENGTH; max_key_length= MI_UNIQUE_HASH_LENGTH;
} }
@ -370,7 +370,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
share.state.rec_per_key_part[key_segs-1]=1L; share.state.rec_per_key_part[key_segs-1]=1L;
length+=key_length; length+=key_length;
keydef->block_length= MI_BLOCK_SIZE(length,pointer,MI_MAX_KEYPTR_SIZE); keydef->block_length= MI_BLOCK_SIZE(length,pointer,MI_MAX_KEYPTR_SIZE);
if (keydef->block_length/MI_KEY_BLOCK_LENGTH > MI_MAX_KEY_BLOCK_SIZE) if (keydef->block_length > MI_MAX_KEY_BLOCK_LENGTH)
{ {
my_errno=HA_WRONG_CREATE_OPTION; my_errno=HA_WRONG_CREATE_OPTION;
goto err; goto err;
@ -386,7 +386,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
(length*2)))* (length*2)))*
(ulong) keydef->block_length; (ulong) keydef->block_length;
} }
for (i=max_key_block_length/MI_KEY_BLOCK_LENGTH ; i-- ; ) for (i=max_key_block_length/MI_MIN_KEY_BLOCK_LENGTH ; i-- ; )
key_del[i]=HA_OFFSET_ERROR; key_del[i]=HA_OFFSET_ERROR;
unique_key_parts=0; unique_key_parts=0;
@ -401,7 +401,8 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
key_segs+=uniques; /* Each unique has 1 key seg */ key_segs+=uniques; /* Each unique has 1 key seg */
base_pos=(MI_STATE_INFO_SIZE + keys * MI_STATE_KEY_SIZE + base_pos=(MI_STATE_INFO_SIZE + keys * MI_STATE_KEY_SIZE +
max_key_block_length/MI_KEY_BLOCK_LENGTH*MI_STATE_KEYBLOCK_SIZE+ max_key_block_length/MI_MIN_KEY_BLOCK_LENGTH*
MI_STATE_KEYBLOCK_SIZE+
key_segs*MI_STATE_KEYSEG_SIZE); key_segs*MI_STATE_KEYSEG_SIZE);
info_length=base_pos+(uint) (MI_BASE_INFO_SIZE+ info_length=base_pos+(uint) (MI_BASE_INFO_SIZE+
keys * MI_KEYDEF_SIZE+ keys * MI_KEYDEF_SIZE+
@ -420,7 +421,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
mi_int2store(share.state.header.base_pos,base_pos); mi_int2store(share.state.header.base_pos,base_pos);
share.state.header.language= (ci->language ? share.state.header.language= (ci->language ?
ci->language : MY_CHARSET_CURRENT); ci->language : MY_CHARSET_CURRENT);
share.state.header.max_block_size=max_key_block_length/MI_KEY_BLOCK_LENGTH; share.state.header.max_block_size=max_key_block_length/MI_MIN_KEY_BLOCK_LENGTH;
share.state.dellink = HA_OFFSET_ERROR; share.state.dellink = HA_OFFSET_ERROR;
share.state.process= (ulong) getpid(); share.state.process= (ulong) getpid();
@ -433,7 +434,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
share.base.rec_reflength=pointer; share.base.rec_reflength=pointer;
share.base.key_reflength= share.base.key_reflength=
mi_get_pointer_length((tot_length + max_key_block_length * keys * mi_get_pointer_length((tot_length + max_key_block_length * keys *
MI_INDEX_BLOCK_MARGIN) / MI_KEY_BLOCK_LENGTH, MI_INDEX_BLOCK_MARGIN) / MI_MIN_KEY_BLOCK_LENGTH,
3); 3);
share.base.keys= share.state.header.keys = keys; share.base.keys= share.state.header.keys = keys;
share.state.header.uniques= uniques; share.state.header.uniques= uniques;
@ -575,7 +576,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
{ {
tmp_keydef.keysegs=1; tmp_keydef.keysegs=1;
tmp_keydef.flag= HA_UNIQUE_CHECK; tmp_keydef.flag= HA_UNIQUE_CHECK;
tmp_keydef.block_length= MI_KEY_BLOCK_LENGTH; tmp_keydef.block_length= myisam_block_size;
tmp_keydef.keylength= MI_UNIQUE_HASH_LENGTH + pointer; tmp_keydef.keylength= MI_UNIQUE_HASH_LENGTH + pointer;
tmp_keydef.minlength=tmp_keydef.maxlength=tmp_keydef.keylength; tmp_keydef.minlength=tmp_keydef.maxlength=tmp_keydef.keylength;
tmp_keyseg.type= MI_UNIQUE_HASH_TYPE; tmp_keyseg.type= MI_UNIQUE_HASH_TYPE;

View file

@ -196,7 +196,8 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
DBUG_ENTER("d_search"); DBUG_ENTER("d_search");
DBUG_DUMP("page",(byte*) anc_buff,mi_getint(anc_buff)); DBUG_DUMP("page",(byte*) anc_buff,mi_getint(anc_buff));
flag=(*keyinfo->bin_search)(info,keyinfo,anc_buff,key,key_length,SEARCH_SAME, flag=(*keyinfo->bin_search)(info,keyinfo,anc_buff,key, USE_WHOLE_KEY,
SEARCH_SAME,
&keypos, lastkey, &last_key); &keypos, lastkey, &last_key);
if (flag == MI_FOUND_WRONG_KEY) if (flag == MI_FOUND_WRONG_KEY)
{ {

View file

@ -43,7 +43,7 @@ int mi_delete_all_rows(MI_INFO *info)
info->state->empty=info->state->key_empty=0; info->state->empty=info->state->key_empty=0;
state->checksum=0; state->checksum=0;
for (i=share->base.max_key_block_length/MI_KEY_BLOCK_LENGTH ; i-- ; ) for (i=share->base.max_key_block_length/MI_MIN_KEY_BLOCK_LENGTH ; i-- ; )
state->key_del[i]= HA_OFFSET_ERROR; state->key_del[i]= HA_OFFSET_ERROR;
for (i=0 ; i < share->base.keys ; i++) for (i=0 ; i < share->base.keys ; i++)
state->key_root[i]= HA_OFFSET_ERROR; state->key_root[i]= HA_OFFSET_ERROR;

View file

@ -1059,11 +1059,11 @@ int _mi_read_dynamic_record(MI_INFO *info, my_off_t filepos, byte *buf)
} while (left_length); } while (left_length);
info->update|= HA_STATE_AKTIV; /* We have a aktive record */ info->update|= HA_STATE_AKTIV; /* We have a aktive record */
VOID(_mi_writeinfo(info,0)); fast_mi_writeinfo(info);
DBUG_RETURN(_mi_rec_unpack(info,buf,info->rec_buff,block_info.rec_len) != DBUG_RETURN(_mi_rec_unpack(info,buf,info->rec_buff,block_info.rec_len) !=
MY_FILE_ERROR ? 0 : -1); MY_FILE_ERROR ? 0 : -1);
} }
VOID(_mi_writeinfo(info,0)); fast_mi_writeinfo(info);
DBUG_RETURN(-1); /* Wrong data to read */ DBUG_RETURN(-1); /* Wrong data to read */
panic: panic:
@ -1393,8 +1393,7 @@ int _mi_read_rnd_dynamic_record(MI_INFO *info, byte *buf,
} while (left_len); } while (left_len);
info->update|= HA_STATE_AKTIV | HA_STATE_KEY_CHANGED; info->update|= HA_STATE_AKTIV | HA_STATE_KEY_CHANGED;
if (share->r_locks == 0 && share->w_locks == 0) fast_mi_writeinfo(info);
VOID(_mi_writeinfo(info,0));
if (_mi_rec_unpack(info,buf,info->rec_buff,block_info.rec_len) != if (_mi_rec_unpack(info,buf,info->rec_buff,block_info.rec_len) !=
MY_FILE_ERROR) MY_FILE_ERROR)
DBUG_RETURN(0); DBUG_RETURN(0);

View file

@ -45,7 +45,7 @@ int mi_status(MI_INFO *info, register MI_ISAMINFO *x, uint flag)
{ {
pthread_mutex_lock(&share->intern_lock); pthread_mutex_lock(&share->intern_lock);
VOID(_mi_readinfo(info,F_RDLCK,0)); VOID(_mi_readinfo(info,F_RDLCK,0));
VOID(_mi_writeinfo(info,0)); fast_mi_writeinfo(info);
pthread_mutex_unlock(&share->intern_lock); pthread_mutex_unlock(&share->intern_lock);
} }
if (flag & HA_STATUS_VARIABLE) if (flag & HA_STATUS_VARIABLE)

View file

@ -346,7 +346,7 @@ err:
int _mi_read_key_record(MI_INFO *info, my_off_t filepos, byte *buf) int _mi_read_key_record(MI_INFO *info, my_off_t filepos, byte *buf)
{ {
VOID(_mi_writeinfo(info,0)); fast_mi_writeinfo(info);
if (filepos != HA_OFFSET_ERROR) if (filepos != HA_OFFSET_ERROR)
{ {
if (info->lastinx >= 0) if (info->lastinx >= 0)

View file

@ -50,6 +50,7 @@ int mi_lock_database(MI_INFO *info, int lock_type)
count= --share->r_locks; count= --share->r_locks;
else else
count= --share->w_locks; count= --share->w_locks;
--share->tot_locks;
if (info->lock_type == F_WRLCK && !share->w_locks && if (info->lock_type == F_WRLCK && !share->w_locks &&
!share->delay_key_write && flush_key_blocks(share->kfile,FLUSH_KEEP)) !share->delay_key_write && flush_key_blocks(share->kfile,FLUSH_KEEP))
{ {
@ -153,6 +154,7 @@ int mi_lock_database(MI_INFO *info, int lock_type)
} }
VOID(_mi_test_if_changed(info)); VOID(_mi_test_if_changed(info));
share->r_locks++; share->r_locks++;
share->tot_locks++;
info->lock_type=lock_type; info->lock_type=lock_type;
break; break;
case F_WRLCK: case F_WRLCK:
@ -200,6 +202,7 @@ int mi_lock_database(MI_INFO *info, int lock_type)
VOID(_mi_test_if_changed(info)); VOID(_mi_test_if_changed(info));
info->lock_type=lock_type; info->lock_type=lock_type;
share->w_locks++; share->w_locks++;
share->tot_locks++;
break; break;
default: default:
break; /* Impossible */ break; /* Impossible */
@ -295,13 +298,12 @@ my_bool mi_check_status(void* param)
int _mi_readinfo(register MI_INFO *info, int lock_type, int check_keybuffer) int _mi_readinfo(register MI_INFO *info, int lock_type, int check_keybuffer)
{ {
MYISAM_SHARE *share;
DBUG_ENTER("_mi_readinfo"); DBUG_ENTER("_mi_readinfo");
share=info->s;
if (info->lock_type == F_UNLCK) if (info->lock_type == F_UNLCK)
{ {
if (!share->r_locks && !share->w_locks) MYISAM_SHARE *share=info->s;
if (!share->tot_locks)
{ {
if ((info->tmp_lock_type=lock_type) != F_RDLCK) if ((info->tmp_lock_type=lock_type) != F_RDLCK)
if (my_lock(share->kfile,lock_type,0L,F_TO_EOF, if (my_lock(share->kfile,lock_type,0L,F_TO_EOF,
@ -339,7 +341,7 @@ int _mi_writeinfo(register MI_INFO *info, uint operation)
DBUG_ENTER("_mi_writeinfo"); DBUG_ENTER("_mi_writeinfo");
error=0; error=0;
if (share->r_locks == 0 && share->w_locks == 0) if (share->tot_locks == 0)
{ {
olderror=my_errno; /* Remember last error */ olderror=my_errno; /* Remember last error */
if (operation) if (operation)

View file

@ -217,7 +217,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
(mi_safe_mul(share->base.reclength, (mi_safe_mul(share->base.reclength,
(ulonglong) 1 << (share->base.rec_reflength*8))-1); (ulonglong) 1 << (share->base.rec_reflength*8))-1);
max_key_file_length= max_key_file_length=
mi_safe_mul(MI_KEY_BLOCK_LENGTH, mi_safe_mul(MI_MIN_KEY_BLOCK_LENGTH,
((ulonglong) 1 << (share->base.key_reflength*8))-1); ((ulonglong) 1 << (share->base.key_reflength*8))-1);
#if SIZEOF_OFF_T == 4 #if SIZEOF_OFF_T == 4
set_if_smaller(max_data_file_length, INT_MAX32); set_if_smaller(max_data_file_length, INT_MAX32);
@ -913,7 +913,7 @@ char *mi_keydef_read(char *ptr, MI_KEYDEF *keydef)
keydef->keylength = mi_uint2korr(ptr); ptr +=2; keydef->keylength = mi_uint2korr(ptr); ptr +=2;
keydef->minlength = mi_uint2korr(ptr); ptr +=2; keydef->minlength = mi_uint2korr(ptr); ptr +=2;
keydef->maxlength = mi_uint2korr(ptr); ptr +=2; keydef->maxlength = mi_uint2korr(ptr); ptr +=2;
keydef->block_size = keydef->block_length/MI_KEY_BLOCK_LENGTH-1; keydef->block_size = keydef->block_length/MI_MIN_KEY_BLOCK_LENGTH-1;
keydef->underflow_block_length=keydef->block_length/3; keydef->underflow_block_length=keydef->block_length/3;
keydef->version = 0; /* Not saved */ keydef->version = 0; /* Not saved */
return ptr; return ptr;

View file

@ -64,9 +64,9 @@ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo,
#ifndef FAST /* Safety check */ #ifndef FAST /* Safety check */
if (page < info->s->base.keystart || if (page < info->s->base.keystart ||
page+keyinfo->block_length > info->state->key_file_length || page+keyinfo->block_length > info->state->key_file_length ||
page & (myisam_block_size-1)) (page & (MI_MIN_KEY_BLOCK_LENGTH-1)))
{ {
DBUG_PRINT("error",("Trying to write outside key region: %lu", DBUG_PRINT("error",("Trying to write inside key status region: %lu",
(long) page)); (long) page));
my_errno=EINVAL; my_errno=EINVAL;
return(-1); return(-1);

View file

@ -45,7 +45,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, const byte *start_key,
if ((inx = _mi_check_index(info,inx)) < 0) if ((inx = _mi_check_index(info,inx)) < 0)
DBUG_RETURN(HA_POS_ERROR); DBUG_RETURN(HA_POS_ERROR);
if (_mi_readinfo(info,F_RDLCK,1)) if (fast_mi_readinfo(info))
DBUG_RETURN(HA_POS_ERROR); DBUG_RETURN(HA_POS_ERROR);
info->update&= (HA_STATE_CHANGED+HA_STATE_ROW_CHANGED); info->update&= (HA_STATE_CHANGED+HA_STATE_ROW_CHANGED);
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
@ -58,7 +58,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, const byte *start_key,
info->state->records+ (ha_rows) 1); info->state->records+ (ha_rows) 1);
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_unlock(&info->s->key_root_lock[inx]); rw_unlock(&info->s->key_root_lock[inx]);
VOID(_mi_writeinfo(info,0)); fast_mi_writeinfo(info);
if (start_pos == HA_POS_ERROR || end_pos == HA_POS_ERROR) if (start_pos == HA_POS_ERROR || end_pos == HA_POS_ERROR)
DBUG_RETURN(HA_POS_ERROR); DBUG_RETURN(HA_POS_ERROR);
DBUG_PRINT("info",("records: %ld",(ulong) (end_pos-start_pos))); DBUG_PRINT("info",("records: %ld",(ulong) (end_pos-start_pos)));
@ -72,7 +72,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, const byte *start_key,
static ha_rows _mi_record_pos(MI_INFO *info, const byte *key, uint key_len, static ha_rows _mi_record_pos(MI_INFO *info, const byte *key, uint key_len,
enum ha_rkey_function search_flag) enum ha_rkey_function search_flag)
{ {
uint inx=(uint) info->lastinx; uint inx=(uint) info->lastinx, nextflag;
MI_KEYDEF *keyinfo=info->s->keyinfo+inx; MI_KEYDEF *keyinfo=info->s->keyinfo+inx;
uchar *key_buff; uchar *key_buff;
double pos; double pos;
@ -86,8 +86,12 @@ static ha_rows _mi_record_pos(MI_INFO *info, const byte *key, uint key_len,
key_len=_mi_pack_key(info,inx,key_buff,(uchar*) key,key_len); key_len=_mi_pack_key(info,inx,key_buff,(uchar*) key,key_len);
DBUG_EXECUTE("key",_mi_print_key(DBUG_FILE,keyinfo->seg, DBUG_EXECUTE("key",_mi_print_key(DBUG_FILE,keyinfo->seg,
(uchar*) key_buff,key_len);); (uchar*) key_buff,key_len););
nextflag=myisam_read_vec[search_flag];
if (!(nextflag & (SEARCH_FIND | SEARCH_NO_FIND | SEARCH_LAST)))
key_len=USE_WHOLE_KEY;
pos=_mi_search_pos(info,keyinfo,key_buff,key_len, pos=_mi_search_pos(info,keyinfo,key_buff,key_len,
myisam_read_vec[search_flag] | SEARCH_SAVE_BUFF, nextflag | SEARCH_SAVE_BUFF,
info->s->state.key_root[inx]); info->s->state.key_root[inx]);
if (pos >= 0.0) if (pos >= 0.0)
{ {
@ -145,9 +149,9 @@ static double _mi_search_pos(register MI_INFO *info,
** Matches keynr+1 ** Matches keynr+1
*/ */
offset=1.0; /* Matches keynr+1 */ offset=1.0; /* Matches keynr+1 */
if (nextflag & SEARCH_FIND && if ((nextflag & SEARCH_FIND) && nod_flag &&
((keyinfo->flag & (HA_NOSAME | HA_NULL_PART)) != HA_NOSAME || ((keyinfo->flag & (HA_NOSAME | HA_NULL_PART)) != HA_NOSAME ||
key_len) && nod_flag) key_len != USE_WHOLE_KEY))
{ {
/* /*
** There may be identical keys in the tree. Try to match on of those. ** There may be identical keys in the tree. Try to match on of those.

View file

@ -27,7 +27,7 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
{ {
uchar *key_buff; uchar *key_buff;
MYISAM_SHARE *share=info->s; MYISAM_SHARE *share=info->s;
uint pack_key_length; uint pack_key_length, use_key_length, nextflag;
DBUG_ENTER("mi_rkey"); DBUG_ENTER("mi_rkey");
DBUG_PRINT("enter",("base: %lx inx: %d search_flag: %d", DBUG_PRINT("enter",("base: %lx inx: %d search_flag: %d",
info,inx,search_flag)); info,inx,search_flag));
@ -55,11 +55,17 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
bmove(key_buff,key,key_len); bmove(key_buff,key,key_len);
} }
if (_mi_readinfo(info,F_RDLCK,1)) if (fast_mi_readinfo(info))
goto err; goto err;
if (share->concurrent_insert) if (share->concurrent_insert)
rw_rdlock(&share->key_root_lock[inx]); rw_rdlock(&share->key_root_lock[inx]);
if (!_mi_search(info,info->s->keyinfo+inx,key_buff,pack_key_length,
nextflag=myisam_read_vec[search_flag];
use_key_length=pack_key_length;
if (!(nextflag & (SEARCH_FIND | SEARCH_NO_FIND | SEARCH_LAST)))
use_key_length=USE_WHOLE_KEY;
if (!_mi_search(info,info->s->keyinfo+inx,key_buff,use_key_length,
myisam_read_vec[search_flag],info->s->state.key_root[inx])) myisam_read_vec[search_flag],info->s->state.key_root[inx]))
{ {
while (info->lastpos >= info->state->data_file_length) while (info->lastpos >= info->state->data_file_length)

View file

@ -35,7 +35,7 @@ int mi_rnext(MI_INFO *info, byte *buf, int inx)
if (info->lastpos == HA_OFFSET_ERROR && info->update & HA_STATE_PREV_FOUND) if (info->lastpos == HA_OFFSET_ERROR && info->update & HA_STATE_PREV_FOUND)
flag=0; /* Read first */ flag=0; /* Read first */
if (_mi_readinfo(info,F_RDLCK,1)) if (fast_mi_readinfo(info))
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_rdlock(&info->s->key_root_lock[inx]); rw_rdlock(&info->s->key_root_lock[inx]);
@ -51,7 +51,7 @@ int mi_rnext(MI_INFO *info, byte *buf, int inx)
info->s->state.key_root[inx]); info->s->state.key_root[inx]);
else else
error=_mi_search(info,info->s->keyinfo+inx,info->lastkey, error=_mi_search(info,info->s->keyinfo+inx,info->lastkey,
info->lastkey_length,flag, info->s->state.key_root[inx]); USE_WHOLE_KEY,flag, info->s->state.key_root[inx]);
if (!error) if (!error)
{ {

View file

@ -35,7 +35,7 @@ int mi_rnext_same(MI_INFO *info, byte *buf)
DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX); DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX);
keyinfo=info->s->keyinfo+inx; keyinfo=info->s->keyinfo+inx;
flag=SEARCH_BIGGER; /* Read next */ flag=SEARCH_BIGGER; /* Read next */
if (_mi_readinfo(info,F_RDLCK,1)) if (fast_mi_readinfo(info))
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
memcpy(info->lastkey2,info->lastkey,info->last_rkey_length); memcpy(info->lastkey2,info->lastkey,info->last_rkey_length);

View file

@ -36,7 +36,7 @@ int mi_rprev(MI_INFO *info, byte *buf, int inx)
if (info->lastpos == HA_OFFSET_ERROR && info->update & HA_STATE_NEXT_FOUND) if (info->lastpos == HA_OFFSET_ERROR && info->update & HA_STATE_NEXT_FOUND)
flag=0; /* Read last */ flag=0; /* Read last */
if (_mi_readinfo(info,F_RDLCK,1)) if (fast_mi_readinfo(info))
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
changed=_mi_test_if_changed(info); changed=_mi_test_if_changed(info);
if (share->concurrent_insert) if (share->concurrent_insert)
@ -50,7 +50,7 @@ int mi_rprev(MI_INFO *info, byte *buf, int inx)
share->state.key_root[inx]); share->state.key_root[inx]);
else else
error=_mi_search(info,share->keyinfo+inx,info->lastkey, error=_mi_search(info,share->keyinfo+inx,info->lastkey,
info->lastkey_length, flag, share->state.key_root[inx]); USE_WHOLE_KEY, flag, share->state.key_root[inx]);
if (!error) if (!error)
{ {

View file

@ -41,7 +41,7 @@ int mi_rsame(MI_INFO *info, byte *record, int inx)
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
/* Read row from data file */ /* Read row from data file */
if (_mi_readinfo(info,F_RDLCK,1)) if (fast_mi_readinfo(info))
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
if (inx >= 0) if (inx >= 0)
@ -51,7 +51,8 @@ int mi_rsame(MI_INFO *info, byte *record, int inx)
info->lastpos); info->lastpos);
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_rdlock(&info->s->key_root_lock[inx]); rw_rdlock(&info->s->key_root_lock[inx]);
VOID(_mi_search(info,info->s->keyinfo+inx,info->lastkey,0,SEARCH_SAME, VOID(_mi_search(info,info->s->keyinfo+inx,info->lastkey, USE_WHOLE_KEY,
SEARCH_SAME,
info->s->state.key_root[inx])); info->s->state.key_root[inx]));
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_unlock(&info->s->key_root_lock[inx]); rw_unlock(&info->s->key_root_lock[inx]);

View file

@ -107,14 +107,15 @@ int _mi_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
} }
else else
{ {
if (nextflag & SEARCH_FIND && (!(keyinfo->flag & HA_NOSAME) if ((nextflag & SEARCH_FIND) && nod_flag &&
|| key_len) && nod_flag) ((keyinfo->flag & (HA_NOSAME | HA_NULL_PART)) != HA_NOSAME ||
key_len != USE_WHOLE_KEY))
{ {
if ((error=_mi_search(info,keyinfo,key,key_len,SEARCH_FIND, if ((error=_mi_search(info,keyinfo,key,key_len,SEARCH_FIND,
_mi_kpos(nod_flag,keypos))) >= 0 || _mi_kpos(nod_flag,keypos))) >= 0 ||
my_errno != HA_ERR_KEY_NOT_FOUND) my_errno != HA_ERR_KEY_NOT_FOUND)
DBUG_RETURN(error); DBUG_RETURN(error);
info->last_keypage= HA_OFFSET_ERROR; /* Buffer not in memory */ info->last_keypage= HA_OFFSET_ERROR; /* Buffer not in mem */
} }
} }
if (pos != info->last_keypage) if (pos != info->last_keypage)
@ -283,8 +284,6 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page,
LINT_INIT(saved_vseg); LINT_INIT(saved_vseg);
t_buff[0]=0; /* Avoid bugs */ t_buff[0]=0; /* Avoid bugs */
if (!(nextflag & (SEARCH_FIND | SEARCH_NO_FIND | SEARCH_LAST)))
key_len=USE_WHOLE_KEY;
end= page+mi_getint(page); end= page+mi_getint(page);
nod_flag=mi_test_if_nod(page); nod_flag=mi_test_if_nod(page);
page+=2+nod_flag; page+=2+nod_flag;
@ -477,11 +476,11 @@ my_off_t _mi_kpos(uint nod_flag, uchar *after_key)
switch (nod_flag) { switch (nod_flag) {
#if SIZEOF_OFF_T > 4 #if SIZEOF_OFF_T > 4
case 7: case 7:
return mi_uint7korr(after_key)*MI_KEY_BLOCK_LENGTH; return mi_uint7korr(after_key)*MI_MIN_KEY_BLOCK_LENGTH;
case 6: case 6:
return mi_uint6korr(after_key)*MI_KEY_BLOCK_LENGTH; return mi_uint6korr(after_key)*MI_MIN_KEY_BLOCK_LENGTH;
case 5: case 5:
return mi_uint5korr(after_key)*MI_KEY_BLOCK_LENGTH; return mi_uint5korr(after_key)*MI_MIN_KEY_BLOCK_LENGTH;
#else #else
case 7: case 7:
after_key++; after_key++;
@ -491,13 +490,13 @@ my_off_t _mi_kpos(uint nod_flag, uchar *after_key)
after_key++; after_key++;
#endif #endif
case 4: case 4:
return ((my_off_t) mi_uint4korr(after_key))*MI_KEY_BLOCK_LENGTH; return ((my_off_t) mi_uint4korr(after_key))*MI_MIN_KEY_BLOCK_LENGTH;
case 3: case 3:
return ((my_off_t) mi_uint3korr(after_key))*MI_KEY_BLOCK_LENGTH; return ((my_off_t) mi_uint3korr(after_key))*MI_MIN_KEY_BLOCK_LENGTH;
case 2: case 2:
return (my_off_t) (mi_uint2korr(after_key)*MI_KEY_BLOCK_LENGTH); return (my_off_t) (mi_uint2korr(after_key)*MI_MIN_KEY_BLOCK_LENGTH);
case 1: case 1:
return (uint) (*after_key)*MI_KEY_BLOCK_LENGTH; return (uint) (*after_key)*MI_MIN_KEY_BLOCK_LENGTH;
case 0: /* At leaf page */ case 0: /* At leaf page */
default: /* Impossible */ default: /* Impossible */
return(HA_OFFSET_ERROR); return(HA_OFFSET_ERROR);
@ -509,7 +508,7 @@ my_off_t _mi_kpos(uint nod_flag, uchar *after_key)
void _mi_kpointer(register MI_INFO *info, register uchar *buff, my_off_t pos) void _mi_kpointer(register MI_INFO *info, register uchar *buff, my_off_t pos)
{ {
pos/=MI_KEY_BLOCK_LENGTH; pos/=MI_MIN_KEY_BLOCK_LENGTH;
switch (info->s->base.key_reflength) { switch (info->s->base.key_reflength) {
#if SIZEOF_OFF_T > 4 #if SIZEOF_OFF_T > 4
case 7: mi_int7store(buff,pos); break; case 7: mi_int7store(buff,pos); break;
@ -719,10 +718,7 @@ int _mi_key_cmp(register MI_KEYSEG *keyseg, register uchar *a,
double d_1,d_2; double d_1,d_2;
uint next_key_length; uint next_key_length;
if (!(nextflag & (SEARCH_FIND | SEARCH_NO_FIND | SEARCH_LAST)))
key_length=USE_WHOLE_KEY;
*diff_pos=0; *diff_pos=0;
for ( ; (int) key_length >0 ; key_length=next_key_length, keyseg++) for ( ; (int) key_length >0 ; key_length=next_key_length, keyseg++)
{ {
uchar *end; uchar *end;
@ -1446,7 +1442,7 @@ int _mi_search_next(register MI_INFO *info, register MI_KEYDEF *keyinfo,
info->page_changed || info->page_changed ||
(info->int_keytree_version != keyinfo->version && (info->int_keytree_version != keyinfo->version &&
(info->int_nod_flag || info->buff_used))) (info->int_nod_flag || info->buff_used)))
DBUG_RETURN(_mi_search(info,keyinfo,key,key_length, DBUG_RETURN(_mi_search(info,keyinfo,key, USE_WHOLE_KEY,
nextflag | SEARCH_SAVE_BUFF, pos)); nextflag | SEARCH_SAVE_BUFF, pos));
if (info->buff_used) if (info->buff_used)
@ -1459,17 +1455,17 @@ int _mi_search_next(register MI_INFO *info, register MI_KEYDEF *keyinfo,
/* Last used buffer is in info->buff */ /* Last used buffer is in info->buff */
nod_flag=mi_test_if_nod(info->buff); nod_flag=mi_test_if_nod(info->buff);
memcpy(lastkey,key,key_length);
if (nextflag & SEARCH_BIGGER) /* Next key */ if (nextflag & SEARCH_BIGGER) /* Next key */
{ {
my_off_t tmp_pos=_mi_kpos(nod_flag,info->int_keypos); my_off_t tmp_pos=_mi_kpos(nod_flag,info->int_keypos);
if (tmp_pos != HA_OFFSET_ERROR) if (tmp_pos != HA_OFFSET_ERROR)
{ {
if ((error=_mi_search(info,keyinfo,key,key_length, if ((error=_mi_search(info,keyinfo,key, USE_WHOLE_KEY,
nextflag | SEARCH_SAVE_BUFF, tmp_pos)) <=0) nextflag | SEARCH_SAVE_BUFF, tmp_pos)) <=0)
DBUG_RETURN(error); DBUG_RETURN(error);
} }
memcpy(lastkey,key,key_length);
if (!(info->lastkey_length=(*keyinfo->get_key)(keyinfo,nod_flag, if (!(info->lastkey_length=(*keyinfo->get_key)(keyinfo,nod_flag,
&info->int_keypos,lastkey))) &info->int_keypos,lastkey)))
DBUG_RETURN(-1); DBUG_RETURN(-1);
@ -1483,12 +1479,14 @@ int _mi_search_next(register MI_INFO *info, register MI_KEYDEF *keyinfo,
if (!info->int_keypos) if (!info->int_keypos)
DBUG_RETURN(-1); DBUG_RETURN(-1);
if (info->int_keypos == info->buff+2) if (info->int_keypos == info->buff+2)
DBUG_RETURN(_mi_search(info,keyinfo,key,key_length, DBUG_RETURN(_mi_search(info,keyinfo,key, USE_WHOLE_KEY,
nextflag | SEARCH_SAVE_BUFF, pos)); nextflag | SEARCH_SAVE_BUFF, pos));
if ((error=_mi_search(info,keyinfo,key,0,nextflag | SEARCH_SAVE_BUFF, if ((error=_mi_search(info,keyinfo,key, USE_WHOLE_KEY,
nextflag | SEARCH_SAVE_BUFF,
_mi_kpos(nod_flag,info->int_keypos))) <= 0) _mi_kpos(nod_flag,info->int_keypos))) <= 0)
DBUG_RETURN(error); DBUG_RETURN(error);
/* QQ: We should be able to optimize away the following call */
if (! _mi_get_last_key(info,keyinfo,info->buff,lastkey, if (! _mi_get_last_key(info,keyinfo,info->buff,lastkey,
info->int_keypos,&info->lastkey_length)) info->int_keypos,&info->lastkey_length))
DBUG_RETURN(-1); DBUG_RETURN(-1);

View file

@ -40,7 +40,7 @@ my_bool myisam_concurrent_insert=0;
#endif #endif
my_off_t myisam_max_extra_temp_length= MI_MAX_TEMP_LENGTH; my_off_t myisam_max_extra_temp_length= MI_MAX_TEMP_LENGTH;
my_off_t myisam_max_temp_length= MAX_FILE_SIZE; my_off_t myisam_max_temp_length= MAX_FILE_SIZE;
uint myisam_bulk_insert_tree_size=8192*1024; ulong myisam_bulk_insert_tree_size=8192*1024;
/* read_vec[] is used for converting between P_READ_KEY.. and SEARCH_ */ /* read_vec[] is used for converting between P_READ_KEY.. and SEARCH_ */
/* Position is , == , >= , <= , > , < */ /* Position is , == , >= , <= , > , < */

View file

@ -181,8 +181,7 @@ int _mi_read_static_record(register MI_INFO *info, register my_off_t pos,
error=my_pread(info->dfile,(char*) record,info->s->base.reclength, error=my_pread(info->dfile,(char*) record,info->s->base.reclength,
pos,MYF(MY_NABP)) != 0; pos,MYF(MY_NABP)) != 0;
if (info->s->r_locks == 0 && info->s->w_locks == 0) fast_mi_writeinfo(info);
VOID(_mi_writeinfo(info,0));
if (! error) if (! error)
{ {
if (!*record) if (!*record)
@ -195,7 +194,7 @@ int _mi_read_static_record(register MI_INFO *info, register my_off_t pos,
} }
return(-1); /* Error on read */ return(-1); /* Error on read */
} }
VOID(_mi_writeinfo(info,0)); /* No such record */ fast_mi_writeinfo(info); /* No such record */
return(-1); return(-1);
} }
@ -257,7 +256,7 @@ int _mi_read_rnd_static_record(MI_INFO *info, byte *buf,
DBUG_PRINT("test",("filepos: %ld (%ld) records: %ld del: %ld", DBUG_PRINT("test",("filepos: %ld (%ld) records: %ld del: %ld",
filepos/share->base.reclength,filepos, filepos/share->base.reclength,filepos,
info->state->records, info->state->del)); info->state->records, info->state->del));
VOID(_mi_writeinfo(info,0)); fast_mi_writeinfo(info);
DBUG_RETURN(my_errno=HA_ERR_END_OF_FILE); DBUG_RETURN(my_errno=HA_ERR_END_OF_FILE);
} }
info->lastpos= filepos; info->lastpos= filepos;

View file

@ -343,15 +343,18 @@ int main(int argc, char *argv[])
} }
if (testflag==3) goto end; if (testflag==3) goto end;
if (!silent)
printf("- Same key: first - next -> last - prev -> first\n");
DBUG_PRINT("progpos",("first - next -> last - prev -> first"));
for (i=999, dupp_keys=j=0 ; i>0 ; i--) for (i=999, dupp_keys=j=0 ; i>0 ; i--)
{ {
if (key1[i] > dupp_keys) { dupp_keys=key1[i]; j=i; } if (key1[i] > dupp_keys) { dupp_keys=key1[i]; j=i; }
} }
sprintf(key,"%6d",j); sprintf(key,"%6d",j);
if (dupp_keys)
{
if (!silent)
printf("- Same key: first - next -> last - prev -> first\n");
DBUG_PRINT("progpos",("first - next -> last - prev -> first"));
if (verbose) printf(" Using key: \"%s\" Keys: %d\n",key,dupp_keys); if (verbose) printf(" Using key: \"%s\" Keys: %d\n",key,dupp_keys);
if (mi_rkey(file,read_record,0,key,0,HA_READ_KEY_EXACT)) goto err; if (mi_rkey(file,read_record,0,key,0,HA_READ_KEY_EXACT)) goto err;
if (mi_rsame(file,read_record2,-1)) goto err; if (mi_rsame(file,read_record2,-1)) goto err;
if (memcmp(read_record,read_record2,reclength) != 0) if (memcmp(read_record,read_record2,reclength) != 0)
@ -406,6 +409,7 @@ int main(int argc, char *argv[])
printf("mi_rnext_same: Found: %d records of %d\n",ant,dupp_keys); printf("mi_rnext_same: Found: %d records of %d\n",ant,dupp_keys);
goto end; goto end;
} }
}
if (!silent) if (!silent)
printf("- All keys: first - next -> last - prev -> first\n"); printf("- All keys: first - next -> last - prev -> first\n");
@ -777,8 +781,12 @@ end:
printf("Write records: %d\nUpdate records: %d\nSame-key-read: %d\nDelete records: %d\n", write_count,update,dupp_keys,opt_delete); printf("Write records: %d\nUpdate records: %d\nSame-key-read: %d\nDelete records: %d\n", write_count,update,dupp_keys,opt_delete);
if (rec_pointer_size) if (rec_pointer_size)
printf("Record pointer size: %d\n",rec_pointer_size); printf("Record pointer size: %d\n",rec_pointer_size);
printf("myisam_block_size: %u\n", myisam_block_size);
if (key_cacheing) if (key_cacheing)
{
puts("Key cacheing used"); puts("Key cacheing used");
printf("key_cache_block_size: %u\n", key_cache_block_size);
}
if (write_cacheing) if (write_cacheing)
puts("Write cacheing used"); puts("Write cacheing used");
if (write_cacheing) if (write_cacheing)
@ -801,7 +809,7 @@ reads: %10lu\n",
end_key_cache(); end_key_cache();
if (blob_buffer) if (blob_buffer)
my_free(blob_buffer,MYF(0)); my_free(blob_buffer,MYF(0));
my_end(MY_CHECK_ERROR | MY_GIVE_INFO); my_end(silent ? MY_CHECK_ERROR : MY_CHECK_ERROR | MY_GIVE_INFO);
return(0); return(0);
err: err:
printf("got error: %d when using MyISAM-database\n",my_errno); printf("got error: %d when using MyISAM-database\n",my_errno);
@ -861,7 +869,29 @@ static void get_options(int argc, char **argv)
verbose=1; verbose=1;
break; break;
case 'm': /* records */ case 'm': /* records */
recant=atoi(++pos); if ((recant=atoi(++pos)) < 10)
{
fprintf(stderr,"record count must be >= 10\n");
exit(1);
}
break;
case 'e': /* myisam_block_length */
if ((myisam_block_size=atoi(++pos)) < MI_MIN_KEY_BLOCK_LENGTH ||
myisam_block_size > MI_MAX_KEY_BLOCK_LENGTH)
{
fprintf(stderr,"Wrong myisam_block_length\n");
exit(1);
}
myisam_block_size=1 << my_bit_log2(myisam_block_size);
break;
case 'E': /* myisam_block_length */
if ((key_cache_block_size=atoi(++pos)) < MI_MIN_KEY_BLOCK_LENGTH ||
key_cache_block_size > MI_MAX_KEY_BLOCK_LENGTH)
{
fprintf(stderr,"Wrong key_cache_block_size\n");
exit(1);
}
key_cache_block_size=1 << my_bit_log2(key_cache_block_size);
break; break;
case 'f': case 'f':
if ((first_key=atoi(++pos)) < 0 || first_key >= MYISAM_KEYS) if ((first_key=atoi(++pos)) < 0 || first_key >= MYISAM_KEYS)
@ -904,7 +934,7 @@ static void get_options(int argc, char **argv)
case 'V': case 'V':
printf("%s Ver 1.2 for %s at %s\n",progname,SYSTEM_TYPE,MACHINE_TYPE); printf("%s Ver 1.2 for %s at %s\n",progname,SYSTEM_TYPE,MACHINE_TYPE);
puts("By Monty, for your professional use\n"); puts("By Monty, for your professional use\n");
printf("Usage: %s [-?AbBcDIKLPRqSsVWltv] [-k#] [-f#] [-m#] [-t#]\n", printf("Usage: %s [-?AbBcDIKLPRqSsVWltv] [-k#] [-f#] [-m#] [-e#] [-E#] [-t#]\n",
progname); progname);
exit(0); exit(0);
case '#': case '#':

View file

@ -1,48 +1,50 @@
Maximum memory usage: 545477 bytes (533k) mi_test2 -s -L -K -R1 -m2000 ; Should give error 135
Maximum memory usage: 545477 bytes (533k)
Maximum memory usage: 545369 bytes (533k)
mi_test2-i686 -s -L -K -R1 -m2000 ; Should give error 135
Error: 135 in write at record: 1105 Error: 135 in write at record: 1105
got error: 135 when using MyISAM-database got error: 135 when using MyISAM-database
Maximum memory usage: 29439 bytes (29k) myisamchk: MyISAM file test2
Maximum memory usage: 66541 bytes (65k) myisamchk: warning: Datafile is almost full, 65532 of 65534 used
Maximum memory usage: 5101 bytes (5k) MyISAM-table 'test2' is usable but should be fixed
Maximum memory usage: 545488 bytes (533k)
Commands Used count Errors Recover errors Commands Used count Errors Recover errors
open 1 0 0 open 17 0 0
write 50 0 0 write 850 0 0
update 5 0 0 update 85 0 0
delete 50 0 0 delete 850 0 0
close 1 0 0 close 17 0 0
extra 6 0 0 extra 102 0 0
Total 113 0 0 Total 1921 0 0
Maximum memory usage: 545744 bytes (533k)
Commands Used count Errors Recover errors Commands Used count Errors Recover errors
open 2 0 0 open 18 0 0
write 100 0 0 write 900 0 0
update 10 0 0 update 90 0 0
delete 100 0 0 delete 900 0 0
close 2 0 0 close 18 0 0
extra 12 0 0 extra 108 0 0
Total 226 0 0 Total 2034 0 0
Maximum memory usage: 5101 bytes (5k)
1.12user 0.52system 0:01.71elapsed 95%CPU (0avgtext+0avgdata 0maxresident)k real 0m1.054s
0inputs+0outputs (214major+25minor)pagefaults 0swaps user 0m0.410s
Maximum memory usage: 21189 bytes (21k) sys 0m0.640s
1.29user 0.55system 0:01.82elapsed 101%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (215major+29minor)pagefaults 0swaps real 0m1.077s
Maximum memory usage: 66541 bytes (65k) user 0m0.550s
1.10user 0.51system 0:01.66elapsed 96%CPU (0avgtext+0avgdata 0maxresident)k sys 0m0.530s
0inputs+0outputs (216major+40minor)pagefaults 0swaps
Maximum memory usage: 82629 bytes (81k) real 0m1.100s
1.33user 0.24system 0:01.54elapsed 101%CPU (0avgtext+0avgdata 0maxresident)k user 0m0.420s
0inputs+0outputs (216major+44minor)pagefaults 0swaps sys 0m0.680s
Maximum memory usage: 545477 bytes (533k)
1.31user 0.24system 0:01.55elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k real 0m0.783s
0inputs+0outputs (216major+173minor)pagefaults 0swaps user 0m0.590s
Maximum memory usage: 545389 bytes (533k) sys 0m0.200s
1.37user 0.18system 0:01.57elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (218major+180minor)pagefaults 0swaps real 0m0.764s
Maximum memory usage: 109165 bytes (107k) user 0m0.560s
1.42user 0.38system 0:01.78elapsed 101%CPU (0avgtext+0avgdata 0maxresident)k sys 0m0.210s
0inputs+0outputs (218major+51minor)pagefaults 0swaps
real 0m0.699s
user 0m0.570s
sys 0m0.130s
real 0m0.991s
user 0m0.630s
sys 0m0.350s

View file

@ -66,6 +66,14 @@ myisamchk$suffix -rs test1
myisamchk$suffix -se test1 myisamchk$suffix -se test1
myisamchk$suffix -rqs test1 myisamchk$suffix -rqs test1
myisamchk$suffix -se test1 myisamchk$suffix -se test1
myisamchk$suffix -rs --correct-checksum test1
myisamchk$suffix -se test1
myisamchk$suffix -rqs --correct-checksum test1
myisamchk$suffix -se test1
myisamchk$suffix -ros --correct-checksum test1
myisamchk$suffix -se test1
myisamchk$suffix -rqos --correct-checksum test1
myisamchk$suffix -se test1
# check of myisampack / myisamchk # check of myisampack / myisamchk
myisampack$suffix --force -s test1 myisampack$suffix --force -s test1
@ -105,13 +113,25 @@ mi_test1$suffix $silent --key_multiple -P -S
myisamchk$suffix -sm test1 myisamchk$suffix -sm test1
mi_test2$suffix $silent -L -K -W -P mi_test2$suffix $silent -L -K -W -P
myisamchk$suffix -sm test2
mi_test2$suffix $silent -L -K -W -P -A mi_test2$suffix $silent -L -K -W -P -A
myisamchk$suffix -sm test2
mi_test2$suffix $silent -L -K -W -P -S -R1 -m500 mi_test2$suffix $silent -L -K -W -P -S -R1 -m500
echo "mi_test2$suffix $silent -L -K -R1 -m2000 ; Should give error 135" echo "mi_test2$suffix $silent -L -K -R1 -m2000 ; Should give error 135"
myisamchk$suffix -sm test2
mi_test2$suffix $silent -L -K -R1 -m2000 mi_test2$suffix $silent -L -K -R1 -m2000
myisamchk$suffix -sm test2
mi_test2$suffix $silent -L -K -P -S -R3 -m50 -b1000000 mi_test2$suffix $silent -L -K -P -S -R3 -m50 -b1000000
myisamchk$suffix -sm test2
mi_test2$suffix $silent -L -B mi_test2$suffix $silent -L -B
myisamchk$suffix -sm test2
mi_test2$suffix $silent -D -B -c mi_test2$suffix $silent -D -B -c
myisamchk$suffix -sm test2
mi_test2$suffix $silent -m10000 -e8192 -K
myisamchk$suffix -sm test2
mi_test2$suffix $silent -m10000 -e16384 -E16384 -K -L
myisamchk$suffix -sm test2
mi_test2$suffix $silent -L -K -W -P -m50 -l mi_test2$suffix $silent -L -K -W -P -m50 -l
myisamlog$suffix myisamlog$suffix
mi_test2$suffix $silent -L -K -W -P -m50 -l -b100 mi_test2$suffix $silent -L -K -W -P -m50 -l -b100

View file

@ -291,7 +291,7 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
my_bool insert_last) my_bool insert_last)
{ {
int error,flag; int error,flag;
uint comp_flag,nod_flag; uint comp_flag,nod_flag, search_key_length;
uchar *temp_buff,*keypos; uchar *temp_buff,*keypos;
uchar keybuff[MI_MAX_KEY_BUFF]; uchar keybuff[MI_MAX_KEY_BUFF];
my_bool was_last_key; my_bool was_last_key;
@ -299,10 +299,14 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
DBUG_ENTER("w_search"); DBUG_ENTER("w_search");
DBUG_PRINT("enter",("page: %ld",page)); DBUG_PRINT("enter",("page: %ld",page));
search_key_length=USE_WHOLE_KEY;
if (keyinfo->flag & HA_SORT_ALLOWS_SAME) if (keyinfo->flag & HA_SORT_ALLOWS_SAME)
comp_flag=SEARCH_BIGGER; /* Put after same key */ comp_flag=SEARCH_BIGGER; /* Put after same key */
else if (keyinfo->flag & HA_NOSAME) else if (keyinfo->flag & HA_NOSAME)
{
comp_flag=SEARCH_FIND | SEARCH_UPDATE; /* No dupplicates */ comp_flag=SEARCH_FIND | SEARCH_UPDATE; /* No dupplicates */
search_key_length= key_length;
}
else else
comp_flag=SEARCH_SAME; /* Keys in rec-pos order */ comp_flag=SEARCH_SAME; /* Keys in rec-pos order */
@ -312,8 +316,8 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
if (!_mi_fetch_keypage(info,keyinfo,page,temp_buff,0)) if (!_mi_fetch_keypage(info,keyinfo,page,temp_buff,0))
goto err; goto err;
flag=(*keyinfo->bin_search)(info,keyinfo,temp_buff,key,key_length,comp_flag, flag=(*keyinfo->bin_search)(info,keyinfo,temp_buff,key,search_key_length,
&keypos, keybuff, &was_last_key); comp_flag, &keypos, keybuff, &was_last_key);
nod_flag=mi_test_if_nod(temp_buff); nod_flag=mi_test_if_nod(temp_buff);
if (flag == 0) if (flag == 0)
{ {

View file

@ -40,6 +40,7 @@ static char **default_argv;
static const char *load_default_groups[]= { "myisamchk", 0 }; static const char *load_default_groups[]= { "myisamchk", 0 };
static const char *set_charset_name; static const char *set_charset_name;
static CHARSET_INFO *set_charset; static CHARSET_INFO *set_charset;
static long opt_myisam_block_size;
static const char *type_names[]= static const char *type_names[]=
{ "?","char","binary", "short", "long", "float", { "?","char","binary", "short", "long", "float",
@ -141,6 +142,9 @@ int main(int argc, char **argv)
static CHANGEABLE_VAR changeable_vars[] = { static CHANGEABLE_VAR changeable_vars[] = {
{ "key_buffer_size",(long*) &check_param.use_buffers,(long) USE_BUFFER_INIT, { "key_buffer_size",(long*) &check_param.use_buffers,(long) USE_BUFFER_INIT,
(long) MALLOC_OVERHEAD, (long) ~0L,(long) MALLOC_OVERHEAD,(long) IO_SIZE }, (long) MALLOC_OVERHEAD, (long) ~0L,(long) MALLOC_OVERHEAD,(long) IO_SIZE },
{ "myisam_block_size", (long*) &opt_myisam_block_size,
MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, MI_MAX_KEY_BLOCK_LENGTH,
0, MI_MIN_KEY_BLOCK_LENGTH },
{ "read_buffer_size", (long*) &check_param.read_buffer_length,(long) READ_BUFFER_INIT, { "read_buffer_size", (long*) &check_param.read_buffer_length,(long) READ_BUFFER_INIT,
(long) MALLOC_OVERHEAD,(long) ~0L,(long) MALLOC_OVERHEAD,(long) 1L }, (long) MALLOC_OVERHEAD,(long) ~0L,(long) MALLOC_OVERHEAD,(long) 1L },
{ "write_buffer_size", (long*) &check_param.write_buffer_length,(long) READ_BUFFER_INIT, { "write_buffer_size", (long*) &check_param.write_buffer_length,(long) READ_BUFFER_INIT,
@ -159,7 +163,10 @@ static CHANGEABLE_VAR changeable_vars[] = {
20, 4, HA_FT_MAXLEN, 0, 1 }, 20, 4, HA_FT_MAXLEN, 0, 1 },
{ NullS,(long*) 0,0L,0L,0L,0L,0L,} }; { NullS,(long*) 0,0L,0L,0L,0L,0L,} };
enum options {OPT_CHARSETS_DIR=256, OPT_SET_CHARSET,OPT_START_CHECK_POS}; enum options {
OPT_CHARSETS_DIR=256, OPT_SET_CHARSET,OPT_START_CHECK_POS,
OPT_CORRECT_CHECKSUM
};
static struct option long_options[] = static struct option long_options[] =
@ -170,6 +177,7 @@ static struct option long_options[] =
{"character-sets-dir",required_argument,0, OPT_CHARSETS_DIR}, {"character-sets-dir",required_argument,0, OPT_CHARSETS_DIR},
{"check", no_argument, 0, 'c'}, {"check", no_argument, 0, 'c'},
{"check-only-changed",no_argument, 0, 'C'}, {"check-only-changed",no_argument, 0, 'C'},
{"correct-checksum", no_argument, 0, OPT_CORRECT_CHECKSUM},
#ifndef DBUG_OFF #ifndef DBUG_OFF
{"debug", optional_argument, 0, '#'}, {"debug", optional_argument, 0, '#'},
#endif #endif
@ -205,7 +213,7 @@ static struct option long_options[] =
static void print_version(void) static void print_version(void)
{ {
printf("%s Ver 1.51 for %s at %s\n",my_progname,SYSTEM_TYPE, printf("%s Ver 1.52 for %s at %s\n",my_progname,SYSTEM_TYPE,
MACHINE_TYPE); MACHINE_TYPE);
} }
@ -248,6 +256,7 @@ static void usage(void)
puts("Repair options (When using -r or -o) \n\ puts("Repair options (When using -r or -o) \n\
-B, --backup Make a backup of the .MYD file as 'filename-time.BAK'\n\ -B, --backup Make a backup of the .MYD file as 'filename-time.BAK'\n\
--correct-checksum Correct checksum information for table. \n\
-D, --data-file-length=# Max length of data file (when recreating data\n\ -D, --data-file-length=# Max length of data file (when recreating data\n\
file when it's full)\n\ file when it's full)\n\
-e, --extend-check Try to recover every possible row from the data file\n\ -e, --extend-check Try to recover every possible row from the data file\n\
@ -433,6 +442,9 @@ static void get_options(register int *argc,register char ***argv)
case 'V': case 'V':
print_version(); print_version();
exit(0); exit(0);
case OPT_CORRECT_CHECKSUM:
check_param.testflag|=T_CALC_CHECKSUM;
break;
case OPT_CHARSETS_DIR: case OPT_CHARSETS_DIR:
charsets_dir = optarg; charsets_dir = optarg;
break; break;
@ -449,6 +461,11 @@ static void get_options(register int *argc,register char ***argv)
exit(0); exit(0);
} }
} }
/* If using repair, then update checksum if one uses --update-state */
if ((check_param.testflag & T_UPDATE_STATE) &&
(check_param.testflag & (T_REP | T_REP_BY_SORT)))
check_param.testflag|= T_CALC_CHECKSUM;
(*argc)-=optind; (*argc)-=optind;
(*argv)+=optind; (*argv)+=optind;
if (*argc == 0) if (*argc == 0)
@ -456,6 +473,7 @@ static void get_options(register int *argc,register char ***argv)
usage(); usage();
exit(-1); exit(-1);
} }
if ((check_param.testflag & T_UNPACK) && if ((check_param.testflag & T_UNPACK) &&
(check_param.opt_rep_quick || (check_param.testflag & T_SORT_RECORDS))) (check_param.opt_rep_quick || (check_param.testflag & T_SORT_RECORDS)))
{ {
@ -479,6 +497,7 @@ static void get_options(register int *argc,register char ***argv)
if (!(set_charset=get_charset_by_name(set_charset_name, MYF(MY_WME)))) if (!(set_charset=get_charset_by_name(set_charset_name, MYF(MY_WME))))
exit(1); exit(1);
myisam_block_size=(uint) 1 << my_bit_log2(opt_myisam_block_size);
return; return;
} /* get options */ } /* get options */
@ -605,7 +624,8 @@ static int myisamchk(MI_CHECK *param, my_string filename)
(((ulonglong) 1L << share->base.keys)-1)) || (((ulonglong) 1L << share->base.keys)-1)) ||
test_if_almost_full(info) || test_if_almost_full(info) ||
info->s->state.header.file_version[3] != myisam_file_magic[3] || info->s->state.header.file_version[3] != myisam_file_magic[3] ||
(set_charset && set_charset->number != share->state.header.language))) (set_charset && set_charset->number != share->state.header.language) ||
myisam_block_size != MI_KEY_BLOCK_LENGTH))
{ {
if (set_charset) if (set_charset)
check_param.language=set_charset->number; check_param.language=set_charset->number;

View file

@ -173,7 +173,7 @@ typedef struct st_mi_isam_share { /* Shared between opens */
File data_file; /* Shared data file */ File data_file; /* Shared data file */
int mode; /* mode of file on open */ int mode; /* mode of file on open */
uint reopen; /* How many times reopened */ uint reopen; /* How many times reopened */
uint w_locks,r_locks; /* Number of read/write locks */ uint w_locks,r_locks,tot_locks; /* Number of read/write locks */
uint blocksize; /* blocksize of keyfile */ uint blocksize; /* blocksize of keyfile */
ulong min_pack_length; /* Theese are used by packed data */ ulong min_pack_length; /* Theese are used by packed data */
ulong max_pack_length; ulong max_pack_length;
@ -365,10 +365,8 @@ struct st_myisam_info {
#define PACK_TYPE_ZERO_FILL 4 #define PACK_TYPE_ZERO_FILL 4
#define MI_FOUND_WRONG_KEY 32738 /* Impossible value from _mi_key_cmp */ #define MI_FOUND_WRONG_KEY 32738 /* Impossible value from _mi_key_cmp */
#define MI_KEY_BLOCK_LENGTH 1024 /* Min key block length */ #define MI_MAX_KEY_BLOCK_SIZE (MI_MAX_KEY_BLOCK_LENGTH/MI_MIN_KEY_BLOCK_LENGTH)
#define MI_MAX_KEY_BLOCK_LENGTH 8192 #define MI_BLOCK_SIZE(key_length,data_pointer,key_pointer) ((((key_length+data_pointer+key_pointer)*4+key_pointer+2)/myisam_block_size+1)*myisam_block_size)
#define MI_MAX_KEY_BLOCK_SIZE (MI_MAX_KEY_BLOCK_LENGTH/MI_KEY_BLOCK_LENGTH)
#define MI_BLOCK_SIZE(key_length,data_pointer,key_pointer) ((((key_length+data_pointer+key_pointer)*4+key_pointer+2)/MI_KEY_BLOCK_LENGTH+1)*MI_KEY_BLOCK_LENGTH)
#define MI_MAX_KEYPTR_SIZE 5 /* For calculating block lengths */ #define MI_MAX_KEYPTR_SIZE 5 /* For calculating block lengths */
#define MI_MIN_KEYBLOCK_LENGTH 50 /* When to split delete blocks */ #define MI_MIN_KEYBLOCK_LENGTH 50 /* When to split delete blocks */
@ -589,6 +587,9 @@ enum myisam_log_commands {
#define myisam_log_command(a,b,c,d,e) if (myisam_log_file >= 0) _myisam_log_command(a,b,c,d,e) #define myisam_log_command(a,b,c,d,e) if (myisam_log_file >= 0) _myisam_log_command(a,b,c,d,e)
#define myisam_log_record(a,b,c,d,e) if (myisam_log_file >= 0) _myisam_log_record(a,b,c,d,e) #define myisam_log_record(a,b,c,d,e) if (myisam_log_file >= 0) _myisam_log_record(a,b,c,d,e)
#define fast_mi_writeinfo(INFO) if (!(INFO)->s->tot_locks) (void) _mi_writeinfo((INFO),0)
#define fast_mi_readinfo(INFO) (!(INFO)->lock_type == F_UNLCK) && _mi_readinfo((INFO),F_RDLCK,1)
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View file

@ -54,7 +54,7 @@ int myrg_create(const char *name, const char **table_names,
if (insert_method != MERGE_INSERT_DISABLED) if (insert_method != MERGE_INSERT_DISABLED)
{ {
end=strxmov(buff,"#INSERT_METHOD=", end=strxmov(buff,"#INSERT_METHOD=",
get_type(&merge_insert_method,insert_method),"\n",NullS); get_type(&merge_insert_method,insert_method-1),"\n",NullS);
if (my_write(file,buff,(uint) (end-buff),MYF(MY_WME | MY_NABP))) if (my_write(file,buff,(uint) (end-buff),MYF(MY_WME | MY_NABP)))
goto err; goto err;
} }

View file

@ -26,5 +26,5 @@
LIST *myrg_open_list=0; LIST *myrg_open_list=0;
static const char *merge_insert_methods[] = static const char *merge_insert_methods[] =
{ "FIRST", "LAST", NullS }; { "FIRST", "LAST", NullS };
TYPELIB merge_insert_method= { array_elements(merge_insert_methods),"", TYPELIB merge_insert_method= { array_elements(merge_insert_methods)-1,"",
merge_insert_methods}; merge_insert_methods};

View file

@ -134,7 +134,7 @@ then
c_u="$c_u References_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_u="$c_u References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Index_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_u="$c_u Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_u="$c_u Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u ssl_type enum('none', 'cipher', 'x509','issuer','subject') NOT NULL," c_u="$c_u ssl_type enum('NONE','ANY', 'X509', 'SPECIFIED') NOT NULL,"
c_u="$c_u ssl_cipher char(60) NULL," c_u="$c_u ssl_cipher char(60) NULL,"
c_u="$c_u x509_issuer blob NULL," c_u="$c_u x509_issuer blob NULL,"
c_u="$c_u x509_subject blob NULL," c_u="$c_u x509_subject blob NULL,"

View file

@ -114,6 +114,11 @@ SLAVE_LOAD_TMPDIR=../../var/tmp #needs to be same length to test logging
RES_SPACE=" " RES_SPACE=" "
MYSQLD_SRC_DIRS="strings mysys include extra regex isam merge myisam \ MYSQLD_SRC_DIRS="strings mysys include extra regex isam merge myisam \
myisammrg heap sql" myisammrg heap sql"
#
# Set LD_LIBRARY_PATH if we are using shared libraries
#
LD_LIBRARY_PATH="$BASEDIR/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH
MASTER_RUNNING=0 MASTER_RUNNING=0
MASTER_MYPORT=9306 MASTER_MYPORT=9306
@ -367,7 +372,7 @@ prompt_user ()
read unused read unused
} }
# We can't use diff -u as this isn't portable # We can't use diff -u or diff -a as these are not portable
show_failed_diff () show_failed_diff ()
{ {
@ -384,7 +389,7 @@ show_failed_diff ()
then then
echo "Below are the diffs between actual and expected results:" echo "Below are the diffs between actual and expected results:"
echo "-------------------------------------------------------" echo "-------------------------------------------------------"
$DIFF -c -a $result_file $reject_file $DIFF -c $result_file $reject_file
echo "-------------------------------------------------------" echo "-------------------------------------------------------"
echo "Please follow the instructions outlined at" echo "Please follow the instructions outlined at"
echo "http://www.mysql.com/doc/R/e/Reporting_mysqltest_bugs.html" echo "http://www.mysql.com/doc/R/e/Reporting_mysqltest_bugs.html"
@ -666,12 +671,12 @@ start_slave()
--exit-info=256 \ --exit-info=256 \
--log-bin=$MYSQL_TEST_DIR/var/log/slave-bin \ --log-bin=$MYSQL_TEST_DIR/var/log/slave-bin \
--log-slave-updates \ --log-slave-updates \
--log=$SLAVE_MYLOG \
--basedir=$MY_BASEDIR \ --basedir=$MY_BASEDIR \
--datadir=$SLAVE_MYDDIR \ --datadir=$SLAVE_MYDDIR \
--pid-file=$SLAVE_MYPID \ --pid-file=$SLAVE_MYPID \
--port=$SLAVE_MYPORT \ --port=$SLAVE_MYPORT \
--socket=$SLAVE_MYSOCK \ --socket=$SLAVE_MYSOCK \
--log=$SLAVE_MYLOG \
--character-sets-dir=$CHARSETSDIR \ --character-sets-dir=$CHARSETSDIR \
--default-character-set=$CHARACTER_SET \ --default-character-set=$CHARACTER_SET \
--core \ --core \
@ -681,6 +686,7 @@ start_slave()
--slave-load-tmpdir=$SLAVE_LOAD_TMPDIR \ --slave-load-tmpdir=$SLAVE_LOAD_TMPDIR \
--report-host=127.0.0.1 --report-user=root \ --report-host=127.0.0.1 --report-user=root \
--report-port=$SLAVE_MYPORT \ --report-port=$SLAVE_MYPORT \
--master-retry-count=5 \
$SMALL_SERVER \ $SMALL_SERVER \
$EXTRA_SLAVE_OPT $EXTRA_SLAVE_MYSQLD_OPT" $EXTRA_SLAVE_OPT $EXTRA_SLAVE_MYSQLD_OPT"
CUR_MYERR=$SLAVE_MYERR CUR_MYERR=$SLAVE_MYERR

View file

@ -229,7 +229,7 @@ drop table t2;
create table t2 (primary key (auto)) select auto+1 as auto,1 as t1, "a" as t2, repeat("a",256) as t3, binary repeat("b",256) as t4 from t1; create table t2 (primary key (auto)) select auto+1 as auto,1 as t1, "a" as t2, repeat("a",256) as t3, binary repeat("b",256) as t4 from t1;
show full columns from t2; show full columns from t2;
Field Type Null Key Default Extra Privileges Field Type Null Key Default Extra Privileges
auto bigint(17) PRI 0 select,insert,update,references auto bigint(17) unsigned PRI 0 select,insert,update,references
t1 bigint(1) 0 select,insert,update,references t1 bigint(1) 0 select,insert,update,references
t2 char(1) select,insert,update,references t2 char(1) select,insert,update,references
t3 mediumtext select,insert,update,references t3 mediumtext select,insert,update,references

View file

@ -14,3 +14,18 @@ select * from t1 where a='18446744073709551615';
delete from t1 where a=18446744073709551615; delete from t1 where a=18446744073709551615;
select * from t1; select * from t1;
drop table t1; drop table t1;
create table t1 ( a int not null default 1, big bigint );
insert into t1 (big) values (-1),(12345678901234567),(9223372036854775807),(18446744073709551615);
select min(big),max(big),max(big)-1 from t1;
select min(big),max(big),max(big)-1 from t1 group by a;
alter table t1 modify big bigint unsigned not null;
select min(big),max(big),max(big)-1 from t1;
select min(big),max(big),max(big)-1 from t1 group by a;
alter table t1 add key (big);
select min(big),max(big),max(big)-1 from t1;
select min(big),max(big),max(big)-1 from t1 group by a;
alter table t1 modify big bigint not null;
select min(big),max(big),max(big)-1 from t1;
select min(big),max(big),max(big)-1 from t1 group by a;
drop table t1;

View file

@ -89,3 +89,26 @@ select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using
--error 1116 --error 1116
select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a); select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a);
drop table t1; drop table t1;
#
# Simple join test. This failed in 3.23.42, there should have been
# no matches, still three matches were found.
#
CREATE TABLE t1 (
a int(11) NOT NULL,
b int(11) NOT NULL,
PRIMARY KEY (a,b)
) TYPE=MyISAM;
INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(2,3);
CREATE TABLE t2 (
a int(11) default NULL
) TYPE=MyISAM;
INSERT INTO t2 VALUES (2),(3);
SELECT t1.a,t2.a,b FROM t1,t2 WHERE t1.a=t2.a AND (t1.a=1 OR t1.a=2) AND b>=1 AND b<=3;
DROP TABLE t1, t2;

View file

@ -2,7 +2,7 @@
# test of MERGE TABLES # test of MERGE TABLES
# #
drop table if exists t1,t2,t3; drop table if exists t1,t2,t3,t4,t5,t6;
create table t1 (a int not null primary key auto_increment, message char(20)); create table t1 (a int not null primary key auto_increment, message char(20));
create table t2 (a int not null primary key auto_increment, message char(20)); create table t2 (a int not null primary key auto_increment, message char(20));
INSERT INTO t1 (message) VALUES ("Testing"),("table"),("t1"); INSERT INTO t1 (message) VALUES ("Testing"),("table"),("t1");
@ -31,6 +31,14 @@ select * from t3 where a > 10 and a < 20;
explain select a from t3 order by a desc limit 10; explain select a from t3 order by a desc limit 10;
select a from t3 order by a desc limit 10; select a from t3 order by a desc limit 10;
select a from t3 order by a desc limit 300,10; select a from t3 order by a desc limit 300,10;
delete from t3 where a=3;
select * from t3 where a < 10;
delete from t3 where a >= 6 and a <= 8;
select * from t3 where a < 10;
update t3 set a=3 where a=9;
select * from t3 where a < 10;
update t3 set a=6 where a=7;
select * from t3 where a < 10;
show create table t3; show create table t3;
# The following should give errors # The following should give errors
@ -114,3 +122,49 @@ insert into t2 values (1,1),(2,2),(0,0),(4,4),(5,5),(6,6);
flush tables; flush tables;
select * from t3 where a=1 order by b limit 2; select * from t3 where a=1 order by b limit 2;
drop table t3,t1,t2; drop table t3,t1,t2;
#
# [phi] testing INSERT_METHOD stuff
#
drop table if exists t6, t5, t4, t3, t2, t1;
# first testing of common stuff with new parameters
create table t1 (a int not null, b int not null, key(a,b));
create table t2 (a int not null, b int not null, key(a,b));
create table t3 (a int not null, b int not null, key(a,b)) UNION=(t1,t2) INSERT_METHOD=NO;
create table t4 (a int not null, b int not null, key(a,b)) TYPE=MERGE UNION=(t1,t2) INSERT_METHOD=NO;
create table t5 (a int not null, b int not null, key(a,b)) TYPE=MERGE UNION=(t1,t2) INSERT_METHOD=FIRST;
create table t6 (a int not null, b int not null, key(a,b)) TYPE=MERGE UNION=(t1,t2) INSERT_METHOD=LAST;
show create table t3;
show create table t4;
show create table t5;
show create table t6;
insert into t1 values (1,1),(1,2),(1,3),(1,4);
insert into t2 values (2,1),(2,2),(2,3),(2,4);
select * from t3 order by b,a limit 3;
select * from t4 order by b,a limit 3;
select * from t5 order by b,a limit 3,3;
select * from t6 order by b,a limit 6,3;
# now testing inserts and where the data gets written
insert into t5 values (5,1),(5,2);
insert into t6 values (6,1),(6,2);
select * from t1 order by a,b;
select * from t2 order by a,b;
select * from t4 order by a,b;
# preperation for next test
insert into t3 values (3,1),(3,2),(3,3),(3,4);
select * from t3 order by a,b;
# now testing whether options are kept by alter table
alter table t4 UNION=(t1,t2,t3);
show create table t4;
select * from t4 order by a,b;
# testing switching off insert method and inserts again
alter table t4 INSERT_METHOD=FIRST;
show create table t4;
insert into t4 values (4,1),(4,2);
select * from t1 order by a,b;
select * from t2 order by a,b;
select * from t3 order by a,b;
select * from t4 order by a,b;
select * from t5 order by a,b;
drop table if exists t6, t5, t4, t3, t2, t1;

View file

@ -11,6 +11,7 @@ use test;
sync_with_master; sync_with_master;
select * from t1; select * from t1;
connection master; connection master;
--replace_result 9307 9999 3350 9999 3351 9999
show slave hosts; show slave hosts;
drop table t1; drop table t1;
save_master_pos; save_master_pos;

View file

@ -3,8 +3,8 @@ master-bin.001
4 4
127.0.0.1 127.0.0.1
replicate replicate
aaaaaaaaaaaaaaab aaaaaaaaaaaaaaabthispartofthepasswordisnotused
9306 $MASTER_MYPORT
1 1
0 0
EOF EOF

View file

@ -79,3 +79,11 @@ create table t1(n int);
insert into t1 values (1); insert into t1 values (1);
show open tables; show open tables;
drop table t1; drop table t1;
create table t1 (a int not null, b VARCHAR(10), INDEX (b) ) AVG_ROW_LENGTH=10 CHECKSUM=1 COMMENT="test" TYPE=MYISAM MIN_ROWS=10 MAX_ROWS=100 PACK_KEYS=1 DELAY_KEY_WRITE=1 ROW_FORMAT=fixed;
show create table t1;
alter table t1 MAX_ROWS=200 ROW_FORMAT=dynamic PACK_KEYS=0;
show create table t1;
ALTER TABLE t1 AVG_ROW_LENGTH=0 CHECKSUM=0 COMMENT="" MIN_ROWS=0 MAX_ROWS=0 PACK_KEYS=DEFAULT DELAY_KEY_WRITE=0 ROW_FORMAT=default;
show create table t1;
drop table t1;

View file

@ -45,7 +45,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\
my_quick.c my_lockmem.c my_static.c \ my_quick.c my_lockmem.c my_static.c \
getopt.c getopt1.c getvar.c my_mkdir.c \ getopt.c getopt1.c getvar.c my_mkdir.c \
default.c my_compress.c checksum.c raid.cc my_net.c \ default.c my_compress.c checksum.c raid.cc my_net.c \
my_vsnprintf.c charset.c my_bitmap.c md5.c my_vsnprintf.c charset.c my_bitmap.c my_bit.c md5.c
EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \ EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
thr_mutex.c thr_rwlock.c thr_mutex.c thr_rwlock.c
libmysys_a_LIBADD = @THREAD_LOBJECTS@ libmysys_a_LIBADD = @THREAD_LOBJECTS@

View file

@ -44,13 +44,6 @@ struct simpleconfig_buf_st {
char *p; char *p;
}; };
/* Defined in strings/ctype.c */
CHARSET_INFO *find_compiled_charset(uint cs_number);
uint compiled_charset_number(const char *name);
const char *compiled_charset_name(uint charset_number);
static uint num_from_csname(CS_ID **cs, const char *name) static uint num_from_csname(CS_ID **cs, const char *name)
{ {
CS_ID **c; CS_ID **c;
@ -264,21 +257,21 @@ static my_bool read_charset_file(uint cs_number, CHARSET_INFO *set,
uint get_charset_number(const char *charset_name) uint get_charset_number(const char *charset_name)
{ {
my_bool error; uint number=compiled_charset_number(charset_name);
error = init_available_charsets(MYF(0)); /* If it isn't initialized */ if (number)
if (error) return number;
return compiled_charset_number(charset_name); if (init_available_charsets(MYF(0))) /* If it isn't initialized */
else return 0;
return num_from_csname(available_charsets, charset_name); return num_from_csname(available_charsets, charset_name);
} }
const char *get_charset_name(uint charset_number) const char *get_charset_name(uint charset_number)
{ {
my_bool error; const char *name=compiled_charset_name(charset_number);
error = init_available_charsets(MYF(0)); /* If it isn't initialized */ if (*name != '?')
if (error) return name;
return compiled_charset_name(charset_number); if (init_available_charsets(MYF(0))) /* If it isn't initialized */
else return "?";
return name_from_csnum(available_charsets, charset_number); return name_from_csnum(available_charsets, charset_number);
} }
@ -293,8 +286,8 @@ static CHARSET_INFO *find_charset(CHARSET_INFO **table, uint cs_number,
return NULL; return NULL;
} }
static CHARSET_INFO *find_charset_by_name(CHARSET_INFO **table, const char *name, static CHARSET_INFO *find_charset_by_name(CHARSET_INFO **table,
size_t tablesz) const char *name, size_t tablesz)
{ {
uint i; uint i;
for (i = 0; i < tablesz; ++i) for (i = 0; i < tablesz; ++i)

View file

@ -53,7 +53,6 @@ typedef struct sec_link {
} SEC_LINK; } SEC_LINK;
static uint find_next_bigger_power(uint value);
static SEC_LINK *find_key_block(int file,my_off_t filepos,int *error); static SEC_LINK *find_key_block(int file,my_off_t filepos,int *error);
/* static variables in this file */ /* static variables in this file */
@ -61,9 +60,11 @@ static SEC_LINK *_my_block_root,**_my_hash_root,
*_my_used_first,*_my_used_last; *_my_used_first,*_my_used_last;
static int _my_disk_blocks; static int _my_disk_blocks;
static uint _my_disk_blocks_used, _my_hash_blocks; static uint _my_disk_blocks_used, _my_hash_blocks;
static uint key_cache_shift;
ulong _my_blocks_used,_my_blocks_changed; ulong _my_blocks_used,_my_blocks_changed;
ulong _my_cache_w_requests,_my_cache_write,_my_cache_r_requests, ulong _my_cache_w_requests,_my_cache_write,_my_cache_r_requests,
_my_cache_read; _my_cache_read;
uint key_cache_block_size=DEFAULT_KEYCACHE_BLOCK_SIZE;
static byte HUGE_PTR *_my_block_mem; static byte HUGE_PTR *_my_block_mem;
static SEC_LINK *changed_blocks[CHANGED_BLOCKS_HASH]; static SEC_LINK *changed_blocks[CHANGED_BLOCKS_HASH];
static SEC_LINK *file_blocks[CHANGED_BLOCKS_HASH]; static SEC_LINK *file_blocks[CHANGED_BLOCKS_HASH];
@ -92,12 +93,16 @@ int init_key_cache(ulong use_mem,
{ {
key_cache_inited=TRUE; key_cache_inited=TRUE;
_my_disk_blocks= -1; _my_disk_blocks= -1;
key_cache_shift=my_bit_log2(key_cache_block_size);
DBUG_PRINT("info",("key_cache_block_size: %u key_cache_shift: %u",
key_cache_block_size, key_cache_shift));
#ifndef DBUG_OFF #ifndef DBUG_OFF
_my_printed=0; _my_printed=0;
#endif #endif
} }
blocks= (uint) (use_mem/(sizeof(SEC_LINK)+sizeof(SEC_LINK*)*5/4+KEYCACHE_BLOCK_SIZE)); blocks= (uint) (use_mem/(sizeof(SEC_LINK)+sizeof(SEC_LINK*)*5/4+
key_cache_block_size));
/* No use to have very few blocks */ /* No use to have very few blocks */
if (blocks >= 8 && _my_disk_blocks < 0) if (blocks >= 8 && _my_disk_blocks < 0)
{ {
@ -107,13 +112,15 @@ int init_key_cache(ulong use_mem,
#endif #endif
for (;;) for (;;)
{ {
if ((_my_hash_blocks=find_next_bigger_power((uint) blocks)) < blocks*5/4) /* Set my_hash_blocks to the next bigger 2 power */
_my_hash_blocks<<=1; _my_hash_blocks=(uint) 1 << (my_bit_log2(blocks*5/4)+1);
while ((length=(uint) blocks*sizeof(SEC_LINK)+ while ((length=(uint) blocks*sizeof(SEC_LINK)+
sizeof(SEC_LINK*)*_my_hash_blocks)+(ulong) blocks*KEYCACHE_BLOCK_SIZE > sizeof(SEC_LINK*)*_my_hash_blocks)+
((ulong) blocks << key_cache_shift) >
use_mem) use_mem)
blocks--; blocks--;
if ((_my_block_mem=my_malloc_lock((ulong) blocks * KEYCACHE_BLOCK_SIZE,MYF(0)))) if ((_my_block_mem=my_malloc_lock((ulong) blocks << key_cache_shift,
MYF(0))))
{ {
if ((_my_block_root=(SEC_LINK*) my_malloc((uint) length,MYF(0))) != 0) if ((_my_block_root=(SEC_LINK*) my_malloc((uint) length,MYF(0))) != 0)
break; break;
@ -170,17 +177,6 @@ void end_key_cache(void)
} /* end_key_cache */ } /* end_key_cache */
static uint find_next_bigger_power(uint value)
{
uint old_value=1;
while (value)
{
old_value=value;
value&= value-1;
}
return (old_value << 1);
}
static inline void link_into_file_blocks(SEC_LINK *next, int file) static inline void link_into_file_blocks(SEC_LINK *next, int file)
{ {
reg1 SEC_LINK **ptr= &file_blocks[(uint) file & CHANGED_BLOCKS_MASK]; reg1 SEC_LINK **ptr= &file_blocks[(uint) file & CHANGED_BLOCKS_MASK];
@ -243,7 +239,7 @@ static void test_key_cache(const char *where, my_bool lock);
/* /*
** read a key_buffer ** read a key_buffer
** filepos must point at a even KEYCACHE_BLOCK_SIZE block ** filepos must point at a even key_cache_block_size block
** if return_buffer is set then the intern buffer is returned if ** if return_buffer is set then the intern buffer is returned if
** it can be used ** it can be used
** Returns adress to where data is read ** Returns adress to where data is read
@ -257,7 +253,7 @@ byte *key_cache_read(File file, my_off_t filepos, byte *buff, uint length,
int error=0; int error=0;
#ifndef THREAD #ifndef THREAD
if (block_length > KEYCACHE_BLOCK_SIZE) if (block_length > key_cache_block_size)
return_buffer=0; return_buffer=0;
#endif #endif
if (_my_disk_blocks > 0) if (_my_disk_blocks > 0)
@ -268,7 +264,8 @@ byte *key_cache_read(File file, my_off_t filepos, byte *buff, uint length,
do do
{ {
_my_cache_r_requests++; _my_cache_r_requests++;
read_length= length > KEYCACHE_BLOCK_SIZE ? KEYCACHE_BLOCK_SIZE : length; read_length= (length > key_cache_block_size ? key_cache_block_size :
length);
if (!(next=find_key_block(file,filepos,&error))) if (!(next=find_key_block(file,filepos,&error)))
{ {
pthread_mutex_unlock(&THR_LOCK_keycache); pthread_mutex_unlock(&THR_LOCK_keycache);
@ -310,7 +307,7 @@ byte *key_cache_read(File file, my_off_t filepos, byte *buff, uint length,
/* write a key_buffer */ /* write a key_buffer */
/* We don't have to use pwrite because of write locking */ /* We don't have to use pwrite because of write locking */
/* buff must point at a even KEYCACHE_BLOCK_SIZE block */ /* buff must point at a even key_cache_block_size block */
int key_cache_write(File file, my_off_t filepos, byte *buff, uint length, int key_cache_write(File file, my_off_t filepos, byte *buff, uint length,
uint block_length __attribute__((unused)), uint block_length __attribute__((unused)),
@ -336,7 +333,7 @@ int key_cache_write(File file, my_off_t filepos, byte *buff, uint length,
_my_cache_w_requests++; _my_cache_w_requests++;
do do
{ {
read_length= length > KEYCACHE_BLOCK_SIZE ? KEYCACHE_BLOCK_SIZE : length; read_length= length > key_cache_block_size ? key_cache_block_size : length;
if (!(next=find_key_block(file,filepos,&error))) if (!(next=find_key_block(file,filepos,&error)))
goto end; /* Fatal error */ goto end; /* Fatal error */
if (!dont_write) /* If we wrote buff at start */ if (!dont_write) /* If we wrote buff at start */
@ -385,7 +382,7 @@ static SEC_LINK *find_key_block(int file, my_off_t filepos, int *error)
#endif #endif
*error=0; *error=0;
next= *(start= &_my_hash_root[((ulong) (filepos/KEYCACHE_BLOCK_SIZE)+(ulong) file) & next= *(start= &_my_hash_root[((ulong) (filepos >> key_cache_shift)+(ulong) file) &
(_my_hash_blocks-1)]); (_my_hash_blocks-1)]);
while (next && (next->diskpos != filepos || next->file != file)) while (next && (next->diskpos != filepos || next->file != file))
next= next->next_hash; next= next->next_hash;
@ -411,7 +408,8 @@ static SEC_LINK *find_key_block(int file, my_off_t filepos, int *error)
{ /* There are unused blocks */ { /* There are unused blocks */
next= &_my_block_root[_my_blocks_used++]; /* Link in hash-chain */ next= &_my_block_root[_my_blocks_used++]; /* Link in hash-chain */
next->buffer=ADD_TO_PTR(_my_block_mem, next->buffer=ADD_TO_PTR(_my_block_mem,
(ulong) _my_disk_blocks_used*KEYCACHE_BLOCK_SIZE,byte*); ((ulong) _my_disk_blocks_used << key_cache_shift),
byte*);
/* link first in file_blocks */ /* link first in file_blocks */
next->changed=0; next->changed=0;
link_into_file_blocks(next,file); link_into_file_blocks(next,file);
@ -426,7 +424,8 @@ static SEC_LINK *find_key_block(int file, my_off_t filepos, int *error)
next= _my_used_first; next= _my_used_first;
if (next->changed) if (next->changed)
{ {
if (my_pwrite(next->file,next->buffer,KEYCACHE_BLOCK_SIZE,next->diskpos, if (my_pwrite(next->file,next->buffer,key_cache_block_size,
next->diskpos,
MYF(MY_NABP | MY_WAIT_IF_FULL))) MYF(MY_NABP | MY_WAIT_IF_FULL)))
{ {
*error=1; *error=1;
@ -505,7 +504,8 @@ static int flush_cached_blocks(File file, SEC_LINK **cache, uint count)
qsort((byte*) cache, count, sizeof(*cache), (qsort_cmp) cmp_sec_link); qsort((byte*) cache, count, sizeof(*cache), (qsort_cmp) cmp_sec_link);
for ( ; count-- ; cache++) for ( ; count-- ; cache++)
{ {
if (my_pwrite(file,(*cache)->buffer,KEYCACHE_BLOCK_SIZE,(*cache)->diskpos, if (my_pwrite(file,(*cache)->buffer,key_cache_block_size,
(*cache)->diskpos,
MYF(MY_NABP | MY_WAIT_IF_FULL))) MYF(MY_NABP | MY_WAIT_IF_FULL)))
{ {
if (!last_errno) if (!last_errno)
@ -646,7 +646,7 @@ static void test_key_cache(const char *where, my_bool lock)
i,(ulong) pos,(ulong) prev,(ulong) pos->prev_hash)); i,(ulong) pos,(ulong) prev,(ulong) pos->prev_hash));
} }
if (((pos->diskpos/KEYCACHE_BLOCK_SIZE)+pos->file) % _my_hash_blocks != i) if (((pos->diskpos >> key_cache_shift)+pos->file) % _my_hash_blocks != i)
{ {
DBUG_PRINT("error",("hash: %d pos: %lx : Wrong disk_buffer %ld", DBUG_PRINT("error",("hash: %d pos: %lx : Wrong disk_buffer %ld",
i,(ulong) pos,(ulong) pos->diskpos)); i,(ulong) pos,(ulong) pos->diskpos));

32
mysys/my_bit.c Normal file
View file

@ -0,0 +1,32 @@
/* 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 */
/* Some useful bit functions */
#include "mysys_priv.h"
/*
Find smallest X in 2^X >= value
This can be used to divide a number with value by doing a shift instead
*/
uint my_bit_log2(ulong value)
{
uint bit;
for (bit=0 ; value > 1 ; value>>=1, bit++) ;
return bit;
}

View file

@ -45,9 +45,8 @@ static my_bool win32_init_tcp_ip();
#else #else
#define my_win_init() #define my_win_init()
#endif #endif
static my_bool my_init_done=0;
my_bool my_init_done=0;
static ulong atoi_octal(const char *str) static ulong atoi_octal(const char *str)
{ {

View file

@ -75,8 +75,8 @@ int my_close(File fd, myf MyFlags)
pthread_mutex_destroy(&my_file_info[fd].mutex); pthread_mutex_destroy(&my_file_info[fd].mutex);
#endif #endif
my_file_info[fd].type = UNOPEN; my_file_info[fd].type = UNOPEN;
my_file_opened--;
} }
my_file_opened--;
pthread_mutex_unlock(&THR_LOCK_open); pthread_mutex_unlock(&THR_LOCK_open);
DBUG_RETURN(err); DBUG_RETURN(err);
} /* my_close */ } /* my_close */
@ -96,9 +96,8 @@ File my_register_filename(File fd, const char *FileName, enum file_type
my_error(EE_OUT_OF_FILERESOURCES, MYF(ME_BELL+ME_WAITTANG), my_error(EE_OUT_OF_FILERESOURCES, MYF(ME_BELL+ME_WAITTANG),
FileName, my_errno); FileName, my_errno);
return(-1); return(-1);
#else
thread_safe_increment(my_file_opened,&THR_LOCK_open);
#endif #endif
thread_safe_increment(my_file_opened,&THR_LOCK_open);
return(fd); /* safeguard */ return(fd); /* safeguard */
} }
pthread_mutex_lock(&THR_LOCK_open); pthread_mutex_lock(&THR_LOCK_open);

View file

@ -84,7 +84,8 @@ int find_type(my_string x, TYPELIB *typelib, uint full_name)
/* Get name of type nr 'nr' */ /* Get name of type nr 'nr' */
/* Warning first type is 1, 0 = empty field */ /* Warning first type is 1, 0 = empty field */
void make_type(register my_string to, register uint nr, register TYPELIB *typelib) void make_type(register my_string to, register uint nr,
register TYPELIB *typelib)
{ {
DBUG_ENTER("make_type"); DBUG_ENTER("make_type");
if (!nr) if (!nr)

View file

@ -76,4 +76,8 @@
#endif /* !__STDC__ */ #endif /* !__STDC__ */
#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
#define __attribute__(A)
#endif
#endif /* !_RL_STDC_H_ */ #endif /* !_RL_STDC_H_ */

View file

@ -3,8 +3,8 @@
echo "This scripts updates the mysql.user, mysql.db, mysql.host and the" echo "This scripts updates the mysql.user, mysql.db, mysql.host and the"
echo "mysql.func table to MySQL 3.22.14 and above." echo "mysql.func table to MySQL 3.22.14 and above."
echo "" echo ""
echo "This is needed if you want to use the new GRANT functions or" echo "This is needed if you want to use the new GRANT functions,"
echo "want to use the more secure passwords." echo "CREATE AGGREAGATE FUNCTION or want to use the more secure passwords in 3.23"
echo "" echo ""
echo "If you get Access denied errors, you should run this script again" echo "If you get Access denied errors, you should run this script again"
echo "and give the MySQL root user password as a argument!" echo "and give the MySQL root user password as a argument!"
@ -15,13 +15,12 @@ host="localhost"
# Fix old password format, add File_priv and func table # Fix old password format, add File_priv and func table
echo "" echo ""
echo "If your tables are already up to date or partially up to date you will" echo "If your tables are already up to date or partially up to date you will"
echo "get some warnings about 'Duplicated column name' or" echo "get some warnings about 'Duplicated column name'. You can safely ignore these!"
echo "'Table 'func' already exists'. You can safely ignore these!"
@bindir@/mysql -f --user=root --password="$root_password" --host="$host" mysql <<END_OF_DATA @bindir@/mysql -f --user=root --password="$root_password" --host="$host" mysql <<END_OF_DATA
alter table user change password password char(16) NOT NULL; alter table user change password password char(16) NOT NULL;
alter table user add File_priv enum('N','Y') NOT NULL; alter table user add File_priv enum('N','Y') NOT NULL;
CREATE TABLE func ( CREATE TABLE if not exists func (
name char(64) DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL,
ret tinyint(1) DEFAULT '0' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL,
dl char(128) DEFAULT '' NOT NULL, dl char(128) DEFAULT '' NOT NULL,
@ -57,6 +56,13 @@ END_OF_DATA
echo "" echo ""
fi fi
echo "Adding columns needed by GRANT .. REQUIRE (openssl)"
echo "You can ignore any Duplicate column errors"
@bindir@/mysql --user=root --password="$root_password" --host="$host" mysql <<END_OF_DATA
ALTER TABLE user ADD ssl_type enum('NONE','ANY','X509', 'SPECIFIED') DEFAULT 'NONE' NOT NULL, ADD ssl_cipher BLOB NOT NULL, ADD x509_issuer BLOB NOT NULL, ADD x509_subject BLOB NOT NULL
END_OF_DATA
echo ""
# #
# Create tables_priv and columns_priv if they don't exists # Create tables_priv and columns_priv if they don't exists
# #
@ -64,7 +70,7 @@ fi
echo "Creating the new table and column privilege tables" echo "Creating the new table and column privilege tables"
@bindir@/mysql -f --user=root --password="$root_password" --host="$host" mysql <<END_OF_DATA @bindir@/mysql -f --user=root --password="$root_password" --host="$host" mysql <<END_OF_DATA
CREATE TABLE tables_priv ( CREATE TABLE IF NOT EXISTS tables_priv (
Host char(60) DEFAULT '' NOT NULL, Host char(60) DEFAULT '' NOT NULL,
Db char(60) DEFAULT '' NOT NULL, Db char(60) DEFAULT '' NOT NULL,
User char(16) DEFAULT '' NOT NULL, User char(16) DEFAULT '' NOT NULL,
@ -75,7 +81,7 @@ CREATE TABLE tables_priv (
Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,
PRIMARY KEY (Host,Db,User,Table_name) PRIMARY KEY (Host,Db,User,Table_name)
); );
CREATE TABLE columns_priv ( CREATE TABLE IF NOT EXISTS columns_priv (
Host char(60) DEFAULT '' NOT NULL, Host char(60) DEFAULT '' NOT NULL,
Db char(60) DEFAULT '' NOT NULL, Db char(60) DEFAULT '' NOT NULL,
User char(16) DEFAULT '' NOT NULL, User char(16) DEFAULT '' NOT NULL,
@ -97,6 +103,7 @@ echo "You can ignore any errors from this"
@bindir@/mysql -f --user=root --password="$root_password" --host="$host" mysql <<END_OF_DATA @bindir@/mysql -f --user=root --password="$root_password" --host="$host" mysql <<END_OF_DATA
ALTER TABLE columns_priv change Type Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL; ALTER TABLE columns_priv change Type Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL;
END_OF_DATA END_OF_DATA
echo ""
# #
# Add the new 'type' column to the func table. # Add the new 'type' column to the func table.
@ -108,3 +115,14 @@ echo "You can ignore any Duplicate column errors"
@bindir@/mysql --user=root --password=$root_password mysql <<EOF @bindir@/mysql --user=root --password=$root_password mysql <<EOF
alter table func add type enum ('function','aggregate') NOT NULL; alter table func add type enum ('function','aggregate') NOT NULL;
EOF EOF
echo ""
echo "Converting all privilege tables to MyISAM format"
@bindir@/mysql -f --user=root --password="$root_password" --host="$host" mysql <<END_OF_DATA
ALTER TABLE user type=MyISAM;
ALTER TABLE db type=MyISAM;
ALTER TABLE host type=MyISAM;
ALTER TABLE func type=MyISAM;
ALTER TABLE columns_priv type=MyISAM;
ALTER TABLE tables_priv type=MyISAM;
END_OF_DATA

View file

@ -224,18 +224,22 @@ then
c_u="$c_u References_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_u="$c_u References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Index_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_u="$c_u Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_u="$c_u Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u ssl_type enum('NONE','ANY','X509', 'SPECIFIED') DEFAULT 'NONE' NOT NULL,"
c_u="$c_u ssl_cipher BLOB NOT NULL,"
c_u="$c_u x509_issuer BLOB NOT NULL,"
c_u="$c_u x509_subject BLOB NOT NULL,"
c_u="$c_u PRIMARY KEY Host (Host,User)" c_u="$c_u PRIMARY KEY Host (Host,User)"
c_u="$c_u )" c_u="$c_u )"
c_u="$c_u comment='Users and global privileges';" c_u="$c_u comment='Users and global privileges';"
i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'); i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','NONE',NULL,NULL,NULL);
INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'); INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','NONE',NULL,NULL,NULL);
REPLACE INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'); REPLACE INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','NONE',NULL,NULL,NULL);
REPLACE INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'); REPLACE INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','NONE',NULL,NULL,NULL);
INSERT INTO user VALUES ('localhost','','','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); INSERT INTO user VALUES ('localhost','','','N','N','N','N','N','N','N','N','N','N','N','N','N','N','NONE',NULL,NULL,NULL);
INSERT INTO user VALUES ('$hostname','','','N','N','N','N','N','N','N','N','N','N','N','N','N','N');" INSERT INTO user VALUES ('$hostname','','','N','N','N','N','N','N','N','N','N','N','N','N','N','N','NONE',NULL,NULL,NULL);"
fi fi
if test ! -f $mdata/func.frm if test ! -f $mdata/func.frm

View file

@ -72,8 +72,7 @@ static void read_texts(const char *file_name,const char ***point,
Check that the above file is the right version for this program!\n\n", Check that the above file is the right version for this program!\n\n",
my_progname,name,ant,error_messages); my_progname,name,ant,error_messages);
VOID(my_close(file,MYF(MY_WME))); VOID(my_close(file,MYF(MY_WME)));
clean_up(0); /* Clean_up frees everything */ unireg_abort(1);
exit(1); /* We can't continue */
} }
x_free((gptr) *point); /* Free old language */ x_free((gptr) *point); /* Free old language */
@ -115,8 +114,7 @@ err:
if (file != FERR) if (file != FERR)
VOID(my_close(file,MYF(MY_WME))); VOID(my_close(file,MYF(MY_WME)));
fprintf(stderr,buff,my_progname,name); fprintf(stderr,buff,my_progname,name);
clean_up(0); /* Clean_up frees everything */ unireg_abort(1);
exit(1); /* We can't continue */
} /* read_texts */ } /* read_texts */

View file

@ -415,10 +415,11 @@ public:
unireg_check_arg, field_name_arg, table_arg, unireg_check_arg, field_name_arg, table_arg,
0, zero_arg,unsigned_arg) 0, zero_arg,unsigned_arg)
{} {}
Field_longlong(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, Field_longlong(uint32 len_arg,bool maybe_null_arg,
struct st_table *table_arg) const char *field_name_arg,
struct st_table *table_arg, bool unsigned_arg)
:Field_num((char*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0, :Field_num((char*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, table_arg,0,0,0) NONE, field_name_arg, table_arg,0,0,unsigned_arg)
{} {}
enum Item_result result_type () const { return INT_RESULT; } enum Item_result result_type () const { return INT_RESULT; }
enum_field_types type() const { return FIELD_TYPE_LONGLONG;} enum_field_types type() const { return FIELD_TYPE_LONGLONG;}

View file

@ -474,7 +474,7 @@ int main(int argc,char **argv)
MY_INIT(argv[0]); MY_INIT(argv[0]);
start_value=1060872L; best_t1=7930739L; best_t2=4311642L; best_type=3; /* mode=5333 add=6 type: 0 */ start_value=1109118L; best_t1=6657025L; best_t2=6114496L; best_type=1; /* mode=4903 add=3 type: 0 */
if (get_options(argc,(char **) argv)) if (get_options(argc,(char **) argv))
exit(1); exit(1);

View file

@ -90,7 +90,7 @@ const char *berkeley_lock_names[] =
{ "DEFAULT", "OLDEST","RANDOM","YOUNGEST",0 }; { "DEFAULT", "OLDEST","RANDOM","YOUNGEST",0 };
u_int32_t berkeley_lock_types[]= u_int32_t berkeley_lock_types[]=
{ DB_LOCK_DEFAULT, DB_LOCK_OLDEST, DB_LOCK_RANDOM }; { DB_LOCK_DEFAULT, DB_LOCK_OLDEST, DB_LOCK_RANDOM };
TYPELIB berkeley_lock_typelib= {array_elements(berkeley_lock_names),"", TYPELIB berkeley_lock_typelib= {array_elements(berkeley_lock_names)-1,"",
berkeley_lock_names}; berkeley_lock_names};
static void berkeley_print_error(const char *db_errpfx, char *buffer); static void berkeley_print_error(const char *db_errpfx, char *buffer);

View file

@ -68,7 +68,7 @@ ulong gemini_recovery_options = GEMINI_RECOVERY_FULL;
/* bits in gemini_recovery_options */ /* bits in gemini_recovery_options */
const char *gemini_recovery_names[] = const char *gemini_recovery_names[] =
{ "FULL", "NONE", "FORCE" }; { "FULL", "NONE", "FORCE" };
TYPELIB gemini_recovery_typelib= {array_elements(gemini_recovery_names),"", TYPELIB gemini_recovery_typelib= {array_elements(gemini_recovery_names)-1,"",
gemini_recovery_names}; gemini_recovery_names};
const int start_of_name = 2; /* Name passed as ./<db>/<table-name> const int start_of_name = 2; /* Name passed as ./<db>/<table-name>

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