/ Check-in [bf2181f1]
Login

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

Overview
Comment:Bug fix associated with OP_SetNumColumns in insert.c. Also changed a variable name in OP_Column. (CVS 1413)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: bf2181f13fdad72d8c90eccc2d29034178181731
User & Date: drh 2004-05-20 02:42:16
Context
2004-05-20
03:02
Bug fix associated with misc3.test. (CVS 1414) check-in: a7f02db7 user: drh tags: trunk
02:42
Bug fix associated with OP_SetNumColumns in insert.c. Also changed a variable name in OP_Column. (CVS 1413) check-in: bf2181f1 user: drh tags: trunk
02:01
VACUUM works again. (CVS 1412) check-in: c4e1d02f user: drh 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.103 2004/05/19 14:56:56 drh Exp $
           15  +** $Id: insert.c,v 1.104 2004/05/20 02:42:16 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:
................................................................................
   303    303   
   304    304         /* The following code runs first because the GOTO at the very top
   305    305         ** of the program jumps to it.  Create the temporary table, then jump
   306    306         ** back up and execute the SELECT code above.
   307    307         */
   308    308         sqlite3VdbeChangeP2(v, iInitCode, sqlite3VdbeCurrentAddr(v));
   309    309         sqlite3VdbeAddOp(v, OP_OpenTemp, srcTab, 0);
   310         -      sqlite3VdbeAddOp(v, OP_SetNumColumns, srcTab, pTab->nCol);
          310  +      sqlite3VdbeAddOp(v, OP_SetNumColumns, srcTab, nColumn);
   311    311         sqlite3VdbeAddOp(v, OP_Goto, 0, iSelectLoop);
   312    312         sqlite3VdbeResolveLabel(v, iCleanup);
   313    313       }else{
   314    314         sqlite3VdbeChangeP2(v, iInitCode, sqlite3VdbeCurrentAddr(v));
   315    315       }
   316    316     }else{
   317    317       /* This is the case if the data for the INSERT is coming from a VALUES

Changes to src/vdbe.c.

    39     39   **
    40     40   ** Various scripts scan this source file in order to generate HTML
    41     41   ** documentation, headers files, or other derived files.  The formatting
    42     42   ** of the code in this file is, therefore, important.  See other comments
    43     43   ** in this file for details.  If in doubt, do not deviate from existing
    44     44   ** commenting and indentation practices when changing or adding code.
    45     45   **
    46         -** $Id: vdbe.c,v 1.306 2004/05/20 01:12:35 danielk1977 Exp $
           46  +** $Id: vdbe.c,v 1.307 2004/05/20 02:42:17 drh Exp $
    47     47   */
    48     48   #include "sqliteInt.h"
    49     49   #include "os.h"
    50     50   #include <ctype.h>
    51     51   #include "vdbeInt.h"
    52     52   
    53     53   /*
................................................................................
   496    496         break;
   497    497   
   498    498       default:
   499    499         assert(0);
   500    500     }
   501    501   }
   502    502   
          503  +/*
          504  +** Move data out of a btree key or data field and into a Mem structure.
          505  +** The data or key is taken from the entry that pCur is currently pointing
          506  +** to.  offset and amt determine what portion of the data or key to retrieve.
          507  +** key is true to get the key or false to get data.  The result is written
          508  +** into the pMem element.
          509  +*/
   503    510   static int getBtreeMem(
   504    511     BtCursor *pCur,   /* Cursor pointing at record to retrieve. */
   505    512     int offset,       /* Offset from the start of data to return bytes from. */
   506    513     int amt,          /* Number of bytes to return. */
   507    514     int key,          /* If true, retrieve from the btree key, not data. */
   508    515     Mem *pMem         /* OUT: Return data in this Mem structure. */
   509    516   ){
................................................................................
  1968   1975   
  1969   1976     u64 nField;        /* number of fields in the record */
  1970   1977     int len;           /* The length of the serialized data for the column */
  1971   1978     int offset = 0;
  1972   1979     int nn;
  1973   1980   
  1974   1981     char *zData;       
  1975         -  Mem zMem;
  1976         -  zMem.flags = 0;
         1982  +  Mem sMem;
         1983  +  sMem.flags = 0;
  1977   1984   
  1978   1985     assert( i<p->nCursor );
  1979   1986     pTos++;
  1980   1987   
  1981   1988     /* If the record is coming from the stack, not from a cursor, then there
  1982   1989     ** is nowhere to cache the record header infomation. This simplifies
  1983   1990     ** things greatly, so deal with this case seperately.
................................................................................
  2083   2090         ** three bytes or less. 
  2084   2091         */
  2085   2092         int max_space = sqlite3VarintLen((((u64)payloadSize)<<1)+13)*nField;
  2086   2093         if( max_space>payloadSize ){
  2087   2094           max_space = payloadSize;
  2088   2095         }
  2089   2096   
  2090         -      rc = getBtreeMem(pCrsr, 0, max_space, pC->keyAsData, &zMem);
         2097  +      rc = getBtreeMem(pCrsr, 0, max_space, pC->keyAsData, &sMem);
  2091   2098         if( rc!=SQLITE_OK ){
  2092   2099           goto abort_due_to_error;
  2093   2100         }
  2094         -      zData = zMem.z;
         2101  +      zData = sMem.z;
  2095   2102       }
  2096   2103   
  2097   2104       /* Read all the serial types for the record.  At the end of this block
  2098   2105       ** variable offset is set to the offset to the start of Data0 in the record.
  2099   2106       */
  2100   2107       for(nn=0; nn<nField; nn++){
  2101   2108         offset += sqlite3GetVarint(&zData[offset], &pC->aType[nn]);
  2102   2109       }
  2103   2110       pC->nHeader = offset;
  2104   2111       pC->cacheValid = 1;
  2105   2112   
  2106         -    Release(&zMem);
  2107         -    zMem.flags = 0;
         2113  +    Release(&sMem);
         2114  +    sMem.flags = 0;
  2108   2115     }
  2109   2116   
  2110   2117     /* Compute the offset from the beginning of the record to the beginning
  2111   2118     ** of the data.  And get the length of the data.
  2112   2119     */
  2113   2120     offset = pC->nHeader;
  2114   2121     for(nn=0; nn<p2; nn++){
................................................................................
  2115   2122       offset += sqlite3VdbeSerialTypeLen(pC->aType[nn]);
  2116   2123     }
  2117   2124   
  2118   2125     if( zRec ){
  2119   2126       zData = &zRec[offset];
  2120   2127     }else{
  2121   2128       len = sqlite3VdbeSerialTypeLen(pC->aType[p2]);
  2122         -    getBtreeMem(pCrsr, offset, len, pC->keyAsData, &zMem);
  2123         -    zData = zMem.z;
         2129  +    getBtreeMem(pCrsr, offset, len, pC->keyAsData, &sMem);
         2130  +    zData = sMem.z;
  2124   2131     }
  2125   2132     sqlite3VdbeSerialGet(zData, pC->aType[p2], pTos);
  2126   2133   
  2127         -  Release(&zMem);
         2134  +  Release(&sMem);
  2128   2135     break;
  2129   2136   }
  2130   2137   
  2131   2138   /* Opcode MakeRecord P1 * P3
  2132   2139   **
  2133   2140   ** This opcode (not yet in use) is a replacement for the current
  2134   2141   ** OP_MakeRecord that supports the SQLite3 manifest typing feature.