/ Check-in [3714ac17]
Login

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

Overview
Comment:Fix a bug in XFER optimization introduced by check-in (3736). (CVS 3744)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:3714ac173289e580a0302a5a3beac05823d92c5b
User & Date: drh 2007-03-29 13:35:36
Context
2007-03-29
15:00
Assume the malloc-failed flag cannot already be set when calling sqlite3_errmsg(16)(). (CVS 3745) check-in: 54fa2227 user: danielk1977 tags: trunk
13:35
Fix a bug in XFER optimization introduced by check-in (3736). (CVS 3744) check-in: 3714ac17 user: drh tags: trunk
12:24
Explicitly test some error cases that up until now have not been checked. (CVS 3743) check-in: 0b7bd9c3 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/insert.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle INSERT statements in SQLite.
    14     14   **
    15         -** $Id: insert.c,v 1.180 2007/03/29 05:51:49 drh Exp $
           15  +** $Id: insert.c,v 1.181 2007/03/29 13:35:36 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** Set P3 of the most recently inserted opcode to a column affinity
    21     21   ** string for index pIdx. A column affinity string has one character
    22     22   ** for each column in the table, according to the affinity of the column:
................................................................................
  1513   1513       emptyDestTest = sqlite3VdbeAddOp(v, OP_Goto, 0, 0);
  1514   1514       sqlite3VdbeJumpHere(v, addr1);
  1515   1515     }else{
  1516   1516       emptyDestTest = 0;
  1517   1517     }
  1518   1518     sqlite3OpenTable(pParse, iSrc, iDbSrc, pSrc, OP_OpenRead);
  1519   1519     emptySrcTest = sqlite3VdbeAddOp(v, OP_Rewind, iSrc, 0);
  1520         -  if( pDest->iPKey>=0 ){
  1521         -    memRowid = pParse->nMem++;
         1520  +  if( pDest->pIndex!=0 ){
  1522   1521       sqlite3VdbeAddOp(v, OP_Rowid, iSrc, 0);
  1523         -    sqlite3VdbeAddOp(v, OP_MemStore, memRowid, 1);
  1524         -    addr1 = sqlite3VdbeAddOp(v, OP_Rowid, iSrc, 0);
         1522  +    memRowid = pParse->nMem++;
         1523  +    sqlite3VdbeAddOp(v, OP_MemStore, memRowid, pDest->iPKey>=0);
         1524  +  }
         1525  +  addr1 = sqlite3VdbeAddOp(v, OP_Rowid, iSrc, 0);
         1526  +  if( pDest->iPKey>=0 ){
  1525   1527       sqlite3VdbeAddOp(v, OP_Dup, 0, 0);
  1526   1528       addr2 = sqlite3VdbeAddOp(v, OP_NotExists, iDest, 0);
  1527   1529       sqlite3VdbeOp3(v, OP_Halt, SQLITE_CONSTRAINT, onError, 
  1528   1530                         "PRIMARY KEY must be unique", P3_STATIC);
  1529   1531       sqlite3VdbeJumpHere(v, addr2);
  1530   1532       autoIncStep(pParse, counterMem);
  1531   1533     }else{
  1532         -    addr1 = sqlite3VdbeAddOp(v, OP_Rowid, iSrc, 0);
         1534  +    assert( pDest->autoInc==0 );
  1533   1535     }
  1534   1536     sqlite3VdbeAddOp(v, OP_RowData, iSrc, 0);
  1535   1537     sqlite3VdbeOp3(v, OP_Insert, iDest,
  1536   1538                       OPFLAG_NCHANGE|OPFLAG_LASTROWID|OPFLAG_APPEND,
  1537   1539                       pDest->zName, 0);
  1538   1540     sqlite3VdbeAddOp(v, OP_Next, iSrc, addr1);
  1539   1541     autoIncEnd(pParse, iDbDest, pDest, counterMem);