Commit 064b8b8f authored by monty@mysql.com's avatar monty@mysql.com

Merge with 4.0 to get bug fixes

parents 949de544 801a2495
...@@ -46,6 +46,7 @@ $opt_test= undef; ...@@ -46,6 +46,7 @@ $opt_test= undef;
$opt_skip_check= undef; $opt_skip_check= undef;
$opt_skip_manual= undef; $opt_skip_manual= undef;
$opt_win_dist= undef; $opt_win_dist= undef;
$opt_quiet= undef;
$version= "unknown"; $version= "unknown";
$major=$minor=$release=0; $major=$minor=$release=0;
...@@ -67,7 +68,8 @@ GetOptions( ...@@ -67,7 +68,8 @@ GetOptions(
"suffix=s", "suffix=s",
"test|t", "test|t",
"verbose|v", "verbose|v",
"win-dist|w" "win-dist|w",
"quiet|q",
) || print_help(""); ) || print_help("");
# #
...@@ -99,8 +101,6 @@ if (defined $opt_build_command) ...@@ -99,8 +101,6 @@ if (defined $opt_build_command)
print_help("") if ($opt_help); print_help("") if ($opt_help);
defined($REPO=$ARGV[0]) || print_help("Please enter the BK repository to be used!"); 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"); &logger("Starting build");
&abort("The directory \"$REPO\" could not be found!") if (!-d $REPO); &abort("The directory \"$REPO\" could not be found!") if (!-d $REPO);
&logger("Using $REPO as the BK parent repository"); &logger("Using $REPO as the BK parent repository");
...@@ -306,7 +306,7 @@ if (!$opt_dry_run) ...@@ -306,7 +306,7 @@ if (!$opt_dry_run)
# #
# Now build the source distribution # Now build the source distribution
# #
&logger("Compiling"); &logger("Compiling...");
$command= $build_command; $command= $build_command;
&run_command($command, "Compilation failed!"); &run_command($command, "Compilation failed!");
...@@ -403,6 +403,7 @@ Options: ...@@ -403,6 +403,7 @@ Options:
include a log file snippet, if logging is enabled) include a log file snippet, if logging is enabled)
Note that the \@-Sign needs to be quoted! Note that the \@-Sign needs to be quoted!
Example: --mail=user\\\@domain.com Example: --mail=user\\\@domain.com
-q, --quiet Be quiet
-p, --pull Update the source BK trees before building -p, --pull Update the source BK trees before building
-r, --revision=<rev> Export the tree as of revision <rev> -r, --revision=<rev> Export the tree as of revision <rev>
(default is up to the latest revision) (default is up to the latest revision)
......
...@@ -204,6 +204,17 @@ if ($opt_stage == 0) ...@@ -204,6 +204,17 @@ if ($opt_stage == 0)
safe_cd($host); safe_cd($host);
if ($opt_stage == 0 && ! $opt_use_old_distribution) 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 -"); safe_system("gunzip < $opt_distribution | $tar xf -");
# Fix file times; This is needed because the time for files may be # Fix file times; This is needed because the time for files may be
...@@ -331,6 +342,9 @@ if ($opt_stage <= 3) ...@@ -331,6 +342,9 @@ if ($opt_stage <= 3)
$tar_file=<$pwd/$host/mysql*.t*gz>; $tar_file=<$pwd/$host/mysql*.t*gz>;
abort ("Could not find tarball!") unless ($tar_file); 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 # Unpack the binary distribution
# #
...@@ -660,7 +674,10 @@ sub safe_system ...@@ -660,7 +674,10 @@ sub safe_system
my($com,$res)=@_; my($com,$res)=@_;
print LOG "$com\n"; print LOG "$com\n";
print "$host: $com\n" if ($opt_debug); 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 sub check_system
......
...@@ -5,7 +5,10 @@ ...@@ -5,7 +5,10 @@
# #
sub logger 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; print timestamp() . " " . $message . "\n" if $opt_verbose;
if (defined $opt_log && !$opt_dry_run) if (defined $opt_log && !$opt_dry_run)
{ {
...@@ -30,9 +33,12 @@ sub run_command ...@@ -30,9 +33,12 @@ sub run_command
} }
else else
{ {
&logger($command); &logger($command, 1);
$command.= " >> $LOGFILE 2>&1" if defined $opt_log;
$command.= " > /dev/null" if (!$opt_verbose && !$opt_log); $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"); system($command) == 0 or &abort("$errormsg\n");
} }
} }
...@@ -47,6 +53,7 @@ sub abort ...@@ -47,6 +53,7 @@ sub abort
{ {
my $message= $_[0]; my $message= $_[0];
my $messagefile; my $messagefile;
my $subject= "Bootstrap of $REPO failed" if $opt_mail;
$message= "ERROR: " . $message; $message= "ERROR: " . $message;
&logger($message); &logger($message);
......
...@@ -10,10 +10,22 @@ ...@@ -10,10 +10,22 @@
# Written by Matt Wagner <matt@mysql.com> # Written by Matt Wagner <matt@mysql.com>
# #
use strict; 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 Digest::MD5;
use Getopt::Long; use Getopt::Long;
my $VER= "1.1"; my $VER= "1.3";
my $EXIT= 0;
# #
# Strip the leading path info off the program name ($0). We want 'my_md5sum' # Strip the leading path info off the program name ($0). We want 'my_md5sum'
...@@ -67,6 +79,9 @@ if ($opt_check) ...@@ -67,6 +79,9 @@ if ($opt_check)
# Print an error message if they don't match, else print OK # Print an error message if they don't match, else print OK
print "$checkfile: FAILED\n" if $digest ne $checksum; print "$checkfile: FAILED\n" if $digest ne $checksum;
print "$checkfile: OK\n" if $digest eq $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 # Else generate the MD5 digest to STDOUT
...@@ -80,6 +95,8 @@ else ...@@ -80,6 +95,8 @@ else
} }
} }
exit($EXIT);
# #
# This routine generates the MD5 digest of a file # This routine generates the MD5 digest of a file
......
...@@ -1851,12 +1851,6 @@ int read_query(struct st_query** q_ptr) ...@@ -1851,12 +1851,6 @@ int read_query(struct st_query** q_ptr)
q->record_file[0]= 0; q->record_file[0]= 0;
q->require_file= 0; q->require_file= 0;
q->first_word_len= 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_errors == 0;
bzero((gptr) global_expected_errno, sizeof(global_expected_errno));
global_expected_errors=0;
q->type = Q_UNKNOWN; q->type = Q_UNKNOWN;
q->query_buf= q->query= 0; q->query_buf= q->query= 0;
...@@ -1869,8 +1863,16 @@ int read_query(struct st_query** q_ptr) ...@@ -1869,8 +1863,16 @@ int read_query(struct st_query** q_ptr)
if (*p == '#') if (*p == '#')
{ {
q->type = Q_COMMENT; 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_errors == 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; q->type= Q_COMMENT_WITH_COMMAND;
p+= 2; /* To calculate first word */ p+= 2; /* To calculate first word */
...@@ -1905,6 +1907,8 @@ int read_query(struct st_query** q_ptr) ...@@ -1905,6 +1907,8 @@ int read_query(struct st_query** q_ptr)
*p1 = 0; *p1 = 0;
} }
} }
end:
while (*p && my_isspace(charset_info, *p)) while (*p && my_isspace(charset_info, *p))
p++; p++;
if (!(q->query_buf= q->query= my_strdup(p, MYF(MY_WME)))) if (!(q->query_buf= q->query= my_strdup(p, MYF(MY_WME))))
......
...@@ -16,10 +16,17 @@ ...@@ -16,10 +16,17 @@
C_MODE_START C_MODE_START
enum get_opt_var_type { GET_NO_ARG, GET_BOOL, GET_INT, GET_UINT, GET_LONG, #define GET_NO_ARG 1
GET_ULONG, GET_LL, GET_ULL, GET_STR, GET_STR_ALLOC, #define GET_BOOL 2
GET_DISABLED #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
#define GET_DISABLED 11
#define GET_ASK_ADDR 128 #define GET_ASK_ADDR 128
#define GET_TYPE_MASK 127 #define GET_TYPE_MASK 127
...@@ -34,7 +41,7 @@ struct my_option ...@@ -34,7 +41,7 @@ struct my_option
gptr *value; /* The variable value */ gptr *value; /* The variable value */
gptr *u_max_value; /* The user def. max variable value */ gptr *u_max_value; /* The user def. max variable value */
const char **str_values; /* Pointer to possible values */ 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; enum get_opt_arg_type arg_type;
longlong def_value; /* Default value */ longlong def_value; /* Default value */
longlong min_value; /* Min allowed value */ longlong min_value; /* Min allowed value */
......
...@@ -18,44 +18,44 @@ create table test_columns_priv select * from mysql.columns_priv; ...@@ -18,44 +18,44 @@ create table test_columns_priv select * from mysql.columns_priv;
delete from test_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); insert into test_columns_priv (Host,Db,User,Table_name,Column_name) values (@name,@name,@name,@name,@name);
select select
if(isnull(test_db.Host),'WRONG!!!','ok') as test_db_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_host.Host),'WRONG!!!','ok') as test_host_Host,
if(isnull(test_user.Host),'WRONG!!!','ok') as test_user_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_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_columns_priv.Host),'WRONG!!!','ok') as test_columns_priv_Host
from test_db from test_db
left join test_host on test_db.Host=test_host.Host 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_user on test_db.Host=test_user.Host
left join test_tables_priv on test_db.Host=test_tables_priv.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; 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 test_db_Host test_host_Host test_user_Host test_tables_priv_Host test_columns_priv_Host
ok ok ok ok ok ok ok ok ok ok
select select
if(isnull(test_db.Db),'WRONG!!!','ok') as test_db_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_host.Db),'WRONG!!!','ok') as test_host_Db,
if(isnull(test_tables_priv.Db),'WRONG!!!','ok') as test_tables_priv_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_columns_priv.Db),'WRONG!!!','ok') as est_columns_priv_Db
from test_db from test_db
left join test_host on test_db.Db=test_host.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_tables_priv on test_db.Db=test_tables_priv.Db
left join test_columns_priv on test_db.Db=test_columns_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 test_db_Db test_host_Db test_tables_priv_Db est_columns_priv_Db
ok ok ok ok ok ok ok ok
select select
if(isnull(test_db.User),'WRONG!!!','ok') as test_db_User, 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_user.User),'WRONG!!!','ok') as test_user_User,
if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_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 if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User
from test_db from test_db
left join test_user on test_db.User=test_user.User 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_tables_priv on test_db.User=test_tables_priv.User
left join test_columns_priv on test_db.User=test_columns_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 test_db_User test_user_User test_tables_priv_User test_columns_priv_User
ok ok ok ok ok ok ok ok
select select
if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_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 if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User
from test_tables_priv from test_tables_priv
left join test_columns_priv on test_tables_priv.Table_name=test_columns_priv.Table_name; left join test_columns_priv on test_tables_priv.Table_name=test_columns_priv.Table_name;
test_tables_priv_User test_columns_priv_User test_tables_priv_User test_columns_priv_User
ok ok ok ok
......
# #
# This test must examine integrity of system database "mysql" # This test must examine integrity of system database "mysql"
# #
-- disable_query_log -- disable_query_log
use mysql; use mysql;
-- enable_query_log -- enable_query_log
-- source include/system_db_struct.inc -- source include/system_db_struct.inc
# #
# This is the test for mysql_fix_privilege_tables # This is the test for mysql_fix_privilege_tables
# #
-- disable_result_log -- disable_result_log
-- disable_query_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;
INSERT INTO db VALUES ('%','test', '','Y','Y','Y','Y','Y','Y'); use test;
INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y');
CREATE TABLE host ( # create system tables as in mysql-3.20
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 ( CREATE TABLE db (
Host char(60) binary DEFAULT '' NOT NULL, Host char(60) binary DEFAULT '' NOT NULL,
User char(16) binary DEFAULT '' NOT NULL, Db char(32) binary DEFAULT '' NOT NULL,
Password char(16), User char(16) binary DEFAULT '' NOT NULL,
Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,
Insert_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, Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,
Delete_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, Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,
Drop_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, PRIMARY KEY Host (Host,Db,User),
Shutdown_priv enum('N','Y') DEFAULT 'N' NOT NULL, KEY User (User)
Process_priv enum('N','Y') DEFAULT 'N' NOT NULL, )
PRIMARY KEY Host (Host,User) type=ISAM;
)
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 -- exec $MYSQL_FIX_SYSTEM_TABLES --database=test
-- enable_query_log -- enable_query_log
-- enable_result_log -- enable_result_log
-- source include/system_db_struct.inc -- source include/system_db_struct.inc
-- disable_query_log -- disable_query_log
DROP TABLE db; DROP TABLE db;
DROP TABLE host; DROP TABLE host;
DROP TABLE user; DROP TABLE user;
DROP TABLE func; DROP TABLE func;
DROP TABLE tables_priv; DROP TABLE tables_priv;
DROP TABLE columns_priv; DROP TABLE columns_priv;
DROP TABLE help_category; DROP TABLE help_category;
DROP TABLE help_keyword; DROP TABLE help_keyword;
DROP TABLE help_relation; DROP TABLE help_relation;
DROP TABLE help_topic; DROP TABLE help_topic;
-- enable_query_log
-- enable_query_log
# #
# This test must examine integrity of current system database # 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"; 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" # If this part is wrong, most likely you've done wrong modification of system database "mysql"
# #
create table test_db select * from mysql.db; create table test_db select * from mysql.db;
delete from test_db; delete from test_db;
--disable_warnings --disable_warnings
insert into test_db (Host,Db,User) values (@name,@name,@name); insert into test_db (Host,Db,User) values (@name,@name,@name);
--enable_warnings --enable_warnings
create table test_host select * from mysql.host; create table test_host select * from mysql.host;
delete from test_host; delete from test_host;
--disable_warnings --disable_warnings
insert into test_host (Host,Db) values (@name,@name); insert into test_host (Host,Db) values (@name,@name);
--enable_warnings --enable_warnings
create table test_user select * from mysql.user; create table test_user select * from mysql.user;
delete from test_user; delete from test_user;
--disable_warnings --disable_warnings
insert into test_user (Host,User) values (@name,@name); insert into test_user (Host,User) values (@name,@name);
--enable_warnings --enable_warnings
create table test_func select * from mysql.func; create table test_func select * from mysql.func;
delete from test_func; delete from test_func;
--disable_warnings --disable_warnings
insert into test_func (name) values (@name); insert into test_func (name) values (@name);
--enable_warnings --enable_warnings
create table test_tables_priv select * from mysql.tables_priv; create table test_tables_priv select * from mysql.tables_priv;
delete from test_tables_priv; delete from test_tables_priv;
--disable_warnings --disable_warnings
insert into test_tables_priv (Host,Db,User,Table_name) values (@name,@name,@name,@name); insert into test_tables_priv (Host,Db,User,Table_name) values (@name,@name,@name,@name);
--enable_warnings --enable_warnings
create table test_columns_priv select * from mysql.columns_priv; create table test_columns_priv select * from mysql.columns_priv;
delete from test_columns_priv; delete from test_columns_priv;
--disable_warnings --disable_warnings
insert into test_columns_priv (Host,Db,User,Table_name,Column_name) values (@name,@name,@name,@name,@name); insert into test_columns_priv (Host,Db,User,Table_name,Column_name) values (@name,@name,@name,@name,@name);
--enable_warnings --enable_warnings
# 'Host' field must be the same for all the tables: # 'Host' field must be the same for all the tables:
select select
if(isnull(test_db.Host),'WRONG!!!','ok') as test_db_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_host.Host),'WRONG!!!','ok') as test_host_Host,
if(isnull(test_user.Host),'WRONG!!!','ok') as test_user_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_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_columns_priv.Host),'WRONG!!!','ok') as test_columns_priv_Host
from test_db from test_db
left join test_host on test_db.Host=test_host.Host 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_user on test_db.Host=test_user.Host
left join test_tables_priv on test_db.Host=test_tables_priv.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; left join test_columns_priv on test_db.Host=test_columns_priv.Host;
# 'Db' field must be the same for all the tables: # '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
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_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 select
if(isnull(test_db.Db),'WRONG!!!','ok') as test_db_Db, if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User,
if(isnull(test_host.Db),'WRONG!!!','ok') as test_host_Db, if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User
if(isnull(test_tables_priv.Db),'WRONG!!!','ok') as test_tables_priv_Db, from test_tables_priv
if(isnull(test_columns_priv.Db),'WRONG!!!','ok') as est_columns_priv_Db left join test_columns_priv on test_tables_priv.Table_name=test_columns_priv.Table_name;
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_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;
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;
...@@ -461,6 +461,17 @@ MY_DIR *my_dir(const char *path, myf MyFlags) ...@@ -461,6 +461,17 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
else else
finfo.mystat= NULL; finfo.mystat= NULL;
/*
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))
continue;
#endif
if (push_dynamic(dir_entries_storage, (gptr)&finfo)) if (push_dynamic(dir_entries_storage, (gptr)&finfo))
goto error; goto error;
......
...@@ -1696,9 +1696,9 @@ void Load_log_event::set_fields(List<Item> &field_list) ...@@ -1696,9 +1696,9 @@ void Load_log_event::set_fields(List<Item> &field_list)
int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
bool use_rli_only_for_errors) bool use_rli_only_for_errors)
{ {
char *load_data_query= 0;
thd->db= (char*) rewrite_db(db); thd->db= (char*) rewrite_db(db);
DBUG_ASSERT(thd->query == 0); DBUG_ASSERT(thd->query == 0);
thd->query= 0; // Should not be needed
thd->query_length= 0; // Should not be needed thd->query_length= 0; // Should not be needed
thd->query_error= 0; thd->query_error= 0;
clear_all_errors(thd, rli); clear_all_errors(thd, rli);
...@@ -1749,6 +1749,19 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, ...@@ -1749,6 +1749,19 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
{ {
char llbuff[22]; char llbuff[22];
enum enum_duplicates handle_dup; 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) if (sql_ex.opt_flags & REPLACE_FLAG)
handle_dup= DUP_REPLACE; handle_dup= DUP_REPLACE;
else if (sql_ex.opt_flags & IGNORE_FLAG) else if (sql_ex.opt_flags & IGNORE_FLAG)
...@@ -1830,8 +1843,14 @@ Slave: load data infile on table '%s' at log position %s in log \ ...@@ -1830,8 +1843,14 @@ Slave: load data infile on table '%s' at log position %s in log \
} }
thd->net.vio = 0; 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); close_thread_tables(thd);
if (load_data_query)
my_afree(load_data_query);
if (thd->query_error) if (thd->query_error)
{ {
/* this err/sql_errno code is copy-paste from send_error() */ /* this err/sql_errno code is copy-paste from send_error() */
...@@ -2846,7 +2865,7 @@ void Create_file_log_event::pack_info(Protocol *protocol) ...@@ -2846,7 +2865,7 @@ void Create_file_log_event::pack_info(Protocol *protocol)
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
int Create_file_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; char *p;
int fd = -1; int fd = -1;
IO_CACHE file; IO_CACHE file;
...@@ -2855,6 +2874,8 @@ int Create_file_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -2855,6 +2874,8 @@ int Create_file_log_event::exec_event(struct st_relay_log_info* rli)
bzero((char*)&file, sizeof(file)); bzero((char*)&file, sizeof(file));
p = slave_load_file_stem(fname_buf, file_id, server_id); p = slave_load_file_stem(fname_buf, file_id, server_id);
strmov(p, ".info"); // strmov takes less code than memcpy 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, if ((fd = my_open(fname_buf, O_WRONLY|O_CREAT|O_BINARY|O_TRUNC,
MYF(MY_WME))) < 0 || MYF(MY_WME))) < 0 ||
init_io_cache(&file, fd, IO_SIZE, WRITE_CACHE, (my_off_t)0, 0, init_io_cache(&file, fd, IO_SIZE, WRITE_CACHE, (my_off_t)0, 0,
...@@ -2898,6 +2919,7 @@ err: ...@@ -2898,6 +2919,7 @@ err:
end_io_cache(&file); end_io_cache(&file);
if (fd >= 0) if (fd >= 0)
my_close(fd, MYF(0)); my_close(fd, MYF(0));
thd->proc_info= 0;
return error ? 1 : Log_event::exec_event(rli); return error ? 1 : Log_event::exec_event(rli);
} }
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */ #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
...@@ -2995,13 +3017,15 @@ void Append_block_log_event::pack_info(Protocol *protocol) ...@@ -2995,13 +3017,15 @@ void Append_block_log_event::pack_info(Protocol *protocol)
#if defined( HAVE_REPLICATION) && !defined(MYSQL_CLIENT) #if defined( HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
int Append_block_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); char *p= slave_load_file_stem(fname, file_id, server_id);
int fd; int fd;
int error = 1; int error = 1;
DBUG_ENTER("Append_block_log_event::exec_event"); DBUG_ENTER("Append_block_log_event::exec_event");
memcpy(p, ".data", 6); 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) 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); slave_print_error(rli,my_errno, "Error in Append_block event: could not open file '%s'", fname);
...@@ -3017,6 +3041,7 @@ int Append_block_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -3017,6 +3041,7 @@ int Append_block_log_event::exec_event(struct st_relay_log_info* rli)
err: err:
if (fd >= 0) if (fd >= 0)
my_close(fd, MYF(0)); my_close(fd, MYF(0));
thd->proc_info= 0;
DBUG_RETURN(error ? error : Log_event::exec_event(rli)); DBUG_RETURN(error ? error : Log_event::exec_event(rli));
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment