summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Frost2016-04-16 01:57:15 +0000
committerStephen Frost2016-04-16 01:57:15 +0000
commit99f2f3c19ae7d6aa2950a9bdb549217c5a60d941 (patch)
tree703eb73dea293b1cc79888cb9ebabafaaee9b17d
parentd2de44c2ce5c697a2de8089fb377816b2387107a (diff)
In recordExtensionInitPriv(), keep the scan til we're done with it
For reasons of sheer brain fade, we (I) was calling systable_endscan() immediately after systable_getnext() and expecting the tuple returned by systable_getnext() to still be valid. That's clearly wrong. Move the systable_endscan() down below the tuple usage. Discovered initially by Pavel Stehule and then also by Alvaro. Add a regression test based on Alvaro's testing.
-rw-r--r--src/backend/catalog/aclchk.c4
-rw-r--r--src/test/modules/test_extensions/Makefile6
-rw-r--r--src/test/modules/test_extensions/expected/test_extensions.out3
-rw-r--r--src/test/modules/test_extensions/sql/test_extensions.sql4
-rw-r--r--src/test/modules/test_extensions/test_ext6--1.0.sql1
-rw-r--r--src/test/modules/test_extensions/test_ext6.control5
6 files changed, 18 insertions, 5 deletions
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index 4b49bb67ba..7d656d5c6d 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -5283,8 +5283,6 @@ recordExtensionInitPriv(Oid objoid, Oid classoid, int objsubid, Acl *new_acl)
/* There should exist only one entry or none. */
oldtuple = systable_getnext(scan);
- systable_endscan(scan);
-
/* If we find an entry, update it with the latest ACL. */
if (HeapTupleIsValid(oldtuple))
{
@@ -5340,6 +5338,8 @@ recordExtensionInitPriv(Oid objoid, Oid classoid, int objsubid, Acl *new_acl)
CatalogUpdateIndexes(relation, tuple);
}
+ systable_endscan(scan);
+
/* prevent error when processing objects multiple times */
CommandCounterIncrement();
diff --git a/src/test/modules/test_extensions/Makefile b/src/test/modules/test_extensions/Makefile
index 283233782a..8f0eeb7d3c 100644
--- a/src/test/modules/test_extensions/Makefile
+++ b/src/test/modules/test_extensions/Makefile
@@ -3,11 +3,11 @@
MODULE = test_extensions
PGFILEDESC = "test_extensions - regression testing for EXTENSION support"
-EXTENSION = test_ext1 test_ext2 test_ext3 test_ext4 test_ext5 \
+EXTENSION = test_ext1 test_ext2 test_ext3 test_ext4 test_ext5 test_ext6 \
test_ext_cyclic1 test_ext_cyclic2
DATA = test_ext1--1.0.sql test_ext2--1.0.sql test_ext3--1.0.sql \
- test_ext4--1.0.sql test_ext5--1.0.sql test_ext_cyclic1--1.0.sql \
- test_ext_cyclic2--1.0.sql
+ test_ext4--1.0.sql test_ext5--1.0.sql test_ext6--1.0.sql \
+ test_ext_cyclic1--1.0.sql test_ext_cyclic2--1.0.sql
REGRESS = test_extensions test_extdepend
diff --git a/src/test/modules/test_extensions/expected/test_extensions.out b/src/test/modules/test_extensions/expected/test_extensions.out
index a57bb4b7ff..105f53fb74 100644
--- a/src/test/modules/test_extensions/expected/test_extensions.out
+++ b/src/test/modules/test_extensions/expected/test_extensions.out
@@ -35,3 +35,6 @@ drop cascades to extension test_ext5
drop cascades to extension test_ext2
drop cascades to extension test_ext4
drop cascades to extension test_ext1
+CREATE EXTENSION test_ext6;
+DROP EXTENSION test_ext6;
+CREATE EXTENSION test_ext6;
diff --git a/src/test/modules/test_extensions/sql/test_extensions.sql b/src/test/modules/test_extensions/sql/test_extensions.sql
index 9076c02807..2ab8b599dc 100644
--- a/src/test/modules/test_extensions/sql/test_extensions.sql
+++ b/src/test/modules/test_extensions/sql/test_extensions.sql
@@ -13,3 +13,7 @@ SELECT extname, nspname, extversion, extrelocatable FROM pg_extension e, pg_name
CREATE EXTENSION test_ext_cyclic1 CASCADE;
DROP SCHEMA test_ext CASCADE;
+
+CREATE EXTENSION test_ext6;
+DROP EXTENSION test_ext6;
+CREATE EXTENSION test_ext6;
diff --git a/src/test/modules/test_extensions/test_ext6--1.0.sql b/src/test/modules/test_extensions/test_ext6--1.0.sql
new file mode 100644
index 0000000000..65a4fc5f10
--- /dev/null
+++ b/src/test/modules/test_extensions/test_ext6--1.0.sql
@@ -0,0 +1 @@
+grant usage on schema @extschema@ to public;
diff --git a/src/test/modules/test_extensions/test_ext6.control b/src/test/modules/test_extensions/test_ext6.control
new file mode 100644
index 0000000000..04b2146685
--- /dev/null
+++ b/src/test/modules/test_extensions/test_ext6.control
@@ -0,0 +1,5 @@
+comment = 'test_ext6'
+default_version = '1.0'
+relocatable = false
+superuser = true
+schema = 'test_ext6'