Bug #88098 | _rowid does not work when the table contains both PRIMARY and UNIQUE keys | ||
---|---|---|---|
Submitted: | 15 Oct 2017 3:41 | Modified: | 28 Jul 2018 15:39 |
Reporter: | monty solomon | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Documentation | Severity: | S3 (Non-critical) |
Version: | OS: | Any | |
Assigned to: | CPU Architecture: | Any |
[15 Oct 2017 3:41]
monty solomon
[15 Oct 2017 15:12]
Peter Laursen
I think the docs should be understood in such a way that row_id refers to an integer PK (if exists), else an non-Nullable Integer Unique Index (if exists). If both exist it will refer to the PK value. And if there are no integer PK and more than one non-Nullable Integer Unique Index, the server decides on its own which Unique Index it will refer to (probably the one listed first in SHOW CREATE TABLE). -- Peter -- not a MySQL/Oracle person
[16 Nov 2017 15:35]
MySQL Verification Team
Hi! What Peter Laursen wrote is correct desciption. However, since different chapters in our manual seem to be out of sync, I can consider this as a documentation bug. Verified as a documentation bug.
[28 Jul 2018 15:39]
Paul DuBois
Posted by developer: Changed the explanation in [create-index] to: If a table has a PRIMARY KEY or UNIQUE NOT NULL index that consists of a single column that has an integer type, you can use _rowid to refer to the indexed column in SELECT statements, as follows: * _rowid refers to the PRIMARY KEY column if there is a PRIMARY KEY consisting of a single integer column. If there is a PRIMARY KEY but it does not consist of a single integer column, _rowid cannot be used. * Otherwise, _rowid refers to the column in the first UNIQUE NOT NULL index if that index consists of a single integer column. If the first UNIQUE NOT NULL index does not consist of a single integer column, _rowid cannot be used. Changed [create-table] to cross reference that explanation so that it's consistent.