Re: Last minute mini-proposal (I know, I know) for PQexecf() - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Last minute mini-proposal (I know, I know) for PQexecf()
Date
Msg-id 26530.1175301022@sss.pgh.pa.us
Whole thread Raw
In response to Last minute mini-proposal (I know, I know) for PQexecf()  (<korryd@enterprisedb.com>)
Responses Re: Last minute mini-proposal (I know, I know) forPQexecf()  (<korryd@enterprisedb.com>)
Re: Last minute mini-proposal (I know, I know) for PQexecf()  (Brian Hurt <bhurt@janestcapital.com>)
List pgsql-hackers
<korryd@enterprisedb.com> writes:
> I'd like to see a new variant on PQexec():
>     PGresult * PQexecf(PGconn *conn, const char *fmt, ...);

Way too late for 8.3 --- if we were going to do something like this,
we should think first and program later.  In particular, blindly
adopting the sprintf format string definition doesn't seem very helpful.
The sorts of escapes I'd want to have are "properly quoted SQL
identifier", "properly quoted SQL literal", etc.  A large fraction of
what sprintf knows about is more or less irrelevant to the task of
creating SQL commands.

Also, how does this interact with parameterized or prepared commands?
If we wanted PQexecf we'd soon want PQexecParamsf, etc.  I don't think
we really want so much duplicate logic there --- it'd be better to
decouple the string-building functionality from the query-sending
functionality.  Probably better to consider something like
PQformatQuery() that passes back a malloc'd string.
        regards, tom lane


pgsql-hackers by date:

Previous
From:
Date:
Subject: Last minute mini-proposal (I know, I know) for PQexecf()
Next
From: "Koichi Suzuki"
Date:
Subject: Re: [PATCHES] Full page writes improvement, code update