Lines Matching defs:pNode
23712 os2ShmNode *pNode, /* Apply locks to this open shared-memory segment */
23722 assert( sqlite3_mutex_held(pNode->mutex) || pNode->nRef==0 );
23735 rc = DosSetFileLocks(pNode->hLockFile,
23740 rc = DosSetFileLocks(pNode->hLockFile,
23746 pNode->hLockFile,
23751 ERR_TRACE(rc, ("os2ShmSystemLock: %d %s\n", rc, pNode->shmBaseName))
23764 os2ShmNode *pNode;
23788 for( pNode = os2ShmNodeList;
23789 pNode && stricmp(shmName, pNode->shmBaseName) != 0;
23790 pNode = pNode->pNext ) ;
23793 if( !pNode ) {
23794 pNode = sqlite3_malloc( sizeof(*pNode) + cbShmName );
23795 if( pNode ) {
23796 memset(pNode, 0, sizeof(*pNode) );
23797 pNode->szRegion = szRegion;
23798 pNode->hLockFile = (HFILE)-1;
23799 strcpy(pNode->shmBaseName, shmName);
23802 if( DosDupHandle(fd->h, &pNode->hLockFile) != 0 ) {
23805 if( DosOpen((PSZ)shmName, &pNode->hLockFile, &action, 0, FILE_NORMAL,
23811 sqlite3_free(pNode);
23814 pNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
23815 if( !pNode->mutex ) {
23816 sqlite3_free(pNode);
23825 pNode->pNext = os2ShmNodeList;
23826 os2ShmNodeList = pNode;
23828 pNode = NULL;
23830 } else if( pNode->szRegion != szRegion ) {
23832 pNode = NULL;
23835 if( pNode ) {
23836 sqlite3_mutex_enter(pNode->mutex);
23840 pLink->pShmNode = pNode;
23841 pLink->pNext = pNode->pFirst;
23842 pNode->pFirst = pLink;
23843 pNode->nRef++;
23847 sqlite3_mutex_leave(pNode->mutex);
23868 os2ShmNode *pNode;
23876 pNode = *ppNode;
23878 if( pNode->nRef == 0 ) {
23879 *ppNode = pNode->pNext;
23881 if( pNode->apRegion ) {
23883 os2ShmSystemLock(pNode, _SHM_WRLCK_WAIT, OS2_SHM_DMS, 1);
23885 while( pNode->nRegion-- ) {
23889 DosFreeMem(pNode->apRegion[pNode->nRegion]);
23892 (int)GetCurrentProcessId(), pNode->nRegion,
23897 os2ShmSystemLock(pNode, _SHM_UNLCK, OS2_SHM_DMS, 1);
23899 sqlite3_free(pNode->apRegion);
23902 DosClose(pNode->hLockFile);
23908 sprintf(fileName, "%s-lck", pNode->shmBaseName + 10);
23916 sqlite3_mutex_free(pNode->mutex);
23918 sqlite3_free(pNode);
23921 ppNode = &pNode->pNext;
23956 os2ShmNode *pNode;
23967 pNode = pFile->pShmLink->pShmNode ;
23969 sqlite3_mutex_enter(pNode->mutex);
23971 assert( szRegion==pNode->szRegion );
23974 if( iRegion >= pNode->nRegion ) {
23976 os2ShmSystemLock(pNode, _SHM_WRLCK_WAIT, OS2_SHM_DMS, 1);
23979 pNode->apRegion, (iRegion + 1) * sizeof(apRegion[0]));
23982 pNode->apRegion = apRegion;
23984 while( pNode->nRegion <= iRegion ) {
23986 pNode->shmBaseName, pNode->nRegion);
24002 apRegion[pNode->nRegion++] = pvTemp;
24006 for( n = pNode->nRegion; n <= iRegion; n++ )
24007 pNode->apRegion[n] = NULL;
24010 *pp = pNode->apRegion[iRegion];
24016 os2ShmSystemLock(pNode, _SHM_UNLCK, OS2_SHM_DMS, 1);
24020 *pp = pNode->apRegion[iRegion];
24023 sqlite3_mutex_leave(pNode->mutex);
24049 os2ShmNode *pNode = pLink->pShmNode;
24051 sqlite3_mutex_enter(pNode->mutex);
24053 for( ppLink = &pNode->pFirst;
24061 nRef = --pNode->nRef;
24064 pNode->shmBaseName))
24070 sqlite3_mutex_leave(pNode->mutex);
130373 RtreeNode *pNode; /* Node cursor is currently pointing at */
130374 int iCell; /* Index of current cell in pNode */
130426 #define NCELL(pNode) readInt16(&(pNode)->zData[2])
130578 ** Add node pNode to the node hash table.
130580 static void nodeHashInsert(Rtree *pRtree, RtreeNode *pNode){
130582 assert( pNode->pNext==0 );
130583 iHash = nodeHash(pNode->iNode);
130584 pNode->pNext = pRtree->aHash[iHash];
130585 pRtree->aHash[iHash] = pNode;
130589 ** Remove node pNode from the node hash table.
130591 static void nodeHashDelete(Rtree *pRtree, RtreeNode *pNode){
130593 if( pNode->iNode!=0 ){
130594 pp = &pRtree->aHash[nodeHash(pNode->iNode)];
130595 for( ; (*pp)!=pNode; pp = &(*pp)->pNext){ assert(*pp); }
130596 *pp = pNode->pNext;
130597 pNode->pNext = 0;
130608 RtreeNode *pNode;
130609 pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode) + pRtree->iNodeSize);
130610 if( pNode ){
130611 memset(pNode, 0, sizeof(RtreeNode) + pRtree->iNodeSize);
130612 pNode->zData = (u8 *)&pNode[1];
130613 pNode->nRef = 1;
130614 pNode->pParent = pParent;
130615 pNode->isDirty = 1;
130618 return pNode;
130633 RtreeNode *pNode;
130638 if( (pNode = nodeHashLookup(pRtree, iNode)) ){
130639 assert( !pParent || !pNode->pParent || pNode->pParent==pParent );
130640 if( pParent && !pNode->pParent ){
130642 pNode->pParent = pParent;
130644 pNode->nRef++;
130645 *ppNode = pNode;
130654 pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize);
130655 if( !pNode ){
130658 pNode->pParent = pParent;
130659 pNode->zData = (u8 *)&pNode[1];
130660 pNode->nRef = 1;
130661 pNode->iNode = iNode;
130662 pNode->isDirty = 0;
130663 pNode->pNext = 0;
130664 memcpy(pNode->zData, zBlob, pRtree->iNodeSize);
130678 if( pNode && iNode==1 ){
130679 pRtree->iDepth = readInt16(pNode->zData);
130689 if( pNode && rc==SQLITE_OK ){
130690 if( NCELL(pNode)>((pRtree->iNodeSize-4)/pRtree->nBytesPerCell) ){
130696 if( pNode!=0 ){
130697 nodeHashInsert(pRtree, pNode);
130701 *ppNode = pNode;
130703 sqlite3_free(pNode);
130711 ** Overwrite cell iCell of node pNode with the contents of pCell.
130715 RtreeNode *pNode,
130720 u8 *p = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];
130725 pNode->isDirty = 1;
130729 ** Remove cell the cell with index iCell from node pNode.
130731 static void nodeDeleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell){
130732 u8 *pDst = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];
130734 int nByte = (NCELL(pNode) - iCell - 1) * pRtree->nBytesPerCell;
130736 writeInt16(&pNode->zData[2], NCELL(pNode)-1);
130737 pNode->isDirty = 1;
130741 ** Insert the contents of cell pCell into node pNode. If the insert
130744 ** If there is not enough free space in pNode, return SQLITE_FULL.
130749 RtreeNode *pNode,
130752 int nCell; /* Current number of cells in pNode */
130753 int nMaxCell; /* Maximum number of cells for pNode */
130756 nCell = NCELL(pNode);
130760 nodeOverwriteCell(pRtree, pNode, pCell, nCell);
130761 writeInt16(&pNode->zData[2], nCell+1);
130762 pNode->isDirty = 1;
130772 nodeWrite(Rtree *pRtree, RtreeNode *pNode){
130774 if( pNode->isDirty ){
130776 if( pNode->iNode ){
130777 sqlite3_bind_int64(p, 1, pNode->iNode);
130781 sqlite3_bind_blob(p, 2, pNode->zData, pRtree->iNodeSize, SQLITE_STATIC);
130783 pNode->isDirty = 0;
130785 if( pNode->iNode==0 && rc==SQLITE_OK ){
130786 pNode->iNode = sqlite3_last_insert_rowid(pRtree->db);
130787 pNode);
130798 nodeRelease(Rtree *pRtree, RtreeNode *pNode){
130800 if( pNode ){
130801 assert( pNode->nRef>0 );
130802 pNode->nRef--;
130803 if( pNode->nRef==0 ){
130804 if( pNode->iNode==1 ){
130807 if( pNode->pParent ){
130808 rc = nodeRelease(pRtree, pNode->pParent);
130811 rc = nodeWrite(pRtree, pNode);
130813 nodeHashDelete(pRtree, pNode);
130814 sqlite3_free(pNode);
130822 ** node pNode. If pNode is a leaf node, this is a rowid. If it is
130827 RtreeNode *pNode,
130830 assert( iCell<NCELL(pNode) );
130831 return readInt64(&pNode->zData[4 + pRtree->nBytesPerCell*iCell]);
130835 ** Return coordinate iCoord from cell iCell in node pNode.
130839 RtreeNode *pNode,
130844 readCoord(&pNode->zData[12 + pRtree->nBytesPerCell*iCell + 4*iCoord], pCoord);
130848 ** Deserialize cell iCell of node pNode. Populate the structure pointed
130853 RtreeNode *pNode,
130858 pCell->iRowid = nodeGetRowid(pRtree, pNode, iCell);
130860 nodeGetCoord(pRtree, pNode, iCell, ii, &pCell->aCoord[ii]);
131005 rc = nodeRelease(pRtree, pCsr->pNode);
131018 return (pCsr->pNode==0);
131059 nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell);
131112 nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell);
131164 RtreeNode *pSavedNode = pCursor->pNode;
131178 iRowid = nodeGetRowid(pRtree, pCursor->pNode, pCursor->iCell);
131179 rc = nodeAcquire(pRtree, iRowid, pCursor->pNode, &pChild);
131184 nodeRelease(pRtree, pCursor->pNode);
131185 pCursor->pNode = pChild;
131196 assert( pCursor->pNode==pChild );
131199 pCursor->pNode = pSavedNode;
131209 ** One of the cells in node pNode is guaranteed to have a 64-bit
131214 RtreeNode *pNode,
131219 int nCell = NCELL(pNode);
131221 if( nodeGetRowid(pRtree, pNode, ii)==iRowid ){
131230 ** Return the index of the cell containing a pointer to node pNode
131231 ** in its parent. If pNode is the root node, return -1.
131233 static int nodeParentIndex(Rtree *pRtree, RtreeNode *pNode, int *piIndex){
131234 RtreeNode *pParent = pNode->pParent;
131236 return nodeRowidIndex(pRtree, pParent, pNode->iNode, piIndex);
131250 /* RtreeCursor.pNode must not be NULL. If is is NULL, then this cursor is
131254 assert( pCsr->pNode );
131258 nodeRelease(pRtree, pCsr->pNode);
131259 pCsr->pNode = 0;
131263 while( pCsr->pNode ){
131264 RtreeNode *pNode = pCsr->pNode;
131265 int nCell = NCELL(pNode);
131273 pCsr->pNode = pNode->pParent;
131274 rc = nodeParentIndex(pRtree, pNode, &pCsr->iCell);
131278 nodeReference(pCsr->pNode);
131279 nodeRelease(pRtree, pNode);
131294 assert(pCsr->pNode);
131295 *pRowid = nodeGetRowid(pRtree, pCsr->pNode, pCsr->iCell);
131308 i64 iRowid = nodeGetRowid(pRtree, pCsr->pNode, pCsr->iCell);
131312 nodeGetCoord(pRtree, pCsr->pNode, pCsr->iCell, i-1, &c);
131416 pCsr->pNode = pLeaf;
131455 pCsr->pNode = 0;
131461 pCsr->pNode = pRoot;
131463 assert( pCsr->pNode==pRoot );
131470 assert( pCsr->pNode==pRoot );
131472 pCsr->pNode = 0;
131474 assert( rc!=SQLITE_OK || !pCsr->pNode || pCsr->iCell<NCELL(pCsr->pNode) );
131725 RtreeNode *pNode;
131726 rc = nodeAcquire(pRtree, 1, 0, &pNode);
131739 int nCell = NCELL(pNode);
131751 nodeRelease(pRtree, pNode);
131752 pNode = 0;
131756 nodeGetCell(pRtree, pNode, jj, &aCell[jj]);
131769 nodeGetCell(pRtree, pNode, iCell, &cell);
131800 rc = nodeAcquire(pRtree, iBest, pNode, &pChild);
131801 nodeRelease(pRtree, pNode);
131802 pNode = pChild;
131805 *ppLeaf = pNode;
131811 ** the node pNode. This function updates the bounding box cells in
131816 RtreeNode *pNode, /* Adjust ancestry of this node. */
131819 RtreeNode *p = pNode;
132312 RtreeNode *pNode,
132321 nodeReference(pNode);
132322 pChild->pParent = pNode;
132325 return xSetMapping(pRtree, iRowid, pNode->iNode);
132330 RtreeNode *pNode,
132338 int nCell = NCELL(pNode);
132359 nodeGetCell(pRtree, pNode, i, &aCell[i]);
132361 nodeZero(pRtree, pNode);
132365 if( pNode->iNode==1 ){
132366 pRight = nodeNew(pRtree, pNode);
132367 pLeft = nodeNew(pRtree, pNode);
132369 pNode->isDirty = 1;
132370 writeInt16(pNode->zData, pRtree->iDepth);
132372 pLeft = pNode;
132404 if( pNode->iNode==1 ){
132435 if( pNode->iNode==1 ){
132506 static int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){
132512 assert( pNode->nRef==1 );
132515 rc = nodeParentIndex(pRtree, pNode, &iCell);
132517 pParent = pNode->pParent;
132518 pNode->pParent = 0;
132530 sqlite3_bind_int64(pRtree->pDeleteNode, 1, pNode->iNode);
132537 sqlite3_bind_int64(pRtree->pDeleteParent, 1, pNode->iNode);
132546 nodeHashDelete(pRtree, pNode);
132547 pNode->iNode = iHeight;
132548 pNode->pNext = pRtree->pDeleted;
132549 pNode->nRef++;
132550 pRtree->pDeleted = pNode;
132555 static int fixBoundingBox(Rtree *pRtree, RtreeNode *pNode){
132556 RtreeNode *pParent = pNode->pParent;
132560 int nCell = NCELL(pNode);
132561 RtreeCell box; /* Bounding box for pNode */
132562 nodeGetCell(pRtree, pNode, 0, &box);
132565 nodeGetCell(pRtree, pNode, ii, &cell);
132568 box.iRowid = pNode->iNode;
132569 rc = nodeParentIndex(pRtree, pNode, &ii);
132579 ** Delete the cell at index iCell of node pNode. After removing the
132582 static int deleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell, int iHeight){
132586 if( SQLITE_OK!=(rc = fixLeafParent(pRtree, pNode)) ){
132593 nodeDeleteCell(pRtree, pNode, iCell);
132600 pParent = pNode->pParent;
132601 assert( pParent || pNode->iNode==1 );
132603 if( NCELL(pNode)<RTREE_MINCELLS(pRtree) ){
132604 rc = removeNode(pRtree, pNode, iHeight);
132606 rc = fixBoundingBox(pRtree, pNode);
132615 RtreeNode *pNode,
132631 nCell = NCELL(pNode)+1;
132653 nodeGetCell(pRtree, pNode, ii, &aCell[ii]);
132675 nodeZero(pRtree, pNode);
132679 nodeInsertCell(pRtree, pNode, p);
132682 rc = rowidWrite(pRtree, p->iRowid, pNode->iNode);
132684 rc = parentWrite(pRtree, p->iRowid, pNode->iNode);
132689 rc = fixBoundingBox(pRtree, pNode);
132692 /* Find a node to store this cell in. pNode->iNode currently contains
132713 ** Insert cell pCell into node pNode. Node pNode is the head of a
132718 RtreeNode *pNode,
132727 nodeReference(pNode);
132728 pChild->pParent = pNode;
132731 if( nodeInsertCell(pRtree, pNode, pCell) ){
132733 if( iHeight<=pRtree->iReinsertHeight || pNode->iNode==1){
132734 rc = SplitNode(pRtree, pNode, pCell, iHeight);
132737 rc = Reinsert(pRtree, pNode, pCell, iHeight);
132740 rc = SplitNode(pRtree, pNode, pCell, iHeight);
132743 rc = AdjustTree(pRtree, pNode, pCell);
132746 rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode);
132748 rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode);
132755 static int reinsertNodeContent(Rtree *pRtree, RtreeNode *pNode){
132758 int nCell = NCELL(pNode);
132763 nodeGetCell(pRtree, pNode, ii, &cell);
132765 /* Find a node to store this cell in. pNode->iNode currently contains
132768 rc = ChooseLeaf(pRtree, &cell, (int)pNode->iNode, &pInsert);
132771 rc = rtreeInsertCell(pRtree, pInsert, &cell, (int)pNode->iNode);