Re: format() with embedded to_char() formatter

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: format() with embedded to_char() formatter
Дата
Msg-id AANLkTikF_BfsfA6gRqFtwmQ28xkas6kH=LBPCuGPu=zQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: format() with embedded to_char() formatter  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: format() with embedded to_char() formatter  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Mon, Nov 22, 2010 at 9:55 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Itagaki Takahiro <itagaki.takahiro@gmail.com> writes:
>> I'd like to propose %{...}s syntax, where format('%{xxx}s', arg)
>> is equivalent to format('%s', to_char(arg, 'xxx')). I think the
>> approach is better than implement C-like formatter because we
>> can reuse existing to_char() functions for the purpose.
>
> This seems pretty gross, not least because the existing to_char
> functions are so limited and broken.  I don't really want to make
> format() incorporate all the brain damage in timestamp to_char, in
> particular.

If the existing to_char() functions are limited and broken, maybe we
ought to fix them.  I am reminded of some wit's quote that XML is like
violence - if it doesn't solve your problem, you aren't using enough
of it.  I'm not a believer in that philosophy, and don't think that
adding a whole new set of functions with incompatible semantics is the
right way to fix problems with the existing functions.  We have enough
of that already - especially around dates - and it sucks badly enough
as it is.  Non-orthogonality is bad.

> Also, it doesn't seem that you're really getting much
> notational leverage with this proposal.

I am not sure I agree.  It seems quite convenient to me to be able to
encode all the formatting crap in the message string, rather than
spreading it out all over the SQL statement.  Maybe time for another
poll on -general.

> And lastly, AFAICS there
> is no way to do what you suggest without some really ugly kluges
> in the parser --- I think the function parsing code would have to
> have special cases to make format() work like this.

Huh?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: directory archive format for pg_dump
Следующее
От: Tom Lane
Дата:
Сообщение: Re: dblink versus long connection strings