diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2019-06-27 11:57:10 -0400 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2019-06-27 11:57:10 -0400 |
commit | 050098b14e33a5d3dfabf172ebbddd20c6bb4665 (patch) | |
tree | e76e184ba4809f72804a09d0ace71c550f4986a3 | |
parent | f2f0082ef5969b57d0b52d0c2e891872ed1b0a51 (diff) | |
download | postgresql-050098b14e33a5d3dfabf172ebbddd20c6bb4665.tar.gz postgresql-050098b14e33a5d3dfabf172ebbddd20c6bb4665.zip |
Fix use-after-free introduced in 55ed3defc966
Evidenced by failure under RELCACHE_FORCE_RELEASE (buildfarm member
prion).
Author: Amit Langote
Discussion: https://postgr.es/m/CA+HiwqGV=k_Eh4jBiQw66ivvdG+EUkrEYeHTYL1SvDj_YOYV0g@mail.gmail.com
-rw-r--r-- | src/backend/commands/indexcmds.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index cdbb56f1a4a..579b9989548 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1059,13 +1059,11 @@ DefineIndex(Oid relationId, memcpy(part_oids, partdesc->oids, sizeof(Oid) * nparts); - parentDesc = CreateTupleDescCopy(RelationGetDescr(rel)); + parentDesc = RelationGetDescr(rel); opfamOids = palloc(sizeof(Oid) * numberOfKeyAttributes); for (i = 0; i < numberOfKeyAttributes; i++) opfamOids[i] = get_opclass_family(classObjectId[i]); - table_close(rel, NoLock); - /* * For each partition, scan all existing indexes; if one matches * our index definition and is not already attached to some other @@ -1265,13 +1263,12 @@ DefineIndex(Oid relationId, heap_freetuple(newtup); } } - else - table_close(rel, NoLock); /* * Indexes on partitioned tables are not themselves built, so we're * done here. */ + table_close(rel, NoLock); if (!OidIsValid(parentIndexId)) pgstat_progress_end_command(); return address; |