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

Partition commands not supported by parser #279

Closed
qoelet opened this issue Feb 1, 2023 · 0 comments · Fixed by #280
Closed

Partition commands not supported by parser #279

qoelet opened this issue Feb 1, 2023 · 0 comments · Fixed by #280
Labels

Comments

@qoelet
Copy link
Contributor

qoelet commented Feb 1, 2023

When a migration includes partition maintenance commands, such as

ALTER TABLE measurement ATTACH PARTITION measurement_y2008m02
    FOR VALUES FROM ('2008-02-01') TO ('2008-03-01' );
ALTER TABLE measurement DETACH PARTITION measurement_y2006m02;

running Squawk results in the following error

note: Squawk schema failed to parse Postgres response. This indicates a bug with Squawk. Please report this error to https://github.com/sbdchd/squawk. Schema error: unknown variant `PartitionCmd`, expected one of `TypeCast`, `FuncCall`, `Constraint`, `ColumnDef`, `A_Const`, `ReplicaIdentityStmt`, `SQLValueFunction` at line 1 column 252
  help: Modify your Postgres statement to use valid syntax.

Besides fixing this, I suppose we would ideally want new rules for Squawk that would warn users about ACCESS EXCLUSIVE locks on the parent table and suggest

  1. Use DETACH PARTITION ... CONCURRENTLY
  2. Add a CHECK constraint before ATTACH PARTITION commands

Both of the above would drop the lock requirement to SHARE UPDATE EXCLUSIVE, which is an improvement. Thoughts?

@sbdchd sbdchd added the bug label Feb 1, 2023
@kodiakhq kodiakhq bot closed this as completed in #280 Feb 1, 2023
kodiakhq bot pushed a commit that referenced this issue Feb 1, 2023
Adds minimal support for partition commands, partially resolves #279
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants