Re: Why format() adds double quote?

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: pavel(dot)stehule(at)gmail(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Why format() adds double quote?
Date: 2016-01-20 06:20:15
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> 2016-01-20 3:47 GMT+01:00 Tatsuo Ishii <ishii(at)postgresql(dot)org>:
>> test=# select format('%I', t) from t1;
>> format
>> ----------
>> aaa
>> "AAA"
>> "あいう"
>> (3 rows)
>> Why is the text value of the third line needed to be double quoted?
>> (note that it is a multi byte character). Same thing can be said to
>> quote_ident().
>> We treat identifiers made of the multi byte characters without double
>> quotation (non delimited identifier) in other places.
>> test=# create table t2(あいう text);
>> test=# insert into t2 values('aaa');
>> INSERT 0 1
>> test=# select あいう from t2;
>> あいう
>> --------
>> aaa
>> (1 row)
> format uses same routine as quote_ident. So quote_ident should be fixed
> first.

Yes, I had that in my mind too.

Attached is the proposed patch to fix the bug.
Regression tests passed.

Here is an example after the patch. Note that the third row is not
quoted any more.

test=# select format('%I', あいう) from t2;
(3 rows)

Best regards,
Tatsuo Ishii
SRA OSS, Inc. Japan

Attachment Content-Type Size
ruleutils.c.diff text/x-patch 782 bytes

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2016-01-20 06:57:52 Re: Stream consistent snapshot via a logical decoding plugin as a series of INSERTs
Previous Message Craig Ringer 2016-01-20 06:05:14 Re: Window2012R2: initdb error: "The current directory is invalid."