Re: Last minute mini-proposal (I know, I know) for PQexecf()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: korryd(at)enterprisedb(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Last minute mini-proposal (I know, I know) for PQexecf()
Date: 2007-03-31 00:30:22
Message-ID: 26530.1175301022@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

<korryd(at)enterprisedb(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Koichi Suzuki 2007-03-31 00:37:01 Re: [PATCHES] Full page writes improvement, code update
Previous Message korryd 2007-03-31 00:07:53 Last minute mini-proposal (I know, I know) for PQexecf()