Discussion:
[Libpqxx-general] parametrized statement's values type support
Trigve Siver
2013-07-16 20:29:22 UTC
Permalink
Hi Jerome, guys

I was in need to use parametrized statement but with explicit parameters types specified. As it is now, all types are treated as untyped literal strings [1], therefor statements which expected concrete types needed some explicit casting. The problem was more serious with polymorphic parameters in plpgsql functions (anyelement, ...).


I'm attaching a patch againt svn trunk. API is backward compatible. Parameter types are specified as oid through parameterized_invocation's operator()(...) overload where all parameters for operator() must be specified (that is Value, if it is non-null and the actual type). See test/unit/test_parameterized.cxx for example/test.

I remember that parameter types were needed when defining prepared statement in the past but weren't passed to libpq API.


Looking forward for reviews.


[1] - http://www.postgresql.org/docs/9.2/static/libpq-exec.html - PQexecParams

Thanks

Trigve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: parametrized_types.patch
Type: application/octet-stream
Size: 9219 bytes
Desc: not available
URL: <http://lists.pgfoundry.org/pipermail/libpqxx-general/attachments/20130716/b255ad90/attachment.obj>
Loading...