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 <[email protected]> Backpatch-through: 19 Discussion: https://postgr.es/m/ca+tgmoymxy-jip5qdhqneiyfebzqsaro6o2d9e8sznzqi1b...@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(-)
