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: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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-14 12:25:58
Message-ID: AANLkTik7JYQnj2Z2ns1jS6OGSqEwbkqUTLO74bBnDGNu@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Oct 14, 2010 at 2:25 AM, Itagaki Takahiro
<itagaki(dot)takahiro(at)gmail(dot)com> wrote:
>> Let's make format support %s, %i, and %l, as well as
>> allowing things like %$3l (meaning, escape the third argument as a
>> literal and interpolate here), and call it good.
>
> Your idea is:
>  % [ $ pos ] format  -- ex. %$3l , %l
>  Escapes: %% => %
>
> Just for information, $ and pos are reversed in C sprintf.
>  % [ pos $ ] format  -- ex. %3$l , %l
>  Escapes: %% => %

Oh, woops. I intended to copy the way C works.

> IMHO, I like {} syntax as like as C# because the format strings are extensible.
>  { pos [ : format ] } -- ex {3:l}, {3} (, and {l} could be also supported)
>  Escapes: {{ => {, }} => }

My personal preference (and Pavel's, I guess) is to use the C-like
syntax. But I wouldn't be upset if consensus congealed around some
other option.

--
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 Andrew Dunstan 2010-10-14 12:50:35 Re: string function - "format" function proposal
Previous Message Robert Haas 2010-10-14 12:22:21 Re: [JDBC] Support for JDBC setQueryTimeout, et al.