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: error in schema change during begin with reference #15283

Closed
maddyblue opened this issue Apr 24, 2017 · 7 comments
Closed

sql: error in schema change during begin with reference #15283

maddyblue opened this issue Apr 24, 2017 · 7 comments
Assignees
Milestone

Comments

@maddyblue
Copy link
Contributor

root@:26257/d> create table t (id int primary key);
CREATE TABLE
root@:26257/d> begin;
Now adding input for a multi-line SQL transaction client-side.
Press Enter two times to send the SQL text collected so far to the server, or Ctrl+C to cancel.
            -> create table x (a int references t);
            -> 
CREATE TABLE
root@:26257  OPEN> commit;
ROLLBACK
root@:26257/d> create table x (a int references t);
CREATE TABLE
root@:26257/d> drop table x;
DROP TABLE
root@:26257/d> begin;
Now adding input for a multi-line SQL transaction client-side.
Press Enter two times to send the SQL text collected so far to the server, or Ctrl+C to cancel.
            -> create table x (a int);
            -> 
CREATE TABLE
root@:26257/d  OPEN> commit;
COMMIT

This demonstrates that adding a table in a begin will fail if it includes a foreign key reference. Is this known and intended? I spent an hour being really confused about what was going on.

@maddyblue maddyblue added this to the 1.0 milestone Apr 24, 2017
@maddyblue
Copy link
Contributor Author

Also happens when using INTERLEAVE, even when no REFERENCES is specified.

@vivekmenezes
Copy link
Contributor

I can reproduce this only through the cockroach CLI

@vivekmenezes
Copy link
Contributor

This is happening because after executing the schema change

create table x (a int references t);

the server is seeing a SHOW DATABASE command and hitting the
statement cannot follow a schema change in a transaction error

This is specific to the CLI

@knz
Copy link
Contributor

knz commented Apr 24, 2017

Ok, I'll take that.

@maddyblue
Copy link
Contributor Author

It's probably safe to bump this to 1.1 also, since it's not a bug, just a surprising behavior.

@knz
Copy link
Contributor

knz commented May 5, 2017

The PR that closed this has been reverted in #15511, so reopening.

@knz knz reopened this May 5, 2017
@knz knz modified the milestones: 1.1, 1.0 May 5, 2017
@vivekmenezes
Copy link
Contributor

the issue as described is no longer an issue. I just tried to reproduce it.

There is another issue: #13505 related to not being able to use a table created with an fk in the same transaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants