| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL-development <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Robert Haas <robertmhaas(at)gmail(dot)com> |
| Subject: | pg_plan_advice: fix parsing underscore in numbers |
| Date: | 2026-07-17 09:22:22 |
| Message-ID: | 22E2ECE0-B768-43D5-8575-61C3EBC2E4E8@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
I’m playing with pg_plan_advice and found a small issue.
PG supports underscores between digits; for example, 1_0 is parsed as 10:
```
evantest=# SELECT 1_0;
?column?
----------
10
(1 row)
```
pg_plan_advice seems to intend to support the same syntax, based on pgpa_scanner.l:
```
decdigit [0-9]
decinteger {decdigit}(_?{decdigit})*
```
But it then uses strtoint() to parse the token, so an underscore causes a parse error:
```
evantest=# SET pg_plan_advice.advice = 'SEQ_SCAN(x#1_0)';
ERROR: invalid value for parameter "pg_plan_advice.advice": "SEQ_SCAN(x#1_0)"
DETAIL: Could not parse advice: integer out of range at or near "1_0"
```
The attached patch fixes this by using pg_strtoint32_safe() in the same way as the core scanner. With the fix, 1_0 works:
```
evantest=# SET pg_plan_advice.advice = 'SEQ_SCAN(x#1_0)';
SET
```
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Fix-parsing-of-underscores-in-pg_plan_advice-occu.patch | application/octet-stream | 2.9 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fujii Masao | 2026-07-17 09:30:14 | Re: [PATCH] Don't call ereport(ERROR) from recovery target GUC assign hooks |
| Previous Message | Ian Lawrence Barwick | 2026-07-17 09:00:49 | Re: doc: clarify wal_sender_shutdown_timeout behavior for small values |