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

Restore object_access hook after dropping extension #2116

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions regress/expected/drop.out
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ NOTICE: label "issue_1305"."r" has been dropped
(1 row)

SELECT drop_label('issue_1305', 'r');
ERROR: rel_name not found for label "r"
ERROR: label "r" does not exist
SELECT drop_label('issue_1305', 'n', false);
NOTICE: label "issue_1305"."n" has been dropped
drop_label
Expand All @@ -124,7 +124,20 @@ NOTICE: label "issue_1305"."n" has been dropped
(1 row)

SELECT drop_label('issue_1305', 'n');
ERROR: rel_name not found for label "n"
ERROR: label "n" does not exist
-- Validate that not only tables are dropped, but labels are also removed via object_access hook.
SELECT COUNT(*) FROM ag_label WHERE name IN ('n', 'r');
count
-------
0
(1 row)

SELECT COUNT(*) FROM pg_catalog.pg_tables WHERE schemaname = 'issue_1305' AND tablename IN ('n', 'r');
count
-------
0
(1 row)

SELECT * FROM drop_graph('issue_1305', true);
NOTICE: drop cascades to 2 other objects
DETAIL: drop cascades to table issue_1305._ag_label_vertex
Expand Down
5 changes: 5 additions & 0 deletions regress/sql/drop.sql
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ SELECT drop_label('issue_1305', 'r', false);
SELECT drop_label('issue_1305', 'r');
SELECT drop_label('issue_1305', 'n', false);
SELECT drop_label('issue_1305', 'n');

-- Validate that not only tables are dropped, but labels are also removed via object_access hook.
SELECT COUNT(*) FROM ag_label WHERE name IN ('n', 'r');
SELECT COUNT(*) FROM pg_catalog.pg_tables WHERE schemaname = 'issue_1305' AND tablename IN ('n', 'r');

SELECT * FROM drop_graph('issue_1305', true);

-- END
Expand Down
3 changes: 3 additions & 0 deletions src/backend/catalog/ag_catalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ static void drop_age_extension(DropStmt *stmt)
/* reset global variables for OIDs */
clear_global_Oids_AGTYPE();
clear_global_Oids_GRAPHID();

/* Restore the object access hook */
object_access_hook_init();
}

/* Check to see if the Utility Command is to drop the AGE Extension. */
Expand Down
Loading