[Cppcms-users] cppdb::statement copy and assign
Brought to you by:
artyom-beilis
|
From: CN <cn...@fa...> - 2015-11-11 14:40:43
|
Hi!
I recently made a mistake by doing this:
cppdb::statement create(){
cppdb::session se("connect parameters");
cppdb::statement st=se << "SELECT * FROM t";
return st;
}
void use(){
cppdb::statement st=create();
st.query();
}
Very weird errors happens to st.query().
It took me quite some time to pin point the bug. After that, I re-read
the comments in cppdb/cppdb/frontend.h and I believe they confirm my
conclusion:
The problem here, I believe, is that cppdb::statement object is already
destroyed before st.query() is executed.
I am writing this note here in order to remind myself of avoiding such
practice. Hopefully no one else will make the same mistake as I did!
Meanwhile, I suspect it will be better off
(a) either to remove the cppdb::statement copy and assignment methods
from cppdb source altogether
(b) or to make cppdb::statement non-copyable
I have a feeling that these two methods serve only as a trap.
Yes? No?
Best Regards,
CN
--
http://www.fastmail.com - Access all of your messages and folders
wherever you are
|