| From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Cc: | imchifan(at)mail(dot)com |
| Subject: | BUG #19878: pg_identify_object functions expose XX000 for unsupported class IDs |
| Date: | 2026-11-11 13:09:08 |
| Message-ID: | 19878-47dc6875d990d8df@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: 19878
Logged by: Faye
Email address: imchifan(at)mail(dot)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().
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Heikki Linnakangas | 2026-11-11 13:12:06 | Re: BUG #19868: pg_resetwal prints uint32 WAL segment size as -1 bytes |
| Previous Message | Heikki Linnakangas | 2026-11-11 12:58:48 | Re: BUG #19862: Replacing a cast leaves prepared statements using the old cast function |