Fix buggy logic in isTempNamespaceInUse()
authorMichael Paquier
Wed, 15 Jan 2020 04:58:41 +0000 (13:58 +0900)
committerMichael Paquier
Wed, 15 Jan 2020 04:58:41 +0000 (13:58 +0900)
The logic introduced in this routine as of 246a6c8 would report an
incorrect result when a session calls it to check if the temporary
namespace owned by the session is in use or not.  It is possible to
optimize more the routine in this case to avoid a PGPROC lookup, but
let's keep the logic simple.  As this routine is used only by autovacuum
for now, there were no live bugs, still let's be correct for any future
code involving it.

Author: Michael Paquier
Reviewed-by: Julien Rouhaud
Discussion: https://postgr.es/m/20200113093703[email protected]
Backpatch-through: 11

src/backend/catalog/namespace.c

index 8d0896c3eb69c74fe1932593fccbb2e38d42720a..b8f0e1da6e945eb64ab4905368a64025ffc7b38b 100644 (file)
@@ -3235,8 +3235,8 @@ isTempNamespaceInUse(Oid namespaceId)
 
    backendId = GetTempNamespaceBackendId(namespaceId);
 
-   if (backendId == InvalidBackendId ||
-       backendId == MyBackendId)
+   /* No such temporary namespace? */
+   if (backendId == InvalidBackendId)
        return false;
 
    /* Is the backend alive? */