1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Add the xIntegrity method to the sqlite3_module object. Implement this

method in RTREE, FTS3/4, and FTS5 so that "PRAGMA integrity_check" also
verifies the correctness of shadow tables associated with those virtual
tables.

FossilOrigin-Name: 17bede8cdefd968210dd8a5a2617acbe12ba2c99fdd5e88c5def8665e7bec2d7
This commit is contained in:
drh
2023-09-06 12:52:00 +00:00
parent 5a05a68315
commit 961c2a9f36
24 changed files with 223 additions and 55 deletions

View File

@ -3502,8 +3502,11 @@ static int rtreeShadowName(const char *zName){
return 0;
}
/* Forward declaration */
static char *rtreeIntegrity(sqlite3_vtab*);
static sqlite3_module rtreeModule = {
3, /* iVersion */
4, /* iVersion */
rtreeCreate, /* xCreate - create a table */
rtreeConnect, /* xConnect - connect to an existing table */
rtreeBestIndex, /* xBestIndex - Determine search strategy */
@ -3526,7 +3529,8 @@ static sqlite3_module rtreeModule = {
rtreeSavepoint, /* xSavepoint */
0, /* xRelease */
0, /* xRollbackTo */
rtreeShadowName /* xShadowName */
rtreeShadowName, /* xShadowName */
rtreeIntegrity /* xIntegrity */
};
static int rtreeSqlInit(
@ -4360,6 +4364,26 @@ static int rtreeCheckTable(
return check.rc;
}
/*
** Implementation of the xIntegrity method for Rtree.
*/
static char *rtreeIntegrity(sqlite3_vtab *pVtab){
Rtree *pRtree = (Rtree*)pVtab;
char *zErr = 0;
int rc;
rc = rtreeCheckTable(pRtree->db, pRtree->zDb, pRtree->zName, &zErr);
if( rc ){
sqlite3_free(zErr);
zErr = sqlite3_mprintf("error code %d while checking RTree %s.%s",
rc, pRtree->zDb, pRtree->zName);
}else if( zErr ){
zErr = sqlite3_mprintf("In RTree %s.%s:\n%z",
pRtree->zDb, pRtree->zName, zErr);
}
return zErr;
}
/*
** Usage:
**