Re: ToDo: show size of partitioned table

Поиск
Список
Период
Сортировка
От Kyotaro HORIGUCHI
Тема Re: ToDo: show size of partitioned table
Дата
Msg-id 20190403.120209.259853618.horiguchi.kyotaro@lab.ntt.co.jp
обсуждение исходный текст
Ответ на Re: ToDo: show size of partitioned table  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Ответы Re: ToDo: show size of partitioned table  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
Список pgsql-hackers
At Tue, 2 Apr 2019 22:49:25 -0300, Alvaro Herrera <alvherre@2ndquadrant.com> wrote in
<20190403014925.GA9976@alvherre.pgsql>
> Hi Amit
> 
> On 2019-Apr-03, Amit Langote wrote:
> 
> > Thanks.  I'm getting an error while applying v12:
> > 
> > patching file src/bin/psql/po/es.po
> > Hunk #1 FAILED at 12.
> > 1 out of 2 hunks FAILED -- saving rejects to file src/bin/psql/po/es.po.rej
> 
> Uh, I certainly did not intend to send the es.po part of the patch, I
> was just testing that the translation worked as intended.  That's what I
> get for doing stuff till the last minute ...

\dPn doesn't show children because the are of 'r' relkind. And
\dPn * doesn't show type for children.

create table pa (a int, b int) partition by range (a);
create table c1 partition of pa for values from (0) to (10);
create table c2 partition of pa for values from (10) to (20);
create index on pa(a);

postgres=# \dPn *
                  List of partitioned tables and indexes
 Schema |   Name   |  Owner   |       Type        | Parent name | On table 
--------+----------+----------+-------------------+-------------+----------
 public | pa       | horiguti | partitioned table |             | 
 public | pa_a_idx | horiguti | partitioned index |             | pa
(2 rows)


With the attached on top of the latest patch, we get the following result.

postgres=# \dPn *
                  List of partitioned tables and indexes
 Schema |   Name   |  Owner   |       Type        | Parent name | On table 
--------+----------+----------+-------------------+-------------+----------
 public | c1       | horiguti | partition table   | pa          | 
 public | c1_a_idx | horiguti | partition index   | pa_a_idx    | c1
 public | c2       | horiguti | partition table   | pa          | 
 public | c2_a_idx | horiguti | partition index   | pa_a_idx    | c2
 public | pa       | horiguti | partitioned table |             | 
 public | pa_a_idx | horiguti | partitioned index |             | pa
(6 rows)

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 736cca33d6..5f97bfc4b2 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3954,7 +3954,11 @@ listPartitions(const char *pattern, bool verbose, bool show_indexes,
         }
     }
 
-    appendPQExpBuffer(&buf, "\nWHERE c.relkind IN (%s)", relkind_str);
+    if (show_nested)
+        appendPQExpBuffer(&buf, "\nWHERE (c.relkind IN (%s) OR c3.relkind IN (%s))", relkind_str, relkind_str);
+    else
+        appendPQExpBuffer(&buf, "\nWHERE c.relkind IN (%s)", relkind_str);
+        
     appendPQExpBufferStr(&buf, !show_nested ? " AND NOT c.relispartition\n" : "\n");
 
     if (!pattern)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 5f97bfc4b2..41075f9a67 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3864,9 +3864,13 @@ listPartitions(const char *pattern, bool verbose, bool show_indexes,
                       ",\n  CASE c.relkind"
                       " WHEN " CppAsString2(RELKIND_PARTITIONED_TABLE) " THEN '%s'"
                       " WHEN " CppAsString2(RELKIND_PARTITIONED_INDEX) " THEN '%s'"
+                      " WHEN " CppAsString2(RELKIND_RELATION) " THEN '%s'"
+                      " WHEN " CppAsString2(RELKIND_INDEX) " THEN '%s'"
                       " END as \"%s\"",
                       gettext_noop("partitioned table"),
                       gettext_noop("partitioned index"),
+                      gettext_noop("partition table"),
+                      gettext_noop("partition index"),
                       gettext_noop("Type"));
 
         translate_columns[3] = true;

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: Transaction commits VS Transaction commits (with parallel) VSquery mean time
Следующее
От: Masahiko Sawada
Дата:
Сообщение: Re: New vacuum option to do only freezing