2001-12-06 13:10:51 +01:00
/* Copyright (C) 2000 MySQL AB
2001-04-20 00:12:10 +02:00
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
2006-12-23 20:17:15 +01:00
the Free Software Foundation ; version 2 of the License .
2001-04-20 00:12:10 +02:00
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 */
/* By Jani Tolonen, 2001-04-20, MySQL Development Team */
2004-10-07 21:08:17 +02:00
# define CHECK_VERSION "2.4.4"
2001-04-20 00:12:10 +02:00
2001-09-12 22:53:31 +02:00
# include "client_priv.h"
2001-04-20 00:12:10 +02:00
# include <m_ctype.h>
2002-09-17 22:46:53 +02:00
# include <mysql_version.h>
# include <mysqld_error.h>
# include <sslopt-vars.h>
2001-04-20 00:12:10 +02:00
/* Exit codes */
# define EX_USAGE 1
# define EX_MYSQLERR 2
static MYSQL mysql_connection , * sock = 0 ;
static my_bool opt_alldbs = 0 , opt_check_only_changed = 0 , opt_extended = 0 ,
opt_compress = 0 , opt_databases = 0 , opt_fast = 0 ,
opt_medium_check = 0 , opt_quick = 0 , opt_all_in_1 = 0 ,
2002-04-02 19:29:53 +02:00
opt_silent = 0 , opt_auto_repair = 0 , ignore_errors = 0 ,
2006-02-17 07:52:32 +01:00
tty_password = 0 , opt_frm = 0 , opt_upgrade = 0 ;
2001-04-20 00:12:10 +02:00
static uint verbose = 0 , opt_mysql_port = 0 ;
static my_string opt_mysql_unix_port = 0 ;
2003-03-16 08:20:45 +01:00
static char * opt_password = 0 , * current_user = 0 ,
2003-05-28 13:23:04 +02:00
* default_charset = ( char * ) MYSQL_DEFAULT_CHARSET_NAME ,
* current_host = 0 ;
2001-04-20 00:12:10 +02:00
static int first_error = 0 ;
2001-04-23 22:29:53 +02:00
DYNAMIC_ARRAY tables4repair ;
2002-11-14 20:16:30 +01:00
# ifdef HAVE_SMEM
static char * shared_memory_base_name = 0 ;
# endif
static uint opt_protocol = 0 ;
2003-03-16 08:20:45 +01:00
static CHARSET_INFO * charset_info = & my_charset_latin1 ;
2001-04-20 00:12:10 +02:00
enum operations { DO_CHECK , DO_REPAIR , DO_ANALYZE , DO_OPTIMIZE } ;
2002-04-02 19:29:53 +02:00
static struct my_option my_long_options [ ] =
2001-04-20 00:12:10 +02:00
{
2002-04-02 19:29:53 +02:00
{ " all-databases " , ' A ' ,
" Check all the databases. This will be same as --databases with all databases selected. " ,
( gptr * ) & opt_alldbs , ( gptr * ) & opt_alldbs , 0 , GET_BOOL , NO_ARG , 0 , 0 , 0 , 0 ,
0 , 0 } ,
{ " analyze " , ' a ' , " Analyze given tables. " , 0 , 0 , 0 , GET_NO_ARG , NO_ARG , 0 , 0 ,
0 , 0 , 0 , 0 } ,
{ " all-in-1 " , ' 1 ' ,
2002-08-28 12:14:11 +02:00
" Instead of issuing one query for each table, use one query per database, naming all tables in the database in a comma-separated list. " ,
2002-04-02 19:29:53 +02:00
( gptr * ) & opt_all_in_1 , ( gptr * ) & opt_all_in_1 , 0 , GET_BOOL , NO_ARG , 0 , 0 , 0 ,
0 , 0 , 0 } ,
2005-08-24 21:03:34 +02:00
# ifdef __NETWARE__
2005-11-18 18:25:46 +01:00
{ " autoclose " , OPT_AUTO_CLOSE , " Auto close the screen on exit for Netware. " ,
2005-08-24 21:03:34 +02:00
0 , 0 , 0 , GET_NO_ARG , NO_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
# endif
2002-04-02 19:29:53 +02:00
{ " auto-repair " , OPT_AUTO_REPAIR ,
" If a checked table is corrupted, automatically fix it. Repairing will be done after all tables have been checked, if corrupted ones were found. " ,
( gptr * ) & opt_auto_repair , ( gptr * ) & opt_auto_repair , 0 , GET_BOOL , NO_ARG , 0 ,
0 , 0 , 0 , 0 , 0 } ,
{ " character-sets-dir " , OPT_CHARSETS_DIR ,
2003-06-13 10:59:02 +02:00
" Directory where character sets are. " , ( gptr * ) & charsets_dir ,
2002-04-02 19:29:53 +02:00
( gptr * ) & charsets_dir , 0 , GET_STR , REQUIRED_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
2003-06-13 10:59:02 +02:00
{ " check " , ' c ' , " Check table for errors. " , 0 , 0 , 0 , GET_NO_ARG , NO_ARG , 0 , 0 ,
2002-04-02 19:29:53 +02:00
0 , 0 , 0 , 0 } ,
{ " check-only-changed " , ' C ' ,
" Check only tables that have changed since last check or haven't been closed properly. " ,
0 , 0 , 0 , GET_NO_ARG , NO_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
2006-02-17 07:52:32 +01:00
{ " check-upgrade " , ' g ' ,
2006-02-17 15:32:52 +01:00
" Check tables for version-dependent changes. May be used with --auto-repair to correct tables requiring version-dependent updates. " ,
2006-02-17 07:52:32 +01:00
0 , 0 , 0 , GET_NO_ARG , NO_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
2002-04-02 19:29:53 +02:00
{ " compress " , OPT_COMPRESS , " Use compression in server/client protocol. " ,
( gptr * ) & opt_compress , ( gptr * ) & opt_compress , 0 , GET_BOOL , NO_ARG , 0 , 0 , 0 ,
0 , 0 , 0 } ,
{ " databases " , ' B ' ,
" To check several databases. Note the difference in usage; In this case no tables are given. All name arguments are regarded as databasenames. " ,
( gptr * ) & opt_databases , ( gptr * ) & opt_databases , 0 , GET_BOOL , NO_ARG ,
0 , 0 , 0 , 0 , 0 , 0 } ,
2004-11-02 10:14:07 +01:00
# ifdef DBUG_OFF
{ " debug " , ' # ' , " This is a non-debug version. Catch this and exit. " ,
0 , 0 , 0 , GET_DISABLED , OPT_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
# else
2003-06-13 10:59:02 +02:00
{ " debug " , ' # ' , " Output debug log. Often this is 'd:t:o,filename'. " ,
2002-04-02 19:29:53 +02:00
0 , 0 , 0 , GET_STR , OPT_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
2004-11-02 10:14:07 +01:00
# endif
2002-04-02 19:29:53 +02:00
{ " default-character-set " , OPT_DEFAULT_CHARSET ,
2003-06-13 10:59:02 +02:00
" Set the default character set. " , ( gptr * ) & default_charset ,
2002-04-02 19:29:53 +02:00
( gptr * ) & default_charset , 0 , GET_STR , REQUIRED_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
2003-06-13 10:59:02 +02:00
{ " fast " , ' F ' , " Check only tables that haven't been closed properly. " ,
2002-04-02 19:29:53 +02:00
( gptr * ) & opt_fast , ( gptr * ) & opt_fast , 0 , GET_BOOL , NO_ARG , 0 , 0 , 0 , 0 , 0 ,
0 } ,
{ " force " , ' f ' , " Continue even if we get an sql-error. " ,
( gptr * ) & ignore_errors , ( gptr * ) & ignore_errors , 0 , GET_BOOL , NO_ARG , 0 , 0 ,
0 , 0 , 0 , 0 } ,
{ " extended " , ' e ' ,
2002-08-27 02:20:25 +02:00
" If you are using this option with CHECK TABLE, it will ensure that the table is 100 percent consistent, but will take a long time. If you are using this option with REPAIR TABLE, it will force using old slow repair with keycache method, instead of much faster repair by sorting. " ,
2002-04-02 19:29:53 +02:00
( gptr * ) & opt_extended , ( gptr * ) & opt_extended , 0 , GET_BOOL , NO_ARG , 0 , 0 , 0 ,
0 , 0 , 0 } ,
{ " help " , ' ? ' , " Display this help message and exit. " , 0 , 0 , 0 , GET_NO_ARG ,
NO_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
{ " host " , ' h ' , " Connect to host. " , ( gptr * ) & current_host ,
2002-05-15 19:24:00 +02:00
( gptr * ) & current_host , 0 , GET_STR_ALLOC , REQUIRED_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
2002-04-02 19:29:53 +02:00
{ " medium-check " , ' m ' ,
" Faster than extended-check, but only finds 99.99 percent of all errors. Should be good enough for most cases. " ,
0 , 0 , 0 , GET_NO_ARG , NO_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
{ " optimize " , ' o ' , " Optimize table. " , 0 , 0 , 0 , GET_NO_ARG , NO_ARG , 0 , 0 , 0 , 0 ,
0 , 0 } ,
{ " password " , ' p ' ,
" Password to use when connecting to server. If password is not given it's solicited on the tty. " ,
0 , 0 , 0 , GET_STR , OPT_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
2001-04-20 00:12:10 +02:00
# ifdef __WIN__
2002-04-02 19:29:53 +02:00
{ " pipe " , ' W ' , " Use named pipes to connect to server. " , 0 , 0 , 0 , GET_NO_ARG ,
NO_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
2001-04-20 00:12:10 +02:00
# endif
Bug #15327: configure: --with-tcp-port option being partially ignored
make sure that if builder configured with a non-standard (!= 3306)
default TCP port that value actually gets used throughout. if they
didn't configure a value, assume "use a sensible default", which
will be read from /etc/services or, failing that, from the factory
default. That makes the order of preference
- command-line option
- my.cnf, where applicable
- $MYSQL_TCP_PORT environment variable
- /etc/services (unless configured --with-tcp-port)
- default port (--with-tcp-port=... or factory default)
client/mysql.cc:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysql_upgrade.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqladmin.cc:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqlbinlog.cc:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqlcheck.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqldump.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqlimport.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqlmanagerc.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
configure.in:
Bug #15327: configure: --with-tcp-port option being partially ignored
If MYSQL_TCP_PORT defaulted in configure (factory default 3306
at the time of this writing), set MYSQL_TCP_PORT to factory
default, then clear factory default after. That way, we lose no
information, and we can distinguish between "defaulted" and the
pathological case "builder specifically configured a port that
coincides with factory default." This can in theory happen if
builder configures and builds several servers from a script
(--with-tcp-port=3306, --with-tcp-port=3316, --with-tcp-port=3326).
Not all that probable, but much preferable to having more "magic"
happen in the server when we can solve this without any guesswork.
client/mysqlshow.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqltest.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
include/mysql_version.h.in:
Bug #15327: configure: --with-tcp-port option being partially ignored
make factory default for TCP port available as MYSQL_PORT_DEFAULT
if build-time configured with a different default. (0 if unchanged)
libmysql/libmysql.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
initialize default tcp port for client, like so:
- if user configured --with-tcp-port, use that value as default
- otherwise assume "use a good default": search mysqld/tcp in
/etc/services; if that doesn't exist, use factory default (3306)
- environment variable MYSQL_TCP_PORT overrides this default
- command-line option overrides all of the above
mysql-test/Makefile.am:
Bug #15327: configure: --with-tcp-port option being partially ignored
make factory default for TCP port available as MYSQL_TCP_PORT_DEFAULT
if build-time configured with a different default. (0 if unchanged)
mysql-test/mysql-test-run-shell.sh:
Bug #15327: configure: --with-tcp-port option being partially ignored
set up MYSQL_TCP_PORT if not already set in environment:
- if user configured --with-tcp-port, use that value as default
- otherwise assume "use a good default": search mysqld/tcp in
/etc/services; if that doesn't exist, use factory default (3306)
netware/mysql_test_run.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
account for non-standard default port-no. configured at build-time
netware/mysqld_safe.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
account for non-standard default port-no. configured at build-time
scripts/Makefile.am:
Bug #15327: configure: --with-tcp-port option being partially ignored
make factory default for TCP port available as MYSQL_TCP_PORT_DEFAULT
if build-time configured with a different default. (0 if unchanged)
scripts/mysql_config.sh:
Bug #15327: configure: --with-tcp-port option being partially ignored
set up MYSQL_TCP_PORT if not already set in environment:
- if user configured --with-tcp-port, use that value as default
- otherwise assume "use a good default": search mysqld/tcp in
/etc/services; if that doesn't exist, use factory default (3306)
scripts/mysql_fix_privilege_tables.sh:
Bug #15327: configure: --with-tcp-port option being partially ignored
clarifying notice only
scripts/mysqld_safe-watch.sh:
Bug #15327: configure: --with-tcp-port option being partially ignored
account for non-standard default port-no. configured at build-time
server-tools/instance-manager/priv.h:
Bug #15327: configure: --with-tcp-port option being partially ignored
account for non-standard default port-no. configured at build-time
sql/mysqld.cc:
Bug #15327: configure: --with-tcp-port option being partially ignored
if builder specifically requested a default port, use that
(even if it coincides with our factory default).
only if they didn't do we check /etc/services (and, failing
on that, fall back to the factory default of 3306).
either default can be overridden by the environment variable
MYSQL_TCP_PORT, which in turn can be overridden with command
line options.
tests/mysql_client_test.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
tests/ssl_test.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
account for non-standard default port-no. configured at build-time
tests/thread_test.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
2007-09-13 16:19:46 +02:00
{ " port " , ' P ' , " Port number to use for connection or 0 for default to, in "
" order of preference, my.cnf, $MYSQL_TCP_PORT, "
# if MYSQL_PORT_DEFAULT == 0
" /etc/services, "
# endif
" built-in default ( " STRINGIFY_ARG ( MYSQL_PORT ) " ). " ,
( gptr * ) & opt_mysql_port ,
2005-10-13 21:28:43 +02:00
( gptr * ) & opt_mysql_port , 0 , GET_UINT , REQUIRED_ARG , 0 , 0 , 0 , 0 , 0 ,
2002-05-11 13:36:34 +02:00
0 } ,
2003-06-13 10:59:02 +02:00
{ " protocol " , OPT_MYSQL_PROTOCOL , " The protocol of connection (tcp,socket,pipe,memory). " ,
2002-11-14 20:16:30 +01:00
0 , 0 , 0 , GET_STR , REQUIRED_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
2002-04-02 19:29:53 +02:00
{ " quick " , ' q ' ,
" If you are using this option with CHECK TABLE, it prevents the check from scanning the rows to check for wrong links. This is the fastest check. If you are using this option with REPAIR TABLE, it will try to repair only the index tree. This is the fastest repair method for a table. " ,
( gptr * ) & opt_quick , ( gptr * ) & opt_quick , 0 , GET_BOOL , NO_ARG , 0 , 0 , 0 , 0 , 0 ,
0 } ,
{ " repair " , ' r ' ,
" Can fix almost anything except unique keys that aren't unique. " ,
0 , 0 , 0 , GET_NO_ARG , NO_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
2002-11-14 20:16:30 +01:00
# ifdef HAVE_SMEM
2004-08-30 18:11:10 +02:00
{ " shared-memory-base-name " , OPT_SHARED_MEMORY_BASE_NAME ,
2003-06-13 10:59:02 +02:00
" Base name of shared memory. " , ( gptr * ) & shared_memory_base_name , ( gptr * ) & shared_memory_base_name ,
2002-11-14 20:16:30 +01:00
0 , GET_STR_ALLOC , REQUIRED_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
# endif
2002-04-02 19:29:53 +02:00
{ " silent " , ' s ' , " Print only error messages. " , ( gptr * ) & opt_silent ,
( gptr * ) & opt_silent , 0 , GET_BOOL , NO_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
{ " socket " , ' S ' , " Socket file to use for connection. " ,
( gptr * ) & opt_mysql_unix_port , ( gptr * ) & opt_mysql_unix_port , 0 , GET_STR ,
REQUIRED_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
2002-09-17 22:46:53 +02:00
# include <sslopt-longopts.h>
2002-04-02 19:29:53 +02:00
{ " tables " , OPT_TABLES , " Overrides option --databases (-B). " , 0 , 0 , 0 ,
GET_NO_ARG , NO_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
2002-11-08 20:57:36 +01:00
{ " use-frm " , OPT_FRM ,
" When used with REPAIR, get table structure from .frm file, so the table can be repaired even if .MYI header is corrupted. " ,
( gptr * ) & opt_frm , ( gptr * ) & opt_frm , 0 , GET_BOOL , NO_ARG , 0 , 0 , 0 , 0 , 0 ,
0 } ,
2006-02-16 17:00:14 +01:00
# ifndef DONT_ALLOW_USER_CHANGE
{ " user " , ' u ' , " User for login if not current user. " , ( gptr * ) & current_user ,
( gptr * ) & current_user , 0 , GET_STR , REQUIRED_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
# endif
2002-04-02 19:29:53 +02:00
{ " verbose " , ' v ' , " Print info about the various stages. " , 0 , 0 , 0 , GET_NO_ARG ,
NO_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
{ " version " , ' V ' , " Output version information and exit. " , 0 , 0 , 0 , GET_NO_ARG ,
NO_ARG , 0 , 0 , 0 , 0 , 0 , 0 } ,
{ 0 , 0 , 0 , 0 , 0 , 0 , GET_NO_ARG , NO_ARG , 0 , 0 , 0 , 0 , 0 , 0 }
2001-04-20 00:12:10 +02:00
} ;
2002-11-08 20:57:36 +01:00
2001-04-20 00:12:10 +02:00
static const char * load_default_groups [ ] = { " mysqlcheck " , " client " , 0 } ;
static void print_version ( void ) ;
static void usage ( void ) ;
static int get_options ( int * argc , char * * * argv ) ;
static int process_all_databases ( ) ;
static int process_databases ( char * * db_names ) ;
static int process_selected_tables ( char * db , char * * table_names , int tables ) ;
static int process_all_tables_in_db ( char * database ) ;
static int use_db ( char * database ) ;
static int handle_request_for_tables ( char * tables , uint length ) ;
static int dbConnect ( char * host , char * user , char * passwd ) ;
static void dbDisconnect ( char * host ) ;
static void DBerror ( MYSQL * mysql , const char * when ) ;
static void safe_exit ( int error ) ;
static void print_result ( ) ;
2007-10-30 09:51:57 +01:00
static uint fixed_name_length ( const char * name ) ;
2003-01-28 22:29:59 +01:00
static char * fix_table_name ( char * dest , char * src ) ;
2001-04-20 00:12:10 +02:00
int what_to_do = 0 ;
2004-05-25 21:00:14 +02:00
# include <help_start.h>
2001-04-20 00:12:10 +02:00
static void print_version ( void )
{
printf ( " %s Ver %s Distrib %s, for %s (%s) \n " , my_progname , CHECK_VERSION ,
MYSQL_SERVER_VERSION , SYSTEM_TYPE , MACHINE_TYPE ) ;
2004-05-25 21:00:14 +02:00
NETWARE_SET_SCREEN_MODE ( 1 ) ;
2001-04-20 00:12:10 +02:00
} /* print_version */
static void usage ( void )
{
print_version ( ) ;
puts ( " By Jani Tolonen, 2001-04-20, MySQL Development Team \n " ) ;
2002-05-15 15:35:27 +02:00
puts ( " This software comes with ABSOLUTELY NO WARRANTY. This is free software, \n " ) ;
puts ( " and you are welcome to modify and redistribute it under the GPL license. \n " ) ;
2001-04-20 00:12:10 +02:00
puts ( " This program can be used to CHECK (-c,-m,-C), REPAIR (-r), ANALYZE (-a) " ) ;
puts ( " or OPTIMIZE (-o) tables. Some of the options (like -e or -q) can be " ) ;
2005-02-03 00:03:34 +01:00
puts ( " used at the same time. Not all options are supported by all storage engines. " ) ;
2001-04-20 00:12:10 +02:00
puts ( " Please consult the MySQL manual for latest information about the " ) ;
2001-04-23 22:29:53 +02:00
puts ( " above. The options -c,-r,-a and -o are exclusive to each other, which " ) ;
puts ( " means that the last option will be used, if several was specified. \n " ) ;
puts ( " The option -c will be used by default, if none was specified. You " ) ;
puts ( " can change the default behavior by making a symbolic link, or " ) ;
puts ( " copying this file somewhere with another name, the alternatives are: " ) ;
puts ( " mysqlrepair: The default option will be -r " ) ;
puts ( " mysqlanalyze: The default option will be -a " ) ;
puts ( " mysqloptimize: The default option will be -o \n " ) ;
2001-04-20 00:12:10 +02:00
printf ( " Usage: %s [OPTIONS] database [tables] \n " , my_progname ) ;
printf ( " OR %s [OPTIONS] --databases DB1 [DB2 DB3...] \n " ,
my_progname ) ;
printf ( " OR %s [OPTIONS] --all-databases \n " , my_progname ) ;
print_defaults ( " my " , load_default_groups ) ;
2002-04-02 19:29:53 +02:00
my_print_help ( my_long_options ) ;
my_print_variables ( my_long_options ) ;
2001-04-20 00:12:10 +02:00
} /* usage */
2004-05-25 21:00:14 +02:00
# include <help_end.h>
2001-12-06 13:10:51 +01:00
2002-04-02 19:29:53 +02:00
static my_bool
get_one_option ( int optid , const struct my_option * opt __attribute__ ( ( unused ) ) ,
char * argument )
{
switch ( optid ) {
2005-08-24 21:03:34 +02:00
# ifdef __NETWARE__
case OPT_AUTO_CLOSE :
setscreenmode ( SCR_AUTOCLOSE_ON_EXIT ) ;
break ;
# endif
2002-04-02 19:29:53 +02:00
case ' a ' :
what_to_do = DO_ANALYZE ;
break ;
case ' c ' :
what_to_do = DO_CHECK ;
break ;
case ' C ' :
what_to_do = DO_CHECK ;
opt_check_only_changed = 1 ;
break ;
case ' I ' : /* Fall through */
case ' ? ' :
usage ( ) ;
exit ( 0 ) ;
case ' m ' :
what_to_do = DO_CHECK ;
opt_medium_check = 1 ;
break ;
case ' o ' :
what_to_do = DO_OPTIMIZE ;
break ;
case ' p ' :
if ( argument )
{
char * start = argument ;
my_free ( opt_password , MYF ( MY_ALLOW_ZERO_PTR ) ) ;
opt_password = my_strdup ( argument , MYF ( MY_FAE ) ) ;
while ( * argument ) * argument + + = ' x ' ; /* Destroy argument */
if ( * start )
2002-11-08 20:57:36 +01:00
start [ 1 ] = 0 ; /* Cut length of argument */
2004-10-07 21:08:17 +02:00
tty_password = 0 ;
2002-04-02 19:29:53 +02:00
}
else
tty_password = 1 ;
break ;
case ' r ' :
what_to_do = DO_REPAIR ;
break ;
2006-02-17 07:52:32 +01:00
case ' g ' :
what_to_do = DO_CHECK ;
opt_upgrade = 1 ;
break ;
2002-04-02 19:29:53 +02:00
case ' W ' :
# ifdef __WIN__
2002-11-14 20:16:30 +01:00
opt_protocol = MYSQL_PROTOCOL_PIPE ;
2002-04-02 19:29:53 +02:00
# endif
break ;
case ' # ' :
DBUG_PUSH ( argument ? argument : " d:t:o " ) ;
break ;
2002-09-17 22:46:53 +02:00
# include <sslopt-case.h>
2002-04-02 19:29:53 +02:00
case OPT_TABLES :
opt_databases = 0 ;
break ;
case ' v ' :
verbose + + ;
break ;
case ' V ' : print_version ( ) ; exit ( 0 ) ;
2002-11-14 20:16:30 +01:00
case OPT_MYSQL_PROTOCOL :
{
2004-08-24 17:13:31 +02:00
if ( ( opt_protocol = find_type ( argument , & sql_protocol_typelib , 0 ) ) < = 0 )
2002-11-14 20:16:30 +01:00
{
fprintf ( stderr , " Unknown option to protocol: %s \n " , argument ) ;
exit ( 1 ) ;
}
break ;
}
2002-04-02 19:29:53 +02:00
}
return 0 ;
}
2001-04-20 00:12:10 +02:00
static int get_options ( int * argc , char * * * argv )
{
2002-04-02 19:29:53 +02:00
int ho_error ;
2001-04-20 00:12:10 +02:00
2001-04-23 22:29:53 +02:00
if ( * argc = = 1 )
{
usage ( ) ;
exit ( 0 ) ;
}
2001-04-20 00:12:10 +02:00
load_defaults ( " my " , load_default_groups , argc , argv ) ;
2002-04-02 19:29:53 +02:00
2004-08-31 18:27:58 +02:00
if ( ( ho_error = handle_options ( argc , argv , my_long_options , get_one_option ) ) )
2002-05-29 14:07:30 +02:00
exit ( ho_error ) ;
2002-04-02 19:29:53 +02:00
2001-04-20 00:12:10 +02:00
if ( ! what_to_do )
2001-04-23 22:29:53 +02:00
{
int pnlen = strlen ( my_progname ) ;
2001-05-29 12:46:17 +02:00
if ( pnlen < 6 ) /* name too short */
2001-04-23 22:29:53 +02:00
what_to_do = DO_CHECK ;
else if ( ! strcmp ( " repair " , my_progname + pnlen - 6 ) )
what_to_do = DO_REPAIR ;
else if ( ! strcmp ( " analyze " , my_progname + pnlen - 7 ) )
what_to_do = DO_ANALYZE ;
else if ( ! strcmp ( " optimize " , my_progname + pnlen - 8 ) )
what_to_do = DO_OPTIMIZE ;
else
what_to_do = DO_CHECK ;
}
2003-11-21 00:53:01 +01:00
/* TODO: This variable is not yet used */
2004-02-11 12:15:39 +01:00
if ( strcmp ( default_charset , charset_info - > csname ) & &
! ( charset_info = get_charset_by_csname ( default_charset ,
2003-05-22 11:37:01 +02:00
MY_CS_PRIMARY , MYF ( MY_WME ) ) ) )
2001-04-20 00:12:10 +02:00
exit ( 1 ) ;
if ( * argc > 0 & & opt_alldbs )
{
printf ( " You should give only options, no arguments at all, with option \n " ) ;
printf ( " --all-databases. Please see %s --help for more information. \n " ,
my_progname ) ;
return 1 ;
}
if ( * argc < 1 & & ! opt_alldbs )
{
printf ( " You forgot to give the arguments! Please see %s --help \n " ,
my_progname ) ;
printf ( " for more information. \n " ) ;
return 1 ;
}
if ( tty_password )
opt_password = get_tty_password ( NullS ) ;
return ( 0 ) ;
} /* get_options */
static int process_all_databases ( )
{
MYSQL_ROW row ;
MYSQL_RES * tableres ;
int result = 0 ;
if ( mysql_query ( sock , " SHOW DATABASES " ) | |
! ( tableres = mysql_store_result ( sock ) ) )
{
my_printf_error ( 0 , " Error: Couldn't execute 'SHOW DATABASES': %s " ,
MYF ( 0 ) , mysql_error ( sock ) ) ;
return 1 ;
}
while ( ( row = mysql_fetch_row ( tableres ) ) )
{
if ( process_all_tables_in_db ( row [ 0 ] ) )
result = 1 ;
}
return result ;
}
/* process_all_databases */
static int process_databases ( char * * db_names )
{
int result = 0 ;
for ( ; * db_names ; db_names + + )
{
if ( process_all_tables_in_db ( * db_names ) )
result = 1 ;
}
return result ;
} /* process_databases */
static int process_selected_tables ( char * db , char * * table_names , int tables )
{
if ( use_db ( db ) )
return 1 ;
if ( opt_all_in_1 )
{
2002-11-12 15:09:33 +01:00
/*
We need table list in form ` a ` , ` b ` , ` c `
2007-10-30 09:51:57 +01:00
that ' s why we need 2 more chars added to to each table name
2002-11-12 15:09:33 +01:00
space is for more readable output in logs and in case of error
*/
2001-04-20 00:12:10 +02:00
char * table_names_comma_sep , * end ;
int i , tot_length = 0 ;
for ( i = 0 ; i < tables ; i + + )
2007-10-30 09:51:57 +01:00
tot_length + = fixed_name_length ( * ( table_names + i ) ) + 2 ;
2001-12-06 13:10:51 +01:00
2001-04-20 00:12:10 +02:00
if ( ! ( table_names_comma_sep = ( char * )
2002-11-12 15:09:33 +01:00
my_malloc ( ( sizeof ( char ) * tot_length ) + 4 , MYF ( MY_WME ) ) ) )
2001-04-20 00:12:10 +02:00
return 1 ;
for ( end = table_names_comma_sep + 1 ; tables > 0 ;
tables - - , table_names + + )
{
2003-01-28 22:29:59 +01:00
end = fix_table_name ( end , * table_names ) ;
* end + + = ' , ' ;
2001-04-20 00:12:10 +02:00
}
* - - end = 0 ;
handle_request_for_tables ( table_names_comma_sep + 1 , tot_length - 1 ) ;
my_free ( table_names_comma_sep , MYF ( 0 ) ) ;
}
else
for ( ; tables > 0 ; tables - - , table_names + + )
2007-10-30 09:51:57 +01:00
handle_request_for_tables ( * table_names , fixed_name_length ( * table_names ) ) ;
2001-04-20 00:12:10 +02:00
return 0 ;
} /* process_selected_tables */
2007-10-30 09:51:57 +01:00
static uint fixed_name_length ( const char * name )
2003-01-28 22:29:59 +01:00
{
2007-10-30 09:51:57 +01:00
const char * p ;
uint extra_length = 2 ; /* count the first/last backticks */
for ( p = name ; * p ; p + + )
{
if ( * p = = ' ` ' )
extra_length + + ;
else if ( * p = = ' . ' )
extra_length + = 2 ;
}
return ( p - name ) + extra_length ;
}
2003-01-28 22:29:59 +01:00
2007-10-30 09:51:57 +01:00
static char * fix_table_name ( char * dest , char * src )
{
2003-01-28 22:29:59 +01:00
* dest + + = ' ` ' ;
2007-10-30 09:51:57 +01:00
for ( ; * src ; src + + )
2003-01-28 22:29:59 +01:00
{
2007-10-30 09:51:57 +01:00
switch ( * src ) {
case ' . ' : /* add backticks around '.' */
* dest + + = ' ` ' ;
* dest + + = ' . ' ;
* dest + + = ' ` ' ;
break ;
case ' ` ' : /* escape backtick character */
* dest + + = ' ` ' ;
/* fall through */
default :
* dest + + = * src ;
}
2003-01-28 22:29:59 +01:00
}
2007-10-30 09:51:57 +01:00
* dest + + = ' ` ' ;
2003-01-28 22:29:59 +01:00
return dest ;
}
2001-04-20 00:12:10 +02:00
static int process_all_tables_in_db ( char * database )
{
MYSQL_RES * res ;
MYSQL_ROW row ;
2008-01-23 17:37:46 +01:00
uint num_columns ;
2001-04-20 00:12:10 +02:00
LINT_INIT ( res ) ;
if ( use_db ( database ) )
return 1 ;
2008-01-23 17:37:46 +01:00
if ( mysql_query ( sock , " SHOW /*!50002 FULL*/ TABLES " ) | |
2004-09-06 22:48:42 +02:00
! ( ( res = mysql_store_result ( sock ) ) ) )
2001-04-20 00:12:10 +02:00
return 1 ;
2001-12-06 13:10:51 +01:00
2008-01-23 17:37:46 +01:00
num_columns = mysql_num_fields ( res ) ;
2001-04-20 00:12:10 +02:00
if ( opt_all_in_1 )
{
2004-09-06 22:48:42 +02:00
/*
2002-11-12 15:09:33 +01:00
We need table list in form ` a ` , ` b ` , ` c `
2007-10-30 09:51:57 +01:00
that ' s why we need 2 more chars added to to each table name
2002-11-12 15:09:33 +01:00
space is for more readable output in logs and in case of error
*/
2004-09-06 22:48:42 +02:00
2001-04-20 00:12:10 +02:00
char * tables , * end ;
uint tot_length = 0 ;
while ( ( row = mysql_fetch_row ( res ) ) )
2007-10-30 09:51:57 +01:00
tot_length + = fixed_name_length ( row [ 0 ] ) + 2 ;
2001-04-20 00:12:10 +02:00
mysql_data_seek ( res , 0 ) ;
2001-12-06 13:10:51 +01:00
2002-11-12 15:09:33 +01:00
if ( ! ( tables = ( char * ) my_malloc ( sizeof ( char ) * tot_length + 4 , MYF ( MY_WME ) ) ) )
2001-04-20 00:12:10 +02:00
{
mysql_free_result ( res ) ;
return 1 ;
}
for ( end = tables + 1 ; ( row = mysql_fetch_row ( res ) ) ; )
{
2008-01-23 17:37:46 +01:00
if ( ( num_columns = = 2 ) & & ( strcmp ( row [ 1 ] , " VIEW " ) = = 0 ) )
continue ;
end = fix_table_name ( end , row [ 0 ] ) ;
* end + + = ' , ' ;
2001-04-20 00:12:10 +02:00
}
* - - end = 0 ;
if ( tot_length )
handle_request_for_tables ( tables + 1 , tot_length - 1 ) ;
my_free ( tables , MYF ( 0 ) ) ;
}
else
{
while ( ( row = mysql_fetch_row ( res ) ) )
2006-07-24 22:31:20 +02:00
/* Skip tables with an engine of NULL (probably a view). */
if ( row [ 1 ] )
{
2008-01-23 17:37:46 +01:00
if ( ( num_columns = = 2 ) & & ( strcmp ( row [ 1 ] , " VIEW " ) = = 0 ) )
continue ;
2007-10-30 09:51:57 +01:00
handle_request_for_tables ( row [ 0 ] , fixed_name_length ( row [ 0 ] ) ) ;
2006-07-24 22:31:20 +02:00
}
2001-04-20 00:12:10 +02:00
}
mysql_free_result ( res ) ;
return 0 ;
} /* process_all_tables_in_db */
static int use_db ( char * database )
{
2005-10-18 11:25:03 +02:00
if ( mysql_get_server_version ( sock ) > = 50003 & &
! my_strcasecmp ( & my_charset_latin1 , database , " information_schema " ) )
return 1 ;
2001-04-20 00:12:10 +02:00
if ( mysql_select_db ( sock , database ) )
{
DBerror ( sock , " when selecting the database " ) ;
return 1 ;
}
return 0 ;
} /* use_db */
static int handle_request_for_tables ( char * tables , uint length )
{
Fixed bug in mysqlcheck when using --fast
Fixed problem when converting bigint to double.
Fixed bug in count(distinct null)
Fixed bug with empty BDB tables.
BitKeeper/deleted/.del-ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~dd306b2e583ebde4:
Delete: sql-bench/Results/ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~11038a44f73070e7:
Delete: sql-bench/Results/RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~662b96bc66bc91b6:
Delete: sql-bench/Results/alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~788ad492867b1226:
Delete: sql-bench/Results/big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~5316add301edb60:
Delete: sql-bench/Results/connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~26e09af61f88d8c9:
Delete: sql-bench/Results/create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~fd2699adb3190d07:
Delete: sql-bench/Results/insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~b01175ad38fd12b6:
Delete: sql-bench/Results/select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~8ba598d217450157:
Delete: sql-bench/Results/wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
Docs/manual.texi:
Changelog + update to Linux section
client/mysqlcheck.c:
Fixed bug when using --fast
--check --auto-repair --fast will not anymore repair tables that
had warnings but where ok.
mysql-test/r/bdb.result:
New test case
mysql-test/r/bigint.result:
New test case
mysql-test/r/count_distinct.result:
New test case
mysql-test/t/bdb.test:
New test case
mysql-test/t/bigint.test:
New test case
mysql-test/t/count_distinct.test:
New test case
sql-bench/Comments/postgres.benchmark:
Update for PostgreSQL 7.1.2
sql-bench/graph-compare-results.sh:
Fixed colors for mysql --fast tests
sql/field.cc:
Fixed problem when converting bigint to double.
sql/item_sum.cc:
Fixed bug in count(distinct null)
sql/item_sum.h:
Fixed bug in count(distinct null)
sql/mysqlbinlog.cc:
Fixed typo
sql/sql_base.cc:
cleanup
sql/sql_select.cc:
Fixed bug with empty BDB tables.
sql/time.cc:
Removed warning when reading timestamps with sub seconds.
2001-06-19 13:30:12 +02:00
char * query , * end , options [ 100 ] , message [ 100 ] ;
2003-01-28 22:29:59 +01:00
uint query_length = 0 ;
2001-04-20 00:12:10 +02:00
const char * op = 0 ;
options [ 0 ] = 0 ;
Fixed bug in mysqlcheck when using --fast
Fixed problem when converting bigint to double.
Fixed bug in count(distinct null)
Fixed bug with empty BDB tables.
BitKeeper/deleted/.del-ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~dd306b2e583ebde4:
Delete: sql-bench/Results/ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~11038a44f73070e7:
Delete: sql-bench/Results/RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~662b96bc66bc91b6:
Delete: sql-bench/Results/alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~788ad492867b1226:
Delete: sql-bench/Results/big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~5316add301edb60:
Delete: sql-bench/Results/connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~26e09af61f88d8c9:
Delete: sql-bench/Results/create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~fd2699adb3190d07:
Delete: sql-bench/Results/insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~b01175ad38fd12b6:
Delete: sql-bench/Results/select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~8ba598d217450157:
Delete: sql-bench/Results/wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
Docs/manual.texi:
Changelog + update to Linux section
client/mysqlcheck.c:
Fixed bug when using --fast
--check --auto-repair --fast will not anymore repair tables that
had warnings but where ok.
mysql-test/r/bdb.result:
New test case
mysql-test/r/bigint.result:
New test case
mysql-test/r/count_distinct.result:
New test case
mysql-test/t/bdb.test:
New test case
mysql-test/t/bigint.test:
New test case
mysql-test/t/count_distinct.test:
New test case
sql-bench/Comments/postgres.benchmark:
Update for PostgreSQL 7.1.2
sql-bench/graph-compare-results.sh:
Fixed colors for mysql --fast tests
sql/field.cc:
Fixed problem when converting bigint to double.
sql/item_sum.cc:
Fixed bug in count(distinct null)
sql/item_sum.h:
Fixed bug in count(distinct null)
sql/mysqlbinlog.cc:
Fixed typo
sql/sql_base.cc:
cleanup
sql/sql_select.cc:
Fixed bug with empty BDB tables.
sql/time.cc:
Removed warning when reading timestamps with sub seconds.
2001-06-19 13:30:12 +02:00
end = options ;
2001-04-20 00:12:10 +02:00
switch ( what_to_do ) {
case DO_CHECK :
op = " CHECK " ;
Fixed bug in mysqlcheck when using --fast
Fixed problem when converting bigint to double.
Fixed bug in count(distinct null)
Fixed bug with empty BDB tables.
BitKeeper/deleted/.del-ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~dd306b2e583ebde4:
Delete: sql-bench/Results/ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~11038a44f73070e7:
Delete: sql-bench/Results/RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~662b96bc66bc91b6:
Delete: sql-bench/Results/alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~788ad492867b1226:
Delete: sql-bench/Results/big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~5316add301edb60:
Delete: sql-bench/Results/connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~26e09af61f88d8c9:
Delete: sql-bench/Results/create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~fd2699adb3190d07:
Delete: sql-bench/Results/insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~b01175ad38fd12b6:
Delete: sql-bench/Results/select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~8ba598d217450157:
Delete: sql-bench/Results/wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
Docs/manual.texi:
Changelog + update to Linux section
client/mysqlcheck.c:
Fixed bug when using --fast
--check --auto-repair --fast will not anymore repair tables that
had warnings but where ok.
mysql-test/r/bdb.result:
New test case
mysql-test/r/bigint.result:
New test case
mysql-test/r/count_distinct.result:
New test case
mysql-test/t/bdb.test:
New test case
mysql-test/t/bigint.test:
New test case
mysql-test/t/count_distinct.test:
New test case
sql-bench/Comments/postgres.benchmark:
Update for PostgreSQL 7.1.2
sql-bench/graph-compare-results.sh:
Fixed colors for mysql --fast tests
sql/field.cc:
Fixed problem when converting bigint to double.
sql/item_sum.cc:
Fixed bug in count(distinct null)
sql/item_sum.h:
Fixed bug in count(distinct null)
sql/mysqlbinlog.cc:
Fixed typo
sql/sql_base.cc:
cleanup
sql/sql_select.cc:
Fixed bug with empty BDB tables.
sql/time.cc:
Removed warning when reading timestamps with sub seconds.
2001-06-19 13:30:12 +02:00
if ( opt_quick ) end = strmov ( end , " QUICK " ) ;
if ( opt_fast ) end = strmov ( end , " FAST " ) ;
if ( opt_medium_check ) end = strmov ( end , " MEDIUM " ) ; /* Default */
if ( opt_extended ) end = strmov ( end , " EXTENDED " ) ;
if ( opt_check_only_changed ) end = strmov ( end , " CHANGED " ) ;
2006-02-17 07:52:32 +01:00
if ( opt_upgrade ) end = strmov ( end , " FOR UPGRADE " ) ;
2001-04-20 00:12:10 +02:00
break ;
case DO_REPAIR :
op = " REPAIR " ;
Fixed bug in mysqlcheck when using --fast
Fixed problem when converting bigint to double.
Fixed bug in count(distinct null)
Fixed bug with empty BDB tables.
BitKeeper/deleted/.del-ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~dd306b2e583ebde4:
Delete: sql-bench/Results/ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~11038a44f73070e7:
Delete: sql-bench/Results/RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~662b96bc66bc91b6:
Delete: sql-bench/Results/alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~788ad492867b1226:
Delete: sql-bench/Results/big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~5316add301edb60:
Delete: sql-bench/Results/connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~26e09af61f88d8c9:
Delete: sql-bench/Results/create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~fd2699adb3190d07:
Delete: sql-bench/Results/insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~b01175ad38fd12b6:
Delete: sql-bench/Results/select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~8ba598d217450157:
Delete: sql-bench/Results/wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
Docs/manual.texi:
Changelog + update to Linux section
client/mysqlcheck.c:
Fixed bug when using --fast
--check --auto-repair --fast will not anymore repair tables that
had warnings but where ok.
mysql-test/r/bdb.result:
New test case
mysql-test/r/bigint.result:
New test case
mysql-test/r/count_distinct.result:
New test case
mysql-test/t/bdb.test:
New test case
mysql-test/t/bigint.test:
New test case
mysql-test/t/count_distinct.test:
New test case
sql-bench/Comments/postgres.benchmark:
Update for PostgreSQL 7.1.2
sql-bench/graph-compare-results.sh:
Fixed colors for mysql --fast tests
sql/field.cc:
Fixed problem when converting bigint to double.
sql/item_sum.cc:
Fixed bug in count(distinct null)
sql/item_sum.h:
Fixed bug in count(distinct null)
sql/mysqlbinlog.cc:
Fixed typo
sql/sql_base.cc:
cleanup
sql/sql_select.cc:
Fixed bug with empty BDB tables.
sql/time.cc:
Removed warning when reading timestamps with sub seconds.
2001-06-19 13:30:12 +02:00
if ( opt_quick ) end = strmov ( end , " QUICK " ) ;
if ( opt_extended ) end = strmov ( end , " EXTENDED " ) ;
2002-11-08 20:57:36 +01:00
if ( opt_frm ) end = strmov ( end , " USE_FRM " ) ;
2001-04-20 00:12:10 +02:00
break ;
case DO_ANALYZE :
op = " ANALYZE " ;
break ;
case DO_OPTIMIZE :
op = " OPTIMIZE " ;
break ;
}
if ( ! ( query = ( char * ) my_malloc ( ( sizeof ( char ) * ( length + 110 ) ) , MYF ( MY_WME ) ) ) )
return 1 ;
2002-11-12 15:09:33 +01:00
if ( opt_all_in_1 )
2003-01-28 22:29:59 +01:00
{
2002-11-12 15:09:33 +01:00
/* No backticks here as we added them before */
2003-01-28 22:29:59 +01:00
query_length = my_sprintf ( query ,
( query , " %s TABLE %s %s " , op , tables , options ) ) ;
}
2002-11-12 15:09:33 +01:00
else
2003-01-28 22:29:59 +01:00
{
char * ptr ;
ptr = strmov ( strmov ( query , op ) , " TABLE " ) ;
ptr = fix_table_name ( ptr , tables ) ;
ptr = strxmov ( ptr , " " , options , NullS ) ;
query_length = ( uint ) ( ptr - query ) ;
}
if ( mysql_real_query ( sock , query , query_length ) )
2001-04-20 00:12:10 +02:00
{
2002-11-12 15:09:33 +01:00
sprintf ( message , " when executing '%s TABLE ... %s' " , op , options ) ;
Fixed bug in mysqlcheck when using --fast
Fixed problem when converting bigint to double.
Fixed bug in count(distinct null)
Fixed bug with empty BDB tables.
BitKeeper/deleted/.del-ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~dd306b2e583ebde4:
Delete: sql-bench/Results/ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~11038a44f73070e7:
Delete: sql-bench/Results/RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~662b96bc66bc91b6:
Delete: sql-bench/Results/alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~788ad492867b1226:
Delete: sql-bench/Results/big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~5316add301edb60:
Delete: sql-bench/Results/connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~26e09af61f88d8c9:
Delete: sql-bench/Results/create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~fd2699adb3190d07:
Delete: sql-bench/Results/insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~b01175ad38fd12b6:
Delete: sql-bench/Results/select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~8ba598d217450157:
Delete: sql-bench/Results/wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
Docs/manual.texi:
Changelog + update to Linux section
client/mysqlcheck.c:
Fixed bug when using --fast
--check --auto-repair --fast will not anymore repair tables that
had warnings but where ok.
mysql-test/r/bdb.result:
New test case
mysql-test/r/bigint.result:
New test case
mysql-test/r/count_distinct.result:
New test case
mysql-test/t/bdb.test:
New test case
mysql-test/t/bigint.test:
New test case
mysql-test/t/count_distinct.test:
New test case
sql-bench/Comments/postgres.benchmark:
Update for PostgreSQL 7.1.2
sql-bench/graph-compare-results.sh:
Fixed colors for mysql --fast tests
sql/field.cc:
Fixed problem when converting bigint to double.
sql/item_sum.cc:
Fixed bug in count(distinct null)
sql/item_sum.h:
Fixed bug in count(distinct null)
sql/mysqlbinlog.cc:
Fixed typo
sql/sql_base.cc:
cleanup
sql/sql_select.cc:
Fixed bug with empty BDB tables.
sql/time.cc:
Removed warning when reading timestamps with sub seconds.
2001-06-19 13:30:12 +02:00
DBerror ( sock , message ) ;
2001-04-20 00:12:10 +02:00
return 1 ;
}
print_result ( ) ;
my_free ( query , MYF ( 0 ) ) ;
return 0 ;
}
static void print_result ( )
{
MYSQL_RES * res ;
MYSQL_ROW row ;
2001-04-23 22:29:53 +02:00
char prev [ NAME_LEN * 2 + 2 ] ;
Fixed bug in mysqlcheck when using --fast
Fixed problem when converting bigint to double.
Fixed bug in count(distinct null)
Fixed bug with empty BDB tables.
BitKeeper/deleted/.del-ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~dd306b2e583ebde4:
Delete: sql-bench/Results/ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~11038a44f73070e7:
Delete: sql-bench/Results/RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~662b96bc66bc91b6:
Delete: sql-bench/Results/alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~788ad492867b1226:
Delete: sql-bench/Results/big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~5316add301edb60:
Delete: sql-bench/Results/connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~26e09af61f88d8c9:
Delete: sql-bench/Results/create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~fd2699adb3190d07:
Delete: sql-bench/Results/insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~b01175ad38fd12b6:
Delete: sql-bench/Results/select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~8ba598d217450157:
Delete: sql-bench/Results/wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
Docs/manual.texi:
Changelog + update to Linux section
client/mysqlcheck.c:
Fixed bug when using --fast
--check --auto-repair --fast will not anymore repair tables that
had warnings but where ok.
mysql-test/r/bdb.result:
New test case
mysql-test/r/bigint.result:
New test case
mysql-test/r/count_distinct.result:
New test case
mysql-test/t/bdb.test:
New test case
mysql-test/t/bigint.test:
New test case
mysql-test/t/count_distinct.test:
New test case
sql-bench/Comments/postgres.benchmark:
Update for PostgreSQL 7.1.2
sql-bench/graph-compare-results.sh:
Fixed colors for mysql --fast tests
sql/field.cc:
Fixed problem when converting bigint to double.
sql/item_sum.cc:
Fixed bug in count(distinct null)
sql/item_sum.h:
Fixed bug in count(distinct null)
sql/mysqlbinlog.cc:
Fixed typo
sql/sql_base.cc:
cleanup
sql/sql_select.cc:
Fixed bug with empty BDB tables.
sql/time.cc:
Removed warning when reading timestamps with sub seconds.
2001-06-19 13:30:12 +02:00
uint i ;
my_bool found_error = 0 ;
2001-04-20 00:12:10 +02:00
res = mysql_use_result ( sock ) ;
2005-03-31 21:43:39 +02:00
2001-04-20 00:12:10 +02:00
prev [ 0 ] = ' \0 ' ;
for ( i = 0 ; ( row = mysql_fetch_row ( res ) ) ; i + + )
{
2001-04-20 12:21:35 +02:00
int changed = strcmp ( prev , row [ 0 ] ) ;
Fixed bug in mysqlcheck when using --fast
Fixed problem when converting bigint to double.
Fixed bug in count(distinct null)
Fixed bug with empty BDB tables.
BitKeeper/deleted/.del-ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~dd306b2e583ebde4:
Delete: sql-bench/Results/ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~11038a44f73070e7:
Delete: sql-bench/Results/RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~662b96bc66bc91b6:
Delete: sql-bench/Results/alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~788ad492867b1226:
Delete: sql-bench/Results/big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~5316add301edb60:
Delete: sql-bench/Results/connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~26e09af61f88d8c9:
Delete: sql-bench/Results/create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~fd2699adb3190d07:
Delete: sql-bench/Results/insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~b01175ad38fd12b6:
Delete: sql-bench/Results/select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~8ba598d217450157:
Delete: sql-bench/Results/wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
Docs/manual.texi:
Changelog + update to Linux section
client/mysqlcheck.c:
Fixed bug when using --fast
--check --auto-repair --fast will not anymore repair tables that
had warnings but where ok.
mysql-test/r/bdb.result:
New test case
mysql-test/r/bigint.result:
New test case
mysql-test/r/count_distinct.result:
New test case
mysql-test/t/bdb.test:
New test case
mysql-test/t/bigint.test:
New test case
mysql-test/t/count_distinct.test:
New test case
sql-bench/Comments/postgres.benchmark:
Update for PostgreSQL 7.1.2
sql-bench/graph-compare-results.sh:
Fixed colors for mysql --fast tests
sql/field.cc:
Fixed problem when converting bigint to double.
sql/item_sum.cc:
Fixed bug in count(distinct null)
sql/item_sum.h:
Fixed bug in count(distinct null)
sql/mysqlbinlog.cc:
Fixed typo
sql/sql_base.cc:
cleanup
sql/sql_select.cc:
Fixed bug with empty BDB tables.
sql/time.cc:
Removed warning when reading timestamps with sub seconds.
2001-06-19 13:30:12 +02:00
my_bool status = ! strcmp ( row [ 2 ] , " status " ) ;
if ( status )
{
2005-08-10 23:37:17 +02:00
/*
if there was an error with the table , we have - - auto - repair set ,
and this isn ' t a repair op , then add the table to the tables4repair
list
*/
2002-10-17 18:34:02 +02:00
if ( found_error & & opt_auto_repair & & what_to_do ! = DO_REPAIR & &
2005-08-10 23:37:17 +02:00
strcmp ( row [ 3 ] , " OK " ) )
2002-10-17 18:34:02 +02:00
insert_dynamic ( & tables4repair , prev ) ;
Fixed bug in mysqlcheck when using --fast
Fixed problem when converting bigint to double.
Fixed bug in count(distinct null)
Fixed bug with empty BDB tables.
BitKeeper/deleted/.del-ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~dd306b2e583ebde4:
Delete: sql-bench/Results/ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~11038a44f73070e7:
Delete: sql-bench/Results/RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~662b96bc66bc91b6:
Delete: sql-bench/Results/alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~788ad492867b1226:
Delete: sql-bench/Results/big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~5316add301edb60:
Delete: sql-bench/Results/connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~26e09af61f88d8c9:
Delete: sql-bench/Results/create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~fd2699adb3190d07:
Delete: sql-bench/Results/insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~b01175ad38fd12b6:
Delete: sql-bench/Results/select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
BitKeeper/deleted/.del-wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~8ba598d217450157:
Delete: sql-bench/Results/wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg
Docs/manual.texi:
Changelog + update to Linux section
client/mysqlcheck.c:
Fixed bug when using --fast
--check --auto-repair --fast will not anymore repair tables that
had warnings but where ok.
mysql-test/r/bdb.result:
New test case
mysql-test/r/bigint.result:
New test case
mysql-test/r/count_distinct.result:
New test case
mysql-test/t/bdb.test:
New test case
mysql-test/t/bigint.test:
New test case
mysql-test/t/count_distinct.test:
New test case
sql-bench/Comments/postgres.benchmark:
Update for PostgreSQL 7.1.2
sql-bench/graph-compare-results.sh:
Fixed colors for mysql --fast tests
sql/field.cc:
Fixed problem when converting bigint to double.
sql/item_sum.cc:
Fixed bug in count(distinct null)
sql/item_sum.h:
Fixed bug in count(distinct null)
sql/mysqlbinlog.cc:
Fixed typo
sql/sql_base.cc:
cleanup
sql/sql_select.cc:
Fixed bug with empty BDB tables.
sql/time.cc:
Removed warning when reading timestamps with sub seconds.
2001-06-19 13:30:12 +02:00
found_error = 0 ;
if ( opt_silent )
continue ;
}
2001-04-20 00:12:10 +02:00
if ( status & & changed )
printf ( " %-50s %s " , row [ 0 ] , row [ 3 ] ) ;
else if ( ! status & & changed )
2001-04-23 22:29:53 +02:00
{
2001-04-20 00:12:10 +02:00
printf ( " %s \n %-9s: %s " , row [ 0 ] , row [ 2 ] , row [ 3 ] ) ;
2004-05-04 14:02:38 +02:00
if ( strcmp ( row [ 2 ] , " note " ) )
found_error = 1 ;
2001-04-23 22:29:53 +02:00
}
2001-04-20 00:12:10 +02:00
else
printf ( " %-9s: %s " , row [ 2 ] , row [ 3 ] ) ;
strmov ( prev , row [ 0 ] ) ;
2001-04-20 12:21:35 +02:00
putchar ( ' \n ' ) ;
2001-04-20 00:12:10 +02:00
}
2005-08-10 23:37:17 +02:00
/* add the last table to be repaired to the list */
if ( found_error & & opt_auto_repair & & what_to_do ! = DO_REPAIR )
2002-10-17 18:34:02 +02:00
insert_dynamic ( & tables4repair , prev ) ;
2001-04-20 00:12:10 +02:00
mysql_free_result ( res ) ;
}
2001-04-20 12:21:35 +02:00
static int dbConnect ( char * host , char * user , char * passwd )
2001-04-20 00:12:10 +02:00
{
DBUG_ENTER ( " dbConnect " ) ;
if ( verbose )
{
fprintf ( stderr , " # Connecting to %s... \n " , host ? host : " localhost " ) ;
}
mysql_init ( & mysql_connection ) ;
if ( opt_compress )
mysql_options ( & mysql_connection , MYSQL_OPT_COMPRESS , NullS ) ;
# ifdef HAVE_OPENSSL
if ( opt_use_ssl )
mysql_ssl_set ( & mysql_connection , opt_ssl_key , opt_ssl_cert , opt_ssl_ca ,
2001-09-30 04:46:20 +02:00
opt_ssl_capath , opt_ssl_cipher ) ;
2002-11-14 20:16:30 +01:00
# endif
if ( opt_protocol )
mysql_options ( & mysql_connection , MYSQL_OPT_PROTOCOL , ( char * ) & opt_protocol ) ;
# ifdef HAVE_SMEM
if ( shared_memory_base_name )
mysql_options ( & mysql_connection , MYSQL_SHARED_MEMORY_BASE_NAME , shared_memory_base_name ) ;
2001-04-20 00:12:10 +02:00
# endif
if ( ! ( sock = mysql_real_connect ( & mysql_connection , host , user , passwd ,
NULL , opt_mysql_port , opt_mysql_unix_port , 0 ) ) )
{
DBerror ( & mysql_connection , " when trying to connect " ) ;
return 1 ;
}
2004-12-09 14:44:10 +01:00
mysql_connection . reconnect = 1 ;
2001-04-20 00:12:10 +02:00
return 0 ;
} /* dbConnect */
static void dbDisconnect ( char * host )
{
if ( verbose )
fprintf ( stderr , " # Disconnecting from %s... \n " , host ? host : " localhost " ) ;
mysql_close ( sock ) ;
} /* dbDisconnect */
static void DBerror ( MYSQL * mysql , const char * when )
{
DBUG_ENTER ( " DBerror " ) ;
my_printf_error ( 0 , " Got error: %d: %s %s " , MYF ( 0 ) ,
mysql_errno ( mysql ) , mysql_error ( mysql ) , when ) ;
safe_exit ( EX_MYSQLERR ) ;
DBUG_VOID_RETURN ;
} /* DBerror */
static void safe_exit ( int error )
{
if ( ! first_error )
first_error = error ;
if ( ignore_errors )
return ;
if ( sock )
mysql_close ( sock ) ;
exit ( error ) ;
}
int main ( int argc , char * * argv )
{
MY_INIT ( argv [ 0 ] ) ;
/*
* * Check out the args
*/
if ( get_options ( & argc , & argv ) )
{
my_end ( 0 ) ;
exit ( EX_USAGE ) ;
}
if ( dbConnect ( current_host , current_user , opt_password ) )
exit ( EX_MYSQLERR ) ;
2002-04-28 23:22:37 +02:00
if ( opt_auto_repair & &
my_init_dynamic_array ( & tables4repair , sizeof ( char ) * ( NAME_LEN * 2 + 2 ) , 16 , 64 ) )
2001-04-23 22:29:53 +02:00
{
first_error = 1 ;
goto end ;
}
2001-04-20 00:12:10 +02:00
if ( opt_alldbs )
process_all_databases ( ) ;
/* Only one database and selected table(s) */
else if ( argc > 1 & & ! opt_databases )
process_selected_tables ( * argv , ( argv + 1 ) , ( argc - 1 ) ) ;
/* One or more databases, all tables */
else
process_databases ( argv ) ;
2001-04-23 22:29:53 +02:00
if ( opt_auto_repair )
{
uint i ;
if ( ! opt_silent & & tables4repair . elements )
puts ( " \n Repairing tables " ) ;
what_to_do = DO_REPAIR ;
for ( i = 0 ; i < tables4repair . elements ; i + + )
{
char * name = ( char * ) dynamic_array_ptr ( & tables4repair , i ) ;
2007-10-30 09:51:57 +01:00
handle_request_for_tables ( name , fixed_name_length ( name ) ) ;
2001-04-23 22:29:53 +02:00
}
}
end :
2001-04-20 00:12:10 +02:00
dbDisconnect ( current_host ) ;
2001-04-23 22:29:53 +02:00
if ( opt_auto_repair )
delete_dynamic ( & tables4repair ) ;
2001-04-20 00:12:10 +02:00
my_free ( opt_password , MYF ( MY_ALLOW_ZERO_PTR ) ) ;
2002-11-14 20:16:30 +01:00
# ifdef HAVE_SMEM
my_free ( shared_memory_base_name , MYF ( MY_ALLOW_ZERO_PTR ) ) ;
# endif
2001-04-20 00:12:10 +02:00
my_end ( 0 ) ;
2001-04-23 22:29:53 +02:00
return ( first_error ! = 0 ) ;
2001-04-20 00:12:10 +02:00
} /* main */