Support `_rowid`
mysql> create table t(id int primary key);
Query OK, 0 rows affected (0.07 sec)
mysql> insert into t values(1),(3);
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
- What did you expect to see? Server version: 5.7.20
mysql> select _rowid from t;
+--------+
| _rowid |
+--------+
| 1 |
| 3 |
+--------+
2 rows in set (0.02 sec)
- What did you see instead?
mysql> select _rowid from t;
ERROR 1105 (HY000): unknown column _rowid
This will be fixed in the future.
I see https://github.com/pingcap/tidb/pull/5984 add the _tidb_rowid for tables without primary key or unique key, which makes it easier to debug and replicate by binlog.
Would it be possible to implement the _rowid mentioned in this thread by the same concept?
PTAL @coocood
@qazbnm456
This is not the same concept, _rowid is only used as an alias for integer primary key.
_tidb_rowid is only used when there is no integer primary key.
Confirming this feature is still missing in master:
create table t(id int primary key);
insert into t values(1),(3);
select _rowid from t;
mysql> create table t(id int primary key);
Query OK, 0 rows affected (0.01 sec)
mysql> insert into t values(1),(3);
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> select _rowid from t;
ERROR 1054 (42S22): Unknown column '_rowid' in 'field list'
mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v3.0.0-beta-265-gd033259d4
Git Commit Hash: d033259d455d3d7958c6f56a3f3a93f9a65121d9
Git Branch: master
UTC Build Time: 2019-03-22 03:12:39
GoVersion: go version go1.12.1 linux/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false
1 row in set (0.00 sec)
Still exists:
..
mysql> select _rowid from t;
ERROR 1054 (42S22): Unknown column '_rowid' in 'field list'
mysql> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0-beta.2-893-g4e829aaee
Edition: Community
Git Commit Hash: 4e829aaee7b656aa807814708ae05af5233302af
Git Branch: master
UTC Build Time: 2020-08-04 12:40:52
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)