Re: [PATCHES] Quoting of psql \d output

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: [PATCHES] Quoting of psql \d output
Дата
Msg-id 200312310240.hBV2ef125745@candle.pha.pa.us
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Lamar Owen
Дата:
Сообщение: Re: Little mess in RPM RH ?
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Preventing stack-overflow crashes (improving on max_expr_depth)