Lines Matching refs:pNode

23277   os2ShmNode *pNode,    /* Apply locks to this open shared-memory segment */
23287 assert( sqlite3_mutex_held(pNode->mutex) || pNode->nRef==0 );
23300 rc = DosSetFileLocks(pNode->hLockFile,
23305 rc = DosSetFileLocks(pNode->hLockFile,
23311 pNode->hLockFile,
23316 ERR_TRACE(rc, ("os2ShmSystemLock: %d %s\n", rc, pNode->shmBaseName))
23329 os2ShmNode *pNode;
23353 for( pNode = os2ShmNodeList;
23354 pNode && stricmp(shmName, pNode->shmBaseName) != 0;
23355 pNode = pNode->pNext ) ;
23358 if( !pNode ) {
23359 pNode = sqlite3_malloc( sizeof(*pNode) + cbShmName );
23360 if( pNode ) {
23361 memset(pNode, 0, sizeof(*pNode) );
23362 pNode->szRegion = szRegion;
23363 pNode->hLockFile = (HFILE)-1;
23364 strcpy(pNode->shmBaseName, shmName);
23367 if( DosDupHandle(fd->h, &pNode->hLockFile) != 0 ) {
23370 if( DosOpen((PSZ)shmName, &pNode->hLockFile, &action, 0, FILE_NORMAL,
23376 sqlite3_free(pNode);
23379 pNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
23380 if( !pNode->mutex ) {
23381 sqlite3_free(pNode);
23390 pNode->pNext = os2ShmNodeList;
23391 os2ShmNodeList = pNode;
23393 pNode = NULL;
23395 } else if( pNode->szRegion != szRegion ) {
23397 pNode = NULL;
23400 if( pNode ) {
23401 sqlite3_mutex_enter(pNode->mutex);
23405 pLink->pShmNode = pNode;
23406 pLink->pNext = pNode->pFirst;
23407 pNode->pFirst = pLink;
23408 pNode->nRef++;
23412 sqlite3_mutex_leave(pNode->mutex);
23433 os2ShmNode *pNode;
23441 pNode = *ppNode;
23443 if( pNode->nRef == 0 ) {
23444 *ppNode = pNode->pNext;
23446 if( pNode->apRegion ) {
23448 os2ShmSystemLock(pNode, _SHM_WRLCK_WAIT, OS2_SHM_DMS, 1);
23450 while( pNode->nRegion-- ) {
23454 DosFreeMem(pNode->apRegion[pNode->nRegion]);
23457 (int)GetCurrentProcessId(), pNode->nRegion,
23462 os2ShmSystemLock(pNode, _SHM_UNLCK, OS2_SHM_DMS, 1);
23464 sqlite3_free(pNode->apRegion);
23467 DosClose(pNode->hLockFile);
23473 sprintf(fileName, "%s-lck", pNode->shmBaseName + 10);
23481 sqlite3_mutex_free(pNode->mutex);
23483 sqlite3_free(pNode);
23486 ppNode = &pNode->pNext;
23521 os2ShmNode *pNode;
23532 pNode = pFile->pShmLink->pShmNode ;
23534 sqlite3_mutex_enter(pNode->mutex);
23536 assert( szRegion==pNode->szRegion );
23539 if( iRegion >= pNode->nRegion ) {
23541 os2ShmSystemLock(pNode, _SHM_WRLCK_WAIT, OS2_SHM_DMS, 1);
23544 pNode->apRegion, (iRegion + 1) * sizeof(apRegion[0]));
23547 pNode->apRegion = apRegion;
23549 while( pNode->nRegion <= iRegion ) {
23551 pNode->shmBaseName, pNode->nRegion);
23567 apRegion[pNode->nRegion++] = pvTemp;
23571 for( n = pNode->nRegion; n <= iRegion; n++ )
23572 pNode->apRegion[n] = NULL;
23575 *pp = pNode->apRegion[iRegion];
23581 os2ShmSystemLock(pNode, _SHM_UNLCK, OS2_SHM_DMS, 1);
23585 *pp = pNode->apRegion[iRegion];
23588 sqlite3_mutex_leave(pNode->mutex);
23614 os2ShmNode *pNode = pLink->pShmNode;
23616 sqlite3_mutex_enter(pNode->mutex);
23618 for( ppLink = &pNode->pFirst;
23626 nRef = --pNode->nRef;
23629 pNode->shmBaseName))
23635 sqlite3_mutex_leave(pNode->mutex);
127241 RtreeNode *pNode; /* Node cursor is currently pointing at */
127294 #define NCELL(pNode) readInt16(&(pNode)->zData[2])
127448 static void nodeHashInsert(Rtree *pRtree, RtreeNode *pNode){
127450 assert( pNode->pNext==0 );
127451 iHash = nodeHash(pNode->iNode);
127452 pNode->pNext = pRtree->aHash[iHash];
127453 pRtree->aHash[iHash] = pNode;
127459 static void nodeHashDelete(Rtree *pRtree, RtreeNode *pNode){
127461 if( pNode->iNode!=0 ){
127462 pp = &pRtree->aHash[nodeHash(pNode->iNode)];
127463 for( ; (*pp)!=pNode; pp = &(*pp)->pNext){ assert(*pp); }
127464 *pp = pNode->pNext;
127465 pNode->pNext = 0;
127476 RtreeNode *pNode;
127477 pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode) + pRtree->iNodeSize);
127478 if( pNode ){
127479 memset(pNode, 0, sizeof(RtreeNode) + pRtree->iNodeSize);
127480 pNode->zData = (u8 *)&pNode[1];
127481 pNode->nRef = 1;
127482 pNode->pParent = pParent;
127483 pNode->isDirty = 1;
127486 return pNode;
127501 RtreeNode *pNode;
127506 if( (pNode = nodeHashLookup(pRtree, iNode)) ){
127507 assert( !pParent || !pNode->pParent || pNode->pParent==pParent );
127508 if( pParent && !pNode->pParent ){
127510 pNode->pParent = pParent;
127512 pNode->nRef++;
127513 *ppNode = pNode;
127522 pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize);
127523 if( !pNode ){
127526 pNode->pParent = pParent;
127527 pNode->zData = (u8 *)&pNode[1];
127528 pNode->nRef = 1;
127529 pNode->iNode = iNode;
127530 pNode->isDirty = 0;
127531 pNode->pNext = 0;
127532 memcpy(pNode->zData, zBlob, pRtree->iNodeSize);
127546 if( pNode && iNode==1 ){
127547 pRtree->iDepth = readInt16(pNode->zData);
127557 if( pNode && rc==SQLITE_OK ){
127558 if( NCELL(pNode)>((pRtree->iNodeSize-4)/pRtree->nBytesPerCell) ){
127564 if( pNode!=0 ){
127565 nodeHashInsert(pRtree, pNode);
127569 *ppNode = pNode;
127571 sqlite3_free(pNode);
127583 RtreeNode *pNode,
127588 u8 *p = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];
127593 pNode->isDirty = 1;
127599 static void nodeDeleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell){
127600 u8 *pDst = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];
127602 int nByte = (NCELL(pNode) - iCell - 1) * pRtree->nBytesPerCell;
127604 writeInt16(&pNode->zData[2], NCELL(pNode)-1);
127605 pNode->isDirty = 1;
127617 RtreeNode *pNode,
127624 nCell = NCELL(pNode);
127628 nodeOverwriteCell(pRtree, pNode, pCell, nCell);
127629 writeInt16(&pNode->zData[2], nCell+1);
127630 pNode->isDirty = 1;
127640 nodeWrite(Rtree *pRtree, RtreeNode *pNode){
127642 if( pNode->isDirty ){
127644 if( pNode->iNode ){
127645 sqlite3_bind_int64(p, 1, pNode->iNode);
127649 sqlite3_bind_blob(p, 2, pNode->zData, pRtree->iNodeSize, SQLITE_STATIC);
127651 pNode->isDirty = 0;
127653 if( pNode->iNode==0 && rc==SQLITE_OK ){
127654 pNode->iNode = sqlite3_last_insert_rowid(pRtree->db);
127655 nodeHashInsert(pRtree, pNode);
127666 nodeRelease(Rtree *pRtree, RtreeNode *pNode){
127668 if( pNode ){
127669 assert( pNode->nRef>0 );
127670 pNode->nRef--;
127671 if( pNode->nRef==0 ){
127672 if( pNode->iNode==1 ){
127675 if( pNode->pParent ){
127676 rc = nodeRelease(pRtree, pNode->pParent);
127679 rc = nodeWrite(pRtree, pNode);
127681 nodeHashDelete(pRtree, pNode);
127682 sqlite3_free(pNode);
127695 RtreeNode *pNode,
127698 assert( iCell<NCELL(pNode) );
127699 return readInt64(&pNode->zData[4 + pRtree->nBytesPerCell*iCell]);
127707 RtreeNode *pNode,
127712 readCoord(&pNode->zData[12 + pRtree->nBytesPerCell*iCell + 4*iCoord], pCoord);
127721 RtreeNode *pNode,
127726 pCell->iRowid = nodeGetRowid(pRtree, pNode, iCell);
127728 nodeGetCoord(pRtree, pNode, iCell, ii, &pCell->aCoord[ii]);
127873 rc = nodeRelease(pRtree, pCsr->pNode);
127886 return (pCsr->pNode==0);
127927 nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell);
127980 nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell);
128032 RtreeNode *pSavedNode = pCursor->pNode;
128046 iRowid = nodeGetRowid(pRtree, pCursor->pNode, pCursor->iCell);
128047 rc = nodeAcquire(pRtree, iRowid, pCursor->pNode, &pChild);
128052 nodeRelease(pRtree, pCursor->pNode);
128053 pCursor->pNode = pChild;
128064 assert( pCursor->pNode==pChild );
128067 pCursor->pNode = pSavedNode;
128082 RtreeNode *pNode,
128087 int nCell = NCELL(pNode);
128089 if( nodeGetRowid(pRtree, pNode, ii)==iRowid ){
128101 static int nodeParentIndex(Rtree *pRtree, RtreeNode *pNode, int *piIndex){
128102 RtreeNode *pParent = pNode->pParent;
128104 return nodeRowidIndex(pRtree, pParent, pNode->iNode, piIndex);
128122 assert( pCsr->pNode );
128126 nodeRelease(pRtree, pCsr->pNode);
128127 pCsr->pNode = 0;
128131 while( pCsr->pNode ){
128132 RtreeNode *pNode = pCsr->pNode;
128133 int nCell = NCELL(pNode);
128141 pCsr->pNode = pNode->pParent;
128142 rc = nodeParentIndex(pRtree, pNode, &pCsr->iCell);
128146 nodeReference(pCsr->pNode);
128147 nodeRelease(pRtree, pNode);
128162 assert(pCsr->pNode);
128163 *pRowid = nodeGetRowid(pRtree, pCsr->pNode, pCsr->iCell);
128176 i64 iRowid = nodeGetRowid(pRtree, pCsr->pNode, pCsr->iCell);
128180 nodeGetCoord(pRtree, pCsr->pNode, pCsr->iCell, i-1, &c);
128284 pCsr->pNode = pLeaf;
128322 pCsr->pNode = 0;
128328 pCsr->pNode = pRoot;
128330 assert( pCsr->pNode==pRoot );
128337 assert( pCsr->pNode==pRoot );
128339 pCsr->pNode = 0;
128341 assert( rc!=SQLITE_OK || !pCsr->pNode || pCsr->iCell<NCELL(pCsr->pNode) );
128592 RtreeNode *pNode;
128593 rc = nodeAcquire(pRtree, 1, 0, &pNode);
128603 int nCell = NCELL(pNode);
128615 nodeRelease(pRtree, pNode);
128616 pNode = 0;
128620 nodeGetCell(pRtree, pNode, jj, &aCell[jj]);
128634 nodeGetCell(pRtree, pNode, iCell, &cell);
128663 rc = nodeAcquire(pRtree, iBest, pNode, &pChild);
128664 nodeRelease(pRtree, pNode);
128665 pNode = pChild;
128668 *ppLeaf = pNode;
128679 RtreeNode *pNode, /* Adjust ancestry of this node. */
128682 RtreeNode *p = pNode;
129175 RtreeNode *pNode,
129184 nodeReference(pNode);
129185 pChild->pParent = pNode;
129188 return xSetMapping(pRtree, iRowid, pNode->iNode);
129193 RtreeNode *pNode,
129201 int nCell = NCELL(pNode);
129222 nodeGetCell(pRtree, pNode, i, &aCell[i]);
129224 nodeZero(pRtree, pNode);
129228 if( pNode->iNode==1 ){
129229 pRight = nodeNew(pRtree, pNode);
129230 pLeft = nodeNew(pRtree, pNode);
129232 pNode->isDirty = 1;
129233 writeInt16(pNode->zData, pRtree->iDepth);
129235 pLeft = pNode;
129267 if( pNode->iNode==1 ){
129298 if( pNode->iNode==1 ){
129369 static int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){
129375 assert( pNode->nRef==1 );
129378 rc = nodeParentIndex(pRtree, pNode, &iCell);
129380 pParent = pNode->pParent;
129381 pNode->pParent = 0;
129393 sqlite3_bind_int64(pRtree->pDeleteNode, 1, pNode->iNode);
129400 sqlite3_bind_int64(pRtree->pDeleteParent, 1, pNode->iNode);
129409 nodeHashDelete(pRtree, pNode);
129410 pNode->iNode = iHeight;
129411 pNode->pNext = pRtree->pDeleted;
129412 pNode->nRef++;
129413 pRtree->pDeleted = pNode;
129418 static int fixBoundingBox(Rtree *pRtree, RtreeNode *pNode){
129419 RtreeNode *pParent = pNode->pParent;
129423 int nCell = NCELL(pNode);
129425 nodeGetCell(pRtree, pNode, 0, &box);
129428 nodeGetCell(pRtree, pNode, ii, &cell);
129431 box.iRowid = pNode->iNode;
129432 rc = nodeParentIndex(pRtree, pNode, &ii);
129445 static int deleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell, int iHeight){
129449 if( SQLITE_OK!=(rc = fixLeafParent(pRtree, pNode)) ){
129456 nodeDeleteCell(pRtree, pNode, iCell);
129463 pParent = pNode->pParent;
129464 assert( pParent || pNode->iNode==1 );
129466 if( NCELL(pNode)<RTREE_MINCELLS(pRtree) ){
129467 rc = removeNode(pRtree, pNode, iHeight);
129469 rc = fixBoundingBox(pRtree, pNode);
129478 RtreeNode *pNode,
129494 nCell = NCELL(pNode)+1;
129516 nodeGetCell(pRtree, pNode, ii, &aCell[ii]);
129538 nodeZero(pRtree, pNode);
129542 nodeInsertCell(pRtree, pNode, p);
129545 rc = rowidWrite(pRtree, p->iRowid, pNode->iNode);
129547 rc = parentWrite(pRtree, p->iRowid, pNode->iNode);
129552 rc = fixBoundingBox(pRtree, pNode);
129581 RtreeNode *pNode,
129590 nodeReference(pNode);
129591 pChild->pParent = pNode;
129594 if( nodeInsertCell(pRtree, pNode, pCell) ){
129596 if( iHeight<=pRtree->iReinsertHeight || pNode->iNode==1){
129597 rc = SplitNode(pRtree, pNode, pCell, iHeight);
129600 rc = Reinsert(pRtree, pNode, pCell, iHeight);
129603 rc = SplitNode(pRtree, pNode, pCell, iHeight);
129606 rc = AdjustTree(pRtree, pNode, pCell);
129609 rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode);
129611 rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode);
129618 static int reinsertNodeContent(Rtree *pRtree, RtreeNode *pNode){
129621 int nCell = NCELL(pNode);
129626 nodeGetCell(pRtree, pNode, ii, &cell);
129631 rc = ChooseLeaf(pRtree, &cell, (int)pNode->iNode, &pInsert);
129634 rc = rtreeInsertCell(pRtree, pInsert, &cell, (int)pNode->iNode);