Re: Potential issue in listExtensions() - Mailing list pgsql-hackers

From Dilip Kumar
Subject Re: Potential issue in listExtensions()
Date
Msg-id CAFiTN-tnZyebP_YdQmtNZDWQJ3P5pHEqkDDU1d2g7TR+ijXV1A@mail.gmail.com
Whole thread Raw
In response to Potential issue in listExtensions()  (Suraj Kharage <suraj.kharage@enterprisedb.com>)
Responses Re: Potential issue in listExtensions()
List pgsql-hackers
On Thu, Jun 5, 2025 at 5:53 AM Suraj Kharage
<suraj.kharage@enterprisedb.com> wrote:
>
> Hi,
>
> Upstream commit d696406a9b255546bc1716d07199103abd8bb785 [1] added the support for default extension version in \dx
outputand changed the query that fetches the extension list. 
> The changed query seems problematic and might display duplicate entries of extension if the same object oid exists in
pg_description.
>
> If I understand correctly, after oid wraparound, it is possible that the existing oid from another catalog might be
usedagain for other catalog objects as per GetNewOidWithIndex(). 
> If this is true, then it is possible that oid exists in pg_description for an object will be used for extension oid,
andwe might get a duplicate entry in \dx output. 

Yes your understanding is correct and there is a possibility of the
bug you mentioned.

> ```
> "FROM pg_catalog.pg_extension e "
>  "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = e.extnamespace "
>  "LEFT JOIN pg_catalog.pg_description d ON d.objoid = e.oid "
>  "LEFT JOIN pg_catalog.pg_available_extensions() ae(name, default_version, comment) ON ae.name = e.extname "
>  "AND d.classoid = 'pg_catalog.pg_extension'::pg_catalog.regclass\n",
> ```
>
> We may need to handle this by moving the AND condition to the left join for pg_catalog.pg_description, so that we
retrieveonly pg_extension entries from pg_description. 
> Attaching the patch for the same.
>
> Thoughts?
>
Attached patch seems to be fixing the issue.



--
Regards,
Dilip Kumar
Google



pgsql-hackers by date:

Previous
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: Missing program_XXX calling in pgbench tests
Next
From: Yugo Nagata
Date:
Subject: Re: psql: tab-completion support for COPY ... TO/FROM STDIN, STDOUT, and PROGRAM