• Fujii Masao's avatar
    postgres_fdw: Fix tests for CLOBBER_CACHE_ALWAYS. · f77717b2
    Fujii Masao authored
    The regression tests added in commits 708d165d and 411ae649 caused
    buildfarm failures when  CLOBBER_CACHE_ALWAYS was enabled.
    This commit stabilizes those tests.
    
    The foreign server connections established by postgres_fdw behaves
    differently depending on whether CLOBBER_CACHE_ALWAYS is enabled or not.
    If it's not enabled, those connections are cached. On the other hand,
    if it's enabled, when the connections are established outside transaction
    block, they are not cached (i.e., they are immediately closed at the end of
    query that established them). So the subsequent postgres_fdw_get_connections()
    cannot list those connections and postgres_fdw_disconnect() cannot close them
    (because they are already closed).
    
    When the connections are established inside transaction block, they are
    cached whether CLOBBER_CACHE_ALWAYS was enabled or not. But if it's enabled,
    they are immediately marked as invalid, otherwise not. This causes the
    subsequent postgres_fdw_get_connections() to return different result in
    "valid" column depending on whether CLOBBER_CACHE_ALWAYS was enabled or not.
    
    This commit prevents the above differences of behavior from
    affecting the regression tests.
    
    Per buildfarm failure on trilobite.
    
    Original patch by Bharath Rupireddy. I (Fujii Masao) extracted
    the regression test fix from that and revised it a bit.
    
    Reported-by: Tom Lane
    Author: Bharath Rupireddy
    Reviewed-by: Fujii Masao
    Discussion: https://postgr.es/m/2688508.1611865371@sss.pgh.pa.us
    f77717b2
postgres_fdw.sql 120 KB