Hi all,

some questions:

1. Is sqlite3_changes() reset to 0 when a new sqlite3_exec() is started?
2. Does a PRAGMA index_list() manipulate sqlite3_changes() in any way?
3. How can i reset sqlite3_changes() manually if its not done on sqlite3_exec()?

My real problem is i have a misdesigned interface (which i cannot change in 
this case) that returns malloc'ed C structs holding a table or integers cast 
to pointers when no table is returned.

Something like this (some parts ommitted)


   Table* t = 0;
   while (sqlite3_step(stmt) == SQLITE_ROW) {
     /* build the table struct and copy the rows...
   }
   sqlite3_finalize(stmt);
   if (t) {
    return t;
   } else {
    return (Table*)sqlite3_changes(db);
   }

Now i exec an PRAGMA index_list('table_with_no_index'), which returns no 
rows, so the t stays 0, but sqlite3_changes() is nonzero.. (1) so i get back 
1 stuffed into the pointer. Obviously this blows up if the code expects NULL 
for no result...

So i have some ways to get out of the mess:
1. Special case PRAGMAs that return tables, which is ugly.
2. Fix the callers to deal with it, even more ugly.
3. Clear sqlite3_changes() before exec() and hope that PRAGMAs don't modify it.
4. Throw away the broken interface. Would like to, but cannot do it here for 
API stability reasons.

Michael

-- 
Michael Schlenker
Software Engineer

CONTACT Software GmbH           Tel.:   +49 (421) 20153-80
Wiener Straße 1-3               Fax:    +49 (421) 20153-41
28359 Bremen
http://www.contact.de/          E-Mail: [EMAIL PROTECTED]

Sitz der Gesellschaft: Bremen
Geschäftsführer: Karl Heinz Zachries, Ralf Holtgrefe
Eingetragen im Handelsregister des Amtsgerichts Bremen unter HRB 13215
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to