Add OID descriptions to dumped parse/query/plan trees

Started by Chao Liabout 1 year ago4 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

appliestests failedCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t52142
psql -h localhost -U postgres

Built from patchset v1 (message #1), September 20, 2026 at 03:02 AM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t52142_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t52142_1 && git checkout t52142_1

Patchset v1 (message #1) is on t52142_1

Jump to latest
#1Chao Li
li.evan.chao@gmail.com

Hi Hackers,

When reading dumped parse/query/plan trees, sometime we want to know
what exact type/operator/function an OID stands for. I just added a new
feature that will add some OID descriptions to the dump trees, like:

```

      :scan.scanrelid 1
      :indexid 16474 # index orders_pkey
      :indexqual (
         {OPEXPR
         :opno 521 # operator >(integer,integer)
         :opfuncid 147 # function int4gt(integer,integer)
         :opresulttype 16 # type boolean
         :opretset false
         :opcollid 0

```

The patch file is attached.

Best regards,

--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachments:

t52142_1
v1-0001-Add-OID-descriptions-to-dumped-parse-query-plan-t.patchtext/plain; charset=UTF-8; name=v1-0001-Add-OID-descriptions-to-dumped-parse-query-plan-t.patchDownload+91-9
#2Kirill Reshke
reshkekirill@gmail.com
In reply to: Chao Li (#1)
Re: Add OID descriptions to dumped parse/query/plan trees

On Fri, 22 Aug 2025 at 14:08, Chao Li <li.evan.chao@gmail.com> wrote:

Hi Hackers,

When reading dumped parse/query/plan trees, sometime we want to know what exact type/operator/function an OID stands for. I just added a new feature that will add some OID descriptions to the dump trees, like:

```

:scan.scanrelid 1
:indexid 16474 # index orders_pkey
:indexqual (
{OPEXPR
:opno 521 # operator >(integer,integer)
:opfuncid 147 # function int4gt(integer,integer)
:opresulttype 16 # type boolean
:opretset false
:opcollid 0

```

The patch file is attached.

Best regards,

--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

Hi!

In commit message:

"This patch also fixes a trivial bug where an extra whitespace was added
when dumping an array, for example:..."

Maybe worth making this a separate change?

I can see that plain text comments can be beneficial for debug
purposes. However, I am not terribly sure these comments should be
included in the text dump unconditionally. This can break some
third-party query analysing tools (as it changes format). Can we make
this optional?

--
Best regards,
Kirill Reshke

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Chao Li (#1)
Re: Add OID descriptions to dumped parse/query/plan trees

Chao Li <li.evan.chao@gmail.com> writes:

When reading dumped parse/query/plan trees, sometime we want to know
what exact type/operator/function an OID stands for. I just added a new
feature that will add some OID descriptions to the dump trees, like:

This is really quite a bad idea. It means that the dump code has to
execute in a live (not-aborted) transaction, which is not a
requirement it had before, and will complicate some debugging
scenarios. The extra catalog accesses that could occur might also
cause problems, maybe even deadlocks in some uses. I'd prefer to
keep the flexibility to be able to call pprint from pretty much
anywhere.

Also, AFAICS this breaks re-reading of dump trees, which breaks all
kinds of stuff (rules, views, parallel query, etc).

regards, tom lane

#4Chao Li
li.evan.chao@gmail.com
In reply to: Tom Lane (#3)
Re: Add OID descriptions to dumped parse/query/plan trees

On Aug 22, 2025, at 22:10, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Chao Li <li.evan.chao@gmail.com> writes:

When reading dumped parse/query/plan trees, sometime we want to know
what exact type/operator/function an OID stands for. I just added a new
feature that will add some OID descriptions to the dump trees, like:

The extra catalog accesses that could occur might also
cause problems, maybe even deadlocks in some uses. I'd prefer to
keep the flexibility to be able to call pprint from pretty much
anywhere.

Also, AFAICS this breaks re-reading of dump trees, which breaks all
kinds of stuff (rules, views, parallel query, etc).

regards, tom lane

Thanks for pointing out that, I withdraw the patch.

--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/