Am 26.06.2012 17:08, schrieb Pavel Ivanov:
You are leaking stmt statement (re-preparing without finaliznig) and
your call to sqlite3_close returns SQLITE_ERROR because of that, but
you don't even check that so you are leaking database connections as
well.
Pavel
On Tue, Jun 26, 2012 at 11:01 AM, deltagam...@gmx.net
<deltagam...@gmx.net> wrote:
Am 26.06.2012 16:49, schrieb Richard Hipp:
On Tue, Jun 26, 2012 at 10:46 AM, deltagam...@gmx.net
<deltagam...@gmx.net>wrote:
I have a c++ GUI application from where the db is read and the content is
displayed in a Clistbox.
Then I try to delete some rows from the sqlite3-db from the console.
After rereading from within the GUI the deleted rows are still there.
How is this possible ?
The GUI is holding a read transaction open. Hence it sees a consistent
snapshot of the database from the moment in time when the transaction was
started. Subsequent writes to the database are ignored by the GUI until
it
closes its current transaction and starts a new one.
================================================================
void InitialReadEventsData()
{
// Remove all events from array
m_arrEvents.RemoveAll();
// write events
Event newEvent;
////// sqlite3 reading ///////////////////////////////////
int rc, id, total_events;
char *sql, *sqltotal;
char *evdate, *evtype;
int evctr;
int the_event_ctr = 0;
CString datetime;
CString datepart;
CString timepart;
sqlite3 *db;
sqlite3_stmt *stmt;
sqlite3_open("ah.db", &db);
/*
// check if table eventlog exists
char create_sql[] = "CREATE TABLE if not exists eventlog ("
"id INTEGER PRIMARY KEY,"
"eventdate DATETIME default current_timestamp,"
"eventtype TEXT,"
"counter INTEGER"
")";
rc = sqlite3_exec(db, create_sql, NULL, NULL, NULL);
*/
// select count(*) from eventlog
sqltotal = "Select count(*) from eventlog";
rc = sqlite3_prepare(db, sqltotal, strlen(sqltotal), &stmt, NULL);
rc = sqlite3_step(stmt);
total_events = sqlite3_column_int(stmt, 0 );
std::cout << total_events << std::endl;
// select * from eventlog
sql = "Select id, eventdate, eventtype, counter FROM eventlog";
sqlite3_prepare(db, sql, strlen(sql), &stmt, NULL);
rc = sqlite3_step(stmt);
while(rc == SQLITE_ROW) {
id = sqlite3_column_int(stmt, 0 );
//cid = sqlite3_column_int(stmt, 1 );
evdate = (char*)sqlite3_column_text(stmt, 1 );
evtype = (char*)sqlite3_column_text(stmt, 2 );
evctr = sqlite3_column_int(stmt, 3 );
datetime = evdate;
datepart = datetime.Mid(0,10);
timepart = datetime.Mid(11,5);
std::cout << datepart << "\t" << timepart << std::endl;
newEvent.m_nEvent = the_event_ctr;
newEvent.m_strLastEventDate = datepart ;
newEvent.m_strEventTime = timepart;
newEvent.m_strEventType = evtype;
newEvent.m_nCount = evctr;
WriteEvent(newEvent, the_event_ctr);
rc = sqlite3_step(stmt);
// increment eventcounter
the_event_ctr++;
} // while
rc = sqlite3_reset(stmt);
rc = sqlite3_finalize(stmt);
rc = sqlite3_close(db);
////// sqlite3 reading ///////////////////////////////////
}
=========================================================================
What am I missing now ? There is a rc = sqlite3_reset(stmt); but the rc
= sqlite3_close(db); still returns error_code 5
The sqlite3_exec is now comment. Do I have to "reset " and finalize this
part normally too ? How is this done ?
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users