From 81c0732a459df71f533cdcc09d1dfec71da17ea6 Mon Sep 17 00:00:00 2001 From: "mwagner@here.mwagner.org" <> Date: Thu, 24 Jun 2004 12:22:48 -0500 Subject: [PATCH 01/49] logger.pm, Bootstrap: Updates for output enhanced Bootstrap --- Build-tools/Bootstrap | 9 +++++---- Build-tools/logger.pm | 15 +++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Build-tools/Bootstrap b/Build-tools/Bootstrap index a46d83ca91c..fa3c6344a05 100755 --- a/Build-tools/Bootstrap +++ b/Build-tools/Bootstrap @@ -46,6 +46,7 @@ $opt_test= undef; $opt_skip_check= undef; $opt_skip_manual= undef; $opt_win_dist= undef; +$opt_quiet= undef; $version= "unknown"; $major=$minor=$release=0; @@ -67,7 +68,8 @@ GetOptions( "suffix=s", "test|t", "verbose|v", - "win-dist|w" + "win-dist|w", + "quiet|q", ) || print_help(""); # @@ -99,8 +101,6 @@ if (defined $opt_build_command) print_help("") if ($opt_help); defined($REPO=$ARGV[0]) || print_help("Please enter the BK repository to be used!"); -$subject= "Bootstrap of $REPO failed" if $opt_mail; - &logger("Starting build"); &abort("The directory \"$REPO\" could not be found!") if (!-d $REPO); &logger("Using $REPO as the BK parent repository"); @@ -306,7 +306,7 @@ if (!$opt_dry_run) # # Now build the source distribution # -&logger("Compiling"); +&logger("Compiling..."); $command= $build_command; &run_command($command, "Compilation failed!"); @@ -403,6 +403,7 @@ Options: include a log file snippet, if logging is enabled) Note that the \@-Sign needs to be quoted! Example: --mail=user\\\@domain.com +-q, --quiet Be quiet -p, --pull Update the source BK trees before building -r, --revision= Export the tree as of revision (default is up to the latest revision) diff --git a/Build-tools/logger.pm b/Build-tools/logger.pm index 835d8014aa0..d3fb4c9db2f 100644 --- a/Build-tools/logger.pm +++ b/Build-tools/logger.pm @@ -5,7 +5,10 @@ # sub logger { - my $message=$_[0]; + my $message= $_[0]; + my $cmnd= $_[1]; + + print $message . "\n" if !$opt_quiet && !$opt_verbose && !$cmnd; print timestamp() . " " . $message . "\n" if $opt_verbose; if (defined $opt_log && !$opt_dry_run) { @@ -30,9 +33,12 @@ sub run_command } else { - &logger($command); - $command.= " >> $LOGFILE 2>&1" if defined $opt_log; - $command.= " > /dev/null" if (!$opt_verbose && !$opt_log); + &logger($command, 1); + + $command.= ';' unless ($command =~ m/^.*;$/); + + $command =~ s/;/ >> $LOGFILE 2>&1;/g if defined $opt_log; + $command =~ s/;/ > \/dev\/null;/g if (!$opt_verbose && !$opt_log); system($command) == 0 or &abort("$errormsg\n"); } } @@ -47,6 +53,7 @@ sub abort { my $message= $_[0]; my $messagefile; + my $subject= "Bootstrap of $REPO failed" if $opt_mail; $message= "ERROR: " . $message; &logger($message); From e228547a61d958f9702ac59ac06ef41116910d55 Mon Sep 17 00:00:00 2001 From: "vva@eagle.mysql.r18.ru" <> Date: Mon, 28 Jun 2004 15:53:49 +0500 Subject: [PATCH 02/49] s/\r\n/\n/ in mysql-test/*/system_mysql_db* according to http://www.bitkeeper.com/Documentation.FAQS.Windows_NT.html --- mysql-test/r/system_mysql_db_refs.result | 56 ++++---- mysql-test/t/system_mysql_db.test | 16 +-- mysql-test/t/system_mysql_db_fix.test | 142 +++++++++---------- mysql-test/t/system_mysql_db_refs.test | 168 +++++++++++------------ 4 files changed, 191 insertions(+), 191 deletions(-) diff --git a/mysql-test/r/system_mysql_db_refs.result b/mysql-test/r/system_mysql_db_refs.result index e15934b03ac..ac072505bc9 100644 --- a/mysql-test/r/system_mysql_db_refs.result +++ b/mysql-test/r/system_mysql_db_refs.result @@ -18,44 +18,44 @@ create table test_columns_priv select * from mysql.columns_priv; delete from test_columns_priv; insert into test_columns_priv (Host,Db,User,Table_name,Column_name) values (@name,@name,@name,@name,@name); select -if(isnull(test_db.Host),'WRONG!!!','ok') as test_db_Host, -if(isnull(test_host.Host),'WRONG!!!','ok') as test_host_Host, -if(isnull(test_user.Host),'WRONG!!!','ok') as test_user_Host, -if(isnull(test_tables_priv.Host),'WRONG!!!','ok') as test_tables_priv_Host, -if(isnull(test_columns_priv.Host),'WRONG!!!','ok') as test_columns_priv_Host -from test_db -left join test_host on test_db.Host=test_host.Host -left join test_user on test_db.Host=test_user.Host -left join test_tables_priv on test_db.Host=test_tables_priv.Host +if(isnull(test_db.Host),'WRONG!!!','ok') as test_db_Host, +if(isnull(test_host.Host),'WRONG!!!','ok') as test_host_Host, +if(isnull(test_user.Host),'WRONG!!!','ok') as test_user_Host, +if(isnull(test_tables_priv.Host),'WRONG!!!','ok') as test_tables_priv_Host, +if(isnull(test_columns_priv.Host),'WRONG!!!','ok') as test_columns_priv_Host +from test_db +left join test_host on test_db.Host=test_host.Host +left join test_user on test_db.Host=test_user.Host +left join test_tables_priv on test_db.Host=test_tables_priv.Host left join test_columns_priv on test_db.Host=test_columns_priv.Host; test_db_Host test_host_Host test_user_Host test_tables_priv_Host test_columns_priv_Host ok ok ok ok ok select -if(isnull(test_db.Db),'WRONG!!!','ok') as test_db_Db, -if(isnull(test_host.Db),'WRONG!!!','ok') as test_host_Db, -if(isnull(test_tables_priv.Db),'WRONG!!!','ok') as test_tables_priv_Db, -if(isnull(test_columns_priv.Db),'WRONG!!!','ok') as est_columns_priv_Db -from test_db -left join test_host on test_db.Db=test_host.Db -left join test_tables_priv on test_db.Db=test_tables_priv.Db +if(isnull(test_db.Db),'WRONG!!!','ok') as test_db_Db, +if(isnull(test_host.Db),'WRONG!!!','ok') as test_host_Db, +if(isnull(test_tables_priv.Db),'WRONG!!!','ok') as test_tables_priv_Db, +if(isnull(test_columns_priv.Db),'WRONG!!!','ok') as est_columns_priv_Db +from test_db +left join test_host on test_db.Db=test_host.Db +left join test_tables_priv on test_db.Db=test_tables_priv.Db left join test_columns_priv on test_db.Db=test_columns_priv.Db; test_db_Db test_host_Db test_tables_priv_Db est_columns_priv_Db ok ok ok ok -select -if(isnull(test_db.User),'WRONG!!!','ok') as test_db_User, -if(isnull(test_user.User),'WRONG!!!','ok') as test_user_User, -if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User, -if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User -from test_db -left join test_user on test_db.User=test_user.User -left join test_tables_priv on test_db.User=test_tables_priv.User +select +if(isnull(test_db.User),'WRONG!!!','ok') as test_db_User, +if(isnull(test_user.User),'WRONG!!!','ok') as test_user_User, +if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User, +if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User +from test_db +left join test_user on test_db.User=test_user.User +left join test_tables_priv on test_db.User=test_tables_priv.User left join test_columns_priv on test_db.User=test_columns_priv.User; test_db_User test_user_User test_tables_priv_User test_columns_priv_User ok ok ok ok -select -if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User, -if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User -from test_tables_priv +select +if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User, +if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User +from test_tables_priv left join test_columns_priv on test_tables_priv.Table_name=test_columns_priv.Table_name; test_tables_priv_User test_columns_priv_User ok ok diff --git a/mysql-test/t/system_mysql_db.test b/mysql-test/t/system_mysql_db.test index bd69297b739..85a2f7f9bae 100644 --- a/mysql-test/t/system_mysql_db.test +++ b/mysql-test/t/system_mysql_db.test @@ -1,8 +1,8 @@ -# -# This test must examine integrity of system database "mysql" -# - --- disable_query_log -use mysql; --- enable_query_log --- source include/system_db_struct.inc +# +# This test must examine integrity of system database "mysql" +# + +-- disable_query_log +use mysql; +-- enable_query_log +-- source include/system_db_struct.inc diff --git a/mysql-test/t/system_mysql_db_fix.test b/mysql-test/t/system_mysql_db_fix.test index 6f3979bf66e..0acc7ea073d 100644 --- a/mysql-test/t/system_mysql_db_fix.test +++ b/mysql-test/t/system_mysql_db_fix.test @@ -1,78 +1,78 @@ -# +# # This is the test for mysql_fix_privilege_tables -# +# --- disable_result_log --- disable_query_log - -use test; - -# create system tables as in mysql-3.20 - -CREATE TABLE db ( - Host char(60) binary DEFAULT '' NOT NULL, - Db char(32) binary DEFAULT '' NOT NULL, - User char(16) binary DEFAULT '' NOT NULL, - Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, - PRIMARY KEY Host (Host,Db,User), - KEY User (User) -) -type=ISAM; +-- disable_result_log +-- disable_query_log -INSERT INTO db VALUES ('%','test', '','Y','Y','Y','Y','Y','Y'); -INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y'); +use test; -CREATE TABLE host ( - Host char(60) binary DEFAULT '' NOT NULL, - Db char(32) binary DEFAULT '' NOT NULL, - Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, - PRIMARY KEY Host (Host,Db) -) -type=ISAM; +# create system tables as in mysql-3.20 -CREATE TABLE user ( - Host char(60) binary DEFAULT '' NOT NULL, - User char(16) binary DEFAULT '' NOT NULL, - Password char(16), - Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Reload_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Shutdown_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Process_priv enum('N','Y') DEFAULT 'N' NOT NULL, - PRIMARY KEY Host (Host,User) -) -type=ISAM; +CREATE TABLE db ( + Host char(60) binary DEFAULT '' NOT NULL, + Db char(32) binary DEFAULT '' NOT NULL, + User char(16) binary DEFAULT '' NOT NULL, + Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, + PRIMARY KEY Host (Host,Db,User), + KEY User (User) +) +type=ISAM; + +INSERT INTO db VALUES ('%','test', '','Y','Y','Y','Y','Y','Y'); +INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y'); + +CREATE TABLE host ( + Host char(60) binary DEFAULT '' NOT NULL, + Db char(32) binary DEFAULT '' NOT NULL, + Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, + PRIMARY KEY Host (Host,Db) +) +type=ISAM; + +CREATE TABLE user ( + Host char(60) binary DEFAULT '' NOT NULL, + User char(16) binary DEFAULT '' NOT NULL, + Password char(16), + Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Reload_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Shutdown_priv enum('N','Y') DEFAULT 'N' NOT NULL, + Process_priv enum('N','Y') DEFAULT 'N' NOT NULL, + PRIMARY KEY Host (Host,User) +) +type=ISAM; + +INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y'); +INSERT INTO user VALUES ('localhost','', '','N','N','N','N','N','N','N','N','N'); -INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y'); -INSERT INTO user VALUES ('localhost','', '','N','N','N','N','N','N','N','N','N'); - -- exec $MYSQL_FIX_SYSTEM_TABLES --database=test --- enable_query_log --- enable_result_log - --- source include/system_db_struct.inc - --- disable_query_log - -DROP TABLE db; -DROP TABLE host; -DROP TABLE user; -DROP TABLE func; -DROP TABLE tables_priv; -DROP TABLE columns_priv; - --- enable_query_log +-- enable_query_log +-- enable_result_log + +-- source include/system_db_struct.inc + +-- disable_query_log + +DROP TABLE db; +DROP TABLE host; +DROP TABLE user; +DROP TABLE func; +DROP TABLE tables_priv; +DROP TABLE columns_priv; + +-- enable_query_log diff --git a/mysql-test/t/system_mysql_db_refs.test b/mysql-test/t/system_mysql_db_refs.test index 49d6f198b32..b68503a6aa5 100644 --- a/mysql-test/t/system_mysql_db_refs.test +++ b/mysql-test/t/system_mysql_db_refs.test @@ -1,89 +1,89 @@ -# -# This test must examine integrity of current system database -# - -set @name="This is a very long string, that mustn't find room in a system field like Table_name. Thus it should be cut by the actual size of the field. So we can use this string to find out the actual length of the field and to use it in any compare queries"; - -# -# If this part is wrong, most likely you've done wrong modification of system database "mysql" -# - -create table test_db select * from mysql.db; -delete from test_db; -insert into test_db (Host,Db,User) values (@name,@name,@name); - -create table test_host select * from mysql.host; -delete from test_host; -insert into test_host (Host,Db) values (@name,@name); - -create table test_user select * from mysql.user; -delete from test_user; -insert into test_user (Host,User) values (@name,@name); - -create table test_func select * from mysql.func; -delete from test_func; -insert into test_func (name) values (@name); - -create table test_tables_priv select * from mysql.tables_priv; -delete from test_tables_priv; -insert into test_tables_priv (Host,Db,User,Table_name) values (@name,@name,@name,@name); - -create table test_columns_priv select * from mysql.columns_priv; -delete from test_columns_priv; -insert into test_columns_priv (Host,Db,User,Table_name,Column_name) values (@name,@name,@name,@name,@name); - -# 'Host' field must be the same for all the tables: - +# +# This test must examine integrity of current system database +# + +set @name="This is a very long string, that mustn't find room in a system field like Table_name. Thus it should be cut by the actual size of the field. So we can use this string to find out the actual length of the field and to use it in any compare queries"; + +# +# If this part is wrong, most likely you've done wrong modification of system database "mysql" +# + +create table test_db select * from mysql.db; +delete from test_db; +insert into test_db (Host,Db,User) values (@name,@name,@name); + +create table test_host select * from mysql.host; +delete from test_host; +insert into test_host (Host,Db) values (@name,@name); + +create table test_user select * from mysql.user; +delete from test_user; +insert into test_user (Host,User) values (@name,@name); + +create table test_func select * from mysql.func; +delete from test_func; +insert into test_func (name) values (@name); + +create table test_tables_priv select * from mysql.tables_priv; +delete from test_tables_priv; +insert into test_tables_priv (Host,Db,User,Table_name) values (@name,@name,@name,@name); + +create table test_columns_priv select * from mysql.columns_priv; +delete from test_columns_priv; +insert into test_columns_priv (Host,Db,User,Table_name,Column_name) values (@name,@name,@name,@name,@name); + +# 'Host' field must be the same for all the tables: + select - if(isnull(test_db.Host),'WRONG!!!','ok') as test_db_Host, - if(isnull(test_host.Host),'WRONG!!!','ok') as test_host_Host, - if(isnull(test_user.Host),'WRONG!!!','ok') as test_user_Host, - if(isnull(test_tables_priv.Host),'WRONG!!!','ok') as test_tables_priv_Host, - if(isnull(test_columns_priv.Host),'WRONG!!!','ok') as test_columns_priv_Host + if(isnull(test_db.Host),'WRONG!!!','ok') as test_db_Host, + if(isnull(test_host.Host),'WRONG!!!','ok') as test_host_Host, + if(isnull(test_user.Host),'WRONG!!!','ok') as test_user_Host, + if(isnull(test_tables_priv.Host),'WRONG!!!','ok') as test_tables_priv_Host, + if(isnull(test_columns_priv.Host),'WRONG!!!','ok') as test_columns_priv_Host + +from test_db +left join test_host on test_db.Host=test_host.Host +left join test_user on test_db.Host=test_user.Host +left join test_tables_priv on test_db.Host=test_tables_priv.Host +left join test_columns_priv on test_db.Host=test_columns_priv.Host; + +# 'Db' field must be the same for all the tables: -from test_db -left join test_host on test_db.Host=test_host.Host -left join test_user on test_db.Host=test_user.Host -left join test_tables_priv on test_db.Host=test_tables_priv.Host -left join test_columns_priv on test_db.Host=test_columns_priv.Host; - -# 'Db' field must be the same for all the tables: - select - if(isnull(test_db.Db),'WRONG!!!','ok') as test_db_Db, - if(isnull(test_host.Db),'WRONG!!!','ok') as test_host_Db, - if(isnull(test_tables_priv.Db),'WRONG!!!','ok') as test_tables_priv_Db, - if(isnull(test_columns_priv.Db),'WRONG!!!','ok') as est_columns_priv_Db + if(isnull(test_db.Db),'WRONG!!!','ok') as test_db_Db, + if(isnull(test_host.Db),'WRONG!!!','ok') as test_host_Db, + if(isnull(test_tables_priv.Db),'WRONG!!!','ok') as test_tables_priv_Db, + if(isnull(test_columns_priv.Db),'WRONG!!!','ok') as est_columns_priv_Db -from test_db -left join test_host on test_db.Db=test_host.Db -left join test_tables_priv on test_db.Db=test_tables_priv.Db -left join test_columns_priv on test_db.Db=test_columns_priv.Db; - -# 'User' field must be the same for all the tables: - -select - if(isnull(test_db.User),'WRONG!!!','ok') as test_db_User, - if(isnull(test_user.User),'WRONG!!!','ok') as test_user_User, - if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User, - if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User +from test_db +left join test_host on test_db.Db=test_host.Db +left join test_tables_priv on test_db.Db=test_tables_priv.Db +left join test_columns_priv on test_db.Db=test_columns_priv.Db; -from test_db -left join test_user on test_db.User=test_user.User -left join test_tables_priv on test_db.User=test_tables_priv.User -left join test_columns_priv on test_db.User=test_columns_priv.User; - -# 'Table_name' field must be the same for all the tables: - -select - if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User, - if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User -from test_tables_priv -left join test_columns_priv on test_tables_priv.Table_name=test_columns_priv.Table_name; - -drop table test_columns_priv; -drop table test_tables_priv; -drop table test_func; -drop table test_host; -drop table test_user; -drop table test_db; +# 'User' field must be the same for all the tables: + +select + if(isnull(test_db.User),'WRONG!!!','ok') as test_db_User, + if(isnull(test_user.User),'WRONG!!!','ok') as test_user_User, + if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User, + if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User + +from test_db +left join test_user on test_db.User=test_user.User +left join test_tables_priv on test_db.User=test_tables_priv.User +left join test_columns_priv on test_db.User=test_columns_priv.User; + +# 'Table_name' field must be the same for all the tables: + +select + if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User, + if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User +from test_tables_priv +left join test_columns_priv on test_tables_priv.Table_name=test_columns_priv.Table_name; + +drop table test_columns_priv; +drop table test_tables_priv; +drop table test_func; +drop table test_host; +drop table test_user; +drop table test_db; From 1adf2aacc662b706ceb6a6962f54b7aff8fc7cd2 Mon Sep 17 00:00:00 2001 From: "mwagner@here.mwagner.org" <> Date: Tue, 29 Jun 2004 02:13:24 -0500 Subject: [PATCH 03/49] my_md5sum: Added code to use locally installed perl modules first --- Build-tools/my_md5sum | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Build-tools/my_md5sum b/Build-tools/my_md5sum index 20742ee2ed0..481a665af1a 100755 --- a/Build-tools/my_md5sum +++ b/Build-tools/my_md5sum @@ -10,10 +10,21 @@ # Written by Matt Wagner # use strict; + +# +# Use local perl libraries first. 'unshift' adds to the front of @INC +# The local perl library dir hidden is $HOME/.perllibs on each build host +# +BEGIN +{ + my $homedir= $ENV{HOME}; + unshift (@INC, "$homedir/.perllibs"); +} + use Digest::MD5; use Getopt::Long; -my $VER= "1.1"; +my $VER= "1.2"; # # Strip the leading path info off the program name ($0). We want 'my_md5sum' From 74809f7445ccc053c77fcce4ad698fd92c582b5d Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Wed, 30 Jun 2004 15:41:35 +0200 Subject: [PATCH 04/49] Fix for BUG#4326 "Replicated LOAD DATA INFILE show nothing in processlist on slave": we now report in SHOW PROCESSLIST that we are writing to the temp files or loading the table. When we are writing to the tmp file: | 3 | system user | | | Connect | 6 | Making temp file /tmp/SQL_LOAD-2-1-2.data | and when we are actually loading the .data temp file into the table: | 3 | system user | | test | Connect | 2 | | LOAD DATA INFILE '/tmp/SQL_LOAD-2-1-2.data' INTO TABLE `t` <...> | --- sql/log_event.cc | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index f94056694cc..3e1544adf14 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1968,10 +1968,10 @@ end: int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, bool use_rli_only_for_errors) { + char *load_data_query= 0; init_sql_alloc(&thd->mem_root, thd->variables.query_alloc_block_size, 0); thd->db= (char*) rewrite_db(db); DBUG_ASSERT(thd->query == 0); - thd->query = 0; // Should not be needed clear_all_errors(thd, rli); if (!use_rli_only_for_errors) @@ -2024,6 +2024,19 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, { char llbuff[22]; enum enum_duplicates handle_dup; + /* + Make a simplified LOAD DATA INFILE query, for the information of the + user in SHOW PROCESSLIST. Note that db is known in the 'db' column. + */ + if ((load_data_query= (char *) my_alloca(18 + strlen(fname) + 14 + + strlen(tables.real_name) + 8))) + { + thd->query_length= (uint)(strxmov(load_data_query, + "LOAD DATA INFILE '", fname, + "' INTO TABLE `", tables.real_name, + "` <...>", NullS) - load_data_query); + thd->query= load_data_query; + } if (sql_ex.opt_flags & REPLACE_FLAG) handle_dup= DUP_REPLACE; else if (sql_ex.opt_flags & IGNORE_FLAG) @@ -2103,8 +2116,14 @@ Slave: load data infile on table '%s' at log position %s in log \ } thd->net.vio = 0; - thd->db= 0; // prevent db from being freed + VOID(pthread_mutex_lock(&LOCK_thread_count)); + thd->db= 0; + thd->query= 0; + thd->query_length= 0; + VOID(pthread_mutex_unlock(&LOCK_thread_count)); close_thread_tables(thd); + if (load_data_query) + my_afree(load_data_query); if (thd->query_error) { /* this err/sql_errno code is copy-paste from send_error() */ @@ -2326,7 +2345,7 @@ int Slave_log_event::exec_event(struct st_relay_log_info* rli) int Create_file_log_event::exec_event(struct st_relay_log_info* rli) { - char fname_buf[FN_REFLEN+10]; + char proc_info[17+FN_REFLEN+10], *fname_buf= proc_info+17; char *p; int fd = -1; IO_CACHE file; @@ -2335,6 +2354,8 @@ int Create_file_log_event::exec_event(struct st_relay_log_info* rli) bzero((char*)&file, sizeof(file)); p = slave_load_file_stem(fname_buf, file_id, server_id); strmov(p, ".info"); // strmov takes less code than memcpy + strnmov(proc_info, "Making temp file ", 17); // no end 0 + thd->proc_info= proc_info; if ((fd = my_open(fname_buf, O_WRONLY|O_CREAT|O_BINARY|O_TRUNC, MYF(MY_WME))) < 0 || init_io_cache(&file, fd, IO_SIZE, WRITE_CACHE, (my_off_t)0, 0, @@ -2376,6 +2397,7 @@ err: end_io_cache(&file); if (fd >= 0) my_close(fd, MYF(0)); + thd->proc_info= 0; return error ? 1 : Log_event::exec_event(rli); } @@ -2392,12 +2414,14 @@ int Delete_file_log_event::exec_event(struct st_relay_log_info* rli) int Append_block_log_event::exec_event(struct st_relay_log_info* rli) { - char fname[FN_REFLEN+10]; + char proc_info[17+FN_REFLEN+10], *fname= proc_info+17; char *p= slave_load_file_stem(fname, file_id, server_id); int fd; int error = 1; memcpy(p, ".data", 6); + strnmov(proc_info, "Making temp file ", 17); // no end 0 + thd->proc_info= proc_info; if ((fd = my_open(fname, O_WRONLY|O_APPEND|O_BINARY, MYF(MY_WME))) < 0) { slave_print_error(rli,my_errno, "Error in Append_block event: could not open file '%s'", fname); @@ -2413,6 +2437,7 @@ int Append_block_log_event::exec_event(struct st_relay_log_info* rli) err: if (fd >= 0) my_close(fd, MYF(0)); + thd->proc_info= 0; return error ? error : Log_event::exec_event(rli); } From 83dbc6b0060d83f3102af54ccef97346f0fac629 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Fri, 2 Jul 2004 19:20:30 +0200 Subject: [PATCH 05/49] Fixing a bug in mysqltest.c: if a command has a comment at the end of line, like: error 2002 ; # this is error 2002 then the parsing of comment should not make mysqltest forget about the value of expected error. Reason it forgot it (so the next query caused the test to fail) is that internally the above line is 2 queries. --- client/mysqltest.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 68b9dd505b2..2ec07692a4d 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1817,13 +1817,6 @@ int read_query(struct st_query** q_ptr) q->record_file[0] = 0; q->require_file=0; q->first_word_len = 0; - memcpy((gptr) q->expected_errno, (gptr) global_expected_errno, - sizeof(global_expected_errno)); - q->expected_errors=global_expected_errors; - q->abort_on_error = global_expected_errno[0] == 0; - bzero((gptr) global_expected_errno,sizeof(global_expected_errno)); - global_expected_errors=0; - q->type = Q_UNKNOWN; q->query_buf=q->query=0; if (read_line(read_query_buf, sizeof(read_query_buf))) @@ -1832,8 +1825,16 @@ int read_query(struct st_query** q_ptr) if (*p == '#') { q->type = Q_COMMENT; + /* This goto is to avoid losing the "expected error" info. */ + goto end; } - else if (p[0] == '-' && p[1] == '-') + memcpy((gptr) q->expected_errno, (gptr) global_expected_errno, + sizeof(global_expected_errno)); + q->expected_errors=global_expected_errors; + q->abort_on_error = global_expected_errno[0] == 0; + bzero((gptr) global_expected_errno,sizeof(global_expected_errno)); + global_expected_errors=0; + if (p[0] == '-' && p[1] == '-') { q->type = Q_COMMENT_WITH_COMMAND; p+=2; /* To calculate first word */ @@ -1868,6 +1869,8 @@ int read_query(struct st_query** q_ptr) *p1 = 0; } } + +end: while (*p && my_isspace(charset_info,*p)) p++; if (!(q->query_buf=q->query=my_strdup(p,MYF(MY_WME)))) From 130740248b1eafcd935e7c75cfc2f195abb63a55 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Sun, 4 Jul 2004 08:46:28 +0300 Subject: [PATCH 06/49] aggregate functions check during substitution made only for single row subselects (BUG#4400) restoring current senect pointer before PS rexecution (backport from 5.0) removed spaces at lines ends --- mysql-test/r/subselect.result | 8 +++++++ mysql-test/t/subselect.test | 10 ++++++++ sql/item_subselect.cc | 44 +++++++++++++++++------------------ sql/item_subselect.h | 10 ++++---- sql/sql_prepare.cc | 1 + 5 files changed, 46 insertions(+), 27 deletions(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 5ab36dacaaf..77339473142 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1891,3 +1891,11 @@ abc b 3 4 deallocate prepare stmt1; DROP TABLE t1, t2, t3; +CREATE TABLE `t1` ( `a` int(11) default NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1; +insert into t1 values (1); +CREATE TABLE `t2` ( `b` int(11) default NULL, `a` int(11) default NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1; +insert into t2 values (1,2); +select t000.a, count(*) `C` FROM t1 t000 GROUP BY t000.a HAVING count(*) > ALL (SELECT count(*) FROM t2 t001 WHERE t001.a=1); +a C +1 1 +drop table t1,t2; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 0c093c4ae3e..eb4b1f33b14 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -1212,3 +1212,13 @@ execute stmt1; select * from t3; deallocate prepare stmt1; DROP TABLE t1, t2, t3; + +# +# Aggregate function comparation with ALL/ANY/SOME subselect +# +CREATE TABLE `t1` ( `a` int(11) default NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1; +insert into t1 values (1); +CREATE TABLE `t2` ( `b` int(11) default NULL, `a` int(11) default NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1; +insert into t2 values (1,2); +select t000.a, count(*) `C` FROM t1 t000 GROUP BY t000.a HAVING count(*) > ALL (SELECT count(*) FROM t2 t001 WHERE t001.a=1); +drop table t1,t2; diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 4c1ffeecc97..ccc72cea608 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* +/* subselect Item SUBSELECT TODO: @@ -41,7 +41,7 @@ Item_subselect::Item_subselect(): { reset(); /* - item value is NULL if select_subselect not changed this value + item value is NULL if select_subselect not changed this value (i.e. some rows will be found returned) */ null_value= 1; @@ -114,7 +114,7 @@ Item_subselect::~Item_subselect() } Item_subselect::trans_res -Item_subselect::select_transformer(JOIN *join) +Item_subselect::select_transformer(JOIN *join) { DBUG_ENTER("Item_subselect::select_transformer"); DBUG_RETURN(RES_OK); @@ -148,11 +148,11 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) if (have_to_be_excluded) engine->exclude(); substitution= 0; - thd->where= "checking transformed subquery"; + thd->where= "checking transformed subquery"; if (!(*ref)->fixed) ret= (*ref)->fix_fields(thd, tables, ref); - // We can't substitute aggregate functions (like (SELECT (max(i))) - if ((*ref)->with_sum_func) + // We can't substitute aggregate functions like "SELECT (max(i))" + if (substype() == SINGLEROW_SUBS && (*ref)->with_sum_func) { my_error(ER_INVALID_GROUP_FUNC_USE, MYF(0)); return 1; @@ -161,7 +161,7 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) } // Is it one field subselect? if (engine->cols() > max_columns) - { + { my_error(ER_OPERAND_COLUMNS, MYF(0), 1); return 1; } @@ -199,7 +199,7 @@ bool Item_subselect::exec() return (res); } -Item::Type Item_subselect::type() const +Item::Type Item_subselect::type() const { return SUBSELECT_ITEM; } @@ -277,7 +277,7 @@ Item_maxmin_subselect::Item_maxmin_subselect(Item_subselect *parent, */ used_tables_cache= parent->get_used_tables_cache(); const_item_cache= parent->get_const_item_cache(); - + DBUG_VOID_RETURN; } @@ -299,7 +299,7 @@ Item_singlerow_subselect::select_transformer(JOIN *join) { if (changed) return RES_OK; - + SELECT_LEX *select_lex= join->select_lex; Statement backup; @@ -314,10 +314,10 @@ Item_singlerow_subselect::select_transformer(JOIN *join) TODO: solve above problem */ !(select_lex->item_list.head()->type() == FIELD_ITEM || - select_lex->item_list.head()->type() == REF_ITEM) + select_lex->item_list.head()->type() == REF_ITEM) ) { - + have_to_be_excluded= 1; if (join->thd->lex->describe) { @@ -355,7 +355,7 @@ Item_singlerow_subselect::select_transformer(JOIN *join) return RES_REDUCE; } return RES_OK; - + err: if (stmt) thd->restore_backup_item_arena(stmt, &backup); @@ -418,7 +418,7 @@ void Item_singlerow_subselect::bring_value() exec(); } -double Item_singlerow_subselect::val() +double Item_singlerow_subselect::val() { DBUG_ASSERT(fixed == 1); if (!exec() && !value->null_value) @@ -433,7 +433,7 @@ double Item_singlerow_subselect::val() } } -longlong Item_singlerow_subselect::val_int() +longlong Item_singlerow_subselect::val_int() { DBUG_ASSERT(fixed == 1); if (!exec() && !value->null_value) @@ -448,7 +448,7 @@ longlong Item_singlerow_subselect::val_int() } } -String *Item_singlerow_subselect::val_str (String *str) +String *Item_singlerow_subselect::val_str (String *str) { if (!exec() && !value->null_value) { @@ -553,7 +553,7 @@ double Item_exists_subselect::val() return (double) value; } -longlong Item_exists_subselect::val_int() +longlong Item_exists_subselect::val_int() { DBUG_ASSERT(fixed == 1); if (exec()) @@ -590,7 +590,7 @@ double Item_in_subselect::val() return (double) value; } -longlong Item_in_subselect::val_int() +longlong Item_in_subselect::val_int() { DBUG_ASSERT(fixed == 1); if (exec()) @@ -842,7 +842,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, { // it is single select without tables => possible optimization item= func->create(left_expr, item); - // fix_field of item will be done in time of substituting + // fix_field of item will be done in time of substituting substitution= item; have_to_be_excluded= 1; if (thd->lex->describe) @@ -885,7 +885,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) thd->where= "row IN/ALL/ANY subquery"; if (stmt) - thd->set_n_backup_item_arena(stmt, &backup); + thd->set_n_backup_item_arena(stmt, &backup); SELECT_LEX *select_lex= join->select_lex; @@ -926,7 +926,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) List_iterator_fast li(select_lex->item_list); for (uint i= 0; i < n; i++) { - Item *func= new Item_ref_null_helper(this, + Item *func= new Item_ref_null_helper(this, select_lex->ref_pointer_array+i, (char *) "", (char *) ""); @@ -1108,7 +1108,7 @@ int subselect_single_select_engine::prepare() (ORDER*) select_lex->order_list.first, (ORDER*) select_lex->group_list.first, select_lex->having, - (ORDER*) 0, select_lex, + (ORDER*) 0, select_lex, select_lex->master_unit())) return 1; thd->lex->current_select= save_select; diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 364781de362..6b8b8b0b3a7 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -47,7 +47,7 @@ protected: /* old engine if engine was changed */ subselect_engine *old_engine; /* cache of used external tables */ - table_map used_tables_cache; + table_map used_tables_cache; /* allowed number of columns (1 for single value subqueries) */ uint max_columns; /* work with 'substitution' */ @@ -69,17 +69,17 @@ public: virtual subs_type substype() { return UNKNOWN_SUBS; } - /* + /* We need this method, because some compilers do not allow 'this' pointer in constructor initialization list, but we need pass pointer to subselect Item class to select_subselect classes constructor. */ - virtual void init (st_select_lex *select_lex, + virtual void init (st_select_lex *select_lex, select_subselect *result); ~Item_subselect(); void cleanup(); - virtual void reset() + virtual void reset() { null_value= 1; } @@ -275,7 +275,7 @@ public: } virtual ~subselect_engine() {}; // to satisfy compiler virtual void cleanup()= 0; - + // set_thd should be called before prepare() void set_thd(THD *thd_arg) { thd= thd_arg; } THD * get_thd() { return thd; } diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 91df364e531..4305bee42a2 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1706,6 +1706,7 @@ static void reset_stmt_for_execute(Prepared_statement *stmt) unit->reinit_exec_mechanism(); } } + stmt->lex->current_select= &stmt->lex->select_lex; } From 41bd6aa4b6082f72ed3129118ffb0810259b714b Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Sun, 4 Jul 2004 10:40:24 +0300 Subject: [PATCH 07/49] do not assign values of left expression of IN/ANN/ANY subquery in case of PS preparation (BUG#4403) --- mysql-test/r/ps_2myisam.result | 12 ++++++------ mysql-test/r/ps_3innodb.result | 24 ++++++++++++------------ mysql-test/r/ps_5merge.result | 24 ++++++++++++------------ mysql-test/r/ps_6bdb.result | 12 ++++++------ sql/item_cmpfunc.cc | 9 ++++++++- 5 files changed, 44 insertions(+), 37 deletions(-) diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index 04c95271aad..d630730d96f 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -389,12 +389,12 @@ where @arg01 = first.b or first.a = second.a or second.b = @arg02; a @arg00 a 1 ABC 1 2 ABC 1 +3 ABC 1 +4 ABC 1 2 ABC 2 2 ABC 3 -2 ABC 4 -3 ABC 1 3 ABC 3 -4 ABC 1 +2 ABC 4 4 ABC 4 prepare stmt1 from ' select first.a, ?, second.a FROM t1 first, t1 second where ? = first.b or first.a = second.a or second.b = ? '; @@ -402,12 +402,12 @@ execute stmt1 using @arg00, @arg01, @arg02; a ? a 1 ABC 1 2 ABC 1 +3 ABC 1 +4 ABC 1 2 ABC 2 2 ABC 3 -2 ABC 4 -3 ABC 1 3 ABC 3 -4 ABC 1 +2 ABC 4 4 ABC 4 test_sequence ------ subquery tests ------ diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index dfb147d0795..8cba3501a73 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -548,14 +548,14 @@ def in_s 8 21 1 Y 32768 0 8 def in_row_s 8 21 1 Y 32768 0 8 scalar_s exists_s in_s in_row_s 2.0000 0 1 0 -2.0000 0 1 0 18.0000 1 0 1 +2.0000 0 1 0 18.0000 1 0 1 execute stmt1 ; scalar_s exists_s in_s in_row_s 2.0000 0 1 0 -2.0000 0 1 0 18.0000 1 0 1 +2.0000 0 1 0 18.0000 1 0 1 set @stmt= concat('explain ',@stmt); prepare stmt1 from @stmt ; @@ -572,8 +572,8 @@ def ref 253 1024 0 Y 0 31 63 def rows 8 10 1 N 32801 0 8 def Extra 253 255 44 N 1 31 63 id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL NULL NULL NULL NULL 2 -1 PRIMARY t_many_col_types ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t_many_col_types ALL NULL NULL NULL NULL 3 +1 PRIMARY ALL NULL NULL NULL NULL 2 Using where 6 DERIVED t2 ALL NULL NULL NULL NULL 2 5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where @@ -581,8 +581,8 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort execute stmt1 ; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL NULL NULL NULL NULL 2 -1 PRIMARY t_many_col_types ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t_many_col_types ALL NULL NULL NULL NULL 3 +1 PRIMARY ALL NULL NULL NULL NULL 2 Using where 6 DERIVED t2 ALL NULL NULL NULL NULL 2 5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where @@ -617,15 +617,15 @@ def in_s 8 21 1 Y 32768 0 8 def in_row_s 8 21 1 Y 32768 0 8 scalar_s exists_s in_s in_row_s 2 0 1 0 -2 0 1 0 18 1 0 1 +2 0 1 0 18 1 0 1 execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08, @arg09 ; scalar_s exists_s in_s in_row_s 2 0 1 0 -2 0 1 0 18 1 0 1 +2 0 1 0 18 1 0 1 set @stmt= concat('explain ',@stmt); prepare stmt1 from @stmt ; @@ -643,8 +643,8 @@ def ref 253 1024 0 Y 0 31 63 def rows 8 10 1 N 32801 0 8 def Extra 253 255 44 N 1 31 63 id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL NULL NULL NULL NULL 2 -1 PRIMARY t_many_col_types ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t_many_col_types ALL NULL NULL NULL NULL 3 +1 PRIMARY ALL NULL NULL NULL NULL 2 Using where 6 DERIVED t2 ALL NULL NULL NULL NULL 2 5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where @@ -653,8 +653,8 @@ id select_type table type possible_keys key key_len ref rows Extra execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08, @arg09 ; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL NULL NULL NULL NULL 2 -1 PRIMARY t_many_col_types ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t_many_col_types ALL NULL NULL NULL NULL 3 +1 PRIMARY ALL NULL NULL NULL NULL 2 Using where 6 DERIVED t2 ALL NULL NULL NULL NULL 2 5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index fab0b552b48..8fc035b0aef 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -432,12 +432,12 @@ where @arg01 = first.b or first.a = second.a or second.b = @arg02; a @arg00 a 1 ABC 1 2 ABC 1 +3 ABC 1 +4 ABC 1 2 ABC 2 2 ABC 3 -2 ABC 4 -3 ABC 1 3 ABC 3 -4 ABC 1 +2 ABC 4 4 ABC 4 prepare stmt1 from ' select first.a, ?, second.a FROM t1 first, t1 second where ? = first.b or first.a = second.a or second.b = ? '; @@ -445,12 +445,12 @@ execute stmt1 using @arg00, @arg01, @arg02; a ? a 1 ABC 1 2 ABC 1 +3 ABC 1 +4 ABC 1 2 ABC 2 2 ABC 3 -2 ABC 4 -3 ABC 1 3 ABC 3 -4 ABC 1 +2 ABC 4 4 ABC 4 test_sequence ------ subquery tests ------ @@ -1615,12 +1615,12 @@ where @arg01 = first.b or first.a = second.a or second.b = @arg02; a @arg00 a 1 ABC 1 2 ABC 1 +3 ABC 1 +4 ABC 1 2 ABC 2 2 ABC 3 -2 ABC 4 -3 ABC 1 3 ABC 3 -4 ABC 1 +2 ABC 4 4 ABC 4 prepare stmt1 from ' select first.a, ?, second.a FROM t1 first, t1 second where ? = first.b or first.a = second.a or second.b = ? '; @@ -1628,12 +1628,12 @@ execute stmt1 using @arg00, @arg01, @arg02; a ? a 1 ABC 1 2 ABC 1 +3 ABC 1 +4 ABC 1 2 ABC 2 2 ABC 3 -2 ABC 4 -3 ABC 1 3 ABC 3 -4 ABC 1 +2 ABC 4 4 ABC 4 test_sequence ------ subquery tests ------ diff --git a/mysql-test/r/ps_6bdb.result b/mysql-test/r/ps_6bdb.result index ac0b38951c0..eeabd114b91 100644 --- a/mysql-test/r/ps_6bdb.result +++ b/mysql-test/r/ps_6bdb.result @@ -389,12 +389,12 @@ where @arg01 = first.b or first.a = second.a or second.b = @arg02; a @arg00 a 1 ABC 1 2 ABC 1 +3 ABC 1 +4 ABC 1 2 ABC 2 2 ABC 3 -2 ABC 4 -3 ABC 1 3 ABC 3 -4 ABC 1 +2 ABC 4 4 ABC 4 prepare stmt1 from ' select first.a, ?, second.a FROM t1 first, t1 second where ? = first.b or first.a = second.a or second.b = ? '; @@ -402,12 +402,12 @@ execute stmt1 using @arg00, @arg01, @arg02; a ? a 1 ABC 1 2 ABC 1 +3 ABC 1 +4 ABC 1 2 ABC 2 2 ABC 3 -2 ABC 4 -3 ABC 1 3 ABC 3 -4 ABC 1 +2 ABC 4 4 ABC 4 test_sequence ------ subquery tests ------ diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 91257c31fb9..60f80249e94 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -483,7 +483,14 @@ bool Item_in_optimizer::fix_left(THD *thd, return 1; cache->setup(args[0]); - cache->store(args[0]); + /* + If it is preparation PS only then we do not know values of parameters => + cant't get there values and do not need that values. + + TODO: during merge with 5.0 it should be changed on !thd->only_prepare() + */ + if (!thd->current_statement) + cache->store(args[0]); if (cache->cols() == 1) { if ((used_tables_cache= args[0]->used_tables())) From 912eb811ba138672d6e2baaebd0d5bcd97dd2166 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Mon, 5 Jul 2004 19:07:26 +0200 Subject: [PATCH 08/49] Windows-specific: Fix for BUG#4375 "Windows specific directories are copied during replication": in the Windows version of my_dir(), do not show hidden or system files which Windows sometimes creates in the root directory of drive (like RECYCLER and SYSTEM VOLUME INFORMATION directories) (so this problem showed up only when the datadir was the root dir of a drive). This will make SHOW DATABASES display better, and will do no harm to MySQL. For example, DROP DATABASE will not miss some files, as MySQL creates no hidden or system files. --- mysys/my_lib.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mysys/my_lib.c b/mysys/my_lib.c index 055e00d2efc..21c558ed489 100644 --- a/mysys/my_lib.c +++ b/mysys/my_lib.c @@ -461,6 +461,15 @@ MY_DIR *my_dir(const char *path, myf MyFlags) else finfo.mystat= NULL; + /* + Do not show hidden or system files which Windows sometimes creates. We + would need to see how this can be achieved with a Borland compiler. + */ +#ifndef __BORLANDC__ + if (attrib & (_A_HIDDEN | _A_SYSTEM)) + continue; +#endif + if (push_dynamic(dir_entries_storage, (gptr)&finfo)) goto error; From 2d5fbe0aecd567d9458408caf7502648b4622707 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Mon, 5 Jul 2004 19:12:23 +0200 Subject: [PATCH 09/49] my_lib.c: more accurate comment --- mysys/my_lib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mysys/my_lib.c b/mysys/my_lib.c index 21c558ed489..0207d9a3683 100644 --- a/mysys/my_lib.c +++ b/mysys/my_lib.c @@ -462,8 +462,10 @@ MY_DIR *my_dir(const char *path, myf MyFlags) finfo.mystat= NULL; /* - Do not show hidden or system files which Windows sometimes creates. We - would need to see how this can be achieved with a Borland compiler. + If the directory is the root directory of the drive, Windows sometimes + creates hidden or system files there (like RECYCLER); do not show + them. We would need to see how this can be achieved with a Borland + compiler. */ #ifndef __BORLANDC__ if (attrib & (_A_HIDDEN | _A_SYSTEM)) From d54157f0d8c253ff499912cf2e274283d8e4a559 Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Wed, 7 Jul 2004 13:47:29 +0500 Subject: [PATCH 10/49] ha_archive.cc: Memory was used after it has been alreay freed. This led to server crash on FreeBSD. --- sql/examples/ha_archive.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc index e052a819ef8..a4fe2aaa8cc 100644 --- a/sql/examples/ha_archive.cc +++ b/sql/examples/ha_archive.cc @@ -188,9 +188,9 @@ static int free_share(ARCHIVE_SHARE *share) hash_delete(&archive_open_tables, (byte*) share); thr_lock_delete(&share->lock); pthread_mutex_destroy(&share->mutex); - my_free((gptr) share, MYF(0)); if (gzclose(share->archive_write) == Z_ERRNO) rc= -1; + my_free((gptr) share, MYF(0)); } pthread_mutex_unlock(&archive_mutex); From aa679b62c06431b2870cf3b1a873ef5add743fa6 Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Wed, 7 Jul 2004 15:20:23 +0500 Subject: [PATCH 11/49] Adding Roman (classical Latin) collation. --- mysql-test/r/ctype_uca.result | 106 ++++++++++++++++++++++++++++++++++ mysql-test/t/ctype_uca.test | 1 + mysys/charset-def.c | 4 ++ strings/ctype-uca.c | 58 +++++++++++++++++++ 4 files changed, 169 insertions(+) diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result index cb6fbecb6e8..51da05f9fee 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -1655,3 +1655,109 @@ Z,z,Ź,ź,Ż,ż,Ž,ž ǁ ǂ ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_roman_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ +AA,Aa,aA,aa +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,dZ,dz,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,J,i,j,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ +IJ,Ij,iJ,ij +IJ,ij +ı +Ɨ +Ɩ +Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj +LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj +NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,V,u,v,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ +Ɯ +Ʊ +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ diff --git a/mysql-test/t/ctype_uca.test b/mysql-test/t/ctype_uca.test index 6ff1407247f..0ab46a5a637 100644 --- a/mysql-test/t/ctype_uca.test +++ b/mysql-test/t/ctype_uca.test @@ -178,4 +178,5 @@ select group_concat(c1 order by c1) from t1 group by c1 collate utf8_danish_ci; select group_concat(c1 order by c1) from t1 group by c1 collate utf8_lithuanian_ci; --select group_concat(c1 order by c1) from t1 group by c1 collate utf8_slovak_ci; select group_concat(c1 order by c1) from t1 group by c1 collate utf8_spanish2_ci; +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_roman_ci; diff --git a/mysys/charset-def.c b/mysys/charset-def.c index 73e36688594..420a13a592d 100644 --- a/mysys/charset-def.c +++ b/mysys/charset-def.c @@ -38,6 +38,7 @@ extern CHARSET_INFO my_charset_ucs2_danish_uca_ci; extern CHARSET_INFO my_charset_ucs2_lithuanian_uca_ci; extern CHARSET_INFO my_charset_ucs2_slovak_uca_ci; extern CHARSET_INFO my_charset_ucs2_spanish2_uca_ci; +extern CHARSET_INFO my_charset_ucs2_roman_uca_ci; #endif #ifdef HAVE_CHARSET_utf8 @@ -56,6 +57,7 @@ extern CHARSET_INFO my_charset_utf8_danish_uca_ci; extern CHARSET_INFO my_charset_utf8_lithuanian_uca_ci; extern CHARSET_INFO my_charset_utf8_slovak_uca_ci; extern CHARSET_INFO my_charset_utf8_spanish2_uca_ci; +extern CHARSET_INFO my_charset_utf8_roman_uca_ci; #endif my_bool init_compiled_charsets(myf flags __attribute__((unused))) @@ -124,6 +126,7 @@ my_bool init_compiled_charsets(myf flags __attribute__((unused))) add_compiled_collation(&my_charset_ucs2_lithuanian_uca_ci); add_compiled_collation(&my_charset_ucs2_slovak_uca_ci); add_compiled_collation(&my_charset_ucs2_spanish2_uca_ci); + add_compiled_collation(&my_charset_ucs2_roman_uca_ci); #endif #ifdef HAVE_CHARSET_ujis @@ -149,6 +152,7 @@ my_bool init_compiled_charsets(myf flags __attribute__((unused))) add_compiled_collation(&my_charset_utf8_lithuanian_uca_ci); add_compiled_collation(&my_charset_utf8_slovak_uca_ci); add_compiled_collation(&my_charset_utf8_spanish2_uca_ci); + add_compiled_collation(&my_charset_utf8_roman_uca_ci); #endif /* Copy compiled charsets */ diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 5bb710946b1..9590b98e664 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -6653,6 +6653,9 @@ static const char spanish2[]= /* Also good for Asturian and Galician */ "&N < \\u00F1 <<< \\u00D1" "&R << rr <<< Rr <<< RR"; +static const char roman[]= /* i.e. Classical Latin */ + "& I << j <<< J " + "& U << v <<< V "; /* Unicode Collation Algorithm: @@ -8328,6 +8331,34 @@ CHARSET_INFO my_charset_ucs2_spanish2_uca_ci= &my_collation_ucs2_uca_handler }; + +CHARSET_INFO my_charset_ucs2_roman_uca_ci= +{ + 143,0,0, /* number */ + MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE, + "ucs2", /* cs name */ + "ucs2_roman_ci", /* name */ + "", /* comment */ + roman, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 2, /* mbminlen */ + 2, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + &my_charset_ucs2_handler, + &my_collation_ucs2_uca_handler +}; + #endif @@ -8779,4 +8810,31 @@ CHARSET_INFO my_charset_utf8_spanish2_uca_ci= &my_charset_utf8_handler, &my_collation_any_uca_handler }; + +CHARSET_INFO my_charset_utf8_roman_uca_ci= +{ + 207,0,0, /* number */ + MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE, + "utf8", /* cs name */ + "utf8_roman_ci", /* name */ + "", /* comment */ + roman, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* mbminlen */ + 2, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + &my_charset_utf8_handler, + &my_collation_any_uca_handler +}; #endif From 6fdafa5635d5ad369f7a4e5272b818b9e4957a1c Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Wed, 7 Jul 2004 16:39:43 +0500 Subject: [PATCH 12/49] Don't allow badly formed UTF8 identitiers --- include/mysqld_error.h | 3 ++- mysql-test/r/ctype_recoding.result | 6 ++++++ mysql-test/t/ctype_recoding.test | 10 ++++++++++ sql/share/czech/errmsg.txt | 1 + sql/share/danish/errmsg.txt | 1 + sql/share/dutch/errmsg.txt | 1 + sql/share/english/errmsg.txt | 1 + sql/share/estonian/errmsg.txt | 1 + sql/share/french/errmsg.txt | 1 + sql/share/german/errmsg.txt | 1 + sql/share/greek/errmsg.txt | 1 + sql/share/hungarian/errmsg.txt | 1 + sql/share/italian/errmsg.txt | 1 + sql/share/japanese/errmsg.txt | 1 + sql/share/korean/errmsg.txt | 1 + sql/share/norwegian-ny/errmsg.txt | 1 + sql/share/norwegian/errmsg.txt | 1 + sql/share/polish/errmsg.txt | 1 + sql/share/portuguese/errmsg.txt | 1 + sql/share/romanian/errmsg.txt | 1 + sql/share/russian/errmsg.txt | 1 + sql/share/serbian/errmsg.txt | 1 + sql/share/slovak/errmsg.txt | 1 + sql/share/spanish/errmsg.txt | 1 + sql/share/swedish/errmsg.txt | 1 + sql/share/ukrainian/errmsg.txt | 1 + sql/sql_yacc.yy | 12 ++++++++++++ 27 files changed, 53 insertions(+), 1 deletion(-) diff --git a/include/mysqld_error.h b/include/mysqld_error.h index 0dcc09a173f..0d752b0daf1 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -316,4 +316,5 @@ #define ER_GET_TEMPORARY_ERRMSG 1297 #define ER_UNKNOWN_TIME_ZONE 1298 #define ER_WARN_INVALID_TIMESTAMP 1299 -#define ER_ERROR_MESSAGES 300 +#define ER_INVALID_CHARACTER_STRING 1300 +#define ER_ERROR_MESSAGES 301 diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result index d40360b9337..805f731f0ec 100644 --- a/mysql-test/r/ctype_recoding.result +++ b/mysql-test/r/ctype_recoding.result @@ -136,3 +136,9 @@ SET character_set_connection=binary; SELECT 'тест' as s; s тест +SET NAMES binary; +CREATE TABLE `good` (a int); +ERROR HY000: Invalid utf8 character string: '' +SET NAMES utf8; +CREATE TABLE `good` (a int); +ERROR HY000: Invalid utf8 character string: '` (a int)' diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test index 45cc0cebfb3..de6332f272c 100644 --- a/mysql-test/t/ctype_recoding.test +++ b/mysql-test/t/ctype_recoding.test @@ -97,3 +97,13 @@ SELECT 'тест' as s; SET NAMES utf8; SET character_set_connection=binary; SELECT 'тест' as s; + +# +# Test that we allow only well-formed UTF8 identitiers +# +SET NAMES binary; +--error 1300 +CREATE TABLE `good` (a int); +SET NAMES utf8; +--error 1300 +CREATE TABLE `good` (a int); diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index 2d377929229..3cc665f0597 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -312,3 +312,4 @@ character-set=latin2 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index af7b8263e6b..7b42d47f008 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -306,3 +306,4 @@ character-set=latin1 "Modtog temporary fejl %d '%-.100s' fra %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index aa20996680e..ce1d06d4356 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -314,3 +314,4 @@ character-set=latin1 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index b5a7f7962cf..b8b4cd1127d 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -303,3 +303,4 @@ character-set=latin1 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index 0cc6e06ab26..a2f4c848217 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -308,3 +308,4 @@ character-set=latin7 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index 2e23db62ddb..7b3497ead2b 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -303,3 +303,4 @@ character-set=latin1 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index c63162c84f6..75732b3f732 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -315,3 +315,4 @@ character-set=latin1 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index fa94b0f5107..3825240927a 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -303,3 +303,4 @@ character-set=greek "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index 56fae82c438..eb968dd3a27 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -305,3 +305,4 @@ character-set=latin2 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index 31768f172b4..7112bcce5f2 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -303,3 +303,4 @@ character-set=latin1 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index 4385f25c991..005f85c6ad7 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -305,3 +305,4 @@ character-set=ujis "Got temporary NDB error %d '%-.100s'", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index a6e84fad01e..a1b6a6c2654 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -303,3 +303,4 @@ character-set=euckr "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index eaf7b3482ee..52f1a4ec12c 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -305,3 +305,4 @@ character-set=latin1 "Mottok temporary feil %d '%-.100s' fra %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index 692c10db58f..fadcc203c37 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -305,3 +305,4 @@ character-set=latin1 "Mottok temporary feil %d '%-.100s' fra %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index 19f2c1c6983..bac2e0678a8 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -307,3 +307,4 @@ character-set=latin2 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index c77d10d83de..9e5988490b3 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -304,3 +304,4 @@ character-set=latin1 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 5ee4efd0063..29dd9eb022a 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -307,3 +307,4 @@ character-set=latin2 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 20188723f6d..7cbbd6e36b8 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -305,3 +305,4 @@ character-set=koi8r "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index cc822431464..c45df8bfbe9 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -309,3 +309,4 @@ character-set=cp1250 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index ee6aac5081b..f94bb70d9e8 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -311,3 +311,4 @@ character-set=latin2 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 483ec7068a2..68488528309 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -305,3 +305,4 @@ character-set=latin1 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index d9f3adf92d4..6bb2ede2cb1 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -303,3 +303,4 @@ character-set=latin1 "Fick tilfllig felkod %d '%-.100s' frn %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index acf6f5121e8..e16b4ef64d6 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -308,3 +308,4 @@ character-set=koi8u "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index d284bff8c7c..2860077b6a0 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4884,7 +4884,19 @@ IDENT_sys: { THD *thd= YYTHD; if (thd->charset_is_system_charset) + { + CHARSET_INFO *cs= system_charset_info; + uint wlen= cs->cset->well_formed_len(cs, $1.str, + $1.str+$1.length, + $1.length); + if (wlen < $1.length) + { + net_printf(YYTHD, ER_INVALID_CHARACTER_STRING, cs->csname, + $1.str + wlen); + YYABORT; + } $$= $1; + } else thd->convert_string(&$$, system_charset_info, $1.str, $1.length, thd->charset()); From c5e6ebc6b61e599141ddb3181d5adb607cfe59ce Mon Sep 17 00:00:00 2001 From: "mwagner@here.mwagner.org" <> Date: Wed, 7 Jul 2004 16:28:07 -0500 Subject: [PATCH 13/49] my_md5sum: Exit properly --- Build-tools/my_md5sum | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Build-tools/my_md5sum b/Build-tools/my_md5sum index 481a665af1a..f4ac2f7d674 100755 --- a/Build-tools/my_md5sum +++ b/Build-tools/my_md5sum @@ -24,7 +24,8 @@ BEGIN use Digest::MD5; use Getopt::Long; -my $VER= "1.2"; +my $VER= "1.3"; +my $EXIT= 0; # # Strip the leading path info off the program name ($0). We want 'my_md5sum' @@ -78,6 +79,9 @@ if ($opt_check) # Print an error message if they don't match, else print OK print "$checkfile: FAILED\n" if $digest ne $checksum; print "$checkfile: OK\n" if $digest eq $checksum; + + # Set the exit() status to non-zero if FAILED + $EXIT= 1 if $digest ne $checksum; } } # Else generate the MD5 digest to STDOUT @@ -91,6 +95,8 @@ else } } +exit($EXIT); + # # This routine generates the MD5 digest of a file From fe57b75079836a3b731b4b05ddb490872df8b3f3 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Wed, 7 Jul 2004 23:49:03 +0200 Subject: [PATCH 14/49] bug#4441 - crash in UNHEX(NULL) --- mysql-test/r/func_str.result | 6 +++--- mysql-test/t/func_str.test | 2 +- sql/item_strfunc.cc | 9 ++++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index f91691853b9..1baf9d8e01c 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -192,9 +192,9 @@ length(quote(concat(char(0),"test"))) select hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235)))); hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235)))) 27E0E3E6E7E8EAEB27 -select unhex(hex("foobar")), hex(unhex("1234567890ABCDEF")), unhex("345678"); -unhex(hex("foobar")) hex(unhex("1234567890ABCDEF")) unhex("345678") -foobar 1234567890ABCDEF 4Vx +select unhex(hex("foobar")), hex(unhex("1234567890ABCDEF")), unhex("345678"), unhex(NULL); +unhex(hex("foobar")) hex(unhex("1234567890ABCDEF")) unhex("345678") unhex(NULL) +foobar 1234567890ABCDEF 4Vx NULL select hex(unhex("1")), hex(unhex("12")), hex(unhex("123")), hex(unhex("1234")), hex(unhex("12345")), hex(unhex("123456")); hex(unhex("1")) hex(unhex("12")) hex(unhex("123")) hex(unhex("1234")) hex(unhex("12345")) hex(unhex("123456")) 01 12 0123 1234 012345 123456 diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index cc8d8a88437..61d0326f7dd 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -78,7 +78,7 @@ select quote(concat('abc\'', '\\cba')); select quote(1/0), quote('\0\Z'); select length(quote(concat(char(0),"test"))); select hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235)))); -select unhex(hex("foobar")), hex(unhex("1234567890ABCDEF")), unhex("345678"); +select unhex(hex("foobar")), hex(unhex("1234567890ABCDEF")), unhex("345678"), unhex(NULL); select hex(unhex("1")), hex(unhex("12")), hex(unhex("123")), hex(unhex("1234")), hex(unhex("12345")), hex(unhex("123456")); select length(unhex(md5("abrakadabra"))); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index b0c685c1c46..b5b08a04f88 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2298,15 +2298,18 @@ String *Item_func_unhex::val_str(String *str) { DBUG_ASSERT(fixed == 1); /* Convert given hex string to a binary string */ + String *res= args[0]->val_str(str); - const char *from=res->ptr(), *end; - char *to; - int r; if (!res || tmp_value.alloc((1+res->length())/2)) { null_value=1; return 0; } + + const char *from=res->ptr(), *end; + char *to; + int r; + null_value=0; tmp_value.length((1+res->length())/2); to= (char*) tmp_value.ptr(); From 206e6425887f017a718b1624a9258d47206c0d9e Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Thu, 8 Jul 2004 10:11:30 +0200 Subject: [PATCH 15/49] results fixed --- mysql-test/r/bdb.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index 25118702d09..4080ba227a0 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -785,7 +785,7 @@ Table Op Msg_type Msg_text test.t1 optimize status OK show keys from t1; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 a A 2 NULL NULL BTREE +t1 0 PRIMARY 1 a NULL 2 NULL NULL BTREE drop table t1; create table t1 (i int, j int )ENGINE=BDB; insert into t1 values (1,2); From a5025f4ca630affdb380ce61831e81d5c708e1ec Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Thu, 8 Jul 2004 15:03:01 +0500 Subject: [PATCH 16/49] WL#807 Optimize loading database options in load_db_opt also known as BUG#2326 Charset of table is determined by charset of db only if "USE db;" --- mysql-test/r/ctype_create.result | 42 ++++-- mysql-test/t/ctype_create.test | 41 ++++-- sql/mysql_priv.h | 4 +- sql/mysqld.cc | 6 +- sql/sql_db.cc | 213 ++++++++++++++++++++++++++++++- sql/sql_parse.cc | 1 + sql/sql_table.cc | 17 +++ sql/sql_yacc.yy | 4 +- 8 files changed, 299 insertions(+), 29 deletions(-) diff --git a/mysql-test/r/ctype_create.result b/mysql-test/r/ctype_create.result index e2dc8c1be66..0da76c556e2 100644 --- a/mysql-test/r/ctype_create.result +++ b/mysql-test/r/ctype_create.result @@ -1,15 +1,37 @@ SET @@character_set_server=latin5; -CREATE DATABASE db1 DEFAULT CHARACTER SET cp1251; -USE db1; -CREATE DATABASE db2; -SHOW CREATE DATABASE db1; +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET cp1251; +USE mysqltest1; +CREATE DATABASE mysqltest2; +SHOW CREATE DATABASE mysqltest1; Database Create Database -db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET cp1251 */ -SHOW CREATE DATABASE db2; +mysqltest1 CREATE DATABASE `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp1251 */ +SHOW CREATE DATABASE mysqltest2; Database Create Database -db2 CREATE DATABASE `db2` /*!40100 DEFAULT CHARACTER SET latin5 */ -DROP DATABASE db2; -USE db1; +mysqltest2 CREATE DATABASE `mysqltest2` /*!40100 DEFAULT CHARACTER SET latin5 */ +CREATE TABLE mysqltest2.t1 (a char(10)); +SHOW CREATE TABLE mysqltest2.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin5 +DROP TABLE mysqltest2.t1; +ALTER DATABASE mysqltest2 DEFAULT CHARACTER SET latin7; +CREATE TABLE mysqltest2.t1 (a char(10)); +SHOW CREATE TABLE mysqltest2.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin7 +DROP DATABASE mysqltest2; +CREATE DATABASE mysqltest2 CHARACTER SET latin2; +CREATE TABLE mysqltest2.t1 (a char(10)); +SHOW CREATE TABLE mysqltest2.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin2 +DROP DATABASE mysqltest2; +USE mysqltest1; CREATE TABLE t1 (a char(10)); SHOW CREATE TABLE t1; Table Create Table @@ -32,4 +54,4 @@ t1 CREATE TABLE `t1` ( `a` char(10) collate latin1_german1_ci default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german1_ci DROP TABLE t1; -DROP DATABASE db1; +DROP DATABASE mysqltest1; diff --git a/mysql-test/t/ctype_create.test b/mysql-test/t/ctype_create.test index bd8c22bb4f6..6d7ed6fc205 100644 --- a/mysql-test/t/ctype_create.test +++ b/mysql-test/t/ctype_create.test @@ -13,25 +13,48 @@ SET @@character_set_server=latin5; -CREATE DATABASE db1 DEFAULT CHARACTER SET cp1251; -USE db1; -CREATE DATABASE db2; +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET cp1251; +USE mysqltest1; +CREATE DATABASE mysqltest2; # # This should be cp1251 # -SHOW CREATE DATABASE db1; +SHOW CREATE DATABASE mysqltest1; # -# This should take the default latin5 value from server level. +# Database "mysqltest2" should take the default latin5 value from +# the server level. +# Afterwards, table "d2.t1" should inherit the default latin5 value from +# the database "mysqltest2", using database option hash. # -SHOW CREATE DATABASE db2; -DROP DATABASE db2; +SHOW CREATE DATABASE mysqltest2; +CREATE TABLE mysqltest2.t1 (a char(10)); +SHOW CREATE TABLE mysqltest2.t1; +DROP TABLE mysqltest2.t1; + +# +# Now we check if the database charset is updated in +# the database options hash when we ALTER DATABASE. +# +ALTER DATABASE mysqltest2 DEFAULT CHARACTER SET latin7; +CREATE TABLE mysqltest2.t1 (a char(10)); +SHOW CREATE TABLE mysqltest2.t1; +DROP DATABASE mysqltest2; + +# +# Now we check if the database charset is removed from +# the database option hash when we DROP DATABASE. +# +CREATE DATABASE mysqltest2 CHARACTER SET latin2; +CREATE TABLE mysqltest2.t1 (a char(10)); +SHOW CREATE TABLE mysqltest2.t1; +DROP DATABASE mysqltest2; # # Check that table value uses database level by default # -USE db1; +USE mysqltest1; CREATE TABLE t1 (a char(10)); SHOW CREATE TABLE t1; DROP TABLE t1; @@ -50,4 +73,4 @@ DROP TABLE t1; # # # -DROP DATABASE db1; +DROP DATABASE mysqltest1; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 72ac3af70ff..9553af13431 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -801,6 +801,7 @@ bool is_keyword(const char *name, uint len); #define MY_DB_OPT_FILE "db.opt" bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create); +void my_dbopt_free(void); /* External variables @@ -894,7 +895,8 @@ extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone, LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_system_variables, LOCK_user_conn; -extern rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; +extern rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave, + LOCK_dboptions; extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager; extern pthread_attr_t connection_attrib; extern I_List threads; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 436f693d734..75f1aaeb775 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -382,7 +382,8 @@ pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count, LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received, LOCK_global_system_variables, LOCK_user_conn, LOCK_slave_list, LOCK_active_mi; -rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; +rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave, + LOCK_dboptions; pthread_cond_t COND_refresh,COND_thread_count, COND_slave_stopped, COND_slave_start; pthread_cond_t COND_thread_cache,COND_flush_thread_cache; @@ -901,6 +902,7 @@ void clean_up(bool print_message) bitmap_free(&slave_error_mask); #endif my_tz_free(); + my_dbopt_free(); #ifndef NO_EMBEDDED_ACCESS_CHECKS acl_free(1); grant_free(); @@ -986,6 +988,7 @@ static void clean_up_mutexes() (void) pthread_mutex_destroy(&LOCK_mysql_create_db); (void) pthread_mutex_destroy(&LOCK_Acl); (void) rwlock_destroy(&LOCK_grant); + (void) rwlock_destroy(&LOCK_dboptions); (void) pthread_mutex_destroy(&LOCK_open); (void) pthread_mutex_destroy(&LOCK_thread_count); (void) pthread_mutex_destroy(&LOCK_mapped_file); @@ -2408,6 +2411,7 @@ static int init_thread_environment() (void) my_rwlock_init(&LOCK_sys_init_connect, NULL); (void) my_rwlock_init(&LOCK_sys_init_slave, NULL); (void) my_rwlock_init(&LOCK_grant, NULL); + (void) my_rwlock_init(&LOCK_dboptions, NULL); (void) pthread_cond_init(&COND_thread_count,NULL); (void) pthread_cond_init(&COND_refresh,NULL); (void) pthread_cond_init(&COND_thread_cache,NULL); diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 9db2198268a..47c50be33fa 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -39,6 +39,184 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, const char *path, uint level); +/* Database options hash */ +static HASH dboptions; +static my_bool dboptions_init= 0; + +/* Structure for database options */ +typedef struct my_dbopt_st +{ + char *name; /* Database name */ + uint name_length; /* Database length name */ + CHARSET_INFO *charset; /* Database default character set */ +} my_dbopt_t; + +/* + Function we use in the creation of our hash to get key. +*/ +static byte* dboptions_get_key(my_dbopt_t *opt, uint *length, + my_bool not_used __attribute__((unused))) +{ + *length= opt->name_length; + return (byte*) opt->name; +} + + +/* + Function to free dboptions hash element +*/ + +static void free_dbopt(void *dbopt) +{ + my_free((gptr) dbopt, MYF(0)); +} + + +/* + Initialize database option hash. +*/ + +static my_bool my_dbopt_init(void) +{ + my_bool rc; + rw_wrlock(&LOCK_dboptions); + if (!dboptions_init) + { + dboptions_init= 1; + rc= hash_init(&dboptions, lower_case_table_names ? + &my_charset_bin : system_charset_info, + 32, 0, 0, (hash_get_key) dboptions_get_key, + free_dbopt,0); + } + else + rc= 0; + rw_unlock(&LOCK_dboptions); + return rc; +} + + +/* + Free database option hash. +*/ +void my_dbopt_free(void) +{ + rw_wrlock(&LOCK_dboptions); + if (dboptions_init) + { + hash_free(&dboptions); + dboptions_init= 0; + } + rw_unlock(&LOCK_dboptions); +} + + +/* + Find database options in the hash. + + DESCRIPTION + Search a database options in the hash, usings its path. + Fills "create" on success. + + RETURN VALUES + 0 on success. + 1 on error. +*/ + +static my_bool get_dbopt(const char *dbname, HA_CREATE_INFO *create) +{ + my_dbopt_t *opt; + uint length; + my_bool rc; + + if (my_dbopt_init()) + return 1; + + length= (uint) strlen(dbname); + + rw_rdlock(&LOCK_dboptions); + if ((opt= (my_dbopt_t*) hash_search(&dboptions, (byte*) dbname, length))) + { + create->default_table_charset= opt->charset; + rc= 0; + } + else + rc= 1; + rw_unlock(&LOCK_dboptions); + + return rc; +} + + +/* + Writes database options into the hash. + + DESCRIPTION + Inserts database options into the hash, or updates + options if they are already in the hash. + + RETURN VALUES + 0 on success. + 1 on error. +*/ + +static my_bool put_dbopt(const char *dbname, HA_CREATE_INFO *create) +{ + my_dbopt_t *opt; + uint length; + my_bool rc; + + if (my_dbopt_init()) + return 1; + + length= (uint) strlen(dbname); + + rw_wrlock(&LOCK_dboptions); + if ((opt= (my_dbopt_t*) hash_search(&dboptions, (byte*) dbname, length))) + { + /* Options are already in hash, update them */ + opt->charset= create->default_table_charset; + rc= 0; + } + else + { + /* Options are not in the hash, insert them */ + char *tmp_name; + if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), + &opt, sizeof(*opt), &tmp_name, length+1, NullS)) + { + rc= 1; + goto ret; + } + + opt->name= tmp_name; + opt->name_length= length; + opt->charset= create->default_table_charset; + strmov(opt->name, dbname); + + if ((rc= my_hash_insert(&dboptions, (byte*) opt))) + my_free((gptr) opt, MYF(0)); + } + +ret: + rw_unlock(&LOCK_dboptions); + return rc; +} + + +/* + Deletes database options from the hash. +*/ + +void del_dbopt(const char *path) +{ + my_dbopt_t *opt; + rw_wrlock(&LOCK_dboptions); + if ((opt= (my_dbopt_t *)hash_search(&dboptions, path, strlen(path)))) + hash_delete(&dboptions, (byte*) opt); + rw_unlock(&LOCK_dboptions); +} + + /* Create database options file: @@ -56,15 +234,19 @@ static bool write_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) char buf[256]; // Should be enough for one option bool error=1; + if (!create->default_table_charset) + create->default_table_charset= thd->variables.collation_server; + + if (put_dbopt(path, create)) + return 1; + if ((file=my_create(path, CREATE_MODE,O_RDWR | O_TRUNC,MYF(MY_WME))) >= 0) { ulong length; - CHARSET_INFO *cs= ((create && create->default_table_charset) ? - create->default_table_charset : - thd->variables.collation_server); length= my_sprintf(buf,(buf, "default-character-set=%s\ndefault-collation=%s\n", - cs->csname,cs->name)); + create->default_table_charset->csname, + create->default_table_charset->name)); /* Error is written by my_write */ if (!my_write(file,(byte*) buf, length, MYF(MY_NABP+MY_WME))) @@ -101,6 +283,12 @@ bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) bzero((char*) create,sizeof(*create)); create->default_table_charset= thd->variables.collation_server; + + /* Check if options for this database are already in the hash */ + if (!get_dbopt(path, create)) + DBUG_RETURN(0); + + /* Otherwise, load options from the .opt file */ if ((file=my_open(path, O_RDONLY | O_SHARE, MYF(0))) >= 0) { IO_CACHE cache; @@ -137,9 +325,16 @@ bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) } } } - error=0; end_io_cache(&cache); my_close(file,MYF(0)); + /* + Put the loaded value into the hash. + Note that another thread could've added the same + entry to the hash after we called get_dbopt(), + but it's not an error, as put_dbopt() takes this + possibility into account. + */ + error= put_dbopt(path, create); } DBUG_RETURN(error); } @@ -338,6 +533,8 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) int error = 0; char path[FN_REFLEN+16], tmp_db[NAME_LEN+1]; MY_DIR *dirp; + uint length; + my_dbopt_t *dbopt; DBUG_ENTER("mysql_rm_db"); VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); @@ -350,7 +547,11 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) } (void) sprintf(path,"%s/%s",mysql_data_home,db); - unpack_dirname(path,path); // Convert if not unix + length= unpack_dirname(path,path); // Convert if not unix + strmov(path+length, MY_DB_OPT_FILE); // Append db option file name + del_dbopt(path); // Remove dboption hash entry + path[length]= '\0'; // Remove file name + /* See if the directory exists */ if (!(dirp = my_dir(path,MYF(MY_DONT_SORT)))) { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0cc25c4fe6e..3ce1c334f96 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4805,6 +4805,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, if (lock_global_read_lock(thd)) return 1; } + my_dbopt_free(); result=close_cached_tables(thd,(options & REFRESH_FAST) ? 0 : 1, tables); } if (options & REFRESH_HOSTS) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index a560bd40028..c0be95c0453 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1158,6 +1158,23 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, } #endif + /* + If the table character set was not given explicitely, + let's fetch the database default character set and + apply it to the table. + */ + if (!create_info->default_table_charset) + { + HA_CREATE_INFO db_info; + uint length; + char path[FN_REFLEN]; + (void) sprintf(path,"%s/%s", mysql_data_home, db); + length= unpack_dirname(path,path); // Convert if not unix + strmov(path+length, MY_DB_OPT_FILE); + load_db_opt(thd, path, &db_info); + create_info->default_table_charset= db_info.default_table_charset; + } + if (mysql_prepare_table(thd, create_info, fields, keys, tmp_table, db_options, file, key_info_buffer, &key_count, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 2860077b6a0..ccbaf7c0112 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1023,7 +1023,7 @@ create: bzero((char*) &lex->create_info,sizeof(lex->create_info)); lex->create_info.options=$2 | $4; lex->create_info.db_type= (enum db_type) lex->thd->variables.table_type; - lex->create_info.default_table_charset= thd->variables.collation_database; + lex->create_info.default_table_charset= NULL; lex->name=0; } create2 @@ -1815,7 +1815,7 @@ alter: lex->select_lex.db=lex->name=0; bzero((char*) &lex->create_info,sizeof(lex->create_info)); lex->create_info.db_type= DB_TYPE_DEFAULT; - lex->create_info.default_table_charset= thd->variables.collation_database; + lex->create_info.default_table_charset= NULL; lex->create_info.row_type= ROW_TYPE_NOT_USED; lex->alter_info.reset(); lex->alter_info.is_simple= 1; From d2076ae8d5700b56333a8ccc723bbb928ee76a35 Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Thu, 8 Jul 2004 15:19:26 +0500 Subject: [PATCH 17/49] Minor fix: V is primary level, not U. --- mysql-test/r/ctype_uca.result | 3 ++- strings/ctype-uca.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result index 51da05f9fee..2fd654da434 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -1736,9 +1736,10 @@ T,t,Ţ,ţ,Ť,ť ƫ Ƭ,ƭ Ʈ -U,V,u,v,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ +Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ Ɯ Ʊ +U,V,u,v Ʋ W,w,Ŵ,ŵ X,x diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 9590b98e664..1b49abd0fbb 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -6655,7 +6655,7 @@ static const char spanish2[]= /* Also good for Asturian and Galician */ static const char roman[]= /* i.e. Classical Latin */ "& I << j <<< J " - "& U << v <<< V "; + "& V << u <<< U "; /* Unicode Collation Algorithm: From 844a9387d6dcfe19bd022adf1afc5c5a7c76df41 Mon Sep 17 00:00:00 2001 From: "mronstrom@mysql.com" <> Date: Thu, 8 Jul 2004 14:41:01 +0200 Subject: [PATCH 18/49] Fixes for min, max and default values of config params Removed all DEPRICATED params Introduced MAX_INT_RNIL as new maximum of Uint32 = RNIL - 1 --- ndb/src/common/mgmcommon/ConfigInfo.cpp | 596 +++++------------------- 1 file changed, 115 insertions(+), 481 deletions(-) diff --git a/ndb/src/common/mgmcommon/ConfigInfo.cpp b/ndb/src/common/mgmcommon/ConfigInfo.cpp index a2ca9c327d0..1eb9d9c639d 100644 --- a/ndb/src/common/mgmcommon/ConfigInfo.cpp +++ b/ndb/src/common/mgmcommon/ConfigInfo.cpp @@ -16,10 +16,11 @@ #include "ConfigInfo.hpp" #include +#include #define MAX_LINE_LENGTH 255 #define KEY_INTERNAL 0 - +#define MAX_INT_RNIL (RNIL - 1) /**************************************************************************** * Section names ****************************************************************************/ @@ -171,24 +172,7 @@ struct DepricationTransform { static const DepricationTransform f_deprication[] = { - { "DB", "NoOfIndexPages", "IndexMemory", 0, 8192 } - ,{ "DB", "MemorySpaceIndexes", "IndexMemory", 0, 8192 } - ,{ "DB", "NoOfDataPages", "DataMemory", 0, 8192 } - ,{ "DB", "MemorySpaceTuples", "DataMemory", 0, 8192 } - ,{ "DB", "TransactionInactiveTimeBeforeAbort", "TransactionInactiveTimeout", - 0, 1 } - ,{ "TCP", "ProcessId1", "NodeId1", 0, 1} - ,{ "TCP", "ProcessId2", "NodeId2", 0, 1} - ,{ "TCP", "SendBufferSize", "SendBufferMemory", 0, 16384 } - ,{ "TCP", "MaxReceiveSize", "ReceiveBufferMemory", 0, 16384 } - - // ,{ "SHM", "ProcessId1", "NodeId1", 0, 1} - // ,{ "SHM", "ProcessId2", "NodeId2", 0, 1} - ,{ "SCI", "ProcessId1", "NodeId1", 0, 1} - ,{ "SCI", "ProcessId2", "NodeId2", 0, 1} - ,{ "OSE", "ProcessId1", "NodeId1", 0, 1} - ,{ "OSE", "ProcessId2", "NodeId2", 0, 1} - ,{ 0, 0, 0, 0, 0} + { 0, 0, 0, 0, 0} }; /** @@ -252,21 +236,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, MANDATORY, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, - { - CFG_NODE_BYTE_ORDER, - "ByteOrder", - "COMPUTER", - "Not yet implemented", - ConfigInfo::USED, // Actually not used, but since it is MANDATORY, - // we don't want any warning message - false, - ConfigInfo::STRING, - MANDATORY, // Big == 0, Little == 1, NotSet == 2 (?) - 0, - 1 }, - /**************************************************************************** * SYSTEM ***************************************************************************/ @@ -316,7 +287,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 0, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_SYS_CONFIG_GENERATION, @@ -328,7 +299,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 0, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, /*************************************************************************** * DB @@ -355,7 +326,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_NODE_SYSTEM, @@ -367,7 +338,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_NODE_ID, @@ -403,7 +374,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, MANDATORY, 1, - 2 }, + 4 }, { CFG_DB_NO_ATTRIBUTES, @@ -415,7 +386,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 1000, 32, - 4096 }, + MAX_INT_RNIL/16 }, { CFG_DB_NO_TABLES, @@ -425,9 +396,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, false, ConfigInfo::INT, - 32, + 128, 8, - 128 }, + MAX_INT_RNIL }, { CFG_DB_NO_INDEXES, @@ -439,7 +410,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 128, 0, - 2048 }, + MAX_INT_RNIL }, { CFG_DB_NO_INDEX_OPS, @@ -451,7 +422,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 8192, 0, - 1000000 + MAX_INT_RNIL }, { @@ -464,7 +435,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 768, 0, - 2432 }, + MAX_INT_RNIL }, { CFG_DB_NO_TRIGGER_OPS, @@ -474,9 +445,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, false, ConfigInfo::INT, - 1000, + 4000, 0, - 1000000 }, + MAX_INT_RNIL }, { KEY_INTERNAL, @@ -488,7 +459,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, MANDATORY, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_DB_NO_SAVE_MSGS, @@ -500,7 +471,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 25, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_DB_MEMLOCK, @@ -512,32 +483,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::BOOL, false, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, - { - KEY_INTERNAL, - "SleepWhenIdle", - "DB", - 0, - ConfigInfo::DEPRICATED, - true, - ConfigInfo::BOOL, - true, - 0, - 0x7FFFFFFF }, - - { - KEY_INTERNAL, - "NoOfSignalsToExecuteBetweenCommunicationInterfacePoll", - "DB", - 0, - ConfigInfo::DEPRICATED, - true, - ConfigInfo::INT, - 20, - 1, - 0x7FFFFFFF }, - { CFG_DB_WATCHDOG_INTERVAL, "TimeBetweenWatchDogCheck", @@ -548,7 +495,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 4000, 70, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_DB_STOP_ON_ERROR, @@ -560,7 +507,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::BOOL, true, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_DB_STOP_ON_ERROR_INSERT, @@ -582,9 +529,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, false, ConfigInfo::INT, - 8192, + 32768, 32, - 1000000 }, + MAX_INT_RNIL }, { CFG_DB_NO_TRANSACTIONS, @@ -596,7 +543,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 4096, 32, - 1000000 }, + MAX_INT_RNIL }, { CFG_DB_NO_SCANS, @@ -606,7 +553,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, false, ConfigInfo::INT, - 25, + 256, 2, 500 }, @@ -618,9 +565,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, false, ConfigInfo::INT, - 1024000, + (1024 * 1024), 1024, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_DB_INDEX_MEM, @@ -630,33 +577,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, false, ConfigInfo::INT64, - 3000 * 8192, + 3 * 1024 * 8192, 128 * 8192, - ((Uint64)192000) * ((Uint64)8192) }, - - { - KEY_INTERNAL, - "NoOfIndexPages", - "DB", - "IndexMemory", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - 3000, - 128, - 192000 }, - - { - KEY_INTERNAL, - "MemorySpaceIndexes", - "DB", - "IndexMemory", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 128, - 192000 }, + ((Uint64)MAX_INT_RNIL) * ((Uint64)8192) }, { CFG_DB_DATA_MEM, @@ -666,34 +589,10 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, false, ConfigInfo::INT64, - 10000 * 8192, + 10 * 1024 * 8192, 128 * 8192, - ((Uint64)400000) * ((Uint64)8192) }, + ((Uint64)MAX_INT_RNIL) * ((Uint64)8192) }, - { - KEY_INTERNAL, - "NoOfDataPages", - "DB", - "DataMemory", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - 10000, - 128, - 400000 }, - - { - KEY_INTERNAL, - "MemorySpaceTuples", - "DB", - "DataMemory", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 128, - 400000 }, - { CFG_DB_START_PARTIAL_TIMEOUT, "StartPartialTimeout", @@ -726,22 +625,10 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, true, ConfigInfo::INT, - 5*60000, + 0, 0, ~0 }, - { - KEY_INTERNAL, - "TimeToWaitAlive", - "DB", - "Start{Partial/Partitioned/Failure}Time", - ConfigInfo::DEPRICATED, - true, - ConfigInfo::INT, - 25, - 2, - 4000 }, - { CFG_DB_HEARTBEAT_INTERVAL, "HeartbeatIntervalDbDb", @@ -752,7 +639,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 1500, 10, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_DB_API_HEARTBEAT_INTERVAL, @@ -764,7 +651,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 1500, 100, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_DB_LCP_INTERVAL, @@ -800,7 +687,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 8, 1, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { KEY_INTERNAL, @@ -825,7 +712,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 1000, 1000, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_DB_TRANSACTION_INACTIVE_TIMEOUT, @@ -839,9 +726,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, true, ConfigInfo::INT, - 3000, + MAX_INT_RNIL, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_DB_TRANSACTION_DEADLOCK_TIMEOUT, @@ -854,22 +741,10 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, true, ConfigInfo::INT, - 3000, + 1200, 50, - 0x7FFFFFFF }, + MAX_INT_RNIL }, - { - KEY_INTERNAL, - "TransactionInactiveTimeBeforeAbort", - "DB", - "TransactionInactiveTimeout", - ConfigInfo::DEPRICATED, - true, - ConfigInfo::INT, - 3000, - 20, - 0x7FFFFFFF }, - { KEY_INTERNAL, "NoOfDiskPagesToDiskDuringRestartTUP", @@ -878,9 +753,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, true, ConfigInfo::INT, - 50, + 40, 1, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { KEY_INTERNAL, @@ -890,9 +765,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, true, ConfigInfo::INT, - 10, + 40, 1, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { KEY_INTERNAL, @@ -902,9 +777,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, true, ConfigInfo::INT, - 25, + 20, 1, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { KEY_INTERNAL, @@ -914,9 +789,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, true, ConfigInfo::INT, - 5, + 20, 1, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { @@ -939,9 +814,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, false, ConfigInfo::INT, - 1000, + 3000, 10, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_DB_FILESYSTEM_PATH, @@ -953,7 +828,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_LOGLEVEL_STARTUP, @@ -1076,7 +951,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, (2 * 1024 * 1024) + (2 * 1024 * 1024), // sum of BackupDataBufferSize and BackupLogBufferSize 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_DB_BACKUP_DATA_BUFFER_MEM, @@ -1088,7 +963,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, (2 * 1024 * 1024), // remember to change BackupMemory 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_DB_BACKUP_LOG_BUFFER_MEM, @@ -1100,7 +975,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, (2 * 1024 * 1024), // remember to change BackupMemory 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_DB_BACKUP_WRITE_SIZE, @@ -1112,7 +987,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 32768, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, /*************************************************************************** * REP @@ -1139,7 +1014,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_NODE_SYSTEM, @@ -1151,7 +1026,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_NODE_ID, @@ -1175,7 +1050,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, MANDATORY, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_REP_HEARTBEAT_INTERVAL, @@ -1187,7 +1062,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 3000, 100, - 0x7FFFFFFF }, + MAX_INT_RNIL }, /*************************************************************************** * API @@ -1214,7 +1089,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_NODE_SYSTEM, @@ -1226,7 +1101,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_NODE_ID, @@ -1250,7 +1125,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, 0, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_NODE_ARBIT_RANK, @@ -1260,7 +1135,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, false, ConfigInfo::INT, - 2, + 0, 0, 2 }, @@ -1274,7 +1149,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 0, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, /**************************************************************************** * MGM @@ -1301,7 +1176,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_NODE_SYSTEM, @@ -1313,7 +1188,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_NODE_ID, @@ -1337,7 +1212,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, 0, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { KEY_INTERNAL, @@ -1349,7 +1224,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, 0, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { KEY_INTERNAL, @@ -1361,7 +1236,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 100, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_MGM_PORT, @@ -1373,7 +1248,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, NDB_BASE_PORT, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { KEY_INTERNAL, @@ -1385,7 +1260,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 2199, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_NODE_ARBIT_RANK, @@ -1395,7 +1270,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, false, ConfigInfo::INT, - 2, + 1, 0, 2 }, @@ -1409,7 +1284,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 0, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, /**************************************************************************** * TCP @@ -1436,7 +1311,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_TCP_HOSTNAME_2, @@ -1448,7 +1323,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_CONNECTION_NODE_1, @@ -1460,19 +1335,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, MANDATORY, 0, - 0x7FFFFFFF }, - - { - KEY_INTERNAL, - "ProcessId1", - "TCP", - "NodeId1", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_CONNECTION_NODE_2, @@ -1484,43 +1347,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, MANDATORY, 0, - 0x7FFFFFFF }, - - { - KEY_INTERNAL, - "ProcessId2", - "TCP", - "NodeId2", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF }, - - { - KEY_INTERNAL, - "IpAddress1", - "TCP", - "HostName1", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::STRING, - UNDEFINED, - 0, - 0x7FFFFFFF }, - - { - KEY_INTERNAL, - "IpAddress2", - "TCP", - "HostName2", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::STRING, - UNDEFINED, - 0, - 0 }, + MAX_INT_RNIL }, { CFG_CONNECTION_SEND_SIGNAL_ID, @@ -1532,7 +1359,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::BOOL, true, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { @@ -1545,7 +1372,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::BOOL, false, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_CONNECTION_SERVER_PORT, @@ -1557,7 +1384,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, MANDATORY, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_TCP_SEND_BUFFER_SIZE, @@ -1569,20 +1396,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 16 * 16384, 1 * 16384, - 0x7FFFFFFF }, + MAX_INT_RNIL }, - { - KEY_INTERNAL, - "SendBufferSize", - "TCP", - "SendBufferMemory", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - 16, - 1, - 0x7FFFFFFF }, - { CFG_TCP_RECEIVE_BUFFER_SIZE, "ReceiveBufferMemory", @@ -1593,19 +1408,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 4 * 16384, 1 * 16384, - 0x7FFFFFFF }, - - { - KEY_INTERNAL, - "MaxReceiveSize", - "TCP", - "ReceiveBufferMemory", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - 4, - 1, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_TCP_PROXY, @@ -1619,19 +1422,6 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { 0, 0 }, - { - KEY_INTERNAL, - "Compression", - "TCP", - 0, - ConfigInfo::DEPRICATED, - false, - ConfigInfo::BOOL, - false, - 0, - 0x7FFFFFFF }, - - { CFG_CONNECTION_NODE_1_SYSTEM, "NodeId1_System", @@ -1642,7 +1432,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_CONNECTION_NODE_2_SYSTEM, @@ -1654,7 +1444,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, /**************************************************************************** @@ -1682,7 +1472,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, MANDATORY, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_CONNECTION_SERVER_PORT, @@ -1694,20 +1484,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, MANDATORY, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, - { - KEY_INTERNAL, - "ProcessId1", - "SHM", - "NodeId1", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::STRING, - UNDEFINED, - 0, - 0x7FFFFFFF }, - { CFG_CONNECTION_NODE_2, "NodeId2", @@ -1718,19 +1496,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, MANDATORY, 0, - 0x7FFFFFFF }, - - { - KEY_INTERNAL, - "ProcessId2", - "SHM", - "NodeId1", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::STRING, - UNDEFINED, - 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_CONNECTION_SEND_SIGNAL_ID, @@ -1742,7 +1508,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::BOOL, false, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { @@ -1755,7 +1521,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::BOOL, true, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_SHM_KEY, @@ -1767,7 +1533,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, MANDATORY, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_SHM_BUFFER_MEM, @@ -1779,20 +1545,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 1048576, 4096, - 0x7FFFFFFF }, + MAX_INT_RNIL }, - { - KEY_INTERNAL, - "Compression", - "SHM", - 0, - ConfigInfo::DEPRICATED, - false, - ConfigInfo::BOOL, - false, - 0, - 0x7FFFFFFF }, - { CFG_CONNECTION_NODE_1_SYSTEM, "NodeId1_System", @@ -1803,7 +1557,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_CONNECTION_NODE_2_SYSTEM, @@ -1815,7 +1569,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, /**************************************************************************** * SCI @@ -1842,19 +1596,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, MANDATORY, 0, - 0x7FFFFFFF }, - - { - KEY_INTERNAL, - "ProcessId1", - "SCI", - "NodeId1", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_CONNECTION_NODE_2, @@ -1866,19 +1608,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, MANDATORY, 0, - 0x7FFFFFFF }, - - { - KEY_INTERNAL, - "ProcessId2", - "SCI", - "NodeId2", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_SCI_ID_0, @@ -1890,7 +1620,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, MANDATORY, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_SCI_ID_1, @@ -1902,7 +1632,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, MANDATORY, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_CONNECTION_SEND_SIGNAL_ID, @@ -1914,7 +1644,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::BOOL, true, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_CONNECTION_CHECKSUM, @@ -1926,7 +1656,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::BOOL, false, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_SCI_SEND_LIMIT, @@ -1938,7 +1668,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 2048, 512, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_SCI_BUFFER_MEM, @@ -1950,67 +1680,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 1048576, 262144, - 0x7FFFFFFF }, - - { - KEY_INTERNAL, - "Node1_NoOfAdapters", - "SCI", - 0, - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF }, - - { - KEY_INTERNAL, - "Node2_NoOfAdapters", - "SCI", - 0, - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF }, - - { - KEY_INTERNAL, - "Node1_Adapter", - "SCI", - 0, - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF }, - - { - KEY_INTERNAL, - "Node2_Adapter", - "SCI", - 0, - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF }, - - { - KEY_INTERNAL, - "Compression", - "SCI", - 0, - ConfigInfo::DEPRICATED, - false, - ConfigInfo::BOOL, - false, - 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_CONNECTION_NODE_1_SYSTEM, @@ -2022,7 +1692,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_CONNECTION_NODE_2_SYSTEM, @@ -2034,7 +1704,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, /**************************************************************************** * OSE @@ -2061,7 +1731,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_OSE_HOSTNAME_2, @@ -2073,7 +1743,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_CONNECTION_NODE_1, @@ -2085,19 +1755,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, MANDATORY, 0, - 0x7FFFFFFF }, - - { - KEY_INTERNAL, - "ProcessId1", - "OSE", - "NodeId1", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_CONNECTION_NODE_2, @@ -2109,19 +1767,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, UNDEFINED, 0, - 0x7FFFFFFF }, - - { - KEY_INTERNAL, - "ProcessId2", - "OSE", - "NodeId2", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - MANDATORY, - 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_CONNECTION_SEND_SIGNAL_ID, @@ -2133,7 +1779,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::BOOL, true, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_CONNECTION_CHECKSUM, @@ -2145,7 +1791,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::BOOL, false, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_OSE_PRIO_A_SIZE, @@ -2157,7 +1803,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 1000, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_OSE_PRIO_B_SIZE, @@ -2169,7 +1815,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 1000, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_OSE_RECEIVE_ARRAY_SIZE, @@ -2181,19 +1827,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 10, 0, - 0x7FFFFFFF }, - - { - KEY_INTERNAL, - "Compression", - "OSE", - 0, - ConfigInfo::DEPRICATED, - false, - ConfigInfo::BOOL, - false, - 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, { CFG_CONNECTION_NODE_1_SYSTEM, @@ -2205,7 +1839,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL}, { CFG_CONNECTION_NODE_2_SYSTEM, @@ -2217,7 +1851,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::STRING, UNDEFINED, 0, - 0x7FFFFFFF }, + MAX_INT_RNIL }, }; const int ConfigInfo::m_NoOfParams = sizeof(m_ParamInfo) / sizeof(ParamInfo); From db7efa27803b1ee58a3b04c63a4cc14241420fd0 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Thu, 8 Jul 2004 15:45:25 +0300 Subject: [PATCH 19/49] New handler::index_flags() definition to make it easy to check the full used key and a specific key part. Added key part to optimize_range() to fix problems when using fields in key parts. --- sql/examples/ha_archive.h | 2 +- sql/examples/ha_example.h | 8 ++++++-- sql/field.cc | 4 ++-- sql/field.h | 4 ++-- sql/ha_berkeley.cc | 17 +++++++++++++++++ sql/ha_berkeley.h | 8 +------- sql/ha_heap.h | 2 +- sql/ha_innodb.h | 2 +- sql/ha_isam.h | 2 +- sql/ha_isammrg.h | 3 ++- sql/ha_myisam.h | 6 +++--- sql/ha_myisammrg.h | 6 +++--- sql/ha_ndbcluster.cc | 3 ++- sql/ha_ndbcluster.h | 2 +- sql/handler.h | 2 +- sql/log.cc | 7 ++++--- sql/log_event.cc | 13 +++++++------ sql/opt_range.cc | 9 ++++++--- sql/opt_sum.cc | 2 +- sql/set_var.cc | 8 ++++---- sql/sql_db.cc | 5 +++-- sql/sql_select.cc | 10 +++++----- sql/sql_show.cc | 5 +++-- sql/sql_update.cc | 5 ++++- sql/table.cc | 4 ++-- 25 files changed, 83 insertions(+), 56 deletions(-) diff --git a/sql/examples/ha_archive.h b/sql/examples/ha_archive.h index 03e296d0eae..2fab80f0598 100644 --- a/sql/examples/ha_archive.h +++ b/sql/examples/ha_archive.h @@ -72,7 +72,7 @@ public: return (HA_REC_NOT_IN_SEQ | HA_NOT_EXACT_COUNT | HA_NO_AUTO_INCREMENT | HA_FILE_BASED); } - ulong index_flags(uint idx, uint part) const + ulong index_flags(uint idx, uint part, bool all_parts) const { return 0; } diff --git a/sql/examples/ha_example.h b/sql/examples/ha_example.h index dc8f265c16e..3c6ce4220ee 100644 --- a/sql/examples/ha_example.h +++ b/sql/examples/ha_example.h @@ -69,12 +69,16 @@ public: return 0; } /* - This is a list of flags that says how the storage engine + This is a bitmap of flags that says how the storage engine implements indexes. The current index flags are documented in handler.h. If you do not implement indexes, just return zero here. + + part is the key part to check. First key part is 0 + If all_parts it's set, MySQL want to know the flags for the combined + index up to and including 'part'. */ - ulong index_flags(uint inx, uint part) const + ulong index_flags(uint inx, uint part, bool all_parts) const { return 0; } diff --git a/sql/field.cc b/sql/field.cc index 2d3729817b7..26c84575b4d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -431,9 +431,9 @@ void Field::store_time(TIME *ltime,timestamp_type type) } -bool Field::optimize_range(uint idx) +bool Field::optimize_range(uint idx, uint part) { - return test(table->file->index_flags(idx) & HA_READ_RANGE); + return test(table->file->index_flags(idx, part, 1) & HA_READ_RANGE); } /**************************************************************************** diff --git a/sql/field.h b/sql/field.h index a2fe77e18a3..24faee9d314 100644 --- a/sql/field.h +++ b/sql/field.h @@ -178,7 +178,7 @@ public: inline bool real_maybe_null(void) { return null_ptr != 0; } virtual void make_field(Send_field *)=0; virtual void sort_string(char *buff,uint length)=0; - virtual bool optimize_range(uint idx); + virtual bool optimize_range(uint idx, uint part); virtual bool store_for_compare() { return 0; } virtual void free() {} Field *new_field(MEM_ROOT *root, struct st_table *new_table) @@ -1134,7 +1134,7 @@ public: uint size_of() const { return sizeof(*this); } enum_field_types real_type() const { return FIELD_TYPE_ENUM; } virtual bool zero_pack() const { return 0; } - bool optimize_range(uint idx) { return 0; } + bool optimize_range(uint idx, uint part) { return 0; } bool eq_def(Field *field); bool has_charset(void) const { return TRUE; } field_cast_enum field_cast_type() { return FIELD_CAST_ENUM; } diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 4bed33af15b..bb07bd9dc4b 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -340,6 +340,23 @@ const char **ha_berkeley::bas_ext() const { static const char *ext[]= { ha_berkeley_ext, NullS }; return ext; } +ulong ha_berkeley::index_flags(uint idx, uint part, bool all_parts) const +{ + ulong flags= (HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | HA_KEYREAD_ONLY + | HA_READ_RANGE); + for (uint idx= all_parts ? 0 : part ; idx <= part ; idx++) + { + if (table->key_info[idx].key_part[part].field->type() == FIELD_TYPE_BLOB) + { + /* We can't use BLOBS to shortcut sorts */ + flags&= ~ (HA_READ_ORDER | HA_KEYREAD_ONLY | HA_READ_RANGE); + break; + } + } + return flags; +} + + static int berkeley_cmp_hidden_key(DB* file, const DBT *new_key, const DBT *saved_key) { diff --git a/sql/ha_berkeley.h b/sql/ha_berkeley.h index efc85d3928e..5cba3bebf10 100644 --- a/sql/ha_berkeley.h +++ b/sql/ha_berkeley.h @@ -94,13 +94,7 @@ class ha_berkeley: public handler changed_rows(0),last_dup_key((uint) -1),version(0),using_ignore(0) {} ~ha_berkeley() {} const char *table_type() const { return "BerkeleyDB"; } - ulong index_flags(uint idx, uint part) const - { - ulong flags=HA_READ_NEXT | HA_READ_PREV; - if (table->key_info[idx].key_part[part].field->key_type() != HA_KEYTYPE_TEXT) - flags|= HA_READ_ORDER | HA_KEYREAD_ONLY | HA_READ_RANGE; - return flags; - } + ulong index_flags(uint idx, uint part, bool all_parts) const; const char *index_type(uint key_number) { return "BTREE"; } const char **bas_ext() const; ulong table_flags(void) const { return int_table_flags; } diff --git a/sql/ha_heap.h b/sql/ha_heap.h index f05146acdc4..9ca6b9b76b6 100644 --- a/sql/ha_heap.h +++ b/sql/ha_heap.h @@ -44,7 +44,7 @@ class ha_heap: public handler HA_REC_NOT_IN_SEQ | HA_READ_RND_SAME | HA_CAN_INSERT_DELAYED); } - ulong index_flags(uint inx, uint part) const + ulong index_flags(uint inx, uint part, bool all_parts) const { return ((table->key_info[inx].algorithm == HA_KEY_ALG_BTREE) ? HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | HA_READ_RANGE : diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h index 7e05488289e..e09697f7ce6 100644 --- a/sql/ha_innodb.h +++ b/sql/ha_innodb.h @@ -94,7 +94,7 @@ class ha_innobase: public handler const char *index_type(uint key_number) { return "BTREE"; } const char** bas_ext() const; ulong table_flags() const { return int_table_flags; } - ulong index_flags(uint idx, uint part) const + ulong index_flags(uint idx, uint part, bool all_parts) const { return (HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | HA_READ_RANGE | HA_KEYREAD_ONLY); diff --git a/sql/ha_isam.h b/sql/ha_isam.h index 521946a17b5..b3e932696cb 100644 --- a/sql/ha_isam.h +++ b/sql/ha_isam.h @@ -36,7 +36,7 @@ class ha_isam: public handler HA_DUPP_POS | HA_NOT_DELETE_WITH_CACHE | HA_FILE_BASED) {} ~ha_isam() {} - ulong index_flags(uint idx, uint part) const + ulong index_flags(uint idx, uint part, bool all_parts) const { return HA_READ_NEXT; } // but no HA_READ_PREV here!!! const char *table_type() const { return "ISAM"; } const char *index_type(uint key_number) { return "BTREE"; } diff --git a/sql/ha_isammrg.h b/sql/ha_isammrg.h index 166a96cf9e4..657e5060272 100644 --- a/sql/ha_isammrg.h +++ b/sql/ha_isammrg.h @@ -34,7 +34,8 @@ class ha_isammrg: public handler const char **bas_ext() const; ulong table_flags() const { return (HA_READ_RND_SAME | HA_REC_NOT_IN_SEQ | HA_FILE_BASED); } - ulong index_flags(uint idx, uint part) const { DBUG_ASSERT(0); return 0; } + ulong index_flags(uint idx, uint part, bool all_parts) const + { DBUG_ASSERT(0); return 0; } uint max_supported_keys() const { return 0; } bool low_byte_first() const { return 0; } diff --git a/sql/ha_myisam.h b/sql/ha_myisam.h index ef3f00577dd..6fde84d6f6f 100644 --- a/sql/ha_myisam.h +++ b/sql/ha_myisam.h @@ -55,11 +55,11 @@ class ha_myisam: public handler const char *index_type(uint key_number); const char **bas_ext() const; ulong table_flags() const { return int_table_flags; } - ulong index_flags(uint inx, uint part) const + ulong index_flags(uint inx, uint part, bool all_parts) const { return ((table->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) ? - 0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | - HA_READ_ORDER | HA_KEYREAD_ONLY); + 0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | + HA_READ_ORDER | HA_KEYREAD_ONLY); } uint max_supported_keys() const { return MI_MAX_KEY; } uint max_supported_key_length() const { return MI_MAX_KEY_LENGTH; } diff --git a/sql/ha_myisammrg.h b/sql/ha_myisammrg.h index 995cfe9ad4a..264c580220c 100644 --- a/sql/ha_myisammrg.h +++ b/sql/ha_myisammrg.h @@ -38,11 +38,11 @@ class ha_myisammrg: public handler HA_NULL_IN_KEY | HA_CAN_INDEX_BLOBS | HA_FILE_BASED | HA_CAN_INSERT_DELAYED); } - ulong index_flags(uint inx, uint part) const + ulong index_flags(uint inx, uint part, bool all_parts) const { return ((table->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) ? - 0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | - HA_READ_ORDER | HA_KEYREAD_ONLY); + 0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | + HA_READ_ORDER | HA_KEYREAD_ONLY); } uint max_supported_keys() const { return MI_MAX_KEY; } uint max_supported_key_length() const { return MI_MAX_KEY_LENGTH; } diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index d499218a8c3..5b36d6d2b55 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -524,7 +524,8 @@ inline NDB_INDEX_TYPE ha_ndbcluster::get_index_type(uint idx_no) const flags depending on the type of the index. */ -inline ulong ha_ndbcluster::index_flags(uint idx_no, uint part) const +inline ulong ha_ndbcluster::index_flags(uint idx_no, uint part, + bool all_parts) const { DBUG_ENTER("index_flags"); DBUG_PRINT("info", ("idx_no: %d", idx_no)); diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index 39c1779a27a..f094b79ef35 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -93,7 +93,7 @@ class ha_ndbcluster: public handler const char * table_type() const { return("ndbcluster");} const char ** bas_ext() const; ulong table_flags(void) const { return m_table_flags; } - ulong index_flags(uint idx, uint part) const; + ulong index_flags(uint idx, uint part, bool all_parts) const; uint max_supported_record_length() const { return NDB_MAX_TUPLE_SIZE; }; uint max_supported_keys() const { return MAX_KEY; } uint max_supported_key_parts() const diff --git a/sql/handler.h b/sql/handler.h index a3ed1f35495..28b0b8df6e2 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -449,7 +449,7 @@ public: virtual const char *table_type() const =0; virtual const char **bas_ext() const =0; virtual ulong table_flags(void) const =0; - virtual ulong index_flags(uint idx, uint part=0) const =0; + virtual ulong index_flags(uint idx, uint part, bool all_parts) const =0; virtual ulong index_ddl_flags(KEY *wanted_index) const { return (HA_DDL_SUPPORT); } virtual int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) diff --git a/sql/log.cc b/sql/log.cc index 124439ae9eb..afba530ce49 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2046,10 +2046,8 @@ bool flush_error_log() bool MYSQL_LOG::cut_spurious_tail() { int error= 0; - char llbuf1[22], llbuf2[22]; - ulonglong actual_size; - DBUG_ENTER("cut_spurious_tail"); + #ifdef HAVE_INNOBASE_DB if (have_innodb != SHOW_OPTION_YES) DBUG_RETURN(0); @@ -2059,6 +2057,9 @@ bool MYSQL_LOG::cut_spurious_tail() */ char *name= ha_innobase::get_mysql_bin_log_name(); ulonglong pos= ha_innobase::get_mysql_bin_log_pos(); + ulonglong actual_size; + char llbuf1[22], llbuf2[22]; + if (name[0] == 0 || pos == ULONGLONG_MAX) { DBUG_PRINT("info", ("InnoDB has not set binlog info")); diff --git a/sql/log_event.cc b/sql/log_event.cc index 315b0f670dd..eb86a50b946 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2378,17 +2378,18 @@ void User_var_log_event::print(FILE* file, bool short_form, char* last_db) > the string constant is still unescaped according to SJIS, not > according to UCS2. */ - char *p, *q; - if (!(p= (char *)my_alloca(2*val_len+1+2))) // 2 hex digits per byte + char *hex_str; + CHARSET_INFO *cs; + + if (!(hex_str= (char *)my_alloca(2*val_len+1+2))) // 2 hex digits / byte break; // no error, as we are 'void' - str_to_hex(p, val, val_len); + str_to_hex(hex_str, val, val_len); /* For proper behaviour when mysqlbinlog|mysql, we need to explicitely specify the variable's collation. It will however cause problems when people want to mysqlbinlog|mysql into another server not supporting the character set. But there's not much to do about this and it's unlikely. */ - CHARSET_INFO *cs; if (!(cs= get_charset(charset_number, MYF(0)))) /* Generate an unusable command (=> syntax error) is probably the best @@ -2396,8 +2397,8 @@ void User_var_log_event::print(FILE* file, bool short_form, char* last_db) */ fprintf(file, ":=???;\n"); else - fprintf(file, ":=_%s %s COLLATE %s;\n", cs->csname, p, cs->name); - my_afree(p); + fprintf(file, ":=_%s %s COLLATE %s;\n", cs->csname, hex_str, cs->name); + my_afree(hex_str); } break; case ROW_RESULT: diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 32a0391a777..40e3ffebe56 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -727,7 +727,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, found_records=check_quick_select(¶m, idx, *key); if (found_records != HA_POS_ERROR && found_records > 2 && head->used_keys.is_set(keynr) && - (head->file->index_flags(keynr) & HA_KEYREAD_ONLY)) + (head->file->index_flags(keynr, param.max_key_part, 1) & + HA_KEYREAD_ONLY)) { /* We can resolve this by only reading through this key. @@ -1028,7 +1029,8 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part, String tmp(buff1,sizeof(buff1),value->collation.collation),*res; uint length,offset,min_length,max_length; - if (!field->optimize_range(param->real_keynr[key_part->key])) + if (!field->optimize_range(param->real_keynr[key_part->key], + key_part->part)) DBUG_RETURN(0); // Can't optimize this if (!(res= value->val_str(&tmp))) DBUG_RETURN(&null_element); @@ -1093,7 +1095,8 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part, DBUG_RETURN(new SEL_ARG(field,min_str,max_str)); } - if (!field->optimize_range(param->real_keynr[key_part->key]) && + if (!field->optimize_range(param->real_keynr[key_part->key], + key_part->part) && type != Item_func::EQ_FUNC && type != Item_func::EQUAL_FUNC) DBUG_RETURN(0); // Can't optimize this diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 27f3f476fe7..f4c39462d0c 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -645,7 +645,7 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref, part != part_end ; part++, jdx++, key_part_to_use= (key_part_to_use << 1) | 1) { - if (!(table->file->index_flags(idx, jdx) & HA_READ_ORDER)) + if (!(table->file->index_flags(idx, jdx, 0) & HA_READ_ORDER)) return 0; if (field->eq(part->field)) diff --git a/sql/set_var.cc b/sql/set_var.cc index 840a7ae075a..9481e1aaef7 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1744,10 +1744,10 @@ bool sys_var_collation::check(THD *thd, set_var *var) } else // INT_RESULT { - if (!(tmp=get_charset(var->value->val_int(),MYF(0)))) + if (!(tmp=get_charset((int) var->value->val_int(),MYF(0)))) { char buf[20]; - int10_to_str(var->value->val_int(), buf, -10); + int10_to_str((int) var->value->val_int(), buf, -10); my_error(ER_UNKNOWN_COLLATION, MYF(0), buf); return 1; } @@ -1783,10 +1783,10 @@ bool sys_var_character_set::check(THD *thd, set_var *var) } else // INT_RESULT { - if (!(tmp=get_charset(var->value->val_int(),MYF(0)))) + if (!(tmp=get_charset((int) var->value->val_int(),MYF(0)))) { char buf[20]; - int10_to_str(var->value->val_int(), buf, -10); + int10_to_str((int) var->value->val_int(), buf, -10); my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), buf); return 1; } diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 9db2198268a..8cae3b398a0 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -636,8 +636,10 @@ bool mysql_change_db(THD *thd, const char *name) int length, db_length; char *dbname=my_strdup((char*) name,MYF(MY_WME)); char path[FN_REFLEN]; - ulong db_access; HA_CREATE_INFO create; +#ifndef NO_EMBEDDED_ACCESS_CHECKS + ulong db_access; +#endif DBUG_ENTER("mysql_change_db"); if (!dbname || !(db_length= strlen(dbname))) @@ -698,4 +700,3 @@ bool mysql_change_db(THD *thd, const char *name) thd->variables.collation_database= thd->db_charset; DBUG_RETURN(0); } - diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 90636364459..657853c98ba 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2825,7 +2825,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, Set tmp to (previous record count) * (records / combination) */ if ((found_part & 1) && - (!(table->file->index_flags(key,0) & HA_ONLY_WHOLE_INDEX) || + (!(table->file->index_flags(key,0,0) & HA_ONLY_WHOLE_INDEX) || found_part == PREV_BITS(uint,keyinfo->key_parts))) { max_key_part=max_part_bit(found_part); @@ -7172,7 +7172,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, if (!select->quick->reverse_sorted()) { // here used_key_parts >0 - if (!(table->file->index_flags(ref_key,used_key_parts-1) + if (!(table->file->index_flags(ref_key,used_key_parts-1, 1) & HA_READ_PREV)) DBUG_RETURN(0); // Use filesort // ORDER BY range_key DESC @@ -7195,9 +7195,9 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, Use a traversal function that starts by reading the last row with key part (A) and then traverse the index backwards. */ - if (!(table->file->index_flags(ref_key,used_key_parts-1) - & HA_READ_PREV)) - DBUG_RETURN(0); // Use filesort + if (!(table->file->index_flags(ref_key,used_key_parts-1, 1) + & HA_READ_PREV)) + DBUG_RETURN(0); // Use filesort tab->read_first_record= join_read_last_key; tab->read_record.read_record= join_read_prev_same; /* fall through */ diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 467c774c2e1..e217555e582 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -701,8 +701,9 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, byte *pos; uint flags=field->flags; String type(tmp,sizeof(tmp), system_charset_info); +#ifndef NO_EMBEDDED_ACCESS_CHECKS uint col_access; - +#endif protocol->prepare_for_resend(); protocol->store(field->field_name, system_charset_info); field->sql_type(type); @@ -995,7 +996,7 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list) str=(key_part->field ? key_part->field->field_name : "?unknown field?"); protocol->store(str, system_charset_info); - if (table->file->index_flags(i,j) & HA_READ_ORDER) + if (table->file->index_flags(i, j, 0) & HA_READ_ORDER) protocol->store(((key_part->key_part_flag & HA_REVERSE_SORT) ? "D" : "A"), 1, system_charset_info); else diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 18394d007ed..db4edff4fa1 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -61,7 +61,10 @@ int mysql_update(THD *thd, bool safe_update= thd->options & OPTION_SAFE_UPDATES; bool used_key_is_modified, transactional_table, log_delayed; int error=0; - uint used_index, want_privilege; + uint used_index; +#ifndef NO_EMBEDDED_ACCESS_CHECKS + uint want_privilege; +#endif ulong query_id=thd->query_id, timestamp_query_id; ha_rows updated, found; key_map old_used_keys; diff --git a/sql/table.cc b/sql/table.cc index 2b92583e777..d3ed6e11756 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -569,13 +569,13 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, if (field->key_length() == key_part->length && !(field->flags & BLOB_FLAG)) { - if (outparam->file->index_flags(key, i) & HA_KEYREAD_ONLY) + if (outparam->file->index_flags(key, i, 1) & HA_KEYREAD_ONLY) { outparam->read_only_keys.clear_bit(key); outparam->keys_for_keyread.set_bit(key); field->part_of_key.set_bit(key); } - if (outparam->file->index_flags(key, i) & HA_READ_ORDER) + if (outparam->file->index_flags(key, i, 1) & HA_READ_ORDER) field->part_of_sortkey.set_bit(key); } if (!(key_part->key_part_flag & HA_REVERSE_SORT) && From 6c996daa911433d3aab0f9d407d716abbbf6d06f Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Thu, 8 Jul 2004 18:54:07 +0500 Subject: [PATCH 20/49] Bug#4338: mysql-test-run fails if compiled with non-latin1 character set --- mysql-test/r/alter_table.result | 2 +- mysql-test/r/connect.result | 4 ++-- mysql-test/r/grant.result | 1 + mysql-test/r/grant2.result | 1 + mysql-test/r/grant_cache.result | 1 + mysql-test/r/multi_update.result | 2 +- mysql-test/r/rpl000001.result | 8 ++++---- mysql-test/r/rpl_do_grant.result | 16 ++++++++-------- mysql-test/r/rpl_ignore_grant.result | 24 ++++++++++++------------ mysql-test/r/show_check.result | 1 + mysql-test/t/alter_table.test | 2 +- mysql-test/t/connect.test | 4 ++-- mysql-test/t/grant.test | 2 ++ mysql-test/t/grant2.test | 2 ++ mysql-test/t/grant_cache.test | 9 +++++++++ mysql-test/t/multi_update.test | 2 +- mysql-test/t/rpl000001.test | 8 ++++---- mysql-test/t/rpl_do_grant.test | 14 +++++++------- mysql-test/t/rpl_ignore_grant.test | 22 +++++++++++----------- mysql-test/t/show_check.test | 1 + 20 files changed, 72 insertions(+), 54 deletions(-) diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 1441b3c3600..5d50a3da666 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -123,7 +123,7 @@ grant all on mysqltest.t1 to mysqltest_1@localhost; alter table t1 rename t2; ERROR 42000: insert command denied to user 'mysqltest_1'@'localhost' for table 't2' revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; -delete from mysql.user where user='mysqltest_1'; +delete from mysql.user where user=_binary'mysqltest_1'; drop database mysqltest; create table t1 (n1 int not null, n2 int, n3 int, n4 float, unique(n1), diff --git a/mysql-test/r/connect.result b/mysql-test/r/connect.result index 6ac32232b2b..10c5d6cc0b8 100644 --- a/mysql-test/r/connect.result +++ b/mysql-test/r/connect.result @@ -38,7 +38,7 @@ time_zone_transition_type user show tables; Tables_in_test -update mysql.user set password=old_password("gambling2") where user="test"; +update mysql.user set password=old_password("gambling2") where user=_binary"test"; flush privileges; set password=old_password('gambling3'); show tables; @@ -60,5 +60,5 @@ time_zone_transition_type user show tables; Tables_in_test -delete from mysql.user where user="test"; +delete from mysql.user where user=_binary"test"; flush privileges; diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 0ae4ec8dee1..aa6c0c3f505 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -1,4 +1,5 @@ drop table if exists t1; +SET NAMES binary; delete from mysql.user where user='mysqltest_1'; delete from mysql.db where user='mysqltest_1'; flush privileges; diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result index 6f341e12344..31e506d2679 100644 --- a/mysql-test/r/grant2.result +++ b/mysql-test/r/grant2.result @@ -1,3 +1,4 @@ +SET NAMES binary; delete from mysql.user where user like 'mysqltest\_%'; delete from mysql.db where user like 'mysqltest\_%'; flush privileges; diff --git a/mysql-test/r/grant_cache.result b/mysql-test/r/grant_cache.result index b890f2e454e..892f1d940a6 100644 --- a/mysql-test/r/grant_cache.result +++ b/mysql-test/r/grant_cache.result @@ -198,6 +198,7 @@ Qcache_hits 8 show status like "Qcache_not_cached"; Variable_name Value Qcache_not_cached 8 +set names binary; delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); delete from mysql.tables_priv where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index b4b78dc4b5b..39ec9ff4eb9 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -447,7 +447,7 @@ update t1, t2 set t1.b=1 where t1.a=t2.a; update t1, t2 set t1.b=(select t3.b from t3 where t1.a=t3.a) where t1.a=t2.a; revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; revoke all privileges on mysqltest.* from mysqltest_1@localhost; -delete from mysql.user where user='mysqltest_1'; +delete from mysql.user where user=_binary'mysqltest_1'; drop database mysqltest; create table t1 (a int, primary key (a)); create table t2 (a int, primary key (a)); diff --git a/mysql-test/r/rpl000001.result b/mysql-test/r/rpl000001.result index b60cad18c54..eef986d8f8c 100644 --- a/mysql-test/r/rpl000001.result +++ b/mysql-test/r/rpl000001.result @@ -76,17 +76,17 @@ create table t1 (n int); insert into t1 values(3456); insert into mysql.user (Host, User, Password) VALUES ("10.10.10.%", "blafasel2", password("blafasel2")); -select select_priv,user from mysql.user where user = 'blafasel2'; +select select_priv,user from mysql.user where user = _binary'blafasel2'; select_priv user N blafasel2 -update mysql.user set Select_priv = "Y" where User="blafasel2"; -select select_priv,user from mysql.user where user = 'blafasel2'; +update mysql.user set Select_priv = "Y" where User= _binary"blafasel2"; +select select_priv,user from mysql.user where user = _binary'blafasel2'; select_priv user Y blafasel2 select n from t1; n 3456 -select select_priv,user from mysql.user where user = 'blafasel2'; +select select_priv,user from mysql.user where user = _binary'blafasel2'; select_priv user Y blafasel2 drop table t1; diff --git a/mysql-test/r/rpl_do_grant.result b/mysql-test/r/rpl_do_grant.result index 983cdf46620..ff3e059503c 100644 --- a/mysql-test/r/rpl_do_grant.result +++ b/mysql-test/r/rpl_do_grant.result @@ -4,11 +4,11 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; -delete from mysql.user where user='rpl_do_grant'; -delete from mysql.db where user='rpl_do_grant'; +delete from mysql.user where user=_binary'rpl_do_grant'; +delete from mysql.db where user=_binary'rpl_do_grant'; flush privileges; -delete from mysql.user where user='rpl_ignore_grant'; -delete from mysql.db where user='rpl_ignore_grant'; +delete from mysql.user where user=_binary'rpl_ignore_grant'; +delete from mysql.db where user=_binary'rpl_ignore_grant'; flush privileges; grant select on *.* to rpl_do_grant@localhost; grant drop on test.* to rpl_do_grant@localhost; @@ -17,10 +17,10 @@ Grants for rpl_do_grant@localhost GRANT SELECT ON *.* TO 'rpl_do_grant'@'localhost' GRANT DROP ON `test`.* TO 'rpl_do_grant'@'localhost' set password for rpl_do_grant@localhost=password("does it work?"); -select password<>'' from mysql.user where user='rpl_do_grant'; -password<>'' +select password<>_binary'' from mysql.user where user=_binary'rpl_do_grant'; +password<>_binary'' 1 -delete from mysql.user where user='rpl_do_grant'; -delete from mysql.db where user='rpl_do_grant'; +delete from mysql.user where user=_binary'rpl_do_grant'; +delete from mysql.db where user=_binary'rpl_do_grant'; flush privileges; flush privileges; diff --git a/mysql-test/r/rpl_ignore_grant.result b/mysql-test/r/rpl_ignore_grant.result index 5e970e71d0b..5169cc8e888 100644 --- a/mysql-test/r/rpl_ignore_grant.result +++ b/mysql-test/r/rpl_ignore_grant.result @@ -4,11 +4,11 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; -delete from mysql.user where user='rpl_ignore_grant'; -delete from mysql.db where user='rpl_ignore_grant'; +delete from mysql.user where user=_binary'rpl_ignore_grant'; +delete from mysql.db where user=_binary'rpl_ignore_grant'; flush privileges; -delete from mysql.user where user='rpl_ignore_grant'; -delete from mysql.db where user='rpl_ignore_grant'; +delete from mysql.user where user=_binary'rpl_ignore_grant'; +delete from mysql.db where user=_binary'rpl_ignore_grant'; flush privileges; grant select on *.* to rpl_ignore_grant@localhost; grant drop on test.* to rpl_ignore_grant@localhost; @@ -18,20 +18,20 @@ GRANT SELECT ON *.* TO 'rpl_ignore_grant'@'localhost' GRANT DROP ON `test`.* TO 'rpl_ignore_grant'@'localhost' show grants for rpl_ignore_grant@localhost; ERROR 42000: There is no such grant defined for user 'rpl_ignore_grant' on host 'localhost' -select count(*) from mysql.user where user='rpl_ignore_grant'; +select count(*) from mysql.user where user=_binary'rpl_ignore_grant'; count(*) 0 -select count(*) from mysql.db where user='rpl_ignore_grant'; +select count(*) from mysql.db where user=_binary'rpl_ignore_grant'; count(*) 0 grant select on *.* to rpl_ignore_grant@localhost; set password for rpl_ignore_grant@localhost=password("does it work?"); -select password<>'' from mysql.user where user='rpl_ignore_grant'; -password<>'' +select password<>_binary'' from mysql.user where user=_binary'rpl_ignore_grant'; +password<>_binary'' 0 -delete from mysql.user where user='rpl_ignore_grant'; -delete from mysql.db where user='rpl_ignore_grant'; +delete from mysql.user where user=_binary'rpl_ignore_grant'; +delete from mysql.db where user=_binary'rpl_ignore_grant'; flush privileges; -delete from mysql.user where user='rpl_ignore_grant'; -delete from mysql.db where user='rpl_ignore_grant'; +delete from mysql.user where user=_binary'rpl_ignore_grant'; +delete from mysql.db where user=_binary'rpl_ignore_grant'; flush privileges; diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index 8aa071b3ca1..3bea4c4509d 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -395,6 +395,7 @@ show create database test_$1; ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'test_$1' drop table test_$1.t1; drop database test_$1; +set names binary; delete from mysql.user where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3'; delete from mysql.db diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 122dcaa6c49..5fed85d7f50 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -123,7 +123,7 @@ connection user1; alter table t1 rename t2; connection root; revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; -delete from mysql.user where user='mysqltest_1'; +delete from mysql.user where user=_binary'mysqltest_1'; drop database mysqltest; # diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test index 7585ff0f608..32c1479ae04 100644 --- a/mysql-test/t/connect.test +++ b/mysql-test/t/connect.test @@ -42,7 +42,7 @@ show tables; # check if old password version also works -update mysql.user set password=old_password("gambling2") where user="test"; +update mysql.user set password=old_password("gambling2") where user=_binary"test"; flush privileges; #connect (con1,localhost,test,gambling2,""); @@ -68,5 +68,5 @@ show tables; # remove user 'test' so that other tests which may use 'test' # do not depend on this test. -delete from mysql.user where user="test"; +delete from mysql.user where user=_binary"test"; flush privileges; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 6bd2fa0c703..c112a0e0c1d 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -5,6 +5,8 @@ drop table if exists t1; --enable_warnings +SET NAMES binary; + # # Test that SSL options works properly # diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test index 1fc1ed78385..3a9afa7453b 100644 --- a/mysql-test/t/grant2.test +++ b/mysql-test/t/grant2.test @@ -1,3 +1,5 @@ +SET NAMES binary; + # # GRANT tests that require several connections # (usually it's GRANT, reconnect as another user, try something) diff --git a/mysql-test/t/grant_cache.test b/mysql-test/t/grant_cache.test index 7806253124e..a82cd732802 100644 --- a/mysql-test/t/grant_cache.test +++ b/mysql-test/t/grant_cache.test @@ -126,6 +126,15 @@ show status like "Qcache_not_cached"; # Cleanup connection root; +# +# A temporary 4.1 workaround to make this test pass if +# mysql was compiled with other than latin1 --with-charset=XXX. +# Without "set names binary" the below queries fail with +# "Illegal mix of collations" error. +# In 5.0 we will change grant tables to use NCHAR(N) instead +# of "CHAR(N) BINARY", and use cast-to-nchar: N'mysqltest_1'. +# +set names binary; delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); delete from mysql.tables_priv where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 492856f9280..c2814606aa2 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -405,7 +405,7 @@ update t1, t2 set t1.b=(select t3.b from t3 where t1.a=t3.a) where t1.a=t2.a; connection root; revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; revoke all privileges on mysqltest.* from mysqltest_1@localhost; -delete from mysql.user where user='mysqltest_1'; +delete from mysql.user where user=_binary'mysqltest_1'; drop database mysqltest; # diff --git a/mysql-test/t/rpl000001.test b/mysql-test/t/rpl000001.test index 445bd579279..2e0ba2fff25 100644 --- a/mysql-test/t/rpl000001.test +++ b/mysql-test/t/rpl000001.test @@ -110,14 +110,14 @@ create table t1 (n int); insert into t1 values(3456); insert into mysql.user (Host, User, Password) VALUES ("10.10.10.%", "blafasel2", password("blafasel2")); -select select_priv,user from mysql.user where user = 'blafasel2'; -update mysql.user set Select_priv = "Y" where User="blafasel2"; -select select_priv,user from mysql.user where user = 'blafasel2'; +select select_priv,user from mysql.user where user = _binary'blafasel2'; +update mysql.user set Select_priv = "Y" where User= _binary"blafasel2"; +select select_priv,user from mysql.user where user = _binary'blafasel2'; save_master_pos; connection slave; sync_with_master; select n from t1; -select select_priv,user from mysql.user where user = 'blafasel2'; +select select_priv,user from mysql.user where user = _binary'blafasel2'; connection master1; drop table t1; save_master_pos; diff --git a/mysql-test/t/rpl_do_grant.test b/mysql-test/t/rpl_do_grant.test index 89ff1afb5c9..27a22874497 100644 --- a/mysql-test/t/rpl_do_grant.test +++ b/mysql-test/t/rpl_do_grant.test @@ -4,16 +4,16 @@ source include/master-slave.inc; # do not be influenced by other tests. connection master; -delete from mysql.user where user='rpl_do_grant'; -delete from mysql.db where user='rpl_do_grant'; +delete from mysql.user where user=_binary'rpl_do_grant'; +delete from mysql.db where user=_binary'rpl_do_grant'; flush privileges; save_master_pos; connection slave; sync_with_master; # if these DELETE did nothing on the master, we need to do them manually on the # slave. -delete from mysql.user where user='rpl_ignore_grant'; -delete from mysql.db where user='rpl_ignore_grant'; +delete from mysql.user where user=_binary'rpl_ignore_grant'; +delete from mysql.db where user=_binary'rpl_ignore_grant'; flush privileges; # test replication of GRANT @@ -31,12 +31,12 @@ set password for rpl_do_grant@localhost=password("does it work?"); save_master_pos; connection slave; sync_with_master; -select password<>'' from mysql.user where user='rpl_do_grant'; +select password<>_binary'' from mysql.user where user=_binary'rpl_do_grant'; # clear what we have done, to not influence other tests. connection master; -delete from mysql.user where user='rpl_do_grant'; -delete from mysql.db where user='rpl_do_grant'; +delete from mysql.user where user=_binary'rpl_do_grant'; +delete from mysql.db where user=_binary'rpl_do_grant'; flush privileges; save_master_pos; connection slave; diff --git a/mysql-test/t/rpl_ignore_grant.test b/mysql-test/t/rpl_ignore_grant.test index 2fd7f186b3e..9b012d08df3 100644 --- a/mysql-test/t/rpl_ignore_grant.test +++ b/mysql-test/t/rpl_ignore_grant.test @@ -6,16 +6,16 @@ source include/master-slave.inc; # do not be influenced by other tests. connection master; -delete from mysql.user where user='rpl_ignore_grant'; -delete from mysql.db where user='rpl_ignore_grant'; +delete from mysql.user where user=_binary'rpl_ignore_grant'; +delete from mysql.db where user=_binary'rpl_ignore_grant'; flush privileges; save_master_pos; connection slave; sync_with_master; # as these DELETE were not replicated, we need to do them manually on the # slave. -delete from mysql.user where user='rpl_ignore_grant'; -delete from mysql.db where user='rpl_ignore_grant'; +delete from mysql.user where user=_binary'rpl_ignore_grant'; +delete from mysql.db where user=_binary'rpl_ignore_grant'; flush privileges; # test non-replication of GRANT @@ -29,8 +29,8 @@ sync_with_master; --error 1141 #("no such grant for user") show grants for rpl_ignore_grant@localhost; # check it another way -select count(*) from mysql.user where user='rpl_ignore_grant'; -select count(*) from mysql.db where user='rpl_ignore_grant'; +select count(*) from mysql.user where user=_binary'rpl_ignore_grant'; +select count(*) from mysql.db where user=_binary'rpl_ignore_grant'; # test non-replication of SET PASSWORD # first force creation of the user on slave (because as the user does not exist @@ -42,16 +42,16 @@ set password for rpl_ignore_grant@localhost=password("does it work?"); save_master_pos; connection slave; sync_with_master; -select password<>'' from mysql.user where user='rpl_ignore_grant'; +select password<>_binary'' from mysql.user where user=_binary'rpl_ignore_grant'; # clear what we have done, to not influence other tests. connection master; -delete from mysql.user where user='rpl_ignore_grant'; -delete from mysql.db where user='rpl_ignore_grant'; +delete from mysql.user where user=_binary'rpl_ignore_grant'; +delete from mysql.db where user=_binary'rpl_ignore_grant'; flush privileges; save_master_pos; connection slave; sync_with_master; -delete from mysql.user where user='rpl_ignore_grant'; -delete from mysql.db where user='rpl_ignore_grant'; +delete from mysql.user where user=_binary'rpl_ignore_grant'; +delete from mysql.db where user=_binary'rpl_ignore_grant'; flush privileges; diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index 58694356943..ac0c9a43010 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -299,6 +299,7 @@ drop table test_$1.t1; drop database test_$1; connection default; +set names binary; delete from mysql.user where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3'; delete from mysql.db From 97920edb9d081f3e62ff5bc78d56061dea3eeefd Mon Sep 17 00:00:00 2001 From: "jani@a80-186-24-72.elisa-laajakaista.fi" <> Date: Thu, 8 Jul 2004 17:12:42 +0300 Subject: [PATCH 21/49] Fixed Bug#4451. According to C/C++ standards, enums should not be used out of their range. --- include/my_getopt.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/my_getopt.h b/include/my_getopt.h index 3b4551b445e..11ecc66fac3 100644 --- a/include/my_getopt.h +++ b/include/my_getopt.h @@ -16,8 +16,17 @@ C_MODE_START -enum get_opt_var_type { GET_NO_ARG, GET_BOOL, GET_INT, GET_UINT, GET_LONG, - GET_ULONG, GET_LL, GET_ULL, GET_STR, GET_STR_ALLOC }; +#define GET_NO_ARG 1 +#define GET_BOOL 2 +#define GET_INT 3 +#define GET_UINT 4 +#define GET_LONG 5 +#define GET_ULONG 6 +#define GET_LL 7 +#define GET_ULL 8 +#define GET_STR 9 +#define GET_STR_ALLOC 10 + enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG }; struct my_option @@ -28,7 +37,7 @@ struct my_option gptr *value; /* The variable value */ gptr *u_max_value; /* The user def. max variable value */ const char **str_values; /* Pointer to possible values */ - enum get_opt_var_type var_type; + ulong var_type; enum get_opt_arg_type arg_type; longlong def_value; /* Default value */ longlong min_value; /* Min allowed value */ From 051a5461cc253372e64727a55341bcc512b9e3eb Mon Sep 17 00:00:00 2001 From: "vva@eagle.mysql.r18.ru" <> Date: Thu, 8 Jul 2004 21:25:17 +0500 Subject: [PATCH 22/49] fixed Bug #4378 "create database IF NOT EXISTS thing" returns an error --- sql/sql_db.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 9db2198268a..e3f892891f1 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -171,6 +171,7 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, int error = 0; MY_STAT stat_info; uint create_options = create_info ? create_info->options : 0; + uint path_len; DBUG_ENTER("mysql_create_db"); VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); @@ -184,7 +185,8 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, /* Check directory */ strxmov(path, mysql_data_home, "/", db, NullS); - unpack_dirname(path,path); // Convert if not unix + path_len= unpack_dirname(path,path); // Convert if not unix + path[path_len-1]= 0; // Remove last '/' from path if (my_stat(path,&stat_info,MYF(0))) { @@ -203,7 +205,6 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, my_error(EE_STAT, MYF(0),path,my_errno); goto exit; } - strend(path)[-1]=0; // Remove last '/' from path if (my_mkdir(path,0777,MYF(0)) < 0) { my_error(ER_CANT_CREATE_DB,MYF(0),db,my_errno); From ec5bb4695cbbcbdf274ce7ea215f557c8716ee25 Mon Sep 17 00:00:00 2001 From: "mwagner@here.mwagner.org" <> Date: Thu, 8 Jul 2004 13:51:18 -0500 Subject: [PATCH 23/49] Do-compile: Added support for MD5 verification of file transfers --- Build-tools/Do-compile | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile index d79fd1f0b65..ecf5316c867 100755 --- a/Build-tools/Do-compile +++ b/Build-tools/Do-compile @@ -202,6 +202,17 @@ if ($opt_stage == 0) safe_cd($host); if ($opt_stage == 0 && ! $opt_use_old_distribution) { + $md5_result= safe_system("my_md5sum -c ${opt_distribution}.md5"); + + if ($md5_result != 0) + { + abort("MD5 failed for $opt_distribution!"); + } + else + { + info("SUCCESS: MD5 checks for $opt_distribution"); + } + safe_system("gunzip < $opt_distribution | $tar xf -"); # Fix file times; This is needed because the time for files may be @@ -320,6 +331,9 @@ if ($opt_stage <= 3) $tar_file=<$pwd/$host/mysql*.t*gz>; abort ("Could not find tarball!") unless ($tar_file); +# Generate the MD5 for the binary distribution +safe_system("my_md5sum $tar_file > ${tar_file}.md5}"); + # # Unpack the binary distribution # @@ -633,7 +647,10 @@ sub safe_system my($com,$res)=@_; print LOG "$com\n"; print "$host: $com\n" if ($opt_debug); - system("$com >> $log 2>&1") && abort("error: Couldn't execute command, error: " . ($? / 256)); + my $result= system("$com >> $log 2>&1"); + abort("error: Couldn't execute command, error: " . ($? / 256)) unless $result == 0; + + return $result; } sub check_system From 63e5c254ac7d465745c9c2f5bce80985bb096c05 Mon Sep 17 00:00:00 2001 From: "mwagner@here.mwagner.org" <> Date: Thu, 8 Jul 2004 16:16:37 -0500 Subject: [PATCH 24/49] Do-compile: Call my_md5sum with path --- Build-tools/Do-compile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile index ecf5316c867..40a5cf38121 100755 --- a/Build-tools/Do-compile +++ b/Build-tools/Do-compile @@ -202,7 +202,7 @@ if ($opt_stage == 0) safe_cd($host); if ($opt_stage == 0 && ! $opt_use_old_distribution) { - $md5_result= safe_system("my_md5sum -c ${opt_distribution}.md5"); + $md5_result= safe_system("./my_md5sum -c ${opt_distribution}.md5"); if ($md5_result != 0) { @@ -332,7 +332,7 @@ $tar_file=<$pwd/$host/mysql*.t*gz>; abort ("Could not find tarball!") unless ($tar_file); # Generate the MD5 for the binary distribution -safe_system("my_md5sum $tar_file > ${tar_file}.md5}"); +safe_system("./my_md5sum $tar_file > ${tar_file}.md5}"); # # Unpack the binary distribution From 664329b56545c6968dcdb75937d06ec4e93b3513 Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Fri, 9 Jul 2004 01:35:35 +0400 Subject: [PATCH 25/49] my_global.h: Define cxa_pure_virtual to print error message and DBUG_ASSERT: calls to pure virtual methods should not go unnoticed. --- include/my_global.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/my_global.h b/include/my_global.h index f5c14ea3e10..3c35ade8383 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -213,7 +213,11 @@ C_MODE_END /* Fix problem when linking c++ programs with gcc 3.x */ #ifdef DEFINE_CXA_PURE_VIRTUAL -#define FIX_GCC_LINKING_PROBLEM extern "C" { int __cxa_pure_virtual() {return 0;} } +#define FIX_GCC_LINKING_PROBLEM \ +extern "C" { int __cxa_pure_virtual() {\ + DBUG_ASSERT("Pure virtual method called." == "Aborted");\ + return 0;\ +} } #else #define FIX_GCC_LINKING_PROBLEM #endif From 4b13824ce55a2c4a4e30fe6277e2db903736e182 Mon Sep 17 00:00:00 2001 From: "joreland@mysql.com" <> Date: Fri, 9 Jul 2004 00:46:49 +0200 Subject: [PATCH 26/49] Bug fix for testOIBasic --- ndb/src/ndbapi/Ndbif.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ndb/src/ndbapi/Ndbif.cpp b/ndb/src/ndbapi/Ndbif.cpp index f561a641961..1efcbe99258 100644 --- a/ndb/src/ndbapi/Ndbif.cpp +++ b/ndb/src/ndbapi/Ndbif.cpp @@ -564,17 +564,17 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]) if (tFirstDataPtr == 0) goto InvalidSignal; if (tWaitState != WAIT_TC_SEIZE) { - return; + goto InvalidSignal; }//if tCon = void2con(tFirstDataPtr); if (tCon->checkMagicNumber() != 0) { - return; + goto InvalidSignal; }//if tReturnCode = tCon->receiveTCSEIZECONF(aSignal); if (tReturnCode != -1) { theWaiter.m_state = NO_WAIT; } else { - return; + goto InvalidSignal; }//if break; } @@ -702,7 +702,7 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]) tDataPtr + ScanTabConf::SignalLength, tLen - ScanTabConf::SignalLength); } - if (tReturnCode != -1) + if (tReturnCode != -1 && tWaitState == WAIT_SCAN) theWaiter.m_state = NO_WAIT; break; } else { From 93f3d4c02045c3af4b5d651ad27c4bdbda66db35 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 9 Jul 2004 02:03:19 +0300 Subject: [PATCH 27/49] Updated result sets (from 4.1) --- mysql-test/r/lowercase_table2.result | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/lowercase_table2.result b/mysql-test/r/lowercase_table2.result index d2283927789..929cedb2ee3 100644 --- a/mysql-test/r/lowercase_table2.result +++ b/mysql-test/r/lowercase_table2.result @@ -32,7 +32,7 @@ T1 ALTER TABLE T1 add b int; SHOW TABLES LIKE "T1"; Tables_in_test (T1) -t1 +T1 ALTER TABLE T1 RENAME T2; SHOW TABLES LIKE "T2"; Tables_in_test (T2) @@ -41,7 +41,7 @@ LOCK TABLE T2 WRITE; ALTER TABLE T2 drop b; SHOW TABLES LIKE "T2"; Tables_in_test (T2) -t2 +T2 UNLOCK TABLES; RENAME TABLE T2 TO T1; SHOW TABLES LIKE "T1"; From c1032fe9eb912a29653c917f63c71c97a5111daa Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 9 Jul 2004 10:55:16 +0300 Subject: [PATCH 28/49] Cleanup of db option cacheing Some bug fixes to last pushed code --- mysql-test/mysql-test-run.sh | 2 +- mysql-test/r/bdb.result | 2 +- mysql-test/t/ps_1general.test | 1 - sql/ha_berkeley.cc | 18 ++++- sql/item_strfunc.cc | 40 +++++----- sql/mysql_priv.h | 5 +- sql/mysqld.cc | 18 ++--- sql/sql_db.cc | 134 +++++++++++++++++++--------------- sql/sql_parse.cc | 3 +- sql/sql_table.cc | 2 +- sql/table.cc | 2 +- 11 files changed, 131 insertions(+), 96 deletions(-) diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 55f9d3b00a9..811d56ba6fe 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -370,7 +370,7 @@ while test $# -gt 0; do $ECHO "You need to have the 'valgrind' program in your PATH to run mysql-test-run with option --valgrind. Valgrind's home page is http://developer.kde.org/~sewardj ." exit 1 fi - VALGRIND="$VALGRIND --alignment=8 --leak-check=yes --num-callers=16" + VALGRIND="$VALGRIND --tool=memcheck --alignment=8 --leak-check=yes --num-callers=16" EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-safemalloc --skip-bdb" EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc --skip-bdb" SLEEP_TIME_AFTER_RESTART=10 diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index 4080ba227a0..25118702d09 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -785,7 +785,7 @@ Table Op Msg_type Msg_text test.t1 optimize status OK show keys from t1; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 a NULL 2 NULL NULL BTREE +t1 0 PRIMARY 1 a A 2 NULL NULL BTREE drop table t1; create table t1 (i int, j int )ENGINE=BDB; insert into t1 values (1,2); diff --git a/mysql-test/t/ps_1general.test b/mysql-test/t/ps_1general.test index 5f0ff528b2b..2c86c30f820 100644 --- a/mysql-test/t/ps_1general.test +++ b/mysql-test/t/ps_1general.test @@ -369,7 +369,6 @@ revoke all privileges on test.t1 from drop_user@localhost ; --error 1295 prepare stmt3 from ' drop user drop_user@localhost '; drop user drop_user@localhost; ---error 1141 #### table related commands ## describe diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index bb07bd9dc4b..39ef6ca855a 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -344,12 +344,24 @@ ulong ha_berkeley::index_flags(uint idx, uint part, bool all_parts) const { ulong flags= (HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | HA_KEYREAD_ONLY | HA_READ_RANGE); - for (uint idx= all_parts ? 0 : part ; idx <= part ; idx++) + for (uint i= all_parts ? 0 : part ; i <= part ; i++) { - if (table->key_info[idx].key_part[part].field->type() == FIELD_TYPE_BLOB) + if (table->key_info[idx].key_part[i].field->type() == FIELD_TYPE_BLOB) { /* We can't use BLOBS to shortcut sorts */ - flags&= ~ (HA_READ_ORDER | HA_KEYREAD_ONLY | HA_READ_RANGE); + flags&= ~(HA_READ_ORDER | HA_KEYREAD_ONLY | HA_READ_RANGE); + break; + } + switch (table->key_info[idx].key_part[i].field->key_type()) { + case HA_KEYTYPE_TEXT: + case HA_KEYTYPE_VARTEXT: + /* + As BDB stores only one copy of equal strings, we can't use key read + on these + */ + flags&= ~HA_KEYREAD_ONLY; + break; + default: // Keep compiler happy break; } } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index b5b08a04f88..a8805be7854 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2294,43 +2294,49 @@ inline int hexchar_to_int(char c) return -1; } -String *Item_func_unhex::val_str(String *str) -{ - DBUG_ASSERT(fixed == 1); + /* Convert given hex string to a binary string */ - String *res= args[0]->val_str(str); - if (!res || tmp_value.alloc((1+res->length())/2)) +String *Item_func_unhex::val_str(String *str) +{ + const char *from, *end; + char *to; + String *res; + uint length; + DBUG_ASSERT(fixed == 1); + + res= args[0]->val_str(str); + if (!res || tmp_value.alloc(length= (1+res->length())/2)) { null_value=1; return 0; } - const char *from=res->ptr(), *end; - char *to; - int r; - - null_value=0; - tmp_value.length((1+res->length())/2); + from= res->ptr(); + null_value= 0; + tmp_value.length(length); to= (char*) tmp_value.ptr(); if (res->length() % 2) { - *to++= r= hexchar_to_int(*from++); - if ((null_value= (r == -1))) + int hex_char; + *to++= hex_char= hexchar_to_int(*from++); + if ((null_value= (hex_char == -1))) return 0; } for (end=res->ptr()+res->length(); from < end ; from+=2, to++) { - *to= (r= hexchar_to_int(from[0])) << 4; - if ((null_value= (r == -1))) + int hex_char; + *to= (hex_char= hexchar_to_int(from[0])) << 4; + if ((null_value= (hex_char == -1))) return 0; - *to|= r= hexchar_to_int(from[1]); - if ((null_value= (r == -1))) + *to|= hex_char= hexchar_to_int(from[1]); + if ((null_value= (hex_char == -1))) return 0; } return &tmp_value; } + void Item_func_binary::print(String *str) { str->append("cast(", 5); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 9553af13431..34e1e7c9113 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -801,6 +801,8 @@ bool is_keyword(const char *name, uint len); #define MY_DB_OPT_FILE "db.opt" bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create); +bool my_dbopt_init(void); +void my_dbopt_cleanup(void); void my_dbopt_free(void); /* @@ -895,8 +897,7 @@ extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone, LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_system_variables, LOCK_user_conn; -extern rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave, - LOCK_dboptions; +extern rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager; extern pthread_attr_t connection_attrib; extern I_List threads; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 75f1aaeb775..1ed535753b1 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -382,8 +382,7 @@ pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count, LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received, LOCK_global_system_variables, LOCK_user_conn, LOCK_slave_list, LOCK_active_mi; -rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave, - LOCK_dboptions; +rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; pthread_cond_t COND_refresh,COND_thread_count, COND_slave_stopped, COND_slave_start; pthread_cond_t COND_thread_cache,COND_flush_thread_cache; @@ -886,6 +885,7 @@ extern "C" void unireg_abort(int exit_code) } #endif + void clean_up(bool print_message) { DBUG_PRINT("exit",("clean_up")); @@ -988,7 +988,6 @@ static void clean_up_mutexes() (void) pthread_mutex_destroy(&LOCK_mysql_create_db); (void) pthread_mutex_destroy(&LOCK_Acl); (void) rwlock_destroy(&LOCK_grant); - (void) rwlock_destroy(&LOCK_dboptions); (void) pthread_mutex_destroy(&LOCK_open); (void) pthread_mutex_destroy(&LOCK_thread_count); (void) pthread_mutex_destroy(&LOCK_mapped_file); @@ -2277,7 +2276,6 @@ static int init_common_variables(const char *conf_file_name, int argc, */ global_system_variables.time_zone= my_tz_SYSTEM; - /* Init mutexes for the global MYSQL_LOG objects. As safe_mutex depends on what MY_INIT() does, we can't init the mutexes of @@ -2384,6 +2382,9 @@ static int init_common_variables(const char *conf_file_name, int argc, if (use_temp_pool && bitmap_init(&temp_pool,0,1024,1)) return 1; + if (my_dbopt_init()) + return 1; + return 0; } @@ -2411,7 +2412,6 @@ static int init_thread_environment() (void) my_rwlock_init(&LOCK_sys_init_connect, NULL); (void) my_rwlock_init(&LOCK_sys_init_slave, NULL); (void) my_rwlock_init(&LOCK_grant, NULL); - (void) my_rwlock_init(&LOCK_dboptions, NULL); (void) pthread_cond_init(&COND_thread_count,NULL); (void) pthread_cond_init(&COND_refresh,NULL); (void) pthread_cond_init(&COND_thread_cache,NULL); @@ -4677,26 +4677,26 @@ replicating a LOAD DATA INFILE command.", "The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.", (gptr*) &dflt_key_cache_var.param_buff_size, (gptr*) 0, - 0, (enum get_opt_var_type) (GET_ULL | GET_ASK_ADDR), + 0, (GET_ULL | GET_ASK_ADDR), REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, (long) ~0, MALLOC_OVERHEAD, IO_SIZE, 0}, {"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE, "The default size of key cache blocks", (gptr*) &dflt_key_cache_var.param_block_size, (gptr*) 0, - 0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, + 0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, KEY_CACHE_BLOCK_SIZE , 512, 1024*16, MALLOC_OVERHEAD, 512, 0}, {"key_cache_division_limit", OPT_KEY_CACHE_DIVISION_LIMIT, "The minimum percentage of warm blocks in key cache", (gptr*) &dflt_key_cache_var.param_division_limit, (gptr*) 0, - 0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100, + 0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100, 1, 100, 0, 1, 0}, {"key_cache_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD, "This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in key cache", (gptr*) &dflt_key_cache_var.param_age_threshold, (gptr*) 0, - 0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, + 0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, 300, 100, ~0L, 0, 100, 0}, {"long_query_time", OPT_LONG_QUERY_TIME, "Log all queries that have taken more than long_query_time seconds to execute to file.", diff --git a/sql/sql_db.cc b/sql/sql_db.cc index aab17873dc6..68aa0787a9b 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -42,6 +42,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, /* Database options hash */ static HASH dboptions; static my_bool dboptions_init= 0; +static rw_lock_t LOCK_dboptions; /* Structure for database options */ typedef struct my_dbopt_st @@ -51,6 +52,7 @@ typedef struct my_dbopt_st CHARSET_INFO *charset; /* Database default character set */ } my_dbopt_t; + /* Function we use in the creation of our hash to get key. */ @@ -73,39 +75,58 @@ static void free_dbopt(void *dbopt) /* - Initialize database option hash. + Initialize database option hash + + SYNOPSIS + my_dbopt_init() + + NOTES + Must be called before any other database function is called. + + RETURN + 0 ok + 1 Fatal error */ -static my_bool my_dbopt_init(void) +bool my_dbopt_init(void) { - my_bool rc; - rw_wrlock(&LOCK_dboptions); + bool error= 0; + (void) my_rwlock_init(&LOCK_dboptions, NULL); if (!dboptions_init) { dboptions_init= 1; - rc= hash_init(&dboptions, lower_case_table_names ? - &my_charset_bin : system_charset_info, - 32, 0, 0, (hash_get_key) dboptions_get_key, - free_dbopt,0); + error= hash_init(&dboptions, lower_case_table_names ? + &my_charset_bin : system_charset_info, + 32, 0, 0, (hash_get_key) dboptions_get_key, + free_dbopt,0); } - else - rc= 0; - rw_unlock(&LOCK_dboptions); - return rc; + return error; } /* Free database option hash. */ + void my_dbopt_free(void) { - rw_wrlock(&LOCK_dboptions); if (dboptions_init) { - hash_free(&dboptions); dboptions_init= 0; + hash_free(&dboptions); + (void) rwlock_destroy(&LOCK_dboptions); } +} + + +void my_dbopt_cleanup(void) +{ + rw_wrlock(&LOCK_dboptions); + hash_free(&dboptions); + hash_init(&dboptions, lower_case_table_names ? + &my_charset_bin : system_charset_info, + 32, 0, 0, (hash_get_key) dboptions_get_key, + free_dbopt,0); rw_unlock(&LOCK_dboptions); } @@ -126,10 +147,7 @@ static my_bool get_dbopt(const char *dbname, HA_CREATE_INFO *create) { my_dbopt_t *opt; uint length; - my_bool rc; - - if (my_dbopt_init()) - return 1; + my_bool error= 1; length= (uint) strlen(dbname); @@ -137,13 +155,10 @@ static my_bool get_dbopt(const char *dbname, HA_CREATE_INFO *create) if ((opt= (my_dbopt_t*) hash_search(&dboptions, (byte*) dbname, length))) { create->default_table_charset= opt->charset; - rc= 0; + error= 0; } - else - rc= 1; rw_unlock(&LOCK_dboptions); - - return rc; + return error; } @@ -163,43 +178,41 @@ static my_bool put_dbopt(const char *dbname, HA_CREATE_INFO *create) { my_dbopt_t *opt; uint length; - my_bool rc; - - if (my_dbopt_init()) - return 1; - + my_bool error= 0; + DBUG_ENTER("put_dbopt"); + length= (uint) strlen(dbname); rw_wrlock(&LOCK_dboptions); - if ((opt= (my_dbopt_t*) hash_search(&dboptions, (byte*) dbname, length))) + if (!(opt= (my_dbopt_t*) hash_search(&dboptions, (byte*) dbname, length))) { - /* Options are already in hash, update them */ - opt->charset= create->default_table_charset; - rc= 0; - } - else - { /* Options are not in the hash, insert them */ char *tmp_name; if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), - &opt, sizeof(*opt), &tmp_name, length+1, NullS)) + &opt, (uint) sizeof(*opt), &tmp_name, length+1, + NullS)) { - rc= 1; - goto ret; + error= 1; + goto end; } opt->name= tmp_name; - opt->name_length= length; - opt->charset= create->default_table_charset; strmov(opt->name, dbname); + opt->name_length= length; - if ((rc= my_hash_insert(&dboptions, (byte*) opt))) + if ((error= my_hash_insert(&dboptions, (byte*) opt))) + { my_free((gptr) opt, MYF(0)); + goto end; + } } -ret: + /* Update / write options in hash */ + opt->charset= create->default_table_charset; + +end: rw_unlock(&LOCK_dboptions); - return rc; + DBUG_RETURN(error); } @@ -243,10 +256,11 @@ static bool write_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) if ((file=my_create(path, CREATE_MODE,O_RDWR | O_TRUNC,MYF(MY_WME))) >= 0) { ulong length; - length= my_sprintf(buf,(buf, - "default-character-set=%s\ndefault-collation=%s\n", - create->default_table_charset->csname, - create->default_table_charset->name)); + length= (ulong) (strxnmov(buf, sizeof(buf), "default-character-set=", + create->default_table_charset->csname, + "\ndefault-collation=", + create->default_table_charset->name, + "\n", NullS) - buf); /* Error is written by my_write */ if (!my_write(file,(byte*) buf, length, MYF(MY_NABP+MY_WME))) @@ -362,10 +376,11 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, bool silent) { char path[FN_REFLEN+16]; - long result=1; - int error = 0; + long result= 1; + int error= 0; + uint length; MY_STAT stat_info; - uint create_options = create_info ? create_info->options : 0; + uint create_options= create_info ? create_info->options : 0; DBUG_ENTER("mysql_create_db"); VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); @@ -386,10 +401,10 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, if (!(create_options & HA_LEX_CREATE_IF_NOT_EXISTS)) { my_error(ER_DB_CREATE_EXISTS,MYF(0),db); - error = -1; + error= -1; goto exit; } - result = 0; + result= 0; } else { @@ -402,19 +417,20 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, if (my_mkdir(path,0777,MYF(0)) < 0) { my_error(ER_CANT_CREATE_DB,MYF(0),db,my_errno); - error = -1; + error= -1; goto exit; } } - unpack_dirname(path, path); - strcat(path,MY_DB_OPT_FILE); + length= unpack_dirname(path, path); + strmov(path+ length, MY_DB_OPT_FILE); if (write_db_opt(thd, path, create_info)) { /* Could not create options file. Restore things to beginning. */ + path[length]= 0; if (rmdir(path) >= 0) { error= -1; @@ -466,7 +482,7 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) { char path[FN_REFLEN+16]; long result=1; - int error = 0; + int error= 0; DBUG_ENTER("mysql_alter_db"); VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); @@ -476,7 +492,7 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) goto exit2; /* Check directory */ - (void)sprintf(path,"%s/%s/%s", mysql_data_home, db, MY_DB_OPT_FILE); + strxmov(path, mysql_data_home, "/", db, "/", MY_DB_OPT_FILE, NullS); fn_format(path, path, "", "", MYF(MY_UNPACK_FILENAME)); if ((error=write_db_opt(thd, path, create_info))) goto exit; @@ -530,7 +546,7 @@ exit2: int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) { long deleted=0; - int error = 0; + int error= 0; char path[FN_REFLEN+16], tmp_db[NAME_LEN+1]; MY_DIR *dirp; uint length; @@ -553,7 +569,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) path[length]= '\0'; // Remove file name /* See if the directory exists */ - if (!(dirp = my_dir(path,MYF(MY_DONT_SORT)))) + if (!(dirp= my_dir(path,MYF(MY_DONT_SORT)))) { if (!if_exists) { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 3ce1c334f96..61b57b2f350 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4562,6 +4562,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, register TABLE_LIST *ptr; char *alias_str; DBUG_ENTER("add_table_to_list"); + DBUG_PRINT("enter",("lock_option: %d", lock_type)); if (!table) DBUG_RETURN(0); // End of memory @@ -4805,7 +4806,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, if (lock_global_read_lock(thd)) return 1; } - my_dbopt_free(); + my_dbopt_cleanup(); result=close_cached_tables(thd,(options & REFRESH_FAST) ? 0 : 1, tables); } if (options & REFRESH_HOSTS) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c0be95c0453..8d82ca44951 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1168,7 +1168,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, HA_CREATE_INFO db_info; uint length; char path[FN_REFLEN]; - (void) sprintf(path,"%s/%s", mysql_data_home, db); + strxmov(path, mysql_data_home, "/", db, NullS); length= unpack_dirname(path,path); // Convert if not unix strmov(path+length, MY_DB_OPT_FILE); load_db_opt(thd, path, &db_info); diff --git a/sql/table.cc b/sql/table.cc index d3ed6e11756..7d1c733b116 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -569,7 +569,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, if (field->key_length() == key_part->length && !(field->flags & BLOB_FLAG)) { - if (outparam->file->index_flags(key, i, 1) & HA_KEYREAD_ONLY) + if (outparam->file->index_flags(key, i, 0) & HA_KEYREAD_ONLY) { outparam->read_only_keys.clear_bit(key); outparam->keys_for_keyread.set_bit(key); From bddd075d7336b8647ca4c6f1286bef452a397e3f Mon Sep 17 00:00:00 2001 From: "mskold@mysql.com" <> Date: Fri, 9 Jul 2004 13:18:56 +0200 Subject: [PATCH 29/49] Fixed bug #4106 and removed buggy pk update --- mysql-test/r/ndb_basic.result | 16 +++------------- mysql-test/t/ndb_basic.test | 11 +++-------- sql/ha_ndbcluster.cc | 32 ++++++-------------------------- 3 files changed, 12 insertions(+), 47 deletions(-) diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result index 56b2d2fb0f7..0e7b039a5f9 100644 --- a/mysql-test/r/ndb_basic.result +++ b/mysql-test/r/ndb_basic.result @@ -3,35 +3,25 @@ CREATE TABLE t1 ( pk1 INT NOT NULL PRIMARY KEY, attr1 INT NOT NULL ) ENGINE=ndbcluster; -INSERT INTO t1 VALUES (9410,9412),(9411,9413); +INSERT INTO t1 VALUES (9410,9412); SELECT pk1 FROM t1; pk1 9410 -9411 SELECT * FROM t1; pk1 attr1 9410 9412 -9411 9413 SELECT t1.* FROM t1; pk1 attr1 9410 9412 -9411 9413 UPDATE t1 SET attr1=1 WHERE pk1=9410; SELECT * FROM t1; pk1 attr1 9410 1 -9411 9413 UPDATE t1 SET pk1=2 WHERE attr1=1; +ERROR 42000: Table 't1' uses an extension that doesn't exist in this MySQL version SELECT * FROM t1; pk1 attr1 -2 1 -9411 9413 -UPDATE t1 SET pk1=2 WHERE attr1=9413; -ERROR 23000: Can't write; duplicate key in table 't1' -SELECT * FROM t1; -pk1 attr1 -2 1 -9411 9413 +9410 1 DELETE FROM t1; SELECT * FROM t1; pk1 attr1 diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index ed13b36bf16..271357ed561 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -17,7 +17,7 @@ CREATE TABLE t1 ( attr1 INT NOT NULL ) ENGINE=ndbcluster; -INSERT INTO t1 VALUES (9410,9412),(9411,9413); +INSERT INTO t1 VALUES (9410,9412); SELECT pk1 FROM t1; SELECT * FROM t1; @@ -27,16 +27,11 @@ SELECT t1.* FROM t1; UPDATE t1 SET attr1=1 WHERE pk1=9410; SELECT * FROM t1; -# Update pk +# Can't UPDATE PK! Test that correct error is returned +-- error 1112 UPDATE t1 SET pk1=2 WHERE attr1=1; SELECT * FROM t1; -# Try to set same pk -# 1022: Can't write; duplicate key in table 't1' --- error 1022 -UPDATE t1 SET pk1=2 WHERE attr1=9413; -SELECT * FROM t1; - # Delete the record DELETE FROM t1; SELECT * FROM t1; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index e88cbc0c4b3..5c5256cc622 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1174,30 +1174,8 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) /* Check for update of primary key and return error */ if ((table->primary_key != MAX_KEY) && (key_cmp(table->primary_key, old_data, new_data))) - { - DBUG_PRINT("info", ("primary key update, doing insert + delete")); - int insert_res = write_row(new_data); - if (!insert_res) - { - DBUG_PRINT("info", ("insert succeded")); - int delete_res = delete_row(old_data); - if (!delete_res) - { - DBUG_PRINT("info", ("insert + delete succeeded")); - DBUG_RETURN(0); - } - else - { - DBUG_PRINT("info", ("delete failed")); - DBUG_RETURN(delete_row(new_data)); - } - } - else - { - DBUG_PRINT("info", ("insert failed")); - DBUG_RETURN(insert_res); - } - } + DBUG_RETURN(HA_ERR_UNSUPPORTED); + if (cursor) { /* @@ -1650,8 +1628,10 @@ int ha_ndbcluster::rnd_init(bool scan) NdbResultSet *cursor= m_active_cursor; DBUG_ENTER("rnd_init"); DBUG_PRINT("enter", ("scan: %d", scan)); - // Check that cursor is not defined - if (cursor) + // Check if scan is to be restarted + if (cursor && scan) + cursor->restart(); + else DBUG_RETURN(1); index_init(table->primary_key); DBUG_RETURN(0); From 8064f06562089d07bae3d3868c522a917fea484a Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Fri, 9 Jul 2004 14:30:51 +0200 Subject: [PATCH 30/49] mysqlhotcopy: fix MYI copying with scp safer tempfile creation --- scripts/mysqlhotcopy.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh index 6388855eaa6..af4e6084c59 100644 --- a/scripts/mysqlhotcopy.sh +++ b/scripts/mysqlhotcopy.sh @@ -8,6 +8,7 @@ use File::Path; use DBI; use Sys::Hostname; use File::Copy; +use File::Temp; =head1 NAME @@ -626,7 +627,6 @@ sub copy_files { sub copy_index { my ($method, $files, $source, $target) = @_; - my $tmpfile="$opt_tmpdir/mysqlhotcopy$$"; print "Copying indices for ".@$files." files...\n" unless $opt{quiet}; foreach my $file (@$files) @@ -652,23 +652,23 @@ sub copy_index } close OUTPUT || die "Error on close of $to: $!\n"; } - elsif ($opt{method} eq 'scp') + elsif ($opt{method} =~ /^scp\b/) { - my $tmp=$tmpfile; - open(OUTPUT,">$tmp") || die "Can\'t create file $tmp: $!\n"; - if (syswrite(OUTPUT,$buff) != length($buff)) + my ($fh, $tmp)=tempfile('mysqlhotcopy-XXXXXX', DIR => $opt_tmpdir); + die "Can\'t create/open file in $opt_tmpdir\n"; + if (syswrite($fh,$buff) != length($buff)) { die "Error when writing data to $tmp: $!\n"; } - close OUTPUT || die "Error on close of $tmp: $!\n"; - safe_system("scp $tmp $to"); + close $fh || die "Error on close of $tmp: $!\n"; + safe_system("$opt{method} $tmp $to"); + unlink $tmp; } else { die "Can't use unsupported method '$opt{method}'\n"; } } - unlink "$tmpfile" if ($opt{method} eq 'scp'); } From 6782982254ebe3fa1c085a127bac3b1f36c87d41 Mon Sep 17 00:00:00 2001 From: "vva@eagle.mysql.r18.ru" <> Date: Fri, 9 Jul 2004 20:39:50 +0500 Subject: [PATCH 31/49] added an optimization in mysql_create_db (sql_db.cc) as after effect of fix for Bug #4378 '"create database IF NOT EXISTS thing" returns an error' (avoided an unpack_dirname and changed strcat into strmake) --- sql/sql_db.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_db.cc b/sql/sql_db.cc index e3f892891f1..ac8ba8611dc 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -213,8 +213,8 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, } } - unpack_dirname(path, path); - strcat(path,MY_DB_OPT_FILE); + path[path_len-1]= FN_LIBCHAR; + strmake(path+path_len, MY_DB_OPT_FILE, sizeof(path)-path_len-1); if (write_db_opt(thd, path, create_info)) { /* From d6f601c80f9b5528726c8db7cea5f630d5773dc2 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Sat, 10 Jul 2004 11:13:05 +0200 Subject: [PATCH 32/49] mysql_find_files() made extern (from static to sql_show.cc) --- sql/mysql_priv.h | 2 ++ sql/sql_show.cc | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 5c15ae9a714..2e893ead407 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -535,6 +535,8 @@ int mysqld_show_variables(THD *thd,const char *wild); int mysqld_show(THD *thd, const char *wild, show_var_st *variables, enum enum_var_type value_type, pthread_mutex_t *mutex); +int mysql_find_files(THD *thd,List *files, const char *db, + const char *path, const char *wild, bool dir); /* sql_handler.cc */ int mysql_ha_open(THD *thd, TABLE_LIST *tables); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 26163ed9bef..6784cd64465 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -35,9 +35,6 @@ static TYPELIB grant_types = { sizeof(grant_names)/sizeof(char **), "grant_types", grant_names}; -static int mysql_find_files(THD *thd,List *files, const char *db, - const char *path, const char *wild, bool dir); - static int store_create_info(THD *thd, TABLE *table, String *packet); @@ -170,7 +167,7 @@ int mysqld_show_tables(THD *thd,const char *db,const char *wild) } -static int +int mysql_find_files(THD *thd,List *files, const char *db,const char *path, const char *wild, bool dir) { From f214e2a02a2331f269d4346900f1cfb306b50c2c Mon Sep 17 00:00:00 2001 From: "dlenev@brandersnatch.localdomain" <> Date: Sat, 10 Jul 2004 15:21:44 +0400 Subject: [PATCH 33/49] Reorder variables to preserve alphabetical sorting. --- sql/set_var.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/set_var.cc b/sql/set_var.cc index 9481e1aaef7..e1cfb77d297 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -802,6 +802,9 @@ struct show_var_st init_vars[]= { {sys_sync_binlog_period.name,(char*) &sys_sync_binlog_period, SHOW_SYS}, #endif {sys_sync_frm.name, (char*) &sys_sync_frm, SHOW_SYS}, +#ifdef HAVE_TZNAME + {"system_time_zone", system_time_zone, SHOW_CHAR}, +#endif {"table_cache", (char*) &table_cache_size, SHOW_LONG}, {sys_table_type.name, (char*) &sys_table_type, SHOW_SYS}, {sys_thread_cache_size.name,(char*) &sys_thread_cache_size, SHOW_SYS}, @@ -810,9 +813,6 @@ struct show_var_st init_vars[]= { #endif {"thread_stack", (char*) &thread_stack, SHOW_LONG}, {sys_time_format.name, (char*) &sys_time_format, SHOW_SYS}, -#ifdef HAVE_TZNAME - {"system_time_zone", system_time_zone, SHOW_CHAR}, -#endif {"time_zone", (char*) &sys_time_zone, SHOW_SYS}, {sys_tmp_table_size.name, (char*) &sys_tmp_table_size, SHOW_SYS}, {"tmpdir", (char*) &opt_mysql_tmpdir, SHOW_CHAR_PTR}, From 610b3d29773b3731c0db273f59cea000508a48c8 Mon Sep 17 00:00:00 2001 From: "joreland@mysql.com" <> Date: Sun, 11 Jul 2004 08:49:01 +0200 Subject: [PATCH 34/49] testSystemRestart -n SR1 Handle arbit during system shutdown --- ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp | 12 +++++++ ndb/src/kernel/blocks/qmgr/QmgrMain.cpp | 9 +++++ ndb/test/run-test/daily-basic-tests.txt | 36 +++++++++++++++++++ ndb/test/run-test/daily-devel-tests.txt | 32 ----------------- 4 files changed, 57 insertions(+), 32 deletions(-) diff --git a/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp b/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp index 0ae83f68b50..91776cd7c03 100644 --- a/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp +++ b/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp @@ -2313,6 +2313,18 @@ void Ndbcntr::execWAIT_GCP_REF(Signal* signal){ void Ndbcntr::execWAIT_GCP_CONF(Signal* signal){ jamEntry(); + ndbrequire(StopReq::getSystemStop(c_stopRec.stopReq.requestInfo)); + NodeState newState(NodeState::SL_STOPPING_3, true); + + /** + * Inform QMGR so that arbitrator won't kill us + */ + NodeStateRep * rep = (NodeStateRep *)&signal->theData[0]; + rep->nodeState = newState; + rep->nodeState.masterNodeId = cmasterNodeId; + rep->nodeState.setNodeGroup(c_nodeGroup); + EXECUTE_DIRECT(QMGR, GSN_NODE_STATE_REP, signal, NodeStateRep::SignalLength); + if(StopReq::getPerformRestart(c_stopRec.stopReq.requestInfo)){ jam(); StartOrd * startOrd = (StartOrd *)&signal->theData[0]; diff --git a/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp b/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp index 0c55c341389..9bf3bf06fa4 100644 --- a/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp +++ b/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp @@ -2311,6 +2311,15 @@ void Qmgr::execPREP_FAILCONF(Signal* signal) * Continues via sendCommitFailReq() if successful. */ arbitRec.failureNr = cfailureNr; + const NodeState & s = getNodeState(); + if(s.startLevel == NodeState::SL_STOPPING_3 && s.stopping.systemShutdown){ + jam(); + /** + * We're performing a system shutdown, + * don't let artibtrator shut us down + */ + return; + } handleArbitCheck(signal); return; }//Qmgr::execPREP_FAILCONF() diff --git a/ndb/test/run-test/daily-basic-tests.txt b/ndb/test/run-test/daily-basic-tests.txt index 2f0988419f7..0b64d9cf9c2 100644 --- a/ndb/test/run-test/daily-basic-tests.txt +++ b/ndb/test/run-test/daily-basic-tests.txt @@ -794,3 +794,39 @@ max-time: 300 cmd: testBlobs args: +max-time: 2500 +cmd: testOIBasic +args: + +# +# +# SYSTEM RESTARTS +# +max-time: 1500 +cmd: testSystemRestart +args: -n SR1 T1 + +max-time: 1500 +cmd: testSystemRestart +args: -n SR1 T6 + +max-time: 1500 +cmd: testSystemRestart +args: -n SR1 T7 + +max-time: 1500 +cmd: testSystemRestart +args: -n SR1 T8 + +max-time: 1500 +cmd: testSystemRestart +args: -n SR2 T1 + +max-time: 1500 +cmd: testSystemRestart +args: -n SR2 T6 + +max-time: 1500 +cmd: testSystemRestart +args: -n SR2 T7 + diff --git a/ndb/test/run-test/daily-devel-tests.txt b/ndb/test/run-test/daily-devel-tests.txt index e967de2aea3..3c72135334b 100644 --- a/ndb/test/run-test/daily-devel-tests.txt +++ b/ndb/test/run-test/daily-devel-tests.txt @@ -37,34 +37,6 @@ args: -n SingleUserMode T1 # # SYSTEM RESTARTS # -max-time: 1500 -cmd: testSystemRestart -args: -n SR1 T1 - -max-time: 1500 -cmd: testSystemRestart -args: -n SR1 T6 - -max-time: 1500 -cmd: testSystemRestart -args: -n SR1 T7 - -max-time: 1500 -cmd: testSystemRestart -args: -n SR1 T8 - -max-time: 1500 -cmd: testSystemRestart -args: -n SR2 T1 - -max-time: 1500 -cmd: testSystemRestart -args: -n SR2 T6 - -max-time: 1500 -cmd: testSystemRestart -args: -n SR2 T7 - max-time: 1500 cmd: testSystemRestart args: -n SR_UNDO T1 @@ -230,7 +202,3 @@ max-time: 2500 cmd: test_event args: -n BasicEventOperation T1 T6 -max-time: 2500 -cmd: testOIBasic -args: - From f39974e6727f3e7b56bedf9fe74af60e5d394e90 Mon Sep 17 00:00:00 2001 From: "joreland@mysql.com" <> Date: Sun, 11 Jul 2004 08:55:32 +0200 Subject: [PATCH 35/49] wl1292 Try to remove rare timeouts by Increased timeout in CpcClient and mgmapi --- ndb/src/common/util/socket_io.cpp | 4 ++-- ndb/src/mgmclient/CpcClient.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ndb/src/common/util/socket_io.cpp b/ndb/src/common/util/socket_io.cpp index 97bb4863a67..b2f4ef91031 100644 --- a/ndb/src/common/util/socket_io.cpp +++ b/ndb/src/common/util/socket_io.cpp @@ -93,8 +93,8 @@ readln_socket(NDB_SOCKET_TYPE socket, int timeout_millis, FD_ZERO(&readset); FD_SET(socket, &readset); - timeout.tv_sec = 1; - timeout.tv_usec = 0; // 1 s + timeout.tv_sec = (timeout_millis / 1000); + timeout.tv_usec = (timeout_millis % 1000) * 1000; const int selectRes = select(socket + 1, &readset, 0, 0, &timeout); if(selectRes != 1){ return -1; diff --git a/ndb/src/mgmclient/CpcClient.cpp b/ndb/src/mgmclient/CpcClient.cpp index 74fa1a828ed..f11aa797ff1 100644 --- a/ndb/src/mgmclient/CpcClient.cpp +++ b/ndb/src/mgmclient/CpcClient.cpp @@ -478,9 +478,9 @@ SimpleCpcClient::connect() { if (::connect(cpc_sock, (struct sockaddr*) &sa, sizeof(sa)) < 0) return -1; - cpc_in = new SocketInputStream(cpc_sock); + cpc_in = new SocketInputStream(cpc_sock, 60000); cpc_out = new SocketOutputStream(cpc_sock); - + return 0; } From 79b3b220be3e914bf2fded18a503895de212389a Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Mon, 12 Jul 2004 07:38:46 +0300 Subject: [PATCH 36/49] Don't close already closed files in vio (not critical) --- mysys/my_init.c | 1 + sql/mysqld.cc | 13 +++++++++++++ sql/sql_parse.cc | 1 - vio/viosocket.c | 4 +++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/mysys/my_init.c b/mysys/my_init.c index da0e6caf96d..0ef938b434c 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -127,6 +127,7 @@ void my_end(int infoflag) FILE *info_file; if (!(info_file=DBUG_FILE)) info_file=stderr; + DBUG_PRINT("info",("Shutting down")); if (infoflag & MY_CHECK_ERROR || info_file != stderr) { /* Test if some file is left open */ if (my_file_opened | my_stream_opened) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 1ed535753b1..4fd13d33bab 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1301,6 +1301,19 @@ void yyerror(const char *s) #ifndef EMBEDDED_LIBRARY +/* + Close a connection + + SYNOPSIS + close_connection() + thd Thread handle + errcode Error code to print to console + lock 1 if we have have to lock LOCK_thread_count + + NOTES + For the connection that is doing shutdown, this is called twice +*/ + void close_connection(THD *thd, uint errcode, bool lock) { st_vio *vio; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 61b57b2f350..e83868bac7c 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4562,7 +4562,6 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, register TABLE_LIST *ptr; char *alias_str; DBUG_ENTER("add_table_to_list"); - DBUG_PRINT("enter",("lock_option: %d", lock_type)); if (!table) DBUG_RETURN(0); // End of memory diff --git a/vio/viosocket.c b/vio/viosocket.c index 8dea06d4adf..48a9058480a 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -203,9 +203,11 @@ int vio_close(Vio * vio) #endif r=CloseHandle(vio->hPipe); } - else if (vio->type != VIO_CLOSED) + else #endif /* __WIN__ */ + if (vio->type != VIO_CLOSED) { + DBUG_ASSERT(vio->sd >= 0); if (shutdown(vio->sd,2)) r= -1; if (closesocket(vio->sd)) From 8542743833c1f2d42faf95307752f968df97ffd0 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Tue, 13 Jul 2004 08:57:55 +0200 Subject: [PATCH 37/49] s/help all/help contents/ bug#4527 --- client/mysql.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysql.cc b/client/mysql.cc index 98bc7e750e1..c9ee6819a13 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1727,7 +1727,7 @@ com_help(String *buffer __attribute__((unused)), commands[i].cmd_char, commands[i].doc); } if (connected && mysql_get_server_version(&mysql) >= 40100) - put_info("\nFor server side help, type 'help all'\n", INFO_INFO); + put_info("\nFor server side help, type 'help contents'\n", INFO_INFO); return 0; } From 141d43ef95ba8c6e1113cdaf5145b31786d7457d Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Tue, 13 Jul 2004 09:37:16 +0200 Subject: [PATCH 38/49] forced X/Open mode on HPUX removed. The correct way (that affects not only C but also C++ and linking) would be CFLAGS="-D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_HPUX_SOURCE" CXXFLAGS="-D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_HPUX_SOURCE" LDFLAGS="-lxnet" but apparently MySQL works without too. --- include/my_global.h | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/include/my_global.h b/include/my_global.h index 3c35ade8383..f7e77abfd26 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -120,26 +120,6 @@ #define __STDC_EXT__ 1 /* To get large file support on hpux */ #endif -#ifdef HPUX11 -/* - Fix warnings on HPUX11 - There is something really strange with HPUX11 include files as you get - error about wrongly declared symbols or missing defines if you don't - do the following: - */ -#if !defined(_XOPEN_SOURCE_EXTENDED) && ! defined(__cplusplus) -#define _XOPEN_SOURCE_EXTENDED 1 -#endif - -/* Fix type of socklen as this is depending on the above define */ -#undef SOCKET_SIZE_TYPE -#ifdef _XOPEN_SOURCE_EXTENDED -#define SOCKET_SIZE_TYPE socklen_t -#else -#define SOCKET_SIZE_TYPE int -#endif /* _XOPEN_SOURCE_EXTENDED */ -#endif /* HPUX11 */ - #if defined(THREAD) && !defined(__WIN__) && !defined(OS2) #ifndef _POSIX_PTHREAD_SEMANTICS #define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */ From c2ca8e1a7a00e805aa0de774c22d3e62646f140d Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Tue, 13 Jul 2004 13:50:06 +0200 Subject: [PATCH 39/49] - fixed tabbing and added several missing symbols (required for linking with PHP5) (thanks to Georg Richter for the patch) --- libmysql/libmysql.def | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/libmysql/libmysql.def b/libmysql/libmysql.def index bbd5af6558d..38ac9505e4b 100644 --- a/libmysql/libmysql.def +++ b/libmysql/libmysql.def @@ -129,6 +129,18 @@ EXPORTS mysql_stmt_prepare mysql_stmt_init mysql_stmt_insert_id - mysql_stmt_attr_get - mysql_stmt_attr_set + mysql_stmt_attr_get + mysql_stmt_attr_set mysql_stmt_field_count + client_errors + mysql_set_local_infile_default + mysql_set_local_infile_handler + mysql_disable_reads_from_master + mysql_disable_rpl_parse + mysql_enable_reads_from_master + mysql_enable_rpl_parse + mysql_master_query + mysql_rpl_parse_enabled + mysql_rpl_probe + mysql_rpl_query_type + mysql_slave_query From a009af5e84b8f4632f9a0804ed6f0971e16b7ca8 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Tue, 13 Jul 2004 16:51:10 +0200 Subject: [PATCH 40/49] WL#1900 "When CHECK TABLE or ANALYZE TABLE of a MyISAM table is killed by KILL or shutdown, do not mark the table as corrupted". It is indeed more logical to leave the corruption flag unchanged. This cannot be extended to REPAIR/OPTIMIZE as they make no backup copy of the MYI. This patch was tested with KILL and mysqladmin shutdown while a CHECK TABLE was running. Without the patch, the table becomes unusable (can't INSERT to it, error 145). With the patch, no. --- sql/ha_myisam.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 77615d68fe4..51c8521c376 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -336,7 +336,7 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt) HA_STATUS_CONST); } } - else if (!mi_is_crashed(file)) + else if (!mi_is_crashed(file) && !thd->killed) { mi_mark_crashed(file); file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED; @@ -378,7 +378,7 @@ int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt) error=update_state_info(¶m,file,UPDATE_STAT); pthread_mutex_unlock(&share->intern_lock); } - else if (!mi_is_crashed(file)) + else if (!mi_is_crashed(file) && !thd->killed) mi_mark_crashed(file); return error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK; } From 80b363bca0b24098f45586759f18a424b477ed9d Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Tue, 13 Jul 2004 22:11:33 +0200 Subject: [PATCH 41/49] - Fixed a previous modification to the MySQL Startup Item for Mac OS X: the name of the startup script itself must match the name of the subdirectory it's located in. Changed MySQL->MySQLCOM in the Do-pkg script and renamed the file in BK. (Thanks to Bryan McCormack for reporting this) --- Build-tools/Do-pkg | 2 +- support-files/MacOSX/{MySQL => MySQLCOM} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename support-files/MacOSX/{MySQL => MySQLCOM} (96%) diff --git a/Build-tools/Do-pkg b/Build-tools/Do-pkg index 286e33f6dd4..b9df444a4ba 100755 --- a/Build-tools/Do-pkg +++ b/Build-tools/Do-pkg @@ -96,7 +96,7 @@ $SI_PARAMS= <$SUPFILEDIR/StartupParameters.plist>; $SI_POST= <$SUPFILEDIR/StartupItem.postinstall>; $SI_NAME= "MySQLStartupItem"; $SI_DIR_NAME= "MySQLCOM"; -$SI_SCRIPT= <$SUPFILEDIR/MySQL>; +$SI_SCRIPT= <$SUPFILEDIR/MySQLCOM>; @RESOURCES= qw/ ReadMe.txt postinstall preinstall /; @LICENSES= ("$SRCBASEDIR/COPYING","$SRCBASEDIR/MySQLEULA.txt"); diff --git a/support-files/MacOSX/MySQL b/support-files/MacOSX/MySQLCOM similarity index 96% rename from support-files/MacOSX/MySQL rename to support-files/MacOSX/MySQLCOM index f6579700384..9be5edb56f7 100755 --- a/support-files/MacOSX/MySQL +++ b/support-files/MacOSX/MySQLCOM @@ -1,6 +1,6 @@ #!/bin/sh # -# /Library/StartupItems/MySQL/MySQL +# /Library/StartupItems/MySQLCOM/MySQLCOM # # A script to automatically start up MySQL on system bootup # for Mac OS X. This is actually just a wrapper script around From d764fb4240680334adb800a379ab980c5c107512 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Wed, 14 Jul 2004 09:10:49 +0200 Subject: [PATCH 42/49] - fixed file name of the MySQL startup item script to MySQLCOM, so it's included in the source distribution --- support-files/MacOSX/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-files/MacOSX/Makefile.am b/support-files/MacOSX/Makefile.am index ff16fa3235a..6babcf97b7a 100644 --- a/support-files/MacOSX/Makefile.am +++ b/support-files/MacOSX/Makefile.am @@ -23,7 +23,7 @@ EXTRA_DIST = Info.plist.sh \ postinstall.sh \ preinstall.sh \ ReadMe.txt \ - MySQL \ + MySQLCOM \ StartupItem.Description.plist \ StartupItem.Info.plist \ StartupItem.postinstall From 791bdf2c480188119a0666423bef1ea3a3adadaf Mon Sep 17 00:00:00 2001 From: "paul@kite-hub.kitebird.com" <> Date: Wed, 14 Jul 2004 11:33:00 -0500 Subject: [PATCH 43/49] mysql_fix_privilege_tables.sh: Language fixups. --- scripts/mysql_fix_privilege_tables.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh index 79b4bc627b7..c9e8e0c4dfd 100644 --- a/scripts/mysql_fix_privilege_tables.sh +++ b/scripts/mysql_fix_privilege_tables.sh @@ -159,11 +159,11 @@ s_echo() fi } -s_echo "This scripts updates all the mysql privilege tables to be usable by" +s_echo "This script updates all the mysql privilege tables to be usable by" s_echo "MySQL 4.0 and above." s_echo "" s_echo "This is needed if you want to use the new GRANT functions," -s_echo "CREATE AGGREGATE FUNCTION or want to use the more secure passwords in 4.1" +s_echo "CREATE AGGREGATE FUNCTION, or the more secure passwords in 4.1" s_echo "" if test $verbose = 1 From 3609ab683e42a0c48226032508b68e5a8043f0b1 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Wed, 14 Jul 2004 23:57:14 +0300 Subject: [PATCH 44/49] stack overflow check added for subqueries processing (BUG#4554) --- sql/item_subselect.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 4c1ffeecc97..3d5a11a26bc 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -128,7 +128,12 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) stmt= thd->current_statement; char const *save_where= thd->where; - int res= engine->prepare(); + int res; + + if (check_stack_overrun(thd, (gptr)&res)) + return 1; + + res= engine->prepare(); // all transformetion is done (used by prepared statements) changed= 1; From 8ab5398bf770c443d0f5869956ed897fea0dbf12 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Thu, 15 Jul 2004 14:17:30 +0300 Subject: [PATCH 45/49] check that all system tables deleted added --- mysql-test/r/system_mysql_db.result | 2 ++ mysql-test/t/system_mysql_db.test | 5 +++++ mysql-test/t/system_mysql_db_fix.test | 14 ++++---------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/system_mysql_db.result b/mysql-test/r/system_mysql_db.result index 1f09a20abc5..3fbe842ce49 100644 --- a/mysql-test/r/system_mysql_db.result +++ b/mysql-test/r/system_mysql_db.result @@ -126,3 +126,5 @@ columns_priv CREATE TABLE `columns_priv` ( `Column_priv` set('Select','Insert','Update','References') NOT NULL default '', PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`,`Column_name`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Column privileges' +show tables; +Tables_in_test diff --git a/mysql-test/t/system_mysql_db.test b/mysql-test/t/system_mysql_db.test index 85a2f7f9bae..a6d683489c3 100644 --- a/mysql-test/t/system_mysql_db.test +++ b/mysql-test/t/system_mysql_db.test @@ -6,3 +6,8 @@ use mysql; -- enable_query_log -- source include/system_db_struct.inc +-- disable_query_log +use test; +-- enable_query_log +# keep results same with system_mysql_db_fix +show tables; diff --git a/mysql-test/t/system_mysql_db_fix.test b/mysql-test/t/system_mysql_db_fix.test index 13c83fc9012..6c44535e3b7 100644 --- a/mysql-test/t/system_mysql_db_fix.test +++ b/mysql-test/t/system_mysql_db_fix.test @@ -68,15 +68,9 @@ INSERT INTO user VALUES ('localhost','', '','N','N','N','N','N','N','N','N',' -- disable_query_log -DROP TABLE db; -DROP TABLE host; -DROP TABLE user; -DROP TABLE func; -DROP TABLE tables_priv; -DROP TABLE columns_priv; -DROP TABLE help_category; -DROP TABLE help_keyword; -DROP TABLE help_relation; -DROP TABLE help_topic; +DROP TABLE db, host, user, func, tables_priv, columns_priv, help_category, help_keyword, help_relation, help_topic, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type; -- enable_query_log + +# check that we droped all system tables +show tables; From fe2425b7254bd403f607ad53990213e9948b6e16 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Thu, 15 Jul 2004 21:18:31 +0200 Subject: [PATCH 46/49] - Avoid the error message "Can't read index header from..." when copying a small index file because the value returned for $length is < 1024. This can happen if the filehandle was open()ed as an UTF-8 encoded file with Unicode characters (In this case read() returns characters not bytes) (Thanks to Mike Bethune) for this hint) --- scripts/mysqlhotcopy.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh index af4e6084c59..fe93aa5a1bc 100644 --- a/scripts/mysqlhotcopy.sh +++ b/scripts/mysqlhotcopy.sh @@ -635,6 +635,7 @@ sub copy_index my $to="$target/$file"; my $buff; open(INPUT, "<$from") || die "Can't open file $from: $!\n"; + binmode(INPUT, ":raw"); my $length=read INPUT, $buff, 2048; die "Can't read index header from $from\n" if ($length < 1024); close INPUT; From 0452d59d222c71dc01b2453ed4ec6a512d01197e Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Fri, 16 Jul 2004 13:21:58 +0200 Subject: [PATCH 47/49] in 4.1 DATABASE() may be NULL --- sql/item_strfunc.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 22134733393..08123370bc6 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -359,9 +359,10 @@ class Item_func_database :public Item_str_func public: Item_func_database() { collation.set(system_charset_info,DERIVATION_IMPLICIT); } String *val_str(String *); - void fix_length_and_dec() - { + void fix_length_and_dec() + { max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen; + maybe_null=1; } const char *func_name() const { return "database"; } }; From f973ac9942265954a9dca65bf10d8f4ae7c4d1c4 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Sat, 17 Jul 2004 02:09:25 +0300 Subject: [PATCH 48/49] test fix --- mysql-test/r/func_system.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/func_system.result b/mysql-test/r/func_system.result index 671132428c5..d3db2cc5151 100644 --- a/mysql-test/r/func_system.result +++ b/mysql-test/r/func_system.result @@ -46,7 +46,7 @@ create table t1 (version char(40)) select database(), user(), version() as 'vers show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `database()` char(34) character set utf8 NOT NULL default '', + `database()` char(34) character set utf8 default NULL, `user()` char(77) character set utf8 NOT NULL default '', `version` char(40) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 From ce96f0e407ab3e2be70e02cf16b74dbb4e99d338 Mon Sep 17 00:00:00 2001 From: "mskold@mysql.com" <> Date: Mon, 19 Jul 2004 10:31:55 +0200 Subject: [PATCH 49/49] Removed timeout tests --- mysql-test/r/ndb_transaction.result | 20 ------------- mysql-test/t/ndb_transaction.test | 45 ----------------------------- 2 files changed, 65 deletions(-) diff --git a/mysql-test/r/ndb_transaction.result b/mysql-test/r/ndb_transaction.result index 886fc0f71a0..405cd1d776a 100644 --- a/mysql-test/r/ndb_transaction.result +++ b/mysql-test/r/ndb_transaction.result @@ -192,26 +192,6 @@ count(*) select count(*) from t4; count(*) 0 -ERROR HY000: Lock wait timeout exceeded; try restarting transaction -select count(*) from t2; -count(*) -0 -select count(*) from t3; -count(*) -0 -select count(*) from t4; -count(*) -0 -ERROR HY000: Lock wait timeout exceeded; try restarting transaction -select count(*) from t2; -count(*) -0 -select count(*) from t3; -count(*) -0 -select count(*) from t4; -count(*) -0 select count(*) from t2; count(*) 100 diff --git a/mysql-test/t/ndb_transaction.test b/mysql-test/t/ndb_transaction.test index 6423f4456c6..4d9d90c21df 100644 --- a/mysql-test/t/ndb_transaction.test +++ b/mysql-test/t/ndb_transaction.test @@ -180,51 +180,6 @@ select count(*) from t2; select count(*) from t3; select count(*) from t4; -# -# insert records into tables and commit after timeout; -# -let $1=100; -disable_query_log; -begin; -while ($1) -{ - eval insert into t2 values($1, $1+9, 5); - eval insert into t3 values($1, $1+9, 5); - eval insert into t4 values($1, $1+9, 5, $1+26000); - dec $1; -} -sleep 15; --- error 1205 -commit; -enable_query_log; - -select count(*) from t2; -select count(*) from t3; -select count(*) from t4; - -# -# insert records into tables and timeout before last operation -# -let $1=100; -disable_query_log; -begin; -while ($1) -{ - eval insert into t2 values($1, $1+9, 5); - eval insert into t3 values($1, $1+9, 5); - eval insert into t4 values($1, $1+9, 5, $1+26000); - dec $1; -} -sleep 15; --- error 1205 -insert into t2 values(10000, 10000, 36000); -commit; -enable_query_log; - -select count(*) from t2; -select count(*) from t3; -select count(*) from t4; - # # insert records into tables and commit; #