Here's a patch for the TODO item "Remove unreferenced table files created by transactions
that were in-progress when the server terminated abruptly."
It adds a new function, CleanupStaleRelFiles, that scans through the data
directory and removes all table files that are not mentioned in pg_class
of the corresponding database. CleanupStaleRelFiles is called after WAL
recovery.
Actually, the patch doesn't currently delete the files, just issues a
warning. Testing is easier if the files don't keep getting deleted :).
The patch also adds a GetTablespacePath function similar to
GetDatabasePath that constructs the path to a tablespace symbolic link.
commands/tablespace.c is modified to use it, in addition to the new
CleanupStaleRelFiles function.
- Heikki