Re: Suggesting a libpq addition

From: Marc Balmer <marc(at)msys(dot)ch>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Suggesting a libpq addition
Date: 2010-12-05 11:04:05
Message-ID: 72682CED-FCE4-4134-B233-CFD2540C22AA@msys.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Am 05.12.2010 um 11:57 schrieb Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>:

> On 05.12.2010 12:10, Magnus Hagander wrote:
>> On Sun, Dec 5, 2010 at 10:22, Marc Balmer<marc(at)msys(dot)ch> wrote:
>>> I am suggesting adding a function to libpq:
>>>
>>> PGresult *PQvexec(PGconn *conn, const char *fmt, ...);
>>>
>>> It behaves similar to PQexec, but it allows for printf style varargs and
>>
>> How is that not a horrible idea, compared to using PQexecParams()? You
>> have to remember to do all your escaping and things manually, whereas
>> PQexecParams() does it automatically.
>
> A varargs version of PQexecParams() would be handy, though. Imagine being able to do:
>
> PQexecVParams("SELECT * FROM mytable WHERE foo = $1 AND bar = $2", foovar, barvar);
>
> instead of constructing an array for the variables.

yes, indeed. while the suggested implementation relies on the caller to do all escaping (a bad idea...), the ease of use of a printf-like function with the security of PQexecParam would be nice.

I'd say forget about my first suggestion, I will spend a bit more time on a better approach.
(and at the same time remove the connection reset code)

>
> --
> Heikki Linnakangas
> EnterpriseDB http://www.enterprisedb.com
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2010-12-05 11:08:12 Re: Suggesting a libpq addition
Previous Message Heikki Linnakangas 2010-12-05 10:57:58 Re: Suggesting a libpq addition