Cockroach: sql: row-level locking modes should be disallowed in READ-ONLY txns

Created on 22 Jun 2020  路  3Comments  路  Source: cockroachdb/cockroach

In PostgreSQL:

nathan=# create table t (i int primary key);
CREATE TABLE

nathan=# begin read only;
BEGIN

nathan=# select * from t for update;
ERROR:  cannot execute SELECT FOR UPDATE in a read-only transaction

nathan=# rollback;
ROLLBACK

nathan=# begin read only;
BEGIN

nathan=# select * from t for share;
ERROR:  cannot execute SELECT FOR SHARE in a read-only transaction

In CockroachDB:

[email protected]:59592/postgres> create table t (i int primary key);
CREATE TABLE

[email protected]:59592/postgres> begin read only;
BEGIN

[email protected]:59592/postgres  OPEN> select * from t for update;
  i
-----
(0 rows)

[email protected]:59592/postgres  OPEN> select * from t for share;
  i
-----
(0 rows)
A-sql-optimizer A-sql-pgcompat C-bug E-easy help wanted

All 3 comments

@nvanbenschoten I would like to work on this issue if no one is looking at it. Thanks!

Hi @manhhiep92, no one is currently looking at this, so it's all yours!

To point you in the right direction, I suspect that this check will take place somewhere in pkg/sql/opt/... tree of packages.

Thanks for the contribution @hiepd!

Was this page helpful?
0 / 5 - 0 ratings