| 1 |
# |
| 2 |
# TRUNCATE TABLE |
| 3 |
# |
| 4 |
|
| 5 |
--source have_engine.inc |
| 6 |
|
| 7 |
--disable_warnings |
| 8 |
DROP TABLE IF EXISTS t1; |
| 9 |
--enable_warnings |
| 10 |
|
| 11 |
--source create_table.inc |
| 12 |
TRUNCATE TABLE t1; |
| 13 |
if ($mysql_errname) |
| 14 |
{ |
| 15 |
--let $functionality = TRUNCATE TABLE |
| 16 |
--source unexpected_result.inc |
| 17 |
} |
| 18 |
if (!$mysql_errname) |
| 19 |
{ |
| 20 |
INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c'); |
| 21 |
TRUNCATE TABLE t1; |
| 22 |
SELECT a,b FROM t1; |
| 23 |
} |
| 24 |
DROP TABLE t1; |
| 25 |
|
| 26 |
|
| 27 |
# Truncate resets auto-increment value on the table |
| 28 |
|
| 29 |
--let $create_definition = a $int_indexed_col KEY AUTO_INCREMENT, c $char_col |
| 30 |
--source create_table.inc |
| 31 |
if ($mysql_errname) |
| 32 |
{ |
| 33 |
--let $my_last_stmt = $create_statement |
| 34 |
--let $functionality = PK or AUTO_INCREMENT |
| 35 |
--source unexpected_result.inc |
| 36 |
} |
| 37 |
if (!$mysql_errname) |
| 38 |
{ |
| 39 |
--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 # 19 # |
| 40 |
SHOW TABLE STATUS LIKE 't1'; |
| 41 |
|
| 42 |
INSERT INTO t1 (c) VALUES ('a'),('b'),('c'); |
| 43 |
--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 # 19 # |
| 44 |
SHOW TABLE STATUS LIKE 't1'; |
| 45 |
|
| 46 |
TRUNCATE TABLE t1; |
| 47 |
--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 # 19 # |
| 48 |
SHOW TABLE STATUS LIKE 't1'; |
| 49 |
|
| 50 |
INSERT INTO t1 (c) VALUES ('d'); |
| 51 |
--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 # 19 # |
| 52 |
SHOW TABLE STATUS LIKE 't1'; |
| 53 |
|
| 54 |
SELECT a,c FROM t1; |
| 55 |
DROP TABLE t1; |
| 56 |
} |
| 57 |
|
| 58 |
# Truncate closes handlers |
| 59 |
|
| 60 |
--source create_table.inc |
| 61 |
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'); |
| 62 |
HANDLER t1 OPEN AS h1; |
| 63 |
if ($mysql_errname) |
| 64 |
{ |
| 65 |
--let $functionality = HANDLER |
| 66 |
--source unexpected_result.inc |
| 67 |
} |
| 68 |
if (!$mysql_errname) |
| 69 |
{ |
| 70 |
HANDLER h1 READ FIRST; |
| 71 |
TRUNCATE TABLE t1; |
| 72 |
--let $error_codes = ER_UNKNOWN_TABLE |
| 73 |
HANDLER h1 READ NEXT; |
| 74 |
--source check_errors.inc |
| 75 |
HANDLER t1 OPEN AS h2; |
| 76 |
HANDLER h2 READ FIRST; |
| 77 |
} |
| 78 |
DROP TABLE t1; |
| 79 |
|
| 80 |
--source cleanup_engine.inc |
| 81 |
|