Fix failure to ignore leftover temp tables after a server crash.
During crash recovery, we remove disk files belonging to temporary tables,
but the system catalog entries for such tables are intentionally not
cleaned up right away. Instead, the first backend that uses a temp schema
is expected to clean out any leftover objects therein. This approach
requires that we be careful to ignore leftover temp tables (since any
actual access attempt would fail), *even if their BackendId matches our
session*, if we have not yet established use of the session's corresponding
temp schema. That worked fine in the past, but was broken by commit
debcec7dc31a992703911a9953e299c8d730c778 which incorrectly removed the
rd_islocaltemp relcache flag. Put it back, and undo various changes
that substituted tests like "rel->rd_backend == MyBackendId" for use
of a state-aware flag. Per trouble report from Heikki Linnakangas.
Back-patch to 9.1 where the erroneous change was made. In the back
branches, be careful to add rd_islocaltemp in a spot in the struct that
was alignment padding before, so as not to break existing add-on code.
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/6919b7e3294702adc39effd16634b2715d04f012
Modified Files
--------------
src/backend/catalog/toasting.c | 2 +-
src/backend/commands/copy.c | 2 +-
src/backend/commands/sequence.c | 4 ++--
src/backend/commands/tablecmds.c | 33 +++++++++++++++++++++++++++++----
src/backend/utils/adt/dbsize.c | 5 ++++-
src/backend/utils/cache/relcache.c | 25 +++++++++++++++++++++----
src/include/utils/rel.h | 17 ++++++-----------
7 files changed, 64 insertions(+), 24 deletions(-)