extensions/sqlite/sqlite-source/insert.c
changeset 1645 27307df4d711
parent 1203 633c25ce6405
     1.1 --- a/extensions/sqlite/sqlite-source/insert.c	Sun Oct 28 05:06:12 2007 +0000
     1.2 +++ b/extensions/sqlite/sqlite-source/insert.c	Sun Oct 28 05:48:06 2007 +0000
     1.3 @@ -41,7 +41,8 @@
     1.4      */
     1.5      int n;
     1.6      Table *pTab = pIdx->pTable;
     1.7 -    pIdx->zColAff = (char *)sqliteMalloc(pIdx->nColumn+1);
     1.8 +    sqlite3 *db = sqlite3VdbeDb(v);
     1.9 +    pIdx->zColAff = (char *)sqlite3DbMallocZero(db, pIdx->nColumn+1);
    1.10      if( !pIdx->zColAff ){
    1.11        return;
    1.12      }
    1.13 @@ -79,8 +80,9 @@
    1.14    if( !pTab->zColAff ){
    1.15      char *zColAff;
    1.16      int i;
    1.17 +    sqlite3 *db = sqlite3VdbeDb(v);
    1.18  
    1.19 -    zColAff = (char *)sqliteMalloc(pTab->nCol+1);
    1.20 +    zColAff = (char *)sqlite3DbMallocZero(db, pTab->nCol+1);
    1.21      if( !zColAff ){
    1.22        return;
    1.23      }
    1.24 @@ -356,10 +358,10 @@
    1.25    int triggers_exist = 0;     /* True if there are FOR EACH ROW triggers */
    1.26  #endif
    1.27  
    1.28 -  if( pParse->nErr || sqlite3MallocFailed() ){
    1.29 +  db = pParse->db;
    1.30 +  if( pParse->nErr || db->mallocFailed ){
    1.31      goto insert_cleanup;
    1.32    }
    1.33 -  db = pParse->db;
    1.34  
    1.35    /* Locate the table into which we will be inserting new information.
    1.36    */
    1.37 @@ -462,7 +464,7 @@
    1.38  
    1.39      /* Resolve the expressions in the SELECT statement and execute it. */
    1.40      rc = sqlite3Select(pParse, pSelect, SRT_Subroutine, iInsertBlock,0,0,0,0);
    1.41 -    if( rc || pParse->nErr || sqlite3MallocFailed() ){
    1.42 +    if( rc || pParse->nErr || db->mallocFailed ){
    1.43        goto insert_cleanup;
    1.44      }
    1.45  
    1.46 @@ -1027,7 +1029,7 @@
    1.47      assert( pParse->ckOffset==nCol );
    1.48      pParse->ckOffset = 0;
    1.49      onError = overrideError!=OE_Default ? overrideError : OE_Abort;
    1.50 -    if( onError==OE_Ignore || onError==OE_Replace ){
    1.51 +    if( onError==OE_Ignore ){
    1.52        sqlite3VdbeAddOp(v, OP_Pop, nCol+1+hasTwoRowids, 0);
    1.53        sqlite3VdbeAddOp(v, OP_Goto, 0, ignoreDest);
    1.54      }else{
    1.55 @@ -1416,9 +1418,7 @@
    1.56    if( onError!=OE_Abort && onError!=OE_Rollback ){
    1.57      return 0;   /* Cannot do OR REPLACE or OR IGNORE or OR FAIL */
    1.58    }
    1.59 -  if( pSelect->pSrc==0 ){
    1.60 -    return 0;   /* SELECT must have a FROM clause */
    1.61 -  }
    1.62 +  assert(pSelect->pSrc);   /* allocated even if there is no FROM clause */
    1.63    if( pSelect->pSrc->nSrc!=1 ){
    1.64      return 0;   /* FROM clause must have exactly one term */
    1.65    }
    1.66 @@ -1523,6 +1523,7 @@
    1.67  #endif
    1.68    iDbSrc = sqlite3SchemaToIndex(pParse->db, pSrc->pSchema);
    1.69    v = sqlite3GetVdbe(pParse);
    1.70 +  sqlite3CodeVerifySchema(pParse, iDbSrc);
    1.71    iSrc = pParse->nTab++;
    1.72    iDest = pParse->nTab++;
    1.73    counterMem = autoIncBegin(pParse, iDbDest, pDest);