-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: index creation fails if issued just after create table in same txn #13505
Comments
cc @dt @vivekmenezes |
extra comment from gitter:
|
I'm guessing this is because we need to use the intermediate non-public state when creating tables that have dependencies on other tables, and then make them public only after we |
I've read the documentation for foreign keys in more detail and experimented with the creation of the schema in a single transaction and without. The single transaction (if I don't add the index called
The non-transactional schema when applied creates:
Both |
Ah, yep, the separate FWIW, if the index were included in the
|
after #14368 we disallow statements that follow a certain type of schema change in the same transaction. This restriction applies to schema changes that are rolled out in many transactions. CREATE TABLE on its own without the use of FKs can be followed by another statement in the same transaction because it is a schema change that can be fully executed within the same transaction. |
A new table descriptor is placed in the non-public TableDescriptor_ADD state when it refers to another table through an FK or interleaved reference, and can only be made public once the other tables back reference is visible across the cluster. This change allows schema change operations on such non-public tables, while preserving the non-public behavior for table leases. fixes cockroachdb#13505
The latest Nakama server schema fails to be created when run as a single transaction.
To reproduce:
CREATE DATABASE nakama;
BEGIN;
andCOMMIT;
around the SQL file and execute:The schema creation will fail with:
If this line from the schema is removed:
CREATE INDEX IF NOT EXISTS user_id_idx ON user_device (user_id);
The schema creation will complete successfully. This may be an issue with the schema but it works without modification when run with
notransaction
.This is tested against cockroachdb configuration:
The text was updated successfully, but these errors were encountered: