Re: quoting psql varible as identifier

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: 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: quoting psql varible as identifier
Date: 2010-01-21 16:57:18
Message-ID: 162867791001210857i52b3de0ei34756c8dc181d51c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2010/1/21 Robert Haas <robertmhaas(at)gmail(dot)com>:
> On Tue, Jan 19, 2010 at 11:19 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> On Tue, Jan 19, 2010 at 4:40 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>>>> I'd like to proceed by committing an initial patch which changes the
>>>> "Escaping Strings for Inclusion in SQL Commands" to use a
>>>> <variablelist> with one <varlistentry> per function (as we do in
>>>> surrounding functions) and consolidates it with the following section,
>>>>  "Escaping Binary Strings for Inclusion in SQL Commands".  Then I'll
>>>> submit a patch implementing pqEscapeLiteral() and pqEscapeIdentifier()
>>>> as discussed here, and the doc diff hunks will actually be readable.
>>>
>>> Sounds like a plan.
>>
>> Initial commit done, and follow-on patch attached.  The docs took
>> longer to write than the code.  I spent a fair amount of time trying
>> to make it all make sense, but suggestions are welcome.
>
> Committed after fixing a couple of oversights in my doc changes.

thank you.

I actualised patch

I thing, we need one libpq change more.

+ static void
+ appendLiteral(PGconn *conn, PQExpBuffer buf, const char *str)
+ {
+ char *escaped_str;
+ size_t len;
+
+ len = strlen(str);
+ escaped_str = PQescapeLiteral(conn, str, len);
+
+ if (escaped_str == NULL)
+ {
+ const char *error_message = PQerrorMessage(pset.db);
+
+ if (strlen(error_message))
+ psql_error("%s", error_message);
+ }
+ else
+ {
+ appendPQExpBufferStr(buf, escaped_str);
+ free(escaped_str);
+ }
+ }

the correct result of this function (when is some error) is broken
buffer. But function markPQExpBufferBroken is static.

Regards
Pavel Stehule

>
> ...Robert
>

Attachment Content-Type Size
patch.diff application/octet-stream 4.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2010-01-21 16:59:58 Re: 8.5 vs. 9.0, Postgres vs. PostgreSQL
Previous Message Kevin Grittner 2010-01-21 16:54:03 Re: 8.5 vs. 9.0, Postgres vs. PostgreSQL