Home | History | Annotate | Download | only in amalgamation

Lines Matching defs:pNode

22843   os2ShmNode *pNode,    /* Apply locks to this open shared-memory segment */
22853 assert( sqlite3_mutex_held(pNode->mutex) || pNode->nRef==0 );
22866 rc = DosSetFileLocks(pNode->hLockFile,
22871 rc = DosSetFileLocks(pNode->hLockFile,
22877 pNode->hLockFile,
22882 ERR_TRACE(rc, ("os2ShmSystemLock: %d %s\n", rc, pNode->shmBaseName))
22895 os2ShmNode *pNode;
22919 for( pNode = os2ShmNodeList;
22920 pNode && stricmp(shmName, pNode->shmBaseName) != 0;
22921 pNode = pNode->pNext ) ;
22924 if( !pNode ) {
22925 pNode = sqlite3_malloc( sizeof(*pNode) + cbShmName );
22926 if( pNode ) {
22927 memset(pNode, 0, sizeof(*pNode) );
22928 pNode->szRegion = szRegion;
22929 pNode->hLockFile = (HFILE)-1;
22930 strcpy(pNode->shmBaseName, shmName);
22933 if( DosDupHandle(fd->h, &pNode->hLockFile) != 0 ) {
22936 if( DosOpen((PSZ)shmName, &pNode->hLockFile, &action, 0, FILE_NORMAL,
22942 sqlite3_free(pNode);
22945 pNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
22946 if( !pNode->mutex ) {
22947 sqlite3_free(pNode);
22956 pNode->pNext = os2ShmNodeList;
22957 os2ShmNodeList = pNode;
22959 pNode = NULL;
22961 } else if( pNode->szRegion != szRegion ) {
22963 pNode = NULL;
22966 if( pNode ) {
22967 sqlite3_mutex_enter(pNode->mutex);
22971 pLink->pShmNode = pNode;
22972 pLink->pNext = pNode->pFirst;
22973 pNode->pFirst = pLink;
22974 pNode->nRef++;
22978 sqlite3_mutex_leave(pNode->mutex);
22999 os2ShmNode *pNode;
23007 pNode = *ppNode;
23009 if( pNode->nRef == 0 ) {
23010 *ppNode = pNode->pNext;
23012 if( pNode->apRegion ) {
23014 os2ShmSystemLock(pNode, _SHM_WRLCK_WAIT, OS2_SHM_DMS, 1);
23016 while( pNode->nRegion-- ) {
23020 DosFreeMem(pNode->apRegion[pNode->nRegion]);
23023 (int)GetCurrentProcessId(), pNode->nRegion,
23028 os2ShmSystemLock(pNode, _SHM_UNLCK, OS2_SHM_DMS, 1);
23030 sqlite3_free(pNode->apRegion);
23033 DosClose(pNode->hLockFile);
23039 sprintf(fileName, "%s-lck", pNode->shmBaseName + 10);
23047 sqlite3_mutex_free(pNode->mutex);
23049 sqlite3_free(pNode);
23052 ppNode = &pNode->pNext;
23087 os2ShmNode *pNode;
23098 pNode = pFile->pShmLink->pShmNode ;
23100 sqlite3_mutex_enter(pNode->mutex);
23102 assert( szRegion==pNode->szRegion );
23105 if( iRegion >= pNode->nRegion ) {
23107 os2ShmSystemLock(pNode, _SHM_WRLCK_WAIT, OS2_SHM_DMS, 1);
23110 pNode->apRegion, (iRegion + 1) * sizeof(apRegion[0]));
23113 pNode->apRegion = apRegion;
23115 while( pNode->nRegion <= iRegion ) {
23117 pNode->shmBaseName, pNode->nRegion);
23133 apRegion[pNode->nRegion++] = pvTemp;
23137 for( n = pNode->nRegion; n <= iRegion; n++ )
23138 pNode->apRegion[n] = NULL;
23141 *pp = pNode->apRegion[iRegion];
23147 os2ShmSystemLock(pNode, _SHM_UNLCK, OS2_SHM_DMS, 1);
23151 *pp = pNode->apRegion[iRegion];
23154 sqlite3_mutex_leave(pNode->mutex);
23180 os2ShmNode *pNode = pLink->pShmNode;
23182 pNode->mutex);
23184 for( ppLink = &pNode->pFirst;
23192 nRef = --pNode->nRef;
23195 pNode->shmBaseName))
23201 sqlite3_mutex_leave(pNode->mutex);
124480 RtreeNode *pNode; /* Node cursor is currently pointing at */
124481 int iCell; /* Index of current cell in pNode */
124533 #define NCELL(pNode) readInt16(&(pNode)->zData[2])
124685 ** Add node pNode to the node hash table.
124687 static void nodeHashInsert(Rtree *pRtree, RtreeNode *pNode){
124689 assert( pNode->pNext==0 );
124690 iHash = nodeHash(pNode->iNode);
124691 pNode->pNext = pRtree->aHash[iHash];
124692 pRtree->aHash[iHash] = pNode;
124696 ** Remove node pNode from the node hash table.
124698 static void nodeHashDelete(Rtree *pRtree, RtreeNode *pNode){
124700 if( pNode->iNode!=0 ){
124701 pp = &pRtree->aHash[nodeHash(pNode->iNode)];
124702 for( ; (*pp)!=pNode; pp = &(*pp)->pNext){ assert(*pp); }
124703 *pp = pNode->pNext;
124704 pNode->pNext = 0;
124715 RtreeNode *pNode;
124716 pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode) + pRtree->iNodeSize);
124717 if( pNode ){
124718 memset(pNode, 0, sizeof(RtreeNode) + pRtree->iNodeSize);
124719 pNode->zData = (u8 *)&pNode[1];
124720 pNode->nRef = 1;
124721 pNode->pParent = pParent;
124722 pNode->isDirty = 1;
124725 return pNode;
124740 RtreeNode *pNode;
124745 if( (pNode = nodeHashLookup(pRtree, iNode)) ){
124746 assert( !pParent || !pNode->pParent || pNode->pParent==pParent );
124747 if( pParent && !pNode->pParent ){
124749 pNode->pParent = pParent;
124751 pNode->nRef++;
124752 *ppNode = pNode;
124761 pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize);
124762 if( !pNode ){
124765 pNode->pParent = pParent;
124766 pNode->zData = (u8 *)&pNode[1];
124767 pNode->nRef = 1;
124768 pNode->iNode = iNode;
124769 pNode->isDirty = 0;
124770 pNode->pNext = 0;
124771 memcpy(pNode->zData, zBlob, pRtree->iNodeSize);
124785 if( pNode && iNode==1 ){
124786 pRtree->iDepth = readInt16(pNode->zData);
124796 if( pNode && rc==SQLITE_OK ){
124797 if( NCELL(pNode)>((pRtree->iNodeSize-4)/pRtree->nBytesPerCell) ){
124803 if( pNode!=0 ){
124804 nodeHashInsert(pRtree, pNode);
124808 *ppNode = pNode;
124810 sqlite3_free(pNode);
124818 ** Overwrite cell iCell of node pNode with the contents of pCell.
124822 RtreeNode *pNode,
124827 u8 *p = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];
124832 pNode->isDirty = 1;
124836 ** Remove cell the cell with index iCell from node pNode.
124838 static void nodeDeleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell){
124839 u8 *pDst = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];
124841 int nByte = (NCELL(pNode) - iCell - 1) * pRtree->nBytesPerCell;
124843 writeInt16(&pNode->zData[2], NCELL(pNode)-1);
124844 pNode->isDirty = 1;
124848 ** Insert the contents of cell pCell into node pNode. If the insert
124851 ** If there is not enough free space in pNode, return SQLITE_FULL.
124856 RtreeNode *pNode,
124859 int nCell; /* Current number of cells in pNode */
124860 int nMaxCell; /* Maximum number of cells for pNode */
124863 nCell = NCELL(pNode);
124867 nodeOverwriteCell(pRtree, pNode, pCell, nCell);
124868 writeInt16(&pNode->zData[2], nCell+1);
124869 pNode->isDirty = 1;
124879 nodeWrite(Rtree *pRtree, RtreeNode *pNode){
124881 if( pNode->isDirty ){
124883 if( pNode->iNode ){
124884 sqlite3_bind_int64(p, 1, pNode->iNode);
124888 sqlite3_bind_blob(p, 2, pNode->zData, pRtree->iNodeSize, SQLITE_STATIC);
124890 pNode->isDirty = 0;
124892 if( pNode->iNode==0 && rc==SQLITE_OK ){
124893 pNode->iNode = sqlite3_last_insert_rowid(pRtree->db);
124894 nodeHashInsert(pRtree, pNode);
124905 nodeRelease(Rtree *pRtree, RtreeNode *pNode){
124907 if( pNode ){
124908 assert( pNode->nRef>0 );
124909 pNode->nRef--;
124910 if( pNode->nRef==0 ){
124911 if( pNode->iNode==1 ){
124914 if( pNode->pParent ){
124915 rc = nodeRelease(pRtree, pNode->pParent);
124918 rc = nodeWrite(pRtree, pNode);
124920 nodeHashDelete(pRtree, pNode);
124921 sqlite3_free(pNode);
124929 ** node pNode. If pNode is a leaf node, this is a rowid. If it is
124934 RtreeNode *pNode,
124937 assert( iCell<NCELL(pNode) );
124938 return readInt64(&pNode->zData[4 + pRtree->nBytesPerCell*iCell]);
124942 ** Return coordinate iCoord from cell iCell in node pNode.
124946 RtreeNode *pNode,
124951 readCoord(&pNode->zData[12 + pRtree->nBytesPerCell*iCell + 4*iCoord], pCoord);
124955 ** Deserialize cell iCell of node pNode. Populate the structure pointed
124960 RtreeNode *pNode,
124965 pCell->iRowid = nodeGetRowid(pRtree, pNode, iCell);
124967 nodeGetCoord(pRtree, pNode, iCell, ii, &pCell->aCoord[ii]);
125112 rc = nodeRelease(pRtree, pCsr->pNode);
125125 return (pCsr->pNode==0);
125166 nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell);
125219 nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell);
125271 RtreeNode *pSavedNode = pCursor->pNode;
125285 iRowid = nodeGetRowid(pRtree, pCursor->pNode, pCursor->iCell);
125286 rc = nodeAcquire(pRtree, iRowid, pCursor->pNode, &pChild);
125291 nodeRelease(pRtree, pCursor->pNode);
125292 pCursor->pNode = pChild;
125303 assert( pCursor->pNode==pChild );
125306 pCursor->pNode = pSavedNode;
125316 ** One of the cells in node pNode is guaranteed to have a 64-bit
125321 RtreeNode *pNode,
125326 int nCell = NCELL(pNode);
125328 if( nodeGetRowid(pRtree, pNode, ii)==iRowid ){
125337 ** Return the index of the cell containing a pointer to node pNode
125338 ** in its parent. If pNode is the root node, return -1.
125340 static int nodeParentIndex(Rtree *pRtree, RtreeNode *pNode, int *piIndex){
125341 RtreeNode *pParent = pNode->pParent;
125343 return nodeRowidIndex(pRtree, pParent, pNode->iNode, piIndex);
125357 /* RtreeCursor.pNode must not be NULL. If is is NULL, then this cursor is
125361 assert( pCsr->pNode );
125365 nodeRelease(pRtree, pCsr->pNode);
125366 pCsr->pNode = 0;
125370 while( pCsr->pNode ){
125371 RtreeNode *pNode = pCsr->pNode;
125372 int nCell = NCELL(pNode);
125380 pCsr->pNode = pNode->pParent;
125381 rc = nodeParentIndex(pRtree, pNode, &pCsr->iCell);
125385 nodeReference(pCsr->pNode);
125386 nodeRelease(pRtree, pNode);
125401 assert(pCsr->pNode);
125402 *pRowid = nodeGetRowid(pRtree, pCsr->pNode, pCsr->iCell);
125415 i64 iRowid = nodeGetRowid(pRtree, pCsr->pNode, pCsr->iCell);
125419 nodeGetCoord(pRtree, pCsr->pNode, pCsr->iCell, i-1, &c);
125523 pCsr->pNode = pLeaf;
125561 pCsr->pNode = 0;
125567 pCsr->pNode = pRoot;
125569 assert( pCsr->pNode==pRoot );
125576 assert( pCsr->pNode==pRoot );
125578 pCsr->pNode = 0;
125580 assert( rc!=SQLITE_OK || !pCsr->pNode || pCsr->iCell<NCELL(pCsr->pNode) );
125831 RtreeNode *pNode;
125832 rc = nodeAcquire(pRtree, 1, 0, &pNode);
125842 int nCell = NCELL(pNode);
125854 nodeRelease(pRtree, pNode);
125855 pNode = 0;
125859 nodeGetCell(pRtree, pNode, jj, &aCell[jj]);
125873 nodeGetCell(pRtree, pNode, iCell, &cell);
125902 rc = nodeAcquire(pRtree, iBest, pNode, &pChild);
125903 nodeRelease(pRtree, pNode);
125904 pNode = pChild;
125907 *ppLeaf = pNode;
125913 ** the node pNode. This function updates the bounding box cells in
125918 RtreeNode *pNode, /* Adjust ancestry of this node. */
125921 RtreeNode *p = pNode;
126414 RtreeNode *pNode,
126423 nodeReference(pNode);
126424 pChild->pParent = pNode;
126427 return xSetMapping(pRtree, iRowid, pNode->iNode);
126432 RtreeNode *pNode,
126440 int nCell = NCELL(pNode);
126461 nodeGetCell(pRtree, pNode, i, &aCell[i]);
126463 nodeZero(pRtree, pNode);
126467 if( pNode->iNode==1 ){
126468 pRight = nodeNew(pRtree, pNode);
126469 pLeft = nodeNew(pRtree, pNode);
126471 pNode->isDirty = 1;
126472 writeInt16(pNode->zData, pRtree->iDepth);
126474 pLeft = pNode;
126506 if( pNode->iNode==1 ){
126537 if( pNode->iNode==1 ){
126608 static int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){
126614 assert( pNode->nRef==1 );
126617 rc = nodeParentIndex(pRtree, pNode, &iCell);
126619 pParent = pNode->pParent;
126620 pNode->pParent = 0;
126632 sqlite3_bind_int64(pRtree->pDeleteNode, 1, pNode->iNode);
126639 sqlite3_bind_int64(pRtree->pDeleteParent, 1, pNode->iNode);
126648 nodeHashDelete(pRtree, pNode);
126649 pNode->iNode = iHeight;
126650 pNode->pNext = pRtree->pDeleted;
126651 pNode->nRef++;
126652 pRtree->pDeleted = pNode;
126657 static int fixBoundingBox(Rtree *pRtree, RtreeNode *pNode){
126658 RtreeNode *pParent = pNode->pParent;
126662 int nCell = NCELL(pNode);
126663 RtreeCell box; /* Bounding box for pNode */
126664 nodeGetCell(pRtree, pNode, 0, &box);
126667 nodeGetCell(pRtree, pNode, ii, &cell);
126670 box.iRowid = pNode->iNode;
126671 rc = nodeParentIndex(pRtree, pNode, &ii);
126681 ** Delete the cell at index iCell of node pNode. After removing the
126684 static int deleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell, int iHeight){
126688 if( SQLITE_OK!=(rc = fixLeafParent(pRtree, pNode)) ){
126695 nodeDeleteCell(pRtree, pNode, iCell);
126702 pParent = pNode->pParent;
126703 assert( pParent || pNode->iNode==1 );
126705 if( NCELL(pNode
126706 rc = removeNode(pRtree, pNode, iHeight);
126708 rc = fixBoundingBox(pRtree, pNode);
126717 RtreeNode *pNode,
126733 nCell = NCELL(pNode)+1;
126755 nodeGetCell(pRtree, pNode, ii, &aCell[ii]);
126777 nodeZero(pRtree, pNode);
126781 nodeInsertCell(pRtree, pNode, p);
126784 rc = rowidWrite(pRtree, p->iRowid, pNode->iNode);
126786 rc = parentWrite(pRtree, p->iRowid, pNode->iNode);
126791 rc = fixBoundingBox(pRtree, pNode);
126794 /* Find a node to store this cell in. pNode->iNode currently contains
126815 ** Insert cell pCell into node pNode. Node pNode is the head of a
126820 RtreeNode *pNode,
126829 nodeReference(pNode);
126830 pChild->pParent = pNode;
126833 if( nodeInsertCell(pRtree, pNode, pCell) ){
126835 if( iHeight<=pRtree->iReinsertHeight || pNode->iNode==1){
126836 rc = SplitNode(pRtree, pNode, pCell, iHeight);
126839 rc = Reinsert(pRtree, pNode, pCell, iHeight);
126842 rc = SplitNode(pRtree, pNode, pCell, iHeight);
126845 rc = AdjustTree(pRtree, pNode, pCell);
126848 rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode);
126850 rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode);
126857 static int reinsertNodeContent(Rtree *pRtree, RtreeNode *pNode){
126860 int nCell = NCELL(pNode);
126865 nodeGetCell(pRtree, pNode, ii, &cell);
126867 /* Find a node to store this cell in. pNode->iNode currently contains
126870 rc = ChooseLeaf(pRtree, &cell, pNode->iNode, &pInsert);
126873 rc = rtreeInsertCell(pRtree, pInsert, &cell, pNode->iNode);