diff options
-rw-r--r-- | BitKeeper/etc/logging_ok | 1 | ||||
-rwxr-xr-x | BitKeeper/triggers/post-commit | 2 | ||||
-rw-r--r-- | client/mysqldump.c | 5 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | include/config-win.h | 4 | ||||
-rw-r--r-- | include/my_global.h | 4 | ||||
-rw-r--r-- | include/mysql_com.h | 2 | ||||
-rw-r--r-- | innobase/row/row0sel.c | 10 | ||||
-rw-r--r-- | myisam/myisamchk.c | 6 | ||||
-rw-r--r-- | mysql-test/r/func_crypt.result | 10 | ||||
-rw-r--r-- | mysql-test/r/myisam.result | 1 | ||||
-rw-r--r-- | mysql-test/t/func_crypt.test | 9 | ||||
-rw-r--r-- | mysql-test/t/myisam.test | 1 | ||||
-rw-r--r-- | mysys/my_new.cc | 4 | ||||
-rw-r--r-- | scripts/mysql_secure_installation.sh | 10 | ||||
-rw-r--r-- | scripts/mysqlhotcopy.sh | 19 | ||||
-rw-r--r-- | sql/item_func.cc | 2 | ||||
-rw-r--r-- | sql/mysqld.cc | 25 | ||||
-rw-r--r-- | sql/sql_parse.cc | 38 | ||||
-rw-r--r-- | sql/sql_select.cc | 2 | ||||
-rw-r--r-- | support-files/mysql.server.sh | 26 |
21 files changed, 126 insertions, 57 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 4c1777f1434..afb9c5cff5c 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -48,6 +48,7 @@ jcole@sarvik.tfr.cafe.ee jcole@tetra.spaceapes.com jorge@linux.jorge.mysql.com kaj@work.mysql.com +konstantin@mysql.com kostja@oak.local lenz@kallisto.mysql.com lenz@mysql.com diff --git a/BitKeeper/triggers/post-commit b/BitKeeper/triggers/post-commit index 636e4262693..2dfefb5deb3 100755 --- a/BitKeeper/triggers/post-commit +++ b/BitKeeper/triggers/post-commit @@ -19,7 +19,7 @@ BK_STATUS=$BK_STATUS$BK_COMMIT if [ "$BK_STATUS" = OK ] then -CHANGESET=`bk -R prs -r+ -h -d':I:' ChangeSet` +CHANGESET=`bk -R prs -r+ -h -d':P:::I:' ChangeSet` #++ # dev-public@ diff --git a/client/mysqldump.c b/client/mysqldump.c index b28373ccd4a..40f88021c89 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1271,10 +1271,13 @@ static int init_dumping(char *database) { if (opt_databases || opt_alldbs) { + /* length of table name * 2 (if name contain quotas), 2 quotas and 0 */ + char quoted_database_buf[64*2+3]; + char *qdatabase= quote_name(database,quoted_database_buf,opt_quoted); fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", database); if (!opt_create_db) fprintf(md_result_file,"\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n", - database); + qdatabase); fprintf(md_result_file,"\nUSE %s;\n", database); } } diff --git a/configure.in b/configure.in index 8ce3a9aea67..02825ce1424 100644 --- a/configure.in +++ b/configure.in @@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! -AM_INIT_AUTOMAKE(mysql, 4.0.16) +AM_INIT_AUTOMAKE(mysql, 4.0.17) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 diff --git a/include/config-win.h b/include/config-win.h index 9f903b3bcd2..53dff5d63af 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -173,8 +173,8 @@ inline double rint(double nr) } #ifdef _WIN64 -#define ulonglong2double(A) ((double) (A)) -#define my_off_t2double(A) ((double) (A)) +#define ulonglong2double(A) ((double) (ulonglong) (A)) +#define my_off_t2double(A) ((double) (my_off_t) (A)) #else inline double ulonglong2double(ulonglong value) diff --git a/include/my_global.h b/include/my_global.h index 59e0c43f18d..349ac8ac82e 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -571,8 +571,8 @@ extern double my_atof(const char*); #define closesocket(A) close(A) #endif #ifndef ulonglong2double -#define ulonglong2double(A) ((double) (A)) -#define my_off_t2double(A) ((double) (A)) +#define ulonglong2double(A) ((double) (ulonglong) (A)) +#define my_off_t2double(A) ((double) (my_off_t) (A)) #endif #endif diff --git a/include/mysql_com.h b/include/mysql_com.h index 6daf26bc2ac..a874034ba46 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -31,7 +31,7 @@ #if defined(__WIN__) && !defined( _CUSTOMCONFIG_) #define MYSQL_NAMEDPIPE "MySQL" -#define MYSQL_SERVICENAME "MySql" +#define MYSQL_SERVICENAME "MySQL" #endif /* __WIN__ */ enum enum_server_command { diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c index 482f82b02ba..f02fbeeb8fd 100644 --- a/innobase/row/row0sel.c +++ b/innobase/row/row0sel.c @@ -3222,8 +3222,14 @@ rec_loop: latest version of the record */ } else if (index == clust_index) { - - if (!lock_clust_rec_cons_read_sees(rec, index, + + /* Fetch a previous version of the row if the current + one is not visible in the snapshot; if we have a very + high force recovery level set, we try to avoid crashes + by skipping this lookup */ + + if (srv_force_recovery < 5 + && !lock_clust_rec_cons_read_sees(rec, index, trx->read_view)) { err = row_sel_build_prev_vers_for_mysql( diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index b7627fc59fd..f1deda41f8b 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -401,7 +401,9 @@ static void usage(void) Change the character set used by the index\n\ -q, --quick Faster repair by not modifying the data file.\n\ One can give a second '-q' to force myisamchk to\n\ - modify the original datafile in case of duplicate keys\n\ + modify the original datafile in case of duplicate keys.\n\ + NOTE: Tables where the data file is currupted can't be\n\ + fixed with this option.\n\ -u, --unpack Unpack file packed with myisampack.\n\ "); @@ -1094,7 +1096,7 @@ end2: filename)); if (param->testflag & T_REP_ANY) VOID(fprintf(stderr, - "Try fixing it by using the --safe-recover (-o) or the --force (-f) option\n")); + "Try fixing it by using the --safe-recover (-o), the --force (-f) option or by not using the --quick (-q) flag\n")); } else if (!(param->error_printed & 2) && !(param->testflag & T_FORCE_CREATE)) diff --git a/mysql-test/r/func_crypt.result b/mysql-test/r/func_crypt.result index 742de833bf7..96bbaa6cae7 100644 --- a/mysql-test/r/func_crypt.result +++ b/mysql-test/r/func_crypt.result @@ -7,3 +7,13 @@ old_password('test') password('test') select length(encrypt('test')), encrypt('test','aa'); length(encrypt('test')) encrypt('test','aa') 13 aaqPiZY5xR5l. +drop table if exists t1; +create table t1 (name varchar(50), pw varchar(16)); +insert into t1 values ('tom', password('my_pass')); +set @pass='my_pass'; +select name from t1 where name='tom' and pw=password(@pass); +name +tom +select name from t1 where name='tom' and pw=password(@undefined); +name +drop table t1; diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 3052af3499d..e113a48f4da 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -83,7 +83,6 @@ OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize status OK DROP TABLE t1; -drop table if exists t1; create table t1 ( t1 char(255), key(t1(250))); insert t1 values ('137513751375137513751375137513751375137569516951695169516951695169516951695169'); insert t1 values ('178417841784178417841784178417841784178403420342034203420342034203420342034203'); diff --git a/mysql-test/t/func_crypt.test b/mysql-test/t/func_crypt.test index f403d96e885..e612405c5e9 100644 --- a/mysql-test/t/func_crypt.test +++ b/mysql-test/t/func_crypt.test @@ -4,3 +4,12 @@ select length(encrypt('foo', 'ff')) <> 0; --replace_result $1$aa$4OSUA5cjdx0RUQ08opV27/ aaqPiZY5xR5l. select old_password('test'), password('test'); select length(encrypt('test')), encrypt('test','aa'); + +drop table if exists t1; +create table t1 (name varchar(50), pw varchar(16)); +insert into t1 values ('tom', password('my_pass')); +set @pass='my_pass'; +select name from t1 where name='tom' and pw=password(@pass); +select name from t1 where name='tom' and pw=password(@undefined); +drop table t1; + diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index a5490153a17..12853cd67ca 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -88,7 +88,6 @@ DROP TABLE t1; # in ha_myisam::repair, and index size is changed (decreased). # -drop table if exists t1; create table t1 ( t1 char(255), key(t1(250))); insert t1 values ('137513751375137513751375137513751375137569516951695169516951695169516951695169'); insert t1 values ('178417841784178417841784178417841784178403420342034203420342034203420342034203'); diff --git a/mysys/my_new.cc b/mysys/my_new.cc index 5cc291af9aa..5f2da90bbd1 100644 --- a/mysys/my_new.cc +++ b/mysys/my_new.cc @@ -25,12 +25,12 @@ void *operator new (size_t sz) { - return (void *) malloc (sz ? sz+1 : sz); + return (void *) malloc (sz ? sz : 1); } void *operator new[] (size_t sz) { - return (void *) malloc (sz ? sz+1 : sz); + return (void *) malloc (sz ? sz : 1); } void operator delete (void *ptr) diff --git a/scripts/mysql_secure_installation.sh b/scripts/mysql_secure_installation.sh index d6392c57731..1c7ca34ad59 100644 --- a/scripts/mysql_secure_installation.sh +++ b/scripts/mysql_secure_installation.sh @@ -85,9 +85,13 @@ set_root_password() { return 1 fi - do_query "SET PASSWORD FOR root=PASSWORD('$password1');" + do_query "UPDATE mysql.user SET Password=PASSWORD('$password1') WHERE User='root';" if [ $? -eq 0 ]; then echo "Password updated successfully!" + echo "Reloading privilege tables.." + if ! reload_privilege_tables; then + exit 1 + fi echo rootpass=$password1 make_config @@ -144,11 +148,11 @@ reload_privilege_tables() { do_query "FLUSH PRIVILEGES;" if [ $? -eq 0 ]; then echo " ... Success!" + return 0 else echo " ... Failed!" + return 1 fi - - return 0 } interrupt() { diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh index f23955da06a..654e5466e12 100644 --- a/scripts/mysqlhotcopy.sh +++ b/scripts/mysqlhotcopy.sh @@ -37,7 +37,7 @@ WARNING: THIS PROGRAM IS STILL IN BETA. Comments/patches welcome. # Documentation continued at end of file -my $VERSION = "1.19"; +my $VERSION = "1.20"; my $opt_tmpdir = $ENV{TMPDIR} || "/tmp"; @@ -235,10 +235,15 @@ else # --- resolve database names from regexp --- if ( defined $opt{regexp} ) { + my $t_regex = '.*'; + if ( $opt{regexp} =~ s{^/(.+)/\./(.+)/$}{$1} ) { + $t_regex = $2; + } + my $sth_dbs = $dbh->prepare("show databases"); $sth_dbs->execute; while ( my ($db_name) = $sth_dbs->fetchrow_array ) { - push @db_desc, { 'src' => $db_name } if ( $db_name =~ m/$opt{regexp}/o ); + push @db_desc, { 'src' => $db_name, 't_regex' => $t_regex } if ( $db_name =~ m/$opt{regexp}/o ); } } @@ -413,6 +418,8 @@ foreach my $rdb ( @db_desc ) { else { mkdir($tgt_dirpath, 0750) or die "Can't create '$tgt_dirpath': $!\n" unless -d $tgt_dirpath; + my @f_info= stat "$datadir/$rdb->{src}"; + chown $f_info[4], $f_info[5], $tgt_dirpath; } } } @@ -938,6 +945,14 @@ server in a mutual replication setup. Copy all databases with names matching the pattern +=item --regexp /pattern1/./pattern2/ + +Copy all tables with names matching pattern2 from all databases with +names matching pattern1. For example, to select all tables which +names begin with 'bar' from all databases which names end with 'foo': + + mysqlhotcopy --indices --method=cp --regexp /foo$/./^bar/ + =item db_name./pattern/ Copy only tables matching pattern. Shell metacharacters ( (, ), |, !, diff --git a/sql/item_func.cc b/sql/item_func.cc index fd6d17d0cf2..8d7ee637d73 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2087,7 +2087,7 @@ void Item_func_get_user_var::fix_length_and_dec() bool Item_func_get_user_var::const_item() const { - return var_entry && current_thd->query_id != var_entry->update_query_id; + return (!var_entry || current_thd->query_id != var_entry->update_query_id); } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 811984e50b4..e5ddbfe7a33 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1958,7 +1958,7 @@ extern "C" pthread_handler_decl(handle_shutdown,arg) #endif -const char *load_default_groups[]= { "mysqld","server",MYSQL_BASE_VERSION,0 }; +const char *load_default_groups[]= { "mysqld","server",MYSQL_BASE_VERSION,0,0}; bool open_log(MYSQL_LOG *log, const char *hostname, const char *opt_name, const char *extension, @@ -2561,7 +2561,7 @@ default_service_handling(char **argv, const char *extra_opt) { char path_and_service[FN_REFLEN+FN_REFLEN+32], *pos, *end; - end= path_and_service + sizeof(path_and_service)-1; + end= path_and_service + sizeof(path_and_service)-3; /* We have to quote filename if it contains spaces */ pos= add_quoted_string(path_and_service, file_path, end); @@ -2571,7 +2571,9 @@ default_service_handling(char **argv, *pos++= ' '; pos= add_quoted_string(pos, extra_opt, end); } - *pos= 0; // Ensure end null + /* We must have servicename last */ + *pos++= ' '; + strmake(pos, servicename, (uint) (end+2 - pos)); if (Service.got_service_option(argv, "install")) { @@ -2613,10 +2615,16 @@ int main(int argc, char **argv) if (!default_service_handling(argv, MYSQL_SERVICENAME, MYSQL_SERVICENAME, file_path, "")) return 0; - if (Service.IsService(argv[1])) + if (Service.IsService(argv[1])) /* Start an optional service */ { - /* start an optional service */ - load_default_groups[0]= argv[1]; + /* + Only add the service name to the groups read from the config file + if it's not "MySQL". (The default service name should be 'mysqld' + but we started a bad tradition by calling it MySQL from the start + and we are now stuck with it. + */ + if (my_strcasecmp(argv[1],"mysql")) + load_default_groups[3]= argv[1]; start_mode= 1; Service.Init(argv[1], mysql_service); return 0; @@ -2624,8 +2632,7 @@ int main(int argc, char **argv) } else if (argc == 3) /* install or remove any optional service */ { - if (!default_service_handling(argv, argv[2], argv[2], file_path, - argv[2])) + if (!default_service_handling(argv, argv[2], argv[2], file_path, "")) return 0; if (Service.IsService(argv[2])) { @@ -2637,6 +2644,8 @@ int main(int argc, char **argv) opt_argc= 2; // Skip service-name opt_argv=argv; start_mode= 1; + if (my_strcasecmp(argv[2],"mysql")) + load_default_groups[3]= argv[2]; Service.Init(argv[2], mysql_service); return 0; } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e068c309e21..0789a1768d1 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -156,7 +156,7 @@ static int get_or_create_user_conn(THD *thd, const char *user, uc->user_len= user_len; uc->host=uc->user + uc->user_len + 1; uc->len = temp_len; - uc->connections = 1; + uc->connections = 0; uc->questions=uc->updates=uc->conn_per_hour=0; uc->user_resources=*mqh; if (max_user_connections && mqh->connections > max_user_connections) @@ -171,6 +171,7 @@ static int get_or_create_user_conn(THD *thd, const char *user, } } thd->user_connect=uc; + uc->connections++; end: (void) pthread_mutex_unlock(&LOCK_user_conn); return return_val; @@ -255,8 +256,8 @@ static bool check_user(THD *thd,enum_server_command command, const char *user, if ((ur.questions || ur.updates || ur.connections || max_user_connections) && get_or_create_user_conn(thd,user,thd->host_or_ip,&ur)) return -1; - if (thd->user_connect && ((thd->user_connect->user_resources.connections) || - max_user_connections) && + if (thd->user_connect && (thd->user_connect->user_resources.connections || + max_user_connections) && check_for_max_user_connections(thd->user_connect)) return -1; if (db && db[0]) @@ -302,17 +303,17 @@ static int check_for_max_user_connections(USER_CONN *uc) { int error=0; DBUG_ENTER("check_for_max_user_connections"); - + + (void) pthread_mutex_lock(&LOCK_user_conn); if (max_user_connections && - (max_user_connections < (uint) uc->connections)) + max_user_connections < uc->connections) { net_printf(&(current_thd->net),ER_TOO_MANY_USER_CONNECTIONS, uc->user); error=1; goto end; } - uc->connections++; if (uc->user_resources.connections && - uc->conn_per_hour++ >= uc->user_resources.connections) + uc->user_resources.connections <= uc->conn_per_hour) { net_printf(¤t_thd->net, ER_USER_LIMIT_REACHED, uc->user, "max_connections", @@ -320,7 +321,11 @@ static int check_for_max_user_connections(USER_CONN *uc) error=1; goto end; } + uc->conn_per_hour++; end: + if (error) + uc->connections--; // no need for decrease_user_connections() here + (void) pthread_mutex_unlock(&LOCK_user_conn); DBUG_RETURN(error); } @@ -328,13 +333,14 @@ end: static void decrease_user_connections(USER_CONN *uc) { DBUG_ENTER("decrease_user_connections"); - if ((uc->connections && !--uc->connections) && !mqh_used) + (void) pthread_mutex_lock(&LOCK_user_conn); + DBUG_ASSERT(uc->connections); + if (!--uc->connections && !mqh_used) { /* Last connection for user; Delete it */ - (void) pthread_mutex_lock(&LOCK_user_conn); (void) hash_delete(&hash_user_connections,(byte*) uc); - (void) pthread_mutex_unlock(&LOCK_user_conn); } + (void) pthread_mutex_unlock(&LOCK_user_conn); DBUG_VOID_RETURN; } @@ -1007,14 +1013,17 @@ bool dispatch_command(enum enum_server_command command, THD *thd, char *save_user= thd->user; char *save_priv_user= thd->priv_user; char *save_db= thd->db; - thd->user=0; - USER_CONN *save_uc= thd->user_connect; + USER_CONN *save_user_connect= thd->user_connect; if ((uint) ((uchar*) db - net->read_pos) > packet_length) { // Check if protocol is ok send_error(net, ER_UNKNOWN_COM_ERROR); break; } + + /* Clear variables that are allocated */ + thd->user= 0; + thd->user_connect= 0; if (check_user(thd, COM_CHANGE_USER, user, passwd, db, 0)) { // Restore old user x_free(thd->user); @@ -1024,10 +1033,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd, thd->db_length=save_db_length; thd->user=save_user; thd->priv_user=save_priv_user; + thd->user_connect= save_user_connect; break; } - if (max_connections && save_uc) - decrease_user_connections(save_uc); + if (save_user_connect) + decrease_user_connections(save_user_connect); x_free((gptr) save_db); x_free((gptr) save_user); break; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f1ab998c0fa..55813378b9c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2600,6 +2600,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) table_map used_tables; if (join->tables > 1) cond->update_used_tables(); // Tablenr may have changed + if (join->const_tables == join->tables) + join->const_table_map|=RAND_TABLE_BIT; { // Check const tables COND *const_cond= make_cond_for_table(cond,join->const_table_map,(table_map) 0); diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index 89d45e0f26d..36eb5c4dff6 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -109,19 +109,6 @@ else fi # -# Set pid file if not given -# -if test -z "$pid_file" -then - pid_file=$datadir/`@HOSTNAME@`.pid -else - case "$pid_file" in - /* ) ;; - * ) pid_file="$datadir/$pid_file" ;; - esac -fi - -# # Test if someone changed datadir; In this case we should also read the # default arguments from this directory # @@ -134,6 +121,19 @@ fi parse_arguments `$print_defaults $extra_args mysqld mysql_server mysql.server` +# +# Set pid file if not given +# +if test -z "$pid_file" +then + pid_file=$datadir/`@HOSTNAME@`.pid +else + case "$pid_file" in + /* ) ;; + * ) pid_file="$datadir/$pid_file" ;; + esac +fi + # Safeguard (relative paths, core dumps..) cd $basedir |