Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite2b42ae

Browse files
committed
Have \d show child tables that inherit from the specified parent
As per discussion, \d shows only the number of child tables, because thatcould be hundreds, when used for partitioning. \d+ shows the actual list.Author: Damien Clochard <damien@dalibo.info>
1 parent53fa850 commite2b42ae

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

‎src/bin/psql/describe.c

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* Copyright (c) 2000-2009, PostgreSQL Global Development Group
1010
*
11-
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.218 2009/06/13 13:43:34 petere Exp $
11+
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.219 2009/07/03 18:56:50 petere Exp $
1212
*/
1313
#include"postgres_fe.h"
1414

@@ -1814,6 +1814,44 @@ describeOneTableDetails(const char *schemaname,
18141814
}
18151815
PQclear(result);
18161816

1817+
/* print child tables */
1818+
printfPQExpBuffer(&buf,"SELECT c.oid::pg_catalog.regclass FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i WHERE c.oid=i.inhrelid AND i.inhparent = '%s' ORDER BY c.oid::pg_catalog.regclass;",oid);
1819+
1820+
result=PSQLexec(buf.data, false);
1821+
if (!result)
1822+
gotoerror_return;
1823+
else
1824+
tuples=PQntuples(result);
1825+
1826+
if (!verbose)
1827+
{
1828+
/* print the number of child tables, if any */
1829+
if (tuples>0)
1830+
{
1831+
printfPQExpBuffer(&buf,_("Number of child tables: %d (Use \\d+ to list them.)"),tuples);
1832+
printTableAddFooter(&cont,buf.data);
1833+
}
1834+
}
1835+
else
1836+
{
1837+
/* display the list of child tables*/
1838+
for (i=0;i<tuples;i++)
1839+
{
1840+
constchar*ct=_("Child tables");
1841+
1842+
if (i==0)
1843+
printfPQExpBuffer(&buf,"%s: %s",ct,PQgetvalue(result,i,0));
1844+
else
1845+
printfPQExpBuffer(&buf,"%*s %s", (int)strlen(ct),"",PQgetvalue(result,i,0));
1846+
if (i<tuples-1)
1847+
appendPQExpBuffer(&buf,",");
1848+
1849+
printTableAddFooter(&cont,buf.data);
1850+
}
1851+
}
1852+
PQclear(result);
1853+
1854+
/* OIDs and options */
18171855
if (verbose)
18181856
{
18191857
constchar*s=_("Has OIDs");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp