Re: string function - "format" function proposal

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: string function - "format" function proposal
Date: 2010-09-06 14:24:08
Message-ID: 26848.1283783048@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:
> On Mon, Sep 6, 2010 at 10:47 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> No, you need to use the I/O functions. Not every type is guaranteed to
>> have a cast to text.

> One issue is that Pavel want to generate valid SQL statement using
> %v format. Boolean values are printed as t or f, so the unquoted
> values are not valid syntax.

So? You'd need to quote the values anyway, in general. If you want
something that will be valid SQL you'd better include the functionality
of quote_literal() in it.

> If we only use output functions, boolean values should be written as
> 't' or 'f' (single-quoted), Only numeric values can be unquoted on %v.

I'm not sure that it's a good idea to have any type-specific special
cases. Failing to quote numeric values will bring in the whole set of
issues about how the parser initially types numeric constants, as in the
other thread over the weekend.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-09-06 14:28:29 Re: string function - "format" function proposal
Previous Message Tom Lane 2010-09-06 14:18:04 Re: Interruptible sleeps (was Re: CommitFest 2009-07: Yay, Kevin! Thanks, reviewers!)