Re: isTempNamespaceInUse() is incorrect with its handling of MyBackendId

From: Julien Rouhaud <rjuju123(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: isTempNamespaceInUse() is incorrect with its handling of MyBackendId
Date: 2020-01-13 12:09:01
Message-ID: 20200113120901.GA38515@nol
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jan 13, 2020 at 06:37:03PM +0900, Michael Paquier wrote:
> Hi all,
>
> While reviewing some code in namespace.c, I have bumped into the
> following issue introduced by 246a6c8:
> diff --git a/src/backend/catalog/namespace.c
> b/src/backend/catalog/namespace.c
> index c82f9fc4b5..e70243a008 100644
> --- a/src/backend/catalog/namespace.c
> +++ b/src/backend/catalog/namespace.c
> @@ -3235,8 +3235,8 @@ isTempNamespaceInUse(Oid namespaceId)
>
> backendId = GetTempNamespaceBackendId(namespaceId);
>
> - if (backendId == InvalidBackendId ||
> - backendId == MyBackendId)
> + /* No such temporary namespace? */
> + if (backendId == InvalidBackendId)
> return false;
>
> The current logic of isTempNamespaceInUse() would cause a session
> calling the routine to return always false if trying to check if its
> own temporary session is in use, but that's incorrect.

Indeed.

> It is actually
> safe to remove the check on MyBackendId as the code would fall back on
> a check equivalent to MyProc->tempNamespaceId a bit down as per the
> attached, so let's fix it.
>
> Thoughts?

But that means an extraneous call to BackendIdGetProc() in that case, it seems
better to avoid it if we already have the information.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2020-01-13 12:13:10 Re: Add FOREIGN to ALTER TABLE in pg_dump
Previous Message Juan José Santamaría Flecha 2020-01-13 12:04:48 Re: Allow to_date() and to_timestamp() to accept localized names