| 1 |
# |
| 2 |
# Basic syntax related to primary keys |
| 3 |
# |
| 4 |
|
| 5 |
--source have_engine.inc |
| 6 |
|
| 7 |
--disable_warnings |
| 8 |
DROP TABLE IF EXISTS t1; |
| 9 |
--enable_warnings |
| 10 |
|
| 11 |
let $create_definition = |
| 12 |
a $int_indexed_col PRIMARY KEY, |
| 13 |
b $char_col |
| 14 |
; |
| 15 |
--source create_table.inc |
| 16 |
if ($mysql_errname) |
| 17 |
{ |
| 18 |
--let $my_last_stmt = $create_statement |
| 19 |
--let $functionality = PRIMARY KEY |
| 20 |
--source unexpected_result.inc |
| 21 |
} |
| 22 |
if (!$mysql_errname) |
| 23 |
{ |
| 24 |
--replace_column 6 # 7 # 10 # 11 # |
| 25 |
SHOW KEYS IN t1; |
| 26 |
|
| 27 |
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'); |
| 28 |
--let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY |
| 29 |
INSERT INTO t1 (a,b) VALUES (1,'c'); |
| 30 |
--source check_errors.inc |
| 31 |
|
| 32 |
DROP TABLE t1; |
| 33 |
} |
| 34 |
|
| 35 |
--let $error_codes = ER_MULTIPLE_PRI_KEY |
| 36 |
let $create_definition = |
| 37 |
a $int_indexed_col PRIMARY KEY, |
| 38 |
b $char_indexed_col PRIMARY KEY |
| 39 |
; |
| 40 |
--source create_table.inc |
| 41 |
if ($mysql_errname != ER_MULTIPLE_PRI_KEY) |
| 42 |
{ |
| 43 |
--let $my_last_stmt = $create_statement |
| 44 |
--let $functionality = PRIMARY KEY |
| 45 |
--source unexpected_result.inc |
| 46 |
} |
| 47 |
|
| 48 |
let $create_definition = |
| 49 |
a $int_indexed_col, |
| 50 |
b $char_indexed_col, |
| 51 |
PRIMARY KEY (a,b) |
| 52 |
; |
| 53 |
--source create_table.inc |
| 54 |
if ($mysql_errname) |
| 55 |
{ |
| 56 |
--let $my_last_stmt = $create_statement |
| 57 |
--let $functionality = Multi-part keys |
| 58 |
--source unexpected_result.inc |
| 59 |
} |
| 60 |
if (!$mysql_errname) |
| 61 |
{ |
| 62 |
--replace_column 6 # 7 # 10 # 11 # |
| 63 |
SHOW INDEX IN t1; |
| 64 |
INSERT INTO t1 (a,b) VALUES (1,'a'),(1,'b'),(2,'a'),(2,'b'); |
| 65 |
--let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY |
| 66 |
INSERT INTO t1 (a,b) VALUES (1,'b'); |
| 67 |
--source check_errors.inc |
| 68 |
DROP TABLE t1; |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
--let $continue = 1 |
| 73 |
--source have_default_index.inc |
| 74 |
if ($have_default_index) |
| 75 |
{ |
| 76 |
# KEY in a column definition means PK! |
| 77 |
let $create_definition = |
| 78 |
a $int_indexed_col KEY, |
| 79 |
b $char_indexed_col, |
| 80 |
$default_index (b) |
| 81 |
; |
| 82 |
--source create_table.inc |
| 83 |
if ($mysql_errname) |
| 84 |
{ |
| 85 |
--let $my_last_stmt = $create_statement |
| 86 |
--let $functionality = Multiple keys or PK or keys on CHAR columns |
| 87 |
--source unexpected_result.inc |
| 88 |
} |
| 89 |
if (!$mysql_errname) |
| 90 |
{ |
| 91 |
--replace_column 6 # 7 # 10 # 11 # |
| 92 |
SHOW INDEX IN t1; |
| 93 |
DROP TABLE t1; |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
let $create_definition = |
| 98 |
a $int_indexed_col, |
| 99 |
b $char_indexed_col PRIMARY KEY |
| 100 |
; |
| 101 |
--source create_table.inc |
| 102 |
if ($mysql_errname) |
| 103 |
{ |
| 104 |
--let $my_last_stmt = $create_statement |
| 105 |
--source unexpected_result.inc |
| 106 |
} |
| 107 |
if (!$mysql_errname) |
| 108 |
{ |
| 109 |
|
| 110 |
--replace_column 6 # 7 # 10 # 11 # |
| 111 |
SHOW INDEX IN t1; |
| 112 |
|
| 113 |
--let $alter_definition = DROP INDEX `PRIMARY` |
| 114 |
--source alter_table.inc |
| 115 |
if ($mysql_errname) |
| 116 |
{ |
| 117 |
--let $my_last_stmt = $alter_statement |
| 118 |
--let $functionality = ALTER TABLE |
| 119 |
--source unexpected_result.inc |
| 120 |
} |
| 121 |
if (!$mysql_errname) |
| 122 |
{ |
| 123 |
--let $alter_definition = ADD CONSTRAINT PRIMARY KEY pk (a) |
| 124 |
--source alter_table.inc |
| 125 |
--source mask_engine.inc |
| 126 |
--replace_column 6 # 7 # 10 # 11 # |
| 127 |
SHOW KEYS IN t1; |
| 128 |
--let $alter_definition = DROP PRIMARY KEY |
| 129 |
--source alter_table.inc |
| 130 |
} |
| 131 |
|
| 132 |
DROP TABLE t1; |
| 133 |
} |
| 134 |
|
| 135 |
--source cleanup_engine.inc |
| 136 |
|