Re: Documentation incorrect pg_partition_root function description.

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: udv(dot)mail(at)gmail(dot)com, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Documentation incorrect pg_partition_root function description.
Date: 2026-02-28 20:12:06
Message-ID: 1223bd05e1482396b63c9ffc01dee7e7f357babe.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Sat, 2026-02-28 at 08:36 +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/18/functions-admin.html
> Description:
>
> https://www.postgresql.org/docs/current/functions-admin.html
>
> pg_partition_root ( regclass ) → regclass
> Returns the top-most parent of the partition tree to which the given
> relation belongs. Returns NULL if the relation does not exist or is not a
> partition or partitioned table.
>
> "does not exist" is not correct description, if table does not exist, we'll
> get an error, not NULL:
>
> EXAMPLE:
> SELECT * FROM pg_partition_root( 'nonexisting_table' );
>
> RESULT:
> SQL Error [42P01]: ERROR: relation "nonexisting_table" does not exist
> Position: 34

The error you are getting is *not* from pg_partition_root(), but from the
cast from "text" to "regclass":

SELECT 'nonexisting_table'::regclass;
ERROR: relation "nonexisting_table" does not exist
LINE 1: SELECT 'nonexisting_table'::regclass;
^

And if you take a "regclass" that corresponds to an object ID that is not
the object ID of any existing relation, you get a NULL result:

SELECT pg_partition_root('12345'::regclass);

pg_partition_root
-------------------

(1 row)

Yours,
Laurenz Albe

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Peter Eisentraut 2026-03-03 12:22:13 Re: Add Restart=on-failure To Example Systemd File
Previous Message Radoulov, Dimitre 2026-02-28 09:45:40 Re: Documentation clarification request: pg_dumpall and Large Objects