if( pBt->readOnly && wrFlag ){ *ppCur = 0; return SQLITE_READONLY; }
static int fileBtreeCursor(Btree *pBt, int iTable, int wrFlag, BtCursor **ppCur){  int rc;  BtCursor *pCur, *pRing;  if( pBt->page1==0 ){    rc = lockBtree(pBt);    if( rc!=SQLITE_OK ){      *ppCur = 0;      return rc;    }  }  pCur = sqliteMalloc( sizeof(*pCur) );  if( pCur==0 ){    rc = SQLITE_NOMEM;    goto create_cursor_exception;  }  pCur->pgnoRoot = (Pgno)iTable;  rc = sqlitepager_get(pBt->pPager, pCur->pgnoRoot, (void**)&pCur->pPage);  if( rc!=SQLITE_OK ){    goto create_cursor_exception;  }  rc = initPage(pBt, pCur->pPage, pCur->pgnoRoot, 0);  if( rc!=SQLITE_OK ){    goto create_cursor_exception;  }  pCur->pOps = &sqliteBtreeCursorOps;  pCur->pBt = pBt;  pCur->wrFlag = wrFlag;  pCur->idx = 0;  pCur->eSkip = SKIP_INVALID;  pCur->pNext = pBt->pCursor;  if( pCur->pNext ){    pCur->pNext->pPrev = pCur;  }  pCur->pPrev = 0;  pRing = pBt->pCursor;  while( pRing && pRing->pgnoRoot!=pCur->pgnoRoot ){ pRing = pRing->pNext; }  if( pRing ){    pCur->pShared = pRing->pShared;    pRing->pShared = pCur;  }else{    pCur->pShared = pCur;  }  pBt->pCursor = pCur;  *ppCur = pCur;  return SQLITE_OK;create_cursor_exception:  *ppCur = 0;  if( pCur ){    if( pCur->pPage ) sqlitepager_unref(pCur->pPage);    sqliteFree(pCur);  }  unlockBtreeIfUnused(pBt);  return rc;}