1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 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;
}
}
|