In libpq, the definition is like:
PGresult *
PQprepare(PGconn *conn,
const char *stmtName, const char *query,
int nParams, const Oid *paramTypes)

Could we remove the parameter "nParams"?
e.g. "insert into foo(id, name, address) values ($1, $2, $3)"
PostgreSQL possibly can parse the prepared sql statement to get the real
paramters count.

Or, is there another alternate way?

Search Discussions

  • Tom Lane at Sep 26, 2008 at 1:19 pm

    iihero writes:
    In libpq, the definition is like:
    PGresult *
    PQprepare(PGconn *conn,
    const char *stmtName, const char *query,
    int nParams, const Oid *paramTypes)
    Could we remove the parameter "nParams"?
    No. We are not going to break every existing user of the function.
    But you can already set it to zero if you don't feel like prespecifying
    the parameter types.

    regards, tom lane
  • Merlin Moncure at Sep 26, 2008 at 6:42 pm

    On Fri, Sep 26, 2008 at 2:45 AM, iihero wrote:
    In libpq, the definition is like:
    PGresult *
    PQprepare(PGconn *conn,
    const char *stmtName, const char *query,
    int nParams, const Oid *paramTypes)

    Could we remove the parameter "nParams"?
    e.g. "insert into foo(id, name, address) values ($1, $2, $3)"
    PostgreSQL possibly can parse the prepared sql statement to get the real
    paramters count.

    Or, is there another alternate way?
    if you are looking for easier way to do things like prepared
    statements, etc. over libpq, you may want to look at libpqtypes (it's
    a external library that will require a patched libpq for versions
    <8.4):

    http://libpqtypes.esilo.com/

    merlin
  • Andrew Chernow at Sep 26, 2008 at 7:39 pm

    Merlin Moncure wrote:
    On Fri, Sep 26, 2008 at 2:45 AM, iihero wrote:
    In libpq, the definition is like:
    PGresult *
    PQprepare(PGconn *conn,
    const char *stmtName, const char *query,
    int nParams, const Oid *paramTypes)

    Could we remove the parameter "nParams"?
    e.g. "insert into foo(id, name, address) values ($1, $2, $3)"
    PostgreSQL possibly can parse the prepared sql statement to get the real
    paramters count.

    Or, is there another alternate way?
    if you are looking for easier way to do things like prepared
    statements, etc. over libpq, you may want to look at libpqtypes (it's
    a external library that will require a patched libpq for versions
    <8.4):

    http://libpqtypes.esilo.com/

    merlin
    Sounds like you could make use of libpqtypes, which abstracts you from
    the standard parameterized API.

    Latest version of libpqtypes is finally online (v1.2a):

    http://pgfoundry.org/frs/?group_id=1000370

    NOTE: requires using cvs head because libpqtypes needs the new
    libpq-events feature.

    --
    Andrew Chernow
    eSilo, LLC
    every bit counts
    http://www.esilo.com/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-hackers @
categoriespostgresql
postedSep 26, '08 at 6:45a
activeSep 26, '08 at 7:39p
posts4
users4
websitepostgresql.org...
irc#postgresql

People

Translate

site design / logo © 2022 Grokbase