Commit 82975297 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge branch '10.0' into 10.1

parents 4c91fd4c eb389d5c
......@@ -11,14 +11,14 @@
--- old/mysql-test/mysql-test-run.pl 2009-06-16 14:24:09.000000000 +0200
+++ new/mysql-test/mysql-test-run.pl 2009-07-04 00:03:34.000000000 +0200
@@ -3578,6 +3578,11 @@ sub mysql_install_db {
mtr_appendfile_to_file("$sql_dir/mysql_system_tables_data.sql",
$bootstrap_sql_file);
mtr_appendfile_to_file("$sql_dir/mysql_system_tables_data.sql",
$bootstrap_sql_file);
+ mtr_tofile($bootstrap_sql_file, "-- Debian removed the default privileges on the 'test' database\n");
+ mtr_tofile($bootstrap_sql_file, "INSERT INTO mysql.db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y');\n");
+ mtr_tofile($bootstrap_sql_file, "INSERT INTO mysql.db VALUES ('%','test\\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y');\n");
+
+ mtr_tofile($bootstrap_sql_file, "-- Debian removed the default privileges on the 'test' database\n");
+ mtr_tofile($bootstrap_sql_file, "INSERT INTO mysql.db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y');\n");
+ mtr_tofile($bootstrap_sql_file, "INSERT INTO mysql.db VALUES ('%','test\\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y');\n");
+
# Add test data for timezone - this is just a subset, on a real
# system these tables will be populated either by mysql_tzinfo_to_sql
# or by downloading the timezone table package from our website
+
# Add test data for timezone - this is just a subset, on a real
# system these tables will be populated either by mysql_tzinfo_to_sql
# or by downloading the timezone table package from our website
# ==== Usage ====
#
# [--let $restart_parameters= --innodb-force-recovery=0 --innodb-read-only=1]
# [--let $mysqld_stub_cmd= $MYSQLD_LAST_CMD]
# [--let $error_log= $MYSQLTEST_VARDIR/log/mysqld.1.err]
# --source include/fail_restart_mysqld.inc
# Evaluate the default of $error_log
if (!$error_log)
{
--let $error_log= $MYSQLTEST_VARDIR/log/mysqld.1.err
}
--error 1
--exec $mysqld_stub_cmd $restart_parameters >> $error_log 2>&1
# As the server is stopped
--disable_reconnect
......@@ -31,7 +31,7 @@ if ($shutdown_timeout == 0)
--exec echo "wait" > $_expect_file_name
# Send shutdown to the connected server and give
# it 10 seconds to die before zapping it
# it an opted number of seconds to die before zapping it
shutdown_server $server_shutdown_timeout;
# Write file to make mysql-test-run.pl start up the server again
......
# Purpose:
# Simple search with Perl for a pattern in some file.
#
# The advantages compared to thinkable auxiliary constructs using the
# mysqltest language and SQL are:
# 1. We do not need a running MySQL server.
# 2. SQL causes "noise" during debugging and increases the size of logs.
# Perl code does not disturb at all.
#
# The environment variables SEARCH_FILE and SEARCH_PATTERN must be set
# before sourcing this routine.
#
# Optionally, SEARCH_RANGE can be set to the max number of bytes of the file
# to search. If negative, it will search that many bytes at the end of the
# file. By default the search happens from the last CURRENT_TEST:
# marker till the end of file (appropriate for searching error logs).
#
# Optionally, SEARCH_ABORT can be set to "FOUND" or "NOT FOUND" and this
# will abort if the search result doesn't match the requested one.
#
# In case of
# - SEARCH_FILE and/or SEARCH_PATTERN is not set
# - SEARCH_FILE cannot be opened
# the test will abort immediate.
#
# Typical use case (check invalid server startup options):
# let $error_log= $MYSQLTEST_VARDIR/log/my_restart.err;
# --error 0,1
# --remove_file $error_log
# let SEARCH_FILE= $error_log;
# # Stop the server
# let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
# --exec echo "wait" > $restart_file
# --shutdown_server 10
# --source include/wait_until_disconnected.inc
#
# --error 1
# --exec $MYSQLD_CMD <whatever wrong setting> > $error_log 2>&1
# # The server restart aborts
# let SEARCH_PATTERN= \[ERROR\] Aborting;
# --source include/search_pattern_in_file.inc
#
# Created: 2011-11-11 mleich
#
perl;
use strict;
die "SEARCH_FILE not set" unless $ENV{SEARCH_FILE};
my @search_files= glob($ENV{SEARCH_FILE});
my $search_pattern= $ENV{SEARCH_PATTERN} or die "SEARCH_PATTERN not set";
my $search_range= $ENV{SEARCH_RANGE};
my $content;
foreach my $search_file (@search_files) {
open(FILE, '<', $search_file) || die("Can't open file $search_file: $!");
my $file_content;
if ($search_range > 0) {
read(FILE, $file_content, $search_range, 0);
} elsif ($search_range < 0) {
my $size= -s $search_file;
$search_range = -$size if $size > -$search_range;
seek(FILE, $search_range, 2);
read(FILE, $file_content, -$search_range, 0);
} else {
while(<FILE>) { # error log
if (/^CURRENT_TEST:/) {
$content='';
} else {
$content.=$_;
}
}
}
close(FILE);
$content.= $file_content;
}
my @matches=($content =~ m/$search_pattern/gs);
my $res=@matches ? "FOUND " . scalar(@matches) : "NOT FOUND";
$ENV{SEARCH_FILE} =~ s{^.*?([^/\\]+)$}{$1};
print "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n";
exit $ENV{SEARCH_ABORT} && $res =~ /^$ENV{SEARCH_ABORT}/;
EOF
# ==== Usage ====
#
# [--let $shutdown_timeout= 30]
# [--let $allow_rpl_inited= 1]
# --source include/shutdown_mysqld.inc
# The default value is empty
--let $server_shutdown_timeout=
if ($shutdown_timeout)
{
--let $server_shutdown_timeout= $shutdown_timeout
}
# This is the first half of include/restart_mysqld.inc.
if ($rpl_inited)
{
......@@ -13,6 +27,6 @@ if ($rpl_inited)
--exec echo "wait" > $_expect_file_name
# Send shutdown to the connected server
--shutdown_server
--shutdown_server $server_shutdown_timeout
--source include/wait_until_disconnected.inc
......@@ -3106,14 +3106,16 @@ sub mysql_install_db {
mtr_add_arg($args, "--bootstrap");
mtr_add_arg($args, "--basedir=%s", $install_basedir);
mtr_add_arg($args, "--datadir=%s", $install_datadir);
mtr_add_arg($args, "--plugin-dir=%s", $plugindir);
mtr_add_arg($args, "--default-storage-engine=myisam");
mtr_add_arg($args, "--skip-plugin-$_") for @optional_plugins;
mtr_add_arg($args, "--loose-skip-plugin-$_") for @optional_plugins;
# starting from 10.0 bootstrap scripts require InnoDB
mtr_add_arg($args, "--loose-innodb");
mtr_add_arg($args, "--loose-innodb-log-file-size=5M");
mtr_add_arg($args, "--disable-sync-frm");
mtr_add_arg($args, "--tmpdir=%s", "$opt_vardir/tmp/");
mtr_add_arg($args, "--core-file");
mtr_add_arg($args, "--console");
if ( $opt_debug )
{
......@@ -3132,13 +3134,6 @@ sub mysql_install_db {
mtr_add_arg($args, $extra_opt);
}
}
# InnoDB options can come not only from the command line, but also
# from option files or combinations
foreach my $extra_opt ( @$extra_opts ) {
if ($extra_opt =~ /--innodb/) {
mtr_add_arg($args, $extra_opt);
}
}
# If DISABLE_GRANT_OPTIONS is defined when the server is compiled (e.g.,
# configure --disable-grant-options), mysqld will not recognize the
......@@ -3153,98 +3148,108 @@ sub mysql_install_db {
# ----------------------------------------------------------------------
$ENV{'MYSQLD_BOOTSTRAP_CMD'}= "$exe_mysqld_bootstrap " . join(" ", @$args);
# Extra options can come not only from the command line, but also
# from option files or combinations. We want them on a command line
# that is executed now, because otherwise the datadir might be
# incompatible with the test settings, but not on the general
# $MYSQLD_BOOTSTRAP_CMD line
foreach my $extra_opt ( @$extra_opts ) {
mtr_add_arg($args, $extra_opt);
}
# ----------------------------------------------------------------------
# Create the bootstrap.sql file
# ----------------------------------------------------------------------
my $bootstrap_sql_file= "$opt_vardir/tmp/bootstrap.sql";
my $bootstrap_sql_file= "$opt_vardir/log/bootstrap.sql";
if ($opt_boot_gdb) {
gdb_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(),
$bootstrap_sql_file);
}
if ($opt_boot_dbx) {
dbx_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(),
$bootstrap_sql_file);
}
if ($opt_boot_ddd) {
ddd_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(),
$bootstrap_sql_file);
}
my $path_sql= my_find_file($install_basedir,
["mysql", "sql/share", "share/mariadb",
"share/mysql", "share", "scripts"],
"mysql_system_tables.sql",
NOT_REQUIRED);
if (-f $path_sql )
if (! -e $bootstrap_sql_file)
{
my $sql_dir= dirname($path_sql);
# Use the mysql database for system tables
mtr_tofile($bootstrap_sql_file, "use mysql;\n");
# Add the offical mysql system tables
# for a production system
mtr_appendfile_to_file("$sql_dir/mysql_system_tables.sql",
$bootstrap_sql_file);
if ($opt_boot_gdb) {
gdb_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(),
$bootstrap_sql_file);
}
if ($opt_boot_dbx) {
dbx_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(),
$bootstrap_sql_file);
}
if ($opt_boot_ddd) {
ddd_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(),
$bootstrap_sql_file);
}
# Add the performance tables
# for a production system
mtr_appendfile_to_file("$sql_dir/mysql_performance_tables.sql",
$bootstrap_sql_file);
my $path_sql= my_find_file($install_basedir,
["mysql", "sql/share", "share/mariadb",
"share/mysql", "share", "scripts"],
"mysql_system_tables.sql",
NOT_REQUIRED);
# Add the mysql system tables initial data
# for a production system
mtr_appendfile_to_file("$sql_dir/mysql_system_tables_data.sql",
$bootstrap_sql_file);
if (-f $path_sql )
{
my $sql_dir= dirname($path_sql);
# Use the mysql database for system tables
mtr_tofile($bootstrap_sql_file, "use mysql;\n");
# Add the offical mysql system tables
# for a production system
mtr_appendfile_to_file("$sql_dir/mysql_system_tables.sql",
$bootstrap_sql_file);
# Add the performance tables
# for a production system
mtr_appendfile_to_file("$sql_dir/mysql_performance_tables.sql",
$bootstrap_sql_file);
# Add the mysql system tables initial data
# for a production system
mtr_appendfile_to_file("$sql_dir/mysql_system_tables_data.sql",
$bootstrap_sql_file);
# Add test data for timezone - this is just a subset, on a real
# system these tables will be populated either by mysql_tzinfo_to_sql
# or by downloading the timezone table package from our website
mtr_appendfile_to_file("$sql_dir/mysql_test_data_timezone.sql",
$bootstrap_sql_file);
# Fill help tables, just an empty file when running from bk repo
# but will be replaced by a real fill_help_tables.sql when
# building the source dist
mtr_appendfile_to_file("$sql_dir/fill_help_tables.sql",
$bootstrap_sql_file);
# mysql.gtid_slave_pos was created in InnoDB, but many tests
# run without InnoDB. Alter it to MyISAM now
mtr_tofile($bootstrap_sql_file, "ALTER TABLE gtid_slave_pos ENGINE=MyISAM;\n");
}
else
{
# Install db from init_db.sql that exist in early 5.1 and 5.0
# versions of MySQL
my $init_file= "$install_basedir/mysql-test/lib/init_db.sql";
mtr_report(" - from '$init_file'");
my $text= mtr_grab_file($init_file) or
mtr_error("Can't open '$init_file': $!");
mtr_tofile($bootstrap_sql_file,
sql_to_bootstrap($text));
}
# Add test data for timezone - this is just a subset, on a real
# system these tables will be populated either by mysql_tzinfo_to_sql
# or by downloading the timezone table package from our website
mtr_appendfile_to_file("$sql_dir/mysql_test_data_timezone.sql",
$bootstrap_sql_file);
# Remove anonymous users
mtr_tofile($bootstrap_sql_file,
"DELETE FROM mysql.user where user= '';\n");
# Fill help tables, just an empty file when running from bk repo
# but will be replaced by a real fill_help_tables.sql when
# building the source dist
mtr_appendfile_to_file("$sql_dir/fill_help_tables.sql",
$bootstrap_sql_file);
# Create mtr database
mtr_tofile($bootstrap_sql_file,
"CREATE DATABASE mtr CHARSET=latin1;\n");
# mysql.gtid_slave_pos was created in InnoDB, but many tests
# run without InnoDB. Alter it to MyISAM now
mtr_tofile($bootstrap_sql_file, "ALTER TABLE gtid_slave_pos ENGINE=MyISAM;\n");
}
else
{
# Install db from init_db.sql that exist in early 5.1 and 5.0
# versions of MySQL
my $init_file= "$install_basedir/mysql-test/lib/init_db.sql";
mtr_report(" - from '$init_file'");
my $text= mtr_grab_file($init_file) or
mtr_error("Can't open '$init_file': $!");
# Add help tables and data for warning detection and supression
mtr_tofile($bootstrap_sql_file,
sql_to_bootstrap(mtr_grab_file("include/mtr_warnings.sql")));
# Add procedures for checking server is restored after testcase
mtr_tofile($bootstrap_sql_file,
sql_to_bootstrap($text));
sql_to_bootstrap(mtr_grab_file("include/mtr_check.sql")));
}
# Remove anonymous users
mtr_tofile($bootstrap_sql_file,
"DELETE FROM mysql.user where user= '';\n");
# Create mtr database
mtr_tofile($bootstrap_sql_file,
"CREATE DATABASE mtr CHARSET=latin1;\n");
# Add help tables and data for warning detection and supression
mtr_tofile($bootstrap_sql_file,
sql_to_bootstrap(mtr_grab_file("include/mtr_warnings.sql")));
# Add procedures for checking server is restored after testcase
mtr_tofile($bootstrap_sql_file,
sql_to_bootstrap(mtr_grab_file("include/mtr_check.sql")));
# Log bootstrap command
my $path_bootstrap_log= "$opt_vardir/log/bootstrap.log";
mtr_tofile($path_bootstrap_log,
......@@ -5168,6 +5173,11 @@ sub mysqld_start ($$) {
# Remember options used when starting
$mysqld->{'started_opts'}= $extra_opts;
# "Dynamic" version of MYSQLD_CMD is reevaluated with each mysqld_start.
# Use it to restart the server at testing a failing server start (e.g
# due to incompatible options).
$ENV{'MYSQLD_LAST_CMD'}= "$exe @$args";
return;
}
......
......@@ -1177,7 +1177,7 @@ character-sets-dir MYSQL_CHARSETSDIR/
chroot (No default value)
completion-type NO_CHAIN
concurrent-insert AUTO
console FALSE
console TRUE
date-format %Y-%m-%d
datetime-format %Y-%m-%d %H:%i:%s
deadlock-search-depth-long 15
......
call mtr.add_suppression("Can't init tc log");
call mtr.add_suppression("Found 1 prepared transactions!");
call mtr.add_suppression("Aborting");
set debug_sync='RESET';
CREATE TABLE t1 (i INT) ENGINE=InnoDB;
SET GLOBAL innodb_flush_log_at_trx_commit=1;
FLUSH TABLES;
set debug_sync='ha_commit_trans_after_prepare WAIT_FOR go';
INSERT INTO t1 VALUES (1);;
# Prove that no COMMIT or ROLLBACK occurred yet.
SELECT * FROM t1;
i
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM t1;
i
1
# Kill the server
FOUND 1 /was in the XA prepared state/ in mysqld.1.err
FOUND 1 /Found 1 prepared transactions!/ in mysqld.1.err
NOT FOUND /\[ERROR\] Can\'t init tc log/ in mysqld.1.err
FOUND 2 /was in the XA prepared state/ in mysqld.1.err
FOUND 1 /Found 1 prepared transactions!/ in mysqld.1.err
FOUND 1 /\[ERROR\] Can\'t init tc log/ in mysqld.1.err
FOUND 1 /Please restart mysqld without --tc-heuristic-recover/ in mysqld.1.err
FOUND 3 /was in the XA prepared state/ in mysqld.1.err
FOUND 1 /Found 1 prepared transactions!/ in mysqld.1.err
FOUND 2 /\[ERROR\] Can\'t init tc log/ in mysqld.1.err
FOUND 2 /Please restart mysqld without --tc-heuristic-recover/ in mysqld.1.err
FOUND 3 /was in the XA prepared state/ in mysqld.1.err
FOUND 1 /Found 1 prepared transactions!/ in mysqld.1.err
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
SELECT * FROM t1;
i
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM t1;
i
DROP TABLE t1;
# Export Table and Import from saved files .cfg and .ibd
# Caller should create t1 table definition and populate table
let $MYSQLD_DATADIR = `SELECT @@datadir`;
if(!$source_db) {
let $source_db = test;
}
if(!$dest_db) {
let $dest_db = test;
}
eval FLUSH TABLES $source_db.t1 FOR EXPORT;
--copy_file $MYSQLD_DATADIR/$source_db/t1.cfg $MYSQLD_DATADIR/t1.cfg_back
--copy_file $MYSQLD_DATADIR/$source_db/t1.ibd $MYSQLD_DATADIR/t1.ibd_back
UNLOCK TABLES;
if($source_db != $dest_db) {
eval USE $dest_db;
let $create1 = query_get_value(SHOW CREATE TABLE $source_db.t1, Create Table, 1);
eval $create1;
}
eval ALTER TABLE $dest_db.t1 DISCARD TABLESPACE;
--move_file $MYSQLD_DATADIR/t1.cfg_back $MYSQLD_DATADIR/$dest_db/t1.cfg
--move_file $MYSQLD_DATADIR/t1.ibd_back $MYSQLD_DATADIR/$dest_db/t1.ibd
eval ALTER TABLE $dest_db.t1 IMPORT TABLESPACE;
eval CHECK TABLE $dest_db.t1;
eval SHOW CREATE TABLE $dest_db.t1;
eval SELECT * FROM $dest_db.t1;
if($source_db != $dest_db) {
eval DROP TABLE $dest_db.t1;
}
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
#
# Show what happens during ALTER TABLE when an existing file
# exists in the target location.
#
# Bug #19218794: IF TABLESPACE EXISTS, CAN'T CREATE TABLE,
# BUT CAN ALTER ENGINE=INNODB
#
CREATE TABLE t1 (a SERIAL, b CHAR(10)) ENGINE=Memory;
INSERT INTO t1(b) VALUES('one'), ('two'), ('three');
#
# Create a file called MYSQLD_DATADIR/test/t1.ibd
# Directory listing of test/*.ibd
#
t1.ibd
ALTER TABLE t1 ENGINE = InnoDB;
ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 "Tablespace already exists")
#
# Move the file to InnoDB as t2
#
ALTER TABLE t1 RENAME TO t2, ENGINE = INNODB;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`b` char(10) DEFAULT NULL,
UNIQUE KEY `a` (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
SELECT * from t2;
a b
1 one
2 two
3 three
ALTER TABLE t2 RENAME TO t1;
ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 "Tablespace already exists")
#
# Create another t1, but in the system tablespace.
#
SET GLOBAL innodb_file_per_table=OFF;
CREATE TABLE t1 (a SERIAL, b CHAR(20)) ENGINE=InnoDB;
INSERT INTO t1(b) VALUES('one'), ('two'), ('three');
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`b` char(20) DEFAULT NULL,
UNIQUE KEY `a` (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1';
name space=0
test/t1 1
#
# ALTER TABLE from system tablespace to system tablespace
#
ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=INPLACE;
ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=COPY;
#
# Try to move t1 from the system tablespace to a file-per-table
# while a blocking t1.ibd file exists.
#
SET GLOBAL innodb_file_per_table=ON;
ALTER TABLE t1 ADD COLUMN e1 INT, ALGORITHM=INPLACE;
ERROR HY000: Tablespace for table 'test/t1' exists. Please DISCARD the tablespace before IMPORT.
ALTER TABLE t1 ADD COLUMN e2 INT, ALGORITHM=COPY;
ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 "Tablespace already exists")
#
# Delete the blocking file called MYSQLD_DATADIR/test/t1.ibd
# Move t1 to file-per-table using ALGORITHM=INPLACE with no blocking t1.ibd.
#
ALTER TABLE t1 ADD COLUMN e INT, ALGORITHM=INPLACE;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`b` char(20) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`d` int(11) DEFAULT NULL,
`e` int(11) DEFAULT NULL,
UNIQUE KEY `a` (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1';
name space=0
test/t1 0
DROP TABLE t1;
#
# Rename t2.ibd to t1.ibd.
#
ALTER TABLE t2 RENAME TO t1;
SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1';
name space=0
test/t1 0
SELECT * from t1;
a b
1 one
2 two
3 three
DROP TABLE t1;
SET @saved_debug_dbug = @@SESSION.debug_dbug;
#
#BUG#21326304 INNODB ONLINE ALTER TABLE ENDS IN CRASH ON DISK FULL
#
CREATE TABLE t1(f1 CHAR(255) NOT NULL, f2 CHAR(255) NOT NULL, f3
CHAR(255) NOT NULL, f4 CHAR(255) NOT NULL, f5 CHAR(255) NOT NULL,f6
CHAR(255) NOT NULL, f7 CHAR(255) NOT NULL, f8 CHAR(255) NOT NULL,f9
CHAR(255) NOT NULL, f10 CHAR(255) NOT NULL, f11 CHAR(255) NOT NULL,f12
CHAR(255) NOT NULL, f13 CHAR(255) NOT NULL, f14 CHAR(255) NOT NULL,f15
CHAR(255) NOT NULL, f16 CHAR(255) NOT NULL, f17 CHAR(255) NOT NULL,f18
CHAR(255) NOT NULL)
ENGINE=INNODB ROW_FORMAT=DYNAMIC;
Warnings:
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope.
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
INSERT INTO t1
VALUES('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r');
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
SET debug_dbug = '+d,disk_is_full';
ALTER TABLE t1 FORCE, ALGORITHM=INPLACE;
ERROR HY000: The table 't1' is full
SET debug_dbug= @saved_debug_dbug;
DROP TABLE t1;
#
# Bug#15923864 (Bug#67718):
# INNODB DRASTICALLY UNDER-FILLS PAGES IN CERTAIN CONDITIONS
#
SET GLOBAL innodb_file_per_table=ON;
CREATE TABLE t1 (a BIGINT PRIMARY KEY, b VARCHAR(4096)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (0, REPEAT('a', 4096));
INSERT INTO t1 VALUES (1000, REPEAT('a', 4096));
INSERT INTO t1 VALUES (1001, REPEAT('a', 4096));
INSERT INTO t1 VALUES (1002, REPEAT('a', 4096));
INSERT INTO t1 VALUES (1, REPEAT('a', 4096));
INSERT INTO t1 VALUES (2, REPEAT('a', 4096));
SELECT page_number, number_records
FROM information_schema.innodb_sys_tablespaces s1,
information_schema.innodb_buffer_page s2
WHERE s1.space = s2.space AND name = 'test/t1'
AND page_type = "INDEX" ORDER BY page_number;
page_number number_records
3 2
4 3
5 3
INSERT INTO t1 VALUES (999, REPEAT('a', 4096));
SELECT page_number, number_records
FROM information_schema.innodb_sys_tablespaces s1,
information_schema.innodb_buffer_page s2
WHERE s1.space = s2.space AND name = 'test/t1'
AND page_type = "INDEX" ORDER BY page_number;
page_number number_records
3 3
4 3
5 3
6 1
INSERT INTO t1 VALUES (998, REPEAT('a', 4096));
SELECT page_number, number_records
FROM information_schema.innodb_sys_tablespaces s1,
information_schema.innodb_buffer_page s2
WHERE s1.space = s2.space AND name = 'test/t1'
AND page_type = "INDEX" ORDER BY page_number;
page_number number_records
3 3
4 3
5 3
6 2
INSERT INTO t1 VALUES (997, REPEAT('a', 4096));
SELECT page_number, number_records
FROM information_schema.innodb_sys_tablespaces s1,
information_schema.innodb_buffer_page s2
WHERE s1.space = s2.space AND name = 'test/t1'
AND page_type = "INDEX" ORDER BY page_number;
page_number number_records
3 3
4 3
5 3
6 3
DROP TABLE t1;
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES(347),(33101),(123),(45),(6);
SET @old_sql_mode = @@sql_mode;
SET @@sql_mode = 'STRICT_TRANS_TABLES';
ALTER TABLE t1 ADD PRIMARY KEY(a);
SET @@sql_mode = @old_sql_mode;
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
LOCK=NONE;
ERROR 0A000: LOCK=NONE is not supported. Reason: Adding an auto-increment column requires a lock. Try LOCK=SHARED.
ALTER TABLE t1 ADD id INT AUTO_INCREMENT;
ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
ALTER TABLE t1 ADD id INT AUTO_INCREMENT, ADD INDEX(a, id);
ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a);
SELECT * FROM t1;
a id
6 0
45 0
123 0
347 0
33101 0
SET AUTO_INCREMENT_INCREMENT = 5, AUTO_INCREMENT_OFFSET = 30;
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1
BEGIN;
INSERT INTO t1 VALUES(7,0);
SELECT * FROM t1;
a id
6 45
45 50
123 55
347 60
33101 65
7 70
ROLLBACK;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=latin1
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, LOCK=NONE;
ERROR 0A000: LOCK=NONE is not supported. Reason: Adding an auto-increment column requires a lock. Try LOCK=SHARED.
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE;
SELECT * FROM t1;
a id
6 45
45 50
123 55
347 60
33101 65
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1
INSERT INTO t1 SET a=123;
INSERT INTO t1 VALUES(-123,-45);
ALTER TABLE t1 AUTO_INCREMENT = 75;
INSERT INTO t1 SET a=123;
SELECT * FROM t1;
a id
-123 -45
6 45
45 50
123 55
347 60
33101 65
123 70
123 75
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=80 DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES(347),(33101),(123),(45),(6);
ALTER TABLE t1 ADD PRIMARY KEY(a);
ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a);
SELECT * FROM t1;
a id
6 0
45 0
123 0
347 0
33101 0
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1
BEGIN;
INSERT INTO t1 VALUES(7,0);
SELECT * FROM t1;
a id
6 45
45 50
123 55
347 60
33101 65
7 70
ROLLBACK;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=latin1
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY;
SELECT * FROM t1;
a id
6 45
45 50
123 55
347 60
33101 65
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=latin1
INSERT INTO t1 SET a=123;
INSERT INTO t1 VALUES(-123,-45);
ALTER TABLE t1 AUTO_INCREMENT = 75;
INSERT INTO t1 SET a=123;
SELECT * FROM t1;
a id
-123 -45
6 45
45 50
123 55
347 60
33101 65
123 75
123 80
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=latin1
DROP TABLE t1;
This diff is collapsed.
set global innodb_file_per_table=on;
set global innodb_file_format='Barracuda';
CREATE TABLE t1(c1 INT NOT NULL, c2 INT, PRIMARY KEY(c1)) Engine=InnoDB;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5);
SET @saved_debug_dbug = @@SESSION.debug_dbug;
SET DEBUG_DBUG='+d,ib_build_indexes_too_many_concurrent_trxs, ib_rename_indexes_too_many_concurrent_trxs, ib_drop_index_too_many_concurrent_trxs';
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
ERROR HY000: Too many active concurrent transactions
SET DEBUG_DBUG = @saved_debug_dbug;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX(c2))
ENGINE=InnoDB;
INSERT INTO bug13861218 VALUES (8, 0), (4, 0), (0, 0);
SET DEBUG_DBUG = '+d,ib_row_merge_buf_add_two';
CREATE UNIQUE INDEX ui ON bug13861218(c1);
SET DEBUG_DBUG = @saved_debug_dbug;
DROP TABLE bug13861218;
CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT UNIQUE) ENGINE=InnoDB;
INSERT INTO bug13861218 VALUES (8, NULL), (4, NULL), (0, NULL);
SET DEBUG_DBUG = '+d,ib_row_merge_buf_add_two';
CREATE UNIQUE INDEX ui ON bug13861218(c1);
SET DEBUG_DBUG = @saved_debug_dbug;
DROP TABLE bug13861218;
set global innodb_file_per_table=1;
set global innodb_file_format=Antelope;
set global innodb_file_format_max=Antelope;
#
# Bug #21762319 ADDING INDEXES ON EMPTY TABLE IS SLOW
# WITH LARGE INNODB_SORT_BUFFER_SIZE.
call mtr.add_suppression("InnoDB: Cannot create temporary merge file");
create table t480(a serial)engine=innodb;
insert into t480
values(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),
(),(),(),(),(),(),(),();
insert into t480 select 0 from t480;
insert into t480 select 0 from t480;
insert into t480 select 0 from t480;
insert into t480 select 0 from t480;
create table t1(f1 int auto_increment not null,
f2 char(200) not null, f3 char(200) not null,
f4 char(200) not null,primary key(f1))engine=innodb;
insert into t1 select NULL,'aaa','bbb','ccc' from t480;
insert into t1 select NULL,'aaaa','bbbb','cccc' from t480;
insert into t1 select NULL,'aaaaa','bbbbb','ccccc' from t480;
insert into t1 select NULL,'aaaaaa','bbbbbb','cccccc' from t480;
insert into t1 select NULL,'aaaaaaa','bbbbbbb','ccccccc' from t480;
insert into t1 select NULL,'aaaaaaaa','bbbbbbbb','cccccccc' from t480;
select count(*) from t1;
count(*)
2880
SET DEBUG_DBUG = '+d,innobase_tmpfile_creation_failure';
alter table t1 force, algorithm=inplace;
ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
SET DEBUG_DBUG = @saved_debug_dbug;
drop table t1, t480;
CREATE TABLE t (a INT PRIMARY KEY, b INT NOT NULL) ENGINE=InnoDB;
INSERT INTO t VALUES(1,2),(2,3);
SET DEBUG_SYNC='alter_table_inplace_after_lock_downgrade SIGNAL do WAIT_FOR m';
SET DEBUG_SYNC='innodb_after_inplace_alter_table SIGNAL scanned WAIT_FOR done';
CREATE INDEX tb ON t(b);
SET DEBUG_SYNC='now WAIT_FOR do';
SET DEBUG_SYNC='row_update_for_mysql_error SIGNAL m WAIT_FOR scanned';
UPDATE t SET a=2 WHERE a=1;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
call mtr.add_suppression('InnoDB: record in index .*tb was not found on rollback, trying to insert');
SET DEBUG_SYNC='now SIGNAL done';
SET DEBUG_SYNC='RESET';
DROP TABLE t;
This diff is collapsed.
CREATE TABLE t (a INT PRIMARY KEY, c TEXT) ENGINE=InnoDB;
CREATE TABLE u (a INT PRIMARY KEY, b INT, c INT NOT NULL) ENGINE=InnoDB;
INSERT INTO t VALUES (1,'aa');
BEGIN;
INSERT INTO u SET a=1, c=1;
INSERT INTO u SELECT a+1,NULL,a+1 FROM u;
INSERT INTO u SELECT a+2,NULL,a+2 FROM u;
INSERT INTO u SELECT a+4,NULL,a+4 FROM u;
INSERT INTO u SELECT a+8,NULL,a+8 FROM u;
INSERT INTO u SELECT a+16,NULL,a+16 FROM u;
INSERT INTO u SELECT a+32,NULL,a+32 FROM u;
INSERT INTO u SELECT a+64,NULL,a+64 FROM u;
INSERT INTO u SELECT a+128,NULL,a+64 FROM u;
INSERT INTO u SELECT a+256,NULL,a+64 FROM u;
COMMIT;
BEGIN;
DELETE FROM u;
SET DEBUG_SYNC='row_log_apply_before SIGNAL created_u WAIT_FOR dml_done_u';
ALTER TABLE u ADD INDEX (c);
COMMIT;
SET DEBUG_SYNC='now WAIT_FOR created_u';
SELECT state FROM information_schema.processlist
WHERE info='ALTER TABLE u ADD INDEX (c)';
state
debug sync point: row_log_apply_before
SET DEBUG_SYNC='row_log_apply_before SIGNAL created_t WAIT_FOR dml_done_t';
CREATE INDEX c1 ON t (c(1));
SET DEBUG_SYNC='now WAIT_FOR created_t';
UPDATE t SET c='ab';
SELECT SLEEP(10);
SLEEP(10)
0
SET DEBUG_SYNC='now SIGNAL dml_done_u';
SET DEBUG_SYNC='now SIGNAL dml_done_t';
SET DEBUG_SYNC='RESET';
DROP TABLE t,u;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
--echo #
--echo # Show what happens during ALTER TABLE when an existing file
--echo # exists in the target location.
--echo #
--echo # Bug #19218794: IF TABLESPACE EXISTS, CAN'T CREATE TABLE,
--echo # BUT CAN ALTER ENGINE=INNODB
--echo #
--source include/have_innodb.inc
--disable_query_log
LET $MYSQLD_DATADIR = `select @@datadir`;
SET @old_innodb_file_per_table = @@innodb_file_per_table;
--enable_query_log
CREATE TABLE t1 (a SERIAL, b CHAR(10)) ENGINE=Memory;
INSERT INTO t1(b) VALUES('one'), ('two'), ('three');
--echo #
--echo # Create a file called MYSQLD_DATADIR/test/t1.ibd
--exec echo "This is not t1.ibd" > $MYSQLD_DATADIR/test/t1.ibd
--echo # Directory listing of test/*.ibd
--echo #
--list_files $MYSQLD_DATADIR/test/ *.ibd
--replace_regex /Error on rename of '.*' to '.*'/Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME'/
--error ER_ERROR_ON_RENAME
ALTER TABLE t1 ENGINE = InnoDB;
--echo #
--echo # Move the file to InnoDB as t2
--echo #
ALTER TABLE t1 RENAME TO t2, ENGINE = INNODB;
SHOW CREATE TABLE t2;
SELECT * from t2;
--replace_regex /Error on rename of '.*' to '.*'/Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME'/
--error ER_ERROR_ON_RENAME
ALTER TABLE t2 RENAME TO t1;
--echo #
--echo # Create another t1, but in the system tablespace.
--echo #
SET GLOBAL innodb_file_per_table=OFF;
CREATE TABLE t1 (a SERIAL, b CHAR(20)) ENGINE=InnoDB;
INSERT INTO t1(b) VALUES('one'), ('two'), ('three');
SHOW CREATE TABLE t1;
SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1';
--echo #
--echo # ALTER TABLE from system tablespace to system tablespace
--echo #
ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=INPLACE;
ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=COPY;
--echo #
--echo # Try to move t1 from the system tablespace to a file-per-table
--echo # while a blocking t1.ibd file exists.
--echo #
SET GLOBAL innodb_file_per_table=ON;
--replace_regex /$MYSQLD_DATADIR/MYSQLD_DATADIR/
--error ER_TABLESPACE_EXISTS
ALTER TABLE t1 ADD COLUMN e1 INT, ALGORITHM=INPLACE;
--replace_regex /Error on rename of '.*' to '.*'/Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME'/
--error ER_ERROR_ON_RENAME
ALTER TABLE t1 ADD COLUMN e2 INT, ALGORITHM=COPY;
--echo #
--echo # Delete the blocking file called MYSQLD_DATADIR/test/t1.ibd
--remove_file $MYSQLD_DATADIR/test/t1.ibd
--echo # Move t1 to file-per-table using ALGORITHM=INPLACE with no blocking t1.ibd.
--echo #
ALTER TABLE t1 ADD COLUMN e INT, ALGORITHM=INPLACE;
SHOW CREATE TABLE t1;
SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1';
DROP TABLE t1;
--echo #
--echo # Rename t2.ibd to t1.ibd.
--echo #
ALTER TABLE t2 RENAME TO t1;
SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1';
SELECT * from t1;
DROP TABLE t1;
--disable_query_log
call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot rename '.*' to '.*' for space ID .* because the target file exists. Remove the target file and try again");
SET GLOBAL innodb_file_per_table = @old_innodb_file_per_table;
--enable_query_log
--source include/have_innodb.inc
--source include/have_innodb_16k.inc
--source include/have_debug.inc
SET @saved_debug_dbug = @@SESSION.debug_dbug;
--echo #
--echo #BUG#21326304 INNODB ONLINE ALTER TABLE ENDS IN CRASH ON DISK FULL
--echo #
CREATE TABLE t1(f1 CHAR(255) NOT NULL, f2 CHAR(255) NOT NULL, f3
CHAR(255) NOT NULL, f4 CHAR(255) NOT NULL, f5 CHAR(255) NOT NULL,f6
CHAR(255) NOT NULL, f7 CHAR(255) NOT NULL, f8 CHAR(255) NOT NULL,f9
CHAR(255) NOT NULL, f10 CHAR(255) NOT NULL, f11 CHAR(255) NOT NULL,f12
CHAR(255) NOT NULL, f13 CHAR(255) NOT NULL, f14 CHAR(255) NOT NULL,f15
CHAR(255) NOT NULL, f16 CHAR(255) NOT NULL, f17 CHAR(255) NOT NULL,f18
CHAR(255) NOT NULL)
ENGINE=INNODB ROW_FORMAT=DYNAMIC;
INSERT INTO t1
VALUES('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r');
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
SET debug_dbug = '+d,disk_is_full';
--error ER_RECORD_FILE_FULL
ALTER TABLE t1 FORCE, ALGORITHM=INPLACE;
SET debug_dbug= @saved_debug_dbug;
DROP TABLE t1;
-- source include/have_innodb.inc
-- source include/have_innodb_16k.inc
--echo #
--echo # Bug#15923864 (Bug#67718):
--echo # INNODB DRASTICALLY UNDER-FILLS PAGES IN CERTAIN CONDITIONS
--echo #
# InnoDB should try to insert to the next page before split,
# if the insert record for split_and_insert is last of the page.
# Otherwise, the follwing records 999,998,997 cause each page per record.
#
--disable_query_log
SET @old_innodb_file_per_table = @@innodb_file_per_table;
--enable_query_log
SET GLOBAL innodb_file_per_table=ON;
CREATE TABLE t1 (a BIGINT PRIMARY KEY, b VARCHAR(4096)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (0, REPEAT('a', 4096));
INSERT INTO t1 VALUES (1000, REPEAT('a', 4096));
INSERT INTO t1 VALUES (1001, REPEAT('a', 4096));
INSERT INTO t1 VALUES (1002, REPEAT('a', 4096));
INSERT INTO t1 VALUES (1, REPEAT('a', 4096));
INSERT INTO t1 VALUES (2, REPEAT('a', 4096));
# | 0, 1, 2 | 1000, 1001, 1002|
SELECT page_number, number_records
FROM information_schema.innodb_sys_tablespaces s1,
information_schema.innodb_buffer_page s2
WHERE s1.space = s2.space AND name = 'test/t1'
AND page_type = "INDEX" ORDER BY page_number;
INSERT INTO t1 VALUES (999, REPEAT('a', 4096));
# try to insert '999' to the end of '0,1,2' page, but no space
# the next '1000,1001,1002' page has also no space.
# | 0, 1, 2 | 999 | 1000, 1001, 1002|
SELECT page_number, number_records
FROM information_schema.innodb_sys_tablespaces s1,
information_schema.innodb_buffer_page s2
WHERE s1.space = s2.space AND name = 'test/t1'
AND page_type = "INDEX" ORDER BY page_number;
INSERT INTO t1 VALUES (998, REPEAT('a', 4096));
# try to insert to the end of '0,1,2' page, but no space
# the next '998' page has space.
# | 0, 1, 2 | 998, 999 | 1000, 1001, 1002|
SELECT page_number, number_records
FROM information_schema.innodb_sys_tablespaces s1,
information_schema.innodb_buffer_page s2
WHERE s1.space = s2.space AND name = 'test/t1'
AND page_type = "INDEX" ORDER BY page_number;
INSERT INTO t1 VALUES (997, REPEAT('a', 4096));
# same
# | 0, 1, 2 | 997, 998, 999 | 1000, 1001, 1002|
SELECT page_number, number_records
FROM information_schema.innodb_sys_tablespaces s1,
information_schema.innodb_buffer_page s2
WHERE s1.space = s2.space AND name = 'test/t1'
AND page_type = "INDEX" ORDER BY page_number;
DROP TABLE t1;
--disable_query_log
SET GLOBAL innodb_file_per_table = @old_innodb_file_per_table;
--enable_query_log
--source include/have_innodb.inc
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES(347),(33101),(123),(45),(6);
# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on.
SET @old_sql_mode = @@sql_mode;
SET @@sql_mode = 'STRICT_TRANS_TABLES';
ALTER TABLE t1 ADD PRIMARY KEY(a);
SET @@sql_mode = @old_sql_mode;
# We cannot assign AUTO_INCREMENT values during online index creation.
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
LOCK=NONE;
--error ER_WRONG_AUTO_KEY
ALTER TABLE t1 ADD id INT AUTO_INCREMENT;
--error ER_WRONG_AUTO_KEY
ALTER TABLE t1 ADD id INT AUTO_INCREMENT, ADD INDEX(a, id);
ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a);
SELECT * FROM t1;
# Test with a non-default increment and offset
SET AUTO_INCREMENT_INCREMENT = 5, AUTO_INCREMENT_OFFSET = 30;
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY;
SHOW CREATE TABLE t1;
# The autoinc next value should increase. It is not rolled back.
BEGIN;
INSERT INTO t1 VALUES(7,0);
SELECT * FROM t1;
ROLLBACK;
SHOW CREATE TABLE t1;
# We cannot assign AUTO_INCREMENT values during online index creation.
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, LOCK=NONE;
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE;
SELECT * FROM t1;
SHOW CREATE TABLE t1;
INSERT INTO t1 SET a=123;
INSERT INTO t1 VALUES(-123,-45);
ALTER TABLE t1 AUTO_INCREMENT = 75;
INSERT INTO t1 SET a=123;
SELECT * FROM t1;
SHOW CREATE TABLE t1;
DROP TABLE t1;
# ALGORITHM=INPLACE should deliver identical results to ALGORITHM=COPY.
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES(347),(33101),(123),(45),(6);
ALTER TABLE t1 ADD PRIMARY KEY(a);
ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a);
SELECT * FROM t1;
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE;
SHOW CREATE TABLE t1;
# The autoinc next value should increase. It is not rolled back.
BEGIN;
INSERT INTO t1 VALUES(7,0);
SELECT * FROM t1;
ROLLBACK;
SHOW CREATE TABLE t1;
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY;
SELECT * FROM t1;
SHOW CREATE TABLE t1;
INSERT INTO t1 SET a=123;
INSERT INTO t1 VALUES(-123,-45);
ALTER TABLE t1 AUTO_INCREMENT = 75;
INSERT INTO t1 SET a=123;
SELECT * FROM t1;
SHOW CREATE TABLE t1;
DROP TABLE t1;
--loose-innodb-sys-indexes
--loose-innodb-sys-columns
--loose-innodb-sys-fields
This diff is collapsed.
-- source include/have_debug.inc
-- source include/have_innodb.inc
let $MYSQLD_DATADIR= `select @@datadir`;
let $per_table=`select @@innodb_file_per_table`;
let $format=`select @@innodb_file_format`;
set global innodb_file_per_table=on;
set global innodb_file_format='Barracuda';
#
# Test for BUG# 12739098, check whether trx->error_status is reset on error.
#
CREATE TABLE t1(c1 INT NOT NULL, c2 INT, PRIMARY KEY(c1)) Engine=InnoDB;
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5);
SET @saved_debug_dbug = @@SESSION.debug_dbug;
SET DEBUG_DBUG='+d,ib_build_indexes_too_many_concurrent_trxs, ib_rename_indexes_too_many_concurrent_trxs, ib_drop_index_too_many_concurrent_trxs';
--error ER_TOO_MANY_CONCURRENT_TRXS
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
SET DEBUG_DBUG = @saved_debug_dbug;
SHOW CREATE TABLE t1;
DROP TABLE t1;
#
# Test for Bug#13861218 Records are not fully sorted during index creation
#
CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX(c2))
ENGINE=InnoDB;
INSERT INTO bug13861218 VALUES (8, 0), (4, 0), (0, 0);
SET DEBUG_DBUG = '+d,ib_row_merge_buf_add_two';
# Force creation of a PRIMARY KEY on c1 to see what happens on the index(c2).
# No crash here, because n_uniq for c2 includes the clustered index fields
CREATE UNIQUE INDEX ui ON bug13861218(c1);
SET DEBUG_DBUG = @saved_debug_dbug;
DROP TABLE bug13861218;
CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT UNIQUE) ENGINE=InnoDB;
INSERT INTO bug13861218 VALUES (8, NULL), (4, NULL), (0, NULL);
SET DEBUG_DBUG = '+d,ib_row_merge_buf_add_two';
# Force creation of a PRIMARY KEY on c1 to see what happens on the index(c2).
# assertion failure: ut_ad(cmp_dtuple_rec(dtuple, rec, rec_offsets) > 0)
CREATE UNIQUE INDEX ui ON bug13861218(c1);
SET DEBUG_DBUG = @saved_debug_dbug;
DROP TABLE bug13861218;
eval set global innodb_file_per_table=$per_table;
eval set global innodb_file_format=$format;
eval set global innodb_file_format_max=$format;
--echo #
--echo # Bug #21762319 ADDING INDEXES ON EMPTY TABLE IS SLOW
--echo # WITH LARGE INNODB_SORT_BUFFER_SIZE.
call mtr.add_suppression("InnoDB: Cannot create temporary merge file");
# Table with large data which is greater than sort buffer
create table t480(a serial)engine=innodb;
insert into t480
values(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),
(),(),(),(),(),(),(),();
insert into t480 select 0 from t480;
insert into t480 select 0 from t480;
insert into t480 select 0 from t480;
insert into t480 select 0 from t480;
create table t1(f1 int auto_increment not null,
f2 char(200) not null, f3 char(200) not null,
f4 char(200) not null,primary key(f1))engine=innodb;
insert into t1 select NULL,'aaa','bbb','ccc' from t480;
insert into t1 select NULL,'aaaa','bbbb','cccc' from t480;
insert into t1 select NULL,'aaaaa','bbbbb','ccccc' from t480;
insert into t1 select NULL,'aaaaaa','bbbbbb','cccccc' from t480;
insert into t1 select NULL,'aaaaaaa','bbbbbbb','ccccccc' from t480;
insert into t1 select NULL,'aaaaaaaa','bbbbbbbb','cccccccc' from t480;
select count(*) from t1;
SET DEBUG_DBUG = '+d,innobase_tmpfile_creation_failure';
--error ER_OUT_OF_RESOURCES
alter table t1 force, algorithm=inplace;
SET DEBUG_DBUG = @saved_debug_dbug;
drop table t1, t480;
--source include/have_innodb.inc
--source include/have_debug_sync.inc
# Save the initial number of concurrent sessions.
--source include/count_sessions.inc
connect (con1,localhost,root,,);
connection default;
CREATE TABLE t (a INT PRIMARY KEY, b INT NOT NULL) ENGINE=InnoDB;
INSERT INTO t VALUES(1,2),(2,3);
SET DEBUG_SYNC='alter_table_inplace_after_lock_downgrade SIGNAL do WAIT_FOR m';
SET DEBUG_SYNC='innodb_after_inplace_alter_table SIGNAL scanned WAIT_FOR done';
--send
CREATE INDEX tb ON t(b);
connection con1;
SET DEBUG_SYNC='now WAIT_FOR do';
SET DEBUG_SYNC='row_update_for_mysql_error SIGNAL m WAIT_FOR scanned';
--error ER_DUP_ENTRY
UPDATE t SET a=2 WHERE a=1;
call mtr.add_suppression('InnoDB: record in index .*tb was not found on rollback, trying to insert');
SET DEBUG_SYNC='now SIGNAL done';
disconnect con1;
connection default;
reap;
SET DEBUG_SYNC='RESET';
DROP TABLE t;
# 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
--loose-innodb-sys-tables
--loose-innodb-sys-columns
--loose-innodb-sys-foreign
--loose-innodb-sys-foreign-cols
This diff is collapsed.
This diff is collapsed.
--innodb-sort-buffer-size=64k
--innodb-online-alter-log-max-size=64k
--innodb-buffer-pool-size=5M
--innodb-log-buffer-size=256k
--innodb-sys-indexes
--innodb-sys-fields
This diff is collapsed.
--innodb-sort-buffer-size=64k --innodb-online-alter-log-max-size=64k --innodb-buffer-pool-size=5M --innodb-log-buffer-size=256k
This diff is collapsed.
--loose-innodb-sys-indexes
--loose-innodb-sys-columns
--loose-innodb-sys-fields
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -9322,8 +9322,10 @@ int TC_LOG_BINLOG::open(const char *opt_name)
if (using_heuristic_recover())
{
mysql_mutex_lock(&LOCK_log);
/* generate a new binlog to mask a corrupted one */
open(opt_name, LOG_BIN, 0, 0, WRITE_CACHE, max_binlog_size, 0, TRUE);
mysql_mutex_unlock(&LOCK_log);
cleanup();
return 1;
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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