merge from 5.5 main

This commit is contained in:
Bjorn Munch 2011-01-29 22:53:17 +01:00
commit c9a0cf7854
24 changed files with 533 additions and 98 deletions

View file

@ -7555,8 +7555,12 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command,
mysql_free_result(res); /* Free normal result set with meta data */
/* Clear prepare warnings */
dynstr_set(&ds_prepare_warnings, NULL);
/*
Clear prepare warnings if there are execute warnings,
since they are probably duplicated.
*/
if (ds_execute_warnings.length || mysql->warning_count)
dynstr_set(&ds_prepare_warnings, NULL);
}
else
{

View file

@ -0,0 +1,78 @@
#
# Originally created by John Embretsen, 2011-01-26.
#
# Checks for the existence of Perl modules DBI and DBD::mysql as seen from the
# perl installation used by "external" executable perl scripts, i.e. scripts
# that are executed as standalone scripts interpreted by the perl installation
# specified by the "shebang" line in the top of these scripts.
#
# If either module is not found, the test will be skipped.
#
# For use in tests that call perl scripts that require these modules.
#
# This file is intended to work on Unix. Windows may need different treatment.
# Reasoning:
# - "shebangs" are not relevant on Windows, but need to be handled here.
# - Perl scripts cannot be made executable on Windows, interpreter must be
# specified.
#
# Note that if there are multiple perl installations and not all have the
# required modules, this check may fail even if the perl in path does have
# the modules available. This may happen if the perl specified by the script's
# shebang (e.g. #!/usr/bin/perl) does not have these modules, and script is
# called without specifying the perl interpreter. However, this will be
# a correct result in cases where a test calls a script with a similar shebang.
#
################################################################################
--source include/not_windows.inc
# We jump through some hoops since there is no direct way to check if an
# external command went OK or not from a mysql-test file:
#
# - In theory, we could do as simple as "exec perl -MDBI -MDBD::mysql -e 1",
# however we cannot check the result (exit code) from within a test script.
# Also, this may not yield the same result as other uses of perl due to the
# shebang issue mentioned above.
# - Instead we use a separate helper perl script that checks for the modules.
# - If the modules are found, the perl script leaves a file which sets a
# variable that can be read by this file.
# If the modules are not found, the perl script does not set this variable,
# but leaves an empty file instead.
#
# This is done because there is apparently no direct way to transfer
# information from perl to the test script itself.
--disable_query_log
--disable_result_log
--disable_warnings
# We do not use embedded perl in this script because that would not have yielded
# correct results for a situation where an external Perl script is called like
# "scriptname" instead of "perl scriptname" and the shebang in the script points
# to a specific perl that may be different than the perl in PATH.
#
# Instead, we call a separate helper script which checks for the modules in its
# own environment. We call it without "perl" in front.
--let $perlChecker= $MYSQLTEST_VARDIR/std_data/checkDBI_DBD-mysql.pl
--let $resultFile= $MYSQL_TMP_DIR/dbidbd-mysql.txt
# Make the script executable and execute it.
--chmod 0755 $perlChecker
--exec $perlChecker
# Source the resulting temporary file and look for a variable being set.
--source $resultFile
if (!$dbidbd) {
--skip Test needs Perl modules DBI and DBD::mysql
}
# Clean up
--remove_file $resultFile
--enable_query_log
--enable_result_log
--enable_warnings

View file

@ -4,12 +4,26 @@
--source include/not_windows.inc
--source include/not_embedded.inc
--source include/have_dbi_dbd-mysql.inc
if (!$MYSQLHOTCOPY)
{
# Fail the test if the mysqlhotcopy script is missing.
# If the tool's location changes, mysql-test-run.pl must be updated to
# reflect this (look for "MYSQLHOTCOPY").
die due to missing mysqlhotcopy tool;
}
# NOTE (johnemb, 2011-01-26):
# In this test mysqlhotcopy (a perl script) is executed as a standalone
# executable, i.e. not necessarily using the perl interpreter in PATH,
# because that is how the documentation demonstrates it.
#
# We include have_dbi_dbd-mysql.inc above so that the test will
# be skipped if Perl modules required by the mysqlhotcopy tool are not
# found when the script is run this way.
let $MYSQLD_DATADIR= `SELECT @@datadir`;
--disable_warnings
DROP DATABASE IF EXISTS hotcopy_test;

View file

@ -90,3 +90,68 @@ test.t1 optimize status Operation failed
# Connection default
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';
#
# Bug#42230 during add index, cannot do queries on storage engines
# that implement add_index
#
DROP DATABASE IF EXISTS db1;
DROP TABLE IF EXISTS t1;
# Test 1: Secondary index, should not block reads (original test case).
# Connection default
CREATE DATABASE db1;
CREATE TABLE db1.t1(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, value INT) engine=innodb;
INSERT INTO db1.t1(value) VALUES (1), (2);
SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
# Sending:
ALTER TABLE db1.t1 ADD INDEX(value);
# Connection con1
SET DEBUG_SYNC= "now WAIT_FOR manage";
USE db1;
SELECT * FROM t1;
id value
1 1
2 2
SET DEBUG_SYNC= "now SIGNAL query";
# Connection default
# Reaping: ALTER TABLE db1.t1 ADD INDEX(value)
DROP DATABASE db1;
# Test 2: Primary index (implicit), should block reads.
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL) engine=innodb;
SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
# Sending:
ALTER TABLE t1 ADD UNIQUE INDEX(a);
# Connection con1
SET DEBUG_SYNC= "now WAIT_FOR manage";
USE test;
# Sending:
SELECT * FROM t1;
# Connection con2
# Waiting for SELECT to be blocked by the metadata lock on t1
SET DEBUG_SYNC= "now SIGNAL query";
# Connection default
# Reaping: ALTER TABLE t1 ADD UNIQUE INDEX(a)
# Connection con1
# Reaping: SELECT * FROM t1
a b
# Test 3: Primary index (explicit), should block reads.
# Connection default
ALTER TABLE t1 DROP INDEX a;
SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
# Sending:
ALTER TABLE t1 ADD PRIMARY KEY (a);
# Connection con1
SET DEBUG_SYNC= "now WAIT_FOR manage";
# Sending:
SELECT * FROM t1;
# Connection con2
# Waiting for SELECT to be blocked by the metadata lock on t1
SET DEBUG_SYNC= "now SIGNAL query";
# Connection default
# Reaping: ALTER TABLE t1 ADD PRIMARY KEY (a)
# Connection con1
# Reaping: SELECT * FROM t1
a b
# Test 4: Secondary unique index, should not block reads.
# Connection default
SET DEBUG_SYNC= "RESET";
DROP TABLE t1;

View file

@ -1,5 +1,18 @@
drop table if exists t1, t2;
#
# Bug#57924: crash when creating partitioned table with
# multiple columns in the partition key
#
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
PARTITION BY KEY(a, b, a);
ERROR HY000: Duplicate partition field name 'a'
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
PARTITION BY KEY(A, b);
DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
PARTITION BY KEY(a, b, A);
ERROR HY000: Duplicate partition field name 'a'
#
# Bug#54483: valgrind errors when making warnings for multiline inserts
# into partition
#

View file

@ -0,0 +1,97 @@
#!/usr/bin/perl
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; version 2
# of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
################################################################################
#
# This perl script checks for availability of the Perl modules DBI and
# DBD::mysql using the "current" perl interpreter.
#
# Useful for test environment checking before testing executable perl scripts
# in the MySQL Server distribution.
#
# NOTE: The "shebang" on the first line of this script should always point to
# /usr/bin/perl, so that we can use this script to check whether or not we
# support running perl scripts with such a shebang without specifying the
# perl interpreter on the command line. Such a script is mysqlhotcopy.
#
# When run as "checkDBI_DBD-mysql.pl" the shebang line will be evaluated
# and used. When run as "perl checkDBI_DBD-mysql.pl" the shebang line is
# not used.
#
# NOTE: This script will create a temporary file in MTR's tmp dir.
# If modules are found, a mysql-test statement which sets a special
# variable is written to this file. If one of the modules is not found
# (or cannot be loaded), the file will remain empty.
# A test (or include file) which sources that file can then easily do
# an if-check on the special variable to determine success or failure.
#
# Example:
#
# --let $perlChecker= $MYSQLTEST_VARDIR/std_data/checkDBI_DBD-mysql.pl
# --let $resultFile= $MYSQL_TMP_DIR/dbidbd-mysql.txt
# --chmod 0755 $perlChecker
# --exec $perlChecker
# --source $resultFile
# if (!$dbidbd) {
# --skip Test needs Perl modules DBI and DBD::mysql
# }
#
# The calling script is also responsible for cleaning up after use:
#
# --remove_file $resultFile
#
# Windows notes:
# - shebangs may work differently - call this script with "perl " in front.
#
# See mysql-test/include/have_dbi_dbd-mysql.inc for example use of this script.
# This script should be executable for the user running MTR.
#
################################################################################
BEGIN {
# By using eval inside BEGIN we can suppress warnings and continue after.
# We need to catch "Can't locate" as well as "Can't load" errors.
eval{
$FOUND_DBI=0;
$FOUND_DBD_MYSQL=0;
# Check for DBI module:
$FOUND_DBI=1 if require DBI;
# Check for DBD::mysql module
$FOUND_DBD_MYSQL=1 if require DBD::mysql;
};
};
# Open a file to be used for transfer of result back to mysql-test.
# The file must be created whether we write to it or not, otherwise mysql-test
# will complain if trying to source it.
# An empty file indicates failure to load modules.
open(FILE, ">", $ENV{'MYSQL_TMP_DIR'}.'/dbidbd-mysql.txt');
if ($FOUND_DBI && $FOUND_DBD_MYSQL) {
# write a mysql-test command setting a variable to indicate success
print(FILE 'let $dbidbd= FOUND_DBI_DBD-MYSQL;'."\n");
}
# close the file.
close(FILE);
1;

View file

@ -29,14 +29,10 @@ DELETE FROM t0_definition;
let $MYSQLD_DATADIR= `select LEFT(@@datadir, LENGTH(@@datadir)-1)`;
#echo MYSQLD_DATADIR: $MYSQLD_DATADIR;
# Dump the current definition of the table t1 to tmp1
# This complicated method - let another mysqltest collect the output - is used
# because of two reasons
# Save the current definition of the table t1
# - SHOW CREATE TABLE t1 is at least currently most probably more reliable than
# the corresponding SELECT on the INFORMATION_SCHEMA
# - SHOW CREATE TABLE .. cannot write its out put into a file like SELECT
let $show_file= $MYSQLD_DATADIR/test/tmp1;
--exec echo "SHOW CREATE TABLE t1; exit; " | $MYSQL_TEST > $show_file 2>&1
let $show_create= `SHOW CREATE TABLE t1`;
if ($do_file_tests)
{
# List the files belonging to the table t1
@ -57,12 +53,13 @@ if (!$do_file_tests)
# Insert the current definition of the table t1 into t0_definition
eval INSERT INTO t0_definition SET state = 'old',
create_command = load_file('$show_file'),
create_command = "$show_create",
file_list = @aux;
# Print the create table statement into the protocol
# Added the concat to avoid changing the result files
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR '\r' ''
SELECT create_command FROM t0_definition WHERE state = 'old';
SELECT concat('SHOW CREATE TABLE t1;\nTable\tCreate Table\n',create_command,'\n') as `create_command` FROM t0_definition WHERE state = 'old';
if ($do_file_tests)
{
# We stored the list of files, therefore printing the content makes sense

View file

@ -28,9 +28,8 @@ DELETE FROM t0_definition WHERE state = 'new';
let $MYSQLD_DATADIR= `select LEFT(@@datadir, LENGTH(@@datadir)-1)`;
#echo MYSQLD_DATADIR: $MYSQLD_DATADIR;
# Dump the current definition of the table t1 to tmp1
let $show_file= $MYSQLD_DATADIR/test/tmp1;
--exec echo "SHOW CREATE TABLE t1; exit; " | $MYSQL_TEST > $show_file 2>&1
# Save the current definition of the table t1
let $show_create= `SHOW CREATE TABLE t1`;
if ($do_file_tests)
{
@ -52,7 +51,7 @@ if (!$do_file_tests)
# Insert the current definition of the table t1 into t0_definition
eval INSERT INTO t0_definition SET state = 'new',
create_command = load_file('$show_file'),
create_command = "$show_create",
file_list = @aux;
# Print the old and new table layout, if they differ

View file

@ -20,6 +20,8 @@ FLUSH TABLES;
let $MYSQLD_DATADIR= `select @@datadir`;
--remove_file $MYSQLD_DATADIR/test/t1_will_crash.MYI
--copy_file std_data/corrupt_t1.MYI $MYSQLD_DATADIR/test/t1_will_crash.MYI
--replace_result \\ /
--replace_regex /Table '.*data/Table './
SELECT * FROM t1_will_crash;
DROP TABLE t1_will_crash;
CREATE TABLE t1_will_crash (a INT, KEY (a))
@ -33,5 +35,7 @@ FLUSH TABLES;
--echo # head -c1024 t1#P#p1.MYI > corrupt_t1#P#p1.MYI
--remove_file $MYSQLD_DATADIR/test/t1_will_crash#P#p1.MYI
--copy_file std_data/corrupt_t1#P#p1.MYI $MYSQLD_DATADIR/test/t1_will_crash#P#p1.MYI
--replace_result \\ /
--replace_regex /Table '.*data/Table './
SELECT * FROM t1_will_crash;
DROP TABLE t1_will_crash;

View file

@ -58,8 +58,8 @@ ENGINE = InnoDB
PARTITION BY HASH (a)
PARTITIONS 2;
connect (con1,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect (con2,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect (con1, localhost, root,,);
connect (con2, localhost, root,,);
--connection con1
SET autocommit=OFF;

View file

@ -16,3 +16,5 @@ rpl_row_create_table : Bug#51574 2010-02-27 andrei failed different way tha
rpl_spec_variables : BUG#47661 2009-10-27 jasonh rpl_spec_variables fails on PB2 hpux
rpl_log_pos : BUG#55675 2010-09-10 alfranio rpl.rpl_log_pos fails sporadically with error binlog truncated in the middle
rpl_get_master_version_and_clock : Bug#59178 Jan 05 2011 joro Valgrind warnings rpl_get_master_version_and_clock
rpl_row_until : BUG#59543 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out
rpl_stm_until : BUG#59543 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out

View file

@ -11,8 +11,6 @@
##############################################################################
lowercase_table3 : Bug#54845 2010-06-30 alik main.lowercase_table3 on Mac OSX
query_cache_28249 : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically
main.mysqlhotcopy_myisam : Bug#56817 2010-10-21 anitha mysqlhotcopy* fails
main.mysqlhotcopy_archive: Bug#56817 2010-10-21 anitha mysqlhotcopy* fails
log_tables-big : Bug#48646 2010-11-15 mattiasj report already exists
read_many_rows_innodb : Bug#37635 2010-11-15 mattiasj report already exists
sum_distinct-big : Bug#56927 2010-11-15 mattiasj was not tested

View file

@ -147,6 +147,139 @@ SET DEBUG_SYNC= 'RESET';
disconnect con1;
--echo #
--echo # Bug#42230 during add index, cannot do queries on storage engines
--echo # that implement add_index
--echo #
--disable_warnings
DROP DATABASE IF EXISTS db1;
DROP TABLE IF EXISTS t1;
--enable_warnings
connect(con1,localhost,root);
connect(con2,localhost,root);
--echo # Test 1: Secondary index, should not block reads (original test case).
--echo # Connection default
connection default;
CREATE DATABASE db1;
CREATE TABLE db1.t1(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, value INT) engine=innodb;
INSERT INTO db1.t1(value) VALUES (1), (2);
SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
--echo # Sending:
--send ALTER TABLE db1.t1 ADD INDEX(value)
--echo # Connection con1
connection con1;
SET DEBUG_SYNC= "now WAIT_FOR manage";
# Neither of these two statements should be blocked
USE db1;
SELECT * FROM t1;
SET DEBUG_SYNC= "now SIGNAL query";
--echo # Connection default
connection default;
--echo # Reaping: ALTER TABLE db1.t1 ADD INDEX(value)
--reap
DROP DATABASE db1;
--echo # Test 2: Primary index (implicit), should block reads.
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL) engine=innodb;
SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
--echo # Sending:
--send ALTER TABLE t1 ADD UNIQUE INDEX(a)
--echo # Connection con1
connection con1;
SET DEBUG_SYNC= "now WAIT_FOR manage";
USE test;
--echo # Sending:
--send SELECT * FROM t1
--echo # Connection con2
connection con2;
--echo # Waiting for SELECT to be blocked by the metadata lock on t1
let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
WHERE state= 'Waiting for table metadata lock'
AND info='SELECT * FROM t1';
--source include/wait_condition.inc
SET DEBUG_SYNC= "now SIGNAL query";
--echo # Connection default
connection default;
--echo # Reaping: ALTER TABLE t1 ADD UNIQUE INDEX(a)
--reap
--echo # Connection con1
connection con1;
--echo # Reaping: SELECT * FROM t1
--reap
--echo # Test 3: Primary index (explicit), should block reads.
--echo # Connection default
connection default;
ALTER TABLE t1 DROP INDEX a;
SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
--echo # Sending:
--send ALTER TABLE t1 ADD PRIMARY KEY (a)
--echo # Connection con1
connection con1;
SET DEBUG_SYNC= "now WAIT_FOR manage";
--echo # Sending:
--send SELECT * FROM t1
--echo # Connection con2
connection con2;
--echo # Waiting for SELECT to be blocked by the metadata lock on t1
let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
WHERE state= 'Waiting for table metadata lock'
AND info='SELECT * FROM t1';
--source include/wait_condition.inc
SET DEBUG_SYNC= "now SIGNAL query";
--echo # Connection default
connection default;
--echo # Reaping: ALTER TABLE t1 ADD PRIMARY KEY (a)
--reap
--echo # Connection con1
connection con1;
--echo # Reaping: SELECT * FROM t1
--reap
--echo # Test 4: Secondary unique index, should not block reads.
# This requires HA_INPLACE_ADD_UNIQUE_INDEX_NO_WRITE to be supported
# by InnoDB. Adding this flag currently introduces a regression so
# this test is disabled until the regression has been fixed.
--echo # Connection default
connection default;
#SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
#--echo # Sending:
#--send ALTER TABLE t1 ADD UNIQUE (b)
#--echo # Connection con1
#connection con1;
#SET DEBUG_SYNC= "now WAIT_FOR manage";
#SELECT * FROM t1;
#SET DEBUG_SYNC= "now SIGNAL query";
#--echo # Connection default
#connection default;
#--echo # Reaping: ALTER TABLE t1 ADD UNIQUE (b)
#--reap
disconnect con1;
disconnect con2;
SET DEBUG_SYNC= "RESET";
DROP TABLE t1;
# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc

View file

@ -10,6 +10,21 @@ drop table if exists t1, t2;
let $MYSQLD_DATADIR= `SELECT @@datadir`;
--echo #
--echo # Bug#57924: crash when creating partitioned table with
--echo # multiple columns in the partition key
--echo #
--error ER_SAME_NAME_PARTITION_FIELD
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
PARTITION BY KEY(a, b, a);
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
PARTITION BY KEY(A, b);
DROP TABLE t1;
--error ER_SAME_NAME_PARTITION_FIELD
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
PARTITION BY KEY(a, b, A);
--echo #
--echo # Bug#54483: valgrind errors when making warnings for multiline inserts
--echo # into partition
@ -670,7 +685,6 @@ PARTITION BY HASH (TIME_TO_SEC(a));
CREATE TABLE t1 (a INT)
PARTITION BY HASH (TIME_TO_SEC(a));
--echo #
--echo # Bug#50036: Inconsistent errors when using TIMESTAMP
--echo # columns/expressions

View file

@ -1,4 +1,4 @@
/* Copyright 2005-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
/* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -6432,28 +6432,28 @@ uint ha_partition::alter_table_flags(uint flags)
already altered, partitions. So both ADD and DROP can only be supported in
pairs.
*/
flags_to_check= HA_ONLINE_ADD_INDEX_NO_WRITES;
flags_to_check|= HA_ONLINE_DROP_INDEX_NO_WRITES;
flags_to_check= HA_INPLACE_ADD_INDEX_NO_READ_WRITE;
flags_to_check|= HA_INPLACE_DROP_INDEX_NO_READ_WRITE;
if ((flags_to_return & flags_to_check) != flags_to_check)
flags_to_return&= ~flags_to_check;
flags_to_check= HA_ONLINE_ADD_UNIQUE_INDEX_NO_WRITES;
flags_to_check|= HA_ONLINE_DROP_UNIQUE_INDEX_NO_WRITES;
flags_to_check= HA_INPLACE_ADD_UNIQUE_INDEX_NO_READ_WRITE;
flags_to_check|= HA_INPLACE_DROP_UNIQUE_INDEX_NO_READ_WRITE;
if ((flags_to_return & flags_to_check) != flags_to_check)
flags_to_return&= ~flags_to_check;
flags_to_check= HA_ONLINE_ADD_PK_INDEX_NO_WRITES;
flags_to_check|= HA_ONLINE_DROP_PK_INDEX_NO_WRITES;
flags_to_check= HA_INPLACE_ADD_PK_INDEX_NO_READ_WRITE;
flags_to_check|= HA_INPLACE_DROP_PK_INDEX_NO_READ_WRITE;
if ((flags_to_return & flags_to_check) != flags_to_check)
flags_to_return&= ~flags_to_check;
flags_to_check= HA_ONLINE_ADD_INDEX;
flags_to_check|= HA_ONLINE_DROP_INDEX;
flags_to_check= HA_INPLACE_ADD_INDEX_NO_WRITE;
flags_to_check|= HA_INPLACE_DROP_INDEX_NO_WRITE;
if ((flags_to_return & flags_to_check) != flags_to_check)
flags_to_return&= ~flags_to_check;
flags_to_check= HA_ONLINE_ADD_UNIQUE_INDEX;
flags_to_check|= HA_ONLINE_DROP_UNIQUE_INDEX;
flags_to_check= HA_INPLACE_ADD_UNIQUE_INDEX_NO_WRITE;
flags_to_check|= HA_INPLACE_DROP_UNIQUE_INDEX_NO_WRITE;
if ((flags_to_return & flags_to_check) != flags_to_check)
flags_to_return&= ~flags_to_check;
flags_to_check= HA_ONLINE_ADD_PK_INDEX;
flags_to_check|= HA_ONLINE_DROP_PK_INDEX;
flags_to_check= HA_INPLACE_ADD_PK_INDEX_NO_WRITE;
flags_to_check|= HA_INPLACE_DROP_PK_INDEX_NO_WRITE;
if ((flags_to_return & flags_to_check) != flags_to_check)
flags_to_return&= ~flags_to_check;
DBUG_RETURN(flags_to_return);

View file

@ -1,7 +1,7 @@
#ifndef HANDLER_INCLUDED
#define HANDLER_INCLUDED
/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -172,28 +172,31 @@
bits in alter_table_flags:
*/
/*
These bits are set if different kinds of indexes can be created
off-line without re-create of the table (but with a table lock).
These bits are set if different kinds of indexes can be created or dropped
in-place without re-creating the table using a temporary table.
NO_READ_WRITE indicates that the handler needs concurrent reads and writes
of table data to be blocked.
Partitioning needs both ADD and DROP to be supported by its underlying
handlers, due to error handling, see bug#57778.
*/
#define HA_ONLINE_ADD_INDEX_NO_WRITES (1L << 0) /*add index w/lock*/
#define HA_ONLINE_DROP_INDEX_NO_WRITES (1L << 1) /*drop index w/lock*/
#define HA_ONLINE_ADD_UNIQUE_INDEX_NO_WRITES (1L << 2) /*add unique w/lock*/
#define HA_ONLINE_DROP_UNIQUE_INDEX_NO_WRITES (1L << 3) /*drop uniq. w/lock*/
#define HA_ONLINE_ADD_PK_INDEX_NO_WRITES (1L << 4) /*add prim. w/lock*/
#define HA_ONLINE_DROP_PK_INDEX_NO_WRITES (1L << 5) /*drop prim. w/lock*/
#define HA_INPLACE_ADD_INDEX_NO_READ_WRITE (1L << 0)
#define HA_INPLACE_DROP_INDEX_NO_READ_WRITE (1L << 1)
#define HA_INPLACE_ADD_UNIQUE_INDEX_NO_READ_WRITE (1L << 2)
#define HA_INPLACE_DROP_UNIQUE_INDEX_NO_READ_WRITE (1L << 3)
#define HA_INPLACE_ADD_PK_INDEX_NO_READ_WRITE (1L << 4)
#define HA_INPLACE_DROP_PK_INDEX_NO_READ_WRITE (1L << 5)
/*
These are set if different kinds of indexes can be created on-line
(without a table lock). If a handler is capable of one or more of
these, it should also set the corresponding *_NO_WRITES bit(s).
These are set if different kinds of indexes can be created or dropped
in-place while still allowing concurrent reads (but not writes) of table
data. If a handler is capable of one or more of these, it should also set
the corresponding *_NO_READ_WRITE bit(s).
*/
#define HA_ONLINE_ADD_INDEX (1L << 6) /*add index online*/
#define HA_ONLINE_DROP_INDEX (1L << 7) /*drop index online*/
#define HA_ONLINE_ADD_UNIQUE_INDEX (1L << 8) /*add unique online*/
#define HA_ONLINE_DROP_UNIQUE_INDEX (1L << 9) /*drop uniq. online*/
#define HA_ONLINE_ADD_PK_INDEX (1L << 10)/*add prim. online*/
#define HA_ONLINE_DROP_PK_INDEX (1L << 11)/*drop prim. online*/
#define HA_INPLACE_ADD_INDEX_NO_WRITE (1L << 6)
#define HA_INPLACE_DROP_INDEX_NO_WRITE (1L << 7)
#define HA_INPLACE_ADD_UNIQUE_INDEX_NO_WRITE (1L << 8)
#define HA_INPLACE_DROP_UNIQUE_INDEX_NO_WRITE (1L << 9)
#define HA_INPLACE_ADD_PK_INDEX_NO_WRITE (1L << 10)
#define HA_INPLACE_DROP_PK_INDEX_NO_WRITE (1L << 11)
/*
HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is
supported at all.

View file

@ -1,7 +1,7 @@
#ifndef ITEM_INCLUDED
#define ITEM_INCLUDED
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
#ifndef ITEM_FUNC_INCLUDED
#define ITEM_FUNC_INCLUDED
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
#ifndef ITEM_TIMEFUNC_INCLUDED
#define ITEM_TIMEFUNC_INCLUDED
/* Copyright (C) 2000-2006 MySQL AB
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -272,10 +272,11 @@ const char *set_thd_proc_info(void *thd_arg, const char *info,
thd= current_thd;
const char *old_info= thd->proc_info;
DBUG_PRINT("proc_info", ("%s:%d %s", calling_file, calling_line,
(info != NULL) ? info : "(null)"));
const char *basename= calling_file ? base_name(calling_file) : NULL;
DBUG_PRINT("proc_info", ("%s:%d %s", basename, calling_line, info));
#if defined(ENABLED_PROFILING)
thd->profiling.status_change(info, calling_function, calling_file, calling_line);
thd->profiling.status_change(info, calling_function, basename, calling_line);
#endif
thd->proc_info= info;
return old_info;

View file

@ -1,4 +1,4 @@
/* Copyright 2005-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
/* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -1,4 +1,4 @@
/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -4745,7 +4745,7 @@ err:
@details Checks if any index is being modified (present as both DROP INDEX
and ADD INDEX) in the current ALTER TABLE statement. Needed for disabling
online ALTER TABLE.
in-place ALTER TABLE.
@param table The table being altered
@param alter_info The ALTER TABLE structure
@ -4861,7 +4861,7 @@ mysql_compare_tables(TABLE *table,
like to keep mysql_compare_tables() idempotent (not altering any
of the arguments) we create a copy of alter_info here and
pass it to mysql_prepare_create_table, then use the result
to evaluate possibility of fast ALTER TABLE, and then
to evaluate possibility of in-place ALTER TABLE, and then
destroy the copy.
*/
Alter_info tmp_alter_info(*alter_info, thd->mem_root);
@ -4902,9 +4902,9 @@ mysql_compare_tables(TABLE *table,
There was a bug prior to mysql-4.0.25. Number of null fields was
calculated incorrectly. As a result frm and data files gets out of
sync after fast alter table. There is no way to determine by which
sync after in-place alter table. There is no way to determine by which
mysql version (in 4.0 and 4.1 branches) table was created, thus we
disable fast alter table for all tables created by mysql versions
disable in-place alter table for all tables created by mysql versions
prior to 5.0 branch.
See BUG#6236.
*/
@ -4927,7 +4927,7 @@ mysql_compare_tables(TABLE *table,
}
/*
Use transformed info to evaluate possibility of fast ALTER TABLE
Use transformed info to evaluate possibility of in-place ALTER TABLE
but use the preserved field to persist modifications.
*/
new_field_it.init(alter_info->create_list);
@ -5207,7 +5207,7 @@ blob_length_by_type(enum_field_types type)
semantic checks.
This function is invoked when we know that we're going to
perform ALTER TABLE via a temporary table -- i.e. fast ALTER TABLE
perform ALTER TABLE via a temporary table -- i.e. in-place ALTER TABLE
is not possible, perhaps because the ALTER statement contains
instructions that require change in table data, not only in
table definition or indexes.
@ -6102,7 +6102,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
/*
If there are index changes only, try to do them online. "Index
If there are index changes only, try to do them in-place. "Index
changes only" means also that the handler for the table does not
change. The table is open and locked. The handler can be accessed.
*/
@ -6110,8 +6110,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
int pk_changed= 0;
ulong alter_flags= 0;
ulong needed_online_flags= 0;
ulong needed_fast_flags= 0;
ulong needed_inplace_with_read_flags= 0;
ulong needed_inplace_flags= 0;
KEY *key;
uint *idx_p;
uint *idx_end_p;
@ -6135,8 +6135,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
DBUG_PRINT("info", ("Dropping primary key"));
/* Primary key. */
needed_online_flags|= HA_ONLINE_DROP_PK_INDEX;
needed_fast_flags|= HA_ONLINE_DROP_PK_INDEX_NO_WRITES;
needed_inplace_with_read_flags|= HA_INPLACE_DROP_PK_INDEX_NO_WRITE;
needed_inplace_flags|= HA_INPLACE_DROP_PK_INDEX_NO_READ_WRITE;
pk_changed++;
candidate_key_count--;
}
@ -6146,8 +6146,9 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
bool is_candidate_key= true;
/* Non-primary unique key. */
needed_online_flags|= HA_ONLINE_DROP_UNIQUE_INDEX;
needed_fast_flags|= HA_ONLINE_DROP_UNIQUE_INDEX_NO_WRITES;
needed_inplace_with_read_flags|=
HA_INPLACE_DROP_UNIQUE_INDEX_NO_WRITE;
needed_inplace_flags|= HA_INPLACE_DROP_UNIQUE_INDEX_NO_READ_WRITE;
/*
Check if all fields in key are declared
@ -6166,12 +6167,13 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
else
{
/* Non-unique key. */
needed_online_flags|= HA_ONLINE_DROP_INDEX;
needed_fast_flags|= HA_ONLINE_DROP_INDEX_NO_WRITES;
needed_inplace_with_read_flags|= HA_INPLACE_DROP_INDEX_NO_WRITE;
needed_inplace_flags|= HA_INPLACE_DROP_INDEX_NO_READ_WRITE;
}
}
no_pk= ((table->s->primary_key == MAX_KEY) ||
(needed_online_flags & HA_ONLINE_DROP_PK_INDEX));
(needed_inplace_with_read_flags &
HA_INPLACE_DROP_PK_INDEX_NO_WRITE));
/* Check added indexes. */
for (idx_p= index_add_buffer, idx_end_p= idx_p + index_add_count;
idx_p < idx_end_p;
@ -6209,57 +6211,59 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
DBUG_PRINT("info", ("Adding primary key"));
/* Primary key. */
needed_online_flags|= HA_ONLINE_ADD_PK_INDEX;
needed_fast_flags|= HA_ONLINE_ADD_PK_INDEX_NO_WRITES;
needed_inplace_with_read_flags|= HA_INPLACE_ADD_PK_INDEX_NO_WRITE;
needed_inplace_flags|= HA_INPLACE_ADD_PK_INDEX_NO_READ_WRITE;
pk_changed++;
no_pk= false;
}
else
{
/* Non-primary unique key. */
needed_online_flags|= HA_ONLINE_ADD_UNIQUE_INDEX;
needed_fast_flags|= HA_ONLINE_ADD_UNIQUE_INDEX_NO_WRITES;
needed_inplace_with_read_flags|= HA_INPLACE_ADD_UNIQUE_INDEX_NO_WRITE;
needed_inplace_flags|= HA_INPLACE_ADD_UNIQUE_INDEX_NO_READ_WRITE;
}
}
else
{
/* Non-unique key. */
needed_online_flags|= HA_ONLINE_ADD_INDEX;
needed_fast_flags|= HA_ONLINE_ADD_INDEX_NO_WRITES;
needed_inplace_with_read_flags|= HA_INPLACE_ADD_INDEX_NO_WRITE;
needed_inplace_flags|= HA_INPLACE_ADD_INDEX_NO_READ_WRITE;
}
}
if ((candidate_key_count > 0) &&
(needed_online_flags & HA_ONLINE_DROP_PK_INDEX))
if ((candidate_key_count > 0) &&
(needed_inplace_with_read_flags & HA_INPLACE_DROP_PK_INDEX_NO_WRITE))
{
/*
Dropped primary key when there is some other unique
not null key that should be converted to primary key
*/
needed_online_flags|= HA_ONLINE_ADD_PK_INDEX;
needed_fast_flags|= HA_ONLINE_ADD_PK_INDEX_NO_WRITES;
needed_inplace_with_read_flags|= HA_INPLACE_ADD_PK_INDEX_NO_WRITE;
needed_inplace_flags|= HA_INPLACE_ADD_PK_INDEX_NO_READ_WRITE;
pk_changed= 2;
}
DBUG_PRINT("info", ("needed_online_flags: 0x%lx, needed_fast_flags: 0x%lx",
needed_online_flags, needed_fast_flags));
DBUG_PRINT("info",
("needed_inplace_with_read_flags: 0x%lx, needed_inplace_flags: 0x%lx",
needed_inplace_with_read_flags, needed_inplace_flags));
/*
Online or fast add/drop index is possible only if
In-place add/drop index is possible only if
the primary key is not added and dropped in the same statement.
Otherwise we have to recreate the table.
need_copy_table is no-zero at this place.
*/
if ( pk_changed < 2 )
{
if ((alter_flags & needed_online_flags) == needed_online_flags)
if ((alter_flags & needed_inplace_with_read_flags) ==
needed_inplace_with_read_flags)
{
/* All required online flags are present. */
/* All required in-place flags to allow concurrent reads are present. */
need_copy_table= ALTER_TABLE_METADATA_ONLY;
need_lock_for_indexes= FALSE;
}
else if ((alter_flags & needed_fast_flags) == needed_fast_flags)
else if ((alter_flags & needed_inplace_flags) == needed_inplace_flags)
{
/* All required fast flags are present. */
/* All required in-place flags are present. */
need_copy_table= ALTER_TABLE_METADATA_ONLY;
}
}
@ -6413,10 +6417,18 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
else
{
if (!table->s->tmp_table &&
/*
Ensure that we will upgrade the metadata lock if
handler::enable/disable_indexes() will be called.
*/
if (alter_info->keys_onoff != LEAVE_AS_IS ||
table->file->indexes_are_disabled())
need_lock_for_indexes= true;
if (!table->s->tmp_table && need_lock_for_indexes &&
wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN))
goto err_new_table_cleanup;
thd_proc_info(thd, "manage keys");
DEBUG_SYNC(thd, "alter_table_manage_keys");
alter_table_manage_keys(table, table->file->indexes_are_disabled(),
alter_info->keys_onoff);
error= trans_commit_stmt(thd);

View file

@ -1,4 +1,4 @@
/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -2574,11 +2574,12 @@ innobase_alter_table_flags(
/*=======================*/
uint flags)
{
return(HA_ONLINE_ADD_INDEX_NO_WRITES
| HA_ONLINE_DROP_INDEX_NO_WRITES
| HA_ONLINE_ADD_UNIQUE_INDEX_NO_WRITES
| HA_ONLINE_DROP_UNIQUE_INDEX_NO_WRITES
| HA_ONLINE_ADD_PK_INDEX_NO_WRITES);
return(HA_INPLACE_ADD_INDEX_NO_READ_WRITE
| HA_INPLACE_ADD_INDEX_NO_WRITE
| HA_INPLACE_DROP_INDEX_NO_READ_WRITE
| HA_INPLACE_ADD_UNIQUE_INDEX_NO_READ_WRITE
| HA_INPLACE_DROP_UNIQUE_INDEX_NO_READ_WRITE
| HA_INPLACE_ADD_PK_INDEX_NO_READ_WRITE);
}
/*****************************************************************//**