]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix parsing of underscores in pg_plan_advice occurrence numbers
authorDaniel Gustafsson <dgustafsson@postgresql.org>
Sun, 19 Jul 2026 21:27:52 +0000 (23:27 +0200)
committerDaniel Gustafsson <dgustafsson@postgresql.org>
Sun, 19 Jul 2026 21:27:52 +0000 (23:27 +0200)
commitf87375bfba5cee2dcea4c19879ee990463be9636
tree5b8e18ae38a045ebafd348ccb4deb15cf990aab5
parentd451ca6917e35ce5aeee032462b3cd783d7a706e
Fix parsing of underscores in pg_plan_advice occurrence numbers

The pg_plan_advice scanner recognizes underscores as digit separators
just like the core parser, but used strtoint() to convert occurrence
numbers which does not support underscores.  Consequently, advice such
as SEQ_SCAN(x#1_0) failed to parse.  Fix by using pg_strtoint32_safe()
like the core scanner, and also add regression test coverage.

This bug was independently found and reported by Lukas Fittl and Chao
Li.  Backpatch down to v19 where pg_plan_advice was introduced.

Author: Chao Li <lic@highgo.com>
Co-authored-by: Daniel Gustafsson <daniel@yesql.se>
Reported-by: Lukas Fittl <lukas@fittl.com>
Reported-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Discussion: https://postgr.es/m/22E2ECE0-B768-43D5-8575-61C3EBC2E4E8@gmail.com
Discussion: https://postgr.es/m/CAP53PkzKeD=t90OfeMsniYrcRe2THQbUx3g6wV17Y=ZtiwmWTQ@mail.gmail.com
Backpatch-through: 19
contrib/pg_plan_advice/expected/syntax.out
contrib/pg_plan_advice/pgpa_scanner.l
contrib/pg_plan_advice/sql/syntax.sql