Re: format() with embedded to_char() formatter - Mailing list pgsql-hackers

From Tom Lane
Subject Re: format() with embedded to_char() formatter
Date
Msg-id 25853.1290437748@sss.pgh.pa.us
Whole thread Raw
In response to format() with embedded to_char() formatter  (Itagaki Takahiro <itagaki.takahiro@gmail.com>)
Responses Re: format() with embedded to_char() formatter
List pgsql-hackers
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.  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


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Re: Proposed Windows-specific change: Enable crash dumps (like core files)
Next
From: Dimitri Fontaine
Date:
Subject: Re: Extensions, this time with a patch