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/schemachanger: CREATE SEQUENCE support in declarative schema changer #104351

Closed
fqazi opened this issue Jun 5, 2023 · 0 comments · Fixed by #104350
Closed

sql/schemachanger: CREATE SEQUENCE support in declarative schema changer #104351

fqazi opened this issue Jun 5, 2023 · 0 comments · Fixed by #104350
Assignees
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@fqazi
Copy link
Collaborator

fqazi commented Jun 5, 2023

As a part of the work to support CREATE TABLE, as starting point, we can implement a more straightforward statement like CREATE SEQUENCE. A sequence is the same as a table but with only a single column and index, so it's a good precursor.

Releated to: CRDB-25187

Jira issue: CRDB-28485

Epic CRDB-31332

@fqazi fqazi added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Jun 5, 2023
@fqazi fqazi self-assigned this Jun 5, 2023
@blathers-crl blathers-crl bot added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label Jun 5, 2023
postamar pushed a commit to postamar/cockroach that referenced this issue Jun 8, 2023
Previously, the declarative schema changer had this arbitrary constraint
which enforced that each element could transition at most once
towards its target during the statement phase(s) in the statement
transaction.

This commit removes this and relies on the two-version-invariant rules
instead. To do so, this commit reintroduces the
PreviousTransactionPrecedence dependency edge kind and expresses those
rules using that instead of the PreviousStagePrecedence kind, which is
now deprecated.

Removing this limitation is necessary for the side-effects of CREATE
statements to be visible inside the statement transaction. This change
does not otherwise significantly alter the plans which are generated.

Informs cockroachdb#104351.
Informs cockroachdb#104123.

Release note: None
postamar pushed a commit to postamar/cockroach that referenced this issue Jun 8, 2023
Previously, the declarative schema changer had this arbitrary constraint
which enforced that each element could transition at most once
towards its target during the statement phase(s) in the statement
transaction.

This commit removes this and relies on the two-version-invariant rules
instead. To do so, this commit reintroduces the
PreviousTransactionPrecedence dependency edge kind and expresses those
rules using that instead of the PreviousStagePrecedence kind, which is
now deprecated.

Removing this limitation is necessary for the side-effects of CREATE
statements to be visible inside the statement transaction. This change
does not otherwise significantly alter the plans which are generated.

Informs cockroachdb#104351.
Informs cockroachdb#104123.

Release note: None
postamar pushed a commit to postamar/cockroach that referenced this issue Jun 8, 2023
Previously, the declarative schema changer had this arbitrary constraint
which enforced that each element could transition at most once
towards its target during the statement phase(s) in the statement
transaction.

This commit removes this and relies on the two-version-invariant rules
instead. To do so, this commit reintroduces the
PreviousTransactionPrecedence dependency edge kind and expresses those
rules using that instead of the PreviousStagePrecedence kind, which is
now deprecated.

Removing this limitation is necessary for the side-effects of CREATE
statements to be visible inside the statement transaction. This change
does not otherwise significantly alter the plans which are generated.

Informs cockroachdb#104351.
Informs cockroachdb#104123.

Release note: None
craig bot pushed a commit that referenced this issue Jun 8, 2023
104535: schemachanger: handle DROP following CREATE in-txn r=postamar a=postamar

This commit fixes a few bugs which prevented the following kind of schema change from performing correctly:

    BEGIN;
    CREATE SCHEMA sc;
    DROP SCHEMA sc;

Informs #104123.

Release note: None

----

  scplan: remove hard-coded 1-op-edge constraint on statement phase
  
  Previously, the declarative schema changer had this arbitrary constraint
  which enforced that each element could transition at most once
  towards its target during the statement phase(s) in the statement
  transaction.
  
  This commit removes this and relies on the two-version-invariant rules
  instead. To do so, this commit reintroduces the
  PreviousTransactionPrecedence dependency edge kind and expresses those
  rules using that instead of the PreviousStagePrecedence kind, which is
  now deprecated.
  
  Removing this limitation is necessary for the side-effects of CREATE
  statements to be visible inside the statement transaction. This change
  does not otherwise significantly alter the plans which are generated.
  
  Informs #104351.
  Informs #104123.
  
  Release note: None

----


  scplan: stop generating pre-commit main stage if redundant
  
  This commit does not change any functionality in any significant way, it
  only makes the EXPLAIN (DDL) output nicer in cases like:
  
      BEGIN;
      CREATE SCHEMA sc;
      EXPLAIN (DDL) DROP SCHEMA sc;
  
  This enables us to test that the following performs correctly:
  
      BEGIN;
      CREATE SCHEMA sc;
      DROP SCHEMA sc;
      CREATE SCHEMA sc;
      COMMIT;
  
  Fixes #104123.
  
  Release note: None

Co-authored-by: Marius Posta <[email protected]>
postamar pushed a commit to postamar/cockroach that referenced this issue Jun 15, 2023
Previously, the declarative schema changer had this arbitrary constraint
which enforced that each element could transition at most once
towards its target during the statement phase(s) in the statement
transaction.

This commit removes this and relies on the two-version-invariant rules
instead. To do so, this commit reintroduces the
PreviousTransactionPrecedence dependency edge kind and expresses those
rules using that instead of the PreviousStagePrecedence kind, which is
now deprecated.

Removing this limitation is necessary for the side-effects of CREATE
statements to be visible inside the statement transaction. This change
does not otherwise significantly alter the plans which are generated.

Informs cockroachdb#104351.
Informs cockroachdb#104123.

Release note: None
@craig craig bot closed this as completed in 2b66f95 Jun 29, 2023
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) T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant