public inbox for [email protected]  
help / color / mirror / Atom feed
From: GF <[email protected]>
To: Ron Johnson <[email protected]>
Cc: pgsql-general <[email protected]>
Subject: Re: Getting specific partition from the partition name
Date: Fri, 9 Aug 2024 17:34:54 +0200
Message-ID: <CAFePLY37HzJZYEz3N6Qrd2kG8p7cZ0j1A2SmgJ3Bv8bdM8LGiQ@mail.gmail.com> (raw)
In-Reply-To: <CANzqJaCs9ZBQvHsu3AhpdoQpry7qTg8KU2JNE-XyFZfO3cq3tg@mail.gmail.com>
References: <CAB+=1TUgzD7CfGbgiBAgcuttN06X11787WvJSeCPs=ek5qCgxw@mail.gmail.com>
	<CAKAnmmLRnzV2C6XBzu64Let3jtABh1P2sGbHBcfAfKpT22ufVQ@mail.gmail.com>
	<CANzqJaCs9ZBQvHsu3AhpdoQpry7qTg8KU2JNE-XyFZfO3cq3tg@mail.gmail.com>

On Fri, 9 Aug 2024 at 06:20, Ron Johnson <[email protected]> wrote:

>
> What if the partitions aren't all rationally named?  There *must* be a
> pg_* table out there which contains the partition boundaries...
>
>
The pg_class column relpartbound contains an internal representation of the
partition boundary, when applicable.
You can decompile it into the canonical text format with pg_get_expr( expr
pg_node_tree, relation oid [, pretty boolean ] ) → text.
So:
    create table t(x int primary key) partition by list(x);
    create table u partition of t for values in (0,1);
    create table v partition of t for values in (2,3,4,5,6,7,8,9);
    select oid::regclass,pg_get_expr(relpartbound,oid) from pg_class where
relkind='r' and relispartition;
 oid |              pg_get_expr
-----+----------------------------------------
 u   | FOR VALUES IN (0, 1)
 v   | FOR VALUES IN (2, 3, 4, 5, 6, 7, 8, 9)
(2 rows)

Best,
Giovanni


view thread (4+ messages)

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: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Getting specific partition from the partition name
  In-Reply-To: <CAFePLY37HzJZYEz3N6Qrd2kG8p7cZ0j1A2SmgJ3Bv8bdM8LGiQ@mail.gmail.com>

* 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