agora inbox for pgsql-bugs@postgresql.org
help / color / mirror / Atom feedFrom: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: hackerzheng666@gmail.com
Subject: BUG #19629: pg_restore_relation_stats reports XX000 instead of proper SQLSTATE for input validation errors
Date: Wed, 19 Aug 2026 03:50:55 +0000
Message-ID: <19629-76babc04b683594d@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 19629
Logged by: Zheng Hacker
Email address: hackerzheng666@gmail.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
view thread (11+ messages) latest in thread
Message-ID: <19629-76babc04b683594d@postgresql.org>
Permalink: ../19629-76babc04b683594d@postgresql.org/
Also on: postgresql.org/message-id/19629-76babc04b683594d@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-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, hackerzheng666@gmail.com
Subject: Re: BUG #19629: pg_restore_relation_stats reports XX000 instead of proper SQLSTATE for input validation errors
In-Reply-To: <19629-76babc04b683594d@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