Hiya,

I'm examining the test suite and I'm trying to reproduce the results for test laststmtchanges-1.1 (and friends). This test creates and populates
a small database as follows :

        create table t0 (x);
        insert into t0 values (1);
        insert into t0 values (1);
        insert into t0 values (2);
        insert into t0 values (2);
        insert into t0 values (1);
        insert into t0 values (1);
        insert into t0 values (1);
        insert into t0 values (2);
        select changes(), total_changes();

It then expects back results of "1 8" because the last insert operated on a single row (that is, exposing sqlite3_changes()) and because the total number of changes to the database is 8 (exposing sqlite3_total_changes()).

In my own code the sequence generates "2 8". I've tried reproducing the
sequence in the shell and I get a curious result. A copy of my attempts to reproduce the problem follows :

----8<----
[EMAIL PROTECTED]:~/sqlite-3.3.16$ ./sqlite3 temp.db
SQLite version 3.3.16
Enter ".help" for instructions
sqlite> create table t0 (x);
sqlite> insert into t0 values(1);
sqlite> select changes(), total_changes();
1|1
sqlite> .quit

[EMAIL PROTECTED]:~/sqlite-3.3.16$ rm temp.db
[EMAIL PROTECTED]:~/sqlite-3.3.16$ ./sqlite3 temp.db
SQLite version 3.3.16
Enter ".help" for instructions
sqlite> create table t0 (x);
sqlite> insert into t0 values(1); select changes(), total_changes();
2|1
----8<----

The second of these two results shows that the values of changes() may exceed the total number of changes made which seems odd in its own right.

From my own experiments changes() appears to be double the expected value when it is used in the second form, for example :

----8<----
sqlite>         create table t0 (x);
sqlite>         insert into t0 values (1);
sqlite>         insert into t0 values (1);
sqlite>         insert into t0 values (2);
sqlite>         insert into t0 values (2);
sqlite>         insert into t0 values (1);
sqlite>         insert into t0 values (1);
sqlite>         insert into t0 values (1);
sqlite>         insert into t0 values (2);
sqlite>
sqlite> update t0 set x=9 where x=1; select changes(), total_changes();
10|13
----8<----

Is there a reason for this seeming discrepancy in the execution of the changes function ?

--
Justin Fletcher, Senior Software Engineer
Picsel Technologies Ltd                                 Tel: +44 141 8855588
Titanium House, Kings Inch Rd, Glasgow, G51 4BP, UK     Web:  www.picsel.com
----------------------------------------------------------------------------
This email is subject to disclaimer at http://www.picsel.com/disclaimer.html


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to