How to Retrieve partitioning boundaries in PostgreSQL

SELECT t.oid::regclass AS partition,

       pg_get_expr(t.relpartbound, t.oid) AS bounds

FROM pg_inherits AS i

   JOIN pg_class AS t ON t.oid = i.inhrelid

WHERE i.inhparent = '<PARTITION TABLE NAME>'::regclass 

order by 1;


Example:

SELECT t.oid::regclass AS partition,

       pg_get_expr(t.relpartbound, t.oid) AS bounds

FROM pg_inherits AS i

   JOIN pg_class AS t ON t.oid = i.inhrelid

WHERE i.inhparent = 'stock.request_pt0_arch'::regclass 

order by 1;


partition_name                 |bounds                                                                          |

-----------------------------------+---------------------------------------------------------------------------+

request_pt0p520000000|FOR VALUES FROM ('520000000') TO ('530000000')|

request_pt0p155000000|FOR VALUES FROM ('155000000') TO ('165000000')|

request_pt0p165000000|FOR VALUES FROM ('165000000') TO ('175000000')|

request_pt0p175000000|FOR VALUES FROM ('175000000') TO ('185000000')|

request_pt0p185000000|FOR VALUES FROM ('185000000') TO ('195000000')|

request_pt0p195000000|FOR VALUES FROM ('195000000') TO ('205000000')|

request_pt0p205000000|FOR VALUES FROM ('205000000') TO ('215000000')|

request_pt0p215000000|FOR VALUES FROM ('215000000') TO ('225000000')|

request_pt0p225000000|FOR VALUES FROM ('225000000') TO ('235000000')|

request_pt0p235000000|FOR VALUES FROM ('235000000') TO ('245000000')|

request_pt0p245000000|FOR VALUES FROM ('245000000') TO ('255000000')|

request_pt0p105000000|FOR VALUES FROM ('105000000') TO ('115000000')|

request_pt0p100000000|FOR VALUES FROM ('100000000') TO ('100500000')|

request_pt0p100500000|FOR VALUES FROM ('100500000') TO ('101000000')|

request_pt0p101000000|FOR VALUES FROM ('101000000') TO ('101500000')|

request_pt0p101500000|FOR VALUES FROM ('101500000') TO ('102000000')|

request_pt0p102000000|FOR VALUES FROM ('102000000') TO ('102500000')|

request_pt0p102500000|FOR VALUES FROM ('102500000') TO ('103000000')|

request_pt0p103000000|FOR VALUES FROM ('103000000') TO ('103500000')|

request_pt0p103500000|FOR VALUES FROM ('103500000') TO ('104000000')|

request_pt0p104000000|FOR VALUES FROM ('104000000') TO ('104500000')|

request_pt0p104500000|FOR VALUES FROM ('104500000') TO ('105000000')|

request_pt0p115000000|FOR VALUES FROM ('115000000') TO ('125000000')|

request_pt0p125000000|FOR VALUES FROM ('125000000') TO ('135000000')|

request_pt0p135000000|FOR VALUES FROM ('135000000') TO ('145000000')|

request_pt0p145000000|FOR VALUES FROM ('145000000') TO ('155000000')|

request_pt0p255000000|FOR VALUES FROM ('255000000') TO ('265000000')|

request_pt0p265000000|FOR VALUES FROM ('265000000') TO ('275000000')|

request_pt0p285000000|FOR VALUES FROM ('285000000') TO ('295000000')|

request_pt0p295000000|FOR VALUES FROM ('295000000') TO ('305000000')|

request_pt0p500000000|FOR VALUES FROM ('500000000') TO ('510000000')|

request_pt0p510000000|FOR VALUES FROM ('510000000') TO ('520000000')|