Commit 99f2f3c1 authored by Stephen Frost's avatar Stephen Frost

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.
parent d2de44c2
...@@ -5283,8 +5283,6 @@ recordExtensionInitPriv(Oid objoid, Oid classoid, int objsubid, Acl *new_acl) ...@@ -5283,8 +5283,6 @@ recordExtensionInitPriv(Oid objoid, Oid classoid, int objsubid, Acl *new_acl)
/* There should exist only one entry or none. */ /* There should exist only one entry or none. */
oldtuple = systable_getnext(scan); oldtuple = systable_getnext(scan);
systable_endscan(scan);
/* If we find an entry, update it with the latest ACL. */ /* If we find an entry, update it with the latest ACL. */
if (HeapTupleIsValid(oldtuple)) if (HeapTupleIsValid(oldtuple))
{ {
...@@ -5340,6 +5338,8 @@ recordExtensionInitPriv(Oid objoid, Oid classoid, int objsubid, Acl *new_acl) ...@@ -5340,6 +5338,8 @@ recordExtensionInitPriv(Oid objoid, Oid classoid, int objsubid, Acl *new_acl)
CatalogUpdateIndexes(relation, tuple); CatalogUpdateIndexes(relation, tuple);
} }
systable_endscan(scan);
/* prevent error when processing objects multiple times */ /* prevent error when processing objects multiple times */
CommandCounterIncrement(); CommandCounterIncrement();
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
MODULE = test_extensions MODULE = test_extensions
PGFILEDESC = "test_extensions - regression testing for EXTENSION support" 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 test_ext_cyclic1 test_ext_cyclic2
DATA = test_ext1--1.0.sql test_ext2--1.0.sql test_ext3--1.0.sql \ 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_ext4--1.0.sql test_ext5--1.0.sql test_ext6--1.0.sql \
test_ext_cyclic2--1.0.sql test_ext_cyclic1--1.0.sql test_ext_cyclic2--1.0.sql
REGRESS = test_extensions test_extdepend REGRESS = test_extensions test_extdepend
......
...@@ -35,3 +35,6 @@ drop cascades to extension test_ext5 ...@@ -35,3 +35,6 @@ drop cascades to extension test_ext5
drop cascades to extension test_ext2 drop cascades to extension test_ext2
drop cascades to extension test_ext4 drop cascades to extension test_ext4
drop cascades to extension test_ext1 drop cascades to extension test_ext1
CREATE EXTENSION test_ext6;
DROP EXTENSION test_ext6;
CREATE EXTENSION test_ext6;
...@@ -13,3 +13,7 @@ SELECT extname, nspname, extversion, extrelocatable FROM pg_extension e, pg_name ...@@ -13,3 +13,7 @@ SELECT extname, nspname, extversion, extrelocatable FROM pg_extension e, pg_name
CREATE EXTENSION test_ext_cyclic1 CASCADE; CREATE EXTENSION test_ext_cyclic1 CASCADE;
DROP SCHEMA test_ext CASCADE; DROP SCHEMA test_ext CASCADE;
CREATE EXTENSION test_ext6;
DROP EXTENSION test_ext6;
CREATE EXTENSION test_ext6;
grant usage on schema @extschema@ to public;
comment = 'test_ext6'
default_version = '1.0'
relocatable = false
superuser = true
schema = 'test_ext6'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment