Re: format() with embedded to_char() formatter

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: format() with embedded to_char() formatter
Date: 2010-11-22 14:55:48
Message-ID: 25853.1290437748@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)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. Also, it doesn't seem that you're really getting much
notational leverage with this proposal. 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.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2010-11-22 15:17:16 Re: Re: Proposed Windows-specific change: Enable crash dumps (like core files)
Previous Message Robert Haas 2010-11-22 14:53:39 Re: Re: Proposed Windows-specific change: Enable crash dumps (like core files)