sql: make table PUBLIC when references created in transaction#25786
Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom May 22, 2018
Merged
sql: make table PUBLIC when references created in transaction#25786craig[bot] merged 1 commit intocockroachdb:masterfrom
craig[bot] merged 1 commit intocockroachdb:masterfrom
Conversation
Member
madelynnblue
approved these changes
May 22, 2018
6496547 to
50d49d8
Compare
Contributor
Author
|
bors r+ |
Contributor
Build failed |
Contributor
Author
|
bors r- |
Normally a table with references (FK, interleaved) is placed in the ADD state to allow the referenced tables to be upgraded with backreferences across the cluster, before the cluster sees the ADD table in the PUBLIC state. When all the table references are created in the same transaction the table can be made PUBLIC immediately because all the references are still not visible to the cluster. This is particularly valuable when commands within a transaction need to use the PUBLIC table and will normally barf on seeing a table in the ADD state. This also fixes a problem with column backfill in the presence of FKs. fixes cockroachdb#24626 Release note (sql fix): Fix problems with using tables created in the same transaction when the tables have FOREIGN KEY or INTERLEAVED references to other tables which have also been created in the same transaction.
Contributor
Author
|
bors r+ |
craig bot
pushed a commit
that referenced
this pull request
May 22, 2018
25786: sql: make table PUBLIC when references created in transaction r=vivekmenezes a=vivekmenezes Normally a table with references (FK, interleaved) is placed in the ADD state to allow the referenced tables to be upgraded with backreferences across the cluster, before the cluster sees the ADD table in the PUBLIC state. When all the table references are created in the same transaction the table can be made PUBLIC immediately because all the references are still not visible to the cluster. This is particularly valuable when commands within a transaction need to use the PUBLIC table and will normally barf on seeing a table in the ADD state. This also fixes a problem with column backfill in the presence of FKs. fixes #24626 Release note (sql fix): Fix problems with using tables created in the same transaction when the tables have FOREIGN KEY or INTERLEAVED references to other tables which have also been created in the same transaction. Co-authored-by: Vivek Menezes <vivek@cockroachlabs.com>
Contributor
Build succeeded |
knz
reviewed
May 22, 2018
| evalCtx *tree.EvalContext, | ||
| tableDesc *sqlbase.TableDescriptor, | ||
| ) error { | ||
| // A column backfill in the ADD state is a noop. |
Contributor
There was a problem hiding this comment.
Are you sure?
What about:
BEGIN;
CREATE TABLE blah ...;
INSERT INTO blah VALUES ...;
CREATE INDEX blih ON blah (...); -- this needs a backfill!
COMMIT;
Contributor
Author
There was a problem hiding this comment.
If TABLE blah is in the ADD state, the INSERT will fail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Normally a table with references (FK, interleaved) is
placed in the ADD state to allow the referenced tables
to be upgraded with backreferences across the cluster,
before the cluster sees the ADD table in the PUBLIC state.
When all the table references are created in the same
transaction the table can be made PUBLIC immediately
because all the references are still not visible to
the cluster. This is particularly valuable when commands
within a transaction need to use the PUBLIC table and
will normally barf on seeing a table in the ADD state.
This also fixes a problem with column backfill in the
presence of FKs.
fixes #24626
Release note (sql fix): Fix problems with using tables
created in the same transaction when the tables have FOREIGN
KEY or INTERLEAVED references to other tables which have also
been created in the same transaction.