Lines Matching defs:pCheck
15771 ExprList *pCheck; /* All CHECK constraints */
23616 CheckMutex *pCheck = (CheckMutex*)p;
23617 pGlobalMutexMethods->xMutexFree(pCheck->mutex);
23618 sqlite3_free(pCheck);
23631 CheckMutex *pCheck = (CheckMutex*)p;
23632 if( pCheck->iType==SQLITE_MUTEX_WARNONCONTENTION ){
23633 if( SQLITE_OK==pGlobalMutexMethods->xMutexTry(pCheck->mutex) ){
23640 pGlobalMutexMethods->xMutexEnter(pCheck->mutex);
23647 CheckMutex *pCheck = (CheckMutex*)p;
23648 return pGlobalMutexMethods->xMutexTry(pCheck->mutex);
23655 CheckMutex *pCheck = (CheckMutex*)p;
23656 pGlobalMutexMethods->xMutexLeave(pCheck->mutex);
23685 CheckMutex *pCheck = (CheckMutex*)p;
23686 assert( pCheck->iType==SQLITE_MUTEX_RECURSIVE );
23687 pCheck->iType = SQLITE_MUTEX_WARNONCONTENTION;
69488 IntegrityCk *pCheck,
69493 if( !pCheck->mxErr ) return;
69494 pCheck->mxErr--;
69495 pCheck->nErr++;
69497 if( pCheck
69498 sqlite3StrAccumAppend(&pCheck->errMsg, "\n", 1);
69500 if( pCheck->zPfx ){
69501 sqlite3XPrintf(&pCheck->errMsg, pCheck->zPfx, pCheck->v1, pCheck->v2);
69503 sqlite3VXPrintf(&pCheck->errMsg, zFormat, ap);
69505 if( pCheck->errMsg.accError==STRACCUM_NOMEM ){
69506 pCheck->mallocFailed = 1;
69517 static int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){
69518 assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 );
69519 return (pCheck->aPgRef[iPg/8] & (1 << (iPg & 0x07)));
69525 static void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){
69526 assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 );
69527 pCheck->aPgRef[iPg/8] |= (1 << (iPg & 0x07));
69533 ** reference to the page, add an error message to pCheck->zErrMsg.
69539 static int checkRef(IntegrityCk *pCheck, Pgno iPage){
69541 if( iPage>pCheck->nPage ){
69542 checkAppendMsg(pCheck, "invalid page number %d", iPage);
69545 if( getPageReferenced(pCheck, iPage) ){
69546 checkAppendMsg(pCheck, "2nd reference to page %d", iPage);
69549 setPageReferenced(pCheck, iPage);
69557 ** to pCheck.
69560 IntegrityCk *pCheck, /* Integrity check context */
69569 rc = ptrmapGet(pCheck->pBt, iChild, &ePtrmapType, &iPtrmapParent);
69571 if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ) pCheck->mallocFailed = 1;
69572 checkAppendMsg(pCheck, "Failed to read ptrmap key=%d", iChild);
69577 checkAppendMsg(pCheck,
69589 IntegrityCk *pCheck, /* Integrity checking context */
69597 while( N-- > 0 && pCheck->mxErr ){
69601 checkAppendMsg(pCheck,
69606 if( checkRef(pCheck, iPage) ) break;
69607 if( sqlite3PagerGet(pCheck->pPager, (Pgno)iPage, &pOvflPage, 0) ){
69608 checkAppendMsg(pCheck, "failed to get page %d", iPage);
69615 if( pCheck->pBt->autoVacuum ){
69616 checkPtrmap(pCheck, iPage, PTRMAP_FREEPAGE, 0);
69619 if( n>(int)pCheck->pBt->usableSize/4-2 ){
69620 checkAppendMsg(pCheck,
69627 if( pCheck->pBt->autoVacuum ){
69628 checkPtrmap(pCheck, iFreePage, PTRMAP_FREEPAGE, 0);
69631 checkRef(pCheck, iFreePage);
69642 if( pCheck->pBt->autoVacuum && N>0 ){
69644 checkPtrmap(pCheck, i, PTRMAP_OVERFLOW2, iPage);
69652 checkAppendMsg(pCheck, "free-page count in header is too small");
69725 IntegrityCk *pCheck, /* Context for the sanity check */
69751 const char *saved_zPfx = pCheck->zPfx;
69752 int saved_v1 = pCheck->v1;
69753 int saved_v2 = pCheck->v2;
69758 pBt = pCheck->pBt;
69761 if( checkRef(pCheck, iPage) ) return 0;
69762 pCheck->zPfx = "Page %d: ";
69763 pCheck->v1 = iPage;
69765 checkAppendMsg(pCheck,
69776 checkAppendMsg(pCheck,
69784 pCheck->zPfx = "On tree page %d cell %d: ";
69804 pCheck->zPfx = "On page %d at right child: ";
69805 checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage);
69808 depth = checkTreePage(pCheck, pgno, &maxKey, maxKey);
69813 heap = pCheck->heap;
69819 for(i=nCell-1; i>=0 && pCheck->mxErr; i--){
69823 pCheck->v2 = i;
69828 checkAppendMsg(pCheck, "Offset %d out of range %d..%d",
69836 checkAppendMsg(pCheck, "Extends off end of page");
69844 checkAppendMsg(pCheck, "Rowid %lld out of order", info.nKey);
69859 checkPtrmap(pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, iPage);
69862 checkList(pCheck, 0, pgnoOvfl, nPage);
69870 checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage);
69873 d2 = checkTreePage(pCheck, pgno, &maxKey, maxKey);
69876 checkAppendMsg(pCheck, "Child page depth differs");
69888 pCheck->zPfx = 0;
69889 if( doCoverageCheck && pCheck->mxErr>0 ){
69894 heap = pCheck->heap;
69944 checkAppendMsg(pCheck,
69959 checkAppendMsg(pCheck,
69968 pCheck->zPfx = saved_zPfx;
69969 pCheck->v1 = saved_v1;
69970 pCheck->v2 = saved_v2;
102255 sqlite3ExprListDelete(db, pTable->pCheck);
102997 pTab->pCheck = sqlite3ExprListAppend(pParse, pTab->pCheck, pCheckExpr);
102999 sqlite3ExprListSetName(pParse, pTab->pCheck, &pParse->constraintName, 1);
103513 if( p->pCheck ){
103514 sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);
103738 p->pCheck = sqlite3ExprListDup(db, pCNames, EXPRDUP_REDUCE);
103848 if( pTable->pCheck ){
103851 ** arglist which is stored in pTable->pCheck. The pCheck field
103855 sqlite3ColumnsFromExprList(pParse, pTable->pCheck,
112169 if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
112170 ExprList *pCheck = pTab->pCheck;
112173 for(i=0; i<pCheck->nExpr; i++){
112175 Expr *pExpr = pCheck->a[i].pExpr;
112182 char *zName = pCheck->a[i].zName;
112937 if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){
116876 if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
116877 ExprList *pCheck = sqlite3ExprListDup(db, pTab->pCheck, 0);
116885 for(k=pCheck->nExpr-1; k>0; k--){
116886 sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0);
116888 sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk,
116899 sqlite3ExprListDelete(db, pCheck);
163030 sqlite3_stmt *pCheck = 0; /* Statement to query database with */
163033 rc = fts3SqlStmt(p, SQL_SEGMENT_IS_APPENDABLE, &pCheck, 0);
163035 sqlite3_bind_int64(pCheck, 1, iEnd);
163036 if( SQLITE_ROW==sqlite3_step(pCheck) ) bRes = 1;
163037 rc = sqlite3_reset(pCheck);
170683 static void rtreeCheckReset(RtreeCheck *pCheck, sqlite3_stmt *pStmt){
170685 if( pCheck->rc==SQLITE_OK ) pCheck->rc = rc;
170697 RtreeCheck *pCheck, /* RtreeCheck object */
170707 if( pCheck->rc==SQLITE_OK ){
170709 pCheck->rc = SQLITE_NOMEM;
170711 pCheck->rc = sqlite3_prepare_v2(pCheck
170723 ** appends it to the report being accumuated in pCheck.
170725 static void rtreeCheckAppendMsg(RtreeCheck *pCheck, const char *zFmt, ...){
170728 if( pCheck->rc==SQLITE_OK && pCheck->nErr<RTREE_CHECK_MAX_ERROR ){
170731 pCheck->rc = SQLITE_NOMEM;
170733 pCheck->zReport = sqlite3_mprintf("%z%s%z",
170734 pCheck->zReport, (pCheck->zReport ? "\n" : ""), z
170736 if( pCheck->zReport==0 ){
170737 pCheck->rc = SQLITE_NOMEM;
170740 pCheck->nErr++;
170759 static u8 *rtreeCheckGetNode(RtreeCheck *pCheck, i64 iNode, int *pnNode){
170762 assert( pCheck->rc==SQLITE_OK );
170763 if( pCheck->pGetNode==0 ){
170764 pCheck->pGetNode = rtreeCheckPrepare(pCheck,
170766 pCheck->zDb, pCheck->zTab
170770 if( pCheck->rc==SQLITE_OK ){
170771 sqlite3_bind_int64(pCheck->pGetNode, 1, iNode);
170772 if( sqlite3_step(pCheck->pGetNode)==SQLITE_ROW ){
170773 int nNode = sqlite3_column_bytes(pCheck->pGetNode, 0);
170774 const u8 *pNode = (const u8*)sqlite3_column_blob(pCheck->pGetNode, 0);
170777 pCheck->rc = SQLITE_NOMEM;
170783 rtreeCheckReset(pCheck, pCheck->pGetNode);
170784 if( pCheck->rc==SQLITE_OK && pRet==0 ){
170785 rtreeCheckAppendMsg(pCheck, "Node %lld missing from database", iNode);
170805 RtreeCheck *pCheck, /* RtreeCheck object */
170818 if( pCheck->aCheckMapping[bLeaf]==0 ){
170819 pCheck->aCheckMapping[bLeaf] = rtreeCheckPrepare(pCheck,
170820 azSql[bLeaf], pCheck->zDb, pCheck->zTab
170823 if( pCheck->rc!=SQLITE_OK ) return;
170825 pStmt = pCheck->aCheckMapping[bLeaf];
170829 rtreeCheckAppendMsg(pCheck, "Mapping (%lld -> %lld) missing from %s table",
170835 rtreeCheckAppendMsg(pCheck,
170841 rtreeCheckReset(pCheck, pStmt);
170857 RtreeCheck *pCheck,
170867 for(i=0; i<pCheck->nDim; i++){
170872 if( pCheck->bInt ? c1.i>c2.i : c1.f>c2.f ){
170873 rtreeCheckAppendMsg(pCheck,
170882 if( (pCheck->bInt ? c1.i<p1.i : c1.f<p1.f)
170883 || (pCheck->bInt ? c2.i>p2.i : c2.f>p2.f)
170885 rtreeCheckAppendMsg(pCheck,
170903 RtreeCheck *pCheck,
170912 assert( pCheck->nDim>0 );
170914 aNode = rtreeCheckGetNode(pCheck, iNode, &nNode);
170917 rtreeCheckAppendMsg(pCheck,
170926 rtreeCheckAppendMsg(pCheck, "Rtree depth out of range (%d)", iDepth);
170932 if( (4 + nCell*(8 + pCheck->nDim*2*4))>nNode ){
170933 rtreeCheckAppendMsg(pCheck,
170939 u8 *pCell = &aNode[4 + i*(8 + pCheck->nDim*2*4)];
170941 rtreeCheckCellCoord(pCheck, iNode, i, &pCell[8], aParent);
170944 rtreeCheckMapping(pCheck, 0, iVal, iNode);
170945 rtreeCheckNode(pCheck, iDepth-1, &pCell[8], iVal);
170946 pCheck->nNonLeaf++;
170948 rtreeCheckMapping(pCheck, 1, iVal, iNode);
170949 pCheck->nLeaf++;
170965 static void rtreeCheckCount(RtreeCheck *pCheck, const char *zTbl, i64 nExpect){
170966 if( pCheck->rc==SQLITE_OK ){
170968 pCount = rtreeCheckPrepare(pCheck, "SELECT count(*) FROM %Q.'%q%s'",
170969 pCheck->zDb, pCheck->zTab, zTbl
170975 rtreeCheckAppendMsg(pCheck, "Wrong number of entries in %%%s table"
170980 pCheck->rc = sqlite3_finalize(pCount);