• Tom Lane's avatar
    Fix DROP TABLESPACE to unlink symlink when directory is not there. · b8347138
    Tom Lane authored
    If the tablespace directory is missing entirely, we allow DROP TABLESPACE
    to go through, on the grounds that it should be possible to clean up the
    catalog entry in such a situation.  However, we forgot that the pg_tblspc
    symlink might still be there.  We should try to remove the symlink too
    (but not fail if it's no longer there), since not doing so can lead to
    weird behavior subsequently, as per report from Michael Nolan.
    
    There was some discussion of adding dependency links to prevent DROP
    TABLESPACE when the catalogs still contain references to the tablespace.
    That might be worth doing too, but it's an orthogonal question, and in
    any case wouldn't be back-patchable.
    
    Back-patch to 9.0, which is as far back as the logic looks like this.
    We could possibly do something similar in 8.x, but given the lack of
    reports I'm not sure it's worth the trouble, and anyway the case could
    not arise in the form the logic is meant to cover (namely, a post-DROP
    transaction rollback having resurrected the pg_tablespace entry after
    some or all of the filesystem infrastructure is gone).
    b8347138
tablespace.c 43.9 KB