From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
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: quoting psql varible as identifier |
Date: | 2010-01-18 21:01:44 |
Message-ID: | 603c8f071001181301q25573ed9m9e86294c52a99aec@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Jan 18, 2010 at 3:26 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> ... Also, I prefer an
>> API where the escaping function does include the quotes, so I've done
>> it that way in the attached patch.
>
> IMO this function should act as much like PQescapeStringConn as possible.
Generally speaking, I agree...
> Random differences like including or not including outer quotes don't
> make the user's life better. Random differences like a slightly
> different rule for the amount of space required are outright dangerous.
I'm not sure that not including the quotes is any better. If someone
escapes foo and gets back foo, are they going to realize that escaping
fo"o is going to give them back fo""o rather than "fo""o"? One
difference vs. PQescapeStringConn() is that if you fail to include the
surrounding quotes in that case, something will almost certainly break
in a noisy and highly visible fashion. Here that might not happen, or
someone might call one of PQescapeStringConn() and
PQescapeIdentifierConn() and then use the wrong sort of outer quotes.
IMO, it's actually pretty weird that PQescapeStringConn() and
quote_literal() are named differently and do incompatible things. I
think it would be a plus if this new function were a little more
similar to quote_ident(), but that's just MHO, of course.
> Also, why is this patch changing the documentation of PQescapeStringConn?
> It might be only whitespace changes, but I don't particularly wish to
> have to determine that.
See previous discussion upthread.
http://archives.postgresql.org/pgsql-hackers/2010-01/msg01516.php
...Robert
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2010-01-18 21:20:32 | Re: Patch: Remove gcc dependency in definition of inline functions |
Previous Message | Tom Lane | 2010-01-18 20:26:53 | Re: quoting psql varible as identifier |