| From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Cc: | hackerzheng666(at)gmail(dot)com |
| Subject: | BUG #19629: pg_restore_relation_stats reports XX000 instead of proper SQLSTATE for input validation errors |
| Date: | 2026-08-19 03:50:55 |
| Message-ID: | 19629-76babc04b683594d@postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 19629
Logged by: Zheng Hacker
Email address: hackerzheng666(at)gmail(dot)com
PostgreSQL version: 19beta3
Operating system: Linux x86_64
Description:
PostgreSQL version: 20devel (commit bdbf662, 2026-08-19)
OS: Linux x86_64
Four ereport(ERROR, ...) calls in src/backend/statistics/stat_utils.c
(function stats_fill_fcinfo_from_arg_pairs) are missing errcode(),
causing user input validation errors to return SQLSTATE XX000
(internal_error) instead of proper error codes.
Reproducers (with \set VERBOSITY verbose):
-- 1. Odd number of variadic args (line 372)
SELECT pg_restore_relation_stats('schemaname', 'stats_import', 'relname');
-- ERROR: XX000: variadic arguments must be name/value pairs
-- LOCATION: stats_fill_fcinfo_from_arg_pairs, stat_utils.c:372
-- 2. NULL argument name (line 387)
SELECT pg_restore_relation_stats(
'schemaname', 'stats_import', 'relname', 'test', NULL, '17'::integer);
-- ERROR: XX000: name at variadic position 5 is null
-- LOCATION: stats_fill_fcinfo_from_arg_pairs, stat_utils.c:387
-- 3. Wrong argument name type (line 391)
SELECT pg_restore_relation_stats(42, 'stats_import', 'relname', 'test');
-- ERROR: XX000: name at variadic position 1 has type integer, expected
type text
-- LOCATION: stats_fill_fcinfo_from_arg_pairs, stat_utils.c:391
A fourth site at line 656 has the same missing errcode pattern.
Suggested fix: add errcode() to each ereport call
(ERRCODE_INVALID_PARAMETER_VALUE,
ERRCODE_NULL_VALUE_NOT_ALLOWED, ERRCODE_DATATYPE_MISMATCH respectively).
Found by automated SQL fuzzing.
Credit: Zheng Wang, Yanjie Zhao, Yiyang Liu
| From | Date | Subject | |
|---|---|---|---|
| Next Message | PG Bug reporting form | 2026-08-19 03:51:32 | BUG #19630: FOR PORTION OF crashes with XX000 when target range is NULL |
| Previous Message | Kyotaro Horiguchi | 2026-08-19 02:56:36 | Re: BUG #19627: 32,768 trigger arguments wrap `tgnargs` and are silently lost at runtime |