SQLite

Check-in [3f9887d4]
Login

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

Overview
Comment:Foreign key constraint failures should return SQLITE_CONSTRAINT_FOREIGNKEY even if there is a RETURNING clause. See forum thread e6be6e82c86aa59b.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3f9887d4a58cbfdbabf2a37e975c81ba660f373414058920b379f3a81e6e1c2c
User & Date: drh 2022-03-14 16:54:05
References
2022-03-31
11:12
Refinement to [3f9887d4a58cbfdb]: The SQLITE_CONSTRAINT error should only be returned if the prepared statement came from sqlite3_prepare_v2(). The legacy sqlite3_prepare() is documented to return only SQLITE_ERROR. (check-in: f2d9262e user: drh tags: trunk)
Context
2022-03-14
20:31
Disable trigger coding while running sqlite3_declare_vtab(). dbsqlfuzz 97e1865771b4226f29e6e482411c1cae14133f50 (check-in: 387ab17b user: drh tags: trunk)
16:54
Foreign key constraint failures should return SQLITE_CONSTRAINT_FOREIGNKEY even if there is a RETURNING clause. See forum thread e6be6e82c86aa59b. (check-in: 3f9887d4 user: drh tags: trunk)
2022-03-11
15:42
Add a comment linking a part of the UPDATE constraint checking code to one of the corresponding TH3 test cases. (check-in: 0606e8e9 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbeaux.c.

2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
  sqlite3 *db = p->db;
  if( (deferred && (db->nDeferredCons+db->nDeferredImmCons)>0) 
   || (!deferred && p->nFkConstraint>0) 
  ){
    p->rc = SQLITE_CONSTRAINT_FOREIGNKEY;
    p->errorAction = OE_Abort;
    sqlite3VdbeError(p, "FOREIGN KEY constraint failed");
    return SQLITE_ERROR;
  }
  return SQLITE_OK;
}
#endif

/*
** This routine is called the when a VDBE tries to halt.  If the VDBE







|







2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
  sqlite3 *db = p->db;
  if( (deferred && (db->nDeferredCons+db->nDeferredImmCons)>0) 
   || (!deferred && p->nFkConstraint>0) 
  ){
    p->rc = SQLITE_CONSTRAINT_FOREIGNKEY;
    p->errorAction = OE_Abort;
    sqlite3VdbeError(p, "FOREIGN KEY constraint failed");
    return SQLITE_CONSTRAINT_FOREIGNKEY;
  }
  return SQLITE_OK;
}
#endif

/*
** This routine is called the when a VDBE tries to halt.  If the VDBE