Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: DDL after write error is misleading #57476

Closed
jayshrivastava opened this issue Dec 3, 2020 · 3 comments
Closed

sql: DDL after write error is misleading #57476

jayshrivastava opened this issue Dec 3, 2020 · 3 comments
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)

Comments

@jayshrivastava
Copy link
Contributor

jayshrivastava commented Dec 3, 2020

The following error is misleading:

root@localhost:26257/defaultdb> create table foo (i int, j int);
CREATE TABLE

root@localhost:26257/defaultdb> begin;
BEGIN

root@localhost:26257/defaultdb  OPEN> insert into foo values (1,2);
INSERT 1

root@localhost:26257/defaultdb  OPEN>  create table t();
ERROR: unimplemented: schema change statement cannot follow a statement that has written in the same transaction
SQLSTATE: 0A000
HINT: You have attempted to use a feature that is not yet implemented.
See: https://go.crdb.dev/issue-v/26508/v21.1

Although it says "schema change statement cannot follow a statement that has written in the same transaction", one can successfully preform a schema change after a write in a txn:

root@localhost:26257/defaultdb  OPEN> create table foo (i int, j int);
CREATE TABLE

root@localhost:26257/defaultdb  OPEN> create table bar (j int);
CREATE TABLE

root@localhost:26257/defaultdb> begin;
BEGIN

root@localhost:26257/defaultdb  OPEN> alter table bar drop column j;
ALTER TABLE

root@localhost:26257/defaultdb  OPEN> insert into foo values (1,2);
INSERT 1

root@localhost:26257/defaultdb  OPEN> create table t();
CREATE TABLE

root@localhost:26257/defaultdb  OPEN> commit;
COMMIT

The error message should be updated to say that we do not support DDLs if the first write in a txn precedes the first DDL. h in the txn

This issue relates to #54477.

@jayshrivastava jayshrivastava added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Dec 3, 2020
@jayshrivastava jayshrivastava added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) and removed C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. labels Dec 21, 2020
@jordanlewis
Copy link
Member

@jayshrivastava we think this should be a 1-line change, right? Do you want to knock it out? :)

@jayshrivastava
Copy link
Contributor Author

@jordanlewis Sure

@thoszhang thoszhang changed the title sql: DDL after write does not throw pgcode.FeatureNotSupported sql: DDL after write error is misleading Dec 22, 2020
@thoszhang
Copy link
Contributor

#58182

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
Projects
None yet
Development

No branches or pull requests

3 participants