Re: string function - "format" function proposal

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: string function - "format" function proposal
Date: 2010-10-18 14:42:40
Message-ID: AANLkTi=greOo4UP3R+3DQ72we0buGptH31z0hSMza7dW@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Oct 18, 2010 at 7:37 AM, Itagaki Takahiro
<itagaki(dot)takahiro(at)gmail(dot)com> wrote:
> On Sat, Oct 16, 2010 at 7:29 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> No doubt.  The problem is that we're going to end up with those bells
>> and whistles in two places: in to_char or other type-specific
>> formatting functions, and again in format.
>
> If we decide to use C-like sprintf(), I think the only thing we can do
> is to implement C-syntax as much as possible. Users will expect the
> function behaves as sprintf, because it has the similar syntax.
> It's not an item for now, but someone would request it at a future date.
>
>
> BTW, the interoperability is why I proposed {} syntax. For example,
> {1:YYYY-MM-DD} for date is expanded to to_char($1, 'YYYY-MM-DD').
> (Maybe it's not so easy; It requires function lookups depending on types.)

There's no particular reason why we couldn't make this work with
sprintf-type syntax; for example, you could allow %{XYZ} to mean
to_char(value, 'XYZ'). But it seems to me that we have agreement that
this should start with just %s, %I, %L and allow 3$ or similar in the
middle to specify which argument it is. We can then argue about how
many more bells and whistles to add later.

I would like to bounce this back for rework along the lines described
above and ask for a resubmit to the next CF. We are out of time to
consider this further for this CF, and clearly it's not ready to go
ATM.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Kupershmidt 2010-10-18 14:43:32 Re: [GENERAL] column-level update privs + lock table
Previous Message Robert Haas 2010-10-18 14:27:37 Re: [GENERAL] column-level update privs + lock table