亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? pager.c

?? 這是一個嵌入式系統上運行的輕量級數據庫
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*** 2001 September 15**** The author disclaims copyright to this source code.  In place of** a legal notice, here is a blessing:****    May you do good and not evil.**    May you find forgiveness for yourself and forgive others.**    May you share freely, never taking more than you give.***************************************************************************** This is the implementation of the page cache subsystem or "pager".** ** The pager is used to access a database disk file.  It implements** atomic commit and rollback through the use of a journal file that** is separate from the database file.  The pager also implements file** locking to prevent two processes from writing the same database** file simultaneously, or one process from reading the database while** another is writing.**** @(#) $Id: pager.c,v 1.101.2.1 2005/12/19 17:37:10 drh Exp $*/#include "os.h"         /* Must be first to enable large file support */#include "sqliteInt.h"#include "pager.h"#include <assert.h>#include <string.h>/*** Macros for troubleshooting.  Normally turned off*/#if 0static Pager *mainPager = 0;#define SET_PAGER(X)  if( mainPager==0 ) mainPager = (X)#define CLR_PAGER(X)  if( mainPager==(X) ) mainPager = 0#define TRACE1(X)     if( pPager==mainPager ) fprintf(stderr,X)#define TRACE2(X,Y)   if( pPager==mainPager ) fprintf(stderr,X,Y)#define TRACE3(X,Y,Z) if( pPager==mainPager ) fprintf(stderr,X,Y,Z)#else#define SET_PAGER(X)#define CLR_PAGER(X)#define TRACE1(X)#define TRACE2(X,Y)#define TRACE3(X,Y,Z)#endif/*** The page cache as a whole is always in one of the following** states:****   SQLITE_UNLOCK       The page cache is not currently reading or **                       writing the database file.  There is no**                       data held in memory.  This is the initial**                       state.****   SQLITE_READLOCK     The page cache is reading the database.**                       Writing is not permitted.  There can be**                       multiple readers accessing the same database**                       file at the same time.****   SQLITE_WRITELOCK    The page cache is writing the database.**                       Access is exclusive.  No other processes or**                       threads can be reading or writing while one**                       process is writing.**** The page cache comes up in SQLITE_UNLOCK.  The first time a** sqlite_page_get() occurs, the state transitions to SQLITE_READLOCK.** After all pages have been released using sqlite_page_unref(),** the state transitions back to SQLITE_UNLOCK.  The first time** that sqlite_page_write() is called, the state transitions to** SQLITE_WRITELOCK.  (Note that sqlite_page_write() can only be** called on an outstanding page which means that the pager must** be in SQLITE_READLOCK before it transitions to SQLITE_WRITELOCK.)** The sqlite_page_rollback() and sqlite_page_commit() functions ** transition the state from SQLITE_WRITELOCK back to SQLITE_READLOCK.*/#define SQLITE_UNLOCK      0#define SQLITE_READLOCK    1#define SQLITE_WRITELOCK   2/*** Each in-memory image of a page begins with the following header.** This header is only visible to this pager module.  The client** code that calls pager sees only the data that follows the header.**** Client code should call sqlitepager_write() on a page prior to making** any modifications to that page.  The first time sqlitepager_write()** is called, the original page contents are written into the rollback** journal and PgHdr.inJournal and PgHdr.needSync are set.  Later, once** the journal page has made it onto the disk surface, PgHdr.needSync** is cleared.  The modified page cannot be written back into the original** database file until the journal pages has been synced to disk and the** PgHdr.needSync has been cleared.**** The PgHdr.dirty flag is set when sqlitepager_write() is called and** is cleared again when the page content is written back to the original** database file.*/typedef struct PgHdr PgHdr;struct PgHdr {  Pager *pPager;                 /* The pager to which this page belongs */  Pgno pgno;                     /* The page number for this page */  PgHdr *pNextHash, *pPrevHash;  /* Hash collision chain for PgHdr.pgno */  int nRef;                      /* Number of users of this page */  PgHdr *pNextFree, *pPrevFree;  /* Freelist of pages where nRef==0 */  PgHdr *pNextAll, *pPrevAll;    /* A list of all pages */  PgHdr *pNextCkpt, *pPrevCkpt;  /* List of pages in the checkpoint journal */  u8 inJournal;                  /* TRUE if has been written to journal */  u8 inCkpt;                     /* TRUE if written to the checkpoint journal */  u8 dirty;                      /* TRUE if we need to write back changes */  u8 needSync;                   /* Sync journal before writing this page */  u8 alwaysRollback;             /* Disable dont_rollback() for this page */  PgHdr *pDirty;                 /* Dirty pages sorted by PgHdr.pgno */  /* SQLITE_PAGE_SIZE bytes of page data follow this header */  /* Pager.nExtra bytes of local data follow the page data */};/*** A macro used for invoking the codec if there is one*/#ifdef SQLITE_HAS_CODEC# define CODEC(P,D,N,X) if( P->xCodec ){ P->xCodec(P->pCodecArg,D,N,X); }#else# define CODEC(P,D,N,X)#endif/*** Convert a pointer to a PgHdr into a pointer to its data** and back again.*/#define PGHDR_TO_DATA(P)  ((void*)(&(P)[1]))#define DATA_TO_PGHDR(D)  (&((PgHdr*)(D))[-1])#define PGHDR_TO_EXTRA(P) ((void*)&((char*)(&(P)[1]))[SQLITE_PAGE_SIZE])/*** How big to make the hash table used for locating in-memory pages** by page number.*/#define N_PG_HASH 2048/*** Hash a page number*/#define pager_hash(PN)  ((PN)&(N_PG_HASH-1))/*** A open page cache is an instance of the following structure.*/struct Pager {  char *zFilename;            /* Name of the database file */  char *zJournal;             /* Name of the journal file */  char *zDirectory;           /* Directory hold database and journal files */  OsFile fd, jfd;             /* File descriptors for database and journal */  OsFile cpfd;                /* File descriptor for the checkpoint journal */  int dbSize;                 /* Number of pages in the file */  int origDbSize;             /* dbSize before the current change */  int ckptSize;               /* Size of database (in pages) at ckpt_begin() */  off_t ckptJSize;            /* Size of journal at ckpt_begin() */  int nRec;                   /* Number of pages written to the journal */  u32 cksumInit;              /* Quasi-random value added to every checksum */  int ckptNRec;               /* Number of records in the checkpoint journal */  int nExtra;                 /* Add this many bytes to each in-memory page */  void (*xDestructor)(void*); /* Call this routine when freeing pages */  int nPage;                  /* Total number of in-memory pages */  int nRef;                   /* Number of in-memory pages with PgHdr.nRef>0 */  int mxPage;                 /* Maximum number of pages to hold in cache */  int nHit, nMiss, nOvfl;     /* Cache hits, missing, and LRU overflows */  void (*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */  void *pCodecArg;            /* First argument to xCodec() */  u8 journalOpen;             /* True if journal file descriptors is valid */  u8 journalStarted;          /* True if header of journal is synced */  u8 useJournal;              /* Use a rollback journal on this file */  u8 ckptOpen;                /* True if the checkpoint journal is open */  u8 ckptInUse;               /* True we are in a checkpoint */  u8 ckptAutoopen;            /* Open ckpt journal when main journal is opened*/  u8 noSync;                  /* Do not sync the journal if true */  u8 fullSync;                /* Do extra syncs of the journal for robustness */  u8 state;                   /* SQLITE_UNLOCK, _READLOCK or _WRITELOCK */  u8 errMask;                 /* One of several kinds of errors */  u8 tempFile;                /* zFilename is a temporary file */  u8 readOnly;                /* True for a read-only database */  u8 needSync;                /* True if an fsync() is needed on the journal */  u8 dirtyFile;               /* True if database file has changed in any way */  u8 alwaysRollback;          /* Disable dont_rollback() for all pages */  u8 *aInJournal;             /* One bit for each page in the database file */  u8 *aInCkpt;                /* One bit for each page in the database */  PgHdr *pFirst, *pLast;      /* List of free pages */  PgHdr *pFirstSynced;        /* First free page with PgHdr.needSync==0 */  PgHdr *pAll;                /* List of all pages */  PgHdr *pCkpt;               /* List of pages in the checkpoint journal */  PgHdr *aHash[N_PG_HASH];    /* Hash table to map page number of PgHdr */};/*** These are bits that can be set in Pager.errMask.*/#define PAGER_ERR_FULL     0x01  /* a write() failed */#define PAGER_ERR_MEM      0x02  /* malloc() failed */#define PAGER_ERR_LOCK     0x04  /* error in the locking protocol */#define PAGER_ERR_CORRUPT  0x08  /* database or journal corruption */#define PAGER_ERR_DISK     0x10  /* general disk I/O error - bad hard drive? *//*** The journal file contains page records in the following** format.**** Actually, this structure is the complete page record for pager** formats less than 3.  Beginning with format 3, this record is surrounded** by two checksums.*/typedef struct PageRecord PageRecord;struct PageRecord {  Pgno pgno;                      /* The page number */  char aData[SQLITE_PAGE_SIZE];   /* Original data for page pgno */};/*** Journal files begin with the following magic string.  The data** was obtained from /dev/random.  It is used only as a sanity check.**** There are three journal formats (so far). The 1st journal format writes** 32-bit integers in the byte-order of the host machine.  New** formats writes integers as big-endian.  All new journals use the** new format, but we have to be able to read an older journal in order** to rollback journals created by older versions of the library.**** The 3rd journal format (added for 2.8.0) adds additional sanity** checking information to the journal.  If the power fails while the** journal is being written, semi-random garbage data might appear in** the journal file after power is restored.  If an attempt is then made** to roll the journal back, the database could be corrupted.  The additional** sanity checking data is an attempt to discover the garbage in the** journal and ignore it.**** The sanity checking information for the 3rd journal format consists** of a 32-bit checksum on each page of data.  The checksum covers both** the page number and the SQLITE_PAGE_SIZE bytes of data for the page.** This cksum is initialized to a 32-bit random value that appears in the** journal file right after the header.  The random initializer is important,** because garbage data that appears at the end of a journal is likely** data that was once in other files that have now been deleted.  If the** garbage data came from an obsolete journal file, the checksums might** be correct.  But by initializing the checksum to random value which** is different for every journal, we minimize that risk.*/static const unsigned char aJournalMagic1[] = {  0xd9, 0xd5, 0x05, 0xf9, 0x20, 0xa1, 0x63, 0xd4,};static const unsigned char aJournalMagic2[] = {  0xd9, 0xd5, 0x05, 0xf9, 0x20, 0xa1, 0x63, 0xd5,};static const unsigned char aJournalMagic3[] = {  0xd9, 0xd5, 0x05, 0xf9, 0x20, 0xa1, 0x63, 0xd6,};#define JOURNAL_FORMAT_1 1#define JOURNAL_FORMAT_2 2#define JOURNAL_FORMAT_3 3/*** The following integer determines what format to use when creating** new primary journal files.  By default we always use format 3.** When testing, we can set this value to older journal formats in order to** make sure that newer versions of the library are able to rollback older** journal files.**** Note that checkpoint journals always use format 2 and omit the header.*/#ifdef SQLITE_TESTint journal_format = 3;#else# define journal_format 3#endif/*** The size of the header and of each page in the journal varies according** to which journal format is being used.  The following macros figure out** the sizes based on format numbers.*/#define JOURNAL_HDR_SZ(X) \   (sizeof(aJournalMagic1) + sizeof(Pgno) + ((X)>=3)*2*sizeof(u32))#define JOURNAL_PG_SZ(X) \   (SQLITE_PAGE_SIZE + sizeof(Pgno) + ((X)>=3)*sizeof(u32))/*** Enable reference count tracking here:*/#ifdef SQLITE_TEST  int pager_refinfo_enable = 0;  static void pager_refinfo(PgHdr *p){    static int cnt = 0;    if( !pager_refinfo_enable ) return;    printf(       "REFCNT: %4d addr=0x%08x nRef=%d\n",       p->pgno, (int)PGHDR_TO_DATA(p), p->nRef    );    cnt++;   /* Something to set a breakpoint on */  }# define REFINFO(X)  pager_refinfo(X)#else# define REFINFO(X)#endif/*** Read a 32-bit integer from the given file descriptor.  Store the integer** that is read in *pRes.  Return SQLITE_OK if everything worked, or an** error code is something goes wrong.**** If the journal format is 2 or 3, read a big-endian integer.  If the** journal format is 1, read an integer in the native byte-order of the** host machine.*/static int read32bits(int format, OsFile *fd, u32 *pRes){  u32 res;  int rc;  rc = sqliteOsRead(fd, &res, sizeof(res));  if( rc==SQLITE_OK && format>JOURNAL_FORMAT_1 ){    unsigned char ac[4];    memcpy(ac, &res, 4);    res = (ac[0]<<24) | (ac[1]<<16) | (ac[2]<<8) | ac[3];  }  *pRes = res;  return rc;}/*** Write a 32-bit integer into the given file descriptor.  Return SQLITE_OK** on success or an error code is something goes wrong.**** If the journal format is 2 or 3, write the integer as 4 big-endian** bytes.  If the journal format is 1, write the integer in the native** byte order.  In normal operation, only formats 2 and 3 are used.** Journal format 1 is only used for testing.*/static int write32bits(OsFile *fd, u32 val){  unsigned char ac[4];  if( journal_format<=1 ){    return sqliteOsWrite(fd, &val, 4);  }  ac[0] = (val>>24) & 0xff;  ac[1] = (val>>16) & 0xff;  ac[2] = (val>>8) & 0xff;  ac[3] = val & 0xff;  return sqliteOsWrite(fd, ac, 4);}/*** Write a 32-bit integer into a page header right before the** page data.  This will overwrite the PgHdr.pDirty pointer.**** The integer is big-endian for formats 2 and 3 and native byte order** for journal format 1.*/static void store32bits(u32 val, PgHdr *p, int offset){  unsigned char *ac;  ac = &((unsigned char*)PGHDR_TO_DATA(p))[offset];  if( journal_format<=1 ){    memcpy(ac, &val, 4);  }else{    ac[0] = (val>>24) & 0xff;    ac[1] = (val>>16) & 0xff;    ac[2] = (val>>8) & 0xff;    ac[3] = val & 0xff;  }}/*** Convert the bits in the pPager->errMask into an approprate** return code.*/static int pager_errcode(Pager *pPager){  int rc = SQLITE_OK;  if( pPager->errMask & PAGER_ERR_LOCK )    rc = SQLITE_PROTOCOL;  if( pPager->errMask & PAGER_ERR_DISK )    rc = SQLITE_IOERR;  if( pPager->errMask & PAGER_ERR_FULL )    rc = SQLITE_FULL;  if( pPager->errMask & PAGER_ERR_MEM )     rc = SQLITE_NOMEM;  if( pPager->errMask & PAGER_ERR_CORRUPT ) rc = SQLITE_CORRUPT;  return rc;}/*** Add or remove a page from the list of all pages that are in the** checkpoint journal.**

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美大尺度电影在线| 一区二区三区在线视频免费观看| 欧美激情在线一区二区三区| 丝袜美腿亚洲综合| 99久久精品免费看| 久久众筹精品私拍模特| 亚洲第一精品在线| 色中色一区二区| 国产欧美精品区一区二区三区| 日韩精品乱码免费| 欧美天堂一区二区三区| 1024成人网| 成人蜜臀av电影| 久久久久99精品国产片| 美日韩一级片在线观看| 欧美精品一二三区| 一区二区三区国产豹纹内裤在线| 成人美女视频在线看| 久久精品一区二区三区不卡牛牛| 日本视频一区二区| 欧美精品在线一区二区三区| 夜夜嗨av一区二区三区| 色偷偷88欧美精品久久久| 国产精品对白交换视频| 不卡欧美aaaaa| 亚洲国产成人午夜在线一区| 国产高清视频一区| 久久精品日产第一区二区三区高清版| 麻豆免费精品视频| 日韩视频中午一区| 九色综合狠狠综合久久| 欧美本精品男人aⅴ天堂| 美女视频一区二区三区| 精品日韩99亚洲| 国产制服丝袜一区| 国产欧美日韩综合| 国产suv精品一区二区三区| 中文字幕不卡的av| 91免费观看视频在线| 亚洲免费看黄网站| 欧美精品日韩一区| 精品一区二区三区免费观看| 久久蜜桃一区二区| 不卡一卡二卡三乱码免费网站| 亚洲天堂精品视频| 欧美色综合网站| 美女网站在线免费欧美精品| 欧美本精品男人aⅴ天堂| 国产91精品露脸国语对白| 综合久久久久久| 欧美伦理影视网| 国产一区二区三区四区五区美女| 国产精品视频第一区| 欧洲精品在线观看| 欧美96一区二区免费视频| 久久久久国产成人精品亚洲午夜| 成人18精品视频| 日本中文字幕一区二区有限公司| 精品粉嫩超白一线天av| 91视频在线观看免费| 日韩中文字幕区一区有砖一区| 久久综合资源网| 色94色欧美sute亚洲线路一久| 日本va欧美va瓶| 国产精品私房写真福利视频| 欧美三区在线视频| 国产91在线观看| 天天爽夜夜爽夜夜爽精品视频| 精品电影一区二区| 91高清视频免费看| 国产精品亚洲一区二区三区妖精| 亚洲中国最大av网站| 久久久精品人体av艺术| 在线观看不卡视频| 国产黑丝在线一区二区三区| 亚洲图片欧美一区| 亚洲国产精品成人久久综合一区 | 九色|91porny| 亚洲天天做日日做天天谢日日欢| 日韩色视频在线观看| 99re这里只有精品视频首页| 久久99日本精品| 亚洲中国最大av网站| 国产精品私人影院| 日韩欧美成人一区二区| 欧美午夜不卡在线观看免费| 岛国精品一区二区| 精品亚洲国内自在自线福利| 亚洲成a人片在线观看中文| 国产精品乱码一区二区三区软件| 日韩精品一区二区三区四区视频| 99精品视频一区二区| 国产精品亚洲成人| 久久91精品久久久久久秒播| 五月婷婷激情综合网| 一二三四区精品视频| 亚洲麻豆国产自偷在线| 中文字幕成人av| 国产调教视频一区| 久久久久久**毛片大全| www欧美成人18+| 欧美va亚洲va| 欧美刺激午夜性久久久久久久| 91精品国产91久久综合桃花| 欧美视频在线观看一区| 在线亚洲一区观看| 91精品福利视频| 色噜噜狠狠色综合中国| 91在线视频官网| 97精品久久久久中文字幕| jlzzjlzz亚洲日本少妇| 成人丝袜高跟foot| 懂色av一区二区在线播放| 国产盗摄精品一区二区三区在线| 国产毛片精品视频| 国产aⅴ综合色| hitomi一区二区三区精品| 99亚偷拍自图区亚洲| 一本到不卡精品视频在线观看| 日本高清成人免费播放| 欧美三区在线视频| 日韩一区二区三区在线视频| 欧美电影免费观看高清完整版 | 97久久久精品综合88久久| 99久久99久久精品国产片果冻| 成人av在线播放网址| 91色在线porny| 欧美日韩国产精品自在自线| 91精品国产综合久久香蕉麻豆| 欧美一个色资源| 26uuu欧美| 亚洲欧美怡红院| 五月激情综合婷婷| 精品一区二区三区免费毛片爱 | 日韩电影免费在线| 久久超级碰视频| 成人在线视频一区二区| 91久久精品午夜一区二区| 制服丝袜亚洲色图| 久久久精品综合| 亚洲综合激情小说| 日韩精品一级中文字幕精品视频免费观看 | 暴力调教一区二区三区| 爽爽淫人综合网网站| 久久超级碰视频| 91在线视频网址| 欧美精品乱人伦久久久久久| 精品美女被调教视频大全网站| 中文字幕第一区综合| 亚洲午夜久久久久| 狠狠久久亚洲欧美| 在线视频国内自拍亚洲视频| 欧美mv日韩mv| 亚洲另类中文字| 久久99精品国产麻豆婷婷洗澡| 91啪在线观看| 精品成a人在线观看| 亚洲欧洲制服丝袜| 美日韩一区二区三区| 色呦呦国产精品| xvideos.蜜桃一区二区| 亚洲综合一区二区三区| 国产不卡在线播放| 日韩视频在线你懂得| 亚洲蜜桃精久久久久久久| 久久 天天综合| 欧美日韩黄色一区二区| 自拍偷自拍亚洲精品播放| 久久99精品网久久| 欧美日韩视频在线第一区| 国产精品福利影院| 国产精品888| 精品乱人伦小说| 爽好多水快深点欧美视频| 色欧美乱欧美15图片| 国产欧美一区二区精品婷婷| 日本vs亚洲vs韩国一区三区 | 成人av网在线| 26uuu成人网一区二区三区| 午夜精品aaa| 在线精品亚洲一区二区不卡| 国产蜜臀97一区二区三区 | 99久久久久久| 欧美国产日韩一二三区| 伦理电影国产精品| 91.麻豆视频| 一区二区高清免费观看影视大全| 国产.欧美.日韩| 国产午夜精品久久久久久久| 黄色日韩三级电影| 精品国产不卡一区二区三区| 日韩电影一区二区三区四区| 欧美日韩一级视频| 亚洲国产精品久久久久婷婷884| 色综合亚洲欧洲| 日韩理论片在线| 色综合久久66| 亚洲第一精品在线| 欧美疯狂做受xxxx富婆| 日韩精品欧美成人高清一区二区|