SQLite

Check-in [61d7d4753f]
Login

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

Overview
Comment:Fix a problem in OP_IdxDelete as used by REPLACE conflict resolution that comes up due to recent enhancements that reduce the work required for UNIQUE NOT NULL indices.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 61d7d4753f36932293c0eb1ca893b17d18355ad3
User & Date: drh 2013-11-11 00:43:21.301
Context
2013-11-11
01:42
Modify a HeapValidate assert in the Win32 native allocator. (check-in: aaed7d1d3b user: mistachkin tags: trunk)
00:43
Fix a problem in OP_IdxDelete as used by REPLACE conflict resolution that comes up due to recent enhancements that reduce the work required for UNIQUE NOT NULL indices. (check-in: 61d7d4753f user: drh tags: trunk)
2013-11-10
00:03
Fix typo in comment and remove superfluous blank line. No changes to code. (check-in: 023233f16e user: mistachkin tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbe.c.
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
  pC = p->apCsr[pOp->p1];
  assert( pC!=0 );
  pCrsr = pC->pCursor;
  if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;
  if( ALWAYS(pCrsr!=0) ){
    r.pKeyInfo = pC->pKeyInfo;
    r.nField = (u16)pOp->p3;
    r.flags = 0;
    r.aMem = &aMem[pOp->p2];
#ifdef SQLITE_DEBUG
    { int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }
#endif
    rc = sqlite3BtreeMovetoUnpacked(pCrsr, &r, 0, 0, &res);
    if( rc==SQLITE_OK && res==0 ){
      rc = sqlite3BtreeDelete(pCrsr);







|







4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
  pC = p->apCsr[pOp->p1];
  assert( pC!=0 );
  pCrsr = pC->pCursor;
  if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;
  if( ALWAYS(pCrsr!=0) ){
    r.pKeyInfo = pC->pKeyInfo;
    r.nField = (u16)pOp->p3;
    r.flags = UNPACKED_PREFIX_MATCH;
    r.aMem = &aMem[pOp->p2];
#ifdef SQLITE_DEBUG
    { int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }
#endif
    rc = sqlite3BtreeMovetoUnpacked(pCrsr, &r, 0, 0, &res);
    if( rc==SQLITE_OK && res==0 ){
      rc = sqlite3BtreeDelete(pCrsr);
Changes to test/conflict2.test.
808
809
810
811
812
813
814

































815
816
817
do_test conflict2-13.2 {
  execsql {
    REPLACE INTO t13 VALUES(3);
    COMMIT;
    SELECT * FROM t13;
  }
} {1 3}



































finish_test







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



808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
do_test conflict2-13.2 {
  execsql {
    REPLACE INTO t13 VALUES(3);
    COMMIT;
    SELECT * FROM t13;
  }
} {1 3}

# Test for an unreleased bug in the REPLACE conflict resolution
# discovered on 2013-11-09.  
#
do_execsql_test conflict2-14.1 {
  DROP TABLE IF EXISTS t1;
  CREATE TABLE t1(
    x TEXT PRIMARY KEY NOT NULL, 
    y TEXT NOT NULL,
    z INTEGER
  );
  INSERT INTO t1 VALUES('alpha','beta',1);
  CREATE UNIQUE INDEX t1xy ON t1(x,y);
  REPLACE INTO t1(x,y,z) VALUES('alpha','gamma',1);
  PRAGMA integrity_check;
  SELECT x,y FROM t1 INDEXED BY t1xy;
  SELECT x,y,z FROM t1 NOT INDEXED;
} {ok alpha gamma alpha gamma 1}
do_execsql_test conflict2-14.2 {
  DROP TABLE IF EXISTS t1;
  CREATE TABLE t1(
    x TEXT PRIMARY KEY NOT NULL, 
    y TEXT NOT NULL,
    z INTEGER
  ) WITHOUT ROWID;
  INSERT INTO t1 VALUES('alpha','beta',1);
  CREATE UNIQUE INDEX t1xy ON t1(x,y);
  REPLACE INTO t1(x,y,z) VALUES('alpha','gamma',1);
  PRAGMA integrity_check;
  SELECT x,y FROM t1 INDEXED BY t1xy;
  SELECT x,y,z FROM t1 NOT INDEXED;
} {ok alpha gamma alpha gamma 1}



finish_test