On Mon, Nov 22, 2010 at 9:55 AM, Tom Lane <t...@sss.pgh.pa.us> wrote:
> Itagaki Takahiro <itagaki.takah...@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

-- 
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