Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 99f2f3c

Browse files
committed
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.
1 parent d2de44c commit 99f2f3c

File tree

6 files changed

+18
-5
lines changed

6 files changed

+18
-5
lines changed

src/backend/catalog/aclchk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5283,8 +5283,6 @@ recordExtensionInitPriv(Oid objoid, Oid classoid, int objsubid, Acl *new_acl)
52835283
/* There should exist only one entry or none. */
52845284
oldtuple = systable_getnext(scan);
52855285

5286-
systable_endscan(scan);
5287-
52885286
/* If we find an entry, update it with the latest ACL. */
52895287
if (HeapTupleIsValid(oldtuple))
52905288
{
@@ -5340,6 +5338,8 @@ recordExtensionInitPriv(Oid objoid, Oid classoid, int objsubid, Acl *new_acl)
53405338
CatalogUpdateIndexes(relation, tuple);
53415339
}
53425340

5341+
systable_endscan(scan);
5342+
53435343
/* prevent error when processing objects multiple times */
53445344
CommandCounterIncrement();
53455345

src/test/modules/test_extensions/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
MODULE = test_extensions
44
PGFILEDESC = "test_extensions - regression testing for EXTENSION support"
55

6-
EXTENSION = test_ext1 test_ext2 test_ext3 test_ext4 test_ext5 \
6+
EXTENSION = test_ext1 test_ext2 test_ext3 test_ext4 test_ext5 test_ext6 \
77
test_ext_cyclic1 test_ext_cyclic2
88
DATA = test_ext1--1.0.sql test_ext2--1.0.sql test_ext3--1.0.sql \
9-
test_ext4--1.0.sql test_ext5--1.0.sql test_ext_cyclic1--1.0.sql \
10-
test_ext_cyclic2--1.0.sql
9+
test_ext4--1.0.sql test_ext5--1.0.sql test_ext6--1.0.sql \
10+
test_ext_cyclic1--1.0.sql test_ext_cyclic2--1.0.sql
1111

1212
REGRESS = test_extensions test_extdepend
1313

src/test/modules/test_extensions/expected/test_extensions.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ drop cascades to extension test_ext5
3535
drop cascades to extension test_ext2
3636
drop cascades to extension test_ext4
3737
drop cascades to extension test_ext1
38+
CREATE EXTENSION test_ext6;
39+
DROP EXTENSION test_ext6;
40+
CREATE EXTENSION test_ext6;

src/test/modules/test_extensions/sql/test_extensions.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ SELECT extname, nspname, extversion, extrelocatable FROM pg_extension e, pg_name
1313
CREATE EXTENSION test_ext_cyclic1 CASCADE;
1414

1515
DROP SCHEMA test_ext CASCADE;
16+
17+
CREATE EXTENSION test_ext6;
18+
DROP EXTENSION test_ext6;
19+
CREATE EXTENSION test_ext6;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
grant usage on schema @extschema@ to public;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
comment = 'test_ext6'
2+
default_version = '1.0'
3+
relocatable = false
4+
superuser = true
5+
schema = 'test_ext6'

0 commit comments

Comments
 (0)