BUG #3002: PQexecParams only supports some commands; needs improved error reporting, documenting or fixing - Mailing list pgsql-bugs

From Phil Endecott
Subject BUG #3002: PQexecParams only supports some commands; needs improved error reporting, documenting or fixing
Date
Msg-id 200702131939.l1DJda97027619@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #3002: PQexecParams only supports some commands; needs improved error reporting, documenting or fixing  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged online:

Bug reference:      3002
Logged by:          Phil Endecott
Email address:      spam_from_postgresql_bugs@chezphil.org
PostgreSQL version: 8.1.0
Operating system:   All?
Description:        PQexecParams only supports some commands; needs improved
error reporting, documenting or fixing
Details:

I understand that PQexecParams may only be used for SELECT, INSERT, DELETE
and UPDATE commands, but not for other commands where parameter substitution
might be useful such as CREATE VIEW and CREATE TABLE AS SELECT.  When I used
PQexecParams with CREATE VIEW with one $ parameter I got no error
immediately, but got a "no value found for parameter 1" error when I later
ran a query that used the view.

Three fixes occur to me:

1. An error could be reported immediately if an unsupported command is
passed to PQexecParams.

2. The documentation of PQexecParams could be fixed to list the four
commands to which it can be applied.

3. PQexecParams could be extended to support these commands.  I have written
a simple wrapper for PQexecParams that expands and escapes parameters and
calls PQexec, for a small set of parameter types.  (Please ask me if you'd
like to see the code; it is only 30 lines of obviousness.)  Presumably this
would be even simpler if done in the backend.

Thanks, Phil.

pgsql-bugs by date:

Previous
From: "laurent faillie"
Date:
Subject: BUG #3000: Linking problem
Next
From: "Michael"
Date:
Subject: BUG #2998: Installation Failed due to Permissions