[Libpqxx-general] Fw: Unnamed prepared statements

Trigve Siver trigves at yahoo.com
Mon Aug 17 11:09:25 UTC 2009


Forwarding to list



----- Forwarded Message ----
> From: Trigve Siver <trigves at yahoo.com>
> To: Jeroen T. Vermeulen <jtv at xs4all.nl>
> Sent: Monday, August 17, 2009 1:06:47 PM
> Subject: Re: [Libpqxx-general] Unnamed prepared statements
> 
> Hi
> 
> 
> > From: Jeroen T. Vermeulen 
> > To: Trigve Siver 
> > Cc: libpqxx-general at pgfoundry.org
> > Sent: Sunday, August 16, 2009 10:15:51 AM
> > Subject: Re: [Libpqxx-general] Unnamed prepared statements
> > 
> > 
> > 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.
> 
> No, it only happen to unnamed prepared statements.
> 
> > (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.
> > 
> I'm attaching the simple .cpp file that demonstrate the problem. (I've problem 
> attaching the file so I'm pasting it inline
> 
> > Jeroen
> 
> Trigve
> 
> ---
> #include 
> #include 
> 
> int main(int argc, char* argv[])
> {
>     if(argc < 4)
>         return 1;
> 
>     std::string const conn_str = std::string("host=localhost user=") + argv[1] + 
> " password=" + argv[2] + " dbname=" + argv[3];
>     // Create connection
>     pqxx::connection conn(conn_str);
>     try
>     {
>         // Execute statement
>         {
>             // Prepare statement
>             pqxx::prepare::declaration decl = conn.prepare("", "SELECT * from 
> pg_tables LIMIT $1")("integer", pqxx::prepare::treat_direct);
>             // Create transaction
>             pqxx::work t(conn);
>             pqxx::prepare::invocation invoc = t.prepared("")(8);
>             invoc.exec();
>         }
>         {
>             // Prepare statement
> //            pqxx::prepare::declaration decl = conn.prepare("", "SELECT * from 
> pg_tables LIMIT $1")("integer", pqxx::prepare::treat_direct);
>             // Create transaction
>             pqxx::work t(conn);
>             pqxx::prepare::invocation invoc = t.prepared("")(8);
>             invoc.exec();
>         }
>     }
>     catch(std::exception const &e)
>     {
>         std::cout << e.what() << std::endl;
>     }
> 
>     return 0;
> }



      


More information about the Libpqxx-general mailing list