Re: psql display of foreign keys
| От | Alvaro Herrera | 
|---|---|
| Тема | Re: psql display of foreign keys | 
| Дата | |
| Msg-id | 20190226222757.GA31622@alvherre.pgsql обсуждение исходный текст | 
| Ответ на | Re: psql display of foreign keys (Michael Paquier <michael@paquier.xyz>) | 
| Ответы | Re: psql display of foreign keys | 
| Список | pgsql-hackers | 
On 2019-Feb-04, Michael Paquier wrote:
> pg_partition_root() has not made it to the finish line yet, still it
> would have been nice to see a rebase, and the patch has been waiting
> for input for 4 weeks now.  So I am marking it as returned with
> feedback.
Thanks for committing pg_partition_root ... but it turns out to be
useless for this purpose.  It turns out that we need to obtain the list
of *ancestors* of the table being displayed, which pg_partition_tree
does not easily give you.  So I ended up adding yet another auxiliary
function, pg_partition_ancestors, which in its current formulation
returns just a lits of OIDs of ancestor tables.  This seems generally
useful, and can be used in conjunction with pg_partition_tree():
alvherre=# select t.* from pg_partition_tree(pg_partition_root('pk11')) t
           join pg_partition_ancestors('pk11', true) a on (t.relid = a.relid);
 relid | parentrelid | isleaf | level 
-------+-------------+--------+-------
 pk    |             | f      |     0
 pk1   | pk          | f      |     1
 pk11  | pk1         | t      |     2
(3 filas)
(A small tweak is to change the return type from OID to regclass.
Docbook additions missing also.)
Anyway, given this function, it's possible to fix the psql display to be
as I showed previously.  Patches attached.
-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
		
	Вложения
В списке pgsql-hackers по дате отправления: