removed delete from table optimization workaround

- added more affected rows tests
- removed documentation and thes for "DELETE FROM TABLE" optimization
bug (fixed as of SQLite 3.6.5, see http://sqlite.org/lang_delete.html )
This commit is contained in:
aleks-f 2013-02-18 10:46:49 -06:00
parent 11cddbf751
commit 32602031fc

View File

@ -681,32 +681,43 @@ void SQLiteTest::testAffectedRows()
tmp << "DROP TABLE IF EXISTS Strings", now; tmp << "DROP TABLE IF EXISTS Strings", now;
tmp << "CREATE TABLE IF NOT EXISTS Strings (str VARCHAR(30))", now; tmp << "CREATE TABLE IF NOT EXISTS Strings (str VARCHAR(30))", now;
Statement stmt((tmp << "SELECT * FROM Strings")); Statement stmt((tmp << "INSERT INTO Strings VALUES(:str)", use(str)));
tmp << "SELECT COUNT(*) FROM Strings", into(count), now;
assert (count == 0);
assert (0 == stmt.execute());
Statement stmt1((tmp << "INSERT INTO Strings VALUES(:str)", use(str)));
count = -1; count = -1;
tmp << "SELECT COUNT(*) FROM Strings", into(count), now; tmp << "SELECT COUNT(*) FROM Strings", into(count), now;
assert (count == 0); assert (count == 0);
assert (4 == stmt1.execute()); assert (4 == stmt.execute());
tmp << "SELECT COUNT(*) FROM Strings", into(count), now; tmp << "SELECT COUNT(*) FROM Strings", into(count), now;
assert (count == 4); assert (count == 4);
Statement stmt2(tmp << "UPDATE Strings SET str = 's4' WHERE str = 's3'"); Statement stmt0(tmp << "DELETE FROM Strings");
assert (2 == stmt2.execute()); assert (4 == stmt0.execute());
tmp << "SELECT COUNT(*) FROM Strings", into(count), now;
assert (count == 0);
Statement stmt3(tmp << "DELETE FROM Strings WHERE str = 's1'"); Statement stmt1((tmp << "SELECT * FROM Strings"));
assert (1 == stmt3.execute()); tmp << "SELECT COUNT(*) FROM Strings", into(count), now;
assert (count == 0);
assert (0 == stmt1.execute());
Statement stmt4(tmp << "DELETE FROM Strings WHERE str = 'bad value'"); Statement stmt2((tmp << "INSERT INTO Strings VALUES(:str)", use(str)));
assert (0 == stmt4.execute()); count = -1;
tmp << "SELECT COUNT(*) FROM Strings", into(count), now;
assert (count == 0);
assert (4 == stmt2.execute());
tmp << "SELECT COUNT(*) FROM Strings", into(count), now;
assert (count == 4);
// see SQLiteStatementImpl::affectedRows() documentation for explanation Statement stmt3(tmp << "UPDATE Strings SET str = 's4' WHERE str = 's3'");
// why "WHERE 1" is necessary here assert (2 == stmt3.execute());
Statement stmt5(tmp << "DELETE FROM Strings WHERE 1");
assert (3 == stmt5.execute()); Statement stmt4(tmp << "DELETE FROM Strings WHERE str = 's1'");
assert (1 == stmt4.execute());
Statement stmt5(tmp << "DELETE FROM Strings WHERE str = 'bad value'");
assert (0 == stmt5.execute());
Statement stmt6(tmp << "DELETE FROM Strings");
assert (3 == stmt6.execute());
} }