drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 1 | /* |
drh | b19a2bc | 2001-09-16 00:13:26 +0000 | [diff] [blame] | 2 | ** 2001 September 15 |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 3 | ** |
drh | b19a2bc | 2001-09-16 00:13:26 +0000 | [diff] [blame] | 4 | ** The author disclaims copyright to this source code. In place of |
| 5 | ** a legal notice, here is a blessing: |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 6 | ** |
drh | b19a2bc | 2001-09-16 00:13:26 +0000 | [diff] [blame] | 7 | ** May you do good and not evil. |
| 8 | ** May you find forgiveness for yourself and forgive others. |
| 9 | ** May you share freely, never taking more than you give. |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 10 | ** |
| 11 | ************************************************************************* |
| 12 | ** This file contains C code routines that are called by the parser |
| 13 | ** to handle UPDATE statements. |
| 14 | ** |
drh | 4a32431 | 2001-12-21 14:30:42 +0000 | [diff] [blame^] | 15 | ** $Id: update.c,v 1.23 2001/12/21 14:30:43 drh Exp $ |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 16 | */ |
| 17 | #include "sqliteInt.h" |
| 18 | |
| 19 | /* |
| 20 | ** Process an UPDATE statement. |
| 21 | */ |
| 22 | void sqliteUpdate( |
| 23 | Parse *pParse, /* The parser context */ |
| 24 | Token *pTableName, /* The table in which we should change things */ |
| 25 | ExprList *pChanges, /* Things to be changed */ |
| 26 | Expr *pWhere /* The WHERE clause. May be null */ |
| 27 | ){ |
| 28 | int i, j; /* Loop counters */ |
| 29 | Table *pTab; /* The table to be updated */ |
| 30 | IdList *pTabList = 0; /* List containing only pTab */ |
| 31 | int end, addr; /* A couple of addresses in the generated code */ |
| 32 | WhereInfo *pWInfo; /* Information about the WHERE clause */ |
| 33 | Vdbe *v; /* The virtual database engine */ |
| 34 | Index *pIdx; /* For looping over indices */ |
| 35 | int nIdx; /* Number of indices that need updating */ |
drh | 4794b98 | 2000-06-06 13:54:14 +0000 | [diff] [blame] | 36 | int base; /* Index of first available table cursor */ |
drh | ecdc753 | 2001-09-23 02:35:53 +0000 | [diff] [blame] | 37 | sqlite *db; /* The database structure */ |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 38 | Index **apIdx = 0; /* An array of indices that need updating too */ |
| 39 | int *aXRef = 0; /* aXRef[i] is the index in pChanges->a[] of the |
drh | 967e8b7 | 2000-06-21 13:59:10 +0000 | [diff] [blame] | 40 | ** an expression for the i-th column of the table. |
| 41 | ** aXRef[i]==-1 if the i-th column is not changed. */ |
drh | f57b339 | 2001-10-08 13:22:32 +0000 | [diff] [blame] | 42 | int openOp; /* Opcode used to open tables */ |
drh | 4a32431 | 2001-12-21 14:30:42 +0000 | [diff] [blame^] | 43 | int chngRecno; /* True if the record number is being changed */ |
| 44 | Expr *pRecnoExpr; /* Expression defining the new record number */ |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 45 | |
drh | daffd0e | 2001-04-11 14:28:42 +0000 | [diff] [blame] | 46 | if( pParse->nErr || sqlite_malloc_failed ) goto update_cleanup; |
drh | ecdc753 | 2001-09-23 02:35:53 +0000 | [diff] [blame] | 47 | db = pParse->db; |
drh | daffd0e | 2001-04-11 14:28:42 +0000 | [diff] [blame] | 48 | |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 49 | /* Locate the table which we want to update. This table has to be |
drh | 1ccde15 | 2000-06-17 13:12:39 +0000 | [diff] [blame] | 50 | ** put in an IdList structure because some of the subroutines we |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 51 | ** will be calling are designed to work with multiple tables and expect |
| 52 | ** an IdList* parameter instead of just a Table* parameger. |
| 53 | */ |
| 54 | pTabList = sqliteIdListAppend(0, pTableName); |
drh | daffd0e | 2001-04-11 14:28:42 +0000 | [diff] [blame] | 55 | if( pTabList==0 ) goto update_cleanup; |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 56 | for(i=0; i<pTabList->nId; i++){ |
drh | ecdc753 | 2001-09-23 02:35:53 +0000 | [diff] [blame] | 57 | pTabList->a[i].pTab = sqliteFindTable(db, pTabList->a[i].zName); |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 58 | if( pTabList->a[i].pTab==0 ){ |
| 59 | sqliteSetString(&pParse->zErrMsg, "no such table: ", |
| 60 | pTabList->a[i].zName, 0); |
| 61 | pParse->nErr++; |
| 62 | goto update_cleanup; |
| 63 | } |
| 64 | if( pTabList->a[i].pTab->readOnly ){ |
| 65 | sqliteSetString(&pParse->zErrMsg, "table ", pTabList->a[i].zName, |
| 66 | " may not be modified", 0); |
| 67 | pParse->nErr++; |
| 68 | goto update_cleanup; |
| 69 | } |
| 70 | } |
| 71 | pTab = pTabList->a[0].pTab; |
| 72 | aXRef = sqliteMalloc( sizeof(int) * pTab->nCol ); |
| 73 | if( aXRef==0 ) goto update_cleanup; |
| 74 | for(i=0; i<pTab->nCol; i++) aXRef[i] = -1; |
| 75 | |
drh | 967e8b7 | 2000-06-21 13:59:10 +0000 | [diff] [blame] | 76 | /* Resolve the column names in all the expressions in both the |
| 77 | ** WHERE clause and in the new values. Also find the column index |
| 78 | ** for each column to be updated in the pChanges array. |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 79 | */ |
| 80 | if( pWhere ){ |
drh | 4794b98 | 2000-06-06 13:54:14 +0000 | [diff] [blame] | 81 | sqliteExprResolveInSelect(pParse, pWhere); |
| 82 | } |
| 83 | for(i=0; i<pChanges->nExpr; i++){ |
| 84 | sqliteExprResolveInSelect(pParse, pChanges->a[i].pExpr); |
| 85 | } |
| 86 | if( pWhere ){ |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 87 | if( sqliteExprResolveIds(pParse, pTabList, pWhere) ){ |
| 88 | goto update_cleanup; |
| 89 | } |
| 90 | if( sqliteExprCheck(pParse, pWhere, 0, 0) ){ |
| 91 | goto update_cleanup; |
| 92 | } |
| 93 | } |
drh | 4a32431 | 2001-12-21 14:30:42 +0000 | [diff] [blame^] | 94 | chngRecno = 0; |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 95 | for(i=0; i<pChanges->nExpr; i++){ |
| 96 | if( sqliteExprResolveIds(pParse, pTabList, pChanges->a[i].pExpr) ){ |
| 97 | goto update_cleanup; |
| 98 | } |
| 99 | if( sqliteExprCheck(pParse, pChanges->a[i].pExpr, 0, 0) ){ |
| 100 | goto update_cleanup; |
| 101 | } |
| 102 | for(j=0; j<pTab->nCol; j++){ |
drh | 6206d50 | 2000-06-19 19:09:08 +0000 | [diff] [blame] | 103 | if( sqliteStrICmp(pTab->aCol[j].zName, pChanges->a[i].zName)==0 ){ |
drh | 4a32431 | 2001-12-21 14:30:42 +0000 | [diff] [blame^] | 104 | if( i==pTab->iPKey ){ |
| 105 | chngRecno = 1; |
| 106 | pRecnoExpr = pChanges->a[i].pExpr; |
| 107 | } |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 108 | aXRef[j] = i; |
| 109 | break; |
| 110 | } |
| 111 | } |
| 112 | if( j>=pTab->nCol ){ |
drh | 967e8b7 | 2000-06-21 13:59:10 +0000 | [diff] [blame] | 113 | sqliteSetString(&pParse->zErrMsg, "no such column: ", |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 114 | pChanges->a[i].zName, 0); |
| 115 | pParse->nErr++; |
| 116 | goto update_cleanup; |
| 117 | } |
| 118 | } |
| 119 | |
drh | 5a2c2c2 | 2001-11-21 02:21:11 +0000 | [diff] [blame] | 120 | /* Allocate memory for the array apIdx[] and fill it with pointers to every |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 121 | ** index that needs to be updated. Indices only need updating if their |
drh | 967e8b7 | 2000-06-21 13:59:10 +0000 | [diff] [blame] | 122 | ** key includes one of the columns named in pChanges. |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 123 | */ |
| 124 | for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
drh | 4a32431 | 2001-12-21 14:30:42 +0000 | [diff] [blame^] | 125 | if( chngRecno ){ |
| 126 | i = 0; |
| 127 | }else { |
| 128 | for(i=0; i<pIdx->nColumn; i++){ |
| 129 | if( aXRef[pIdx->aiColumn[i]]>=0 ) break; |
| 130 | } |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 131 | } |
drh | 967e8b7 | 2000-06-21 13:59:10 +0000 | [diff] [blame] | 132 | if( i<pIdx->nColumn ) nIdx++; |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 133 | } |
drh | b072950 | 2001-03-14 12:35:57 +0000 | [diff] [blame] | 134 | if( nIdx>0 ){ |
| 135 | apIdx = sqliteMalloc( sizeof(Index*) * nIdx ); |
| 136 | if( apIdx==0 ) goto update_cleanup; |
| 137 | } |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 138 | for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
drh | 4a32431 | 2001-12-21 14:30:42 +0000 | [diff] [blame^] | 139 | if( chngRecno ){ |
| 140 | i = 0; |
| 141 | }else{ |
| 142 | for(i=0; i<pIdx->nColumn; i++){ |
| 143 | if( aXRef[pIdx->aiColumn[i]]>=0 ) break; |
| 144 | } |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 145 | } |
drh | 967e8b7 | 2000-06-21 13:59:10 +0000 | [diff] [blame] | 146 | if( i<pIdx->nColumn ) apIdx[nIdx++] = pIdx; |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | /* Begin generating code. |
| 150 | */ |
drh | d8bc708 | 2000-06-07 23:51:50 +0000 | [diff] [blame] | 151 | v = sqliteGetVdbe(pParse); |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 152 | if( v==0 ) goto update_cleanup; |
drh | ecdc753 | 2001-09-23 02:35:53 +0000 | [diff] [blame] | 153 | if( (db->flags & SQLITE_InTrans)==0 ){ |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 154 | sqliteVdbeAddOp(v, OP_Transaction, 0, 0); |
| 155 | sqliteVdbeAddOp(v, OP_VerifyCookie, db->schema_cookie, 0); |
drh | ecdc753 | 2001-09-23 02:35:53 +0000 | [diff] [blame] | 156 | pParse->schemaVerified = 1; |
drh | 5e00f6c | 2001-09-13 13:46:56 +0000 | [diff] [blame] | 157 | } |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 158 | |
| 159 | /* Begin the database scan |
| 160 | */ |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 161 | pWInfo = sqliteWhereBegin(pParse, pTabList, pWhere, 1); |
| 162 | if( pWInfo==0 ) goto update_cleanup; |
| 163 | |
| 164 | /* Remember the index of every item to be updated. |
| 165 | */ |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 166 | sqliteVdbeAddOp(v, OP_ListWrite, 0, 0); |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 167 | |
| 168 | /* End the database scan loop. |
| 169 | */ |
| 170 | sqliteWhereEnd(pWInfo); |
| 171 | |
drh | 1bee3d7 | 2001-10-15 00:44:35 +0000 | [diff] [blame] | 172 | /* Initialize the count of updated rows |
| 173 | */ |
| 174 | if( db->flags & SQLITE_CountRows ){ |
| 175 | sqliteVdbeAddOp(v, OP_Integer, 0, 0); |
| 176 | } |
| 177 | |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 178 | /* Rewind the list of records that need to be updated and |
| 179 | ** open every index that needs updating. |
| 180 | */ |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 181 | sqliteVdbeAddOp(v, OP_ListRewind, 0, 0); |
drh | 4794b98 | 2000-06-06 13:54:14 +0000 | [diff] [blame] | 182 | base = pParse->nTab; |
drh | f57b339 | 2001-10-08 13:22:32 +0000 | [diff] [blame] | 183 | openOp = pTab->isTemp ? OP_OpenWrAux : OP_OpenWrite; |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 184 | sqliteVdbeAddOp(v, openOp, base, pTab->tnum); |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 185 | for(i=0; i<nIdx; i++){ |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 186 | sqliteVdbeAddOp(v, openOp, base+i+1, apIdx[i]->tnum); |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | /* Loop over every record that needs updating. We have to load |
drh | 967e8b7 | 2000-06-21 13:59:10 +0000 | [diff] [blame] | 190 | ** the old data for each record to be updated because some columns |
drh | 1ccde15 | 2000-06-17 13:12:39 +0000 | [diff] [blame] | 191 | ** might not change and we will need to copy the old value. |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 192 | ** Also, the old data is needed to delete the old index entires. |
drh | 4a32431 | 2001-12-21 14:30:42 +0000 | [diff] [blame^] | 193 | ** So make the cursor point at the old record. |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 194 | */ |
| 195 | end = sqliteVdbeMakeLabel(v); |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 196 | addr = sqliteVdbeAddOp(v, OP_ListRead, 0, end); |
| 197 | sqliteVdbeAddOp(v, OP_Dup, 0, 0); |
| 198 | sqliteVdbeAddOp(v, OP_MoveTo, base, 0); |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 199 | |
| 200 | /* Delete the old indices for the current record. |
| 201 | */ |
| 202 | for(i=0; i<nIdx; i++){ |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 203 | sqliteVdbeAddOp(v, OP_Dup, 0, 0); |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 204 | pIdx = apIdx[i]; |
drh | 967e8b7 | 2000-06-21 13:59:10 +0000 | [diff] [blame] | 205 | for(j=0; j<pIdx->nColumn; j++){ |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 206 | sqliteVdbeAddOp(v, OP_Column, base, pIdx->aiColumn[j]); |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 207 | } |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 208 | sqliteVdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0); |
drh | 8721ce4 | 2001-11-07 14:22:00 +0000 | [diff] [blame] | 209 | sqliteVdbeAddOp(v, OP_IdxDelete, base+i+1, 0); |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 210 | } |
| 211 | |
drh | 4a32431 | 2001-12-21 14:30:42 +0000 | [diff] [blame^] | 212 | /* If changing the record number, remove the old record number |
| 213 | ** from the top of the stack and replace it with the new one. |
| 214 | */ |
| 215 | if( chngRecno ){ |
| 216 | sqliteVdbeAddOp(v, OP_Pop, 1, 0); |
| 217 | sqliteExprCode(pParse, pRecnoExpr); |
| 218 | sqliteVdbeAddOp(v, OP_AddImm, 0, 0); |
| 219 | } |
| 220 | |
drh | 5a2c2c2 | 2001-11-21 02:21:11 +0000 | [diff] [blame] | 221 | /* Compute new data for this record. |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 222 | */ |
| 223 | for(i=0; i<pTab->nCol; i++){ |
drh | 4a32431 | 2001-12-21 14:30:42 +0000 | [diff] [blame^] | 224 | if( i==pTab->iPKey ){ |
| 225 | sqliteVdbeAddOp(v, OP_Dup, i, 0); |
| 226 | continue; |
| 227 | } |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 228 | j = aXRef[i]; |
| 229 | if( j<0 ){ |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 230 | sqliteVdbeAddOp(v, OP_Column, base, i); |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 231 | }else{ |
| 232 | sqliteExprCode(pParse, pChanges->a[j].pExpr); |
| 233 | } |
| 234 | } |
| 235 | |
drh | 4a32431 | 2001-12-21 14:30:42 +0000 | [diff] [blame^] | 236 | /* If changing the record number, delete the hold record. |
| 237 | */ |
| 238 | if( chngRecno ){ |
| 239 | sqliteVdbeAddOp(v, OP_Delete, 0, 0); |
| 240 | } |
| 241 | |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 242 | /* Insert new index entries that correspond to the new data |
| 243 | */ |
| 244 | for(i=0; i<nIdx; i++){ |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 245 | sqliteVdbeAddOp(v, OP_Dup, pTab->nCol, 0); /* The KEY */ |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 246 | pIdx = apIdx[i]; |
drh | 967e8b7 | 2000-06-21 13:59:10 +0000 | [diff] [blame] | 247 | for(j=0; j<pIdx->nColumn; j++){ |
drh | 4a32431 | 2001-12-21 14:30:42 +0000 | [diff] [blame^] | 248 | int idx = pIdx->aiColumn[j]; |
| 249 | if( idx==pTab->iPKey ){ |
| 250 | sqliteVdbeAddOp(v, OP_Dup, j, 0); |
| 251 | }else{ |
| 252 | sqliteVdbeAddOp(v, OP_Dup, j+pTab->nCol-idx, 0); |
| 253 | } |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 254 | } |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 255 | sqliteVdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0); |
drh | 8721ce4 | 2001-11-07 14:22:00 +0000 | [diff] [blame] | 256 | sqliteVdbeAddOp(v, OP_IdxPut, base+i+1, pIdx->isUnique); |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | /* Write the new data back into the database. |
| 260 | */ |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 261 | sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0); |
| 262 | sqliteVdbeAddOp(v, OP_Put, base, 0); |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 263 | |
drh | 1bee3d7 | 2001-10-15 00:44:35 +0000 | [diff] [blame] | 264 | /* Increment the count of rows affected by the update |
| 265 | */ |
| 266 | if( db->flags & SQLITE_CountRows ){ |
| 267 | sqliteVdbeAddOp(v, OP_AddImm, 1, 0); |
| 268 | } |
| 269 | |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 270 | /* Repeat the above with the next record to be updated, until |
| 271 | ** all record selected by the WHERE clause have been updated. |
| 272 | */ |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 273 | sqliteVdbeAddOp(v, OP_Goto, 0, addr); |
| 274 | sqliteVdbeResolveLabel(v, end); |
drh | a8b38d2 | 2001-11-01 14:41:34 +0000 | [diff] [blame] | 275 | sqliteVdbeAddOp(v, OP_ListReset, 0, 0); |
drh | ecdc753 | 2001-09-23 02:35:53 +0000 | [diff] [blame] | 276 | if( (db->flags & SQLITE_InTrans)==0 ){ |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 277 | sqliteVdbeAddOp(v, OP_Commit, 0, 0); |
drh | 5e00f6c | 2001-09-13 13:46:56 +0000 | [diff] [blame] | 278 | } |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 279 | |
drh | 1bee3d7 | 2001-10-15 00:44:35 +0000 | [diff] [blame] | 280 | /* |
| 281 | ** Return the number of rows that were changed. |
| 282 | */ |
| 283 | if( db->flags & SQLITE_CountRows ){ |
| 284 | sqliteVdbeAddOp(v, OP_ColumnCount, 1, 0); |
| 285 | sqliteVdbeAddOp(v, OP_ColumnName, 0, 0); |
| 286 | sqliteVdbeChangeP3(v, -1, "rows updated", P3_STATIC); |
| 287 | sqliteVdbeAddOp(v, OP_Callback, 1, 0); |
| 288 | } |
| 289 | |
drh | cce7d17 | 2000-05-31 15:34:51 +0000 | [diff] [blame] | 290 | update_cleanup: |
| 291 | sqliteFree(apIdx); |
| 292 | sqliteFree(aXRef); |
| 293 | sqliteIdListDelete(pTabList); |
| 294 | sqliteExprListDelete(pChanges); |
| 295 | sqliteExprDelete(pWhere); |
| 296 | return; |
| 297 | } |