agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Robert Haas <rhaas@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: pg_plan_advice: Disallow partition name without partition schema
Date: Thu, 17 Sep 2026 01:16:43 +0000
Message-ID: <E1x70jz-000000002O3-1ynr@gemulon.postgresql.org> (raw)

pg_plan_advice: Disallow partition name without partition schema.

Up until now, pg_plan_advice has had a feature that allows an advice
target to mention a partition name but omit the partition schema;
that is, something like SEQ_SCAN(foo/bar) forces a sequential scan on
every child of table foo whose partition name is bar, regardless of
the schema in which bar appears. However, that feature turns out to
have a nasty design flaw: while advice enforcement handles this case
just fine, the advice feedback code doesn't know about it and will
mark such advice as "matched, failed" even when everything worked
perfectly. Unfortunately, there seems to be no simple code fix for
this problem.

Since the release of PostgreSQL 19 is imminent, take the conservative
course and revert this feature of pg_plan_advice. In other words,
require the partition schema whenever the partition name is present.
You must now write e.g. SEQ_SCAN(foo/public.bar) rather than just
SEQ_SCAN(foo/bar). This doesn't affect any cases where automatically
generated advice is supplied, since generated advice has always
included the partition schema anyway. Manually written advice will
have to conform to the new, stricter rule. For a later release, we
can consider whether to again relax this restriction in some way,
but now is not the time to design new things.

Reported-by: Noah Misch <noah@leadboat.com>
Backpatch-through: 19
Discussion: https://postgr.es/m/CA+TgmoYmXy-jiP5qDhqNEiYFEBzQsArO6O2d9E8szNZqi1bePQ@mail.gmail.com

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3201ea8f171a552b1a12e6c602a70f25252ba1cf

Modified Files
--------------
contrib/pg_plan_advice/README                     | 10 ++--
contrib/pg_plan_advice/expected/join_order.out    |  8 +--
contrib/pg_plan_advice/expected/partitionwise.out | 60 +----------------------
contrib/pg_plan_advice/expected/syntax.out        | 21 +++-----
contrib/pg_plan_advice/pgpa_ast.c                 | 12 ++---
contrib/pg_plan_advice/pgpa_ast.h                 |  4 +-
contrib/pg_plan_advice/pgpa_identifier.c          | 31 +++++-------
contrib/pg_plan_advice/pgpa_parser.y              | 12 ++---
contrib/pg_plan_advice/pgpa_trove.c               | 18 +++----
contrib/pg_plan_advice/sql/join_order.sql         |  4 +-
contrib/pg_plan_advice/sql/partitionwise.sql      |  7 +--
contrib/pg_plan_advice/sql/syntax.sql             |  7 +--
doc/src/sgml/pgplanadvice.sgml                    |  9 ++--
13 files changed, 58 insertions(+), 145 deletions(-)



view thread (2+ messages)

Message-ID: <E1x70jz-000000002O3-1ynr@gemulon.postgresql.org>
Permalink:  ../E1x70jz-000000002O3-1ynr@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1x70jz-000000002O3-1ynr@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: rhaas@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: pg_plan_advice: Disallow partition name without partition schema
  In-Reply-To: <E1x70jz-000000002O3-1ynr@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox