diff options
author | Jorgen Loland <jorgen.loland@oracle.com> | 2011-02-21 16:49:03 +0100 |
---|---|---|
committer | Jorgen Loland <jorgen.loland@oracle.com> | 2011-02-21 16:49:03 +0100 |
commit | d1d166875ac2eec18d15611d0d82ba49b6def288 (patch) | |
tree | bd39ce93c66ae75c0edf2138f5bba3d254039996 /mysql-test/r/partition.result | |
parent | 08e4eba4289c2e6cca2d0de548bf7f2fb1881583 (diff) | |
download | mariadb-git-d1d166875ac2eec18d15611d0d82ba49b6def288.tar.gz |
BUG#11762751: UPDATE STATEMENT THROWS AN ERROR, BUT STILL
UPDATES THE TABLE ENTRIES (formerly 55385)
BUG#11764529: MULTI UPDATE+INNODB REPORTS ER_KEY_NOT_FOUND
IF A TABLE IS UPDATED TWICE (formerly 57373)
If multiple-table update updates a row through two aliases and
the first update physically moves the row, the second update will
fail to locate the row. This results in different errors
depending on storage engine:
* MyISAM: Got error 134 from storage engine
* InnoDB: Can't find record in 'tbl'
None of these errors accurately describe the problem.
Furthermore, since MyISAM is non-transactional, the update
executed first will be performed while the second will not.
In addition, for two equal multiple-table update statements,
one could succeed and the other fail based on whether or not
the record actually moved or not. This was inconsistent.
Two update operations may physically move a row:
1) Update of a column in a clustered primary key
2) Update of a column used to calculate which partition the
row belongs to
BUG#11764529 is about case 1) above, BUG#11762751 was about case 2).
The fix for these bugs is to return with an error if multiple-table
update is about to:
a) Update a table through multiple aliases, and
b) Perform an update that may physically more the row
in at least one of these aliases
This avoids
* partial updates as described for MyISAM above,
* provides the same error message that describes the actual problem
for all SEs
* inconsistent behavior where a statement fails or succeeds based on
e.g. the partitioning algorithm of the table.
mysql-test/r/multi_update.result:
Add test for bug#57373
mysql-test/r/multi_update_innodb.result:
Add test for bug#57373
mysql-test/r/partition.result:
Add test for bug#55385
mysql-test/t/multi_update.test:
Add test for bug#57373
mysql-test/t/multi_update_innodb.test:
Add test for bug#57373
mysql-test/t/partition.test:
Add test for bug#55385
sql/handler.cc:
Translate handler error HA_ERR_RECORD_DELETED to server error
sql/share/errmsg-utf8.txt:
New error message for multi-table update where the same table is updated multiple times.
sql/sql_update.cc:
Add function unsafe_key_update()
Diffstat (limited to 'mysql-test/r/partition.result')
-rw-r--r-- | mysql-test/r/partition.result | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 9c8b93d9fe2..1d7a08e9a7c 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -2264,3 +2264,51 @@ INSERT INTO t1 VALUES(0); DROP TABLE t1; SET GLOBAL myisam_use_mmap=default; End of 5.1 tests +# +# BUG#55385: UPDATE statement throws an error, but still updates +# the table entries +CREATE TABLE t1_part ( +partkey int, +nokey int +) PARTITION BY LINEAR HASH(partkey) PARTITIONS 3; +INSERT INTO t1_part VALUES (1, 1) , (10, 10); +CREATE VIEW v1 AS SELECT * FROM t1_part; + +# Should be (1,1),(10,10) +SELECT * FROM t1_part; +partkey nokey +1 1 +10 10 + +# Case 1 +# Update is refused because partitioning key is updated +UPDATE t1_part AS A NATURAL JOIN t1_part B SET A.partkey = 2, B.nokey = 3; +ERROR HY000: Primary key/partition key update is not allowed since the table is updated both as 'A' and 'B'. +UPDATE t1_part AS A NATURAL JOIN t1_part B SET A.nokey = 2, B.partkey = 3; +ERROR HY000: Primary key/partition key update is not allowed since the table is updated both as 'A' and 'B'. + +# Case 2 +# Like 1, but partition accessed through a view +UPDATE t1_part AS A NATURAL JOIN v1 as B SET A.nokey = 2 , B.partkey = 3; +ERROR HY000: Primary key/partition key update is not allowed since the table is updated both as 'A' and 'B'. +UPDATE v1 AS A NATURAL JOIN t1_part as B SET A.nokey = 2 , B.partkey = 3; +ERROR HY000: Primary key/partition key update is not allowed since the table is updated both as 'A' and 'B'. + +# Should be (1,1),(10,10) +SELECT * FROM t1_part; +partkey nokey +1 1 +10 10 + +# Case 3 +# Update is accepted because partitioning key is not updated +UPDATE t1_part AS A NATURAL JOIN t1_part B SET A.nokey = 2 , B.nokey = 3; + +# Should be (1,3),(10,3) +SELECT * FROM t1_part; +partkey nokey +1 3 +10 3 + +DROP VIEW v1; +DROP TABLE t1_part; |