Re: [PATCHES] Quoting of psql \d output - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [PATCHES] Quoting of psql \d output
Date
Msg-id 200312310240.hBV2ef125745@candle.pha.pa.us
Whole thread Raw
List pgsql-hackers
We have been discussing this patch on the patches list:
ftp://candle.pha.pa.us/pub/postgresql/mypatches/fmtId

In short, the patch removes quoting from \d displays when quotes is not
required (e.g. identifier is all lower case and has no embedded spaces).

The patch changes this current output:
test=> \d friend2        Table "public.friend2"  Column   |     Type      | Modifiers
-----------+---------------+-----------firstname | character(15) |  lastname  | character(20) |  city      |
character(15)|  state     | character(2)  |  age       | integer       |  gender    | character(1)  |  last_met  | date
        | Indexes:    "firstname_idx" btree (firstname)Check constraints:    "friend2_state" CHECK
(length(btrim(state::text))= 2)    "friend2_age" CHECK (age >= 0)    "friend2_gender" CHECK (gender = 'M'::bpchar OR
gender= 'F'::bpchar)    "friend2_last_met" CHECK (last_met >= '1950-01-01'::date AND last_met <= 'now'::text::date)
"$1"CHECK (upper(btrim(firstname::text)) <> 'ED'::text OR upper(btrim(lastname::text)) <> 'RIVERS'::text)
 

to this:
test=> \d friend2         Table public.friend2  Column   |     Type      | Modifiers
-----------+---------------+-----------firstname | character(15) |  lastname  | character(20) |  city      |
character(15)|  state     | character(2)  |  age       | integer       |  gender    | character(1)  |  last_met  | date
        | Indexes:    firstname_idx btree (firstname)Check constraints:    friend2_state CHECK
(length(btrim(state::text))= 2)    friend2_age CHECK (age >= 0)    friend2_gender CHECK (gender = 'M'::bpchar OR gender
='F'::bpchar)    friend2_last_met CHECK (last_met >= '1950-01-01'::date AND last_met <= 'now'::text::date)    "$1"
CHECK(upper(btrim(firstname::text)) <> 'ED'::text OR upper(btrim(lastname::text)) <> 'RIVERS'::text)
 

It makes the \d display look cleaner and more similar to how people
usually type these things.

However, Peter feels that these are messages and should follow the style
guidelines of quoting identifiers, and Tom is concerned that the patch
pulls in fmtId() from pg_dump for a purely esthetic purpose.

I developed the patch only because some liked the cleaner display.  If
people want the patch or don't, let us know.  I have two people who
don't want the patch, and one who does, so it is really unclear how to
proceed.   Unless lots of people want it, I will just leave the code
unchanged.

This is really an issue regarding consistency, code simplicity, and
appearance.  All of the perspectives are valid, we just need to
determine which is most important in this case.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


pgsql-hackers by date:

Previous
From: Lamar Owen
Date:
Subject: Re: Little mess in RPM RH ?
Next
From: Bruce Momjian
Date:
Subject: Re: Preventing stack-overflow crashes (improving on max_expr_depth)