diff options
Diffstat (limited to 'kexi/3rdparty/kexisql3/src/btree.c')
-rw-r--r-- | kexi/3rdparty/kexisql3/src/btree.c | 140 |
1 files changed, 70 insertions, 70 deletions
diff --git a/kexi/3rdparty/kexisql3/src/btree.c b/kexi/3rdparty/kexisql3/src/btree.c index 472d63a6..65cddcd4 100644 --- a/kexi/3rdparty/kexisql3/src/btree.c +++ b/kexi/3rdparty/kexisql3/src/btree.c @@ -126,7 +126,7 @@ ** 8 4 Right child (the Ptr(N+1) value). Omitted on leaves. ** ** The flags define the format of this btree page. The leaf flag means that -** this page has no children. The zerodata flag means that this page carries +** this page has no tqchildren. The zerodata flag means that this page carries ** only keys and no data. The intkey flag means that the key is a integer ** which is stored in the key size entry of the cell header rather than in ** the payload area. @@ -212,7 +212,7 @@ #include <assert.h> /* Round up a number to the next larger multiple of 8. This is used -** to force 8-byte alignment on 64-bit architectures. +** to force 8-byte tqalignment on 64-bit architectures. */ #define ROUND8(x) ((x+7)&~7) @@ -262,9 +262,9 @@ static const char zMagicHeader[] = SQLITE_FILE_HEADER; ** structure is appended and initialized to zero. This structure stores ** information about the page that is decoded from the raw file page. ** -** The pParent field points back to the parent page. This allows us to +** The pParent field points back to the tqparent page. This allows us to ** walk up the BTree from any leaf to the root. Care must be taken to -** unref() the parent page pointer when this page is no longer referenced. +** unref() the tqparent page pointer when this page is no longer referenced. ** The pageDestructor() routine handles that chore. */ struct MemPage { @@ -281,7 +281,7 @@ struct MemPage { u16 maxLocal; /* Copy of Btree.maxLocal or Btree.maxLeaf */ u16 minLocal; /* Copy of Btree.minLocal or Btree.minLeaf */ u16 cellOffset; /* Index in aData of first cell pointer */ - u16 idxParent; /* Index in parent of this node */ + u16 idxParent; /* Index in tqparent of this node */ u16 nFree; /* Number of free bytes on the page */ u16 nCell; /* Number of cells on this page, local and ovfl */ struct _OvflCell { /* Cells that will not fit on aData[] */ @@ -291,7 +291,7 @@ struct MemPage { struct Btree *pBt; /* Pointer back to BTree structure */ u8 *aData; /* Pointer back to the start of the page */ Pgno pgno; /* Page number for this page */ - MemPage *pParent; /* The parent of this page. NULL for root */ + MemPage *pParent; /* The tqparent of this page. NULL for root */ }; /* @@ -443,18 +443,18 @@ static void put4byte(unsigned char *p, u32 v){ #define PTRMAP_ISPAGE(pgsz, pgno) (PTRMAP_PAGENO(pgsz,pgno)==pgno) /* -** The pointer map is a lookup table that identifies the parent page for -** each child page in the database file. The parent page is the page that -** contains a pointer to the child. Every page in the database contains -** 0 or 1 parent pages. (In this context 'database page' refers +** The pointer map is a lookup table that identifies the tqparent page for +** each child page in the database file. The tqparent page is the page that +** contains a pointer to the child. Every page in the database tqcontains +** 0 or 1 tqparent pages. (In this context 'database page' refers ** to any page that is not part of the pointer map itself.) Each pointer map -** entry consists of a single byte 'type' and a 4 byte parent page number. +** entry consists of a single byte 'type' and a 4 byte tqparent page number. ** The PTRMAP_XXX identifiers below are the valid types. ** ** The purpose of the pointer map is to facility moving pages from one ** position in the file to another as part of autovacuum. When a page -** is moved, the pointer in its parent must be updated to point to the -** new location. The pointer map is used to locate the parent page quickly. +** is moved, the pointer in its tqparent must be updated to point to the +** new location. The pointer map is used to locate the tqparent page quickly. ** ** PTRMAP_ROOTPAGE: The database page is a root-page. The page-number is not ** used in this case. @@ -471,7 +471,7 @@ static void put4byte(unsigned char *p, u32 v){ ** page in the overflow page list. ** ** PTRMAP_BTREE: The database page is a non-root btree page. The page number -** identifies the parent page in the btree. +** identifies the tqparent page in the btree. */ #define PTRMAP_ROOTPAGE 1 #define PTRMAP_FREEPAGE 2 @@ -483,10 +483,10 @@ static void put4byte(unsigned char *p, u32 v){ ** Write an entry into the pointer map. ** ** This routine updates the pointer map entry for page number 'key' -** so that it maps to type 'eType' and parent page number 'pgno'. +** so that it maps to type 'eType' and tqparent page number 'pgno'. ** An error code is returned if something goes wrong, otherwise SQLITE_OK. */ -static int ptrmapPut(Btree *pBt, Pgno key, u8 eType, Pgno parent){ +static int ptrmapPut(Btree *pBt, Pgno key, u8 eType, Pgno tqparent){ u8 *pPtrmap; /* The pointer map page */ Pgno iPtrmap; /* The pointer map page number */ int offset; /* Offset in pointer map page */ @@ -503,12 +503,12 @@ static int ptrmapPut(Btree *pBt, Pgno key, u8 eType, Pgno parent){ } offset = PTRMAP_PTROFFSET(pBt->usableSize, key); - if( eType!=pPtrmap[offset] || get4byte(&pPtrmap[offset+1])!=parent ){ - TRACE(("PTRMAP_UPDATE: %d->(%d,%d)\n", key, eType, parent)); + if( eType!=pPtrmap[offset] || get4byte(&pPtrmap[offset+1])!=tqparent ){ + TRACE(("PTRMAP_UPDATE: %d->(%d,%d)\n", key, eType, tqparent)); rc = sqlite3pager_write(pPtrmap); if( rc==SQLITE_OK ){ pPtrmap[offset] = eType; - put4byte(&pPtrmap[offset+1], parent); + put4byte(&pPtrmap[offset+1], tqparent); } } @@ -520,7 +520,7 @@ static int ptrmapPut(Btree *pBt, Pgno key, u8 eType, Pgno parent){ ** Read an entry from the pointer map. ** ** This routine retrieves the pointer map entry for page 'key', writing -** the type and parent page number to *pEType and *pPgno respectively. +** the type and tqparent page number to *pEType and *pPgno respectively. ** An error code is returned if something goes wrong, otherwise SQLITE_OK. */ static int ptrmapGet(Btree *pBt, Pgno key, u8 *pEType, Pgno *pPgno){ @@ -1001,8 +1001,8 @@ static void decodeFlags(MemPage *pPage, int flagByte){ ** Initialize the auxiliary information for a disk block. ** ** The pParent parameter must be a pointer to the MemPage which -** is the parent of the page being initialized. The root of a -** BTree has no parent and so for that page, pParent==NULL. +** is the tqparent of the page being initialized. The root of a +** BTree has no tqparent and so for that page, pParent==NULL. ** ** Return SQLITE_OK on success. If we see that the page does ** not contain a well-formed database page, then return @@ -1012,7 +1012,7 @@ static void decodeFlags(MemPage *pPage, int flagByte){ */ static int initPage( MemPage *pPage, /* The page to be initialized */ - MemPage *pParent /* The parent. Might be NULL */ + MemPage *pParent /* The tqparent. Might be NULL */ ){ int pc; /* Address of a freeblock within pPage->aData[] */ int hdr; /* Offset to beginning of page header */ @@ -1029,7 +1029,7 @@ static int initPage( assert( pPage->pgno==sqlite3pager_pagenumber(pPage->aData) ); assert( pPage->aData == &((unsigned char*)pPage)[-pBt->pageSize] ); if( pPage->pParent!=pParent && (pPage->pParent!=0 || pPage->isInit) ){ - /* The parent page should never change unless the file is corrupt */ + /* The tqparent page should never change unless the file is corrupt */ return SQLITE_CORRUPT_BKPT; } if( pPage->isInit ) return SQLITE_OK; @@ -1286,14 +1286,14 @@ int sqlite3BtreeOpen( #endif } pBt->usableSize = pBt->pageSize - nReserve; - assert( (pBt->pageSize & 7)==0 ); /* 8-byte alignment of pageSize */ + assert( (pBt->pageSize & 7)==0 ); /* 8-byte tqalignment of pageSize */ sqlite3pager_set_pagesize(pBt->pPager, pBt->pageSize); *ppBtree = pBt; return SQLITE_OK; } /* -** Close an open database and invalidate all cursors. +** Close an open database and tqinvalidate all cursors. */ int sqlite3BtreeClose(Btree *pBt){ while( pBt->pCursor ){ @@ -1658,7 +1658,7 @@ int sqlite3BtreeBeginTrans(Btree *pBt, int wrflag){ #ifndef SQLITE_OMIT_AUTOVACUUM /* -** Set the pointer-map entries for all children of page pPage. Also, if +** Set the pointer-map entries for all tqchildren of page pPage. Also, if ** pPage contains cells that point to overflow pages, set the pointer ** map entries for the overflow pages as well. */ @@ -2080,7 +2080,7 @@ int sqlite3BtreeCommitStmt(Btree *pBt){ ** Rollback the active statement subtransaction. If no subtransaction ** is active this routine is a no-op. ** -** All cursors will be invalidated by this operation. Any attempt +** All cursors will be tqinvalidated by this operation. Any attempt ** to use a cursor that was open at the beginning of this operation ** will result in an error. */ @@ -2578,7 +2578,7 @@ static int isRootPage(MemPage *pPage){ } /* -** Move the cursor up to the parent page. +** Move the cursor up to the tqparent page. ** ** pCur->idx is set to the cell index that contains the pointer ** to the page we are coming from. If we are coming from the @@ -3065,7 +3065,7 @@ static int allocatePage( memcpy(&pPrevTrunk->aData[0], &pTrunk->aData[0], 4); } }else{ - /* The trunk page is required by the caller but it contains + /* The trunk page is required by the caller but it tqcontains ** pointers to free-list leaves. The first leaf becomes a trunk ** page in this case. */ @@ -3425,11 +3425,11 @@ static int reparentPage(Btree *pBt, Pgno pgno, MemPage *pNewParent, int idx){ /* -** Change the pParent pointer of all children of pPage to point back +** Change the pParent pointer of all tqchildren of pPage to point back ** to pPage. ** ** In other words, for every child of pPage, invoke reparentPage() -** to make sure that each child knows that pPage is its parent. +** to make sure that each child knows that pPage is its tqparent. ** ** This routine gets called after you memcpy() one page into ** another. @@ -3644,7 +3644,7 @@ static void assemblePage( /* Forward reference */ static int balance(MemPage*, int); -#ifndef SQLITE_OMIT_QUICKBALANCE +#ifndef SQLITE_OMIT_TQUICKBALANCE /* ** This version of balance() handles the common special case where ** a new entry is being inserted on the extreme right-end of the @@ -3659,7 +3659,7 @@ static int balance(MemPage*, int); ** fill up. On average. ** ** pPage is the leaf page which is the right-most page in the tree. -** pParent is its parent. pPage must have a single overflow entry +** pParent is its tqparent. pPage must have a single overflow entry ** which is also the right-most entry on the page. */ static int balance_quick(MemPage *pPage, MemPage *pParent){ @@ -3670,9 +3670,9 @@ static int balance_quick(MemPage *pPage, MemPage *pParent){ int szCell; CellInfo info; Btree *pBt = pPage->pBt; - int parentIdx = pParent->nCell; /* pParent new divider cell index */ - int parentSize; /* Size of new divider cell */ - u8 parentCell[64]; /* Space for the new divider cell */ + int tqparentIdx = pParent->nCell; /* pParent new divider cell index */ + int tqparentSize; /* Size of new divider cell */ + u8 tqparentCell[64]; /* Space for the new divider cell */ /* Allocate a new page. Insert the overflow cell from pPage ** into it. Then remove the overflow cell from pPage. @@ -3687,7 +3687,7 @@ static int balance_quick(MemPage *pPage, MemPage *pParent){ assemblePage(pNew, 1, &pCell, &szCell); pPage->nOverflow = 0; - /* Set the parent of the newly allocated page to pParent. */ + /* Set the tqparent of the newly allocated page to pParent. */ pNew->pParent = pParent; sqlite3pager_ref(pParent->aData); @@ -3697,16 +3697,16 @@ static int balance_quick(MemPage *pPage, MemPage *pParent){ */ assert( pPage->nCell>0 ); parseCellPtr(pPage, findCell(pPage, pPage->nCell-1), &info); - rc = fillInCell(pParent, parentCell, 0, info.nKey, 0, 0, &parentSize); + rc = fillInCell(pParent, tqparentCell, 0, info.nKey, 0, 0, &tqparentSize); if( rc!=SQLITE_OK ){ return rc; } - assert( parentSize<64 ); - rc = insertCell(pParent, parentIdx, parentCell, parentSize, 0, 4); + assert( tqparentSize<64 ); + rc = insertCell(pParent, tqparentIdx, tqparentCell, tqparentSize, 0, 4); if( rc!=SQLITE_OK ){ return rc; } - put4byte(findOverflowCell(pParent,parentIdx), pPage->pgno); + put4byte(findOverflowCell(pParent,tqparentIdx), pPage->pgno); put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew); #ifndef SQLITE_OMIT_AUTOVACUUM @@ -3726,13 +3726,13 @@ static int balance_quick(MemPage *pPage, MemPage *pParent){ } #endif - /* Release the reference to the new page and balance the parent page, + /* Release the reference to the new page and balance the tqparent page, ** in case the divider cell inserted caused it to become overfull. */ releasePage(pNew); return balance(pParent, 0); } -#endif /* SQLITE_OMIT_QUICKBALANCE */ +#endif /* SQLITE_OMIT_TQUICKBALANCE */ /* ** The ISAUTOVACUUM macro is used within balance_nonroot() to determine @@ -3752,7 +3752,7 @@ static int balance_quick(MemPage *pPage, MemPage *pParent){ ** of pPage so that all pages have about the same amount of free space. ** Usually NN siblings on either side of pPage is used in the balancing, ** though more siblings might come from one side if pPage is the first -** or last child of its parent. If pPage has fewer than 2*NN siblings +** or last child of its tqparent. If pPage has fewer than 2*NN siblings ** (something which can only happen if pPage is the root page or a ** child of root) then all available siblings participate in the balancing. ** @@ -3768,16 +3768,16 @@ static int balance_quick(MemPage *pPage, MemPage *pParent){ ** if the page is overfull. Part of the job of this routine is to ** make sure all Cells for pPage once again fit in pPage->aData[]. ** -** In the course of balancing the siblings of pPage, the parent of pPage +** In the course of balancing the siblings of pPage, the tqparent of pPage ** might become overfull or underfull. If that happens, then this routine -** is called recursively on the parent. +** is called recursively on the tqparent. ** ** If this routine fails for any reason, it might leave the database ** in a corrupted state. So if this routine fails, the database should ** be rolled back. */ static int balance_nonroot(MemPage *pPage){ - MemPage *pParent; /* The parent of pPage */ + MemPage *pParent; /* The tqparent of pPage */ Btree *pBt; /* The whole database */ int nCell = 0; /* Number of cells in apCell[] */ int nMaxCells = 0; /* Allocated size of apCell, szCell, aFrom. */ @@ -3812,7 +3812,7 @@ static int balance_nonroot(MemPage *pPage){ #endif /* - ** Find the parent page. + ** Find the tqparent page. */ assert( pPage->isInit ); assert( sqlite3pager_iswriteable(pPage->aData) ); @@ -3822,7 +3822,7 @@ static int balance_nonroot(MemPage *pPage){ assert( pParent ); TRACE(("BALANCE: begin page %d child of %d\n", pPage->pgno, pParent->pgno)); -#ifndef SQLITE_OMIT_QUICKBALANCE +#ifndef SQLITE_OMIT_TQUICKBALANCE /* ** A special case: If a new entry has just been inserted into a ** table (that is, a btree with integer keys and all data at the leaves) @@ -3848,7 +3848,7 @@ static int balance_nonroot(MemPage *pPage){ #endif /* - ** Find the cell in the parent page whose left child points back + ** Find the cell in the tqparent page whose left child points back ** to pPage. The "idx" variable is the index of that cell. If pPage ** is the rightmost child of pParent then set idx to pParent->nCell */ @@ -3879,7 +3879,7 @@ static int balance_nonroot(MemPage *pPage){ ** the siblings. An attempt is made to find NN siblings on either ** side of pPage. More siblings are taken from one side, however, if ** pPage there are fewer than NN siblings on the other side. If pParent - ** has NB or fewer children then all children of pParent are taken. + ** has NB or fewer tqchildren then all tqchildren of pParent are taken. */ nxDiv = idx - NN; if( nxDiv + NB > pParent->nCell ){ @@ -3911,7 +3911,7 @@ static int balance_nonroot(MemPage *pPage){ } /* Make nMaxCells a multiple of 2 in order to preserve 8-byte - ** alignment */ + ** tqalignment */ nMaxCells = (nMaxCells + 1)&~1; /* @@ -3930,13 +3930,13 @@ static int balance_nonroot(MemPage *pPage){ } szCell = (int*)&apCell[nMaxCells]; aCopy[0] = (u8*)&szCell[nMaxCells]; - assert( ((aCopy[0] - (u8*)apCell) & 7)==0 ); /* 8-byte alignment required */ + assert( ((aCopy[0] - (u8*)apCell) & 7)==0 ); /* 8-byte tqalignment required */ for(i=1; i<NB; i++){ aCopy[i] = &aCopy[i-1][pBt->pageSize+ROUND8(sizeof(MemPage))]; - assert( ((aCopy[i] - (u8*)apCell) & 7)==0 ); /* 8-byte alignment required */ + assert( ((aCopy[i] - (u8*)apCell) & 7)==0 ); /* 8-byte tqalignment required */ } aSpace = &aCopy[NB-1][pBt->pageSize+ROUND8(sizeof(MemPage))]; - assert( ((aSpace - (u8*)apCell) & 7)==0 ); /* 8-byte alignment required */ + assert( ((aSpace - (u8*)apCell) & 7)==0 ); /* 8-byte tqalignment required */ #ifndef SQLITE_OMIT_AUTOVACUUM if( pBt->autoVacuum ){ aFrom = &aSpace[5*pBt->pageSize]; @@ -4199,7 +4199,7 @@ static int balance_nonroot(MemPage *pPage){ #ifndef SQLITE_OMIT_AUTOVACUUM /* If this is an auto-vacuum database, update the pointer map entries ** that point to the siblings that were rearranged. These can be: left - ** children of cells, the right-child of the page, or overflow pages + ** tqchildren of cells, the right-child of the page, or overflow pages ** pointed to by cells. */ if( pBt->autoVacuum ){ @@ -4218,7 +4218,7 @@ static int balance_nonroot(MemPage *pPage){ j = cntNew[i]; /* If the sibling page assembled above was not the right-most sibling, - ** insert a divider cell into the parent page. + ** insert a divider cell into the tqparent page. */ if( i<nNew-1 && j<nCell ){ u8 *pCell; @@ -4284,7 +4284,7 @@ static int balance_nonroot(MemPage *pPage){ } /* - ** Reparent children of all cells. + ** Retqparent tqchildren of all cells. */ for(i=0; i<nNew; i++){ rc = reparentChildPages(apNew[i]); @@ -4294,9 +4294,9 @@ static int balance_nonroot(MemPage *pPage){ if( rc!=SQLITE_OK ) goto balance_cleanup; /* - ** Balance the parent page. Note that the current page (pPage) might + ** Balance the tqparent page. Note that the current page (pPage) might ** have been added to the freelist so it might no longer be initialized. - ** But the parent page will always be initialized. + ** But the tqparent page will always be initialized. */ assert( pParent->isInit ); /* assert( pPage->isInit ); // No! pPage might have been added to freelist */ @@ -4376,7 +4376,7 @@ static int balance_shallower(MemPage *pPage){ szCell[i] = cellSizePtr(pChild, apCell[i]); } assemblePage(pPage, pChild->nCell, apCell, szCell); - /* Copy the right-pointer of the child to the parent. */ + /* Copy the right-pointer of the child to the tqparent. */ put4byte(&pPage->aData[pPage->hdrOffset+8], get4byte(&pChild->aData[pChild->hdrOffset+8])); freePage(pChild); @@ -4433,10 +4433,10 @@ static int balance_deeper(MemPage *pPage){ Pgno pgnoChild; /* Page number of the new child page */ Btree *pBt; /* The BTree */ int usableSize; /* Total usable size of a page */ - u8 *data; /* Content of the parent page */ + u8 *data; /* Content of the tqparent page */ u8 *cdata; /* Content of the child page */ - int hdr; /* Offset to page header in parent */ - int brk; /* Offset to content of first cell in parent */ + int hdr; /* Offset to page header in tqparent */ + int brk; /* Offset to content of first cell in tqparent */ assert( pPage->pParent==0 ); assert( pPage->nOverflow>0 ); @@ -4842,7 +4842,7 @@ int sqlite3BtreeCreateTable(Btree *pBt, int *piTable, int flags){ } /* -** Erase the given database page and all its children. Return +** Erase the given database page and all its tqchildren. Return ** the page to the freelist. */ static int clearDatabasePage( @@ -5136,7 +5136,7 @@ static int btreePageDump(Btree *pBt, int pgno, int recursive, MemPage *pParent){ pPage->leaf = (c & PTF_LEAF)!=0; pPage->hasData = !(pPage->zeroData || (!pPage->leaf && pPage->leafData)); nCell = get2byte(&data[hdr+3]); - sqlite3DebugPrintf("PAGE %d: flags=0x%02x frag=%d parent=%d\n", pgno, + sqlite3DebugPrintf("PAGE %d: flags=0x%02x frag=%d tqparent=%d\n", pgno, data[hdr], data[hdr+7], (pPage->isInit && pPage->pParent) ? pPage->pParent->pgno : 0); assert( hdr == (pgno==1 ? 100 : 0) ); @@ -5353,7 +5353,7 @@ static void checkPtrmap( IntegrityCk *pCheck, /* Integrity check context */ Pgno iChild, /* Child page number */ u8 eType, /* Expected pointer map type */ - Pgno iParent, /* Expected pointer map parent page number */ + Pgno iParent, /* Expected pointer map tqparent page number */ char *zContext /* Context description (used for error msg) */ ){ int rc; @@ -5457,8 +5457,8 @@ static void checkList( ** NO 3. Make sure no key is less than or equal to zLowerBound. ** NO 4. Make sure no key is greater than or equal to zUpperBound. ** 5. Check the integrity of overflow pages. -** 6. Recursively call checkTreePage on all children. -** 7. Verify that the depth of all children is the same. +** 6. Recursively call checkTreePage on all tqchildren. +** 7. Verify that the depth of all tqchildren is the same. ** 8. Make sure this page is at least 33% full or else it is ** the root of the tree. */ |