|
8 | 8 | *
|
9 | 9 | * Copyright (c) 2000-2009, PostgreSQL Global Development Group
|
10 | 10 | *
|
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 $ |
12 | 12 | */
|
13 | 13 | #include "postgres_fe.h"
|
14 | 14 |
|
@@ -1814,6 +1814,44 @@ describeOneTableDetails(const char *schemaname,
|
1814 | 1814 | }
|
1815 | 1815 | PQclear(result);
|
1816 | 1816 |
|
| 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 | + goto error_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 | + const char *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 */ |
1817 | 1855 | if (verbose)
|
1818 | 1856 | {
|
1819 | 1857 | const char *s = _("Has OIDs");
|
|
0 commit comments