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);
130356 RtreeNode *pNode; /* Node cursor is currently pointing at */
130409 #define NCELL(pNode) readInt16(&(pNode)->zData[2])
130563 static void nodeHashInsert(Rtree *pRtree, RtreeNode *pNode){
130565 assert( pNode->pNext==0 );
130566 iHash = nodeHash(pNode->iNode);
130567 pNode->pNext = pRtree->aHash[iHash];
130568 pRtree->aHash[iHash] = pNode;
130574 static void nodeHashDelete(Rtree *pRtree, RtreeNode *pNode){
130576 if( pNode->iNode!=0 ){
130577 pp = &pRtree->aHash[nodeHash(pNode->iNode)];
130578 for( ; (*pp)!=pNode; pp = &(*pp)->pNext){ assert(*pp); }
130579 *pp = pNode->pNext;
130580 pNode->pNext = 0;
130591 RtreeNode *pNode;
130592 pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode) + pRtree->iNodeSize);
130593 if( pNode ){
130594 memset(pNode, 0, sizeof(RtreeNode) + pRtree->iNodeSize);
130595 pNode->zData = (u8 *)&pNode[1];
130596 pNode->nRef = 1;
130597 pNode->pParent = pParent;
130598 pNode->isDirty = 1;
130601 return pNode;
130616 RtreeNode *pNode;
130621 if( (pNode = nodeHashLookup(pRtree, iNode)) ){
130622 assert( !pParent || !pNode->pParent || pNode->pParent==pParent );
130623 if( pParent && !pNode->pParent ){
130625 pNode->pParent = pParent;
130627 pNode->nRef++;
130628 *ppNode = pNode;
130637 pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize);
130638 if( !pNode ){
130641 pNode->pParent = pParent;
130642 pNode->zData = (u8 *)&pNode[1];
130643 pNode->nRef = 1;
130644 pNode->iNode = iNode;
130645 pNode->isDirty = 0;
130646 pNode->pNext = 0;
130647 memcpy(pNode->zData, zBlob, pRtree->iNodeSize);
130661 if( pNode && iNode==1 ){
130662 pRtree->iDepth = readInt16(pNode->zData);
130672 if( pNode && rc==SQLITE_OK ){
130673 if( NCELL(pNode)>((pRtree->iNodeSize-4)/pRtree->nBytesPerCell) ){
130679 if( pNode!=0 ){
130680 nodeHashInsert(pRtree, pNode);
130684 *ppNode = pNode;
130686 sqlite3_free(pNode);
130698 RtreeNode *pNode,
130703 u8 *p = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];
130708 pNode->isDirty = 1;
130714 static void nodeDeleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell){
130715 u8 *pDst = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];
130717 int nByte = (NCELL(pNode) - iCell - 1) * pRtree->nBytesPerCell;
130719 writeInt16(&pNode->zData[2], NCELL(pNode)-1);
130720 pNode->isDirty = 1;
130732 RtreeNode *pNode,
130739 nCell = NCELL(pNode);
130743 nodeOverwriteCell(pRtree, pNode, pCell, nCell);
130744 writeInt16(&pNode->zData[2], nCell+1);
130745 pNode->isDirty = 1;
130755 nodeWrite(Rtree *pRtree, RtreeNode *pNode){
130757 if( pNode->isDirty ){
130759 if( pNode->iNode ){
130760 sqlite3_bind_int64(p, 1, pNode->iNode);
130764 sqlite3_bind_blob(p, 2, pNode->zData, pRtree->iNodeSize, SQLITE_STATIC);
130766 pNode->isDirty = 0;
130768 if( pNode->iNode==0 && rc==SQLITE_OK ){
130769 pNode->iNode = sqlite3_last_insert_rowid(pRtree->db);
130770 nodeHashInsert(pRtree, pNode);
130781 nodeRelease(Rtree *pRtree, RtreeNode *pNode){
130783 if( pNode ){
130784 assert( pNode->nRef>0 );
130785 pNode->nRef--;
130786 if( pNode->nRef==0 ){
130787 if( pNode->iNode==1 ){
130790 if( pNode->pParent ){
130791 rc = nodeRelease(pRtree, pNode->pParent);
130794 rc = nodeWrite(pRtree, pNode);
130796 nodeHashDelete(pRtree, pNode);
130797 sqlite3_free(pNode);
130810 RtreeNode *pNode,
130813 assert( iCell<NCELL(pNode) );
130814 return readInt64(&pNode->zData[4 + pRtree->nBytesPerCell*iCell]);
130822 RtreeNode *pNode,
130827 readCoord(&pNode->zData[12 + pRtree->nBytesPerCell*iCell + 4*iCoord], pCoord);
130836 RtreeNode *pNode,
130841 pCell->iRowid = nodeGetRowid(pRtree, pNode, iCell);
130843 nodeGetCoord(pRtree, pNode, iCell, ii, &pCell->aCoord[ii]);
130988 rc = nodeRelease(pRtree, pCsr->pNode);
131001 return (pCsr->pNode==0);
131042 nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell);
131095 nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell);
131147 RtreeNode *pSavedNode = pCursor->pNode;
131161 iRowid = nodeGetRowid(pRtree, pCursor->pNode, pCursor->iCell);
131162 rc = nodeAcquire(pRtree, iRowid, pCursor->pNode, &pChild);
131167 nodeRelease(pRtree, pCursor->pNode);
131168 pCursor->pNode = pChild;
131179 assert( pCursor->pNode==pChild );
131182 pCursor->pNode = pSavedNode;
131197 RtreeNode *pNode,
131202 int nCell = NCELL(pNode);
131204 if( nodeGetRowid(pRtree, pNode, ii)==iRowid ){
131216 static int nodeParentIndex(Rtree *pRtree, RtreeNode *pNode, int *piIndex){
131217 RtreeNode *pParent = pNode->pParent;
131219 return nodeRowidIndex(pRtree, pParent, pNode->iNode, piIndex);
131237 assert( pCsr->pNode );
131241 nodeRelease(pRtree, pCsr->pNode);
131242 pCsr->pNode = 0;
131246 while( pCsr->pNode ){
131247 RtreeNode *pNode = pCsr->pNode;
131248 int nCell = NCELL(pNode);
131256 pCsr->pNode = pNode->pParent;
131257 rc = nodeParentIndex(pRtree, pNode, &pCsr->iCell);
131261 nodeReference(pCsr->pNode);
131262 nodeRelease(pRtree, pNode);
131277 assert(pCsr->pNode);
131278 *pRowid = nodeGetRowid(pRtree, pCsr->pNode, pCsr->iCell);
131291 i64 iRowid = nodeGetRowid(pRtree, pCsr->pNode, pCsr->iCell);
131295 nodeGetCoord(pRtree, pCsr->pNode, pCsr->iCell, i-1, &c);
131399 pCsr->pNode = pLeaf;
131438 pCsr->pNode = 0;
131444 pCsr->pNode = pRoot;
131446 assert( pCsr->pNode==pRoot );
131453 assert( pCsr->pNode==pRoot );
131455 pCsr->pNode = 0;
131457 assert( rc!=SQLITE_OK || !pCsr->pNode || pCsr->iCell<NCELL(pCsr->pNode) );
131708 RtreeNode *pNode;
131709 rc = nodeAcquire(pRtree, 1, 0, &pNode);
131722 int nCell = NCELL(pNode);
131734 nodeRelease(pRtree, pNode);
131735 pNode = 0;
131739 nodeGetCell(pRtree, pNode, jj, &aCell[jj]);
131752 nodeGetCell(pRtree, pNode, iCell, &cell);
131783 rc = nodeAcquire(pRtree, iBest, pNode, &pChild);
131784 nodeRelease(pRtree, pNode);
131785 pNode = pChild;
131788 *ppLeaf = pNode;
131799 RtreeNode *pNode, /* Adjust ancestry of this node. */
131802 RtreeNode *p = pNode;
132295 RtreeNode *pNode,
132304 nodeReference(pNode);
132305 pChild->pParent = pNode;
132308 return xSetMapping(pRtree, iRowid, pNode->iNode);
132313 RtreeNode *pNode,
132321 int nCell = NCELL(pNode);
132342 nodeGetCell(pRtree, pNode, i, &aCell[i]);
132344 nodeZero(pRtree, pNode);
132348 if( pNode->iNode==1 ){
132349 pRight = nodeNew(pRtree, pNode);
132350 pLeft = nodeNew(pRtree, pNode);
132352 pNode->isDirty = 1;
132353 writeInt16(pNode->zData, pRtree->iDepth);
132355 pLeft = pNode;
132387 if( pNode->iNode==1 ){
132418 if( pNode->iNode==1 ){
132489 static int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){
132495 assert( pNode->nRef==1 );
132498 rc = nodeParentIndex(pRtree, pNode, &iCell);
132500 pParent = pNode->pParent;
132501 pNode->pParent = 0;
132513 sqlite3_bind_int64(pRtree->pDeleteNode, 1, pNode->iNode);
132520 sqlite3_bind_int64(pRtree->pDeleteParent, 1, pNode->iNode);
132529 nodeHashDelete(pRtree, pNode);
132530 pNode->iNode = iHeight;
132531 pNode->pNext = pRtree->pDeleted;
132532 pNode->nRef++;
132533 pRtree->pDeleted = pNode;
132538 static int fixBoundingBox(Rtree *pRtree, RtreeNode *pNode){
132539 RtreeNode *pParent = pNode->pParent;
132543 int nCell = NCELL(pNode);
132545 nodeGetCell(pRtree, pNode, 0, &box);
132548 nodeGetCell(pRtree, pNode, ii, &cell);
132551 box.iRowid = pNode->iNode;
132552 rc = nodeParentIndex(pRtree, pNode, &ii);
132565 static int deleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell, int iHeight){
132569 if( SQLITE_OK!=(rc = fixLeafParent(pRtree, pNode)) ){
132576 nodeDeleteCell(pRtree, pNode, iCell);
132583 pParent = pNode->pParent;
132584 assert( pParent || pNode->iNode==1 );
132586 if( NCELL(pNode)<RTREE_MINCELLS(pRtree) ){
132587 rc = removeNode(pRtree, pNode, iHeight);
132589 rc = fixBoundingBox(pRtree, pNode);
132598 RtreeNode *pNode,
132614 nCell = NCELL(pNode)+1;
132636 nodeGetCell(pRtree, pNode, ii, &aCell[ii]);
132658 nodeZero(pRtree, pNode);
132662 nodeInsertCell(pRtree, pNode, p);
132665 rc = rowidWrite(pRtree, p->iRowid, pNode->iNode);
132667 rc = parentWrite(pRtree, p->iRowid, pNode->iNode);
132672 rc = fixBoundingBox(pRtree, pNode);
132701 RtreeNode *pNode,
132710 nodeReference(pNode);
132711 pChild->pParent = pNode;
132714 if( nodeInsertCell(pRtree, pNode, pCell) ){
132716 if( iHeight<=pRtree->iReinsertHeight || pNode->iNode==1){
132717 rc = SplitNode(pRtree, pNode, pCell, iHeight);
132720 rc = Reinsert(pRtree, pNode, pCell, iHeight);
132723 rc = SplitNode(pRtree, pNode, pCell, iHeight);
132726 rc = AdjustTree(pRtree, pNode, pCell);
132729 rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode);
132731 rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode);
132738 static int reinsertNodeContent(Rtree *pRtree, RtreeNode *pNode){
132741 int nCell = NCELL(pNode);
132746 nodeGetCell(pRtree, pNode, ii, &cell);
132751 rc = ChooseLeaf(pRtree, &cell, (int)pNode->iNode, &pInsert);
132754 rc = rtreeInsertCell(pRtree, pInsert, &cell, (int)pNode->iNode);