BUG #19878: pg_identify_object functions expose XX000 for unsupported class IDs
BUG #19878: pg_identify_object functions expose XX000 for unsupported class IDs
От:
PG Bug reporting form <noreply@postgresql.org>
Дата:
The following bug has been logged on the website:
Bug reference: 19878
Logged by: Faye
Email address: imchifan@mail.com
PostgreSQL version: 18.6
Operating system: Linux/amd64
Description:
Passing an unsupported class ID to pg_identify_object() or
pg_identify_object_as_address() produces SQLSTATE XX000 (internal_error).
These public object-address inspection functions should classify invalid
user input as SQLSTATE 22023 (invalid_parameter_value) instead.
The block below records pg_describe_object() as a comparison, but its result
is not part of the assertion. The assertion applies only to the two
pg_identify_* functions.
How to repeat:
Save this as reproducer.sql and run `psql -X -d postgres -f reproducer.sql`:
```
-- The two pg_identify_* functions take the same (classid, objid, objsubid)
-- address as pg_describe_object() and must classify an unsupported classid
as
-- invalid_parameter_value (22023), never internal_error (XX000).
-- describe_code is recorded only as a comparison and is not asserted.
DO $object_address$
DECLARE
describe_code text;
identify_code text;
address_code text;
BEGIN
BEGIN
PERFORM pg_describe_object(1::oid, 1::oid, 0);
EXCEPTION WHEN OTHERS THEN
GET STACKED DIAGNOSTICS describe_code = RETURNED_SQLSTATE;
END;
BEGIN
PERFORM pg_identify_object(1::oid, 1::oid, 0);
EXCEPTION WHEN OTHERS THEN
GET STACKED DIAGNOSTICS identify_code = RETURNED_SQLSTATE;
END;
BEGIN
PERFORM pg_identify_object_as_address(1::oid, 1::oid, 0);
EXCEPTION WHEN OTHERS THEN
GET STACKED DIAGNOSTICS address_code = RETURNED_SQLSTATE;
END;
RAISE NOTICE 'describe=%, identify=%, as_address=%',
describe_code, identify_code, address_code;
IF identify_code IS DISTINCT FROM '22023'
OR address_code IS DISTINCT FROM '22023' THEN
RAISE EXCEPTION
'oracle failed: describe=%, identify=%, as_address=% (expected
22023)',
describe_code, identify_code, address_code;
END IF;
END
$object_address$;
-- DO creates no persistent database objects; cleanup is vacuous.
```
I get the following output:
```
NOTICE: describe=XX000, identify=XX000, as_address=XX000
ERROR: oracle failed: describe=XX000, identify=XX000, as_address=XX000
(expected 22023)
CONTEXT: PL/pgSQL function inline_code_block line 30 at RAISE
```
The issue was reproduced on PostgreSQL 18.6 on Linux/amd64. The anonymous
block creates no persistent database objects, and the server remains usable
after the error.
This occurs when object-address inspection code passes an unsupported class
ID to pg_identify_object() or pg_identify_object_as_address().
Re: BUG #19878: pg_identify_object functions expose XX000 for unsupported class IDs
От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
> On 11 Nov 2026, at 14:09, PG Bug reporting form wrote: > Passing an unsupported class ID to pg_identify_object() or > pg_identify_object_as_address() produces SQLSTATE XX000 (internal_error). > These public object-address inspection functions should classify invalid > user input as SQLSTATE 22023 (invalid_parameter_value) instead. That's not a bug, but a feature enhancement request. If you would like to see another errcode then feel free to submit a patch and argue for it's value. -- Daniel Gustafsson