Lines Matching refs: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);
130371 RtreeNode *pNode; /* Node cursor is currently pointing at */
130372 int iCell; /* Index of current cell in pNode */
130424 #define NCELL(pNode) readInt16(&(pNode)->zData[2])
130576 ** Add node pNode to the node hash table.
130578 static void nodeHashInsert(Rtree *pRtree, RtreeNode *pNode){
130580 assert( pNode->pNext==0 );
130581 iHash = nodeHash(pNode->iNode);
130582 pNode->pNext = pRtree->aHash[iHash];
130583 pRtree->aHash[iHash] = pNode;
130587 ** Remove node pNode from the node hash table.
130589 static void nodeHashDelete(Rtree *pRtree, RtreeNode *pNode){
130591 if( pNode->iNode!=0 ){
130592 pp = &pRtree->aHash[nodeHash(pNode->iNode)];
130593 for( ; (*pp)!=pNode; pp = &(*pp)->pNext){ assert(*pp); }
130594 *pp = pNode->pNext;
130595 pNode->pNext = 0;
130606 RtreeNode *pNode;
130607 pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode) + pRtree->iNodeSize);
130608 if( pNode ){
130609 memset(pNode, 0, sizeof(RtreeNode) + pRtree->iNodeSize);
130610 pNode->zData = (u8 *)&pNode[1];
130611 pNode->nRef = 1;
130612 pNode->pParent = pParent;
130613 pNode->isDirty = 1;
130616 return pNode;
130631 RtreeNode *pNode;
130636 if( (pNode = nodeHashLookup(pRtree, iNode)) ){
130637 assert( !pParent || !pNode->pParent || pNode->pParent==pParent );
130638 if( pParent && !pNode->pParent ){
130640 pNode->pParent = pParent;
130642 pNode->nRef++;
130643 *ppNode = pNode;
130652 pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize);
130653 if( !pNode ){
130656 pNode->pParent = pParent;
130657 pNode->zData = (u8 *)&pNode[1];
130658 pNode->nRef = 1;
130659 pNode->iNode = iNode;
130660 pNode->isDirty = 0;
130661 pNode->pNext = 0;
130662 memcpy(pNode->zData, zBlob, pRtree->iNodeSize);
130676 if( pNode && iNode==1 ){
130677 pRtree->iDepth = readInt16(pNode->zData);
130687 if( pNode && rc==SQLITE_OK ){
130688 if( NCELL(pNode)>((pRtree->iNodeSize-4)/pRtree->nBytesPerCell) ){
130694 if( pNode!=0 ){
130695 nodeHashInsert(pRtree, pNode);
130699 *ppNode = pNode;
130701 sqlite3_free(pNode);
130709 ** Overwrite cell iCell of node pNode with the contents of pCell.
130713 RtreeNode *pNode,
130718 u8 *p = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];
130723 pNode->isDirty = 1;
130727 ** Remove cell the cell with index iCell from node pNode.
130729 static void nodeDeleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell){
130730 u8 *pDst = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];
130732 int nByte = (NCELL(pNode) - iCell - 1) * pRtree->nBytesPerCell;
130734 writeInt16(&pNode->zData[2], NCELL(pNode)-1);
130735 pNode->isDirty = 1;
130739 ** Insert the contents of cell pCell into node pNode. If the insert
130742 ** If there is not enough free space in pNode, return SQLITE_FULL.
130747 RtreeNode *pNode,
130750 int nCell; /* Current number of cells in pNode */
130751 int nMaxCell; /* Maximum number of cells for pNode */
130754 nCell = NCELL(pNode);
130758 nodeOverwriteCell(pRtree, pNode, pCell, nCell);
130759 writeInt16(&pNode->zData[2], nCell+1);
130760 pNode->isDirty = 1;
130770 nodeWrite(Rtree *pRtree, RtreeNode *pNode){
130772 if( pNode->isDirty ){
130774 if( pNode->iNode ){
130775 sqlite3_bind_int64(p, 1, pNode->iNode);
130779 sqlite3_bind_blob(p, 2, pNode->zData, pRtree->iNodeSize, SQLITE_STATIC);
130781 pNode->isDirty = 0;
130783 if( pNode->iNode==0 && rc==SQLITE_OK ){
130784 pNode->iNode = sqlite3_last_insert_rowid(pRtree->db);
130785 nodeHashInsert(pRtree, pNode);
130796 nodeRelease(Rtree *pRtree, RtreeNode *pNode){
130798 if( pNode ){
130799 assert( pNode->nRef>0 );
130800 pNode->nRef--;
130801 if( pNode->nRef==0 ){
130802 if( pNode->iNode==1 ){
130805 if( pNode->pParent ){
130806 rc = nodeRelease(pRtree, pNode->pParent);
130809 rc = nodeWrite(pRtree, pNode);
130811 nodeHashDelete(pRtree, pNode);
130812 sqlite3_free(pNode);
130820 ** node pNode. If pNode is a leaf node, this is a rowid. If it is
130825 RtreeNode *pNode,
130828 assert( iCell<NCELL(pNode) );
130829 return readInt64(&pNode->zData[4 + pRtree->nBytesPerCell*iCell]);
130833 ** Return coordinate iCoord from cell iCell in node pNode.
130837 RtreeNode *pNode,
130842 readCoord(&pNode->zData[12 + pRtree->nBytesPerCell*iCell + 4*iCoord], pCoord);
130846 ** Deserialize cell iCell of node pNode. Populate the structure pointed
130851 RtreeNode *pNode,
130856 pCell->iRowid = nodeGetRowid(pRtree, pNode, iCell);
130858 nodeGetCoord(pRtree, pNode, iCell, ii, &pCell->aCoord[ii]);
131003 rc = nodeRelease(pRtree, pCsr->pNode);
131016 return (pCsr->pNode==0);
131057 nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell);
131110 nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell);
131162 RtreeNode *pSavedNode = pCursor->pNode;
131176 iRowid = nodeGetRowid(pRtree, pCursor->pNode, pCursor->iCell);
131177 rc = nodeAcquire(pRtree, iRowid, pCursor->pNode, &pChild);
131182 nodeRelease(pRtree, pCursor->pNode);
131183 pCursor->pNode = pChild;
131194 assert( pCursor->pNode==pChild );
131197 pCursor->pNode = pSavedNode;
131207 ** One of the cells in node pNode is guaranteed to have a 64-bit
131212 RtreeNode *pNode,
131217 int nCell = NCELL(pNode);
131219 if( nodeGetRowid(pRtree, pNode, ii)==iRowid ){
131228 ** Return the index of the cell containing a pointer to node pNode
131229 ** in its parent. If pNode is the root node, return -1.
131231 static int nodeParentIndex(Rtree *pRtree, RtreeNode *pNode, int *piIndex){
131232 RtreeNode *pParent = pNode->pParent;
131234 return nodeRowidIndex(pRtree, pParent, pNode->iNode, piIndex);
131248 /* RtreeCursor.pNode must not be NULL. If is is NULL, then this cursor is
131252 assert( pCsr->pNode );
131256 nodeRelease(pRtree, pCsr->pNode);
131257 pCsr->pNode = 0;
131261 while( pCsr->pNode ){
131262 RtreeNode *pNode = pCsr->pNode;
131263 int nCell = NCELL(pNode);
131271 pCsr->pNode = pNode->pParent;
131272 rc = nodeParentIndex(pRtree, pNode, &pCsr->iCell);
131276 nodeReference(pCsr->pNode);
131277 nodeRelease(pRtree, pNode);
131292 assert(pCsr->pNode);
131293 *pRowid = nodeGetRowid(pRtree, pCsr->pNode, pCsr->iCell);
131306 i64 iRowid = nodeGetRowid(pRtree, pCsr->pNode, pCsr->iCell);
131310 nodeGetCoord(pRtree, pCsr->pNode, pCsr->iCell, i-1, &c);
131414 pCsr->pNode = pLeaf;
131453 pCsr->pNode = 0;
131459 pCsr->pNode = pRoot;
131461 assert( pCsr->pNode==pRoot );
131468 assert( pCsr->pNode==pRoot );
131470 pCsr->pNode = 0;
131472 assert( rc!=SQLITE_OK || !pCsr->pNode || pCsr->iCell<NCELL(pCsr->pNode) );
131723 RtreeNode *pNode;
131724 rc = nodeAcquire(pRtree, 1, 0, &pNode);
131737 int nCell = NCELL(pNode);
131749 nodeRelease(pRtree, pNode);
131750 pNode = 0;
131754 nodeGetCell(pRtree, pNode, jj, &aCell[jj]);
131767 nodeGetCell(pRtree, pNode, iCell, &cell);
131798 rc = nodeAcquire(pRtree, iBest, pNode, &pChild);
131799 nodeRelease(pRtree, pNode);
131800 pNode = pChild;
131803 *ppLeaf = pNode;
131809 ** the node pNode. This function updates the bounding box cells in
131814 RtreeNode *pNode, /* Adjust ancestry of this node. */
131817 RtreeNode *p = pNode;
132310 RtreeNode *pNode,
132319 nodeReference(pNode);
132320 pChild->pParent = pNode;
132323 return xSetMapping(pRtree, iRowid, pNode->iNode);
132328 RtreeNode *pNode,
132336 int nCell = NCELL(pNode);
132357 nodeGetCell(pRtree, pNode, i, &aCell[i]);
132359 nodeZero(pRtree, pNode);
132363 if( pNode->iNode==1 ){
132364 pRight = nodeNew(pRtree, pNode);
132365 pLeft = nodeNew(pRtree, pNode);
132367 pNode->isDirty = 1;
132368 writeInt16(pNode->zData, pRtree->iDepth);
132370 pLeft = pNode;
132402 if( pNode->iNode==1 ){
132433 if( pNode->iNode==1 ){
132504 static int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){
132510 assert( pNode->nRef==1 );
132513 rc = nodeParentIndex(pRtree, pNode, &iCell);
132515 pParent = pNode->pParent;
132516 pNode->pParent = 0;
132528 sqlite3_bind_int64(pRtree->pDeleteNode, 1, pNode->iNode);
132535 sqlite3_bind_int64(pRtree->pDeleteParent, 1, pNode->iNode);
132544 nodeHashDelete(pRtree, pNode);
132545 pNode->iNode = iHeight;
132546 pNode->pNext = pRtree->pDeleted;
132547 pNode->nRef++;
132548 pRtree->pDeleted = pNode;
132553 static int fixBoundingBox(Rtree *pRtree, RtreeNode *pNode){
132554 RtreeNode *pParent = pNode->pParent;
132558 int nCell = NCELL(pNode);
132559 RtreeCell box; /* Bounding box for pNode */
132560 nodeGetCell(pRtree, pNode, 0, &box);
132563 nodeGetCell(pRtree, pNode, ii, &cell);
132566 box.iRowid = pNode->iNode;
132567 rc = nodeParentIndex(pRtree, pNode, &ii);
132577 ** Delete the cell at index iCell of node pNode. After removing the
132580 static int deleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell, int iHeight){
132584 if( SQLITE_OK!=(rc = fixLeafParent(pRtree, pNode)) ){
132591 nodeDeleteCell(pRtree, pNode, iCell);
132598 pParent = pNode->pParent;
132599 assert( pParent || pNode->iNode==1 );
132601 if( NCELL(pNode)<RTREE_MINCELLS(pRtree) ){
132602 rc = removeNode(pRtree, pNode, iHeight);
132604 rc = fixBoundingBox(pRtree, pNode);
132613 RtreeNode *pNode,
132629 nCell = NCELL(pNode)+1;
132651 nodeGetCell(pRtree, pNode, ii, &aCell[ii]);
132673 nodeZero(pRtree, pNode);
132677 nodeInsertCell(pRtree, pNode, p);
132680 rc = rowidWrite(pRtree, p->iRowid, pNode->iNode);
132682 rc = parentWrite(pRtree, p->iRowid, pNode->iNode);
132687 rc = fixBoundingBox(pRtree, pNode);
132690 /* Find a node to store this cell in. pNode->iNode currently contains
132711 ** Insert cell pCell into node pNode. Node pNode is the head of a
132716 RtreeNode *pNode,
132725 nodeReference(pNode);
132726 pChild->pParent = pNode;
132729 if( nodeInsertCell(pRtree, pNode, pCell) ){
132731 if( iHeight<=pRtree->iReinsertHeight || pNode->iNode==1){
132732 rc = SplitNode(pRtree, pNode, pCell, iHeight);
132735 rc = Reinsert(pRtree, pNode, pCell, iHeight);
132738 rc = SplitNode(pRtree, pNode, pCell, iHeight);
132741 rc = AdjustTree(pRtree, pNode, pCell);
132744 rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode);
132746 rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode);
132753 static int reinsertNodeContent(Rtree *pRtree, RtreeNode *pNode){
132756 int nCell = NCELL(pNode);
132761 nodeGetCell(pRtree, pNode, ii, &cell);
132763 /* Find a node to store this cell in. pNode->iNode currently contains
132766 rc = ChooseLeaf(pRtree, &cell, (int)pNode->iNode, &pInsert);
132769 rc = rtreeInsertCell(pRtree, pInsert, &cell, (int)pNode->iNode);