Re: [PATCHES] Quoting of psql \d output

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, chriskl(at)familyhealth(dot)com(dot)au
Subject: Re: [PATCHES] Quoting of psql \d output
Date: 2003-12-31 02:40:41
Message-ID: 200312310240.hBV2ef125745@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

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(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2003-12-31 02:42:38 Re: Preventing stack-overflow crashes (improving on max_expr_depth)
Previous Message Lamar Owen 2003-12-31 01:42:01 Re: Little mess in RPM RH ?

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2003-12-31 05:17:13 Re: fork/exec patch: pre-CreateProcess finalization
Previous Message Claudio Natoli 2003-12-31 02:33:09 Re: pg_usleep