SQLite

Check-in [19e56291]
Login

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

Overview
Comment:During DELETE, if an index entry is missing, do not raise the SQLITE_CORRUPT_INDEX error (added by [f339f31f9e9a856b]) if in "PRAGMA writable_schema=ON" mode.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 19e56291a7344c7aa69e2845f11cb865ee10a6b89a00bbe74b3babbeebe0357b
User & Date: drh 2021-08-11 18:43:54
References
2021-11-04
16:15
Update a test case in corruptN.test to account for the fact that if writable_schema=1 is set, no error is raised if a DELETE statement finds that an index entry is missing ([19e56291a7344c7a]). (check-in: a90c5f0b user: dan tags: trunk)
Context
2021-08-12
14:22
By default, do not use memory mapping to access the temporary files used for external sorts. The old behaviour (to use memory mapping by default) may be restored by building with SQLITE_ENABLE_SORTER_MMAP defined. (check-in: 306694df user: dan tags: trunk)
2021-08-11
18:43
During DELETE, if an index entry is missing, do not raise the SQLITE_CORRUPT_INDEX error (added by [f339f31f9e9a856b]) if in "PRAGMA writable_schema=ON" mode. (check-in: 19e56291 user: drh tags: trunk)
13:48
Do not apply the push-down optimization to CTE subqueries that will be reused in other contexts in where the same optimization is unlikely to be valid. Fix for the bug reported by forum post d496c3d29bc93736. (check-in: a7ce29a6 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

5916
5917
5918
5919
5920
5921
5922
5923

5924
5925
5926
5927
5928
5929
5930
** index opened by cursor P1.
**
** If P5 is not zero, then raise an SQLITE_CORRUPT_INDEX error
** if no matching index entry is found.  This happens when running
** an UPDATE or DELETE statement and the index entry to be updated
** or deleted is not found.  For some uses of IdxDelete
** (example:  the EXCEPT operator) it does not matter that no matching
** entry is found.  For those cases, P5 is zero.

*/
case OP_IdxDelete: {
  VdbeCursor *pC;
  BtCursor *pCrsr;
  int res;
  UnpackedRecord r;








|
>







5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
** index opened by cursor P1.
**
** If P5 is not zero, then raise an SQLITE_CORRUPT_INDEX error
** if no matching index entry is found.  This happens when running
** an UPDATE or DELETE statement and the index entry to be updated
** or deleted is not found.  For some uses of IdxDelete
** (example:  the EXCEPT operator) it does not matter that no matching
** entry is found.  For those cases, P5 is zero.  Also, do not raise
** this (self-correcting and non-critical) error if in writable_schema mode.
*/
case OP_IdxDelete: {
  VdbeCursor *pC;
  BtCursor *pCrsr;
  int res;
  UnpackedRecord r;

5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
  r.default_rc = 0;
  r.aMem = &aMem[pOp->p2];
  rc = sqlite3BtreeIndexMoveto(pCrsr, &r, &res);
  if( rc ) goto abort_due_to_error;
  if( res==0 ){
    rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);
    if( rc ) goto abort_due_to_error;
  }else if( pOp->p5 ){
    rc = sqlite3ReportError(SQLITE_CORRUPT_INDEX, __LINE__, "index corruption");
    goto abort_due_to_error;
  }
  assert( pC->deferredMoveto==0 );
  pC->cacheStatus = CACHE_STALE;
  pC->seekResult = 0;
  break;







|







5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
  r.default_rc = 0;
  r.aMem = &aMem[pOp->p2];
  rc = sqlite3BtreeIndexMoveto(pCrsr, &r, &res);
  if( rc ) goto abort_due_to_error;
  if( res==0 ){
    rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);
    if( rc ) goto abort_due_to_error;
  }else if( pOp->p5 && !sqlite3WritableSchema(db) ){
    rc = sqlite3ReportError(SQLITE_CORRUPT_INDEX, __LINE__, "index corruption");
    goto abort_due_to_error;
  }
  assert( pC->deferredMoveto==0 );
  pC->cacheStatus = CACHE_STALE;
  pC->seekResult = 0;
  break;