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

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

?? vacuum.c

?? sqlite 3.3.8 支持加密的版本
?? C
字號:
/*
** 2003 April 6
**
** 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 file contains code used to implement the VACUUM command.
**
** Most of the code in this file may be omitted by defining the
** SQLITE_OMIT_VACUUM macro.
**
** $Id: vacuum.c,v 1.24 2006/10/12 21:34:22 rmsimpson Exp $
*/
#include "sqliteInt.h"
#include "vdbeInt.h"
#include "os.h"

#ifndef SQLITE_OMIT_VACUUM
/*
** Generate a random name of 20 character in length.
*/
static void randomName(unsigned char *zBuf){
  static const unsigned char zChars[] =
    "abcdefghijklmnopqrstuvwxyz"
    "0123456789";
  int i;
  sqlite3Randomness(20, zBuf);
  for(i=0; i<20; i++){
    zBuf[i] = zChars[ zBuf[i]%(sizeof(zChars)-1) ];
  }
}

/*
** Execute zSql on database db. Return an error code.
*/
static int execSql(sqlite3 *db, const char *zSql){
  sqlite3_stmt *pStmt;
  if( SQLITE_OK!=sqlite3_prepare(db, zSql, -1, &pStmt, 0) ){
    return sqlite3_errcode(db);
  }
  while( SQLITE_ROW==sqlite3_step(pStmt) ){}
  return sqlite3_finalize(pStmt);
}

/*
** Execute zSql on database db. The statement returns exactly
** one column. Execute this as SQL on the same database.
*/
static int execExecSql(sqlite3 *db, const char *zSql){
  sqlite3_stmt *pStmt;
  int rc;

  rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);
  if( rc!=SQLITE_OK ) return rc;

  while( SQLITE_ROW==sqlite3_step(pStmt) ){
    rc = execSql(db, (char*)sqlite3_column_text(pStmt, 0));
    if( rc!=SQLITE_OK ){
      sqlite3_finalize(pStmt);
      return rc;
    }
  }

  return sqlite3_finalize(pStmt);
}

/*
** The non-standard VACUUM command is used to clean up the database,
** collapse free space, etc.  It is modelled after the VACUUM command
** in PostgreSQL.
**
** In version 1.0.x of SQLite, the VACUUM command would call
** gdbm_reorganize() on all the database tables.  But beginning
** with 2.0.0, SQLite no longer uses GDBM so this command has
** become a no-op.
*/
void sqlite3Vacuum(Parse *pParse){
  Vdbe *v = sqlite3GetVdbe(pParse);
  if( v ){
    sqlite3VdbeAddOp(v, OP_Vacuum, 0, 0);
  }
  return;
}

/*
** This routine implements the OP_Vacuum opcode of the VDBE.
*/
int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
  int rc = SQLITE_OK;     /* Return code from service routines */
  const char *zFilename;  /* full pathname of the database file */
  int nFilename;          /* number of characters  in zFilename[] */
  char *zTemp = 0;        /* a temporary file in same directory as zFilename */
  Btree *pMain;           /* The database being vacuumed */
  Btree *pTemp;
  char *zSql = 0;
  int saved_flags;       /* Saved value of the db->flags */
  Db *pDb = 0;           /* Database to detach at end of vacuum */

  /* Save the current value of the write-schema flag before setting it. */
  saved_flags = db->flags;
  db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;

  if( !db->autoCommit ){
    sqlite3SetString(pzErrMsg, "cannot VACUUM from within a transaction", 
       (char*)0);
    rc = SQLITE_ERROR;
    goto end_of_vacuum;
  }

  /* Get the full pathname of the database file and create a
  ** temporary filename in the same directory as the original file.
  */
  pMain = db->aDb[0].pBt;
  zFilename = sqlite3BtreeGetFilename(pMain);
  assert( zFilename );
  if( zFilename[0]=='\0' ){
    /* The in-memory database. Do nothing. Return directly to avoid causing
    ** an error trying to DETACH the vacuum_db (which never got attached)
    ** in the exit-handler.
    */
    return SQLITE_OK;
  }
  nFilename = strlen(zFilename);
  zTemp = sqliteMalloc( nFilename+100 );
  if( zTemp==0 ){
    rc = SQLITE_NOMEM;
    goto end_of_vacuum;
  }
  strcpy(zTemp, zFilename);

  /* The randomName() procedure in the following loop uses an excellent
  ** source of randomness to generate a name from a space of 1.3e+31 
  ** possibilities.  So unless the directory already contains on the order
  ** of 1.3e+31 files, the probability that the following loop will
  ** run more than once or twice is vanishingly small.  We are certain
  ** enough that this loop will always terminate (and terminate quickly)
  ** that we don't even bother to set a maximum loop count.
  */
  do {
    zTemp[nFilename] = '-';
    randomName((unsigned char*)&zTemp[nFilename+1]);
  } while( sqlite3OsFileExists(zTemp) );

  /* Attach the temporary database as 'vacuum_db'. The synchronous pragma
  ** can be set to 'off' for this file, as it is not recovered if a crash
  ** occurs anyway. The integrity of the database is maintained by a
  ** (possibly synchronous) transaction opened on the main database before
  ** sqlite3BtreeCopyFile() is called.
  **
  ** An optimisation would be to use a non-journaled pager.
  */
  zSql = sqlite3MPrintf("ATTACH '%q' AS vacuum_db;", zTemp);
  if( !zSql ){
    rc = SQLITE_NOMEM;
    goto end_of_vacuum;
  }
  rc = execSql(db, zSql);
  sqliteFree(zSql);
  zSql = 0;
  if( rc!=SQLITE_OK ) goto end_of_vacuum;
  pDb = &db->aDb[db->nDb-1];
  assert( strcmp(db->aDb[db->nDb-1].zName,"vacuum_db")==0 );
  pTemp = db->aDb[db->nDb-1].pBt;
  sqlite3BtreeSetPageSize(pTemp, sqlite3BtreeGetPageSize(pMain),
     sqlite3BtreeGetReserve(pMain));
  assert( sqlite3BtreeGetPageSize(pTemp)==sqlite3BtreeGetPageSize(pMain) );
  rc = execSql(db, "PRAGMA vacuum_db.synchronous=OFF");
  if( rc!=SQLITE_OK ){
    goto end_of_vacuum;
  }

#ifndef SQLITE_OMIT_AUTOVACUUM
  sqlite3BtreeSetAutoVacuum(pTemp, sqlite3BtreeGetAutoVacuum(pMain));
#endif

  /* Begin a transaction */
  rc = execSql(db, "BEGIN EXCLUSIVE;");
  if( rc!=SQLITE_OK ) goto end_of_vacuum;

  /* Query the schema of the main database. Create a mirror schema
  ** in the temporary database.
  */
  rc = execExecSql(db, 
      "SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14,100000000) "
      "  FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence'"
      "   AND rootpage>0"
  );
  if( rc!=SQLITE_OK ) goto end_of_vacuum;
  rc = execExecSql(db, 
      "SELECT 'CREATE INDEX vacuum_db.' || substr(sql,14,100000000)"
      "  FROM sqlite_master WHERE sql LIKE 'CREATE INDEX %' ");
  if( rc!=SQLITE_OK ) goto end_of_vacuum;
  rc = execExecSql(db, 
      "SELECT 'CREATE UNIQUE INDEX vacuum_db.' || substr(sql,21,100000000) "
      "  FROM sqlite_master WHERE sql LIKE 'CREATE UNIQUE INDEX %'");
  if( rc!=SQLITE_OK ) goto end_of_vacuum;

  /* Loop through the tables in the main database. For each, do
  ** an "INSERT INTO vacuum_db.xxx SELECT * FROM xxx;" to copy
  ** the contents to the temporary database.
  */
  rc = execExecSql(db, 
      "SELECT 'INSERT INTO vacuum_db.' || quote(name) "
      "|| ' SELECT * FROM ' || quote(name) || ';'"
      "FROM sqlite_master "
      "WHERE type = 'table' AND name!='sqlite_sequence' "
      "  AND rootpage>0"

  );
  if( rc!=SQLITE_OK ) goto end_of_vacuum;

  /* Copy over the sequence table
  */
  rc = execExecSql(db, 
      "SELECT 'DELETE FROM vacuum_db.' || quote(name) || ';' "
      "FROM vacuum_db.sqlite_master WHERE name='sqlite_sequence' "
  );
  if( rc!=SQLITE_OK ) goto end_of_vacuum;
  rc = execExecSql(db, 
      "SELECT 'INSERT INTO vacuum_db.' || quote(name) "
      "|| ' SELECT * FROM ' || quote(name) || ';' "
      "FROM vacuum_db.sqlite_master WHERE name=='sqlite_sequence';"
  );
  if( rc!=SQLITE_OK ) goto end_of_vacuum;


  /* Copy the triggers, views, and virtual tables from the main database
  ** over to the temporary database.  None of these objects has any
  ** associated storage, so all we have to do is copy their entries
  ** from the SQLITE_MASTER table.
  */
  rc = execSql(db,
      "INSERT INTO vacuum_db.sqlite_master "
      "  SELECT type, name, tbl_name, rootpage, sql"
      "    FROM sqlite_master"
      "   WHERE type='view' OR type='trigger'"
      "      OR (type='table' AND rootpage=0)"
  );
  if( rc ) goto end_of_vacuum;

  /* At this point, unless the main db was completely empty, there is now a
  ** transaction open on the vacuum database, but not on the main database.
  ** Open a btree level transaction on the main database. This allows a
  ** call to sqlite3BtreeCopyFile(). The main database btree level
  ** transaction is then committed, so the SQL level never knows it was
  ** opened for writing. This way, the SQL transaction used to create the
  ** temporary database never needs to be committed.
  */
  if( rc==SQLITE_OK ){
    u32 meta;
    int i;

    /* This array determines which meta meta values are preserved in the
    ** vacuum.  Even entries are the meta value number and odd entries
    ** are an increment to apply to the meta value after the vacuum.
    ** The increment is used to increase the schema cookie so that other
    ** connections to the same database will know to reread the schema.
    */
    static const unsigned char aCopy[] = {
       1, 1,    /* Add one to the old schema cookie */
       3, 0,    /* Preserve the default page cache size */
       5, 0,    /* Preserve the default text encoding */
       6, 0,    /* Preserve the user version */
    };

    assert( 1==sqlite3BtreeIsInTrans(pTemp) );
    assert( 1==sqlite3BtreeIsInTrans(pMain) );

    /* Copy Btree meta values */
    for(i=0; i<sizeof(aCopy)/sizeof(aCopy[0]); i+=2){
      rc = sqlite3BtreeGetMeta(pMain, aCopy[i], &meta);
      if( rc!=SQLITE_OK ) goto end_of_vacuum;
      rc = sqlite3BtreeUpdateMeta(pTemp, aCopy[i], meta+aCopy[i+1]);
      if( rc!=SQLITE_OK ) goto end_of_vacuum;
    }

    rc = sqlite3BtreeCopyFile(pMain, pTemp);
    if( rc!=SQLITE_OK ) goto end_of_vacuum;
    rc = sqlite3BtreeCommit(pTemp);
    if( rc!=SQLITE_OK ) goto end_of_vacuum;
    rc = sqlite3BtreeCommit(pMain);
  }

end_of_vacuum:
  /* Restore the original value of db->flags */
  db->flags = saved_flags;

  /* Currently there is an SQL level transaction open on the vacuum
  ** database. No locks are held on any other files (since the main file
  ** was committed at the btree level). So it safe to end the transaction
  ** by manually setting the autoCommit flag to true and detaching the
  ** vacuum database. The vacuum_db journal file is deleted when the pager
  ** is closed by the DETACH.
  */
  db->autoCommit = 1;

  if( pDb ){
    sqlite3MallocDisallow();
    sqlite3BtreeClose(pDb->pBt);
    sqlite3MallocAllow();
    pDb->pBt = 0;
    pDb->pSchema = 0;
  }

  if( zTemp ){
    sqlite3OsDelete(zTemp);
    sqliteFree(zTemp);
  }
  sqliteFree( zSql );
  sqlite3ResetInternalSchema(db, 0);

  return rc;
}
#endif  /* SQLITE_OMIT_VACUUM */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本一区二区三区久久久久久久久不| 久久久精品一品道一区| 韩国女主播成人在线| 亚洲另类色综合网站| 亚洲精品一区二区精华| 日本韩国欧美在线| 国产成人亚洲精品青草天美| 亚洲国产精品久久一线不卡| 国产精品―色哟哟| 日韩一级完整毛片| 欧美影院精品一区| 成人国产一区二区三区精品| 日本色综合中文字幕| 亚洲美女免费在线| 久久久欧美精品sm网站| 日韩一级大片在线观看| 欧美在线观看视频在线| 成人自拍视频在线观看| 国产在线不卡视频| 日韩福利视频导航| 亚洲成人免费av| 亚洲一区二区三区中文字幕在线| 欧美经典一区二区| 日韩欧美一级二级| 91 com成人网| 欧美日韩国产123区| 欧美在线综合视频| 一本色道久久综合精品竹菊| 成人性生交大片免费看视频在线| 久久国产精品无码网站| 免费高清成人在线| 蜜桃av一区二区三区电影| 五月综合激情日本mⅴ| 亚洲一区二区在线播放相泽| 亚洲影视在线观看| 依依成人综合视频| 亚洲综合激情另类小说区| 五月天网站亚洲| 亚洲一区二区av在线| 亚洲综合一区二区| 亚洲国产成人va在线观看天堂| 亚洲精品成人天堂一二三| 亚洲三级小视频| 亚洲人成影院在线观看| 亚洲免费大片在线观看| 依依成人精品视频| 亚洲成av人片www| 婷婷丁香久久五月婷婷| 日本大胆欧美人术艺术动态| 亚洲九九爱视频| 午夜日韩在线观看| 免费成人av资源网| 久久99精品国产| 国产激情一区二区三区桃花岛亚洲| 国产91高潮流白浆在线麻豆| 成人激情开心网| 91福利视频在线| 欧美精品v国产精品v日韩精品| 日韩一级完整毛片| 国产网站一区二区| 中文字幕在线播放不卡一区| 亚洲精品精品亚洲| 香港成人在线视频| 国产最新精品免费| 成人av在线看| 欧洲一区二区av| 欧美成人乱码一区二区三区| 国产日韩av一区| 亚洲欧美怡红院| 天天综合色天天| 国产一区二区调教| 99精品视频在线播放观看| 欧美日韩高清一区二区三区| 欧美不卡一区二区三区四区| 国产精品麻豆视频| 亚洲狠狠爱一区二区三区| 狠狠网亚洲精品| 色婷婷综合久久久中文一区二区| 欧美人伦禁忌dvd放荡欲情| 精品久久久久久久久久久久包黑料| 国产亚洲综合在线| 亚洲一区二区av在线| 九色综合狠狠综合久久| 91亚洲国产成人精品一区二三| 欧美一级一区二区| 欧美国产精品v| 三级一区在线视频先锋| 成人免费看视频| 欧美日韩一区三区四区| 久久久久久久综合日本| 亚洲va韩国va欧美va精品| 国产精品一区久久久久| 欧美日韩一区高清| 精品黑人一区二区三区久久| 亚洲精品国产第一综合99久久 | 青青草成人在线观看| 国产精品白丝jk白祙喷水网站 | 国产精品美女久久久久久久久久久 | 国产成人免费在线视频| 欧美偷拍一区二区| 国产视频一区在线播放| 免费一级欧美片在线观看| 成人国产精品视频| 91.com在线观看| 亚洲色欲色欲www| 国产一区二区精品久久99| 日本一区二区综合亚洲| 天天操天天色综合| 成人app网站| 日韩欧美一区在线观看| 亚洲一区二区三区四区在线| 成人开心网精品视频| 精品国产乱码久久久久久夜甘婷婷| 一区二区三区欧美激情| 成人高清av在线| 欧美精品丝袜中出| 亚洲日本在线观看| 成人激情免费视频| 久久久久97国产精华液好用吗| 免费成人性网站| 欧美喷水一区二区| 亚洲一区二区三区视频在线| 99精品久久免费看蜜臀剧情介绍| 精品99一区二区三区| 九九视频精品免费| 日韩欧美一级在线播放| 日韩一区欧美二区| 欧美老年两性高潮| 亚洲国产cao| 在线观看免费视频综合| 一区二区三区四区在线免费观看| 97久久精品人人爽人人爽蜜臀| 亚洲欧洲韩国日本视频| 岛国精品一区二区| 国产精品久久影院| 成人91在线观看| 国产精品国产三级国产三级人妇| 国产aⅴ综合色| 久久久亚洲高清| 成人sese在线| 亚洲欧美日韩一区| 色综合激情久久| 一区二区在线观看av| 欧美在线视频你懂得| 亚洲国产综合在线| 91麻豆精品国产无毒不卡在线观看| 亚洲一区二区三区在线| 欧美日韩亚州综合| 日韩在线一区二区| 日韩一区二区精品葵司在线| 国产麻豆一精品一av一免费 | 国产精品欧美一区二区三区| 丁香亚洲综合激情啪啪综合| 自拍偷拍欧美精品| 在线观看av一区二区| 午夜精品成人在线| 欧美mv日韩mv亚洲| 国产馆精品极品| 自拍偷拍国产精品| 欧美日韩一级片网站| 蜜桃av一区二区三区电影| 337p粉嫩大胆色噜噜噜噜亚洲| 国产成人丝袜美腿| 亚洲日本在线a| 在线电影一区二区三区| 久久精品国产99久久6| 国产拍欧美日韩视频二区| 色哟哟一区二区在线观看| 亚洲综合另类小说| 精品电影一区二区三区| 99久久精品国产网站| 午夜精品视频在线观看| 久久久电影一区二区三区| 91网页版在线| 日本人妖一区二区| 中文字幕一区二区三区视频| 欧美美女激情18p| 国产不卡在线视频| 亚洲午夜久久久久| 久久久久久一级片| 欧洲一区二区三区在线| 国产乱一区二区| 亚洲一线二线三线视频| 久久视频一区二区| 精品视频色一区| 国产成人av影院| 日韩经典一区二区| 国产精品美女一区二区三区| 欧美一区二区三区思思人| av不卡在线观看| 麻豆国产精品一区二区三区 | 欧美色区777第一页| 国产一区在线看| 午夜av一区二区| **欧美大码日韩| 精品国产凹凸成av人导航| 在线观看欧美精品| 99免费精品在线观看| 国产精品一区二区在线观看网站 | 一区视频在线播放|