Project

General

Profile

Wt::Dbo::Session::execute() and try-catch

Added by denis talakevich about 12 years ago

when using construction:

try{

Dbo::Transaction transaction(session);

session.execute("update public.mail_accounts set username= ?").bind(uname).where("id= ?").bind(id);

transaction.commit();

}catch(Dbo::Exception &a) { msg(1,"error"); session.rereadAll(); return; }

after exception was catched, sql transaction was rollbacked. but next sql commands return error like :

A collection for '...' is already in use. Reentrant statement use is not yet implemented.

and there is no way to fix it without reset WApplication session


Replies (6)

RE: Wt::Dbo::Session::execute() and try-catch - Added by Koen Deforche about 12 years ago

Hey Denis,

I can't see how these three lines cause that problem though. Can you isolate this problem in a small test case that we can run ?

Regards,

koen

RE: Wt::Dbo::Session::execute() and try-catch - Added by denis talakevich about 12 years ago

creating table and index in Postgresql console:

create table mail_test (id serial, name varchar(16) not null,password varchar(36) not null,create_date timestamp with time zone default now());
alter table mail_test add primary key (id);
create unique index mail_test_pkey on mail_test (name);

we need create an exception situation by adding row with name that already exist

in t_status and db log you will see what is going on

I'm attaching c files to this message

Makefile (343 Bytes) Makefile makefile for freebsd (I have freebsd 8.2 p2 x86)
main_koen.cpp (1.53 KB) main_koen.cpp source
main_koen.h (2 KB) main_koen.h header

RE: Wt::Dbo::Session::execute() and try-catch - Added by denis talakevich about 12 years ago

last row in postgresql console:

create unique index mail_test_idx on mail_test (name);

RE: Wt::Dbo::Session::execute() and try-catch - Added by Koen Deforche about 12 years ago

Hey,

Got it now, execute() indeed didn't recycle the statement correctly in case of an exception. I've got a fix ready to be pushed.

Regards,

kone

    (1-6/6)