On Wed, Mar 26, 2014 at 12:53:32PM -0300, Alvaro Herrera wrote:
> Bruce Momjian wrote:
> > On Wed, Mar 26, 2014 at 12:20:07PM -0300, Alvaro Herrera wrote:
> 
> > > Not opposed to this, but it seems a bit strange; REPLICA IDENTITY is a
> > > property of the table, not of any individual index.  I think we should
> > > lose the token in the "Indexes" section.
> > 
> > That is an interesting idea.  It would mean that \d table would not show
> > anything about replica identity, because right now it does:
> > 
> >     test=> \d test
> >          Table "public.test"
> >      Column |  Type   | Modifiers
> >     --------+---------+-----------
> >      x      | integer | not null
> >     Indexes:
> >         "test_pkey" PRIMARY KEY, btree (x) REPLICA IDENTITY
> > 
> > That seems logical.
> 
> Hmm.  It seems to me that to make this more compact we could keep the
> current token in the index line if it's INDEX, and not display the
> Replica Identity: line at all; and if it's something other than index
> and different from the default value, then print "Replica Identity" in
> both \d and \d+.

OK. Tom's original complaint was about showing the default state in \d:

        http://www.postgresql.org/message-id/12303.1387038...@sss.pgh.pa.us

though that example was for an odd case where a system table didn't use
the default value.

The attached patch matches your suggestion.  It is basically back to
what the code originally had, except it skips system tables, and shows
"???" for invalid values.

-- 
  Bruce Momjian  <br...@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
new file mode 100644
index 21bbdf8..d1447fe
*** a/src/bin/psql/describe.c
--- b/src/bin/psql/describe.c
*************** describeOneTableDetails(const char *sche
*** 2345,2360 ****
  			printTableAddFooter(&cont, buf.data);
  		}
  
! 		if (verbose && (tableinfo.relkind == 'r' || tableinfo.relkind == 'm') &&
  			strcmp(schemaname, "pg_catalog") != 0)
  		{
  			const char *s = _("Replica Identity");
  
  			printfPQExpBuffer(&buf, "%s: %s",
  							  s,
- 							  tableinfo.relreplident == 'd' ? "DEFAULT" :
  							  tableinfo.relreplident == 'f' ? "FULL" :
- 							  tableinfo.relreplident == 'i' ? "USING INDEX" :
  							  tableinfo.relreplident == 'n' ? "NOTHING" :
  							  "???");
  
--- 2345,2363 ----
  			printTableAddFooter(&cont, buf.data);
  		}
  
! 		if ((tableinfo.relkind == 'r' || tableinfo.relkind == 'm') &&
! 			/*
! 			 * No need to display default values;  we already display a
! 			 * REPLICA IDENTITY marker on indexes.
! 			 */
! 			tableinfo.relreplident != 'd' && tableinfo.relreplident != 'i' &&
  			strcmp(schemaname, "pg_catalog") != 0)
  		{
  			const char *s = _("Replica Identity");
  
  			printfPQExpBuffer(&buf, "%s: %s",
  							  s,
  							  tableinfo.relreplident == 'f' ? "FULL" :
  							  tableinfo.relreplident == 'n' ? "NOTHING" :
  							  "???");
  
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to