Lines Matching refs:pCheck
17466 ExprList *pCheck; /* All CHECK constraints */ member
25729 CheckMutex *pCheck = (CheckMutex*)p; in checkMutexFree() local
25730 pGlobalMutexMethods->xMutexFree(pCheck->mutex); in checkMutexFree()
25731 sqlite3_free(pCheck); in checkMutexFree()
25744 CheckMutex *pCheck = (CheckMutex*)p; in checkMutexEnter() local
25745 if( pCheck->iType==SQLITE_MUTEX_WARNONCONTENTION ){ in checkMutexEnter()
25746 if( SQLITE_OK==pGlobalMutexMethods->xMutexTry(pCheck->mutex) ){ in checkMutexEnter()
25753 pGlobalMutexMethods->xMutexEnter(pCheck->mutex); in checkMutexEnter()
25760 CheckMutex *pCheck = (CheckMutex*)p; in checkMutexTry() local
25761 return pGlobalMutexMethods->xMutexTry(pCheck->mutex); in checkMutexTry()
25768 CheckMutex *pCheck = (CheckMutex*)p; in checkMutexLeave() local
25769 pGlobalMutexMethods->xMutexLeave(pCheck->mutex); in checkMutexLeave()
25798 CheckMutex *pCheck = (CheckMutex*)p; in sqlite3MutexWarnOnContention() local
25799 assert( pCheck->iType==SQLITE_MUTEX_RECURSIVE ); in sqlite3MutexWarnOnContention()
25800 pCheck->iType = SQLITE_MUTEX_WARNONCONTENTION; in sqlite3MutexWarnOnContention()
73941 IntegrityCk *pCheck,
73946 if( !pCheck->mxErr ) return;
73947 pCheck->mxErr--;
73948 pCheck->nErr++;
73950 if( pCheck->errMsg.nChar ){
73951 sqlite3_str_append(&pCheck->errMsg, "\n", 1);
73953 if( pCheck->zPfx ){
73954 sqlite3_str_appendf(&pCheck->errMsg, pCheck->zPfx, pCheck->v1, pCheck->v2);
73956 sqlite3_str_vappendf(&pCheck->errMsg, zFormat, ap);
73958 if( pCheck->errMsg.accError==SQLITE_NOMEM ){
73959 pCheck->mallocFailed = 1;
73970 static int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){
73971 assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 );
73972 return (pCheck->aPgRef[iPg/8] & (1 << (iPg & 0x07)));
73978 static void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){
73979 assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 );
73980 pCheck->aPgRef[iPg/8] |= (1 << (iPg & 0x07));
73992 static int checkRef(IntegrityCk *pCheck, Pgno iPage){
73993 if( iPage>pCheck->nPage || iPage==0 ){
73994 checkAppendMsg(pCheck, "invalid page number %d", iPage);
73997 if( getPageReferenced(pCheck, iPage) ){
73998 checkAppendMsg(pCheck, "2nd reference to page %d", iPage);
74001 if( AtomicLoad(&pCheck->db->u1.isInterrupted) ) return 1;
74002 setPageReferenced(pCheck, iPage);
74013 IntegrityCk *pCheck, /* Integrity check context */
74022 rc = ptrmapGet(pCheck->pBt, iChild, &ePtrmapType, &iPtrmapParent);
74024 if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ) pCheck->mallocFailed = 1;
74025 checkAppendMsg(pCheck, "Failed to read ptrmap key=%d", iChild);
74030 checkAppendMsg(pCheck,
74042 IntegrityCk *pCheck, /* Integrity checking context */
74049 int nErrAtStart = pCheck->nErr;
74050 while( iPage!=0 && pCheck->mxErr ){
74053 if( checkRef(pCheck, iPage) ) break;
74055 if( sqlite3PagerGet(pCheck->pPager, (Pgno)iPage, &pOvflPage, 0) ){
74056 checkAppendMsg(pCheck, "failed to get page %d", iPage);
74063 if( pCheck->pBt->autoVacuum ){
74064 checkPtrmap(pCheck, iPage, PTRMAP_FREEPAGE, 0);
74067 if( n>pCheck->pBt->usableSize/4-2 ){
74068 checkAppendMsg(pCheck,
74075 if( pCheck->pBt->autoVacuum ){
74076 checkPtrmap(pCheck, iFreePage, PTRMAP_FREEPAGE, 0);
74079 checkRef(pCheck, iFreePage);
74090 if( pCheck->pBt->autoVacuum && N>0 ){
74092 checkPtrmap(pCheck, i, PTRMAP_OVERFLOW2, iPage);
74099 if( N && nErrAtStart==pCheck->nErr ){
74100 checkAppendMsg(pCheck,
74175 IntegrityCk *pCheck, /* Context for the sanity check */
74201 const char *saved_zPfx = pCheck->zPfx;
74202 int saved_v1 = pCheck->v1;
74203 int saved_v2 = pCheck->v2;
74208 pBt = pCheck->pBt;
74211 if( checkRef(pCheck, iPage) ) return 0;
74212 pCheck->zPfx = "Page %d: ";
74213 pCheck->v1 = iPage;
74215 checkAppendMsg(pCheck,
74226 checkAppendMsg(pCheck,
74232 checkAppendMsg(pCheck, "free space corruption", rc);
74239 pCheck->zPfx = "On tree page %d cell %d: ";
74259 pCheck->zPfx = "On page %d at right child: ";
74260 checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage);
74263 depth = checkTreePage(pCheck, pgno, &maxKey, maxKey);
74268 heap = pCheck->heap;
74274 for(i=nCell-1; i>=0 && pCheck->mxErr; i--){
74278 pCheck->v2 = i;
74283 checkAppendMsg(pCheck, "Offset %d out of range %d..%d",
74291 checkAppendMsg(pCheck, "Extends off end of page");
74299 checkAppendMsg(pCheck, "Rowid %lld out of order", info.nKey);
74314 checkPtrmap(pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, iPage);
74317 checkList(pCheck, 0, pgnoOvfl, nPage);
74325 checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage);
74328 d2 = checkTreePage(pCheck, pgno, &maxKey, maxKey);
74331 checkAppendMsg(pCheck, "Child page depth differs");
74343 pCheck->zPfx = 0;
74344 if( doCoverageCheck && pCheck->mxErr>0 ){
74349 heap = pCheck->heap;
74399 checkAppendMsg(pCheck,
74414 checkAppendMsg(pCheck,
74423 pCheck->zPfx = saved_zPfx;
74424 pCheck->v1 = saved_v1;
74425 pCheck->v2 = saved_v2;
106872 sqlite3WalkExprList(&sWalker, sParse.pNewTable->pCheck);
107083 sqlite3WalkExprList(&sWalker, pTab->pCheck);
110724 sqlite3ExprListDelete(db, pTable->pCheck);
111648 pTab->pCheck = sqlite3ExprListAppend(pParse, pTab->pCheck, pCheckExpr);
111650 sqlite3ExprListSetName(pParse, pTab->pCheck, &pParse->constraintName, 1);
112355 if( p->pCheck ){
112356 sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);
112360 sqlite3ExprListDelete(db, p->pCheck);
112361 p->pCheck = 0;
112363 markExprListImmutable(p->pCheck);
112624 p->pCheck = sqlite3ExprListDup(db, pCNames, EXPRDUP_REDUCE);
112744 }else if( pTable->pCheck ){
112751 sqlite3ColumnsFromExprList(pParse, pTable->pCheck,
121807 if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
121808 ExprList *pCheck = pTab->pCheck;
121811 for(i=0; i<pCheck->nExpr; i++){
121814 Expr *pExpr = pCheck->a[i].pExpr;
121836 char *zName = pCheck->a[i].zEName;
122865 if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){
127000 if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
127001 ExprList *pCheck = sqlite3ExprListDup(db, pTab->pCheck, 0);
127008 for(k=pCheck->nExpr-1; k>0; k--){
127009 sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0);
127011 sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk,
127021 sqlite3ExprListDelete(db, pCheck);
180426 sqlite3_stmt *pCheck = 0; /* Statement to query database with */
180429 rc = fts3SqlStmt(p, SQL_SEGMENT_IS_APPENDABLE, &pCheck, 0);
180431 sqlite3_bind_int64(pCheck, 1, iEnd);
180432 if( SQLITE_ROW==sqlite3_step(pCheck) ) bRes = 1;
180433 rc = sqlite3_reset(pCheck);
191096 static void rtreeCheckReset(RtreeCheck *pCheck, sqlite3_stmt *pStmt){
191098 if( pCheck->rc==SQLITE_OK ) pCheck->rc = rc;
191110 RtreeCheck *pCheck, /* RtreeCheck object */
191120 if( pCheck->rc==SQLITE_OK ){
191122 pCheck->rc = SQLITE_NOMEM;
191124 pCheck->rc = sqlite3_prepare_v2(pCheck->db, z, -1, &pRet, 0);
191138 static void rtreeCheckAppendMsg(RtreeCheck *pCheck, const char *zFmt, ...){
191141 if( pCheck->rc==SQLITE_OK && pCheck->nErr<RTREE_CHECK_MAX_ERROR ){
191144 pCheck->rc = SQLITE_NOMEM;
191146 pCheck->zReport = sqlite3_mprintf("%z%s%z",
191147 pCheck->zReport, (pCheck->zReport ? "\n" : ""), z
191149 if( pCheck->zReport==0 ){
191150 pCheck->rc = SQLITE_NOMEM;
191153 pCheck->nErr++;
191172 static u8 *rtreeCheckGetNode(RtreeCheck *pCheck, i64 iNode, int *pnNode){
191175 if( pCheck->rc==SQLITE_OK && pCheck->pGetNode==0 ){
191176 pCheck->pGetNode = rtreeCheckPrepare(pCheck,
191178 pCheck->zDb, pCheck->zTab
191182 if( pCheck->rc==SQLITE_OK ){
191183 sqlite3_bind_int64(pCheck->pGetNode, 1, iNode);
191184 if( sqlite3_step(pCheck->pGetNode)==SQLITE_ROW ){
191185 int nNode = sqlite3_column_bytes(pCheck->pGetNode, 0);
191186 const u8 *pNode = (const u8*)sqlite3_column_blob(pCheck->pGetNode, 0);
191189 pCheck->rc = SQLITE_NOMEM;
191195 rtreeCheckReset(pCheck, pCheck->pGetNode);
191196 if( pCheck->rc==SQLITE_OK && pRet==0 ){
191197 rtreeCheckAppendMsg(pCheck, "Node %lld missing from database", iNode);
191217 RtreeCheck *pCheck, /* RtreeCheck object */
191230 if( pCheck->aCheckMapping[bLeaf]==0 ){
191231 pCheck->aCheckMapping[bLeaf] = rtreeCheckPrepare(pCheck,
191232 azSql[bLeaf], pCheck->zDb, pCheck->zTab
191235 if( pCheck->rc!=SQLITE_OK ) return;
191237 pStmt = pCheck->aCheckMapping[bLeaf];
191241 rtreeCheckAppendMsg(pCheck, "Mapping (%lld -> %lld) missing from %s table",
191247 rtreeCheckAppendMsg(pCheck,
191253 rtreeCheckReset(pCheck, pStmt);
191269 RtreeCheck *pCheck,
191279 for(i=0; i<pCheck->nDim; i++){
191284 if( pCheck->bInt ? c1.i>c2.i : c1.f>c2.f ){
191285 rtreeCheckAppendMsg(pCheck,
191294 if( (pCheck->bInt ? c1.i<p1.i : c1.f<p1.f)
191295 || (pCheck->bInt ? c2.i>p2.i : c2.f>p2.f)
191297 rtreeCheckAppendMsg(pCheck,
191315 RtreeCheck *pCheck,
191324 assert( pCheck->nDim>0 );
191326 aNode = rtreeCheckGetNode(pCheck, iNode, &nNode);
191329 rtreeCheckAppendMsg(pCheck,
191338 rtreeCheckAppendMsg(pCheck, "Rtree depth out of range (%d)", iDepth);
191344 if( (4 + nCell*(8 + pCheck->nDim*2*4))>nNode ){
191345 rtreeCheckAppendMsg(pCheck,
191351 u8 *pCell = &aNode[4 + i*(8 + pCheck->nDim*2*4)];
191353 rtreeCheckCellCoord(pCheck, iNode, i, &pCell[8], aParent);
191356 rtreeCheckMapping(pCheck, 0, iVal, iNode);
191357 rtreeCheckNode(pCheck, iDepth-1, &pCell[8], iVal);
191358 pCheck->nNonLeaf++;
191360 rtreeCheckMapping(pCheck, 1, iVal, iNode);
191361 pCheck->nLeaf++;
191377 static void rtreeCheckCount(RtreeCheck *pCheck, const char *zTbl, i64 nExpect){
191378 if( pCheck->rc==SQLITE_OK ){
191380 pCount = rtreeCheckPrepare(pCheck, "SELECT count(*) FROM %Q.'%q%s'",
191381 pCheck->zDb, pCheck->zTab, zTbl
191387 rtreeCheckAppendMsg(pCheck, "Wrong number of entries in %%%s table"
191392 pCheck->rc = sqlite3_finalize(pCount);