SQLite

Check-in [55591fc49c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Make sure changes to virtual tables are counted the same as real tables. Ticket #3038. (CVS 4976)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 55591fc49c8ab8146c1f3eff733e637501bff627
User & Date: drh 2008-04-10 14:00:10.000
Context
2008-04-10
14:51
Add source file test_osinst.c. A wrapper vfs with instrumentation capabilities. (CVS 4977) (check-in: d9a6b653d3 user: danielk1977 tags: trunk)
14:00
Make sure changes to virtual tables are counted the same as real tables. Ticket #3038. (CVS 4976) (check-in: 55591fc49c user: drh tags: trunk)
13:42
Fix to the "copy" method in the TCL interface. Ticket #3039. (CVS 4975) (check-in: 6f07968ec4 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbe.c.
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
**
** Various scripts scan this source file in order to generate HTML
** documentation, headers files, or other derived files.  The formatting
** of the code in this file is, therefore, important.  See other comments
** in this file for details.  If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.728 2008/04/05 18:41:43 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
#include "vdbeInt.h"

/*
** The following global variable is incremented every time a cursor







|







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
**
** Various scripts scan this source file in order to generate HTML
** documentation, headers files, or other derived files.  The formatting
** of the code in this file is, therefore, important.  See other comments
** in this file for details.  If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.729 2008/04/10 14:00:10 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
#include "vdbeInt.h"

/*
** The following global variable is incremented every time a cursor
4764
4765
4766
4767
4768
4769
4770

4771
4772
4773
4774
4775
4776
4777
    rc = pModule->xUpdate(pVtab, nArg, apArg, &rowid);
    sqlite3VtabUnlock(db, pVtab);
    if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
    if( pOp->p1 && rc==SQLITE_OK ){
      assert( nArg>1 && apArg[0] && (apArg[0]->flags&MEM_Null) );
      db->lastRowid = rowid;
    }

  }
  break;
}
#endif /* SQLITE_OMIT_VIRTUALTABLE */

#ifndef SQLITE_OMIT_TRACE
/* Opcode: Trace * * * P4 *







>







4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
    rc = pModule->xUpdate(pVtab, nArg, apArg, &rowid);
    sqlite3VtabUnlock(db, pVtab);
    if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
    if( pOp->p1 && rc==SQLITE_OK ){
      assert( nArg>1 && apArg[0] && (apArg[0]->flags&MEM_Null) );
      db->lastRowid = rowid;
    }
    p->nChange++;
  }
  break;
}
#endif /* SQLITE_OMIT_VIRTUALTABLE */

#ifndef SQLITE_OMIT_TRACE
/* Opcode: Trace * * * P4 *
Changes to test/vtab1.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2006 June 10
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is creating and dropping virtual tables.
#
# $Id: vtab1.test,v 1.50 2007/12/13 21:54:11 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

ifcapable !vtab||!schema_pragmas {
  finish_test
  return













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2006 June 10
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is creating and dropping virtual tables.
#
# $Id: vtab1.test,v 1.51 2008/04/10 14:00:10 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

ifcapable !vtab||!schema_pragmas {
  finish_test
  return
604
605
606
607
608
609
610
611
612
613





614
615
616
617
618
619
















620
621
622
623
624
625
626





627
628
629
630
631
632
633





634
635
636
637
638
639
























640





641
642






643



644

645
646
647
648
649
650
651
do_test vtab1-6-2 {
  execsql {
    CREATE TABLE treal(a PRIMARY KEY, b, c);
    CREATE VIRTUAL TABLE techo USING echo(treal);
    SELECT name FROM sqlite_master WHERE type = 'table';
  }
} {treal techo}
do_test vtab1-6-3 {
  execsql {
    INSERT INTO techo VALUES(1, 2, 3);





    SELECT * FROM techo;
  }
} {1 2 3}
do_test vtab1-6-4 {
  execsql {
    UPDATE techo SET a = 5;
















    SELECT * FROM techo;
  }
} {5 2 3}

do_test vtab1-6-5 {
 execsql {
   UPDATE techo set a = a||b||c;





   SELECT * FROM techo;
 }
} {523 2 3}

do_test vtab1-6-6 {
  execsql {
    UPDATE techo set rowid = 10;





    SELECT rowid FROM techo;
  }
} {10}

do_test vtab1-6-7 {
  execsql {
























    DELETE FROM techo;





    SELECT * FROM techo;
  }






} {}






file delete -force test2.db
file delete -force test2.db-journal
sqlite3 db2 test2.db
execsql {
  CREATE TABLE techo(a PRIMARY KEY, b, c);
} db2







|


>
>
>
>
>



|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




|


>
>
>
>
>




|


>
>
>
>
>




|

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
|

>
>
>
>
>
>
|
>
>
>
|
>







604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
do_test vtab1-6-2 {
  execsql {
    CREATE TABLE treal(a PRIMARY KEY, b, c);
    CREATE VIRTUAL TABLE techo USING echo(treal);
    SELECT name FROM sqlite_master WHERE type = 'table';
  }
} {treal techo}
do_test vtab1-6-3.1 {
  execsql {
    INSERT INTO techo VALUES(1, 2, 3);
  }
  db changes
} {1}
do_test vtab1-6-3.2 {
  execsql {
    SELECT * FROM techo;
  }
} {1 2 3}
do_test vtab1-6-4.1 {
  execsql {
    UPDATE techo SET a = 5;
  }
  db changes
} {1}
do_test vtab1-6-4.2 {
  execsql {
    SELECT * FROM techo;
  }
} {5 2 3}
do_test vtab1-6-4.3 {
  execsql {
    UPDATE techo SET a=6 WHERE a<0;
  }
  db changes
} {0}
do_test vtab1-6-4.4 {
  execsql {
    SELECT * FROM techo;
  }
} {5 2 3}

do_test vtab1-6-5.1 {
 execsql {
   UPDATE techo set a = a||b||c;
 }
 db changes
} {1}
do_test vtab1-6-5.2 {
 execsql {
   SELECT * FROM techo;
 }
} {523 2 3}

do_test vtab1-6-6.1 {
  execsql {
    UPDATE techo set rowid = 10;
  }
  db changes
} {1}
do_test vtab1-6-6.2 {
  execsql {
    SELECT rowid FROM techo;
  }
} {10}

do_test vtab1-6-7.1 {
  execsql {
    INSERT INTO techo VALUES(11,12,13);
  }
  db changes
} {1}
do_test vtab1-6-7.2 {
  execsql {
    SELECT * FROM techo ORDER BY a;
  }
} {11 12 13 523 2 3}
do_test vtab1-6-7.3 {
  execsql {
    UPDATE techo SET b=b+1000
  }
  db changes
} {2}
do_test vtab1-6-7.4 {
  execsql {
    SELECT * FROM techo ORDER BY a;
  }
} {11 1012 13 523 1002 3}


do_test vtab1-6-8.1 {
  execsql {
    DELETE FROM techo WHERE a=5;
  }
  db changes
} {0}
do_test vtab1-6-8.2 {
  execsql {
    SELECT * FROM techo ORDER BY a;
  }
} {11 1012 13 523 1002 3}
do_test vtab1-6-8.3 {
  execsql {
    DELETE FROM techo;
  }
  db changes
} {2}
do_test vtab1-6-8.4 {
  execsql {
    SELECT * FROM techo ORDER BY a;
  }
} {}

file delete -force test2.db
file delete -force test2.db-journal
sqlite3 db2 test2.db
execsql {
  CREATE TABLE techo(a PRIMARY KEY, b, c);
} db2