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

Support for views #88

Merged
merged 2 commits into from
May 22, 2023
Merged

Support for views #88

merged 2 commits into from
May 22, 2023

Conversation

shayonj
Copy link
Owner

@shayonj shayonj commented May 21, 2023

pg-osc will now re-create any views after the table name swap. Because pg-osc uses shadow tables, after the name swap happens, views can continue to refer the old table name. This isn't ideal.

Instead, we now perform a CREATE OR REPLACE VIEW... after the swap is performed. We do it after swap to ensure any view creation doesn't keep the exclusive lock held for a longer duration.

Closes: #81

pg-osc will now re-create any views after the table name swap. Because pg-osc
uses shadow tables, after the name swap happens, views can continue to refer the old table name.
This isn't ideal.

Instead, we now perform a CREATE OR REPLACE VIEW... after the swap is perform. We do it after swap to ensure
any view creation doesn't keep the exclusive lock held for a longer duration
@@ -301,6 +301,21 @@ def storage_parameters_for(client, table, reuse_trasaction = false)
columns.first
end

def view_definitions_for(client, table)
query = <<~SQL
select *
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can probably do better than this query. We should be able to use pg_depend like this postgres wiki article details.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah nice! good call. Updated!

@shayonj
Copy link
Owner Author

shayonj commented May 22, 2023

Good for review now. Will release it today/tomorrow.

Copy link
Collaborator

@jfrost jfrost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@shayonj shayonj merged commit fa86af4 into main May 22, 2023
@shayonj shayonj deleted the s/support-views branch May 22, 2023 13:25
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

Successfully merging this pull request may close these issues.

Views aren't updated after the swap
2 participants