]> granicus.if.org Git - postgresql/commit
Fix unsafe order of operations in foreign-table DDL commands.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 14 Aug 2011 19:40:41 +0000 (15:40 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 14 Aug 2011 19:40:41 +0000 (15:40 -0400)
commit3c96f5c647852d1c77f9854cf1f78dfb01af8631
treee8574136d2dc0289a6c6b99eb80d3eda61ba0e44
parentceaf5052c6a7bee794211f5d4c503639bdf3dff0
Fix unsafe order of operations in foreign-table DDL commands.

When updating or deleting a system catalog tuple, it's necessary to acquire
RowExclusiveLock on the catalog before looking up the tuple; otherwise a
concurrent VACUUM FULL on the catalog might move the tuple to a different
TID before we can apply the update.  Coding patterns that find the tuple
via a table scan aren't at risk here, but when obtaining the tuple from a
catalog cache, correct ordering is important; and several routines in
foreigncmds.c got it wrong.  Noted while running the regression tests in
parallel with VACUUM FULL of assorted system catalogs.

For consistency I moved all the heap_open calls to the starts of their
functions, including a couple for which there was no actual bug.

Back-patch to 8.4 where foreigncmds.c was added.
src/backend/commands/foreigncmds.c