Skip to content

Commit

Permalink
Some followups to MATERIALIZED pg_catalog views (#8149)
Browse files Browse the repository at this point in the history
Add another comment and some code to support patching the changes in
that got lost in another working directory.

Follow-up to #8145.
  • Loading branch information
msullivan authored Dec 19, 2024
1 parent 50965cd commit c012623
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions edb/pgsql/metaschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -6294,6 +6294,10 @@ def _generate_sql_information_schema(
backend_version: params.BackendVersion
) -> List[dbops.Command]:

# Helper to create wrappers around materialized views. For
# performance, we use MATERIALIZED VIEW for some of our SQL
# emulation tables. Unfortunately we can't use those directly,
# since we need tableoid to match the real pg_catalog table.
def make_wrapper_view(name: str) -> trampoline.VersionedView:
return trampoline.VersionedView(
name=("edgedbsql", name),
Expand Down
13 changes: 11 additions & 2 deletions edb/server/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,10 +750,19 @@ def _generate_drop_views(
for cv in reversed(list(group)):
dv: Any
if isinstance(cv, dbops.CreateView):
dv = dbops.DropView(
# We try deleting both a MATERIALIZED and not materialized
# version, since that allows us to switch between them
# more easily.
dv = dbops.CommandGroup()
dv.add_command(dbops.DropView(
cv.view.name,
conditions=[dbops.ViewExists(cv.view.name)],
)
))
dv.add_command(dbops.DropView(
cv.view.name,
conditions=[dbops.ViewExists(cv.view.name, materialized=True)],
materialized=True,
))
elif isinstance(cv, dbops.CreateFunction):
dv = dbops.DropFunction(
cv.function.name,
Expand Down

0 comments on commit c012623

Please sign in to comment.