Is it worth adding Assert(false) for unknown paths in print_path()?

Started by David Rowleyalmost 3 years 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.

won't retrysuccessCI 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:t48517
psql -h localhost -U postgres

Built from patchset v1 (message #1), July 28, 2026 at 12:03 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 t48517_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 t48517_1 && git checkout t48517_1

Patchset v1 (message #1) is on t48517_1

Jump to latest
#1David Rowley
dgrowleyml@gmail.com

In [1]/messages/by-id/379082d6-1b6a-4cd6-9ecf-7157d8c08635@postgrespro.ru Andrey highlighted that I'd forgotten to add print_path()
handling for TidRangePaths in bb437f995.

I know the OPTIMIZER_DEBUG code isn't exactly well used. I never
personally use it and I work quite a bit in the planner, however, if
we're keeping it, I thought maybe we might get the memo of missing
paths a bit sooner if we add an Assert(false) in the default cases.

Is the attached worthwhile?

David

[1]: /messages/by-id/379082d6-1b6a-4cd6-9ecf-7157d8c08635@postgrespro.ru

Attachments:

t48517_1
assert_fail_unknown_paths_in_print_path.patchapplication/octet-stream; name=assert_fail_unknown_paths_in_print_path.patchDownload+10-0
#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: David Rowley (#1)
Re: Is it worth adding Assert(false) for unknown paths in print_path()?

On 2023-Sep-29, David Rowley wrote:

In [1] Andrey highlighted that I'd forgotten to add print_path()
handling for TidRangePaths in bb437f995.

I know the OPTIMIZER_DEBUG code isn't exactly well used. I never
personally use it and I work quite a bit in the planner, however, if
we're keeping it, I thought maybe we might get the memo of missing
paths a bit sooner if we add an Assert(false) in the default cases.

Is the attached worthwhile?

Hmm, if we had a buildfarm animal with OPTIMIZER_DEBUG turned on, then I
agree it would catch the omission quickly.

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"¿Cómo puedes confiar en algo que pagas y que no ves,
y no confiar en algo que te dan y te lo muestran?" (Germán Poo)

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: David Rowley (#1)
Re: Is it worth adding Assert(false) for unknown paths in print_path()?

David Rowley <dgrowleyml@gmail.com> writes:

In [1] Andrey highlighted that I'd forgotten to add print_path()
handling for TidRangePaths in bb437f995.

I know the OPTIMIZER_DEBUG code isn't exactly well used. I never
personally use it and I work quite a bit in the planner, however, if
we're keeping it, I thought maybe we might get the memo of missing
paths a bit sooner if we add an Assert(false) in the default cases.

FWIW, I'd argue for dropping print_path rather than continuing to
maintain it. I never use it, finding pprint() to serve the need
better and more reliably. However, assuming that we keep it ...

Is the attached worthwhile?

... I think this is actually counterproductive. It will certainly
not help draw the notice of anyone who wouldn't otherwise pay
attention to print_path. Also, observe the extremely longstanding
policy decision in outNode's default: case:

/*
* This should be an ERROR, but it's too useful to be able to
* dump structures that outNode only understands part of.
*/
elog(WARNING, "could not dump unrecognized node type: %d",
(int) nodeTag(obj));
break;

The same argument applies to print_path, I should think.

regards, tom lane

#4David Rowley
dgrowleyml@gmail.com
In reply to: Tom Lane (#3)
Re: Is it worth adding Assert(false) for unknown paths in print_path()?

On Fri, 29 Sept 2023 at 03:23, Tom Lane <tgl@sss.pgh.pa.us> wrote:

FWIW, I'd argue for dropping print_path rather than continuing to
maintain it. I never use it, finding pprint() to serve the need
better and more reliably.

Then perhaps we just need to open a thread with an appropriate subject
to check if anyone finds it useful and if we don't get any response
after some number of weeks, just remove it from master.

David