@@ -2870,7 +2870,9 @@ describeOneTableDetails(const char *schemaname,
28702870 /* print child tables (with additional info if partitions) */
28712871 if (pset .sversion >= 100000 )
28722872 printfPQExpBuffer (& buf ,
2873- "SELECT c.oid::pg_catalog.regclass, pg_catalog.pg_get_expr(c.relpartbound, c.oid)"
2873+ "SELECT c.oid::pg_catalog.regclass,"
2874+ " pg_catalog.pg_get_expr(c.relpartbound, c.oid),"
2875+ " c.relkind"
28742876 " FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i"
28752877 " WHERE c.oid=i.inhrelid AND i.inhparent = '%s'"
28762878 " ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;" , oid );
@@ -2893,7 +2895,18 @@ describeOneTableDetails(const char *schemaname,
28932895 else
28942896 tuples = PQntuples (result );
28952897
2896- if (!verbose )
2898+ /*
2899+ * For a partitioned table with no partitions, always print the number
2900+ * of partitions as zero, even when verbose output is expected.
2901+ * Otherwise, we will not print "Partitions" section for a partitioned
2902+ * table without any partitions.
2903+ */
2904+ if (tableinfo .relkind == RELKIND_PARTITIONED_TABLE && tuples == 0 )
2905+ {
2906+ printfPQExpBuffer (& buf , _ ("Number of partitions: %d" ), tuples );
2907+ printTableAddFooter (& cont , buf .data );
2908+ }
2909+ else if (!verbose )
28972910 {
28982911 /* print the number of child tables, if any */
28992912 if (tuples > 0 )
@@ -2925,12 +2938,21 @@ describeOneTableDetails(const char *schemaname,
29252938 }
29262939 else
29272940 {
2941+ char * partitioned_note ;
2942+
2943+ if (* PQgetvalue (result , i , 2 ) == RELKIND_PARTITIONED_TABLE )
2944+ partitioned_note = ", PARTITIONED" ;
2945+ else
2946+ partitioned_note = "" ;
2947+
29282948 if (i == 0 )
2929- printfPQExpBuffer (& buf , "%s: %s %s" ,
2930- ct , PQgetvalue (result , i , 0 ), PQgetvalue (result , i , 1 ));
2949+ printfPQExpBuffer (& buf , "%s: %s %s%s" ,
2950+ ct , PQgetvalue (result , i , 0 ), PQgetvalue (result , i , 1 ),
2951+ partitioned_note );
29312952 else
2932- printfPQExpBuffer (& buf , "%*s %s %s" ,
2933- ctw , "" , PQgetvalue (result , i , 0 ), PQgetvalue (result , i , 1 ));
2953+ printfPQExpBuffer (& buf , "%*s %s %s%s" ,
2954+ ctw , "" , PQgetvalue (result , i , 0 ), PQgetvalue (result , i , 1 ),
2955+ partitioned_note );
29342956 }
29352957 if (i < tuples - 1 )
29362958 appendPQExpBufferChar (& buf , ',' );
0 commit comments