| 1 |
# |
| 2 |
# Basic REPLACE statements |
| 3 |
# |
| 4 |
--source have_engine.inc |
| 5 |
|
| 6 |
--disable_warnings |
| 7 |
DROP TABLE IF EXISTS t1; |
| 8 |
--enable_warnings |
| 9 |
|
| 10 |
--source create_table.inc |
| 11 |
|
| 12 |
# When there is no duplicate key, REPLACE should work as INSERT |
| 13 |
|
| 14 |
REPLACE INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'); |
| 15 |
--sorted_result |
| 16 |
SELECT a,b FROM t1; |
| 17 |
|
| 18 |
REPLACE t1 (a,b) VALUE (10,'foo'),(10,'foo'); |
| 19 |
--sorted_result |
| 20 |
SELECT a,b FROM t1; |
| 21 |
|
| 22 |
DROP TABLE t1; |
| 23 |
|
| 24 |
--let $create_definition = a $int_indexed_col, b $char_col, UNIQUE INDEX (a) |
| 25 |
--source create_table.inc |
| 26 |
if ($mysql_errname) |
| 27 |
{ |
| 28 |
--let $my_last_stmt = $create_statement |
| 29 |
--let $functionality = Unique keys |
| 30 |
--source unexpected_result.inc |
| 31 |
} |
| 32 |
if (!$mysql_errname) |
| 33 |
{ |
| 34 |
REPLACE INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'); |
| 35 |
--let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY |
| 36 |
INSERT INTO t1 (a,b) VALUES (2,'d'); |
| 37 |
--source check_errors.inc |
| 38 |
REPLACE INTO t1 (a,b) VALUES (2,'d'); |
| 39 |
--sorted_result |
| 40 |
SELECT a,b FROM t1; |
| 41 |
|
| 42 |
DROP TABLE t1; |
| 43 |
} |
| 44 |
|
| 45 |
--let $create_definition = a $int_col, b $char_indexed_col, PRIMARY KEY (b) |
| 46 |
--source create_table.inc |
| 47 |
if ($mysql_errname) |
| 48 |
{ |
| 49 |
--let $my_last_stmt = $create_statement |
| 50 |
--let $functionality = Primary keys |
| 51 |
--source unexpected_result.inc |
| 52 |
} |
| 53 |
if (!$mysql_errname) |
| 54 |
{ |
| 55 |
REPLACE INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'); |
| 56 |
--let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY |
| 57 |
INSERT INTO t1 (a,b) VALUES (4,'b'); |
| 58 |
--source check_errors.inc |
| 59 |
REPLACE INTO t1 (a,b) VALUES (4,'b'); |
| 60 |
--sorted_result |
| 61 |
SELECT a,b FROM t1; |
| 62 |
|
| 63 |
DROP TABLE t1; |
| 64 |
} |
| 65 |
|
| 66 |
--source cleanup_engine.inc |
| 67 |
|