aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/catalog/aclchk.c47
-rw-r--r--src/test/modules/test_pg_dump/README2
-rw-r--r--src/test/modules/test_pg_dump/expected/test_pg_dump.out3
-rw-r--r--src/test/modules/test_pg_dump/sql/test_pg_dump.sql3
4 files changed, 35 insertions, 20 deletions
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index a3f680d388a..06687c53a60 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -5580,19 +5580,22 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
elog(ERROR, "cache lookup failed for relation %u", objoid);
pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple);
- /* Indexes don't have permissions */
+ /*
+ * Indexes don't have permissions, neither do the pg_class rows for
+ * composite types. (These cases are unreachable given the
+ * restrictions in ALTER EXTENSION ADD, but let's check anyway.)
+ */
if (pg_class_tuple->relkind == RELKIND_INDEX ||
- pg_class_tuple->relkind == RELKIND_PARTITIONED_INDEX)
- return;
-
- /* Composite types don't have permissions either */
- if (pg_class_tuple->relkind == RELKIND_COMPOSITE_TYPE)
+ pg_class_tuple->relkind == RELKIND_PARTITIONED_INDEX ||
+ pg_class_tuple->relkind == RELKIND_COMPOSITE_TYPE)
+ {
+ ReleaseSysCache(tuple);
return;
+ }
/*
- * If this isn't a sequence, index, or composite type then it's
- * possibly going to have columns associated with it that might have
- * ACLs.
+ * If this isn't a sequence then it's possibly going to have
+ * column-level ACLs associated with it.
*/
if (pg_class_tuple->relkind != RELKIND_SEQUENCE)
{
@@ -5724,6 +5727,11 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
SysScanDesc scan;
Relation relation;
+ /*
+ * Note: this is dead code, given that we don't allow large objects to
+ * be made extension members. But it seems worth carrying in case
+ * some future caller of this function has need for it.
+ */
relation = table_open(LargeObjectMetadataRelationId, RowExclusiveLock);
/* There's no syscache for pg_largeobject_metadata */
@@ -5866,19 +5874,22 @@ removeExtObjInitPriv(Oid objoid, Oid classoid)
elog(ERROR, "cache lookup failed for relation %u", objoid);
pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple);
- /* Indexes don't have permissions */
+ /*
+ * Indexes don't have permissions, neither do the pg_class rows for
+ * composite types. (These cases are unreachable given the
+ * restrictions in ALTER EXTENSION DROP, but let's check anyway.)
+ */
if (pg_class_tuple->relkind == RELKIND_INDEX ||
- pg_class_tuple->relkind == RELKIND_PARTITIONED_INDEX)
- return;
-
- /* Composite types don't have permissions either */
- if (pg_class_tuple->relkind == RELKIND_COMPOSITE_TYPE)
+ pg_class_tuple->relkind == RELKIND_PARTITIONED_INDEX ||
+ pg_class_tuple->relkind == RELKIND_COMPOSITE_TYPE)
+ {
+ ReleaseSysCache(tuple);
return;
+ }
/*
- * If this isn't a sequence, index, or composite type then it's
- * possibly going to have columns associated with it that might have
- * ACLs.
+ * If this isn't a sequence then it's possibly going to have
+ * column-level ACLs associated with it.
*/
if (pg_class_tuple->relkind != RELKIND_SEQUENCE)
{
diff --git a/src/test/modules/test_pg_dump/README b/src/test/modules/test_pg_dump/README
index e6c78b822c3..b7c2e337ca7 100644
--- a/src/test/modules/test_pg_dump/README
+++ b/src/test/modules/test_pg_dump/README
@@ -1,2 +1,4 @@
test_pg_dump is an extension explicitly to test pg_dump when
extensions are present in the system.
+
+We also make use of this module to test ALTER EXTENSION ADD/DROP.
diff --git a/src/test/modules/test_pg_dump/expected/test_pg_dump.out b/src/test/modules/test_pg_dump/expected/test_pg_dump.out
index c9bc6f76258..a50eaf6125d 100644
--- a/src/test/modules/test_pg_dump/expected/test_pg_dump.out
+++ b/src/test/modules/test_pg_dump/expected/test_pg_dump.out
@@ -4,7 +4,8 @@ ALTER EXTENSION test_pg_dump ADD DATABASE postgres; -- error
ERROR: syntax error at or near "DATABASE"
LINE 1: ALTER EXTENSION test_pg_dump ADD DATABASE postgres;
^
-CREATE TABLE test_pg_dump_t1 (c1 int);
+CREATE TABLE test_pg_dump_t1 (c1 int, junk text);
+ALTER TABLE test_pg_dump_t1 DROP COLUMN junk; -- to exercise dropped-col cases
CREATE VIEW test_pg_dump_v1 AS SELECT * FROM test_pg_dump_t1;
CREATE MATERIALIZED VIEW test_pg_dump_mv1 AS SELECT * FROM test_pg_dump_t1;
CREATE SCHEMA test_pg_dump_s1;
diff --git a/src/test/modules/test_pg_dump/sql/test_pg_dump.sql b/src/test/modules/test_pg_dump/sql/test_pg_dump.sql
index e463dec4040..a61a7c8c4ce 100644
--- a/src/test/modules/test_pg_dump/sql/test_pg_dump.sql
+++ b/src/test/modules/test_pg_dump/sql/test_pg_dump.sql
@@ -3,7 +3,8 @@ CREATE EXTENSION test_pg_dump;
ALTER EXTENSION test_pg_dump ADD DATABASE postgres; -- error
-CREATE TABLE test_pg_dump_t1 (c1 int);
+CREATE TABLE test_pg_dump_t1 (c1 int, junk text);
+ALTER TABLE test_pg_dump_t1 DROP COLUMN junk; -- to exercise dropped-col cases
CREATE VIEW test_pg_dump_v1 AS SELECT * FROM test_pg_dump_t1;
CREATE MATERIALIZED VIEW test_pg_dump_mv1 AS SELECT * FROM test_pg_dump_t1;
CREATE SCHEMA test_pg_dump_s1;