MDEV-11: Generic storage engine test suite

This commit is contained in:
Elena Stepanova 2012-07-16 06:17:56 +04:00
parent 403cac0fe7
commit 72a5542f0e
405 changed files with 36013 additions and 0 deletions

View File

@ -0,0 +1,11 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW CREATE TABLE t1;
SHOW COLUMNS IN t1;
INSERT INTO t1 VALUES (1,'a');
INSERT INTO t1 (a,b) VALUES (2,'b');
SELECT * FROM t1;
a b
1 a
2 b
DROP TABLE t1;

View File

@ -0,0 +1,81 @@
#
# This test checks some very basic capabilities
# which will be used in almost every other test,
# and will not be checked through support* variables.
# If this test does not pass, there is no point
# at executing other ones.
#
# Minimal requirements:
# - supported column types: INT, CHAR (default CHAR(8), INT(11));
# - column attributes as declared in define_engine.inc ($default_col_opts)
# (by default empty, which means no additional attributes apart from the type);
# - table attributes as declared in define_engine.inc ($default_tbl_opts)
# (by default empty, which means no additional attributes apart from ENGINE);
# - CREATE TABLE .. (column1 <column options>, column2 <column options>) ENGINE=<storage_engine>;
# - INSERT INTO TABLE .. VALUES (val1,val2);
# - DROP TABLE ..
# - SELECT * FROM ..
# - SHOW CREATE TABLE ..
# - SHOW COLUMNS IN ...
#
--source have_engine.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = CREATE TABLE
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--disable_result_log
SHOW CREATE TABLE t1;
if ($mysql_errname)
{
--let $functionality = SHOW CREATE TABLE
--source unexpected_result.inc
}
SHOW COLUMNS IN t1;
if ($mysql_errname)
{
--let $functionality = SHOW COLUMNS
--source unexpected_result.inc
}
--enable_result_log
INSERT INTO t1 VALUES (1,'a');
if ($mysql_errname)
{
--let $functionality = INSERT INTO .. VALUES
--source unexpected_result.inc
}
INSERT INTO t1 (a,b) VALUES (2,'b');
if ($mysql_errname)
{
--let $functionality = INSERT INTO .. (column_list) VALUES
--source unexpected_result.inc
}
SELECT * FROM t1;
if ($mysql_errname)
{
--let $functionality = SELECT * FROM ..
--source unexpected_result.inc
}
DROP TABLE t1;
if ($mysql_errname)
{
--let $functionality = DROP TABLE
--source unexpected_result.inc
}
}
--source cleanup_engine.inc

View File

@ -0,0 +1,91 @@
##################################
#
# This include file will be used for all ALTER TABLE statements in the suite.
# If you need to add additional steps or change the logic, copy the file
# to storage/<engine>/mysql-test/storage_engine/ folder and modify it there.
#
##################
#
# Parameters:
#
# --let $alter_definition = <alter definition> # mandatory, everything that goes after the table name in ALTER statement
# --let $table_name = <table name> # optional, default t1
# --let $error_codes = <expected error codes, as in --error> # optional, default 0
# --let $online = [0|1] # optional, default 0 (1 adds ONLINE)
# --let $rename_to = <new table name> # optional, default empty.
# # If set, means we are running RENAME TO, then alter definition is ignored
#
# Usage examples:
#
# --let $alter_definition = ADD COLUMN b $char_col DEFAULT ''
#
if ($rename_to)
{
--let $alter_definition = RENAME TO $rename_to
}
if (!$alter_definition)
{
--die # The ALTER statement is empty
}
--let $alter_statement = ALTER
if ($online)
{
--let $alter_statement = $alter_statement ONLINE
}
if (!$table_name)
{
--let $table_name = t1
}
--let $alter_statement = $alter_statement TABLE $table_name $alter_definition
# We now have the complete ALTER statement in $alter_statement.
# If your ALTER statement should be composed differently,
# modify the logic above.
#####################
# Here you can add logic needed BEFORE the main statement
# (e.g. base tables need to be altered, etc.).
# Surround it by --disable_query_log/--enable_query_log
# if you don't want it to appear in the result output.
#####################
--source obfuscate.inc
eval $alter_statement;
--source check_errors.inc
# Make sure you don't add any statements between the main ALTER (above)
# and saving mysql_errno and mysql_errname (below)
# They are saved in case you want to add more logic after the main ALTER,
# because we need the result code of the statement.
# Also, do not change $alter_statement after it is executed!
--let $my_errno = $mysql_errno
--let $my_errname = $mysql_errname
#####################
# Here you can add logic needed AFTER the main statement.
# Surround it by --disable_query_log/--enable_query_log
# if you don't want it to appear in the result output.
#####################
# Unset the parameters, we don't want them to be accidentally reused later
--let $alter_definition =
--let $table_name =
--let $error_codes =
--let $online = 0
--let $rename_to =
# Restore the error codes of the main statement
--let $mysql_errno = $my_errno
--let $mysql_errname = $my_errname
# Make sure you don't add any SQL statements after restoring
# mysql_errno and mysql_errname (above)

View File

@ -0,0 +1,147 @@
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (a <INT_COLUMN>, c <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,c) VALUES (1,'a'),(5,'z');
ALTER TABLE t1 ADD COLUMN b <INT_COLUMN>;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`c` char(8) DEFAULT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
ALTER TABLE t1 ALTER COLUMN a SET DEFAULT '0';
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT '0',
`c` char(8) DEFAULT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
ALTER TABLE t1 ALTER a DROP DEFAULT;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11),
`c` char(8) DEFAULT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
ALTER TABLE t1 CHANGE COLUMN b b1 <CHAR_COLUMN> FIRST;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`b1` char(8) DEFAULT NULL,
`a` int(11),
`c` char(8) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
ALTER TABLE t1 CHANGE b1 b <INT_COLUMN> AFTER c;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11),
`c` char(8) DEFAULT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
ALTER TABLE t1 CHANGE b b <CHAR_COLUMN>;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11),
`c` char(8) DEFAULT NULL,
`b` char(8) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
ALTER TABLE t1 MODIFY COLUMN b <INT_COLUMN>;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11),
`c` char(8) DEFAULT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
ALTER TABLE t1 MODIFY COLUMN b <CHAR_COLUMN> FIRST;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`b` char(8) DEFAULT NULL,
`a` int(11),
`c` char(8) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
ALTER TABLE t1 MODIFY COLUMN b <INT_COLUMN> AFTER a;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11),
`b` int(11) DEFAULT NULL,
`c` char(8) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
ALTER TABLE t1 DROP COLUMN b;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11),
`c` char(8) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
ALTER TABLE t1 RENAME TO t2;
SHOW CREATE TABLE t1;
ERROR 42S02: Table 'test.t1' doesn't exist
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` int(11),
`c` char(8) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t1 (a <INT_COLUMN>, b <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (1,5),(2,2),(4,3);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
ALTER TABLE t1 ORDER BY b ASC, a DESC;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
SELECT * FROM t1;
a b
2 2
4 3
1 5
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, c <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHARACTER SET latin1 COLLATE latin1_general_cs;
INSERT INTO t1 (a,b,c) VALUES (5,'z','t');
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` char(8) COLLATE latin1_general_cs DEFAULT NULL,
`c` char(8) COLLATE latin1_general_cs DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs
ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` char(8) DEFAULT NULL,
`c` char(8) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=utf8
ALTER TABLE t1 DEFAULT CHARACTER SET = latin1 COLLATE latin1_general_ci;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` char(8) CHARACTER SET utf8 DEFAULT NULL,
`c` char(8) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
ALTER TABLE t1 FORCE;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` char(8) CHARACTER SET utf8 DEFAULT NULL,
`c` char(8) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
DROP TABLE t1;

View File

@ -0,0 +1,148 @@
#
# Basic ALTER TABLE statements.
#
# USAGE of table options in ALTER statements
# is covered in tbl_standard_opts and tbl_opt*.tests.
#
# Index operations are covered in index* tests.
#
# ALTER ONLINE syntax is covered in alter_online_table.test
# ALTER OFFLINE is not covered as it is not supported, as of 5.5.23
#
# ALTER TABLE ... DISCARD|IMPORT TABLESPACE is covered in alter_tablespace.test
#
--source have_engine.inc
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
--let $create_definition = a $int_col, c $char_col
--source create_table.inc
INSERT INTO t1 (a,c) VALUES (1,'a'),(5,'z');
# Column operations
--let $alter_definition = ADD COLUMN b $int_col
--source alter_table.inc
if ($mysql_errname)
{
--source unexpected_result.inc
}
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = ALTER COLUMN a SET DEFAULT '0'
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = ALTER a DROP DEFAULT
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = CHANGE COLUMN b b1 $char_col FIRST
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = CHANGE b1 b $int_col AFTER c
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = CHANGE b b $char_col
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = MODIFY COLUMN b $int_col
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = MODIFY COLUMN b $char_col FIRST
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = MODIFY COLUMN b $int_col AFTER a
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = DROP COLUMN b
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
# Rename table
--let $rename_to = t2
--source alter_table.inc
--let $error_codes = ER_NO_SUCH_TABLE
SHOW CREATE TABLE t1;
--source check_errors.inc
if ($mysql_errname != 'ER_NO_SUCH_TABLE')
{
--let $functionality = ALTER TABLE
--source unexpected_result.inc
DROP TABLE t1;
}
if ($mysql_errname == ER_NO_SUCH_TABLE)
{
--source mask_engine.inc
SHOW CREATE TABLE t2;
DROP TABLE t2;
}
# ORDER BY
--let $create_definition = a $int_col, b $int_col
--source create_table.inc
INSERT INTO t1 (a,b) VALUES (1,5),(2,2),(4,3);
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = ORDER BY b ASC, a DESC
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
# Character set, collate
--let $table_options = CHARACTER SET latin1 COLLATE latin1_general_cs
--let $create_definition = a $int_col, b $char_col, c $char_col
--source create_table.inc
INSERT INTO t1 (a,b,c) VALUES (5,'z','t');
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = CONVERT TO CHARACTER SET utf8
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = DEFAULT CHARACTER SET = latin1 COLLATE latin1_general_ci
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
# A 'null' ALTER operation
--let $alter_definition = FORCE
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
# Cleanup
DROP TABLE t1;
--source cleanup_engine.inc

View File

@ -0,0 +1,35 @@
DROP TABLE IF EXISTS t1,t2,t3;
CREATE TABLE t1 (a <INT_COLUMN>, b <INT_COLUMN>, c <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b,c) VALUES (1,100,'a'),(2,200,'b'),(3,300,'c');
ALTER ONLINE TABLE t1 MODIFY b <INT_COLUMN> DEFAULT 5;
ALTER ONLINE TABLE t1 CHANGE b new_name <INT_COLUMN>;
ALTER ONLINE TABLE t1 COMMENT 'new comment';
ALTER ONLINE TABLE t1 RENAME TO t2;
DROP TABLE IF EXISTS t2;
CREATE TEMPORARY TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c');
ALTER ONLINE TABLE t1 MODIFY b <INT_COLUMN> DEFAULT 5;
ERROR HY000: Can't execute the given 'ALTER' command as online
ALTER ONLINE TABLE t1 CHANGE b new_name <INT_COLUMN>;
ERROR HY000: Can't execute the given 'ALTER' command as online
ALTER ONLINE TABLE t1 COMMENT 'new comment';
ERROR HY000: Can't execute the given 'ALTER' command as online
ALTER ONLINE TABLE t1 RENAME TO t2;
ERROR HY000: Can't execute the given 'ALTER' command as online
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>, b <INT_COLUMN>, c <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b,c) VALUES (1,100,'a'),(2,200,'b'),(3,300,'c');
ALTER ONLINE TABLE t1 DROP COLUMN b, ADD b <INT_COLUMN>;
ERROR HY000: Can't execute the given 'ALTER' command as online
ALTER ONLINE TABLE t1 MODIFY b BIGINT <CUSTOM_COL_OPTIONS>;
ERROR HY000: Can't execute the given 'ALTER' command as online
ALTER ONLINE TABLE t1 ENGINE=MEMORY;
ERROR HY000: Can't execute the given 'ALTER' command as online
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>, b <INT_COLUMN>, c <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
ALTER ONLINE TABLE t1 ADD INDEX (b);
ERROR HY000: Can't execute the given 'ALTER' command as online
ALTER TABLE t1 ADD INDEX (b);
ALTER ONLINE TABLE t1 DROP INDEX b;
ERROR HY000: Can't execute the given 'ALTER' command as online
DROP TABLE t1;

View File

@ -0,0 +1,160 @@
#
# ALTER ONLINE TABLE
#
--source have_engine.inc
--disable_warnings
DROP TABLE IF EXISTS t1,t2,t3;
--enable_warnings
#
# Test of things that can be done online
# We are repeating notification here, because for some engines
# only a part of these ALTER ONLINE statements might be supported.
#
let $create_definition = a $int_col, b $int_col, c $char_col;
--source create_table.inc
INSERT INTO t1 (a,b,c) VALUES (1,100,'a'),(2,200,'b'),(3,300,'c');
--let $online = 1
--let $alter_definition = MODIFY b $int_col DEFAULT 5
--source alter_table.inc
if ($mysql_errname)
{
--source unexpected_result.inc
}
--let $online = 1
--let $alter_definition = CHANGE b new_name $int_col
--source alter_table.inc
if ($mysql_errname)
{
--source unexpected_result.inc
}
--let $online = 1
--let $alter_definition = COMMENT 'new comment'
--source alter_table.inc
if ($mysql_errname)
{
--source unexpected_result.inc
}
--let $online = 1
--let $rename_to = t2
--source alter_table.inc
if ($mysql_errname)
{
--source unexpected_result.inc
DROP TABLE t1;
}
DROP TABLE IF EXISTS t2;
#
# temporary tables always require a copy
#
--let $temporary = 1
--source create_table.inc
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c');
--let $error_codes = ER_CANT_DO_ONLINE
--let $online = 1
--let $alter_definition = MODIFY b $int_col DEFAULT 5
--source alter_table.inc
if ($mysql_errname != ER_CANT_DO_ONLINE)
{
--source unexpected_result.inc
}
--let $error_codes = ER_CANT_DO_ONLINE
--let $online = 1
--let $alter_definition = CHANGE b new_name $int_col
--source alter_table.inc
--let $error_codes = ER_CANT_DO_ONLINE
--let $online = 1
--let $alter_definition = COMMENT 'new comment'
--source alter_table.inc
--let $error_codes = ER_CANT_DO_ONLINE
--let $online = 1
--let $rename_to = t2
--source alter_table.inc
DROP TABLE t1;
#
# Test of things that is not possible to do online
#
--let $create_definition = a $int_col, b $int_col, c $char_col
--source create_table.inc
INSERT INTO t1 (a,b,c) VALUES (1,100,'a'),(2,200,'b'),(3,300,'c');
--let $error_codes = ER_CANT_DO_ONLINE
--let $online = 1
--let $alter_definition = DROP COLUMN b, ADD b $int_col
--source alter_table.inc
if ($mysql_errname!=ER_CANT_DO_ONLINE)
{
--source unexpected_result.inc
}
--let $error_codes = ER_CANT_DO_ONLINE
--let $online = 1
--let $alter_definition = MODIFY b BIGINT $default_col_opts
--source alter_table.inc
--let $alternative_engine = `SELECT engine FROM information_schema.engines WHERE engine != '$storage_engine' AND support IN ('YES','DEFAULT')`
--let $error_codes = ER_CANT_DO_ONLINE
--let $online = 1
--let $alter_definition = ENGINE=$alternative_engine
--source alter_table.inc
DROP TABLE t1;
--let $create_definition = a $int_col, b $int_indexed_col, c $char_col
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Column options
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--let $error_codes = ER_CANT_DO_ONLINE
--let $online = 1
--let $alter_definition = ADD INDEX (b)
--source alter_table.inc
if ($mysql_errname!=ER_CANT_DO_ONLINE)
{
--let $functionality = Adding an index or ALTER ONLINE
--source unexpected_result.inc
}
--let $alter_definition = ADD INDEX (b)
--source alter_table.inc
if ($mysql_errname)
{
--let $functionality = Adding an index or ALTER TABLE
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--let $error_codes = ER_CANT_DO_ONLINE
--let $online = 1
--let $alter_definition = DROP INDEX b
--source alter_table.inc
}
DROP TABLE t1;
}
--source cleanup_engine.inc

View File

@ -0,0 +1,19 @@
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
ALTER TABLE t1 DISCARD TABLESPACE;
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a) VALUES (1),(2);
SELECT * FROM t1;
a
1
2
ALTER TABLE t1 DISCARD TABLESPACE;
SELECT * FROM t1;
ERROR HY000: Got error -1 from storage engine
ALTER TABLE t1 IMPORT TABLESPACE;
SELECT * FROM t1;
a
1
2
DROP TABLE t1;

View File

@ -0,0 +1,91 @@
#
# IMPORT / DISCARD TABLESPACE
#
# The test might require additional engine options,
# e.g. for InnoDB it is --innodb-file-per-table
--source have_engine.inc
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
--let $create_definition = a $int_col
--source create_table.inc
--let $alter_definition = DISCARD TABLESPACE
--source alter_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $alter_statement
--let $functionality = Tablespace operations
--source unexpected_result.inc
}
if (!$mysql_errname)
{
DROP TABLE t1;
--let $create_definition = a $int_col
--source create_table.inc
INSERT INTO t1 (a) VALUES (1),(2);
--sorted_result
SELECT * FROM t1;
# http://dev.mysql.com/doc/mysql-enterprise-backup/3.5/en/partial.restoring.single.html
# To get a "clean" backup we need to either use innobackup, or to monitor show engine innodb status,
# and the documented conditions do not look exactly feasible. So, we will go a simple way:
# just restart the server, and take the backup while the server is down.
# (And we need to have a really clean backup, see MySQL:65429 / LP:1004910)
--let $datadir = `SELECT @@datadir`
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart
wait
EOF
--enable_reconnect
--shutdown_server 60
--source include/wait_until_disconnected.inc
--replace_result $datadir <DATADIR>
--copy_file $datadir/test/t1.ibd $datadir/test/t1.ibd.save
--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart
EOF
--source include/wait_until_connected_again.inc
--let $alter_definition = DISCARD TABLESPACE
--source alter_table.inc
--let $error_codes = ER_GET_ERRNO
SELECT * FROM t1;
--source check_errors.inc
if ($mysql_errname != ER_GET_ERRNO)
{
--let $functionality = Tablespace operations
--source unexpected_result.inc
}
--move_file $datadir/test/t1.ibd.save $datadir/test/t1.ibd
--let $alter_definition = IMPORT TABLESPACE
--source alter_table.inc
--sorted_result
SELECT * FROM t1;
# Adding a warning suppression based on what InnoDB currently does
# when it attempts to access a table without an *.ibd file
--disable_query_log
eval CALL mtr.add_suppression('$storage_engine: Error:.*');
--enable_query_log
}
DROP TABLE t1;
--source cleanup_engine.inc

View File

@ -0,0 +1,43 @@
#
# ANALYZE TABLE statements
#
# Note: the output is likely to be different for the engine under test,
# in which case rdiff will be needed. Or, the output might say that
# the storage engine does not support ANALYZE.
#
--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
--let $create_definition = a $int_col, b $char_col
--source create_table.inc
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
--let $create_definition = a $int_col, b $char_col
--let $table_name = t2
--source create_table.inc
INSERT INTO t1 (a,b) VALUES (3,'c');
ANALYZE TABLE t1;
INSERT INTO t2 (a,b) VALUES (4,'d');
ANALYZE NO_WRITE_TO_BINLOG TABLE t2;
INSERT INTO t1 (a,b) VALUES (5,'e');
INSERT INTO t2 (a,b) VALUES (6,'f');
ANALYZE LOCAL TABLE t1, t2;
DROP TABLE t1, t2;
--let $continue = 1
--source have_default_index.inc
if ($have_default_index)
{
--let $create_definition = a $int_indexed_col, $default_index(a)
--source create_table.inc
INSERT INTO t1 (a) VALUES (1),(2),(4),(7);
ANALYZE TABLE t1;
INSERT INTO t1 (a) VALUES (8),(10),(11),(12);
ANALYZE TABLE t1;
DROP TABLE t1;
}

View File

@ -0,0 +1,29 @@
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (3,'c');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
INSERT INTO t2 (a,b) VALUES (4,'d');
ANALYZE NO_WRITE_TO_BINLOG TABLE t2;
Table Op Msg_type Msg_text
test.t2 analyze status OK
INSERT INTO t1 (a,b) VALUES (5,'e');
INSERT INTO t2 (a,b) VALUES (6,'f');
ANALYZE LOCAL TABLE t1, t2;
Table Op Msg_type Msg_text
test.t1 analyze status OK
test.t2 analyze status OK
DROP TABLE t1, t2;
CREATE TABLE t1 (a <INT_COLUMN>, <CUSTOM_INDEX>(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a) VALUES (1),(2),(4),(7);
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
INSERT INTO t1 (a) VALUES (8),(10),(11),(12);
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
DROP TABLE t1;

View File

@ -0,0 +1,14 @@
#
# ANALYZE TABLE statements
#
# Note: the output is likely to be different for the engine under test,
# in which case rdiff will be needed. Or, the output might say that
# the storage engine does not support ANALYZE.
#
--source have_engine.inc
--source analyze_table.inc
--source cleanup_engine.inc

View File

@ -0,0 +1,40 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a <INT_COLUMN> AUTO_INCREMENT, b <CHAR_COLUMN>, PRIMARY KEY (a,b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (b) VALUES ('a'),('b'),('b'),('c'),('a');
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
1
SELECT * FROM t1;
a b
1 a
2 b
3 b
4 c
5 a
DROP TABLE t1;
CREATE TABLE t1 (a <CHAR_COLUMN>, b <INT_COLUMN> AUTO_INCREMENT, PRIMARY KEY (a,b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a) VALUES ('a'),('b'),('b'),('c'),('a');
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
1
SELECT * FROM t1;
a b
a 1
a 2
b 1
b 2
c 1
DROP TABLE t1;
CREATE TABLE t1 (a <CHAR_COLUMN>, b <INT_COLUMN> AUTO_INCREMENT, PRIMARY KEY (a,b), <CUSTOM_INDEX>(b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a) VALUES ('a'),('b'),('b'),('c'),('a');
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
1
SELECT * FROM t1;
a b
a 1
a 5
b 2
b 3
c 4
DROP TABLE t1;

View File

@ -0,0 +1,73 @@
#
# AUTO_INCREMENT on a secondary column in a multi-part key
#
--source have_engine.inc
--source have_default_index.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
#
# AUTO_INCREMENT is the primary column in a multiple-column index
#
--let $create_definition = a $int_col AUTO_INCREMENT, b $char_col, PRIMARY KEY (a,b)
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Multi-part keys or PK or AUTO_INCREMENT (on a primary column)
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (b) VALUES ('a'),('b'),('b'),('c'),('a');
SELECT LAST_INSERT_ID();
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
}
#
# AUTO_INCREMENT is the secondary column in a multiple-column index
#
--let $create_definition = a $char_col, b $int_col AUTO_INCREMENT, PRIMARY KEY (a,b)
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Multi-part keys or PK or AUTO_INCREMENT (on a secondary column)
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a) VALUES ('a'),('b'),('b'),('c'),('a');
SELECT LAST_INSERT_ID();
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
}
# AUTO_INCREMENT is the secondary column in a multiple-column index,
# and primary in another index
#
--let $create_definition = a $char_col, b $int_indexed_col AUTO_INCREMENT, PRIMARY KEY (a,b), $default_index(b)
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Multi-part keys or AUTO_INCREMENT (on the secondary column) or multiple keys
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a) VALUES ('a'),('b'),('b'),('c'),('a');
SELECT LAST_INSERT_ID();
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
}
--source cleanup_engine.inc

View File

@ -0,0 +1,55 @@
DROP TABLE IF EXISTS t1;
SET auto_increment_offset = 200;
CREATE TABLE t1 (a <INT_COLUMN> AUTO_INCREMENT, b <CHAR_COLUMN>, <CUSTOM_INDEX>(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (NULL,'a'),(NULL,'b'),(NULL,'c');
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
1
SELECT * FROM t1;
a b
1 a
2 b
3 c
SET auto_increment_increment = 300;
INSERT INTO t1 (a,b) VALUES (NULL,'d'),(NULL,'e'),(NULL,'f');
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
200
SELECT * FROM t1;
a b
1 a
2 b
200 d
3 c
500 e
800 f
SET auto_increment_increment = 50;
INSERT INTO t1 (a,b) VALUES (NULL,'g'),(NULL,'h'),(NULL,'i');
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
850
SELECT * FROM t1;
a b
1 a
2 b
200 d
3 c
500 e
800 f
850 g
900 h
950 i
DROP TABLE t1;
SET auto_increment_increment = 500;
SET auto_increment_offset = 300;
CREATE TABLE t1 (a TINYINT <CUSTOM_COL_OPTIONS> AUTO_INCREMENT, <CUSTOM_INDEX>(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a) VALUES (NULL);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
127
SELECT * FROM t1;
a
127
DROP TABLE t1;

View File

@ -0,0 +1,68 @@
#
# auto-increment-offset and auto-increment-increment
#
--source have_engine.inc
--source have_default_index.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
# auto_increment_offset
SET auto_increment_offset = 200;
--let $create_definition = a $int_indexed_col AUTO_INCREMENT, b $char_col, $default_index(a)
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = AUTO_INCREMENT
--source unexpected_result.inc
}
if (!$mysql_errname)
{
# If auto_increment_offset is greater than auto_increment_increment,
# the offset is ignored
INSERT INTO t1 (a,b) VALUES (NULL,'a'),(NULL,'b'),(NULL,'c');
SELECT LAST_INSERT_ID();
--sorted_result
SELECT * FROM t1;
# auto_increment_increment
SET auto_increment_increment = 300;
# offset should not be ignored anymore
INSERT INTO t1 (a,b) VALUES (NULL,'d'),(NULL,'e'),(NULL,'f');
SELECT LAST_INSERT_ID();
--sorted_result
SELECT * FROM t1;
SET auto_increment_increment = 50;
INSERT INTO t1 (a,b) VALUES (NULL,'g'),(NULL,'h'),(NULL,'i');
SELECT LAST_INSERT_ID();
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
}
# offset is greater than the max value
SET auto_increment_increment = 500;
SET auto_increment_offset = 300;
--let $create_definition = a TINYINT $default_col_indexed_opts AUTO_INCREMENT, $default_index(a)
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = AUTO_INCREMENT
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a) VALUES (NULL);
SELECT LAST_INSERT_ID();
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
}
--source cleanup_engine.inc

View File

@ -0,0 +1,133 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a <INT_COLUMN> AUTO_INCREMENT, b <CHAR_COLUMN>, <CUSTOM_INDEX>(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL AUTO_INCREMENT,
`b` char(8) DEFAULT NULL,
KEY `a` (`a`)
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
INSERT INTO t1 (b) VALUES ('a'),('b');
SELECT * FROM t1 ORDER BY a;
a b
1 a
2 b
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
1
INSERT INTO t1 (a,b) VALUES (NULL,'c'),(0,'d');
SELECT * FROM t1 ORDER BY a;
a b
1 a
2 b
3 c
4 d
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
3
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
INSERT INTO t1 (a,b) VALUES (NULL,'e');
SELECT * FROM t1 ORDER BY a;
a b
1 a
2 b
3 c
4 d
5 e
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
5
INSERT INTO t1 (a,b) VALUES (0,'f');
SELECT * FROM t1 ORDER BY a;
a b
0 f
1 a
2 b
3 c
4 d
5 e
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
5
SET sql_mode = '<INITIAL_SQL_MODE>';
SHOW TABLE STATUS FROM test LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 <STORAGE_ENGINE> # # # # # # # # 6 # # # # # # #
INSERT INTO t1 (a,b) VALUES (6,'g'),(7,'h');
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
5
SHOW TABLE STATUS FROM test LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 # # # # # # # # # 8 # # # # # # #
INSERT INTO t1 (a,b) VALUES (NULL,'i'),(9,'j');
SELECT * FROM t1 ORDER BY a;
a b
0 f
1 a
2 b
3 c
4 d
5 e
6 g
7 h
8 i
9 j
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
8
SHOW TABLE STATUS FROM test LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 # # # # # # # # # 10 # # # # # # #
INSERT INTO t1 (a,b) VALUES (20,'k');
SHOW TABLE STATUS FROM test LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 # # # # # # # # # 21 # # # # # # #
INSERT INTO t1 (a,b) VALUES (NULL,'l');
SELECT * FROM t1 ORDER BY a;
a b
0 f
1 a
2 b
3 c
4 d
5 e
6 g
7 h
8 i
9 j
20 k
21 l
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
21
SHOW TABLE STATUS FROM test LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 # # # # # # # # # 22 # # # # # # #
INSERT INTO t1 (a,b) VALUES (-5,'m');
SELECT * FROM t1 ORDER BY a;
a b
-5 m
0 f
1 a
2 b
3 c
4 d
5 e
6 g
7 h
8 i
9 j
20 k
21 l
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN> AUTO_INCREMENT, b <CHAR_COLUMN>, <CUSTOM_INDEX>(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> AUTO_INCREMENT = 100;
INSERT INTO t1 (a,b) VALUES (NULL,'a'),(NULL,'b');
SELECT * FROM t1;
a b
100 a
101 b
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
100
DROP TABLE t1;

View File

@ -0,0 +1,114 @@
#
# Basic AUTO_INCREMENT capabilities
#
--source have_engine.inc
--let $skip = 1
--source have_default_index.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--let $create_definition = a $int_indexed_col AUTO_INCREMENT, b $char_col, $default_index(a)
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = AUTO_INCREMENT
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--source mask_engine.inc
SHOW CREATE TABLE t1;
# Automatic values
INSERT INTO t1 (b) VALUES ('a'),('b');
SELECT * FROM t1 ORDER BY a;
SELECT LAST_INSERT_ID();
INSERT INTO t1 (a,b) VALUES (NULL,'c'),(0,'d');
SELECT * FROM t1 ORDER BY a;
SELECT LAST_INSERT_ID();
let $sql_mode = `SELECT @@sql_mode`;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
INSERT INTO t1 (a,b) VALUES (NULL,'e');
SELECT * FROM t1 ORDER BY a;
SELECT LAST_INSERT_ID();
INSERT INTO t1 (a,b) VALUES (0,'f');
SELECT * FROM t1 ORDER BY a;
SELECT LAST_INSERT_ID();
--replace_result $sql_mode <INITIAL_SQL_MODE>
eval SET sql_mode = '$sql_mode';
# SHOW TABLE STATUS shows the auto-increment value in column 11,
# that's all we need here and further
--source mask_engine.inc
--replace_column 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 #
SHOW TABLE STATUS FROM test LIKE 't1';
# Mix of automatic and explicit values
INSERT INTO t1 (a,b) VALUES (6,'g'),(7,'h');
SELECT LAST_INSERT_ID();
--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 #
SHOW TABLE STATUS FROM test LIKE 't1';
INSERT INTO t1 (a,b) VALUES (NULL,'i'),(9,'j');
SELECT * FROM t1 ORDER BY a;
SELECT LAST_INSERT_ID();
--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 #
SHOW TABLE STATUS FROM test LIKE 't1';
# Creating a gap in the sequence
INSERT INTO t1 (a,b) VALUES (20,'k');
--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 #
SHOW TABLE STATUS FROM test LIKE 't1';
INSERT INTO t1 (a,b) VALUES (NULL,'l');
SELECT * FROM t1 ORDER BY a;
SELECT LAST_INSERT_ID();
--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 #
SHOW TABLE STATUS FROM test LIKE 't1';
# Negative values: we will try to insert one just to check that it does not cause a crash,
# but won't check what happens to the sequence after that, since the behavior is undefined
INSERT INTO t1 (a,b) VALUES (-5,'m');
SELECT * FROM t1 ORDER BY a;
DROP TABLE t1;
}
# Autoincrement with table option AUTO_INCREMENT
--let $create_definition = a $int_indexed_col AUTO_INCREMENT, b $char_col, $default_index(a)
--let $table_options = AUTO_INCREMENT = 100
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = AUTO_INCREMENT column or table option
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a,b) VALUES (NULL,'a'),(NULL,'b');
--sorted_result
SELECT * FROM t1;
SELECT LAST_INSERT_ID();
DROP TABLE t1;
}
--source cleanup_engine.inc

View File

@ -0,0 +1,69 @@
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> (a)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
CREATE TABLE t2 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> (b)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
CACHE INDEX t1 INDEX (a), t2 IN <CACHE_NAME>;
ERROR HY000: Unknown key cache '<CACHE_NAME>'
SET GLOBAL <CACHE_NAME>.key_buffer_size=128*1024;
CACHE INDEX t1 INDEX (a), t2 IN <CACHE_NAME>;
Table Op Msg_type Msg_text
test.t1 assign_to_keycache status OK
test.t2 assign_to_keycache status OK
LOAD INDEX INTO CACHE t1, t2;
Table Op Msg_type Msg_text
test.t1 preload_keys status OK
test.t2 preload_keys status OK
INSERT INTO t1 (a,b) VALUES (3,'c'),(4,'d');
SET GLOBAL <CACHE_NAME>.key_buffer_size=8*1024;
LOAD INDEX INTO CACHE t1, t2 IGNORE LEAVES;
Table Op Msg_type Msg_text
test.t1 preload_keys status OK
test.t2 preload_keys status OK
SET GLOBAL <CACHE_NAME>.key_cache_age_threshold = 100, <CACHE_NAME>.key_cache_block_size = 512, <CACHE_NAME>.key_cache_division_limit = 1, <CACHE_NAME>.key_cache_segments=2;
INSERT INTO t1 (a,b) VALUES (5,'e'),(6,'f');
LOAD INDEX INTO CACHE t1;
Table Op Msg_type Msg_text
test.t1 preload_keys status OK
SET GLOBAL new_<CACHE_NAME>.key_buffer_size=128*1024;
CACHE INDEX t1 IN new_<CACHE_NAME>;
Table Op Msg_type Msg_text
test.t1 assign_to_keycache status OK
INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
LOAD INDEX INTO CACHE t1 IGNORE LEAVES;
Table Op Msg_type Msg_text
test.t1 preload_keys status OK
INSERT INTO t1 (a,b) VALUES (9,'i');
DROP TABLE t2;
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> (a),
<CUSTOM_INDEX> (b)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
CACHE INDEX t1 IN <CACHE_NAME>;
Table Op Msg_type Msg_text
test.t1 assign_to_keycache status OK
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
LOAD INDEX INTO CACHE t1;
Table Op Msg_type Msg_text
test.t1 preload_keys status OK
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> a_b (a,b)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
CACHE INDEX t1 IN <CACHE_NAME>;
Table Op Msg_type Msg_text
test.t1 assign_to_keycache status OK
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
LOAD INDEX INTO CACHE t1;
Table Op Msg_type Msg_text
test.t1 preload_keys status OK
DROP TABLE t1;
SET GLOBAL <CACHE_NAME>.key_buffer_size=0;
SET GLOBAL new_<CACHE_NAME>.key_buffer_size=0;

View File

@ -0,0 +1,142 @@
#
# CACHE INDEX and LOAD INDEX INTO CACHE
#
--source have_engine.inc
--source have_default_index.inc
# Due to ancient MySQL bug#16111 we need to generate a unique cache name
--let $cache_name = `SELECT CONNECTION_ID()`
--let $cache_name = my_cache_$cache_name
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
let $create_definition =
a $int_indexed_col,
b $char_col,
$default_index (a)
;
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Indexes on INT columns
--source unexpected_result.inc
}
if (!$mysql_errname)
{
let $create_definition =
a $int_col,
b $char_indexed_col,
$default_index (b)
;
let $table_name = t2;
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Indexes on CHAR columns
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_result $cache_name <CACHE_NAME>
--let $error_codes = ER_UNKNOWN_KEY_CACHE
eval CACHE INDEX t1 INDEX (a), t2 IN $cache_name;
--source check_errors.inc
if ($mysql_errname != ER_UNKNOWN_KEY_CACHE)
{
--let $functionality = Key cache or indexes
--source unexpected_result.inc
}
--replace_result $cache_name <CACHE_NAME>
eval SET GLOBAL $cache_name.key_buffer_size=128*1024;
--replace_result $cache_name <CACHE_NAME>
eval CACHE INDEX t1 INDEX (a), t2 IN $cache_name;
if ($mysql_errname)
{
--let $functionality = Indexes
--source unexpected_result.inc
}
LOAD INDEX INTO CACHE t1, t2;
if ($mysql_errname)
{
--let $functionality = Indexes
--source unexpected_result.inc
}
INSERT INTO t1 (a,b) VALUES (3,'c'),(4,'d');
--replace_result $cache_name <CACHE_NAME>
eval SET GLOBAL $cache_name.key_buffer_size=8*1024;
LOAD INDEX INTO CACHE t1, t2 IGNORE LEAVES;
--replace_result $cache_name <CACHE_NAME>
eval SET GLOBAL $cache_name.key_cache_age_threshold = 100, $cache_name.key_cache_block_size = 512, $cache_name.key_cache_division_limit = 1, $cache_name.key_cache_segments=2;
INSERT INTO t1 (a,b) VALUES (5,'e'),(6,'f');
LOAD INDEX INTO CACHE t1;
--replace_result $cache_name <CACHE_NAME>
eval SET GLOBAL new_$cache_name.key_buffer_size=128*1024;
--replace_result $cache_name <CACHE_NAME>
eval CACHE INDEX t1 IN new_$cache_name;
INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
LOAD INDEX INTO CACHE t1 IGNORE LEAVES;
INSERT INTO t1 (a,b) VALUES (9,'i');
DROP TABLE t2;
}
DROP TABLE t1;
}
let $create_definition =
a $int_indexed_col,
b $char_indexed_col,
$default_index (a),
$default_index (b)
;
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Multiple keys or indexes on INT or CHAR columns
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_result $cache_name <CACHE_NAME>
eval CACHE INDEX t1 IN $cache_name;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
LOAD INDEX INTO CACHE t1;
DROP TABLE t1;
let $create_definition =
a $int_indexed_col,
b $char_indexed_col,
$default_index a_b (a,b)
;
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Multi-part keys
--source unexpected_result.inc
}
--replace_result $cache_name <CACHE_NAME>
eval CACHE INDEX t1 IN $cache_name;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
LOAD INDEX INTO CACHE t1;
DROP TABLE t1;
}
# Cleanup
--replace_result $cache_name <CACHE_NAME>
eval SET GLOBAL $cache_name.key_buffer_size=0;
--replace_result $cache_name <CACHE_NAME>
eval SET GLOBAL new_$cache_name.key_buffer_size=0;
--source cleanup_engine.inc

View File

@ -0,0 +1,80 @@
#
# Since we run tests in disable_abort_on_error mode, we cannot use --error command,
# and need to check the result manually.
# Usage in a test:
# --let $error_codes = <comma-separated list> # optional, default ''
# --let $mysql_errname = <error name> # optional, default current $mysql_errname (from the last SQL command)
# --let $mysql_errno = <error code> # optional, default current $mysql_errno (from the last SQL command)
#
if ($error_codes == '0')
{
--let $error_codes =
}
if ($error_codes == '')
{
if ($mysql_errname)
{
--echo # ERROR: Statement ended with errno $mysql_errno, errname $mysql_errname (expected to succeed)
}
# If both error_codes and mysql_errname are false, all is good, no logic needed
}
if ($error_codes != '')
{
# If mysql_errname or mysql_errno is equal to $error_codes, it's good too, nothing to do
if ($mysql_errname != $error_codes)
{
if ($mysql_errno != $error_codes)
{
--let $save_errno = $mysql_errno
--let $save_errname = $mysql_errname
--let $codeline = `SELECT CONCAT('\'',REPLACE('$error_codes',',','\',\''),'\'')`
--let $result = `SELECT '$save_errname' IN($codeline) or '$save_errno' IN ($codeline)`
--let $mysql_errno = $save_errno
--let $mysql_errname = $save_errname
if (!$result)
{
if ($mysql_errname)
{
--echo # ERROR: Statement ended with errno $mysql_errno, errname $mysql_errname (expected results: $error_codes)
}
if (!$mysql_errname)
{
--echo # ERROR: Statement succeeded (expected results: $error_codes)
}
}
# If a list contained more than one error, it could be on one of two reasons:
# first, we do not care which code it is, as long as it is one of the listed errors.
# In this case we will suggest to add an rdiff file if the message differs.
# Second, check_errors might be called from a generalized include file or test,
# which runs with different parameters and thus might produce different results for the same statement.
# Then, the message will be stricter, as the difference with the result file is actually a problem
# which needs to be checked at least.
if ($result)
{
if (!$strict_check)
{
--echo # Statement ended with one of expected results ($error_codes).
--echo # If you got a difference in error message, just add it to rdiff file
}
if ($strict_check)
{
--echo # WARNING: Statement ended with errno $mysql_errno, errname '$mysql_errname'.
--echo # If it differs from the result file, it might indicate a problem.
}
}
}
}
}
# Don't want the variables to be accidentally reused later
--let $error_codes =
--let $strict_check =

View File

@ -0,0 +1,62 @@
#
# CHECK TABLE statements
#
# Note: the output is likely to be different for the engine under test,
# in which case rdiff will be needed. Or, the output might say that
# the storage engine does not support CHECK.
#
--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
--let $create_definition = a $int_col, b $char_col
--source create_table.inc
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
--let $table_name = t2
--let $create_definition = a $int_col, b $char_col
--source create_table.inc
CHECK TABLE t1;
INSERT INTO t1 (a,b) VALUES (3,'c');
INSERT INTO t2 (a,b) VALUES (4,'d');
CHECK TABLE t1, t2 FOR UPGRADE;
INSERT INTO t2 (a,b) VALUES (5,'e');
CHECK TABLE t2 QUICK;
INSERT INTO t1 (a,b) VALUES (6,'f');
CHECK TABLE t1 FAST;
INSERT INTO t1 (a,b) VALUES (7,'g');
INSERT INTO t2 (a,b) VALUES (8,'h');
CHECK TABLE t2, t1 MEDIUM;
INSERT INTO t1 (a,b) VALUES (9,'i');
INSERT INTO t2 (a,b) VALUES (10,'j');
CHECK TABLE t1, t2 EXTENDED;
INSERT INTO t1 (a,b) VALUES (11,'k');
CHECK TABLE t1 CHANGED;
DROP TABLE t1, t2;
--let $continue = 1
--source have_default_index.inc
if ($have_default_index)
{
--let $create_definition = a $int_indexed_col, $default_index(a)
--source create_table.inc
INSERT INTO t1 (a) VALUES (1),(2),(5);
CHECK TABLE t1;
INSERT INTO t1 (a) VALUES (6),(8),(12);
CHECK TABLE t1 FOR UPGRADE;
INSERT INTO t1 (a) VALUES (13),(15),(16);
CHECK TABLE t1 QUICK;
INSERT INTO t1 (a) VALUES (17),(120),(132);
CHECK TABLE t1 FAST;
INSERT INTO t1 (a) VALUES (801),(900),(7714);
CHECK TABLE t1 MEDIUM;
INSERT INTO t1 (a) VALUES (8760),(10023),(12000);
CHECK TABLE t1 EXTENDED;
INSERT INTO t1 (a) VALUES (13345),(24456),(78302),(143028);
CHECK TABLE t1 CHANGED;
DROP TABLE t1;
}

View File

@ -0,0 +1,68 @@
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 (a,b) VALUES (3,'c');
INSERT INTO t2 (a,b) VALUES (4,'d');
CHECK TABLE t1, t2 FOR UPGRADE;
Table Op Msg_type Msg_text
test.t1 check status OK
test.t2 check status OK
INSERT INTO t2 (a,b) VALUES (5,'e');
CHECK TABLE t2 QUICK;
Table Op Msg_type Msg_text
test.t2 check status OK
INSERT INTO t1 (a,b) VALUES (6,'f');
CHECK TABLE t1 FAST;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 (a,b) VALUES (7,'g');
INSERT INTO t2 (a,b) VALUES (8,'h');
CHECK TABLE t2, t1 MEDIUM;
Table Op Msg_type Msg_text
test.t2 check status OK
test.t1 check status OK
INSERT INTO t1 (a,b) VALUES (9,'i');
INSERT INTO t2 (a,b) VALUES (10,'j');
CHECK TABLE t1, t2 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
test.t2 check status OK
INSERT INTO t1 (a,b) VALUES (11,'k');
CHECK TABLE t1 CHANGED;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1, t2;
CREATE TABLE t1 (a <INT_COLUMN>, <CUSTOM_INDEX>(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a) VALUES (1),(2),(5);
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 (a) VALUES (6),(8),(12);
CHECK TABLE t1 FOR UPGRADE;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 (a) VALUES (13),(15),(16);
CHECK TABLE t1 QUICK;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 (a) VALUES (17),(120),(132);
CHECK TABLE t1 FAST;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 (a) VALUES (801),(900),(7714);
CHECK TABLE t1 MEDIUM;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 (a) VALUES (8760),(10023),(12000);
CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 (a) VALUES (13345),(24456),(78302),(143028);
CHECK TABLE t1 CHANGED;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;

View File

@ -0,0 +1,14 @@
#
# CHECK TABLE statements
#
# Note: the output is likely to be different for the engine under test,
# in which case rdiff will be needed. Or, the output might say that
# the storage engine does not support CHECK.
#
--source have_engine.inc
--source check_table.inc
--source cleanup_engine.inc

View File

@ -0,0 +1,31 @@
#
# CHECKSUM TABLE statements for standard CHECKSUM properties.
# Live checksums are covered in checksum_table_live.test
#
--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
# For most engines CHECKSUM=0 option will be ignored,
# but we are setting it here for those which have it 1 by default
# (there will be another test for live checksum)
--let $table_options = CHECKSUM=0
--let $create_definition = a $int_col, b $char_col
--source create_table.inc
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
--let $table_name = t2
--let $table_options = CHECKSUM=0
--let $create_definition = a $int_col, b $char_col
--source create_table.inc
CHECKSUM TABLE t1;
CHECKSUM TABLE t2, t1;
CHECKSUM TABLE t1, t2 QUICK;
CHECKSUM TABLE t1, t2 EXTENDED;
DROP TABLE t1, t2;

View File

@ -0,0 +1,20 @@
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHECKSUM=0;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHECKSUM=0;
CHECKSUM TABLE t1;
Table Checksum
test.t1 4272806499
CHECKSUM TABLE t2, t1;
Table Checksum
test.t2 0
test.t1 4272806499
CHECKSUM TABLE t1, t2 QUICK;
Table Checksum
test.t1 NULL
test.t2 NULL
CHECKSUM TABLE t1, t2 EXTENDED;
Table Checksum
test.t1 4272806499
test.t2 0
DROP TABLE t1, t2;

View File

@ -0,0 +1,11 @@
#
# CHECKSUM TABLE statements for standard CHECKSUM properties.
# Live checksums are covered in checksum_table_live.test
#
--source have_engine.inc
--source checksum_table.inc
--source cleanup_engine.inc

View File

@ -0,0 +1,30 @@
#
# CHECKSUM TABLE statements for live CHECKSUM.
#
# Note: the feature is likely to be unsupported, in which case
# instead of numeric values some CHECKSUMs will produce NULL
#
--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
# For most engines CHECKSUM=1 option will be ignored,
# and the results will be different
--let $table_options = CHECKSUM=1
--let $create_definition = a $int_col, b $char_col
--source create_table.inc
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
--let $table_name = t2
--let $table_options = CHECKSUM=1
--let $create_definition = a $int_col, b $char_col
--source create_table.inc
CHECKSUM TABLE t1;
CHECKSUM TABLE t2, t1;
CHECKSUM TABLE t1, t2 QUICK;
CHECKSUM TABLE t1, t2 EXTENDED;
DROP TABLE t1, t2;

View File

@ -0,0 +1,20 @@
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHECKSUM=1;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHECKSUM=1;
CHECKSUM TABLE t1;
Table Checksum
test.t1 4272806499
CHECKSUM TABLE t2, t1;
Table Checksum
test.t2 0
test.t1 4272806499
CHECKSUM TABLE t1, t2 QUICK;
Table Checksum
test.t1 4272806499
test.t2 0
CHECKSUM TABLE t1, t2 EXTENDED;
Table Checksum
test.t1 4272806499
test.t2 0
DROP TABLE t1, t2;

View File

@ -0,0 +1,13 @@
#
# CHECKSUM TABLE statements for live CHECKSUM.
#
# Note: the feature is likely to be unsupported, in which case
# instead of numeric values some CHECKSUMs will produce NULL
#
--source have_engine.inc
--source checksum_table_live.inc
--source cleanup_engine.inc

View File

@ -0,0 +1,11 @@
###########################################
#
# This is a stub of the include file cleanup_engine.inc which
# should be placed in storage/<engine>/mysql-test/storage_engine folder.
#
################################
#
# Here you can add whatever is needed to cleanup
# in case your define_engine.inc created any artefacts,
# e.g. an additional schema and/or tables.

View File

@ -0,0 +1,92 @@
#
# NOT NULL attribute in columns
#
# Usage:
# let $col_definition = <column type (and possibly more options)>;
# let $col_default = <default non-null value for a column>;
# --source col_not_null.inc
#
# We will add NOT NULL at the end of $col;
#
# Also, if $col_default is defined,
# we will create a table with 2 columns
# (one with DEFAULT $col_default, and one without any default),
# and will also attempt to add a column with DEFAULT NULL.
#
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--let $create_definition = c $col_definition NOT NULL
--source create_table.inc
if ($mysql_errname)
{
--source unexpected_result.inc
}
if (!$mysql_errname)
{
SHOW COLUMNS IN t1;
--let $error_codes = ER_BAD_NULL_ERROR
INSERT INTO t1 (c) VALUES (NULL);
--source check_errors.inc
DROP TABLE t1;
}
if ($col_default != '')
{
let $create_definition =
c $col_definition NOT NULL,
c2 $col_definition NOT NULL DEFAULT $col_default
;
--source create_table.inc
if ($mysql_errname)
{
--source unexpected_result.inc
}
if (!$mysql_errname)
{
SHOW COLUMNS IN t1;
--let $error_codes = ER_INVALID_DEFAULT
--let $alter_definition = ADD COLUMN err $col_definition NOT NULL DEFAULT NULL
--source alter_table.inc
if ($mysql_errname != ER_INVALID_DEFAULT)
{
--let $functionality = ALTER or DEFAULT
--source unexpected_result.inc
}
--let $error_codes = ER_BAD_NULL_ERROR
INSERT INTO t1 (c) VALUES (NULL);
--source check_errors.inc
if ($mysql_errname != ER_BAD_NULL_ERROR)
{
--let $functionality = NOT NULL columns
--source unexpected_result.inc
}
# HEX should be universal for all column types
SELECT HEX(c), HEX(c2) FROM t1;
--let $error_codes = ER_BAD_NULL_ERROR
INSERT INTO t1 (c2) VALUES (NULL);
--source check_errors.inc
--eval INSERT INTO t1 (c) VALUES ($col_default)
if ($mysql_errname)
{
--let $functionality = DEFAULT
--source unexpected_result.inc
}
SELECT COUNT(c), COUNT(c2) FROM t1;
DROP TABLE t1;
}
}
# We don't want to preserve it
let $col_default = ;

View File

@ -0,0 +1,65 @@
#
# NULL attribute and DEFAULT NULL in columns
#
# Usage:
# let $col_definition = <column type (and possibly more options)>;
# let $col_default = <default non-null value for a column>;
# --source col_null.inc
#
# We will add NULL at the end of $col;
#
# Also, if $col_default is defined,
# we will create a table with 3 columns (one with DEFAULT NULL,
# one with DEFAULT $col_default, and one without any default)
#
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--let $create_definition = c $col_definition NULL
--source create_table.inc
SHOW COLUMNS IN t1;
if ($mysql_errname)
{
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (c) VALUES (NULL);
if ($mysql_errname)
{
--let $functionality = NULLable columns
--source unexpected_result.inc
}
SELECT COUNT(c), COUNT(*) FROM t1;
DROP TABLE t1;
}
if ($col_default != '')
{
let $create_definition =
c $col_definition NULL,
c1 $col_definition NULL DEFAULT NULL,
c2 $col_definition NULL DEFAULT $col_default
;
--source create_table.inc
if ($mysql_errname)
{
--source unexpected_result.inc
}
if (!$mysql_errname)
{
SHOW COLUMNS IN t1;
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
DROP TABLE t1;
}
}
# We don't want to preserve it
let $col_default = ;

View File

@ -0,0 +1,20 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a <INT_COLUMN> DEFAULT '0') ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a int(11) # 0
INSERT INTO t1 (a) VALUES (1);
SELECT * FROM t1;
a
1
ALTER TABLE t1 ADD COLUMN b <CHAR_COLUMN> DEFAULT '';
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a int(11) # 0
b char(8) #
INSERT INTO t1 (b) VALUES ('a');
SELECT * FROM t1;
a b
0 a
1
DROP TABLE t1;

View File

@ -0,0 +1,49 @@
#
# Check whether DEFAULT column attribute
# is supported in CREATE and ALTER TABLE.
# If the attribute is supported at all, it will be covered
# in more details in col_option_null and col_option_not_null tests.
#
--source have_engine.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--let $create_definition = a $int_col DEFAULT '0'
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = DEFAULT values
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 3 #
SHOW COLUMNS IN t1;
INSERT INTO t1 (a) VALUES (1);
--sorted_result
SELECT * FROM t1;
--let $alter_definition = ADD COLUMN b $char_col DEFAULT ''
--source alter_table.inc
if ($mysql_errname)
{
--let $functionality = ALTER or DEFAULT
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 3 #
SHOW COLUMNS IN t1;
INSERT INTO t1 (b) VALUES ('a');
--sorted_result
SELECT * FROM t1;
}
DROP TABLE t1;
}
--source cleanup_engine.inc

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,260 @@
#
# NOT NULL column attribute
#
let $extra_col_opts = NOT NULL;
--source have_engine.inc
--echo #
--echo # BINARY columns
--echo #
--source type_binary.inc
--let $col_definition = BINARY $default_col_opts
--let $col_default = 0
--source col_not_null.inc
--echo #
--echo # VARBINARY columns
--echo #
--source type_varbinary.inc
--let $col_definition = VARBINARY(64) $default_col_opts
--let $col_default = 'test'
--source col_not_null.inc
--echo #
--echo # BIT columns
--echo #
--source type_bit.inc
--let $col_definition = BIT $default_col_opts
--let $col_default = 1
--source col_not_null.inc
--echo #
--echo # BLOB columns
--echo #
--source type_blob.inc
--let $col_definition = BLOB $default_col_opts
--source col_not_null.inc
--let $col_definition = TINYBLOB $default_col_opts
--source col_not_null.inc
--let $col_definition = MEDIUMBLOB $default_col_opts
--source col_not_null.inc
--let $col_definition = LONGBLOB $default_col_opts
--source col_not_null.inc
--echo #
--echo # BOOL columns
--echo #
--source type_bool.inc
--let $col_definition = BOOL $default_col_opts
--let $col_default = '0'
--source col_not_null.inc
--echo #
--echo # CHAR columns
--echo #
--source type_char.inc
--let $col_definition = CHAR $default_col_opts
--let $col_default = '_'
--source col_not_null.inc
--echo #
--echo # VARCHAR columns
--echo #
--source type_varchar.inc
--let $col_definition = VARCHAR(64) $default_col_opts
--let $col_default = 'test default'
--source col_not_null.inc
--echo #
--echo # date and time columns
--echo #
--source type_date_time.inc
--let $col_definition = DATE $default_col_opts
--let $col_default = '2012-12-21'
--source col_not_null.inc
--let $col_definition = DATETIME $default_col_opts
--let $col_default = '2012-12-21 12:21:12'
--source col_not_null.inc
# For TIMESTAMP the behavior is non-standard
# $col_opts already contains NOT NULL part (it's set in have_engine.inc)
let $create_definition =
c TIMESTAMP $col_opts,
c2 TIMESTAMP $col_opts DEFAULT '2012-02-21 12:21:12'
;
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = TIMESTAMP type or NOT NULL columns or DEFAULT
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--let $error_codes = ER_INVALID_DEFAULT
--let $alter_definition = ADD COLUMN err TIMESTAMP $col_opts DEFAULT NULL
--source alter_table.inc
if ($mysql_errname!=ER_INVALID_DEFAULT)
{
--let $functionality = ALTER or DEFAULT
--source unexpected_result.inc
}
INSERT INTO t1 (c) VALUES (NULL);
INSERT INTO t1 (c2) VALUES (NULL);
--replace_regex /2012-02-21 12:21:12/<DEFAULT_TIMESTAMP>/ /[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2} [[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}/<TIMESTAMP>/
SELECT c, c2 FROM t1;
DROP TABLE t1;
}
--let $create_definition = c TIMESTAMP $col_opts
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = TIMESTAMP type
--source unexpected_result.inc
}
if (!$mysql_errname)
{
SHOW COLUMNS IN t1;
INSERT INTO t1 (c) VALUES (NULL);
if ($mysql_errname)
{
--let $functionality = TIMESTAMP
--source unexpected_result.inc
}
--replace_regex /[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2} [[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}/<TIMESTAMP>/
SELECT * FROM t1;
DROP TABLE t1;
}
# End of TIMESTAMP exception
--let $col_definition = TIME $default_col_opts
--let $col_default = '12:21:12'
--source col_not_null.inc
--let $col_definition = YEAR $default_col_opts
--let $col_default = '2012'
--source col_not_null.inc
--let $col_definition = YEAR(2) $default_col_opts
--let $col_default = '12'
--source col_not_null.inc
--echo #
--echo # ENUM columns
--echo #
--source type_enum.inc
--let $col_definition = ENUM('test1','test2','test3') $default_col_opts
--let $col_default = 'test2'
--source col_not_null.inc
--echo #
--echo # Fixed point columns (NUMERIC, DECIMAL)
--echo #
--source type_fixed.inc
--let $col_definition = DECIMAL $default_col_opts
--let $col_default = 1.1
--source col_not_null.inc
--let $col_definition = NUMERIC $default_col_opts
--let $col_default = 0
--source col_not_null.inc
--echo #
--echo # Floating point columns (FLOAT, DOUBLE)
--echo #
--source type_float.inc
--let $col_definition = FLOAT $default_col_opts
--let $col_default = 1.1
--source col_not_null.inc
--let $col_definition = DOUBLE $default_col_opts
--let $col_default = 0
--source col_not_null.inc
--echo #
--echo # INT columns
--echo #
--source type_int.inc
--let $col_definition = INT $default_col_opts
--let $col_default = 2147483647
--source col_not_null.inc
--let $col_definition = TINYINT $default_col_opts
--let $col_default = 127
--source col_not_null.inc
--let $col_definition = SMALLINT $default_col_opts
--let $col_default = 0
--source col_not_null.inc
--let $col_definition = MEDIUMINT $default_col_opts
--let $col_default = 1
--source col_not_null.inc
--let $col_definition = BIGINT $default_col_opts
--let $col_default = 9223372036854775807
--source col_not_null.inc
--echo #
--echo # SET columns
--echo #
--source type_set.inc
--let $col_definition = SET('test1','test2','test3') $default_col_opts
--let $col_default = 'test2,test3'
--source col_not_null.inc
--echo #
--echo # TEXT columns
--echo #
--source type_text.inc
--let $col_definition = TEXT $default_col_opts
--source col_not_null.inc
--let $col_definition = TINYTEXT $default_col_opts
--source col_not_null.inc
--let $col_definition = MEDIUMTEXT $default_col_opts
--source col_not_null.inc
--let $col_definition = LONGTEXT $default_col_opts
--source col_not_null.inc
--source cleanup_engine.inc

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,208 @@
#
# NULL column attribute
#
let $extra_col_opts = NULL;
--source have_engine.inc
--echo #
--echo # BINARY columns
--echo #
--source type_binary.inc
--let $col_definition = BINARY $default_col_opts
--let $col_default = 0
--source col_null.inc
--echo #
--echo # VARBINARY columns
--echo #
--source type_varbinary.inc
--let $col_definition = VARBINARY(64) $default_col_opts
--let $col_default = 'test'
--source col_null.inc
--echo #
--echo # BIT columns
--echo #
--source type_bit.inc
--let $col_definition = BIT $default_col_opts
--let $col_default = 1
--source col_null.inc
--echo #
--echo # BLOB columns
--echo #
--source type_blob.inc
--let $col_definition = BLOB $default_col_opts
--source col_null.inc
--let $col_definition = TINYBLOB $default_col_opts
--source col_null.inc
--let $col_definition = MEDIUMBLOB $default_col_opts
--source col_null.inc
--let $col_definition = LONGBLOB $default_col_opts
--source col_null.inc
--echo #
--echo # BOOL columns
--echo #
--source type_bool.inc
--let $col_definition = BOOL $default_col_opts
--let $col_default = '0'
--source col_null.inc
--echo #
--echo # CHAR columns
--echo #
--source type_char.inc
--let $col_definition = CHAR $default_col_opts
--let $col_default = '_'
--source col_null.inc
--echo #
--echo # VARCHAR columns
--echo #
--source type_varchar.inc
--let $col_definition = VARCHAR(64) $default_col_opts
--let $col_default = 'test default'
--source col_null.inc
--echo #
--echo # date and time columns
--echo #
--source type_date_time.inc
--let $col_definition = DATE $default_col_opts
--let $col_default = '2012-12-21'
--source col_null.inc
--let $col_definition = DATETIME $default_col_opts
--let $col_default = '2012-12-21 12:21:12'
--source col_null.inc
--let $col_definition = TIMESTAMP $default_col_opts
--let $col_default = '2012-12-21 12:21:12'
--source col_null.inc
--let $col_definition = TIME $default_col_opts
--let $col_default = '12:21:12'
--source col_null.inc
--let $col_definition = YEAR $default_col_opts
--let $col_default = '2012'
--source col_null.inc
--let $col_definition = YEAR(2) $default_col_opts
--let $col_default = '12'
--source col_null.inc
--echo #
--echo # ENUM columns
--echo #
--source type_enum.inc
--let $col_definition = ENUM('test1','test2','test3') $default_col_opts
--let $col_default = 'test2'
--source col_null.inc
--echo #
--echo # Fixed point columns (NUMERIC, DECIMAL)
--echo #
--source type_fixed.inc
--let $col_definition = DECIMAL $default_col_opts
--let $col_default = 1.1
--source col_null.inc
--let $col_definition = NUMERIC $default_col_opts
--let $col_default = 0
--source col_null.inc
--echo #
--echo # Floating point columns (FLOAT, DOUBLE)
--echo #
--source type_float.inc
--let $col_definition = FLOAT $default_col_opts
--let $col_default = 1.1
--source col_null.inc
--let $col_definition = DOUBLE $default_col_opts
--let $col_default = 0
--source col_null.inc
--echo #
--echo # INT columns
--echo #
--source type_int.inc
--let $col_definition = INT $default_col_opts
--let $col_default = 2147483647
--source col_null.inc
--let $col_definition = TINYINT $default_col_opts
--let $col_default = 127
--source col_null.inc
--let $col_definition = SMALLINT $default_col_opts
--let $col_default = 0
--source col_null.inc
--let $col_definition = MEDIUMINT $default_col_opts
--let $col_default = 1
--source col_null.inc
--let $col_definition = BIGINT $default_col_opts
--let $col_default = 9223372036854775807
--source col_null.inc
--echo #
--echo # SET columns
--echo #
--source type_set.inc
--let $col_definition = SET('test1','test2','test3') $default_col_opts
--let $col_default = 'test2,test3'
--source col_null.inc
--echo #
--echo # TEXT columns
--echo #
--source type_text.inc
--let $col_definition = TEXT $default_col_opts
--source col_null.inc
--let $col_definition = TINYTEXT $default_col_opts
--source col_null.inc
--let $col_definition = MEDIUMTEXT $default_col_opts
--source col_null.inc
--let $col_definition = LONGTEXT $default_col_opts
--source col_null.inc
--source cleanup_engine.inc

View File

@ -0,0 +1,697 @@
#
# Fixed point columns (NUMERIC, DECIMAL)
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (d DECIMAL UNSIGNED <CUSTOM_COL_OPTIONS>,
d0 DECIMAL(0) UNSIGNED <CUSTOM_COL_OPTIONS>,
d1_1 DECIMAL(1,1) UNSIGNED <CUSTOM_COL_OPTIONS>,
d10_2 DECIMAL(10,2) UNSIGNED <CUSTOM_COL_OPTIONS>,
d60_10 DECIMAL(60,10) UNSIGNED <CUSTOM_COL_OPTIONS>,
n NUMERIC UNSIGNED <CUSTOM_COL_OPTIONS>,
n0_0 NUMERIC(0,0) UNSIGNED <CUSTOM_COL_OPTIONS>,
n1 NUMERIC(1) UNSIGNED <CUSTOM_COL_OPTIONS>,
n20_4 NUMERIC(20,4) UNSIGNED <CUSTOM_COL_OPTIONS>,
n65_4 NUMERIC(65,4) UNSIGNED <CUSTOM_COL_OPTIONS>
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
d decimal(10,0) unsigned # # #
d0 decimal(10,0) unsigned # # #
d1_1 decimal(1,1) unsigned # # #
d10_2 decimal(10,2) unsigned # # #
d60_10 decimal(60,10) unsigned # # #
n decimal(10,0) unsigned # # #
n0_0 decimal(10,0) unsigned # # #
n1 decimal(1,0) unsigned # # #
n20_4 decimal(20,4) unsigned # # #
n65_4 decimal(65,4) unsigned # # #
INSERT INTO t1 VALUES (100,123456,0.3,40000.25,123456789123456789.10001,1024,7000.0,8.0,999999.9,9223372036854775807);
INSERT INTO t1 VALUES (0,0,0,0,0,0,0,0,0,0);
INSERT INTO t1 VALUES (9999999999.0,9999999999.0,0.9,99999999.99,99999999999999999999999999999999999999999999999999.9999999999,9999999999.0,9999999999.0,9.0,9999999999999999.9999,9999999999999999999999999999999999999999999999999999999999999.9999);
SELECT * FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
INSERT INTO t1 VALUES (-100,-123456,-0.3,-40000.25,-123456789123456789.10001,-1024,-7000.0,-8.0,-999999.9,-9223372036854775807);
Warnings:
Warning 1264 Out of range value for column 'd' at row 1
Warning 1264 Out of range value for column 'd0' at row 1
Warning 1264 Out of range value for column 'd1_1' at row 1
Warning 1264 Out of range value for column 'd10_2' at row 1
Warning 1264 Out of range value for column 'd60_10' at row 1
Warning 1264 Out of range value for column 'n' at row 1
Warning 1264 Out of range value for column 'n0_0' at row 1
Warning 1264 Out of range value for column 'n1' at row 1
Warning 1264 Out of range value for column 'n20_4' at row 1
Warning 1264 Out of range value for column 'n65_4' at row 1
INSERT INTO t1 VALUES (-9999999999.0,-9999999999.0,-0.9,-99999999.99,-99999999999999999999999999999999999999999999999999.9999999999,-9999999999.0,-9999999999.0,-9.0,-9999999999999999.9999,-9999999999999999999999999999999999999999999999999999999999999.9999);
Warnings:
Warning 1264 Out of range value for column 'd' at row 1
Warning 1264 Out of range value for column 'd0' at row 1
Warning 1264 Out of range value for column 'd1_1' at row 1
Warning 1264 Out of range value for column 'd10_2' at row 1
Warning 1264 Out of range value for column 'd60_10' at row 1
Warning 1264 Out of range value for column 'n' at row 1
Warning 1264 Out of range value for column 'n0_0' at row 1
Warning 1264 Out of range value for column 'n1' at row 1
Warning 1264 Out of range value for column 'n20_4' at row 1
Warning 1264 Out of range value for column 'n65_4' at row 1
SELECT * FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
SELECT * FROM t1 WHERE n20_4 = 9999999999999999.9999 OR d < 100;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
INSERT INTO t1 SELECT n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4 FROM t1 WHERE n65_4 = ( SELECT MAX(n65_4) FROM t1 );
Warnings:
Warning 1264 Out of range value for column 'd' at row 1
Warning 1264 Out of range value for column 'd0' at row 1
Warning 1264 Out of range value for column 'd1_1' at row 1
Warning 1264 Out of range value for column 'd10_2' at row 1
Warning 1264 Out of range value for column 'd60_10' at row 1
Warning 1264 Out of range value for column 'n' at row 1
Warning 1264 Out of range value for column 'n0_0' at row 1
Warning 1264 Out of range value for column 'n1' at row 1
Warning 1264 Out of range value for column 'n20_4' at row 1
SELECT * FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
INSERT INTO t1 VALUES (10000000000.0,10000000000.0,1.1,100000000.99,100000000000000000000000000000000000000000000000000.0,10000000000.0,10000000000.0,10.0,10000000000000000.9999,10000000000000000000000000000000000000000000000000000000000000.9999);
Warnings:
Warning 1264 Out of range value for column 'd' at row 1
Warning 1264 Out of range value for column 'd0' at row 1
Warning 1264 Out of range value for column 'd1_1' at row 1
Warning 1264 Out of range value for column 'd10_2' at row 1
Warning 1264 Out of range value for column 'd60_10' at row 1
Warning 1264 Out of range value for column 'n' at row 1
Warning 1264 Out of range value for column 'n0_0' at row 1
Warning 1264 Out of range value for column 'n1' at row 1
Warning 1264 Out of range value for column 'n20_4' at row 1
Warning 1264 Out of range value for column 'n65_4' at row 1
SELECT * FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
INSERT INTO t1 VALUES (9999999999.1,9999999999.1,1.9,99999999.001,99999999999999999999999999999999999999999999999999.99999999991,9999999999.1,9999999999.1,9.1,9999999999999999.00001,9999999999999999999999999999999999999999999999999999999999999.11111);
Warnings:
Note 1265 Data truncated for column 'd' at row 1
Note 1265 Data truncated for column 'd0' at row 1
Warning 1264 Out of range value for column 'd1_1' at row 1
Note 1265 Data truncated for column 'd10_2' at row 1
Note 1265 Data truncated for column 'd60_10' at row 1
Note 1265 Data truncated for column 'n' at row 1
Note 1265 Data truncated for column 'n0_0' at row 1
Note 1265 Data truncated for column 'n1' at row 1
Note 1265 Data truncated for column 'n20_4' at row 1
Note 1265 Data truncated for column 'n65_4' at row 1
SELECT * FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
9999999999 9999999999 0.9 99999999.00 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.0000 9999999999999999999999999999999999999999999999999999999999999.1111
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66);
ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65.
ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6);
ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65.
ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66);
ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 30.
DROP TABLE t1;
CREATE TABLE t1 (a DECIMAL UNSIGNED <CUSTOM_COL_OPTIONS>,
b NUMERIC UNSIGNED <CUSTOM_COL_OPTIONS>
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a decimal(10,0) unsigned # # # #
b decimal(10,0) unsigned # # # #
INSERT INTO t1 (a,b) VALUES (1.0,-1.0);
Warnings:
Warning 1264 Out of range value for column 'b' at row 1
INSERT INTO t1 (a,b) VALUES (-100,100);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
SELECT * FROM t1;
a b
0 100
1 0
DROP TABLE t1;
#
# Floating point columns (FLOAT, DOUBLE)
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (f FLOAT UNSIGNED <CUSTOM_COL_OPTIONS>,
f0 FLOAT(0) UNSIGNED <CUSTOM_COL_OPTIONS>,
r1_1 REAL(1,1) UNSIGNED <CUSTOM_COL_OPTIONS>,
f23_0 FLOAT(23) UNSIGNED <CUSTOM_COL_OPTIONS>,
f20_3 FLOAT(20,3) UNSIGNED <CUSTOM_COL_OPTIONS>,
d DOUBLE UNSIGNED <CUSTOM_COL_OPTIONS>,
d1_0 DOUBLE(1,0) UNSIGNED <CUSTOM_COL_OPTIONS>,
d10_10 DOUBLE PRECISION (10,10) UNSIGNED <CUSTOM_COL_OPTIONS>,
d53 DOUBLE(53,0) UNSIGNED <CUSTOM_COL_OPTIONS>,
d53_10 DOUBLE(53,10) UNSIGNED <CUSTOM_COL_OPTIONS>
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
f float unsigned # # #
f0 float unsigned # # #
r1_1 double(1,1) unsigned # # #
f23_0 float unsigned # # #
f20_3 float(20,3) unsigned # # #
d double unsigned # # #
d1_0 double(1,0) unsigned # # #
d10_10 double(10,10) unsigned # # #
d53 double(53,0) unsigned # # #
d53_10 double(53,10) unsigned # # #
INSERT INTO t1 VALUES (12345.12345,12345.12345,0.9,123456789.123,56789.987,11111111.111,8.0,0.0123456789,1234566789123456789,99999999999999999.99999999);
SELECT * FROM t1;
f 12345.1
d 11111111.111
d10_10 0.0123456789
d1_0 8
d53 1234566789123456800
d53_10 100000000000000000.0000000000
f0 12345.1
f20_3 56789.988
f23_0 123457000
r1_1 0.9
INSERT INTO t1 VALUES (0,0,0,0,0,0,0,0,0,0);
INSERT INTO t1 VALUES (
99999999999999999999999999999999999999,
99999999999999999999999999999999999999.9999999999999999,
0.9,
99999999999999999999999999999999999999.9,
99999999999999999.999,
999999999999999999999999999999999999999999999999999999999999999999999999999999999,
9,
0.9999999999,
1999999999999999999999999999999999999999999999999999999,
19999999999999999999999999999999999999999999.9999999999
);
Warnings:
Warning 1264 Out of range value for column 'd53' at row 1
Warning 1264 Out of range value for column 'd53_10' at row 1
SELECT * FROM t1;
f 12345.1
d 0
d 11111111.111
d 1e81
d10_10 0.0000000000
d10_10 0.0123456789
d10_10 0.9999999999
d1_0 0
d1_0 8
d1_0 9
d53 0
d53 100000000000000000000000000000000000000000000000000000
d53 1234566789123456800
d53_10 0.0000000000
d53_10 100000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
f 0
f 1e38
f0 0
f0 12345.1
f0 1e38
f20_3 0.000
f20_3 56789.988
f20_3 99999998430674940.000
f23_0 0
f23_0 123457000
f23_0 1e38
r1_1 0.0
r1_1 0.9
r1_1 0.9
INSERT INTO t1 VALUES (-999999999999999999999999,-99999999999.999999999999,-0.9,-999.99999999999999999999,-99999999999999999.999,-999999999999999999999999999999999999999999999999999999999999-0.999,-9,-.9999999999,-999999999999999999999999999999.99999999999999999999999,-9999999999999999999999999999999999999999999.9999999999);
Warnings:
Warning 1264 Out of range value for column 'f' at row 1
Warning 1264 Out of range value for column 'f0' at row 1
Warning 1264 Out of range value for column 'r1_1' at row 1
Warning 1264 Out of range value for column 'f23_0' at row 1
Warning 1264 Out of range value for column 'f20_3' at row 1
Warning 1264 Out of range value for column 'd' at row 1
Warning 1264 Out of range value for column 'd1_0' at row 1
Warning 1264 Out of range value for column 'd10_10' at row 1
Warning 1264 Out of range value for column 'd53' at row 1
Warning 1264 Out of range value for column 'd53_10' at row 1
SELECT * FROM t1;
f 12345.1
d 0
d 0
d 11111111.111
d 1e81
d10_10 0.0000000000
d10_10 0.0000000000
d10_10 0.0123456789
d10_10 0.9999999999
d1_0 0
d1_0 0
d1_0 8
d1_0 9
d53 0
d53 0
d53 100000000000000000000000000000000000000000000000000000
d53 1234566789123456800
d53_10 0.0000000000
d53_10 0.0000000000
d53_10 100000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
f 0
f 0
f 1e38
f0 0
f0 0
f0 12345.1
f0 1e38
f20_3 0.000
f20_3 0.000
f20_3 56789.988
f20_3 99999998430674940.000
f23_0 0
f23_0 0
f23_0 123457000
f23_0 1e38
r1_1 0.0
r1_1 0.0
r1_1 0.9
r1_1 0.9
SELECT MAX(f), MAX(f0), MAX(r1_1), MAX(f23_0), MAX(f20_3), MAX(d), MAX(d1_0), MAX(d10_10), MAX(d53), MAX(d53_10) FROM t1;
MAX(f) 9.999999680285692e37
MAX(d) 1e81
MAX(d10_10) 0.9999999999
MAX(d1_0) 9
MAX(d53) 100000000000000000000000000000000000000000000000000000
MAX(d53_10) 10000000000000000000000000000000000000000000.0000000000
MAX(f0) 9.999999680285692e37
MAX(f20_3) 99999998430674940.000
MAX(f23_0) 9.999999680285692e37
MAX(r1_1) 0.9
INSERT INTO t1 SELECT d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10 FROM t1 ORDER BY d53_10 DESC LIMIT 1;
Warnings:
Warning 1264 Out of range value for column 'f' at row 1
Warning 1264 Out of range value for column 'f0' at row 1
Warning 1264 Out of range value for column 'r1_1' at row 1
Warning 1264 Out of range value for column 'f23_0' at row 1
Warning 1264 Out of range value for column 'f20_3' at row 1
Warning 1264 Out of range value for column 'd1_0' at row 1
SELECT * FROM t1;
f 12345.1
d 0
d 0
d 11111111.111
d 1e43
d 1e81
d10_10 0.0000000000
d10_10 0.0000000000
d10_10 0.0123456789
d10_10 0.9999999999
d10_10 10000000000000000000000000000000000000000000.0000000000
d1_0 0
d1_0 0
d1_0 8
d1_0 9
d1_0 9
d53 0
d53 0
d53 10000000000000000000000000000000000000000000
d53 100000000000000000000000000000000000000000000000000000
d53 1234566789123456800
d53_10 0.0000000000
d53_10 0.0000000000
d53_10 100000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
f 0
f 0
f 1e38
f 3.40282e38
f0 0
f0 0
f0 12345.1
f0 1e38
f0 3.40282e38
f20_3 0.000
f20_3 0.000
f20_3 56789.988
f20_3 99999998430674940.000
f20_3 99999998430674940.000
f23_0 0
f23_0 0
f23_0 123457000
f23_0 1e38
f23_0 3.40282e38
r1_1 0.0
r1_1 0.0
r1_1 0.9
r1_1 0.9
r1_1 0.9
INSERT INTO t1 VALUES (
999999999999999999999999999999999999999,
999999999999999999999999999999999999999.9999999999999999,
1.9,
999999999999999999999999999999999999999.9,
999999999999999999.999,
9999999999999999999999999999999999999999999999999999999999999999999999999999999999,
99,
1.9999999999,
1999999999999999999999999999999999999999999999999999999,
19999999999999999999999999999999999999999999.9999999999
);
Warnings:
Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Warning 1264 Out of range value for column 'f' at row 1
Warning 1264 Out of range value for column 'f0' at row 1
Warning 1264 Out of range value for column 'r1_1' at row 1
Warning 1264 Out of range value for column 'f23_0' at row 1
Warning 1264 Out of range value for column 'f20_3' at row 1
Warning 1264 Out of range value for column 'd1_0' at row 1
Warning 1264 Out of range value for column 'd10_10' at row 1
Warning 1264 Out of range value for column 'd53' at row 1
Warning 1264 Out of range value for column 'd53_10' at row 1
SELECT * FROM t1;
f 12345.1
d 0
d 0
d 11111111.111
d 1e43
d 1e65
d 1e81
d10_10 0.0000000000
d10_10 0.0000000000
d10_10 0.0123456789
d10_10 0.9999999999
d10_10 0.9999999999
d10_10 10000000000000000000000000000000000000000000.0000000000
d1_0 0
d1_0 0
d1_0 8
d1_0 9
d1_0 9
d1_0 9
d53 0
d53 0
d53 10000000000000000000000000000000000000000000
d53 100000000000000000000000000000000000000000000000000000
d53 100000000000000000000000000000000000000000000000000000
d53 1234566789123456800
d53_10 0.0000000000
d53_10 0.0000000000
d53_10 100000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
f 0
f 0
f 1e38
f 3.40282e38
f 3.40282e38
f0 0
f0 0
f0 12345.1
f0 1e38
f0 3.40282e38
f0 3.40282e38
f20_3 0.000
f20_3 0.000
f20_3 56789.988
f20_3 99999998430674940.000
f20_3 99999998430674940.000
f20_3 99999998430674940.000
f23_0 0
f23_0 0
f23_0 123457000
f23_0 1e38
f23_0 3.40282e38
f23_0 3.40282e38
r1_1 0.0
r1_1 0.0
r1_1 0.9
r1_1 0.9
r1_1 0.9
r1_1 0.9
ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0);
ERROR 42000: Display width out of range for 'd0_0' (max = 255)
ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1);
ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65.
ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35);
ERROR 42000: Too big scale 35 specified for 'n66_66'. Maximum is 30.
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE UNSIGNED <CUSTOM_COL_OPTIONS>,
b FLOAT UNSIGNED <CUSTOM_COL_OPTIONS>
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a double unsigned # # # #
b float unsigned # # # #
INSERT INTO t1 (a,b) VALUES (1.0,-1.0);
Warnings:
Warning 1264 Out of range value for column 'b' at row 1
INSERT INTO t1 (a,b) VALUES (-100,100);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
SELECT * FROM t1;
a b
0 100
1 0
DROP TABLE t1;
#
# INT columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (i INT UNSIGNED <CUSTOM_COL_OPTIONS>,
i0 INT(0) UNSIGNED <CUSTOM_COL_OPTIONS>,
i1 INT(1) UNSIGNED <CUSTOM_COL_OPTIONS>,
i20 INT(20) UNSIGNED <CUSTOM_COL_OPTIONS>,
t TINYINT UNSIGNED <CUSTOM_COL_OPTIONS>,
t0 TINYINT(0) UNSIGNED <CUSTOM_COL_OPTIONS>,
t1 TINYINT(1) UNSIGNED <CUSTOM_COL_OPTIONS>,
t20 TINYINT(20) UNSIGNED <CUSTOM_COL_OPTIONS>,
s SMALLINT UNSIGNED <CUSTOM_COL_OPTIONS>,
s0 SMALLINT(0) UNSIGNED <CUSTOM_COL_OPTIONS>,
s1 SMALLINT(1) UNSIGNED <CUSTOM_COL_OPTIONS>,
s20 SMALLINT(20) UNSIGNED <CUSTOM_COL_OPTIONS>,
m MEDIUMINT UNSIGNED <CUSTOM_COL_OPTIONS>,
m0 MEDIUMINT(0) UNSIGNED <CUSTOM_COL_OPTIONS>,
m1 MEDIUMINT(1) UNSIGNED <CUSTOM_COL_OPTIONS>,
m20 MEDIUMINT(20) UNSIGNED <CUSTOM_COL_OPTIONS>,
b BIGINT UNSIGNED <CUSTOM_COL_OPTIONS>,
b0 BIGINT(0) UNSIGNED <CUSTOM_COL_OPTIONS>,
b1 BIGINT(1) UNSIGNED <CUSTOM_COL_OPTIONS>,
b20 BIGINT(20) UNSIGNED <CUSTOM_COL_OPTIONS>
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
i int(10) unsigned # # #
i0 int(10) unsigned # # #
i1 int(1) unsigned # # #
i20 int(20) unsigned # # #
t tinyint(3) unsigned # # #
t0 tinyint(3) unsigned # # #
t1 tinyint(1) unsigned # # #
t20 tinyint(20) unsigned # # #
s smallint(5) unsigned # # #
s0 smallint(5) unsigned # # #
s1 smallint(1) unsigned # # #
s20 smallint(20) unsigned # # #
m mediumint(8) unsigned # # #
m0 mediumint(8) unsigned # # #
m1 mediumint(1) unsigned # # #
m20 mediumint(20) unsigned # # #
b bigint(20) unsigned # # #
b0 bigint(20) unsigned # # #
b1 bigint(1) unsigned # # #
b20 bigint(20) unsigned # # #
INSERT INTO t1 VALUES (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
INSERT INTO t1 VALUES (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
INSERT INTO t1 VALUES (2147483647,2147483647,2147483647,2147483647,127,127,127,127,32767,32767,32767,32767,8388607,8388607,8388607,8388607,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807);
SELECT * FROM t1;
i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
INSERT INTO t1 VALUES (-2147483648,-2147483648,-2147483648,-2147483648,-128,-128,-128,-128,-32768,-32768,-32768,-32768,-8388608,-8388608,-8388608,-8388608,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808);
Warnings:
Warning 1264 Out of range value for column 'i' at row 1
Warning 1264 Out of range value for column 'i0' at row 1
Warning 1264 Out of range value for column 'i1' at row 1
Warning 1264 Out of range value for column 'i20' at row 1
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't0' at row 1
Warning 1264 Out of range value for column 't1' at row 1
Warning 1264 Out of range value for column 't20' at row 1
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 's0' at row 1
Warning 1264 Out of range value for column 's1' at row 1
Warning 1264 Out of range value for column 's20' at row 1
Warning 1264 Out of range value for column 'm' at row 1
Warning 1264 Out of range value for column 'm0' at row 1
Warning 1264 Out of range value for column 'm1' at row 1
Warning 1264 Out of range value for column 'm20' at row 1
Warning 1264 Out of range value for column 'b' at row 1
Warning 1264 Out of range value for column 'b0' at row 1
Warning 1264 Out of range value for column 'b1' at row 1
Warning 1264 Out of range value for column 'b20' at row 1
INSERT INTO t1 VALUES (4294967295,4294967295,4294967295,4294967295,255,255,255,255,65535,65535,65535,65535,16777215,16777215,16777215,16777215,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615);
SELECT * FROM t1;
i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
INSERT INTO t1 VALUES (-2147483649,-2147483649,-2147483649,-2147483649,-129,-129,-129,-129,-32769,-32769,-32769,-32769,-8388609,-8388609,-8388609,-8388609,-9223372036854775809,-9223372036854775809,-9223372036854775809,-9223372036854775809);
Warnings:
Warning 1264 Out of range value for column 'i' at row 1
Warning 1264 Out of range value for column 'i0' at row 1
Warning 1264 Out of range value for column 'i1' at row 1
Warning 1264 Out of range value for column 'i20' at row 1
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't0' at row 1
Warning 1264 Out of range value for column 't1' at row 1
Warning 1264 Out of range value for column 't20' at row 1
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 's0' at row 1
Warning 1264 Out of range value for column 's1' at row 1
Warning 1264 Out of range value for column 's20' at row 1
Warning 1264 Out of range value for column 'm' at row 1
Warning 1264 Out of range value for column 'm0' at row 1
Warning 1264 Out of range value for column 'm1' at row 1
Warning 1264 Out of range value for column 'm20' at row 1
Warning 1264 Out of range value for column 'b' at row 1
Warning 1264 Out of range value for column 'b0' at row 1
Warning 1264 Out of range value for column 'b1' at row 1
Warning 1264 Out of range value for column 'b20' at row 1
INSERT INTO t1 VALUES (4294967296,4294967296,4294967296,4294967296,256,256,256,256,65536,65536,65536,65536,16777216,16777216,16777216,16777216,18446744073709551616,18446744073709551616,18446744073709551616,18446744073709551616);
Warnings:
Warning 1264 Out of range value for column 'i' at row 1
Warning 1264 Out of range value for column 'i0' at row 1
Warning 1264 Out of range value for column 'i1' at row 1
Warning 1264 Out of range value for column 'i20' at row 1
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't0' at row 1
Warning 1264 Out of range value for column 't1' at row 1
Warning 1264 Out of range value for column 't20' at row 1
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 's0' at row 1
Warning 1264 Out of range value for column 's1' at row 1
Warning 1264 Out of range value for column 's20' at row 1
Warning 1264 Out of range value for column 'm' at row 1
Warning 1264 Out of range value for column 'm0' at row 1
Warning 1264 Out of range value for column 'm1' at row 1
Warning 1264 Out of range value for column 'm20' at row 1
Warning 1264 Out of range value for column 'b' at row 1
Warning 1264 Out of range value for column 'b0' at row 1
Warning 1264 Out of range value for column 'b1' at row 1
Warning 1264 Out of range value for column 'b20' at row 1
INSERT INTO t1 SELECT b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b FROM t1 WHERE b IN (-9223372036854775808,9223372036854775807,18446744073709551615);
Warnings:
Warning 1264 Out of range value for column 'i' at row 1
Warning 1264 Out of range value for column 'i0' at row 1
Warning 1264 Out of range value for column 'i1' at row 1
Warning 1264 Out of range value for column 'i20' at row 1
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't0' at row 1
Warning 1264 Out of range value for column 't1' at row 1
Warning 1264 Out of range value for column 't20' at row 1
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 's0' at row 1
Warning 1264 Out of range value for column 's1' at row 1
Warning 1264 Out of range value for column 's20' at row 1
Warning 1264 Out of range value for column 'm' at row 1
Warning 1264 Out of range value for column 'm0' at row 1
Warning 1264 Out of range value for column 'm1' at row 1
Warning 1264 Out of range value for column 'm20' at row 1
Warning 1264 Out of range value for column 'i' at row 2
Warning 1264 Out of range value for column 'i0' at row 2
Warning 1264 Out of range value for column 'i1' at row 2
Warning 1264 Out of range value for column 'i20' at row 2
Warning 1264 Out of range value for column 't' at row 2
Warning 1264 Out of range value for column 't0' at row 2
Warning 1264 Out of range value for column 't1' at row 2
Warning 1264 Out of range value for column 't20' at row 2
Warning 1264 Out of range value for column 's' at row 2
Warning 1264 Out of range value for column 's0' at row 2
Warning 1264 Out of range value for column 's1' at row 2
Warning 1264 Out of range value for column 's20' at row 2
Warning 1264 Out of range value for column 'm' at row 2
Warning 1264 Out of range value for column 'm0' at row 2
Warning 1264 Out of range value for column 'm1' at row 2
Warning 1264 Out of range value for column 'm20' at row 2
Warning 1264 Out of range value for column 'i' at row 3
Warning 1264 Out of range value for column 'i0' at row 3
Warning 1264 Out of range value for column 'i1' at row 3
Warning 1264 Out of range value for column 'i20' at row 3
Warning 1264 Out of range value for column 't' at row 3
Warning 1264 Out of range value for column 't0' at row 3
Warning 1264 Out of range value for column 't1' at row 3
Warning 1264 Out of range value for column 't20' at row 3
Warning 1264 Out of range value for column 's' at row 3
Warning 1264 Out of range value for column 's0' at row 3
Warning 1264 Out of range value for column 's1' at row 3
Warning 1264 Out of range value for column 's20' at row 3
Warning 1264 Out of range value for column 'm' at row 3
Warning 1264 Out of range value for column 'm0' at row 3
Warning 1264 Out of range value for column 'm1' at row 3
Warning 1264 Out of range value for column 'm20' at row 3
SELECT * FROM t1;
i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
ALTER TABLE t1 ADD COLUMN i257 INT(257);
ERROR 42000: Display width out of range for 'i257' (max = 255)
DROP TABLE t1;
CREATE TABLE t1 (t TINYINT UNSIGNED <CUSTOM_COL_OPTIONS>,
s SMALLINT UNSIGNED <CUSTOM_COL_OPTIONS>,
m MEDIUMINT UNSIGNED <CUSTOM_COL_OPTIONS>,
i INT UNSIGNED <CUSTOM_COL_OPTIONS>,
b BIGINT UNSIGNED <CUSTOM_COL_OPTIONS>
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
t tinyint(3) unsigned # # # #
s smallint(5) unsigned # # # #
m mediumint(8) unsigned # # # #
i int(10) unsigned # # # #
b bigint(20) unsigned # # # #
INSERT INTO t1 (t,s,m,i,b) VALUES (255,65535,16777215,4294967295,18446744073709551615);
INSERT INTO t1 (t,s,m,i,b) VALUES (-1,-1,-1,-1,-1);
Warnings:
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 'm' at row 1
Warning 1264 Out of range value for column 'i' at row 1
Warning 1264 Out of range value for column 'b' at row 1
SELECT * FROM t1;
t s m i b
0 0 0 0 0
255 65535 16777215 4294967295 18446744073709551615
DROP TABLE t1;

View File

@ -0,0 +1,95 @@
#
# UNSIGNED column attribute
#
let $extra_type_opts = UNSIGNED;
--source have_engine.inc
--echo #
--echo # Fixed point columns (NUMERIC, DECIMAL)
--echo #
--source type_fixed.inc
let $create_definition =
a DECIMAL $col_opts,
b NUMERIC $col_opts
;
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Fixed point types or UNSIGNED columns
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 3 # 4 # 5 # 6 #
SHOW COLUMNS IN t1;
INSERT INTO t1 (a,b) VALUES (1.0,-1.0);
INSERT INTO t1 (a,b) VALUES (-100,100);
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
}
--echo #
--echo # Floating point columns (FLOAT, DOUBLE)
--echo #
--source type_float.inc
let $create_definition =
a DOUBLE $col_opts,
b FLOAT $col_opts
;
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Floating point types or UNSIGNED columns
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 3 # 4 # 5 # 6 #
SHOW COLUMNS IN t1;
INSERT INTO t1 (a,b) VALUES (1.0,-1.0);
INSERT INTO t1 (a,b) VALUES (-100,100);
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
}
--echo #
--echo # INT columns
--echo #
--source type_int.inc
let $create_definition =
t TINYINT $col_opts,
s SMALLINT $col_opts,
m MEDIUMINT $col_opts,
i INT $col_opts,
b BIGINT $col_opts
;
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = INT types or UNSIGNED columns
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 3 # 4 # 5 # 6 #
SHOW COLUMNS IN t1;
INSERT INTO t1 (t,s,m,i,b) VALUES (255,65535,16777215,4294967295,18446744073709551615);
INSERT INTO t1 (t,s,m,i,b) VALUES (-1,-1,-1,-1,-1);
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
}
--source cleanup_engine.inc

View File

@ -0,0 +1,679 @@
#
# Fixed point columns (NUMERIC, DECIMAL)
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (d DECIMAL ZEROFILL <CUSTOM_COL_OPTIONS>,
d0 DECIMAL(0) ZEROFILL <CUSTOM_COL_OPTIONS>,
d1_1 DECIMAL(1,1) ZEROFILL <CUSTOM_COL_OPTIONS>,
d10_2 DECIMAL(10,2) ZEROFILL <CUSTOM_COL_OPTIONS>,
d60_10 DECIMAL(60,10) ZEROFILL <CUSTOM_COL_OPTIONS>,
n NUMERIC ZEROFILL <CUSTOM_COL_OPTIONS>,
n0_0 NUMERIC(0,0) ZEROFILL <CUSTOM_COL_OPTIONS>,
n1 NUMERIC(1) ZEROFILL <CUSTOM_COL_OPTIONS>,
n20_4 NUMERIC(20,4) ZEROFILL <CUSTOM_COL_OPTIONS>,
n65_4 NUMERIC(65,4) ZEROFILL <CUSTOM_COL_OPTIONS>
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
d decimal(10,0) unsigned zerofill # # #
d0 decimal(10,0) unsigned zerofill # # #
d1_1 decimal(1,1) unsigned zerofill # # #
d10_2 decimal(10,2) unsigned zerofill # # #
d60_10 decimal(60,10) unsigned zerofill # # #
n decimal(10,0) unsigned zerofill # # #
n0_0 decimal(10,0) unsigned zerofill # # #
n1 decimal(1,0) unsigned zerofill # # #
n20_4 decimal(20,4) unsigned zerofill # # #
n65_4 decimal(65,4) unsigned zerofill # # #
INSERT INTO t1 VALUES (100,123456,0.3,40000.25,123456789123456789.10001,1024,7000.0,8.0,999999.9,9223372036854775807);
INSERT INTO t1 VALUES (0,0,0,0,0,0,0,0,0,0);
INSERT INTO t1 VALUES (9999999999.0,9999999999.0,0.9,99999999.99,99999999999999999999999999999999999999999999999999.9999999999,9999999999.0,9999999999.0,9.0,9999999999999999.9999,9999999999999999999999999999999999999999999999999999999999999.9999);
SELECT * FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
0000000100 0000123456 0.3 00040000.25 00000000000000000000000000000000123456789123456789.1000100000 0000001024 0000007000 8 0000000000999999.9000 0000000000000000000000000000000000000000009223372036854775807.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
INSERT INTO t1 VALUES (-100,-123456,-0.3,-40000.25,-123456789123456789.10001,-1024,-7000.0,-8.0,-999999.9,-9223372036854775807);
Warnings:
Warning 1264 Out of range value for column 'd' at row 1
Warning 1264 Out of range value for column 'd0' at row 1
Warning 1264 Out of range value for column 'd1_1' at row 1
Warning 1264 Out of range value for column 'd10_2' at row 1
Warning 1264 Out of range value for column 'd60_10' at row 1
Warning 1264 Out of range value for column 'n' at row 1
Warning 1264 Out of range value for column 'n0_0' at row 1
Warning 1264 Out of range value for column 'n1' at row 1
Warning 1264 Out of range value for column 'n20_4' at row 1
Warning 1264 Out of range value for column 'n65_4' at row 1
INSERT INTO t1 VALUES (-9999999999.0,-9999999999.0,-0.9,-99999999.99,-99999999999999999999999999999999999999999999999999.9999999999,-9999999999.0,-9999999999.0,-9.0,-9999999999999999.9999,-9999999999999999999999999999999999999999999999999999999999999.9999);
Warnings:
Warning 1264 Out of range value for column 'd' at row 1
Warning 1264 Out of range value for column 'd0' at row 1
Warning 1264 Out of range value for column 'd1_1' at row 1
Warning 1264 Out of range value for column 'd10_2' at row 1
Warning 1264 Out of range value for column 'd60_10' at row 1
Warning 1264 Out of range value for column 'n' at row 1
Warning 1264 Out of range value for column 'n0_0' at row 1
Warning 1264 Out of range value for column 'n1' at row 1
Warning 1264 Out of range value for column 'n20_4' at row 1
Warning 1264 Out of range value for column 'n65_4' at row 1
SELECT * FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
0000000100 0000123456 0.3 00040000.25 00000000000000000000000000000000123456789123456789.1000100000 0000001024 0000007000 8 0000000000999999.9000 0000000000000000000000000000000000000000009223372036854775807.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
SELECT * FROM t1 WHERE n20_4 = 9999999999999999.9999 OR d < 100;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
INSERT INTO t1 SELECT n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4 FROM t1 WHERE n65_4 = ( SELECT MAX(n65_4) FROM t1 );
Warnings:
Warning 1264 Out of range value for column 'd' at row 1
Warning 1264 Out of range value for column 'd0' at row 1
Warning 1264 Out of range value for column 'd1_1' at row 1
Warning 1264 Out of range value for column 'd10_2' at row 1
Warning 1264 Out of range value for column 'd60_10' at row 1
Warning 1264 Out of range value for column 'n' at row 1
Warning 1264 Out of range value for column 'n0_0' at row 1
Warning 1264 Out of range value for column 'n1' at row 1
Warning 1264 Out of range value for column 'n20_4' at row 1
SELECT * FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
0000000100 0000123456 0.3 00040000.25 00000000000000000000000000000000123456789123456789.1000100000 0000001024 0000007000 8 0000000000999999.9000 0000000000000000000000000000000000000000009223372036854775807.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
INSERT INTO t1 VALUES (10000000000.0,10000000000.0,1.1,100000000.99,100000000000000000000000000000000000000000000000000.0,10000000000.0,10000000000.0,10.0,10000000000000000.9999,10000000000000000000000000000000000000000000000000000000000000.9999);
Warnings:
Warning 1264 Out of range value for column 'd' at row 1
Warning 1264 Out of range value for column 'd0' at row 1
Warning 1264 Out of range value for column 'd1_1' at row 1
Warning 1264 Out of range value for column 'd10_2' at row 1
Warning 1264 Out of range value for column 'd60_10' at row 1
Warning 1264 Out of range value for column 'n' at row 1
Warning 1264 Out of range value for column 'n0_0' at row 1
Warning 1264 Out of range value for column 'n1' at row 1
Warning 1264 Out of range value for column 'n20_4' at row 1
Warning 1264 Out of range value for column 'n65_4' at row 1
SELECT * FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
0000000100 0000123456 0.3 00040000.25 00000000000000000000000000000000123456789123456789.1000100000 0000001024 0000007000 8 0000000000999999.9000 0000000000000000000000000000000000000000009223372036854775807.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
INSERT INTO t1 VALUES (9999999999.1,9999999999.1,1.9,99999999.001,99999999999999999999999999999999999999999999999999.99999999991,9999999999.1,9999999999.1,9.1,9999999999999999.00001,9999999999999999999999999999999999999999999999999999999999999.11111);
Warnings:
Note 1265 Data truncated for column 'd' at row 1
Note 1265 Data truncated for column 'd0' at row 1
Warning 1264 Out of range value for column 'd1_1' at row 1
Note 1265 Data truncated for column 'd10_2' at row 1
Note 1265 Data truncated for column 'd60_10' at row 1
Note 1265 Data truncated for column 'n' at row 1
Note 1265 Data truncated for column 'n0_0' at row 1
Note 1265 Data truncated for column 'n1' at row 1
Note 1265 Data truncated for column 'n20_4' at row 1
Note 1265 Data truncated for column 'n65_4' at row 1
SELECT * FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
0000000100 0000123456 0.3 00040000.25 00000000000000000000000000000000123456789123456789.1000100000 0000001024 0000007000 8 0000000000999999.9000 0000000000000000000000000000000000000000009223372036854775807.0000
9999999999 9999999999 0.9 99999999.00 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.0000 9999999999999999999999999999999999999999999999999999999999999.1111
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66);
ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65.
ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6);
ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65.
ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66);
ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 30.
DROP TABLE t1;
CREATE TABLE t1 (a DECIMAL ZEROFILL <CUSTOM_COL_OPTIONS>,
b NUMERIC ZEROFILL <CUSTOM_COL_OPTIONS>
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a decimal(10,0) unsigned zerofill # # # #
b decimal(10,0) unsigned zerofill # # # #
INSERT INTO t1 (a,b) VALUES (1.1,1234);
Warnings:
Note 1265 Data truncated for column 'a' at row 1
SELECT * FROM t1;
a b
0000000001 0000001234
DROP TABLE t1;
#
# Floating point columns (FLOAT, DOUBLE)
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (f FLOAT ZEROFILL <CUSTOM_COL_OPTIONS>,
f0 FLOAT(0) ZEROFILL <CUSTOM_COL_OPTIONS>,
r1_1 REAL(1,1) ZEROFILL <CUSTOM_COL_OPTIONS>,
f23_0 FLOAT(23) ZEROFILL <CUSTOM_COL_OPTIONS>,
f20_3 FLOAT(20,3) ZEROFILL <CUSTOM_COL_OPTIONS>,
d DOUBLE ZEROFILL <CUSTOM_COL_OPTIONS>,
d1_0 DOUBLE(1,0) ZEROFILL <CUSTOM_COL_OPTIONS>,
d10_10 DOUBLE PRECISION (10,10) ZEROFILL <CUSTOM_COL_OPTIONS>,
d53 DOUBLE(53,0) ZEROFILL <CUSTOM_COL_OPTIONS>,
d53_10 DOUBLE(53,10) ZEROFILL <CUSTOM_COL_OPTIONS>
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
f float unsigned zerofill # # #
f0 float unsigned zerofill # # #
r1_1 double(1,1) unsigned zerofill # # #
f23_0 float unsigned zerofill # # #
f20_3 float(20,3) unsigned zerofill # # #
d double unsigned zerofill # # #
d1_0 double(1,0) unsigned zerofill # # #
d10_10 double(10,10) unsigned zerofill # # #
d53 double(53,0) unsigned zerofill # # #
d53_10 double(53,10) unsigned zerofill # # #
INSERT INTO t1 VALUES (12345.12345,12345.12345,0.9,123456789.123,56789.987,11111111.111,8.0,0.0123456789,1234566789123456789,99999999999999999.99999999);
SELECT * FROM t1;
f 0000012345.1
d 000000000011111111.111
d10_10 0.0123456789
d1_0 8
d53 00000000000000000000000000000000001234566789123456800
d53_10 000000000000000000000000100000000000000000.0000000000
f0 0000012345.1
f20_3 0000000000056789.988
f23_0 000123457000
r1_1 0.9
INSERT INTO t1 VALUES (0,0,0,0,0,0,0,0,0,0);
INSERT INTO t1 VALUES (
99999999999999999999999999999999999999,
99999999999999999999999999999999999999.9999999999999999,
0.9,
99999999999999999999999999999999999999.9,
99999999999999999.999,
999999999999999999999999999999999999999999999999999999999999999999999999999999999,
9,
0.9999999999,
1999999999999999999999999999999999999999999999999999999,
19999999999999999999999999999999999999999999.9999999999
);
Warnings:
Warning 1264 Out of range value for column 'd53' at row 1
Warning 1264 Out of range value for column 'd53_10' at row 1
SELECT * FROM t1;
f 0000012345.1
d 0000000000000000000000
d 0000000000000000001e81
d 000000000011111111.111
d10_10 0.0000000000
d10_10 0.0123456789
d10_10 0.9999999999
d1_0 0
d1_0 8
d1_0 9
d53 00000000000000000000000000000000000000000000000000000
d53 00000000000000000000000000000000001234566789123456800
d53 100000000000000000000000000000000000000000000000000000
d53_10 000000000000000000000000000000000000000000.0000000000
d53_10 000000000000000000000000100000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
f 000000000000
f 000000001e38
f0 000000000000
f0 000000001e38
f0 0000012345.1
f20_3 0000000000000000.000
f20_3 0000000000056789.988
f20_3 99999998430674940.000
f23_0 000000000000
f23_0 000000001e38
f23_0 000123457000
r1_1 0.0
r1_1 0.9
r1_1 0.9
INSERT INTO t1 VALUES (-999999999999999999999999,-99999999999.999999999999,-0.9,-999.99999999999999999999,-99999999999999999.999,-999999999999999999999999999999999999999999999999999999999999-0.999,-9,-.9999999999,-999999999999999999999999999999.99999999999999999999999,-9999999999999999999999999999999999999999999.9999999999);
Warnings:
Warning 1264 Out of range value for column 'f' at row 1
Warning 1264 Out of range value for column 'f0' at row 1
Warning 1264 Out of range value for column 'r1_1' at row 1
Warning 1264 Out of range value for column 'f23_0' at row 1
Warning 1264 Out of range value for column 'f20_3' at row 1
Warning 1264 Out of range value for column 'd' at row 1
Warning 1264 Out of range value for column 'd1_0' at row 1
Warning 1264 Out of range value for column 'd10_10' at row 1
Warning 1264 Out of range value for column 'd53' at row 1
Warning 1264 Out of range value for column 'd53_10' at row 1
SELECT * FROM t1;
f 0000012345.1
d 0000000000000000000000
d 0000000000000000000000
d 0000000000000000001e81
d 000000000011111111.111
d10_10 0.0000000000
d10_10 0.0000000000
d10_10 0.0123456789
d10_10 0.9999999999
d1_0 0
d1_0 0
d1_0 8
d1_0 9
d53 00000000000000000000000000000000000000000000000000000
d53 00000000000000000000000000000000000000000000000000000
d53 00000000000000000000000000000000001234566789123456800
d53 100000000000000000000000000000000000000000000000000000
d53_10 000000000000000000000000000000000000000000.0000000000
d53_10 000000000000000000000000000000000000000000.0000000000
d53_10 000000000000000000000000100000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
f 000000000000
f 000000000000
f 000000001e38
f0 000000000000
f0 000000000000
f0 000000001e38
f0 0000012345.1
f20_3 0000000000000000.000
f20_3 0000000000000000.000
f20_3 0000000000056789.988
f20_3 99999998430674940.000
f23_0 000000000000
f23_0 000000000000
f23_0 000000001e38
f23_0 000123457000
r1_1 0.0
r1_1 0.0
r1_1 0.9
r1_1 0.9
SELECT MAX(f), MAX(f0), MAX(r1_1), MAX(f23_0), MAX(f20_3), MAX(d), MAX(d1_0), MAX(d10_10), MAX(d53), MAX(d53_10) FROM t1;
MAX(f) 9.999999680285692e37
MAX(d) 1e81
MAX(d10_10) 0.9999999999
MAX(d1_0) 9
MAX(d53) 100000000000000000000000000000000000000000000000000000
MAX(d53_10) 10000000000000000000000000000000000000000000.0000000000
MAX(f0) 9.999999680285692e37
MAX(f20_3) 99999998430674940.000
MAX(f23_0) 9.999999680285692e37
MAX(r1_1) 0.9
INSERT INTO t1 SELECT d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10 FROM t1 ORDER BY d53_10 DESC LIMIT 1;
Warnings:
Warning 1264 Out of range value for column 'f' at row 1
Warning 1264 Out of range value for column 'f0' at row 1
Warning 1264 Out of range value for column 'r1_1' at row 1
Warning 1264 Out of range value for column 'f23_0' at row 1
Warning 1264 Out of range value for column 'f20_3' at row 1
Warning 1264 Out of range value for column 'd1_0' at row 1
SELECT * FROM t1;
f 0000012345.1
d 0000000000000000000000
d 0000000000000000000000
d 0000000000000000001e43
d 0000000000000000001e81
d 000000000011111111.111
d10_10 0.0000000000
d10_10 0.0000000000
d10_10 0.0123456789
d10_10 0.9999999999
d10_10 10000000000000000000000000000000000000000000.0000000000
d1_0 0
d1_0 0
d1_0 8
d1_0 9
d1_0 9
d53 00000000000000000000000000000000000000000000000000000
d53 00000000000000000000000000000000000000000000000000000
d53 00000000000000000000000000000000001234566789123456800
d53 00000000010000000000000000000000000000000000000000000
d53 100000000000000000000000000000000000000000000000000000
d53_10 000000000000000000000000000000000000000000.0000000000
d53_10 000000000000000000000000000000000000000000.0000000000
d53_10 000000000000000000000000100000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
f 000000000000
f 000000000000
f 000000001e38
f 003.40282e38
f0 000000000000
f0 000000000000
f0 000000001e38
f0 0000012345.1
f0 003.40282e38
f20_3 0000000000000000.000
f20_3 0000000000000000.000
f20_3 0000000000056789.988
f20_3 99999998430674940.000
f20_3 99999998430674940.000
f23_0 000000000000
f23_0 000000000000
f23_0 000000001e38
f23_0 000123457000
f23_0 003.40282e38
r1_1 0.0
r1_1 0.0
r1_1 0.9
r1_1 0.9
r1_1 0.9
INSERT INTO t1 VALUES (
999999999999999999999999999999999999999,
999999999999999999999999999999999999999.9999999999999999,
1.9,
999999999999999999999999999999999999999.9,
999999999999999999.999,
9999999999999999999999999999999999999999999999999999999999999999999999999999999999,
99,
1.9999999999,
1999999999999999999999999999999999999999999999999999999,
19999999999999999999999999999999999999999999.9999999999
);
Warnings:
Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Warning 1264 Out of range value for column 'f' at row 1
Warning 1264 Out of range value for column 'f0' at row 1
Warning 1264 Out of range value for column 'r1_1' at row 1
Warning 1264 Out of range value for column 'f23_0' at row 1
Warning 1264 Out of range value for column 'f20_3' at row 1
Warning 1264 Out of range value for column 'd1_0' at row 1
Warning 1264 Out of range value for column 'd10_10' at row 1
Warning 1264 Out of range value for column 'd53' at row 1
Warning 1264 Out of range value for column 'd53_10' at row 1
SELECT * FROM t1;
f 0000012345.1
d 0000000000000000000000
d 0000000000000000000000
d 0000000000000000001e43
d 0000000000000000001e65
d 0000000000000000001e81
d 000000000011111111.111
d10_10 0.0000000000
d10_10 0.0000000000
d10_10 0.0123456789
d10_10 0.9999999999
d10_10 0.9999999999
d10_10 10000000000000000000000000000000000000000000.0000000000
d1_0 0
d1_0 0
d1_0 8
d1_0 9
d1_0 9
d1_0 9
d53 00000000000000000000000000000000000000000000000000000
d53 00000000000000000000000000000000000000000000000000000
d53 00000000000000000000000000000000001234566789123456800
d53 00000000010000000000000000000000000000000000000000000
d53 100000000000000000000000000000000000000000000000000000
d53 100000000000000000000000000000000000000000000000000000
d53_10 000000000000000000000000000000000000000000.0000000000
d53_10 000000000000000000000000000000000000000000.0000000000
d53_10 000000000000000000000000100000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
f 000000000000
f 000000000000
f 000000001e38
f 003.40282e38
f 003.40282e38
f0 000000000000
f0 000000000000
f0 000000001e38
f0 0000012345.1
f0 003.40282e38
f0 003.40282e38
f20_3 0000000000000000.000
f20_3 0000000000000000.000
f20_3 0000000000056789.988
f20_3 99999998430674940.000
f20_3 99999998430674940.000
f20_3 99999998430674940.000
f23_0 000000000000
f23_0 000000000000
f23_0 000000001e38
f23_0 000123457000
f23_0 003.40282e38
f23_0 003.40282e38
r1_1 0.0
r1_1 0.0
r1_1 0.9
r1_1 0.9
r1_1 0.9
r1_1 0.9
ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0);
ERROR 42000: Display width out of range for 'd0_0' (max = 255)
ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1);
ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65.
ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35);
ERROR 42000: Too big scale 35 specified for 'n66_66'. Maximum is 30.
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE ZEROFILL <CUSTOM_COL_OPTIONS>,
b FLOAT ZEROFILL <CUSTOM_COL_OPTIONS>
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a double unsigned zerofill # # # #
b float unsigned zerofill # # # #
INSERT INTO t1 (a,b) VALUES (1,1234.5);
SELECT * FROM t1;
a b
0000000000000000000001 0000001234.5
DROP TABLE t1;
#
# INT columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (i INT ZEROFILL <CUSTOM_COL_OPTIONS>,
i0 INT(0) ZEROFILL <CUSTOM_COL_OPTIONS>,
i1 INT(1) ZEROFILL <CUSTOM_COL_OPTIONS>,
i20 INT(20) ZEROFILL <CUSTOM_COL_OPTIONS>,
t TINYINT ZEROFILL <CUSTOM_COL_OPTIONS>,
t0 TINYINT(0) ZEROFILL <CUSTOM_COL_OPTIONS>,
t1 TINYINT(1) ZEROFILL <CUSTOM_COL_OPTIONS>,
t20 TINYINT(20) ZEROFILL <CUSTOM_COL_OPTIONS>,
s SMALLINT ZEROFILL <CUSTOM_COL_OPTIONS>,
s0 SMALLINT(0) ZEROFILL <CUSTOM_COL_OPTIONS>,
s1 SMALLINT(1) ZEROFILL <CUSTOM_COL_OPTIONS>,
s20 SMALLINT(20) ZEROFILL <CUSTOM_COL_OPTIONS>,
m MEDIUMINT ZEROFILL <CUSTOM_COL_OPTIONS>,
m0 MEDIUMINT(0) ZEROFILL <CUSTOM_COL_OPTIONS>,
m1 MEDIUMINT(1) ZEROFILL <CUSTOM_COL_OPTIONS>,
m20 MEDIUMINT(20) ZEROFILL <CUSTOM_COL_OPTIONS>,
b BIGINT ZEROFILL <CUSTOM_COL_OPTIONS>,
b0 BIGINT(0) ZEROFILL <CUSTOM_COL_OPTIONS>,
b1 BIGINT(1) ZEROFILL <CUSTOM_COL_OPTIONS>,
b20 BIGINT(20) ZEROFILL <CUSTOM_COL_OPTIONS>
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
i int(10) unsigned zerofill # # #
i0 int(10) unsigned zerofill # # #
i1 int(1) unsigned zerofill # # #
i20 int(20) unsigned zerofill # # #
t tinyint(3) unsigned zerofill # # #
t0 tinyint(3) unsigned zerofill # # #
t1 tinyint(1) unsigned zerofill # # #
t20 tinyint(20) unsigned zerofill # # #
s smallint(5) unsigned zerofill # # #
s0 smallint(5) unsigned zerofill # # #
s1 smallint(1) unsigned zerofill # # #
s20 smallint(20) unsigned zerofill # # #
m mediumint(8) unsigned zerofill # # #
m0 mediumint(8) unsigned zerofill # # #
m1 mediumint(1) unsigned zerofill # # #
m20 mediumint(20) unsigned zerofill # # #
b bigint(20) unsigned zerofill # # #
b0 bigint(20) unsigned zerofill # # #
b1 bigint(1) unsigned zerofill # # #
b20 bigint(20) unsigned zerofill # # #
INSERT INTO t1 VALUES (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
INSERT INTO t1 VALUES (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
INSERT INTO t1 VALUES (2147483647,2147483647,2147483647,2147483647,127,127,127,127,32767,32767,32767,32767,8388607,8388607,8388607,8388607,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807);
SELECT * FROM t1;
i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
0000000001 0000000002 3 00000000000000000004 005 006 7 00000000000000000008 00009 00010 11 00000000000000000012 00000013 00000014 15 00000000000000000016 00000000000000000017 00000000000000000018 19 00000000000000000020
2147483647 2147483647 2147483647 00000000002147483647 127 127 127 00000000000000000127 32767 32767 32767 00000000000000032767 08388607 08388607 8388607 00000000000008388607 09223372036854775807 09223372036854775807 9223372036854775807 09223372036854775807
INSERT INTO t1 VALUES (-2147483648,-2147483648,-2147483648,-2147483648,-128,-128,-128,-128,-32768,-32768,-32768,-32768,-8388608,-8388608,-8388608,-8388608,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808);
Warnings:
Warning 1264 Out of range value for column 'i' at row 1
Warning 1264 Out of range value for column 'i0' at row 1
Warning 1264 Out of range value for column 'i1' at row 1
Warning 1264 Out of range value for column 'i20' at row 1
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't0' at row 1
Warning 1264 Out of range value for column 't1' at row 1
Warning 1264 Out of range value for column 't20' at row 1
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 's0' at row 1
Warning 1264 Out of range value for column 's1' at row 1
Warning 1264 Out of range value for column 's20' at row 1
Warning 1264 Out of range value for column 'm' at row 1
Warning 1264 Out of range value for column 'm0' at row 1
Warning 1264 Out of range value for column 'm1' at row 1
Warning 1264 Out of range value for column 'm20' at row 1
Warning 1264 Out of range value for column 'b' at row 1
Warning 1264 Out of range value for column 'b0' at row 1
Warning 1264 Out of range value for column 'b1' at row 1
Warning 1264 Out of range value for column 'b20' at row 1
INSERT INTO t1 VALUES (4294967295,4294967295,4294967295,4294967295,255,255,255,255,65535,65535,65535,65535,16777215,16777215,16777215,16777215,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615);
SELECT * FROM t1;
i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
0000000001 0000000002 3 00000000000000000004 005 006 7 00000000000000000008 00009 00010 11 00000000000000000012 00000013 00000014 15 00000000000000000016 00000000000000000017 00000000000000000018 19 00000000000000000020
2147483647 2147483647 2147483647 00000000002147483647 127 127 127 00000000000000000127 32767 32767 32767 00000000000000032767 08388607 08388607 8388607 00000000000008388607 09223372036854775807 09223372036854775807 9223372036854775807 09223372036854775807
4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
INSERT INTO t1 VALUES (-2147483649,-2147483649,-2147483649,-2147483649,-129,-129,-129,-129,-32769,-32769,-32769,-32769,-8388609,-8388609,-8388609,-8388609,-9223372036854775809,-9223372036854775809,-9223372036854775809,-9223372036854775809);
Warnings:
Warning 1264 Out of range value for column 'i' at row 1
Warning 1264 Out of range value for column 'i0' at row 1
Warning 1264 Out of range value for column 'i1' at row 1
Warning 1264 Out of range value for column 'i20' at row 1
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't0' at row 1
Warning 1264 Out of range value for column 't1' at row 1
Warning 1264 Out of range value for column 't20' at row 1
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 's0' at row 1
Warning 1264 Out of range value for column 's1' at row 1
Warning 1264 Out of range value for column 's20' at row 1
Warning 1264 Out of range value for column 'm' at row 1
Warning 1264 Out of range value for column 'm0' at row 1
Warning 1264 Out of range value for column 'm1' at row 1
Warning 1264 Out of range value for column 'm20' at row 1
Warning 1264 Out of range value for column 'b' at row 1
Warning 1264 Out of range value for column 'b0' at row 1
Warning 1264 Out of range value for column 'b1' at row 1
Warning 1264 Out of range value for column 'b20' at row 1
INSERT INTO t1 VALUES (4294967296,4294967296,4294967296,4294967296,256,256,256,256,65536,65536,65536,65536,16777216,16777216,16777216,16777216,18446744073709551616,18446744073709551616,18446744073709551616,18446744073709551616);
Warnings:
Warning 1264 Out of range value for column 'i' at row 1
Warning 1264 Out of range value for column 'i0' at row 1
Warning 1264 Out of range value for column 'i1' at row 1
Warning 1264 Out of range value for column 'i20' at row 1
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't0' at row 1
Warning 1264 Out of range value for column 't1' at row 1
Warning 1264 Out of range value for column 't20' at row 1
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 's0' at row 1
Warning 1264 Out of range value for column 's1' at row 1
Warning 1264 Out of range value for column 's20' at row 1
Warning 1264 Out of range value for column 'm' at row 1
Warning 1264 Out of range value for column 'm0' at row 1
Warning 1264 Out of range value for column 'm1' at row 1
Warning 1264 Out of range value for column 'm20' at row 1
Warning 1264 Out of range value for column 'b' at row 1
Warning 1264 Out of range value for column 'b0' at row 1
Warning 1264 Out of range value for column 'b1' at row 1
Warning 1264 Out of range value for column 'b20' at row 1
INSERT INTO t1 SELECT b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b FROM t1 WHERE b IN (-9223372036854775808,9223372036854775807,18446744073709551615);
Warnings:
Warning 1264 Out of range value for column 'i' at row 1
Warning 1264 Out of range value for column 'i0' at row 1
Warning 1264 Out of range value for column 'i1' at row 1
Warning 1264 Out of range value for column 'i20' at row 1
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't0' at row 1
Warning 1264 Out of range value for column 't1' at row 1
Warning 1264 Out of range value for column 't20' at row 1
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 's0' at row 1
Warning 1264 Out of range value for column 's1' at row 1
Warning 1264 Out of range value for column 's20' at row 1
Warning 1264 Out of range value for column 'm' at row 1
Warning 1264 Out of range value for column 'm0' at row 1
Warning 1264 Out of range value for column 'm1' at row 1
Warning 1264 Out of range value for column 'm20' at row 1
Warning 1264 Out of range value for column 'i' at row 2
Warning 1264 Out of range value for column 'i0' at row 2
Warning 1264 Out of range value for column 'i1' at row 2
Warning 1264 Out of range value for column 'i20' at row 2
Warning 1264 Out of range value for column 't' at row 2
Warning 1264 Out of range value for column 't0' at row 2
Warning 1264 Out of range value for column 't1' at row 2
Warning 1264 Out of range value for column 't20' at row 2
Warning 1264 Out of range value for column 's' at row 2
Warning 1264 Out of range value for column 's0' at row 2
Warning 1264 Out of range value for column 's1' at row 2
Warning 1264 Out of range value for column 's20' at row 2
Warning 1264 Out of range value for column 'm' at row 2
Warning 1264 Out of range value for column 'm0' at row 2
Warning 1264 Out of range value for column 'm1' at row 2
Warning 1264 Out of range value for column 'm20' at row 2
Warning 1264 Out of range value for column 'i' at row 3
Warning 1264 Out of range value for column 'i0' at row 3
Warning 1264 Out of range value for column 'i1' at row 3
Warning 1264 Out of range value for column 'i20' at row 3
Warning 1264 Out of range value for column 't' at row 3
Warning 1264 Out of range value for column 't0' at row 3
Warning 1264 Out of range value for column 't1' at row 3
Warning 1264 Out of range value for column 't20' at row 3
Warning 1264 Out of range value for column 's' at row 3
Warning 1264 Out of range value for column 's0' at row 3
Warning 1264 Out of range value for column 's1' at row 3
Warning 1264 Out of range value for column 's20' at row 3
Warning 1264 Out of range value for column 'm' at row 3
Warning 1264 Out of range value for column 'm0' at row 3
Warning 1264 Out of range value for column 'm1' at row 3
Warning 1264 Out of range value for column 'm20' at row 3
SELECT * FROM t1;
i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
0000000001 0000000002 3 00000000000000000004 005 006 7 00000000000000000008 00009 00010 11 00000000000000000012 00000013 00000014 15 00000000000000000016 00000000000000000017 00000000000000000018 19 00000000000000000020
2147483647 2147483647 2147483647 00000000002147483647 127 127 127 00000000000000000127 32767 32767 32767 00000000000000032767 08388607 08388607 8388607 00000000000008388607 09223372036854775807 09223372036854775807 9223372036854775807 09223372036854775807
4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 09223372036854775807 09223372036854775807 9223372036854775807 09223372036854775807
4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
ALTER TABLE t1 ADD COLUMN i257 INT(257);
ERROR 42000: Display width out of range for 'i257' (max = 255)
DROP TABLE t1;
CREATE TABLE t1 (t TINYINT ZEROFILL <CUSTOM_COL_OPTIONS>,
s SMALLINT ZEROFILL <CUSTOM_COL_OPTIONS>,
m MEDIUMINT ZEROFILL <CUSTOM_COL_OPTIONS>,
i INT ZEROFILL <CUSTOM_COL_OPTIONS>,
b BIGINT ZEROFILL <CUSTOM_COL_OPTIONS>
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
t tinyint(3) unsigned zerofill # # # #
s smallint(5) unsigned zerofill # # # #
m mediumint(8) unsigned zerofill # # # #
i int(10) unsigned zerofill # # # #
b bigint(20) unsigned zerofill # # # #
INSERT INTO t1 (t,s,m,i,b) VALUES (1,10,100,1000,0);
SELECT * FROM t1;
t s m i b
001 00010 00000100 0000001000 00000000000000000000
DROP TABLE t1;

View File

@ -0,0 +1,88 @@
#
# ZEROFILL column attribute
#
let $extra_type_opts = ZEROFILL;
--source have_engine.inc
--echo #
--echo # Fixed point columns (NUMERIC, DECIMAL)
--echo #
--source type_fixed.inc
let $create_definition =
a DECIMAL $col_opts,
b NUMERIC $col_opts
;
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Fixed point types or ZEROFILL columns
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 3 # 4 # 5 # 6 #
SHOW COLUMNS IN t1;
INSERT INTO t1 (a,b) VALUES (1.1,1234);
SELECT * FROM t1;
DROP TABLE t1;
}
--echo #
--echo # Floating point columns (FLOAT, DOUBLE)
--echo #
--source type_float.inc
let $create_definition =
a DOUBLE $col_opts,
b FLOAT $col_opts
;
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Floating point types or ZEROFILL columns
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 3 # 4 # 5 # 6 #
SHOW COLUMNS IN t1;
INSERT INTO t1 (a,b) VALUES (1,1234.5);
SELECT * FROM t1;
DROP TABLE t1;
}
--echo #
--echo # INT columns
--echo #
--source type_int.inc
let $create_definition =
t TINYINT $col_opts,
s SMALLINT $col_opts,
m MEDIUMINT $col_opts,
i INT $col_opts,
b BIGINT $col_opts
;
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = INT types or UNSIGNED columns
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 3 # 4 # 5 # 6 #
SHOW COLUMNS IN t1;
INSERT INTO t1 (t,s,m,i,b) VALUES (1,10,100,1000,0);
SELECT * FROM t1;
DROP TABLE t1;
}
--source cleanup_engine.inc

View File

@ -0,0 +1,174 @@
##################################
#
# This include file will be used for all CREATE TABLE statements in the suite.
# If you need to add additional steps or change the logic, copy the file
# to storage/<engine>/mysql-test/storage_engine/ folder and modify it there.
#
##################
#
# Parameters:
#
# --let $create_definition = <column names, types, indexes) # optional, default a $int_col, b $char_col (based on defaults)
# --let $table_name = <table name> # optional, default t1
# --let $table_options = <table options> # optional, default based on define_engine.inc
# --let $partition_options = <partitioning definition> # optional, default none
# --let $as_select = <SELECT statement> # optional, default empty
# --let $error_codes = <expected error codes, as in --error> # optional, default 0
# --let $if_not_exists = [0|1] # optional, default 0 (1 adds IF NOT EXISTS clause)
# --let $default_engine = [0|1] # optional, default 0 (with 1 will rely on default engine, no ENGINE=)
# --let $temporary = [0|1] # optional, default 0 (1 adds TEMPORARY)
# --let $disable_query_log = [0|1] # optional, default 0 (1 disables logging of CREATE)
#
# Usage examples:
#
# --source create_table.inc -- creates a default table
#
# --let $create_definition = a INT NOT NULL, b CHAR(1) PRIMARY KEY, INDEX(a)
# --let $table_options = AUTO_INCREMENT = 100
# --let $partition_options = PARTITION BY HASH(a) PARTITIONS 2
# --let $as_select = SELECT 1, 'a'
# --source create_table.inc
#
# Additionally, a test can define $extra_tbl_options. The difference with $table_options
# is that its value is persistent and will be used until it is unset explicitly, or
# until the test ends. The purpose of it is to allow one test to call another test,
# when the called test does not know about specific options the calling test might require,
# and thus cannot set them on per-create basis.
--let $create_statement = CREATE
if ($temporary)
{
--let $create_statement = $create_statement TEMPORARY
}
--let $create_statement = $create_statement TABLE
if ($if_not_exists)
{
--let $create_statement = $create_statement IF NOT EXISTS
}
if (!$table_name)
{
--let $table_name = t1
}
--let $create_statement = $create_statement $table_name
if (!$create_definition)
{
# If $create_definition is not defined, and AS SELECT is requested,
# we should not set $create_definition to the default value,
# because it might be inconsistent with the SELECT.
if (!$as_select)
{
--let $create_definition = a $int_col, b $char_col
}
}
if ($create_definition)
{
--let $create_statement = $create_statement ($create_definition)
}
# If $default_engine is set, we will rely on the default storage engine
if (!$default_engine)
{
--let $create_statement = $create_statement ENGINE=$storage_engine
}
# Default table options from define_engine.inc
--let $create_statement = $create_statement $default_tbl_opts
# The calling script could request additional table options
if ($table_options)
{
--let $create_statement = $create_statement $table_options
}
# The difference between $extra_tbl_opts and $table_options
# is that its $extra_tbl_opts is persistent -- it will not be unset at the end of this file,
# and will be used until it is unset explicitly by the calling test,
# or until the test ends. The purpose of it is to allow one test to call another test,
# when the called test does not know about specific options the calling test might require,
# and thus cannot set them on per-create basis.
if ($extra_tbl_opts)
{
--let $create_statement = $create_statement $extra_tbl_opts
}
if ($as_select)
{
--let $create_statement = $create_statement AS $as_select
}
if ($partition_options)
{
--let $create_statement = $create_statement $partition_options
}
# We now have the complete CREATE statement in $create_statement.
# If your CREATE statement should be composed differently,
# modify the logic above.
#####################
# Here you can add logic needed BEFORE the main table creation
# (e.g. the table needs a base table, a reference table, etc.).
# Surround it by --disable_query_log/--enable_query_log
# if you don't want it to appear in the result output.
#####################
if ($disable_query_log)
{
--disable_query_log
}
--source obfuscate.inc
eval $create_statement;
--source strict_check_errors.inc
# Make sure you don't add any statements between the main CREATE (above)
# and saving mysql_errno and mysql_errname (below)
# They are saved in case you want to add more logic after the main CREATE,
# because we need the result code of the table creation.
# Also, do not change $create_statement after it is executed!
--let $my_errno = $mysql_errno
--let $my_errname = $mysql_errname
if ($disable_query_log)
{
--enable_query_log
}
#####################
# Here you can add logic needed AFTER the main table creation,
# e.g. triggers creation.
# Surround it by --disable_query_log/--enable_query_log
# if you don't want it to appear in the result output.
#####################
# Unset the parameters, we don't want them to be accidentally reused later
--let $create_definition =
--let $table_name = t1
--let $table_options =
--let $partition_options =
--let $as_select = 0
--let $error_codes =
--let $if_not_exists = 0
--let $default_engine = 0
--let $temporary = 0
--let $disable_query_log = 0
# Restore the error codes of the main statement
--let $mysql_errno = $my_errno
--let $mysql_errname = $my_errname
# Make sure you don't add any SQL statements after restoring
# mysql_errno and mysql_errname (above)

View File

@ -0,0 +1,45 @@
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
CREATE TABLE IF NOT EXISTS t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
Warnings:
Note 1050 Table 't1' already exists
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
CREATE TEMPORARY TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TEMPORARY TABLE `t2` (
`a` int(11) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
DROP TEMPORARY TABLE t2;
DROP TABLE t2;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> AS SELECT 1 UNION SELECT 2;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`1` bigint(20) NOT NULL DEFAULT '0'
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
SELECT * FROM t1;
1
1
2
DROP TABLE t1;
SET storage_engine = <STORAGE_ENGINE>;
CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
FLUSH LOGS;
DROP TABLE IF EXISTS t1;

View File

@ -0,0 +1,107 @@
#
# Basic CREATE TABLE statements
#
--source have_engine.inc
--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
# Simple create table with minimal table options
# which are defined in have_engine.inc
# (default empty) plus ENGINE=
--let $create_definition = a $int_col
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = CREATE TABLE
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--source mask_engine.inc
SHOW CREATE TABLE t1;
# IF NOT EXISTS
--let $if_not_exists = 1
--let $create_definition = a $int_col
--source create_table.inc
}
# CREATE .. LIKE
CREATE TABLE t2 LIKE t1;
if ($mysql_errname)
{
--let $functionality = CREATE TABLE .. LIKE
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--source mask_engine.inc
SHOW CREATE TABLE t2;
eval
CREATE TEMPORARY TABLE t2 LIKE t1;
if ($mysql_errname)
{
--let $functionality = Temporary tables
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--source mask_engine.inc
SHOW CREATE TABLE t2;
DROP TEMPORARY TABLE t2;
}
DROP TABLE t2;
}
DROP TABLE IF EXISTS t1;
# CREATE .. AS SELECT
--let $as_select = SELECT 1 UNION SELECT 2
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = CREATE TABLE .. AS SELECT
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--source mask_engine.inc
SHOW CREATE TABLE t1;
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
}
# Use the engine as default
--source mask_engine.inc
eval SET storage_engine = $storage_engine;
--let $tbl_opts = $default_tbl_opts
--let $create_definition = a $int_col
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = CREATE TABLE or using the engine as default
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--source mask_engine.inc
SHOW CREATE TABLE t1;
}
# Just to add FLUSH LOGS into the mix while we are in the most common test
FLUSH LOGS;
DROP TABLE IF EXISTS t1;
--source cleanup_engine.inc

View File

@ -0,0 +1,45 @@
###########################################
#
# This is a template of the include file define_engine.inc which
# should be placed in storage/<engine>/mysql-test/storage_engine folder.
#
################################
#
# The name of the engine under test must be defined in $ENGINE variable.
# You can set it either here (uncomment and edit) or in your environment.
#
# let $ENGINE =;
#
################################
#
# The following three variables define specific options for columns and tables.
# Normally there should be none needed, but for some engines it can be different.
# If the engine requires specific column option for all or indexed columns,
# set them inside the comment, e.g. /*!NOT NULL*/.
# Do the same for table options if needed, e.g. /*!INSERT_METHOD=LAST*/
let $default_col_opts = /*!*/;
let $default_col_indexed_opts = /*!*/;
let $default_tbl_opts = /*!*/;
# INDEX, UNIQUE INDEX, PRIMARY KEY, special index type - choose the fist that the engine allows,
# or set it to /*!*/ if none is supported
let $default_index = /*!INDEX*/;
# If the engine does not support the following types, replace them with the closest possible
let $default_int_type = INT(11);
let $default_char_type = CHAR(8);
################################
--disable_query_log
--disable_result_log
# Here you can place your custom MTR code which needs to be executed before each test,
# e.g. creation of an additional schema or table, etc.
# The cleanup part should be defined in cleanup_engine.inc
--enable_query_log
--enable_result_log

View File

@ -0,0 +1,77 @@
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (10000,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
INSERT INTO t1 (a,b) SELECT a, b FROM t1;
DELETE FROM t1 WHERE b IN ('c');
SELECT * FROM t1;
a b
1 a
1 a
10000 foobar
10000 foobar
2 b
2 b
4 d
4 d
5 e
5 e
DELETE FROM t1 WHERE a < 0 OR b = 'a';
SELECT * FROM t1;
a b
10000 foobar
10000 foobar
2 b
2 b
4 d
4 d
5 e
5 e
DELETE FROM t1 WHERE a <= 4 ORDER BY b DESC LIMIT 1;
SELECT * FROM t1;
a b
10000 foobar
10000 foobar
2 b
2 b
4 d
5 e
5 e
CREATE TABLE t2 (c <CHAR_COLUMN>, d <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t2 (c,d) SELECT b, a FROM t1;
SELECT * FROM t2;
c d
b 2
b 2
d 4
e 5
e 5
foobar 10000
foobar 10000
DELETE t2.* FROM t1, t2 WHERE c < b AND a + d != 1;
SELECT * FROM t1;
a b
10000 foobar
10000 foobar
2 b
2 b
4 d
5 e
5 e
SELECT * FROM t2;
c d
foobar 10000
foobar 10000
DELETE FROM t2, t1.* USING t2, t1 WHERE c = 'foobar' and b = c;
SELECT * FROM t1;
a b
2 b
2 b
4 d
5 e
5 e
SELECT * FROM t2;
c d
DELETE FROM t1;
SELECT * FROM t1;
a b
DROP TABLE t1, t2;

View File

@ -0,0 +1,68 @@
#
# Basic DELETE statements.
# DELETE LOW_PRIORITY is covered in delete_low_prio test
# DELETE QUICK is covered in delete_quick test (syntax only)
# DELETE IGNORE is covered in delete_ignore test
#
--source have_engine.inc
--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
--let $create_definition = a $int_col, b $char_col
--source create_table.inc
INSERT INTO t1 (a,b) VALUES (10000,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
INSERT INTO t1 (a,b) SELECT a, b FROM t1;
# Single-table DELETE
DELETE FROM t1 WHERE b IN ('c');
if ($mysql_errname)
{
--let $functionality = DELETE FROM
--source unexpected_result.inc
}
--sorted_result
SELECT * FROM t1;
DELETE FROM t1 WHERE a < 0 OR b = 'a';
--sorted_result
SELECT * FROM t1;
# ORDER BY and LIMIT
DELETE FROM t1 WHERE a <= 4 ORDER BY b DESC LIMIT 1;
--sorted_result
SELECT * FROM t1;
# Multi-table DELETE
--let $create_definition = c $char_col, d $int_col
--let $table_name = t2
--source create_table.inc
INSERT INTO t2 (c,d) SELECT b, a FROM t1;
--sorted_result
SELECT * FROM t2;
DELETE t2.* FROM t1, t2 WHERE c < b AND a + d != 1;
--sorted_result
SELECT * FROM t1;
--sorted_result
SELECT * FROM t2;
DELETE FROM t2, t1.* USING t2, t1 WHERE c = 'foobar' and b = c;
--sorted_result
SELECT * FROM t1;
--sorted_result
SELECT * FROM t2;
DELETE FROM t1;
--sorted_result
SELECT * FROM t1;
# Cleanup
DROP TABLE t1, t2;
--source cleanup_engine.inc

View File

@ -0,0 +1,59 @@
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (10000,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
INSERT INTO t1 (a,b) SELECT a, b FROM t1;
CREATE TABLE t2 (c <CHAR_COLUMN>, d <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t2 (c,d) SELECT b, a FROM t1;
SELECT * FROM t1;
a b
1 a
1 a
10000 foobar
10000 foobar
2 b
2 b
3 c
3 c
4 d
4 d
5 e
5 e
SELECT * FROM t2;
c d
a 1
a 1
b 2
b 2
c 3
c 3
d 4
d 4
e 5
e 5
foobar 10000
foobar 10000
DELETE IGNORE FROM t1 WHERE b IS NOT NULL ORDER BY a LIMIT 1;
SELECT * FROM t1;
a b
1 a
10000 foobar
10000 foobar
2 b
2 b
3 c
3 c
4 d
4 d
5 e
5 e
DELETE IGNORE t1.*, t2.* FROM t1, t2 WHERE c < b OR a != ( SELECT 1 UNION SELECT 2 );
Warnings:
Warning 1242 Subquery returns more than 1 row
SELECT * FROM t1;
a b
1 a
SELECT * FROM t2;
c d
foobar 10000
foobar 10000
DROP TABLE t1, t2;

View File

@ -0,0 +1,44 @@
#
# DELETE IGNORE
#
--source have_engine.inc
--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
--let $create_definition = a $int_col, b $char_col
--source create_table.inc
INSERT INTO t1 (a,b) VALUES (10000,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
INSERT INTO t1 (a,b) SELECT a, b FROM t1;
--let $create_definition = c $char_col, d $int_col
--let $table_name = t2
--source create_table.inc
INSERT INTO t2 (c,d) SELECT b, a FROM t1;
--sorted_result
SELECT * FROM t1;
--sorted_result
SELECT * FROM t2;
DELETE IGNORE FROM t1 WHERE b IS NOT NULL ORDER BY a LIMIT 1;
if ($mysql_errname)
{
--let $functionality = DELETE IGNORE FROM ..
--source unexpected_result.inc
}
--sorted_result
SELECT * FROM t1;
DELETE IGNORE t1.*, t2.* FROM t1, t2 WHERE c < b OR a != ( SELECT 1 UNION SELECT 2 );
--sorted_result
SELECT * FROM t1;
--sorted_result
SELECT * FROM t2;
# Cleanup
DROP TABLE t1, t2;
--source cleanup_engine.inc

View File

@ -0,0 +1,59 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
SET LOW_PRIORITY_UPDATES = 0;
SET lock_wait_timeout = 4;
connect con1,localhost,root,,;
SET lock_wait_timeout = 2;
SELECT SLEEP(1) FROM t1;
connection default;
DELETE FROM t1;
connect con2,localhost,root,,;
SET lock_wait_timeout = 3;
SELECT SLEEP(1) FROM t1;
SLEEP(1)
connection con1;
SLEEP(1)
0
0
connection default;
SELECT * FROM t1;
a b
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
connection con1;
SELECT SLEEP(1) FROM t1;
connection default;
DELETE LOW_PRIORITY FROM t1;
connection con2;
SELECT SLEEP(1) FROM t1;
SLEEP(1)
0
0
connection con1;
SLEEP(1)
0
0
connection default;
SELECT * FROM t1;
a b
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
SET LOW_PRIORITY_UPDATES = 1;
connection con1;
SELECT SLEEP(1) FROM t1;
connection default;
DELETE FROM t1;
connection con2;
SELECT SLEEP(1) FROM t1;
SLEEP(1)
0
0
connection con1;
SLEEP(1)
0
0
connection default;
SELECT * FROM t1;
a b
disconnect con1;
disconnect con2;
DROP TABLE t1;

View File

@ -0,0 +1,162 @@
#
# DELETE LOW_PRIORITY
#
--source have_engine.inc
--source include/count_sessions.inc
--enable_connect_log
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--let $create_definiiton = a $int_col, b $char_col
--source create_table.inc
INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
# We will have 3 connections:
# con1 will start SELECT which should give us enough time;
# default will run DELETE
# con2 will then start another SELECT.
# With LOW_PRIORITY_UPDATES = 0,
# with standard DELETE we should see all rows in con1 resultset,
# but no rows in con2 resultset.
# With DELETE LOW_PRIORITY we should see all rows in both resultsets.
# Then we will set LOW_PRIORITY_UPDATES to 1.
# Then with standard DELETE we should see all rows in both resultsets.
SET LOW_PRIORITY_UPDATES = 0;
SET lock_wait_timeout = 4;
# Normal DELETE with low_priority_updates=0
--connect (con1,localhost,root,,)
SET lock_wait_timeout = 2;
--send
SELECT SLEEP(1) FROM t1;
--connection default
let $show_statement = SHOW PROCESSLIST;
let $field = State;
let $condition = = 'User sleep';
# We don't need to wait long,
# if the feature works, threads
# should show up in the processlist right away
let $wait_timeout = 2;
--source include/wait_show_condition.inc
--send
DELETE FROM t1;
--connect (con2,localhost,root,,)
SET lock_wait_timeout = 3;
let $field = Info;
let $condition = = 'DELETE FROM t1';
let $wait_timeout = 2;
--source include/wait_show_condition.inc
if (!$found)
{
--let $mysql_errname = timeout in wait_show_condition.inc
--let $functionality = DELETE or table locking
--source unexpected_result.inc
}
if ($found)
{
SELECT SLEEP(1) FROM t1;
}
--connection con1
--reap
--connection default
--reap
--sorted_result
SELECT * FROM t1;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
# DELETE LOW_PRIORITY
--connection con1
--send
SELECT SLEEP(1) FROM t1;
--connection default
let $field = State;
let $condition = = 'User sleep';
let $wait_timeout = 2;
--source include/wait_show_condition.inc
--send
DELETE LOW_PRIORITY FROM t1;
--connection con2
let $field = Info;
let $condition = = 'DELETE LOW_PRIORITY FROM t1';
let $wait_timeout = 2;
--source include/wait_show_condition.inc
if (!$found)
{
--let $mysql_errname = timeout in wait_show_condition.inc
--let $functionality = DELETE LOW_PRIORITY or table locking
--source unexpected_result.inc
}
if ($found)
{
SELECT SLEEP(1) FROM t1;
}
--connection con1
--reap
--connection default
--reap
--sorted_result
SELECT * FROM t1;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
SET LOW_PRIORITY_UPDATES = 1;
# Normal DELETE with low_priority_updates=1
--connection con1
--send
SELECT SLEEP(1) FROM t1;
--connection default
let $field = State;
let $condition = = 'User sleep';
let $wait_timeout = 2;
--source include/wait_show_condition.inc
--send
DELETE FROM t1;
--connection con2
let $field = Info;
let $condition = = 'DELETE FROM t1';
let $wait_timeout = 2;
--source include/wait_show_condition.inc
if ($found)
{
SELECT SLEEP(1) FROM t1;
}
--connection con1
--reap
--connection default
--reap
--sorted_result
SELECT * FROM t1;
--disconnect con1
--disconnect con2
# Cleanup
DROP TABLE t1;
--source include/wait_until_count_sessions.inc
--source cleanup_engine.inc

View File

@ -0,0 +1,25 @@
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (a <INT_COLUMN>, <CUSTOM_INDEX> (a), b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
DELETE QUICK FROM t1 WHERE a = 1 OR b > 'foo';
SELECT * FROM t1;
a b
2 b
3 c
4 d
5 e
CREATE TABLE t2 (c <CHAR_COLUMN>, d <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t2 SELECT b, a FROM t1;
SELECT * FROM t2;
c d
b 2
c 3
d 4
e 5
DELETE QUICK FROM t2, t1.* USING t2, t1 WHERE c IS NULL OR a = d;
SELECT * FROM t1;
a b
SELECT * FROM t2;
c d
DROP TABLE t2;
DROP TABLE t1;

View File

@ -0,0 +1,55 @@
#
# DELETE QUICK syntax.
# For now we only check that the keyword is accepted,
# without actually checking whether the feature works.
#
--source have_engine.inc
--source have_default_index.inc
--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
--let $create_definition = a $int_indexed_col, $default_index (a), b $char_col
--source create_table.inc
if ($mysql_errname)
{
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
DELETE QUICK FROM t1 WHERE a = 1 OR b > 'foo';
if ($mysql_errname)
{
--let $functionality = DELETE or DELETE QUICK
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--sorted_result
SELECT * FROM t1;
--let $create_definition = c $char_col, d $int_col
--let $table_name = t2
--source create_table.inc
INSERT INTO t2 SELECT b, a FROM t1;
--sorted_result
SELECT * FROM t2;
DELETE QUICK FROM t2, t1.* USING t2, t1 WHERE c IS NULL OR a = d;
--sorted_result
SELECT * FROM t1;
--sorted_result
SELECT * FROM t2;
DROP TABLE t2;
}
DROP TABLE t1;
}
# Cleanup
--source cleanup_engine.inc

View File

@ -0,0 +1,38 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, <CUSTOM_INDEX> (b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'x'),(7,'y'),(8,'z');
DELETE FROM t1 WHERE b > 'y';
DELETE FROM t1 WHERE a=2;
SELECT * FROM t1;
a b
1 a
3 c
4 d
5 e
6 x
7 y
DELETE FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN> PRIMARY KEY, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'x'),(7,'y'),(8,'z');
DELETE FROM t1 WHERE b > 'y';
DELETE FROM t1 WHERE a=2;
SELECT * FROM t1;
a b
1 a
3 c
4 d
5 e
6 x
7 y
DELETE FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>, b <INT_COLUMN>, c <INT_COLUMN>, <CUSTOM_INDEX>(a), <CUSTOM_INDEX>(b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b,c) VALUES (1,2,3),(4,5,6),(7,8,9);
DELETE FROM t1 WHERE a = 10 OR b = 20 ORDER BY c LIMIT 1;
SELECT * FROM t1;
a b c
1 2 3
4 5 6
7 8 9
DROP TABLE t1;

View File

@ -0,0 +1,74 @@
#
# DELETE statements for tables with keys
#
--source have_engine.inc
--source have_default_index.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--let $create_definition = a $int_col, b $char_indexed_col, $default_index (b)
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Index on a CHAR column
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'x'),(7,'y'),(8,'z');
DELETE FROM t1 WHERE b > 'y';
if ($mysql_errname)
{
--let $functionality = DELETE
--source unexpected_result.inc
}
if (!$mysql_errname)
{
DELETE FROM t1 WHERE a=2;
--sorted_result
SELECT * FROM t1;
DELETE FROM t1;
}
DROP TABLE t1;
}
--let $create_definition = a $int_indexed_col PRIMARY KEY, b $char_col
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = PRIMARY KEY
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'x'),(7,'y'),(8,'z');
DELETE FROM t1 WHERE b > 'y';
DELETE FROM t1 WHERE a=2;
--sorted_result
SELECT * FROM t1;
DELETE FROM t1;
DROP TABLE t1;
}
--let $create_definition = a $int_indexed_col, b $int_col, c $int_indexed_col, $default_index(a), $default_index(b)
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Multiple indexes
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a,b,c) VALUES (1,2,3),(4,5,6),(7,8,9);
DELETE FROM t1 WHERE a = 10 OR b = 20 ORDER BY c LIMIT 1;
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
}
--source cleanup_engine.inc

View File

@ -0,0 +1,18 @@
DROP TABLE IF EXISTS t1, t2, t3;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHARACTER SET utf8;
INSERT INTO t1 (a,b) VALUES (100,'foo'),(2, 'b');
CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHARACTER SET utf8;
INSERT INTO t2 (a,b) VALUES (1, 'bar');
CREATE TABLE t3 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHARACTER SET utf8;
DESCRIBE t1;
Field Type Null Key Default Extra
a int(11) YES NULL
b char(8) YES NULL
DESC t2 a;
Field Type Null Key Default Extra
a int(11) YES NULL
DESCRIBE t3 '%';
Field Type Null Key Default Extra
a int(11) YES NULL
b char(8) YES NULL
DROP TABLE t1, t2, t3;

View File

@ -0,0 +1,50 @@
#
# DESCRIBE statement
#
# Note: the output might well be different
# (depending on default values for the engine).
# Examine mismatch carefully and, if columns are shown
# with correct options, add an rdiff.
# If you create combinations (with different startup options),
# you might have to add an rdiff for each of them.
#
--source have_engine.inc
--disable_warnings
DROP TABLE IF EXISTS t1, t2, t3;
--enable_warnings
--let $create_definition = a $int_col, b $char_col
--let $table_options = CHARACTER SET utf8
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = CHARACTER SET
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a,b) VALUES (100,'foo'),(2, 'b');
--let $create_definition = a $int_col, b $char_col
--let $table_options = CHARACTER SET utf8
--let $table_name = t2
--source create_table.inc
INSERT INTO t2 (a,b) VALUES (1, 'bar');
--let $create_definition = a $int_col, b $char_col
--let $table_name = t3
--let $table_options = CHARACTER SET utf8
--source create_table.inc
DESCRIBE t1;
DESC t2 a;
DESCRIBE t3 '%';
DROP TABLE t1, t2, t3;
}
--source cleanup_engine.inc

View File

@ -0,0 +1,71 @@
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> (a)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
CREATE TABLE t2 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
FOREIGN KEY (a) REFERENCES t1(a)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL,
`b` char(8) DEFAULT NULL,
KEY `a` (`a`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
INSERT INTO t2 (a,b) VALUES (1,'a'),(2,'b');
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
INSERT INTO t1 (a,b) VALUES (1,'c'),(2,'d');
INSERT INTO t2 (a,b) VALUES (1,'a'),(2,'b');
UPDATE t2 SET a=a+1;
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
UPDATE t1 SET a=3 WHERE a=2;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
DELETE FROM t1 WHERE a=2;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
DELETE FROM t2 WHERE a=2;
SELECT * FROM t1;
a b
1 c
2 d
SELECT * FROM t2;
a b
1 a
DROP TABLE t1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
DROP TABLE t2;
CREATE TABLE t2 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
FOREIGN KEY (a) REFERENCES t1(a)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL,
`b` char(8) DEFAULT NULL,
KEY `a` (`a`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
INSERT INTO t2 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d');
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`) ON DELETE CASCADE ON UPDATE CASCADE)
INSERT INTO t1 (a,b) VALUES (3,'a'),(4,'a');
INSERT INTO t2 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(4,'e'),(3,'a');
UPDATE t1 SET a=a+1;
SELECT * FROM t2;
a b
5 a
5 a
5 b
5 c
5 d
5 e
DELETE FROM t1 WHERE b='a' LIMIT 2;
SELECT * FROM t2;
a b
TRUNCATE TABLE t1;
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `test`.`t1` (`a`))
DROP TABLE t2;
DROP TABLE t1;

View File

@ -0,0 +1,148 @@
#
# Simple foreign keys setup
#
--source have_engine.inc
--source have_default_index.inc
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
let $create_definition =
a $int_indexed_col,
b $char_col,
$default_index (a)
;
--source create_table.inc
if ($mysql_errname)
{
--source unexpected_result.inc
}
if (!$mysql_errname)
{
let $create_definition =
a $int_indexed_col,
b $char_col,
FOREIGN KEY (a) REFERENCES t1(a)
;
--let $table_name = t2
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Foreign keys
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--source mask_engine.inc
SHOW CREATE TABLE t2;
--let $error_codes = ER_NO_REFERENCED_ROW_2
INSERT INTO t2 (a,b) VALUES (1,'a'),(2,'b');
--source check_errors.inc
if ($mysql_errname != ER_NO_REFERENCED_ROW_2)
{
--let $functionality = Foreign keys
--source unexpected_result.inc
}
INSERT INTO t1 (a,b) VALUES (1,'c'),(2,'d');
INSERT INTO t2 (a,b) VALUES (1,'a'),(2,'b');
--let $error_codes = ER_NO_REFERENCED_ROW_2
UPDATE t2 SET a=a+1;
--source check_errors.inc
if ($mysql_errname != ER_NO_REFERENCED_ROW_2)
{
--let $functionality = Foreign keys
--source unexpected_result.inc
}
--let $error_codes = ER_ROW_IS_REFERENCED_2
UPDATE t1 SET a=3 WHERE a=2;
--source check_errors.inc
--let $error_codes = ER_ROW_IS_REFERENCED_2
DELETE FROM t1 WHERE a=2;
--source check_errors.inc
if ($mysql_errname != ER_ROW_IS_REFERENCED_2)
{
--let $functionality = Foreign keys
--source unexpected_result.inc
}
DELETE FROM t2 WHERE a=2;
--sorted_result
SELECT * FROM t1;
SELECT * FROM t2;
--let $error_codes = ER_ROW_IS_REFERENCED
DROP TABLE t1;
--source check_errors.inc
if ($mysql_errname != ER_ROW_IS_REFERENCED)
{
--let $functionality = Foreign keys
--source unexpected_result.inc
}
DROP TABLE t2;
}
let $create_definition =
a $int_indexed_col,
b $char_col,
FOREIGN KEY (a) REFERENCES t1(a)
ON DELETE CASCADE ON UPDATE CASCADE
;
--let $table_name = t2
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Foreign keys or ON DELETE|UPDATE CASCADE
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--source mask_engine.inc
SHOW CREATE TABLE t2;
--let $error_codes = ER_NO_REFERENCED_ROW_2
INSERT INTO t2 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d');
--source check_errors.inc
INSERT INTO t1 (a,b) VALUES (3,'a'),(4,'a');
INSERT INTO t2 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(4,'e'),(3,'a');
UPDATE t1 SET a=a+1;
if ($mysql_errname)
{
--let $functionality = UPDATE
--source unexpected_result.inc
}
--sorted_result
SELECT * FROM t2;
DELETE FROM t1 WHERE b='a' LIMIT 2;
if ($mysql_errname)
{
--let $functionality = DELETE
--source unexpected_result.inc
}
--sorted_result
SELECT * FROM t2;
--let $error_codes = ER_TRUNCATE_ILLEGAL_FK
TRUNCATE TABLE t1;
--source check_errors.inc
if ($mysql_errname != ER_TRUNCATE_ILLEGAL_FK)
{
--let $functionality = Foreign keys
--source unexpected_result.inc
}
DROP TABLE t2;
}
DROP TABLE t1;
}
--source cleanup_engine.inc

View File

@ -0,0 +1,132 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (v0 VARCHAR(64) <CUSTOM_COL_OPTIONS>,
v1 VARCHAR(16384) <CUSTOM_COL_OPTIONS>,
v2 TEXT <CUSTOM_COL_OPTIONS>,
FULLTEXT v1 (v1)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW INDEXES IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 v1 1 v1 # # NULL NULL YES FULLTEXT
INSERT INTO t1 (v0,v1,v2) VALUES ('text1','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
For developers who want to code on MariaDB or MySQL
* Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
* MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
For MariaDB / MySQL end users
* MariaDB Crash Course by Ben Forta
o First MariaDB book!
o For people who want to learn SQL and the basics of MariaDB.
o Now shipping. Purchase at Amazon.com or your favorite bookseller.
* SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
o Free to read in the Knowledgebase!
* MySQL (4th Edition) by Paul DuBois
o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
* MySQL Cookbook by Paul DuBois
o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
* High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
* MySQL Admin Cookbook
o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
* MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ',
'There are several reasons why contributing code is one of the easiest and most rewarding ways to contribute to MariaDB:
1. We are very responsive toward reviews of submitted code and as soon as the review is done, the submitted code is merged into an existing MariaDB tree and made available to everyone, not just select customers.
2. Code reviews are performed by the MariaDB core development team and the quality, detail, and timeliness of our reviews are better than you will find elsewhere.
3. With MariaDB everyone has access to the latest code.
4. If a patch is very safe and/or very useful we are willing to push it into the stable code (as long as it can\'t break any existing applications). We are willing to do this to ensure the freedom to add small, needed fixes on a stable release so users don\'t have to wait a year for something to be added which is critical to their business.
5. If you are an active contributor, you can become a member of maria-captains, even if you aren\'t working for Monty Program Ab. All captains have the same rights as any other captain to accept and reject patches. Our development model is truly open for everyone.
The Contributing Code page details many of the actual steps involved in working with the MariaDB source code. It\'s important that you use the same tools and submit patches in the same way as other developers to keep development running smoothly.'
), ('text2','test1','test2');
SELECT v0 FROM t1 WHERE MATCH(v1) AGAINST ('contributing' IN NATURAL LANGUAGE MODE);
v0
INSERT INTO t1 (v0,v1,v2) VALUES ('text3','test','test');
SELECT v0, MATCH(v1) AGAINST('contributing' IN NATURAL LANGUAGE MODE) AS rating FROM t1 WHERE MATCH(v1) AGAINST ('contributing' IN NATURAL LANGUAGE MODE);
v0 rating
INSERT INTO t1 (v0,v1,v2) VALUES ('text4','Contributing more...','...is a good idea'),('text5','test','test');
SELECT v0, MATCH(v1) AGAINST('contributing') AS rating FROM t1 WHERE MATCH(v1) AGAINST ('contributing');
v0 rating
text4 1.3705332279205322
SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('-test1 +critical +Cook*' IN BOOLEAN MODE);
v0
text1
SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('-patch +critical +Cook*' IN BOOLEAN MODE);
v0
SELECT v0, MATCH(v1) AGAINST('database' WITH QUERY EXPANSION) AS rating FROM t1 WHERE MATCH(v1) AGAINST ('database' WITH QUERY EXPANSION);
v0 rating
text1 178.11756896972656
DROP TABLE t1;
CREATE TABLE t1 (v0 VARCHAR(64) <CUSTOM_COL_OPTIONS>,
v1 VARCHAR(16384) <CUSTOM_COL_OPTIONS>,
v2 TEXT <CUSTOM_COL_OPTIONS>,
FULLTEXT v1 (v1),
FULLTEXT v1_v2 (v1,v2)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW INDEXES IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 v1 1 v1 # # NULL NULL YES FULLTEXT
t1 1 v1_v2 1 v1 # # NULL NULL YES FULLTEXT
t1 1 v1_v2 2 v2 # # NULL NULL YES FULLTEXT
INSERT INTO t1 (v0,v1,v2) VALUES ('text1','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
For developers who want to code on MariaDB or MySQL
* Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
* MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
For MariaDB / MySQL end users
* MariaDB Crash Course by Ben Forta
o First MariaDB book!
o For people who want to learn SQL and the basics of MariaDB.
o Now shipping. Purchase at Amazon.com or your favorite bookseller.
* SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
o Free to read in the Knowledgebase!
* MySQL (4th Edition) by Paul DuBois
o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
* MySQL Cookbook by Paul DuBois
o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
* High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
* MySQL Admin Cookbook
o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
* MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ',
'There are several reasons why contributing code is one of the easiest and most rewarding ways to contribute to MariaDB:
1. We are very responsive toward reviews of submitted code and as soon as the review is done, the submitted code is merged into an existing MariaDB tree and made available to everyone, not just select customers.
2. Code reviews are performed by the MariaDB core development team and the quality, detail, and timeliness of our reviews are better than you will find elsewhere.
3. With MariaDB everyone has access to the latest code.
4. If a patch is very safe and/or very useful we are willing to push it into the stable code (as long as it can\'t break any existing applications). We are willing to do this to ensure the freedom to add small, needed fixes on a stable release so users don\'t have to wait a year for something to be added which is critical to their business.
5. If you are an active contributor, you can become a member of maria-captains, even if you aren\'t working for Monty Program Ab. All captains have the same rights as any other captain to accept and reject patches. Our development model is truly open for everyone.
The Contributing Code page details many of the actual steps involved in working with the MariaDB source code. It\'s important that you use the same tools and submit patches in the same way as other developers to keep development running smoothly.'
), ('text2','test1','test2');
SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('contributing' IN NATURAL LANGUAGE MODE);
v0
INSERT INTO t1 (v0,v1,v2) VALUES ('text3','test','test');
SELECT v0, MATCH(v1,v2) AGAINST('contributing' IN NATURAL LANGUAGE MODE) AS rating FROM t1 WHERE MATCH(v1,v2) AGAINST ('contributing' IN NATURAL LANGUAGE MODE);
v0 rating
text1 0.2809644043445587
INSERT INTO t1 (v0,v1,v2) VALUES ('text4','Contributing more...','...is a good idea'),('text5','test','test');
SELECT v0, MATCH(v1) AGAINST('contributing') AS rating FROM t1 WHERE MATCH(v1) AGAINST ('contributing');
v0 rating
text4 1.3705332279205322
SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('-test1 +critical +Cook*' IN BOOLEAN MODE);
v0
text1
SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('-patch +critical +Cook*' IN BOOLEAN MODE);
v0
SELECT v0, MATCH(v1,v2) AGAINST('database' WITH QUERY EXPANSION) AS rating FROM t1 WHERE MATCH(v1,v2) AGAINST ('database' WITH QUERY EXPANSION);
v0 rating
text1 190.56150817871094
text4 1.1758291721343994
DROP TABLE t1;

View File

@ -0,0 +1,187 @@
#
# Full-text indexes and search
#
--source have_engine.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
let $create_definition =
v0 VARCHAR(64) $col_opts,
v1 VARCHAR(16384) $col_indexed_opts,
v2 TEXT $col_opts,
FULLTEXT v1 (v1)
;
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = FULLTEXT indexes or VARCHAR|TEXT data types
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 6 # 7 #
SHOW INDEXES IN t1;
INSERT INTO t1 (v0,v1,v2) VALUES ('text1','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
For developers who want to code on MariaDB or MySQL
* Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
* MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
For MariaDB / MySQL end users
* MariaDB Crash Course by Ben Forta
o First MariaDB book!
o For people who want to learn SQL and the basics of MariaDB.
o Now shipping. Purchase at Amazon.com or your favorite bookseller.
* SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
o Free to read in the Knowledgebase!
* MySQL (4th Edition) by Paul DuBois
o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
* MySQL Cookbook by Paul DuBois
o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
* High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
* MySQL Admin Cookbook
o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
* MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ',
'There are several reasons why contributing code is one of the easiest and most rewarding ways to contribute to MariaDB:
1. We are very responsive toward reviews of submitted code and as soon as the review is done, the submitted code is merged into an existing MariaDB tree and made available to everyone, not just select customers.
2. Code reviews are performed by the MariaDB core development team and the quality, detail, and timeliness of our reviews are better than you will find elsewhere.
3. With MariaDB everyone has access to the latest code.
4. If a patch is very safe and/or very useful we are willing to push it into the stable code (as long as it can\'t break any existing applications). We are willing to do this to ensure the freedom to add small, needed fixes on a stable release so users don\'t have to wait a year for something to be added which is critical to their business.
5. If you are an active contributor, you can become a member of maria-captains, even if you aren\'t working for Monty Program Ab. All captains have the same rights as any other captain to accept and reject patches. Our development model is truly open for everyone.
The Contributing Code page details many of the actual steps involved in working with the MariaDB source code. It\'s important that you use the same tools and submit patches in the same way as other developers to keep development running smoothly.'
), ('text2','test1','test2');
# 50% rule -- no result if the string is represented in at least 50% rows
SELECT v0 FROM t1 WHERE MATCH(v1) AGAINST ('contributing' IN NATURAL LANGUAGE MODE);
# Adding a row to start getting results
INSERT INTO t1 (v0,v1,v2) VALUES ('text3','test','test');
SELECT v0, MATCH(v1) AGAINST('contributing' IN NATURAL LANGUAGE MODE) AS rating FROM t1 WHERE MATCH(v1) AGAINST ('contributing' IN NATURAL LANGUAGE MODE);
INSERT INTO t1 (v0,v1,v2) VALUES ('text4','Contributing more...','...is a good idea'),('text5','test','test');
SELECT v0, MATCH(v1) AGAINST('contributing') AS rating FROM t1 WHERE MATCH(v1) AGAINST ('contributing');
# Boolean mode
SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('-test1 +critical +Cook*' IN BOOLEAN MODE);
SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('-patch +critical +Cook*' IN BOOLEAN MODE);
# Query expansion
SELECT v0, MATCH(v1) AGAINST('database' WITH QUERY EXPANSION) AS rating FROM t1 WHERE MATCH(v1) AGAINST ('database' WITH QUERY EXPANSION);
DROP TABLE t1;
}
let $create_definition =
v0 VARCHAR(64) $col_opts,
v1 VARCHAR(16384) $col_opts,
v2 TEXT $col_opts,
FULLTEXT v1 (v1),
FULLTEXT v1_v2 (v1,v2)
;
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = FULLTEXT indexes or multiple keys or VARCHAR|TEXT data types
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 6 # 7 #
SHOW INDEXES IN t1;
INSERT INTO t1 (v0,v1,v2) VALUES ('text1','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
For developers who want to code on MariaDB or MySQL
* Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
* MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
For MariaDB / MySQL end users
* MariaDB Crash Course by Ben Forta
o First MariaDB book!
o For people who want to learn SQL and the basics of MariaDB.
o Now shipping. Purchase at Amazon.com or your favorite bookseller.
* SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
o Free to read in the Knowledgebase!
* MySQL (4th Edition) by Paul DuBois
o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
* MySQL Cookbook by Paul DuBois
o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
* High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
* MySQL Admin Cookbook
o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
* MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ',
'There are several reasons why contributing code is one of the easiest and most rewarding ways to contribute to MariaDB:
1. We are very responsive toward reviews of submitted code and as soon as the review is done, the submitted code is merged into an existing MariaDB tree and made available to everyone, not just select customers.
2. Code reviews are performed by the MariaDB core development team and the quality, detail, and timeliness of our reviews are better than you will find elsewhere.
3. With MariaDB everyone has access to the latest code.
4. If a patch is very safe and/or very useful we are willing to push it into the stable code (as long as it can\'t break any existing applications). We are willing to do this to ensure the freedom to add small, needed fixes on a stable release so users don\'t have to wait a year for something to be added which is critical to their business.
5. If you are an active contributor, you can become a member of maria-captains, even if you aren\'t working for Monty Program Ab. All captains have the same rights as any other captain to accept and reject patches. Our development model is truly open for everyone.
The Contributing Code page details many of the actual steps involved in working with the MariaDB source code. It\'s important that you use the same tools and submit patches in the same way as other developers to keep development running smoothly.'
), ('text2','test1','test2');
# 50% rule -- no result if the string is represented in at least 50% rows
SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('contributing' IN NATURAL LANGUAGE MODE);
# Adding a row to start getting results
INSERT INTO t1 (v0,v1,v2) VALUES ('text3','test','test');
SELECT v0, MATCH(v1,v2) AGAINST('contributing' IN NATURAL LANGUAGE MODE) AS rating FROM t1 WHERE MATCH(v1,v2) AGAINST ('contributing' IN NATURAL LANGUAGE MODE);
INSERT INTO t1 (v0,v1,v2) VALUES ('text4','Contributing more...','...is a good idea'),('text5','test','test');
SELECT v0, MATCH(v1) AGAINST('contributing') AS rating FROM t1 WHERE MATCH(v1) AGAINST ('contributing');
# Boolean mode
SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('-test1 +critical +Cook*' IN BOOLEAN MODE);
SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('-patch +critical +Cook*' IN BOOLEAN MODE);
# Query expansion
SELECT v0, MATCH(v1,v2) AGAINST('database' WITH QUERY EXPANSION) AS rating FROM t1 WHERE MATCH(v1,v2) AGAINST ('database' WITH QUERY EXPANSION);
DROP TABLE t1;
}
--source cleanup_engine.inc

View File

@ -0,0 +1,77 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a <CHAR_COLUMN>, b <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES ('foobar',1000),('a',1),('bar',200),('foo',100);
HANDLER t1 OPEN AS h1;
HANDLER t1 READ FIRST;
ERROR 42S02: Unknown table 't1' in HANDLER
HANDLER h1 READ FIRST;
a b
foobar 1000
HANDLER h1 READ NEXT;
a b
a 1
HANDLER h1 READ FIRST WHERE a < 'foo';
a b
a 1
HANDLER h1 READ NEXT;
a b
bar 200
HANDLER h1 READ NEXT;
a b
foo 100
HANDLER h1 READ NEXT;
a b
HANDLER h1 READ FIRST LIMIT 2;
a b
foobar 1000
a 1
HANDLER h1 READ NEXT;
a b
bar 200
HANDLER h1 READ NEXT WHERE b>500 LIMIT 2;
a b
HANDLER t1 OPEN;
HANDLER h1 READ FIRST WHERE b>500 LIMIT 5;
a b
foobar 1000
HANDLER t1 READ NEXT;
a b
foobar 1000
HANDLER h1 READ NEXT WHERE b<100;
a b
HANDLER t1 CLOSE;
HANDLER h1 READ FIRST;
a b
foobar 1000
HANDLER t1 CLOSE;
ERROR 42S02: Unknown table 't1' in HANDLER
DROP TABLE t1;
HANDLER h1 CLOSE;
ERROR 42S02: Unknown table 'h1' in HANDLER
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, <CUSTOM_INDEX> (a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (b,a) VALUES ('a',1),('b',200),('f',100),('b',101),('c',2);
HANDLER t1 OPEN AS h1;
HANDLER h1 READ a = (100);
a b
100 f
HANDLER h1 READ a <= (100) WHERE b < 'f';
a b
2 c
HANDLER h1 READ a > (2) WHERE b IS NOT NULL LIMIT 2;
a b
100 f
101 b
HANDLER h1 READ a FIRST;
a b
1 a
HANDLER h1 READ a LAST;
a b
200 b
HANDLER h1 READ a PREV;
a b
101 b
HANDLER h1 READ a NEXT;
a b
200 b
HANDLER h1 CLOSE;
DROP TABLE t1;

View File

@ -0,0 +1,81 @@
#
# Basic HANDLER syntax
#
# HANDLER .. READ <index_name> is covered in handler_index test
#
--source have_engine.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--let $create_definition = a $char_col, b $int_col
--source create_table.inc
INSERT INTO t1 (a,b) VALUES ('foobar',1000),('a',1),('bar',200),('foo',100);
HANDLER t1 OPEN AS h1;
if ($mysql_errname)
{
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--let $error_codes = ER_UNKNOWN_TABLE
HANDLER t1 READ FIRST;
--source check_errors.inc
HANDLER h1 READ FIRST;
HANDLER h1 READ NEXT;
HANDLER h1 READ FIRST WHERE a < 'foo';
HANDLER h1 READ NEXT;
HANDLER h1 READ NEXT;
HANDLER h1 READ NEXT;
HANDLER h1 READ FIRST LIMIT 2;
HANDLER h1 READ NEXT;
HANDLER h1 READ NEXT WHERE b>500 LIMIT 2;
HANDLER t1 OPEN;
HANDLER h1 READ FIRST WHERE b>500 LIMIT 5;
HANDLER t1 READ NEXT;
HANDLER h1 READ NEXT WHERE b<100;
HANDLER t1 CLOSE;
HANDLER h1 READ FIRST;
--let $error_codes = ER_UNKNOWN_TABLE
HANDLER t1 CLOSE;
--source check_errors.inc
}
DROP TABLE t1;
--let $error_codes = ER_UNKNOWN_TABLE
HANDLER h1 CLOSE;
--source check_errors.inc
--let $continue = 1
--source have_default_index.inc
if ($have_default_index)
{
--let $create_definition = a $int_indexed_col, b $char_col, $default_index (a)
--source create_table.inc
INSERT INTO t1 (b,a) VALUES ('a',1),('b',200),('f',100),('b',101),('c',2);
if ($mysql_errname)
{
--source unexpected_result.inc
}
HANDLER t1 OPEN AS h1;
if (!$mysql_errname)
{
HANDLER h1 READ a = (100);
HANDLER h1 READ a <= (100) WHERE b < 'f';
HANDLER h1 READ a > (2) WHERE b IS NOT NULL LIMIT 2;
HANDLER h1 READ a FIRST;
HANDLER h1 READ a LAST;
HANDLER h1 READ a PREV;
HANDLER h1 READ a NEXT;
HANDLER h1 CLOSE;
}
DROP TABLE t1;
}
--source cleanup_engine.inc

View File

@ -0,0 +1,20 @@
#
# This include file either just prints the message, or skips the rest of the test
# Usage:
# --let $continue = 1; # optional
# --source have_default_index.inc
#
--let $have_default_index = 1
if ($default_index == '/*!*/ /*Custom index*/')
{
if (!$continue)
{
--source cleanup_engine.inc
--skip # Configuration does not allow indexes. Check \$default_index value
}
--echo # According to the configuration, the engine does not allow indexes. Check \$default_index value
--let $have_default_index = 0
--let $continue = 0
}

View File

@ -0,0 +1,127 @@
###########################################
#
# This include file executes define_engine.inc which belongs to the storage engine
# and then checks and sets test options and parameters.
#
# The name of the engine under test must be defined in $ENGINE variable.
# You can define it either in define_engine.inc or in your environment.
#
################################
#
# The following three variables define specific options for columns and tables.
# Normally there should be none needed, but for some engines it can be different.
# If the engine requires specific column option for all or indexed columns,
# set them inside the comment, e.g. /*!NOT NULL*/.
# Do the same for table options if needed, e.g. /*!INSERT_METHOD=LAST*/
let $default_col_opts = /*!*/;
let $default_col_indexed_opts = /*!*/;
let $default_tbl_opts = /*!*/;
# INDEX, UNIQUE INDEX, PRIMARY KEY, special index type -- choose minimal that the engine allows,
# or set it to /*!*/ if none is supported
let $default_index = /*!INDEX*/;
# If the engine does not support these types, replace them with the closest possible
let $default_int_type = INT(11);
let $default_char_type = CHAR(8);
################################
#
# Here the actual work starts
# define_engine.inc will set the ENGINE variable
# and possibly redefine some of default_* variables
--source define_engine.inc
if (!$ENGINE)
{
--skip ERROR: Storage engine under test is not defined, export ENGINE env variable or set it in define_engine.inc
}
# Check that the storage engine is loaded. Here we don't need to worry about the case,
# as I_S is case-insensitive.
if (!`SELECT engine FROM INFORMATION_SCHEMA.ENGINES WHERE engine = '$ENGINE' AND support IN ('YES', 'DEFAULT', 'ENABLED')`)
{
--skip The test requires $ENGINE engine
}
# Further in tests we will use $storage_engine variable
let $storage_engine = $ENGINE;
# In case somebody removed comment tags in define_engine.inc
if (!$default_col_opts)
{
let $default_col_opts = /*!*/;
}
if (!$default_col_indexed_opts)
{
let $default_col_indexed_opts = /*!*/;
}
if (!$default_tbl_opts)
{
let $default_tbl_opts = /*!*/;
}
if (!$default_index)
{
let $default_index = /*!*/;
}
# Adding a comment after default options helps later to mask the custom values in result output
let $default_index = $default_index /*Custom index*/;
let $default_col_opts = $default_col_opts /*Custom column options*/;
let $default_col_indexed_opts = $default_col_indexed_opts /*Custom indexed column options*/;
let $default_tbl_opts = $default_tbl_opts /*Custom table options*/;
# Finally, set some variables which will make our life easier later.
# For many tests, we need a simple INT or CHAR column, but with
# (optional) column attributes which the engine might require.
# Also, a test might be called by another test, and the calling test
# might need additional attributes. So, here we are collecting them all together.
# Example:
# CSV engine requires all columns to be NOT NULL, so its define_engine.inc file will contain
# let $default_col_opts = /*!NOT NULL*/;
# Then, we have test1.test which calls have_engine.inc.
# If it's executed directly, it will have $int_col = 'INT(11) NOT NULL' for CSV and 'INT(11)' for MyISAM.
# Another test, test2.test might set $extra_type_opts = UNSIGNED and/or $extra_col_opts = NULL
# and call test1.test.
# If both are set, test1.test will be executed for MyISAM with 'INT(11) UNSIGNED NULL',
# and for CSV INT(11) UNSIGNED NOT NULL NULL (and will fail because CSV does not support nullable columns)
let $col_opts = $default_col_opts;
let $col_indexed_opts = $default_col_indexed_opts;
if ($extra_col_opts)
{
let $col_opts = $col_opts $extra_col_opts;
let $col_indexed_opts = $col_indexed_opts $extra_col_opts;
}
if ($extra_type_opts)
{
let $col_opts = $extra_type_opts $col_opts;
let $col_indexed_opts = $extra_type_opts $col_indexed_opts;
}
let $int_col = $default_int_type $col_opts;
let $int_indexed_col = $default_int_type $col_indexed_opts;
let $char_col = $default_char_type $col_opts;
let $char_indexed_col = $default_char_type $col_indexed_opts;
if (`SELECT @@global.log_bin = 'ON' AND @@global.binlog_format = 'STATEMENT'`)
{
--disable_query_log
CALL mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT');
--enable_query_log
}
--disable_abort_on_error

View File

@ -0,0 +1,194 @@
#
# Basic syntax related to indexes:
# unique and non-unique keys,
# single- and multi-column keys,
# index option COMMENT.
#
# See other index* tests for operations
# which are less likely to be supported
#
# PRIMARY KEY syntax is covered in index_primary test.
# Index types BTREE|HASH -- in index_type_btree|hash tests.
# SPATIAL -- in type_spatial_indexes test.
# FULLTEXT -- in fulltext_search test.
# KEY_BLOCK_SIZE -- in index_key_block_size test.
#
# Usage to call the test from another test:
#
# A calling test may define $index_type, in which case
# USING clause will be added to the syntax.
#
let $using_index_type = ;
if ($index_type)
{
let $using_index_type = USING $index_type;
}
--source have_engine.inc
--let $continue = 1
--source have_default_index.inc
if ($have_default_index)
{
let $create_definition =
a $int_indexed_col,
b $char_col,
$default_index $using_index_type (a)
;
--source create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--source unexpected_result.inc
}
if (!$mysql_errname)
{
# Cardinality is not the exact science, so here and further
# we'll be masking it
--replace_column 6 # 7 # 10 #
SHOW KEYS IN t1;
DROP TABLE t1;
}
let $create_definition =
a $int_indexed_col,
b $char_indexed_col,
$default_index a_b $using_index_type (a,b) COMMENT 'a_b index'
;
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Multi-part indexes
--let $my_last_stmt = $create_statement
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 6 # 7 # 10 #
SHOW KEYS IN t1;
DROP TABLE t1;
}
let $create_definition =
a $int_indexed_col,
b $char_indexed_col,
$default_index $using_index_type (a),
$default_index $using_index_type (b)
;
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Multiple indexes
--let $my_last_stmt = $create_statement
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 6 # 7 # 10 #
SHOW KEYS IN t1;
DROP TABLE t1;
}
let $create_definition =
a $int_indexed_col,
b $char_col,
UNIQUE INDEX $using_index_type (a)
;
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Unique indexes
--let $my_last_stmt = $create_statement
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 6 # 7 # 10 #
SHOW KEYS IN t1;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
--let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
INSERT INTO t1 (a,b) VALUES (1,'c');
--source check_errors.inc
DROP TABLE t1;
}
#
# ALTER TABLE
#
--let $create_definition = a $int_indexed_col, b $char_col
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Column options
--let $my_last_stmt = $create_statement
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a,b) VALUES (100,'z');
--let $alter_definition = ADD $default_index (a) $using_index_type COMMENT 'simple index on a'
--source alter_table.inc
if ($mysql_errname)
{
--let $functionality = ALTER TABLE .. ADD INDEX
--let $my_last_stmt = $alter_statement
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 6 # 7 # 10 #
SHOW INDEX FROM t1;
--let $alter_definition = DROP KEY a
--source alter_table.inc
}
DROP TABLE t1;
}
let $create_definition =
a $int_indexed_col,
b $char_col,
UNIQUE INDEX $using_index_type (a)
;
--source create_table.inc
if ($mysql_errname)
{
--let $functionality = Unique indexes
--let $my_last_stmt = $create_statement
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 6 # 7 # 10 #
SHOW KEYS IN t1;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
--let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
INSERT INTO t1 (a,b) VALUES (1,'c');
--source check_errors.inc
--let $alter_definition = DROP INDEX a
--source alter_table.inc
if ($mysql_errname)
{
--let $functionality = ALTER TABLE .. DROP INDEX
--let $my_last_stmt = $alter_statement
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a,b) VALUES (1,'c');
--let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
--let $alter_definition = ADD UNIQUE INDEX a(a) $using_index_type
--source alter_table.inc
}
DROP TABLE t1;
}
}

View File

@ -0,0 +1,67 @@
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> (a)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a 1 a # # NULL NULL # BTREE
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> a_b (a,b) COMMENT 'a_b index'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a_b 1 a # # NULL NULL # BTREE a_b index
t1 1 a_b 2 b # # NULL NULL # BTREE a_b index
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> (a),
<CUSTOM_INDEX> (b)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a 1 a # # NULL NULL # BTREE
t1 1 b 1 b # # NULL NULL # BTREE
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
UNIQUE INDEX (a)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 a 1 a # # NULL NULL # BTREE
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
INSERT INTO t1 (a,b) VALUES (1,'c');
ERROR 23000: Duplicate entry '1' for key 'a'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (100,'z');
ALTER TABLE t1 ADD <CUSTOM_INDEX> (a) COMMENT 'simple index on a';
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a 1 a # # NULL NULL # BTREE simple index on a
ALTER TABLE t1 DROP KEY a;
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
UNIQUE INDEX (a)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 a 1 a # # NULL NULL # BTREE
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
INSERT INTO t1 (a,b) VALUES (1,'c');
ERROR 23000: Duplicate entry '1' for key 'a'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
ALTER TABLE t1 DROP INDEX a;
INSERT INTO t1 (a,b) VALUES (1,'c');
ALTER TABLE t1 ADD UNIQUE INDEX a(a) ;
ERROR 23000: Duplicate entry '1' for key 'a'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
DROP TABLE t1;

View File

@ -0,0 +1,23 @@
#
# Basic syntax related to indexes:
# unique and non-unique keys,
# single- and multi-column keys,
# index option COMMENT.
#
# See other index* tests for operations
# which are less likely to be supported
#
# PRIMARY KEY syntax is covered in index_primary test.
# Index types BTREE|HASH -- in index_type_btree|hash tests.
# SPATIAL -- in type_spatial_indexes test.
# FULLTEXT -- in fulltext_search test.
# KEY_BLOCK_SIZE -- in index_key_block_size test.
#
--source have_engine.inc
--source have_default_index.inc
--source index.inc
--source cleanup_engine.inc

View File

@ -0,0 +1,45 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a <INT_COLUMN>, <CUSTOM_INDEX>(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a) VALUES (10);
INSERT INTO t1 (a) VALUES
(1),(2),(3),(4),(5),(6),(7),(8),(9),
(21),(22),(23),(24),(25),(26),(27),(28),(29);
EXPLAIN SELECT a FROM t1 ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 5 NULL # Using index
SHOW INDEX IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a 1 a # # NULL NULL YES BTREE
ALTER TABLE t1 DISABLE KEYS;
SHOW INDEX IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a 1 a # # NULL NULL YES BTREE disabled
EXPLAIN SELECT a FROM t1 ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 19 Using filesort
INSERT INTO t1 (a) VALUES
(11),(12),(13),(14),(15),(16),(17),(18),(19),(20);
ALTER TABLE t1 ENABLE KEYS;
SHOW INDEX IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a 1 a # # NULL NULL YES BTREE
EXPLAIN SELECT a FROM t1 ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 5 NULL # Using index
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>, UNIQUE INDEX(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a) VALUES
(1),(2),(3),(4),(5),(6),(7),(8),(9),
(21),(22),(23),(24),(25),(26),(27),(28),(29);
ALTER TABLE t1 DISABLE KEYS;
INSERT INTO t1 (a) VALUES (29);
ERROR 23000: Duplicate entry '29' for key 'a'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
SHOW INDEX IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 a 1 a # # NULL NULL YES BTREE
EXPLAIN SELECT a FROM t1 ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 5 NULL # Using index
DROP TABLE t1;

View File

@ -0,0 +1,88 @@
#
# ENABLE KEYS / DISABLE KEYS
#
--source have_engine.inc
--source have_default_index.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--let $create_definition = a $int_indexed_col, $default_index(a)
--source create_table.inc
INSERT INTO t1 (a) VALUES (10);
INSERT INTO t1 (a) VALUES
(1),(2),(3),(4),(5),(6),(7),(8),(9),
(21),(22),(23),(24),(25),(26),(27),(28),(29);
# Plan should use the index.
# Masking the `rows` column as the value might vary a bit
--replace_column 9 #
EXPLAIN SELECT a FROM t1 ORDER BY a;
--replace_column 6 # 7 #
SHOW INDEX IN t1;
--let $alter_definition = DISABLE KEYS
--source alter_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $alter_statement
--let $functionality = ALTER .. DISABLE KEYS
--source unexpected_result.inc
}
# Now comment should say 'disabled'
--replace_column 6 # 7 #
SHOW INDEX IN t1;
# And the plan should not use the index
EXPLAIN SELECT a FROM t1 ORDER BY a;
INSERT INTO t1 (a) VALUES
(11),(12),(13),(14),(15),(16),(17),(18),(19),(20);
# The index should be back active
--let $alter_definition = ENABLE KEYS
--source alter_table.inc
--replace_column 6 # 7 #
SHOW INDEX IN t1;
--replace_column 9 #
EXPLAIN SELECT a FROM t1 ORDER BY a;
DROP TABLE t1;
--let $create_definition = a $int_indexed_col, UNIQUE INDEX(a)
--source create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--let $functionality = Unique keys
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a) VALUES
(1),(2),(3),(4),(5),(6),(7),(8),(9),
(21),(22),(23),(24),(25),(26),(27),(28),(29);
# For unique indexes DISABLE KEYS has no effect
--let $alter_definition = DISABLE KEYS
--source alter_table.inc
--let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
INSERT INTO t1 (a) VALUES (29);
--source check_errors.inc
--replace_column 6 # 7 #
SHOW INDEX IN t1;
--replace_column 9 #
EXPLAIN SELECT a FROM t1 ORDER BY a;
DROP TABLE t1;
}
# Cleanup
--source cleanup_engine.inc

View File

@ -0,0 +1,43 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> (a) KEY_BLOCK_SIZE=8
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a 1 a # # NULL NULL # #
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> ind1(b ASC) KEY_BLOCK_SIZE=0
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW INDEX IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 ind1 1 b # # NULL NULL # #
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
UNIQUE INDEX ind2(b(1) DESC) KEY_BLOCK_SIZE=32768 COMMENT 'big key_block_size value'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW INDEX IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 ind2 1 b # # 1 NULL # # big key_block_size value
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> a_b(a,b) KEY_BLOCK_SIZE=8192
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW INDEX IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a_b 1 a # # NULL NULL # #
t1 1 a_b 2 b # # NULL NULL # #
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (100,'z');
ALTER TABLE t1 ADD <CUSTOM_INDEX>(a) KEY_BLOCK_SIZE 8192;
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a 1 a # # NULL NULL # #
DROP TABLE t1;

View File

@ -0,0 +1,125 @@
#
# KEY_BLOCK_SIZE index option.
#
# The results are likely to be different
# depending on the engine
#
--source have_engine.inc
--source have_default_index.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
let $create_definition =
a $int_indexed_col,
b $char_col,
$default_index (a) KEY_BLOCK_SIZE=8
;
--source create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--source unexpected_result.inc
}
if (!$mysql_errname)
{
# Cardinality is not the exact science, so here and further
# we'll be masking it
--replace_column 6 # 7 # 10 # 11 #
SHOW KEYS IN t1;
DROP TABLE t1;
}
let $create_definition =
a $int_col,
b $char_indexed_col,
$default_index ind1(b ASC) KEY_BLOCK_SIZE=0
;
--source create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--let $functionality = Indexes on CHAR columns
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 6 # 7 # 10 # 11 #
SHOW INDEX IN t1;
DROP TABLE t1;
}
let $create_definition =
a $int_col,
b $char_indexed_col,
UNIQUE INDEX ind2(b(1) DESC) KEY_BLOCK_SIZE=32768 COMMENT 'big key_block_size value'
;
--source create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--let $functionality = Unique keys on char columns
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 6 # 7 # 10 # 11 #
SHOW INDEX IN t1;
DROP TABLE t1;
}
let $create_definition =
a $int_indexed_col,
b $char_indexed_col,
$default_index a_b(a,b) KEY_BLOCK_SIZE=8192
;
--source create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--let $functionality = Multi-part keys
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 6 # 7 # 10 # 11 #
SHOW INDEX IN t1;
DROP TABLE t1;
}
#
# ALTER TABLE
#
let $create_definition =
a $int_indexed_col,
b $char_col
;
--source create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a,b) VALUES (100,'z');
--let $alter_definition = ADD $default_index(a) KEY_BLOCK_SIZE 8192
--source alter_table.inc
--replace_column 6 # 7 # 10 # 11 #
SHOW INDEX FROM t1;
DROP TABLE t1;
}
--source cleanup_engine.inc

View File

@ -0,0 +1,53 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a <INT_COLUMN> PRIMARY KEY,
b <CHAR_COLUMN>
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 PRIMARY 1 a # # NULL NULL # #
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
INSERT INTO t1 (a,b) VALUES (1,'c');
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN> PRIMARY KEY,
b <CHAR_COLUMN> PRIMARY KEY
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
ERROR 42000: Multiple primary key defined
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
PRIMARY KEY (a,b)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW INDEX IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 PRIMARY 1 a # # NULL NULL # #
t1 0 PRIMARY 2 b # # NULL NULL # #
INSERT INTO t1 (a,b) VALUES (1,'a'),(1,'b'),(2,'a'),(2,'b');
INSERT INTO t1 (a,b) VALUES (1,'b');
ERROR 23000: Duplicate entry '1-b' for key 'PRIMARY'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN> KEY,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> (b)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW INDEX IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 PRIMARY 1 a # # NULL NULL # #
t1 1 b 1 b # # NULL NULL # #
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN> PRIMARY KEY
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW INDEX IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 PRIMARY 1 b # # NULL NULL # #
ALTER TABLE t1 DROP INDEX `PRIMARY`;
ALTER TABLE t1 ADD CONSTRAINT PRIMARY KEY pk (a);
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 PRIMARY 1 a # # NULL NULL # #
ALTER TABLE t1 DROP PRIMARY KEY;
DROP TABLE t1;

View File

@ -0,0 +1,136 @@
#
# Basic syntax related to primary keys
#
--source have_engine.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
let $create_definition =
a $int_indexed_col PRIMARY KEY,
b $char_col
;
--source create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--let $functionality = PRIMARY KEY
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 6 # 7 # 10 # 11 #
SHOW KEYS IN t1;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
--let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
INSERT INTO t1 (a,b) VALUES (1,'c');
--source check_errors.inc
DROP TABLE t1;
}
--let $error_codes = ER_MULTIPLE_PRI_KEY
let $create_definition =
a $int_indexed_col PRIMARY KEY,
b $char_indexed_col PRIMARY KEY
;
--source create_table.inc
if ($mysql_errname != ER_MULTIPLE_PRI_KEY)
{
--let $my_last_stmt = $create_statement
--let $functionality = PRIMARY KEY
--source unexpected_result.inc
}
let $create_definition =
a $int_indexed_col,
b $char_indexed_col,
PRIMARY KEY (a,b)
;
--source create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--let $functionality = Multi-part keys
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 6 # 7 # 10 # 11 #
SHOW INDEX IN t1;
INSERT INTO t1 (a,b) VALUES (1,'a'),(1,'b'),(2,'a'),(2,'b');
--let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
INSERT INTO t1 (a,b) VALUES (1,'b');
--source check_errors.inc
DROP TABLE t1;
}
--let $continue = 1
--source have_default_index.inc
if ($have_default_index)
{
# KEY in a column definition means PK!
let $create_definition =
a $int_indexed_col KEY,
b $char_indexed_col,
$default_index (b)
;
--source create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--let $functionality = Multiple keys or PK or keys on CHAR columns
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 6 # 7 # 10 # 11 #
SHOW INDEX IN t1;
DROP TABLE t1;
}
}
let $create_definition =
a $int_indexed_col,
b $char_indexed_col PRIMARY KEY
;
--source create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 6 # 7 # 10 # 11 #
SHOW INDEX IN t1;
--let $alter_definition = DROP INDEX `PRIMARY`
--source alter_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $alter_statement
--let $functionality = ALTER TABLE
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--let $alter_definition = ADD CONSTRAINT PRIMARY KEY pk (a)
--source alter_table.inc
--source mask_engine.inc
--replace_column 6 # 7 # 10 # 11 #
SHOW KEYS IN t1;
--let $alter_definition = DROP PRIMARY KEY
--source alter_table.inc
}
DROP TABLE t1;
}
--source cleanup_engine.inc

View File

@ -0,0 +1,67 @@
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> USING BTREE (a)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a 1 a # # NULL NULL # BTREE
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> a_b USING BTREE (a,b) COMMENT 'a_b index'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a_b 1 a # # NULL NULL # BTREE a_b index
t1 1 a_b 2 b # # NULL NULL # BTREE a_b index
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> USING BTREE (a),
<CUSTOM_INDEX> USING BTREE (b)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a 1 a # # NULL NULL # BTREE
t1 1 b 1 b # # NULL NULL # BTREE
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
UNIQUE INDEX USING BTREE (a)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 a 1 a # # NULL NULL # BTREE
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
INSERT INTO t1 (a,b) VALUES (1,'c');
ERROR 23000: Duplicate entry '1' for key 'a'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (100,'z');
ALTER TABLE t1 ADD <CUSTOM_INDEX> (a) USING BTREE COMMENT 'simple index on a';
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a 1 a # # NULL NULL # BTREE simple index on a
ALTER TABLE t1 DROP KEY a;
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
UNIQUE INDEX USING BTREE (a)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 a 1 a # # NULL NULL # BTREE
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
INSERT INTO t1 (a,b) VALUES (1,'c');
ERROR 23000: Duplicate entry '1' for key 'a'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
ALTER TABLE t1 DROP INDEX a;
INSERT INTO t1 (a,b) VALUES (1,'c');
ALTER TABLE t1 ADD UNIQUE INDEX a(a) USING BTREE;
ERROR 23000: Duplicate entry '1' for key 'a'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
DROP TABLE t1;

View File

@ -0,0 +1,12 @@
#
# Index type BTREE
#
--source have_engine.inc
let $index_type = BTREE;
--source index.inc
--source cleanup_engine.inc

View File

@ -0,0 +1,67 @@
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> USING HASH (a)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a 1 a # # NULL NULL # HASH
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> a_b USING HASH (a,b) COMMENT 'a_b index'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a_b 1 a # # NULL NULL # HASH a_b index
t1 1 a_b 2 b # # NULL NULL # HASH a_b index
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> USING HASH (a),
<CUSTOM_INDEX> USING HASH (b)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a 1 a # # NULL NULL # HASH
t1 1 b 1 b # # NULL NULL # HASH
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
UNIQUE INDEX USING HASH (a)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 a 1 a # # NULL NULL # HASH
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
INSERT INTO t1 (a,b) VALUES (1,'c');
ERROR 23000: Duplicate entry '1' for key 'a'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (100,'z');
ALTER TABLE t1 ADD <CUSTOM_INDEX> (a) USING HASH COMMENT 'simple index on a';
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a 1 a # # NULL NULL # HASH simple index on a
ALTER TABLE t1 DROP KEY a;
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
UNIQUE INDEX USING HASH (a)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 a 1 a # # NULL NULL # HASH
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
INSERT INTO t1 (a,b) VALUES (1,'c');
ERROR 23000: Duplicate entry '1' for key 'a'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
ALTER TABLE t1 DROP INDEX a;
INSERT INTO t1 (a,b) VALUES (1,'c');
ALTER TABLE t1 ADD UNIQUE INDEX a(a) USING HASH;
ERROR 23000: Duplicate entry '1' for key 'a'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
DROP TABLE t1;

View File

@ -0,0 +1,12 @@
#
# Index type HASH
#
--source have_engine.inc
let $index_type = HASH;
--source index.inc
--source cleanup_engine.inc

View File

@ -0,0 +1,149 @@
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 VALUES (100,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
SELECT * FROM t1;
a b
1 a
100 foobar
2 b
3 c
4 d
5 e
INSERT t1 VALUE (10,'foo'),(11,'abc');
SELECT * FROM t1;
a b
1 a
10 foo
100 foobar
11 abc
2 b
3 c
4 d
5 e
INSERT INTO t1 (b,a) VALUES ('test',0);
SELECT * FROM t1;
a b
0 test
1 a
10 foo
100 foobar
11 abc
2 b
3 c
4 d
5 e
INSERT INTO t1 VALUES (DEFAULT,DEFAULT);
SELECT * FROM t1;
a b
0 test
1 a
10 foo
100 foobar
11 abc
2 b
3 c
4 d
5 e
NULL NULL
INSERT t1 (a) VALUE (10),(20);
SELECT * FROM t1;
a b
0 test
1 a
10 NULL
10 foo
100 foobar
11 abc
2 b
20 NULL
3 c
4 d
5 e
NULL NULL
INSERT INTO t1 SET a = 11, b = 'f';
SELECT * FROM t1;
a b
0 test
1 a
10 NULL
10 foo
100 foobar
11 abc
11 f
2 b
20 NULL
3 c
4 d
5 e
NULL NULL
INSERT t1 SET b = DEFAULT;
SELECT * FROM t1;
a b
0 test
1 a
10 NULL
10 foo
100 foobar
11 abc
11 f
2 b
20 NULL
3 c
4 d
5 e
NULL NULL
NULL NULL
CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t2 SELECT * FROM t1;
INSERT INTO t1 (a) SELECT a FROM t2 WHERE b = 'foo';
SELECT * FROM t1;
a b
0 test
1 a
10 NULL
10 NULL
10 foo
100 foobar
11 abc
11 f
2 b
20 NULL
3 c
4 d
5 e
NULL NULL
NULL NULL
INSERT t1 SELECT * FROM t1;
SELECT * FROM t1;
a b
0 test
0 test
1 a
1 a
10 NULL
10 NULL
10 NULL
10 NULL
10 foo
10 foo
100 foobar
100 foobar
11 abc
11 abc
11 f
11 f
2 b
2 b
20 NULL
20 NULL
3 c
3 c
4 d
4 d
5 e
5 e
NULL NULL
NULL NULL
NULL NULL
NULL NULL
DROP TABLE t1, t2;

View File

@ -0,0 +1,78 @@
#
# Basic INSERT statements
#
# LOW_PRIORITY|HIGH_PRIORITY are covered in insert_high_low_prio test
# DELAYED is covered in insert_delayed test
# IGNORE and ON DUPLICATE KEY UPDATE are covered in insert_with_keys test
--source have_engine.inc
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
--source create_table.inc
# INSERT [INTO] .. VALUES|VALUE ..
INSERT INTO t1 VALUES (100,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
if ($mysql_errname)
{
--let $functionality = INSERT
--source unexpected_result.inc
}
--sorted_result
SELECT * FROM t1;
INSERT t1 VALUE (10,'foo'),(11,'abc');
--sorted_result
SELECT * FROM t1;
INSERT INTO t1 (b,a) VALUES ('test',0);
--sorted_result
SELECT * FROM t1;
INSERT INTO t1 VALUES (DEFAULT,DEFAULT);
--sorted_result
SELECT * FROM t1;
INSERT t1 (a) VALUE (10),(20);
--sorted_result
SELECT * FROM t1;
# INSERT [INTO] .. SET
INSERT INTO t1 SET a = 11, b = 'f';
--sorted_result
SELECT * FROM t1;
INSERT t1 SET b = DEFAULT;
--sorted_result
SELECT * FROM t1;
# INSERT .. SELECT
--let $table_name = t2
--source create_table.inc
INSERT INTO t2 SELECT * FROM t1;
if ($mysql_errname)
{
--let $functionality = INSERT .. SELECT
--source unexpected_result.inc
}
INSERT INTO t1 (a) SELECT a FROM t2 WHERE b = 'foo';
--sorted_result
SELECT * FROM t1;
INSERT t1 SELECT * FROM t1;
--sorted_result
SELECT * FROM t1;
# Cleanup
DROP TABLE t1, t2;
--source cleanup_engine.inc

View File

@ -0,0 +1,25 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
LOCK TABLE t1 READ;
connect con0,localhost,root,,;
SET lock_wait_timeout = 1;
INSERT DELAYED INTO t1 (a,b) VALUES (3,'c');
INSERT DELAYED INTO t1 SET a=4, b='d';
INSERT DELAYED INTO t1 SELECT 5, 'e';
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
disconnect con0;
connection default;
SELECT * FROM t1;
a b
1 f
2 b
UNLOCK TABLES;
FLUSH TABLES;
SELECT * FROM t1;
a b
1 f
2 b
3 c
4 d
DROP TABLE t1;

View File

@ -0,0 +1,62 @@
#
# INSERT DELAYED
#
--source have_engine.inc
if (`SELECT @@log_bin AND @@binlog_format IN ('statement','mixed')`)
{
--source cleanup_engine.inc
--skip # INSERT DELAYED does not work with binlog format STATEMENT or MIXED
}
--source include/count_sessions.inc
--enable_connect_log
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--let $create_definition = a $int_col, b $char_col
--source create_table.inc
INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
LOCK TABLE t1 READ;
if ($mysql_errname)
{
--let $functionality = LOCK TABLE .. READ
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--connect (con0,localhost,root,,)
SET lock_wait_timeout = 1;
INSERT DELAYED INTO t1 (a,b) VALUES (3,'c');
if ($mysql_errname)
{
--let $functionality = INSERT DELAYED
--source unexpected_result.inc
}
INSERT DELAYED INTO t1 SET a=4, b='d';
# DELAYED is ignored with INSERT .. SELECT
--let $error_codes = ER_LOCK_WAIT_TIMEOUT
INSERT DELAYED INTO t1 SELECT 5, 'e';
--source check_errors.inc
--disconnect con0
--connection default
SELECT * FROM t1;
}
UNLOCK TABLES;
FLUSH TABLES;
SELECT * FROM t1;
# Cleanup
DROP TABLE t1;
let $wait_timeout = 30;
--source include/wait_until_count_sessions.inc
--source cleanup_engine.inc

View File

@ -0,0 +1,64 @@
DROP TABLE IF EXISTS t1;
SET @low_prio_updates = @@global.low_priority_updates;
SET @concur_insert = @@global.concurrent_insert;
SET GLOBAL concurrent_insert = NEVER;
connect con0,localhost,root,,;
SET lock_wait_timeout = 4;
connect con1,localhost,root,,;
SET lock_wait_timeout = 4;
connect con2,localhost,root,,;
SET lock_wait_timeout = 4;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
SET GLOBAL LOW_PRIORITY_UPDATES = 1;
connection con1;
SELECT SLEEP(1) FROM t1;
connection con0;
INSERT INTO t1 (a,b) VALUES (3,'z');
connection con2;
# Should return only 2 rows
SELECT SLEEP(1) FROM t1;
SLEEP(1)
0
0
connection con1;
SLEEP(1)
0
0
connection con0;
SELECT * FROM t1;
a b
1 f
2 b
3 z
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
connection con1;
SELECT SLEEP(1) FROM t1;
connection con0;
INSERT HIGH_PRIORITY INTO t1 (a,b) VALUES (3,'z');
connection con2;
# Should return 3 rows
SELECT SLEEP(1) FROM t1;
SLEEP(1)
0
0
0
connection con1;
SLEEP(1)
0
0
connection con0;
SELECT * FROM t1;
a b
1 f
2 b
3 z
disconnect con1;
disconnect con2;
disconnect con0;
connection default;
SET GLOBAL low_priority_updates = @low_prio_updates;
SET GLOBAL concurrent_insert = @concur_insert;
DROP TABLE t1;

View File

@ -0,0 +1,143 @@
#
# INSERT HIGH_PRIOIRITY
#
--source have_engine.inc
--source include/count_sessions.inc
--enable_connect_log
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
# We will be changing the GLOBAL value of low_priority_updates
# due to bug#64892
# (Session-level low_priority_updates does not work for INSERT)
SET @low_prio_updates = @@global.low_priority_updates;
# Concurrent insert might interfere
# with HIGH|LOW_PRIORITY logic
SET @concur_insert = @@global.concurrent_insert;
SET GLOBAL concurrent_insert = NEVER;
# We will have 3 connections:
# con1 will start SELECT which should give us enough time;
# con0 will run INSERT
# con2 will then start another SELECT.
# With standard INSERT and low_priority_updates=1
# we should see only old rows in both resultsets,
# while with INSERT HIGH_PRIORITY we should see new rows in con2 resultset.
--connect (con0,localhost,root,,)
SET lock_wait_timeout = 4;
--connect (con1,localhost,root,,)
SET lock_wait_timeout = 4;
--connect (con2,localhost,root,,)
SET lock_wait_timeout = 4;
--source create_table.inc
INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
# Normal INSERT with low_priority_updates=1
# should work like INSERT LOW_PRIORITY
SET GLOBAL LOW_PRIORITY_UPDATES = 1;
--connection con1
--send
SELECT SLEEP(1) FROM t1;
--connection con0
let $show_statement = SHOW PROCESSLIST;
let $field = State;
let $condition = = 'User sleep';
let $wait_timeout = 2;
--source include/wait_show_condition.inc
--send
INSERT INTO t1 (a,b) VALUES (3,'z');
--connection con2
let $condition = = 'Waiting for table level lock';
let $wait_timeout = 2;
--source include/wait_show_condition.inc
if (!$found)
{
--let $mysql_errname = timeout in wait_show_condition.inc
--let $functionality = @@low_priority_updates or INSERT or table locking
--source unexpected_result.inc
}
if ($found)
{
--echo # Should return only 2 rows
SELECT SLEEP(1) FROM t1;
}
--connection con1
--reap
--connection con0
--reap
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
--source create_table.inc
INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
# INSERT HIGH_PRIORITY should override low_priority_updates=1
--connection con1
--send
SELECT SLEEP(1) FROM t1;
--connection con0
let $condition = = 'User sleep';
let $wait_timeout = 2;
--source include/wait_show_condition.inc
--send
INSERT HIGH_PRIORITY INTO t1 (a,b) VALUES (3,'z');
--connection con2
let $condition = = 'Waiting for table level lock';
let $wait_timeout = 2;
--source include/wait_show_condition.inc
if (!$found)
{
--let $mysql_errname = timeout in wait_show_condition.inc
--let $functionality = @@low_priority_updates or INSERT HIGH_PRIORITY or table locking
--source unexpected_result.inc
}
if ($found)
{
--echo # Should return 3 rows
SELECT SLEEP(1) FROM t1;
}
--connection con1
--reap
--connection con0
--reap
--sorted_result
SELECT * FROM t1;
--disconnect con1
--disconnect con2
--disconnect con0
let $wait_timeout = 30;
--connection default
SET GLOBAL low_priority_updates = @low_prio_updates;
SET GLOBAL concurrent_insert = @concur_insert;
# Cleanup
DROP TABLE t1;
--source include/wait_until_count_sessions.inc
--source cleanup_engine.inc

View File

@ -0,0 +1,39 @@
DROP TABLE IF EXISTS t1;
SET @low_prio_updates = @@global.low_priority_updates;
SET @concur_insert = @@global.concurrent_insert;
SET GLOBAL concurrent_insert = NEVER;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
connect con0,localhost,root,,;
SET lock_wait_timeout = 4;
connect con1,localhost,root,,;
SET lock_wait_timeout = 4;
connect con2,localhost,root,,;
SET lock_wait_timeout = 4;
connection con1;
SELECT SLEEP(1) FROM t1;
connection con0;
INSERT LOW_PRIORITY INTO t1 (a,b) VALUES (3,'z');
connection con2;
# Should return only 2 rows
SELECT SLEEP(1) FROM t1;
SLEEP(1)
0
0
connection con1;
SLEEP(1)
0
0
connection con0;
SELECT * FROM t1;
a b
1 f
2 b
3 z
disconnect con0;
disconnect con1;
disconnect con2;
connection default;
SET GLOBAL low_priority_updates = @low_prio_updates;
SET GLOBAL concurrent_insert = @concur_insert;
DROP TABLE t1;

View File

@ -0,0 +1,95 @@
#
# INSERT LOW_PRIORITY
#
--source have_engine.inc
--source include/count_sessions.inc
--enable_connect_log
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
# We will be changing the GLOBAL value of low_priority_updates
# due to bug#64892
# (Session-level low_priority_updates does not work for INSERT)
SET @low_prio_updates = @@global.low_priority_updates;
# Concurrent insert might interfere
# with HIGH|LOW_PRIORITY logic
SET @concur_insert = @@global.concurrent_insert;
SET GLOBAL concurrent_insert = NEVER;
--source create_table.inc
INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
# We will have 3 connections:
# con1 will start SELECT which should give us enough time;
# con0 will run INSERT
# con2 will then start another SELECT.
# With INSERT LOW_PRIORITY we should see only old rows in both resultsets.
--connect (con0,localhost,root,,)
SET lock_wait_timeout = 4;
--connect (con1,localhost,root,,)
SET lock_wait_timeout = 4;
--connect (con2,localhost,root,,)
SET lock_wait_timeout = 4;
--connection con1
--send
SELECT SLEEP(1) FROM t1;
--connection con0
let $show_statement = SHOW PROCESSLIST;
let $field = State;
let $condition = = 'User sleep';
# We don't need to wait long,
# thread should show up in the processlist right away
let $wait_timeout = 2;
--source include/wait_show_condition.inc
--send
INSERT LOW_PRIORITY INTO t1 (a,b) VALUES (3,'z');
--connection con2
let $condition = = 'Waiting for table level lock';
let $wait_timeout = 2;
--source include/wait_show_condition.inc
if (!$found)
{
--let $mysql_errname = timeout in wait_show_condition
--let $functionality = INSERT LOW_PRIORITY or table locking
--source unexpected_result.inc
}
if ($found)
{
--echo # Should return only 2 rows
SELECT SLEEP(1) FROM t1;
}
--connection con1
--reap
--connection con0
--reap
--sorted_result
SELECT * FROM t1;
--disconnect con0
--disconnect con1
--disconnect con2
--connection default
SET GLOBAL low_priority_updates = @low_prio_updates;
SET GLOBAL concurrent_insert = @concur_insert;
# Cleanup
DROP TABLE t1;
--source include/wait_until_count_sessions.inc
--source cleanup_engine.inc

View File

@ -0,0 +1,148 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, <CUSTOM_INDEX>(b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
SELECT * FROM t1;
a b
0
1 a
1 a
100 a
12345 z
2 b
29 n
3 a
3 c
30 m
4 d
5 e
6 f
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, UNIQUE INDEX(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
ERROR 23000: Duplicate entry '1' for key 'a'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
ERROR 23000: Duplicate entry '3' for key 'a'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
INSERT INTO t1 (a,b) VALUES (0,'');
SELECT * FROM t1;
a b
0
1 a
100 a
2 b
29 n
3 c
30 m
4 d
5 e
6 f
INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
INSERT INTO t1 (a,b) VALUES (3,'a'),(4,'d') ON DUPLICATE KEY UPDATE a = a+10;
SELECT * FROM t1;
a b
0
1 a
100 a
12345 z
13 c
14 d
2 b
29 n
30 m
5 e
6 f
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, UNIQUE INDEX(a,b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
INSERT INTO t1 (a,b) VALUES (100,'b'), (2,'c');
INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
ERROR 23000: Duplicate entry '1-a' for key 'a'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
SELECT * FROM t1;
a b
1 a
100 a
100 b
2 b
2 c
29 n
3 c
30 m
4 d
5 e
6 f
INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z') ON DUPLICATE KEY UPDATE a = a+VALUES(a);
SELECT * FROM t1;
a b
100 a
100 b
2 a
2 b
2 c
24690 z
29 n
3 c
30 m
4 d
5 e
6 f
INSERT INTO t1 (a,b) VALUES (101,'x'),(101,'x');
ERROR 23000: Duplicate entry '101-x' for key 'a'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN> PRIMARY KEY, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
# If you got a difference in error message, just add it to rdiff file
INSERT INTO t1 (a,b) VALUES (0,'');
SELECT * FROM t1;
a b
0
1 a
100 a
2 b
29 n
3 c
30 m
4 d
5 e
6 f
INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z') ON DUPLICATE KEY UPDATE b = CONCAT(b,b);
SELECT * FROM t1;
a b
0
1 aa
100 a
12345 zz
2 b
29 n
3 c
30 m
4 d
5 e
6 f
DROP TABLE t1;

View File

@ -0,0 +1,143 @@
#
# INSERT statements for tables with keys
#
--source have_engine.inc
--source have_default_index.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--let $create_definition = a $int_col, b $char_indexed_col, $default_index(b)
--source create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--let $functionality = Indexes on CHAR columns
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
}
--let $create_definition = a $int_indexed_col, b $char_col, UNIQUE INDEX(a)
--source create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--let $functionality = Unique indexes
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
--let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
--source check_errors.inc
--let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
--source check_errors.inc
INSERT INTO t1 (a,b) VALUES (0,'');
--sorted_result
SELECT * FROM t1;
INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
if ($mysql_errname)
{
--source unexpected_result.inc
}
INSERT INTO t1 (a,b) VALUES (3,'a'),(4,'d') ON DUPLICATE KEY UPDATE a = a+10;
if ($mysql_errname)
{
--source unexpected_result.inc
}
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
}
--let $create_definition = a $int_indexed_col, b $char_indexed_col, UNIQUE INDEX(a,b)
--source create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--let $functionality = Multi-part indexes
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
INSERT INTO t1 (a,b) VALUES (100,'b'), (2,'c');
--let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
--source check_errors.inc
--sorted_result
SELECT * FROM t1;
INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z') ON DUPLICATE KEY UPDATE a = a+VALUES(a);
--sorted_result
SELECT * FROM t1;
--let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
INSERT INTO t1 (a,b) VALUES (101,'x'),(101,'x');
--source check_errors.inc
DROP TABLE t1;
}
--let $create_definition = a $int_indexed_col PRIMARY KEY, b $char_col
--source create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--let $functionality = Primary keys
--source unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
--let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
--source check_errors.inc
--let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
--source check_errors.inc
INSERT INTO t1 (a,b) VALUES (0,'');
--sorted_result
SELECT * FROM t1;
INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
if ($mysql_errname)
{
--source unexpected_result.inc
}
INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z') ON DUPLICATE KEY UPDATE b = CONCAT(b,b);
if ($mysql_errname)
{
--source unexpected_result.inc
}
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
}
--source cleanup_engine.inc

View File

@ -0,0 +1,68 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
LOAD DATA INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1
FIELDS TERMINATED BY ',';
SELECT * FROM t1;
a b
1 foo
2 bar
3
4 abc
LOAD DATA LOCAL INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1
CHARACTER SET utf8 COLUMNS TERMINATED BY ','
ESCAPED BY '/';
SELECT * FROM t1;
a b
1 foo
1 foo
2 bar
2 bar
3
3
4 abc
4 abc
LOAD DATA INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1
FIELDS TERMINATED BY ';'
OPTIONALLY ENCLOSED BY ''''
LINES STARTING BY 'prefix:'
IGNORE 2 LINES
(a,b);
Warnings:
Warning 1262 Row 2 was truncated; it contained more data than there were input columns
SELECT * FROM t1;
a b
0
1 foo
1 foo
100 foo
2 bar
2 bar
3
3
4 abc
4 abc
7 test
LOAD DATA LOCAL INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1
FIELDS TERMINATED BY ';'
(a) SET b='loaded';
Warnings:
Warning 1262 Row 1 was truncated; it contained more data than there were input columns
Warning 1262 Row 2 was truncated; it contained more data than there were input columns
Warning 1262 Row 3 was truncated; it contained more data than there were input columns
SELECT * FROM t1;
a b
0
0 loaded
1 foo
1 foo
100 foo
102 loaded
2 bar
2 bar
3
3
4 abc
4 abc
5 loaded
7 test
DROP TABLE t1;

View File

@ -0,0 +1,88 @@
#
# Basic LOAD DATA statements
#
--source have_engine.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--source create_table.inc
let $datadir = `SELECT @@datadir`;
--write_file $datadir/se_loaddata.dat
1,foo,
2,bar,
3,,
4,abc,
EOF
--replace_result $datadir <DATADIR>
eval
LOAD DATA INFILE '$datadir/se_loaddata.dat' INTO TABLE t1
FIELDS TERMINATED BY ',';
if ($mysql_errname)
{
--source unexpected_result.inc
}
if (!$mysql_errname)
{
--sorted_result
SELECT * FROM t1;
--replace_result $datadir <DATADIR>
eval
LOAD DATA LOCAL INFILE '$datadir/se_loaddata.dat' INTO TABLE t1
CHARACTER SET utf8 COLUMNS TERMINATED BY ','
ESCAPED BY '/';
--sorted_result
SELECT * FROM t1;
--remove_file $datadir/se_loaddata.dat
--write_file $datadir/se_loaddata.dat
prefix:5;'foo';
prefix:6;'';
prefix:100;foo;
prefix:7;'test';suffix
101;abc;
102;'z';
prefix:0;;
EOF
--replace_result $datadir <DATADIR>
eval
LOAD DATA INFILE '$datadir/se_loaddata.dat' INTO TABLE t1
FIELDS TERMINATED BY ';'
OPTIONALLY ENCLOSED BY ''''
LINES STARTING BY 'prefix:'
IGNORE 2 LINES
(a,b);
--sorted_result
SELECT * FROM t1;
--remove_file $datadir/se_loaddata.dat
--write_file $datadir/se_loaddata.dat
5;YYY;
102;'zzz';
0;'test';
EOF
--replace_result $datadir <DATADIR>
eval
LOAD DATA LOCAL INFILE '$datadir/se_loaddata.dat' INTO TABLE t1
FIELDS TERMINATED BY ';'
(a) SET b='loaded';
--sorted_result
SELECT * FROM t1;
}
# Cleanup
--remove_file $datadir/se_loaddata.dat
DROP TABLE t1;
--source cleanup_engine.inc

View File

@ -0,0 +1,111 @@
connect con1,localhost,root,,;
SET lock_wait_timeout=1;
connection default;
DROP TABLE IF EXISTS t1, t2, t3;
CREATE TABLE t1 (id <INT_COLUMN>, id2 <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (id,id2) VALUES (1,1),(1,2),(1,3);
LOCK TABLE t1 LOW_PRIORITY WRITE;
SELECT id2,COUNT(DISTINCT id) FROM t1 GROUP BY id2;
id2 COUNT(DISTINCT id)
1 1
2 1
3 1
UPDATE t1 SET id=-1 WHERE id=1;
connection con1;
SELECT * FROM t1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
LOCK TABLE t1 READ;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
connection default;
LOCK TABLE t1 READ;
UPDATE t1 SET id=1 WHERE id=1;
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
connection con1;
SELECT COUNT(DISTINCT id) FROM t1;
COUNT(DISTINCT id)
1
UPDATE t1 SET id=2 WHERE id=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
LOCK TABLE t1 WRITE;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
LOCK TABLE t1 READ;
UNLOCK TABLES;
connection default;
CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
ERROR HY000: Table 't2' was not locked with LOCK TABLES
CREATE TEMPORARY TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
DROP TABLE IF EXISTS t2;
UNLOCK TABLES;
CREATE TABLE t2 (id <INT_COLUMN>, id2 <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
LOCK TABLE t1 WRITE, t2 WRITE;
INSERT INTO t2 SELECT * FROM t1;
UPDATE t1 SET id=1 WHERE id=-1;
DROP TABLE t1,t2;
CREATE TABLE t1 (i1 <INT_COLUMN>, nr <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
CREATE TABLE t2 (nr <INT_COLUMN>, nm <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t2 (nr,nm) VALUES (1,3);
INSERT INTO t2 (nr,nm) VALUES (2,4);
lock tables t1 write, t2 read;
INSERT INTO t1 (i1,nr) SELECT 1, nr FROM t2 WHERE nm=3;
INSERT INTO t1 (i1,nr) SELECT 2, nr FROM t2 WHERE nm=4;
UNLOCK TABLES;
LOCK TABLES t1 WRITE;
INSERT INTO t1 (i1,nr) SELECT i1, nr FROM t1;
ERROR HY000: Table 't1' was not locked with LOCK TABLES
UNLOCK TABLES;
LOCK TABLES t1 WRITE, t1 AS t1_alias READ;
INSERT INTO t1 (i1,nr) SELECT i1, nr FROM t1 AS t1_alias;
DROP TABLE t1,t2;
ERROR HY000: Table 't2' was not locked with LOCK TABLES
UNLOCK TABLES;
DROP TABLE t1,t2;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
CREATE TABLE t3 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE;
DROP TABLE t2, t3, t1;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
CREATE TABLE t3 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE, t1 AS t4 READ;
ALTER TABLE t2 ADD COLUMN c2 <INT_COLUMN>;
DROP TABLE t1, t2, t3;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
LOCK TABLE t1 READ, t2 READ;
FLUSH TABLE t1;
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
FLUSH TABLES;
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
FLUSH TABLES t1, t2 WITH READ LOCK;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
UNLOCK TABLES;
FLUSH TABLES t1, t2 WITH READ LOCK;
connection con1;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
connection default;
UNLOCK TABLES;
FLUSH TABLES WITH READ LOCK;
connection con1;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
connection default;
UNLOCK TABLES;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
FLUSH TABLES WITH READ LOCK AND DISABLE CHECKPOINT;
DROP TABLE t1, t2;
ERROR HY000: Can't execute the query because you have a conflicting read lock
UNLOCK TABLES;
DROP TABLE t1, t2;
disconnect con1;
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
LOCK TABLE t1 WRITE, t2 WRITE;
CREATE TEMPORARY TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
FLUSH TABLE t1;
DROP TEMPORARY TABLE t1;
SELECT * FROM t1;
a b
UNLOCK TABLES;
DROP TABLE t1, t2;

View File

@ -0,0 +1,244 @@
# Standard table locking:
# LOCK TABLE .. READ
# LOCK TABLE .. [LOW_PRIORITY] WRITE
# UNLOCK TABLES
#
# and global locking:
# FLUSH TABLES [..] WITH READ LOCK
#
#
--source have_engine.inc
--enable_connect_log
# Save the initial number of concurrent sessions.
--source include/count_sessions.inc
connect (con1,localhost,root,,);
SET lock_wait_timeout=1;
connection default;
--disable_warnings
DROP TABLE IF EXISTS t1, t2, t3;
--enable_warnings
--let $create_definition = id $int_col, id2 $int_col
--source create_table.inc
INSERT INTO t1 (id,id2) VALUES (1,1),(1,2),(1,3);
# LOW_PRIORITY has no effect, but is still syntactically correct
LOCK TABLE t1 LOW_PRIORITY WRITE;
SELECT id2,COUNT(DISTINCT id) FROM t1 GROUP BY id2;
UPDATE t1 SET id=-1 WHERE id=1;
if ($mysql_errname)
{
--let $functionality = UPDATE
--source unexpected_result.inc
}
connection con1;
# With WRITE lock held by connection 'default',
# nobody else can access the table
--let $error_codes = ER_LOCK_WAIT_TIMEOUT
SELECT * FROM t1;
--source check_errors.inc
--let $error_codes = ER_LOCK_WAIT_TIMEOUT
LOCK TABLE t1 READ;
--source check_errors.inc
connection default;
LOCK TABLE t1 READ;
--let $error_codes = ER_TABLE_NOT_LOCKED_FOR_WRITE
UPDATE t1 SET id=1 WHERE id=1;
--source check_errors.inc
if ($mysql_errname != ER_TABLE_NOT_LOCKED_FOR_WRITE)
{
--let $functonality = UPDATE or locking
--source unexpected_result.inc
}
connection con1;
# With READ lock held by connection 'default',
# it should be possible to read from the table
# or acquire another READ lock,
# but not update it or acquire WRITE lock
SELECT COUNT(DISTINCT id) FROM t1;
--let $error_codes = ER_LOCK_WAIT_TIMEOUT
UPDATE t1 SET id=2 WHERE id=2;
--source check_errors.inc
--let $error_codes = ER_LOCK_WAIT_TIMEOUT
LOCK TABLE t1 WRITE;
--source check_errors.inc
LOCK TABLE t1 READ;
UNLOCK TABLES;
--connection default
--let $error_codes = ER_TABLE_NOT_LOCKED
--let $table_name = t2
--source create_table.inc
--let $table_name = t2
--let $temporary = 1
--source create_table.inc
DROP TABLE IF EXISTS t2;
UNLOCK TABLES;
--let $table_name = t2
--let $create_definition = id $int_col, id2 $int_col
--source create_table.inc
LOCK TABLE t1 WRITE, t2 WRITE;
INSERT INTO t2 SELECT * FROM t1;
UPDATE t1 SET id=1 WHERE id=-1;
if ($mysql_errname)
{
--let $functionality = UPDATE
--source unexpected_result.inc
}
DROP TABLE t1,t2;
#
# INSERT ... SELECT with lock tables
#
--let $create_definition = i1 $int_col, nr $int_col
--source create_table.inc
--let $table_name = t2
--let $create_definition = nr $int_col, nm $int_col
--source create_table.inc
INSERT INTO t2 (nr,nm) VALUES (1,3);
INSERT INTO t2 (nr,nm) VALUES (2,4);
lock tables t1 write, t2 read;
INSERT INTO t1 (i1,nr) SELECT 1, nr FROM t2 WHERE nm=3;
INSERT INTO t1 (i1,nr) SELECT 2, nr FROM t2 WHERE nm=4;
UNLOCK TABLES;
LOCK TABLES t1 WRITE;
--let $error_codes = ER_TABLE_NOT_LOCKED
INSERT INTO t1 (i1,nr) SELECT i1, nr FROM t1;
--source check_errors.inc
UNLOCK TABLES;
LOCK TABLES t1 WRITE, t1 AS t1_alias READ;
INSERT INTO t1 (i1,nr) SELECT i1, nr FROM t1 AS t1_alias;
--let $error_codes = ER_TABLE_NOT_LOCKED
DROP TABLE t1,t2;
--source check_errors.inc
UNLOCK TABLES;
DROP TABLE t1,t2;
#
# Check that a dropped table is removed from a lock
--source create_table.inc
--let $table_name = t2
--source create_table.inc
--let $table_name = t3
--source create_table.inc
LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE;
# This removes one table after the other from the lock.
DROP TABLE t2, t3, t1;
#
# Check that a lock merge works
--source create_table.inc
--let $table_name = t2
--source create_table.inc
--let $table_name = t3
--source create_table.inc
LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE, t1 AS t4 READ;
--let $alter_definition = ADD COLUMN c2 $int_col
--let $table_name = t2
--source alter_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $alter_statement
--let $functionality = ALTER TABLE
--source unexpected_result.inc
}
DROP TABLE t1, t2, t3;
# FLUSH TABLES is not permitted when there is an active LOCK TABLES .. READ,
# FLUSH TABLES .. WITH READ LOCK should be used instead
# (and for other connections the table is locked)
--source create_table.inc
--let $table_name = t2
--source create_table.inc
LOCK TABLE t1 READ, t2 READ;
--let $error_codes = ER_TABLE_NOT_LOCKED_FOR_WRITE
FLUSH TABLE t1;
--source check_errors.inc
--let $error_codes = ER_TABLE_NOT_LOCKED_FOR_WRITE
FLUSH TABLES;
--source check_errors.inc
--let $error_codes = ER_LOCK_OR_ACTIVE_TRANSACTION
FLUSH TABLES t1, t2 WITH READ LOCK;
--source check_errors.inc
UNLOCK TABLES;
FLUSH TABLES t1, t2 WITH READ LOCK;
--connection con1
--let $error_codes = ER_LOCK_WAIT_TIMEOUT
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
--source check_errors.inc
--connection default
UNLOCK TABLES;
# Global lock
FLUSH TABLES WITH READ LOCK;
--connection con1
--let $error_codes = ER_LOCK_WAIT_TIMEOUT
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
--source check_errors.inc
--connection default
UNLOCK TABLES;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
FLUSH TABLES WITH READ LOCK AND DISABLE CHECKPOINT;
--let $error_codes = ER_CANT_UPDATE_WITH_READLOCK
DROP TABLE t1, t2;
--source check_errors.inc
UNLOCK TABLES;
DROP TABLE t1, t2;
--disconnect con1
#
# Ensure that FLUSH TABLES doesn't substitute a base locked table
# with a temporary one.
#
--source create_table.inc
--let $table_name = t2
--source create_table.inc
LOCK TABLE t1 WRITE, t2 WRITE;
--let $temporary = 1
--source create_table.inc
FLUSH TABLE t1;
DROP TEMPORARY TABLE t1;
SELECT * FROM t1;
UNLOCK TABLES;
DROP TABLE t1, t2;
# 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
--source cleanup_engine.inc

View File

@ -0,0 +1,12 @@
SET lock_wait_timeout = 1;
CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
LOCK TABLES t1 WRITE CONCURRENT, t1 AS t2 READ;
SET lock_wait_timeout = 1;
LOCK TABLES t1 READ LOCAL;
UNLOCK TABLES;
UNLOCK TABLES;
LOCK TABLES t1 READ LOCAL;
LOCK TABLES t1 WRITE CONCURRENT, t1 AS t2 READ;
UNLOCK TABLES;
UNLOCK TABLES;
DROP TABLE t1;

View File

@ -0,0 +1,52 @@
#
# READ LOCAL / WRITE CONCURRENT locks.
# This test is separate from the main lock.test
# because the feature is likely to be unsupported.
#
--source have_engine.inc
--source include/count_sessions.inc
SET lock_wait_timeout = 1;
--let $create_definition = a $int_col
--source create_table.inc
LOCK TABLES t1 WRITE CONCURRENT, t1 AS t2 READ;
connect (con1,localhost,root,,);
SET lock_wait_timeout = 1;
# If this statement fails with ER_LOCK_WAIT_TIMEOUT,
# most likely the engine does not support LOCK .. WRITE CONCURRENT
LOCK TABLES t1 READ LOCAL;
if ($mysql_errname)
{
--let $functionality = LOCK .. WRITE CONCURRENT
--source unexpected_result.inc
}
UNLOCK TABLES;
connection default;
UNLOCK TABLES;
connection con1;
LOCK TABLES t1 READ LOCAL;
connection default;
LOCK TABLES t1 WRITE CONCURRENT, t1 AS t2 READ;
UNLOCK TABLES;
connection con1;
UNLOCK TABLES;
disconnect con1;
connection default;
DROP TABLE t1;
--source include/wait_until_count_sessions.inc
--source cleanup_engine.inc

View File

@ -0,0 +1,14 @@
#
# This include file just replaces the storage engine under test by the generic string <STORAGE_ENGINE>
# in the next statement. More masks can be added by defining $add_regex, e.g.
# let $add_regex = /$data_dir/<DATA_DIR>/ /$index_dir/<INDEX_DIR>/
#
--let $regex = /$storage_engine/<STORAGE_ENGINE>/i
if ($add_regex)
{
--let $regex = $regex $add_regex
}
--let $add_regex =
--replace_regex $regex

View File

@ -0,0 +1,79 @@
INSERT INTO mysql.event (
db,
name,
body,
definer,
interval_value,
interval_field,
originator,
character_set_client,
collation_connection,
db_collation,
body_utf8)
values (
database(),
"ev1",
"select 1",
user(),
100,
"SECOND_MICROSECOND",
1,
'utf8',
'utf8_general_ci',
'utf8_general_ci',
'select 1');
SHOW EVENTS;
ERROR 42000: This version of MariaDB doesn't yet support 'MICROSECOND'
DROP EVENT ev1;
SELECT TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE ORDER BY TABLE_NAME;
TABLE_NAME COLUMN_NAME REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
columns_priv Column_name NULL NULL
columns_priv Db NULL NULL
columns_priv Host NULL NULL
columns_priv Table_name NULL NULL
columns_priv User NULL NULL
db Db NULL NULL
db Host NULL NULL
db User NULL NULL
event db NULL NULL
event name NULL NULL
func name NULL NULL
help_category help_category_id NULL NULL
help_category name NULL NULL
help_keyword help_keyword_id NULL NULL
help_keyword name NULL NULL
help_relation help_keyword_id NULL NULL
help_relation help_topic_id NULL NULL
help_topic help_topic_id NULL NULL
help_topic name NULL NULL
host Db NULL NULL
host Host NULL NULL
ndb_binlog_index epoch NULL NULL
plugin name NULL NULL
proc db NULL NULL
proc name NULL NULL
proc type NULL NULL
procs_priv Db NULL NULL
procs_priv Host NULL NULL
procs_priv Routine_name NULL NULL
procs_priv Routine_type NULL NULL
procs_priv User NULL NULL
proxies_priv Host NULL NULL
proxies_priv Proxied_host NULL NULL
proxies_priv Proxied_user NULL NULL
proxies_priv User NULL NULL
servers Server_name NULL NULL
tables_priv Db NULL NULL
tables_priv Host NULL NULL
tables_priv Table_name NULL NULL
tables_priv User NULL NULL
time_zone Time_zone_id NULL NULL
time_zone_leap_second Transition_time NULL NULL
time_zone_name Name NULL NULL
time_zone_transition Time_zone_id NULL NULL
time_zone_transition Transition_time NULL NULL
time_zone_transition_type Time_zone_id NULL NULL
time_zone_transition_type Transition_type_id NULL NULL
user Host NULL NULL
user User NULL NULL

View File

@ -0,0 +1,47 @@
#
# Different statements not related to an engine,
# but added to provide function coverage for handler.cc and handler.h.
# The test can be disabled or removed later.
#
# hits get_error_message(int, String*)
--source have_engine.inc
INSERT INTO mysql.event (
db,
name,
body,
definer,
interval_value,
interval_field,
originator,
character_set_client,
collation_connection,
db_collation,
body_utf8)
values (
database(),
"ev1",
"select 1",
user(),
100,
"SECOND_MICROSECOND",
1,
'utf8',
'utf8_general_ci',
'utf8_general_ci',
'select 1');
--let $error_codes = ER_NOT_SUPPORTED_YET
SHOW EVENTS;
--source check_errors.inc
DROP EVENT ev1;
# hits get_foreign_key_list(THD*, List<st_foreign_key_info>*)
--sorted_result
SELECT TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE ORDER BY TABLE_NAME;
--source cleanup_engine.inc

Some files were not shown because too many files have changed in this diff Show More