[Libpqxx-general] Unnamed prepared statements

Jeroen T. Vermeulen jtv at xs4all.nl
Sun Aug 16 08:15:51 UTC 2009


On Sat, August 15, 2009 15:47, Trigve Siver wrote:

> because I cannot simple isolate it. But I try to describe it. I'm
> preparing (and using it) unnamed prepared statement (UPS) with definition
> named def1 (with some parameters). Then I create the same UPS (as the
> first) with definition of def1 and  call it and I've got the error
> "unnamed prepared statement does not exist" from  Postgres. This is some
> basic scheme in which I encounter the problem. The fix is  attached.  I
> found that in rev. 1553 there was some update in UPS's. I've added
> "i->second.registered = false;" in "pqxx::prepare::declaration
> pqxx::connection_base::prepare". I havent go deeper but it seems that it
> works.  So can someone shed some light on this?

Does the same happen with a regular (named) prepared statement?  It'd be
nice to have a minimal program to reproduce this, so I can add it to the
test suite.

(Don't apply your patch while checking this, because it'll break
redefinition of named statements if they've already been prepared).

The current trunk version basically does this when redefining the unnamed
statement:

    if (new_definition != definition)
    {
      registered = false;
      definition = new_definition;
    }

    // Prepare for new definition of parameters
    parameters.clear();
    varargs = false;
    complete = false;

The only way I can see that failing is if you redefine the statement with
the same body but a different parameters list.


Jeroen



More information about the Libpqxx-general mailing list