您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ sqlite3FindTable函数代码示例

51自学网 2021-06-03 08:13:51
  C++
这篇教程C++ sqlite3FindTable函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中sqlite3FindTable函数的典型用法代码示例。如果您正苦于以下问题:C++ sqlite3FindTable函数的具体用法?C++ sqlite3FindTable怎么用?C++ sqlite3FindTable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了sqlite3FindTable函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: sqlite3AnalysisLoad

/*** Load the content of the sqlite_stat1 table into the index hash tables.*/int sqlite3AnalysisLoad(sqlite3 *db, int iDb){  analysisInfo sInfo;  HashElem *i;  char *zSql;  int rc;  assert( iDb>=0 && iDb<db->nDb );  assert( db->aDb[iDb].pBt!=0 );  assert( sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );  /* Clear any prior statistics */  for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){    Index *pIdx = sqliteHashData(i);    sqlite3DefaultRowEst(pIdx);  }  /* Check to make sure the sqlite_stat1 table existss */  sInfo.db = db;  sInfo.zDatabase = db->aDb[iDb].zName;  if( sqlite3FindTable(db, "sqlite_stat1", sInfo.zDatabase)==0 ){     return SQLITE_ERROR;  }  /* Load new statistics out of the sqlite_stat1 table */  zSql = sqlite3MPrintf(db, "SELECT idx, stat FROM %Q.sqlite_stat1",                        sInfo.zDatabase);  sqlite3SafetyOff(db);  rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);  sqlite3SafetyOn(db);  sqlite3_free(zSql);  return rc;}
开发者ID:ChunHungLiu,项目名称:Reclass-2015,代码行数:36,


示例2: sqlite3VtabCallCreate

/*** This function is invoked by the vdbe to call the xCreate method** of the virtual table named zTab in database iDb. **** If an error occurs, *pzErr is set to point to an English language** description of the error and an SQLITE_XXX error code is returned.** In this case the caller must call sqlite3DbFree(db, ) on *pzErr.*/int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){  int rc = SQLITE_OK;  Table *pTab;  Module *pMod;  const char *zMod;  pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName);  assert( pTab && (pTab->tabFlags & TF_Virtual)!=0 && !pTab->pVTable );  /* Locate the required virtual table module */  zMod = pTab->azModuleArg[0];  pMod = (Module*)sqlite3HashFind(&db->aModule, zMod);  /* If the module has been registered and includes a Create method,   ** invoke it now. If the module has not been registered, return an   ** error. Otherwise, do nothing.  */  if( pMod==0 || pMod->pModule->xCreate==0 || pMod->pModule->xDestroy==0 ){    *pzErr = sqlite3MPrintf(db, "no such module: %s", zMod);    rc = SQLITE_ERROR;  }else{    rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xCreate, pzErr);  }  /* Justification of ALWAYS():  The xConstructor method is required to  ** create a valid sqlite3_vtab if it returns SQLITE_OK. */  if( rc==SQLITE_OK && ALWAYS(sqlite3GetVTable(db, pTab)) ){    rc = growVTrans(db);    if( rc==SQLITE_OK ){      addToVTrans(db, sqlite3GetVTable(db, pTab));    }  }  return rc;}
开发者ID:wangyiran126,项目名称:sqlite,代码行数:43,


示例3: sqlite3VtabCallDestroy

/*** This function is invoked by the vdbe to call the xDestroy method** of the virtual table named zTab in database iDb. This occurs** when a DROP TABLE is mentioned.**** This call is a no-op if zTab is not a virtual table.*/int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){  int rc = SQLITE_OK;  Table *pTab;  pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName);  if( pTab!=0 && ALWAYS(pTab->pVTable!=0) ){    VTable *p;    int (*xDestroy)(sqlite3_vtab *);    for(p=pTab->pVTable; p; p=p->pNext){      assert( p->pVtab );      if( p->pVtab->nRef>0 ){        return SQLITE_LOCKED;      }    }    p = vtabDisconnectAll(db, pTab);    xDestroy = p->pMod->pModule->xDestroy;    assert( xDestroy!=0 );  /* Checked before the virtual table is created */    rc = xDestroy(p->pVtab);    /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */    if( rc==SQLITE_OK ){      assert( pTab->pVTable==p && p->pNext==0 );      p->pVtab = 0;      pTab->pVTable = 0;      sqlite3VtabUnlock(p);    }  }  return rc;}
开发者ID:wangyiran126,项目名称:sqlite,代码行数:36,


示例4: sqlite3VtabCallCreate

/*** This function is invoked by the vdbe to call the xCreate method** of the virtual table named zTab in database iDb. **** If an error occurs, *pzErr is set to point an an English language** description of the error and an SQLITE_XXX error code is returned.** In this case the caller must call sqliteFree() on *pzErr.*/int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){  int rc = SQLITE_OK;  Table *pTab;  Module *pMod;  const char *zModule;  pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);  assert(pTab && pTab->isVirtual && !pTab->pVtab);  pMod = pTab->pMod;  zModule = pTab->azModuleArg[0];  /* If the module has been registered and includes a Create method,   ** invoke it now. If the module has not been registered, return an   ** error. Otherwise, do nothing.  */  if( !pMod ){    *pzErr = sqlite3MPrintf("no such module: %s", zModule);    rc = SQLITE_ERROR;  }else{    rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xCreate, pzErr);  }  if( rc==SQLITE_OK && pTab->pVtab ){      rc = addToVTrans(db, pTab->pVtab);  }  return rc;}
开发者ID:Bracket-,项目名称:psp-ports,代码行数:36,


示例5: sqlite3AnalysisLoad

/*** Load the content of the sqlite_stat1 table into the index hash tables.*/void sqlite3AnalysisLoad(sqlite3 *db, int iDb){  analysisInfo sInfo;  HashElem *i;  char *zSql;  /* Clear any prior statistics */  for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){    Index *pIdx = sqliteHashData(i);    sqlite3DefaultRowEst(pIdx);  }  /* Check to make sure the sqlite_stat1 table existss */  sInfo.db = db;  sInfo.zDatabase = db->aDb[iDb].zName;  if( sqlite3FindTable(db, "sqlite_stat1", sInfo.zDatabase)==0 ){     return;  }  /* Load new statistics out of the sqlite_stat1 table */  zSql = sqlite3MPrintf("SELECT idx, stat FROM %Q.sqlite_stat1",                        sInfo.zDatabase);  sqlite3SafetyOff(db);  sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);  sqlite3SafetyOn(db);  sqliteFree(zSql);}
开发者ID:GameLemur,项目名称:nebula-device3,代码行数:30,


示例6: openStatTable

/*** This routine generates code that opens the sqlite_stat1 table on cursor** iStatCur.**** If the sqlite_stat1 tables does not previously exist, it is created.** If it does previously exist, all entires associated with table zWhere** are removed.  If zWhere==0 then all entries are removed.*/static void openStatTable(  Parse *pParse,          /* Parsing context */  int iDb,                /* The database we are looking in */  int iStatCur,           /* Open the sqlite_stat1 table on this cursor */  const char *zWhere      /* Delete entries associated with this table */){  sqlite3 *db = pParse->db;  Db *pDb;  int iRootPage;  Table *pStat;  Vdbe *v = sqlite3GetVdbe(pParse);  if( v==0 ) return;  assert( sqlite3BtreeHoldsAllMutexes(db) );  assert( sqlite3VdbeDb(v)==db );  pDb = &db->aDb[iDb];  if( (pStat = sqlite3FindTable(db, "sqlite_stat1", pDb->zName))==0 ){    /* The sqlite_stat1 tables does not exist.  Create it.      ** Note that a side-effect of the CREATE TABLE statement is to leave    ** the rootpage of the new table on the top of the stack.  This is    ** important because the OpenWrite opcode below will be needing it. */    sqlite3NestedParse(pParse,      "CREATE TABLE %Q.sqlite_stat1(tbl,idx,stat)",      pDb->zName    );    iRootPage = 0;  /* Cause rootpage to be taken from top of stack */  }else if( zWhere ){    /* The sqlite_stat1 table exists.  Delete all entries associated with    ** the table zWhere. */    sqlite3NestedParse(pParse,       "DELETE FROM %Q.sqlite_stat1 WHERE tbl=%Q",       pDb->zName, zWhere    );    iRootPage = pStat->tnum;  }else{    /* The sqlite_stat1 table already exists.  Delete all rows. */    iRootPage = pStat->tnum;    sqlite3VdbeAddOp(v, OP_Clear, pStat->tnum, iDb);  }  /* Open the sqlite_stat1 table for writing. Unless it was created  ** by this vdbe program, lock it for writing at the shared-cache level.   ** If this vdbe did create the sqlite_stat1 table, then it must have   ** already obtained a schema-lock, making the write-lock redundant.  */  if( iRootPage>0 ){    sqlite3TableLock(pParse, iDb, iRootPage, 1, "sqlite_stat1");  }  sqlite3VdbeAddOp(v, OP_Integer, iDb, 0);  sqlite3VdbeAddOp(v, OP_OpenWrite, iStatCur, iRootPage);  sqlite3VdbeAddOp(v, OP_SetNumColumns, iStatCur, 3);}
开发者ID:ChunHungLiu,项目名称:Reclass-2015,代码行数:60,


示例7: openStatTable

/*** This routine generates code that opens the sqlite_stat1 table on cursor** iStatCur.**** If the sqlite_stat1 tables does not previously exist, it is created.** If it does previously exist, all entires associated with table zWhere** are removed.  If zWhere==0 then all entries are removed.*/static void openStatTable(  Parse *pParse,          /* Parsing context */  int iDb,                /* The database we are looking in */  int iStatCur,           /* Open the sqlite_stat1 table on this cursor */  const char *zWhere      /* Delete entries associated with this table */){  sqlite3 *db = pParse->db;  Db *pDb;  int iRootPage;  Table *pStat;  Vdbe *v = sqlite3GetVdbe(pParse);  pDb = &db->aDb[iDb];  if( (pStat = sqlite3FindTable(db, "sqlite_stat1", pDb->zName))==0 ){    /* The sqlite_stat1 tables does not exist.  Create it.      ** Note that a side-effect of the CREATE TABLE statement is to leave    ** the rootpage of the new table on the top of the stack.  This is    ** important because the OpenWrite opcode below will be needing it. */    sqlite3NestedParse(pParse,      "CREATE TABLE %Q.sqlite_stat1(tbl,idx,stat)",      pDb->zName    );    iRootPage = 0;  /* Cause rootpage to be taken from top of stack */  }else if( zWhere ){    /* The sqlite_stat1 table exists.  Delete all entries associated with    ** the table zWhere. */    sqlite3NestedParse(pParse,       "DELETE FROM %Q.sqlite_stat1 WHERE tbl=%Q",       pDb->zName, zWhere    );    iRootPage = pStat->tnum;  }else{    /* The sqlite_stat1 table already exists.  Delete all rows. */    iRootPage = pStat->tnum;    sqlite3VdbeAddOp(v, OP_Clear, pStat->tnum, iDb);  }  /* Open the sqlite_stat1 table for writing.  */  sqlite3VdbeAddOp(v, OP_Integer, iDb, 0);  sqlite3VdbeAddOp(v, OP_OpenWrite, iStatCur, iRootPage);  sqlite3VdbeAddOp(v, OP_SetNumColumns, iStatCur, 3);}
开发者ID:stephen-hill,项目名称:musicCube,代码行数:51,


示例8: analysisLoader

/*** This callback is invoked once for each index when reading the** sqlite_stat1 table.  ****     argv[0] = name of the table**     argv[1] = name of the index (might be NULL)**     argv[2] = results of analysis - on integer for each column**** Entries for which argv[1]==NULL simply record the number of rows in** the table.*/static int analysisLoader(void *pData, int argc, char **argv, char **NotUsed){  analysisInfo *pInfo = (analysisInfo*)pData;  Index *pIndex;  Table *pTable;  int i, c, n;  unsigned int v;  const char *z;  assert( argc==3 );  UNUSED_PARAMETER2(NotUsed, argc);  if( argv==0 || argv[0]==0 || argv[2]==0 ){    return 0;  }  pTable = sqlite3FindTable(pInfo->db, argv[0], pInfo->zDatabase);  if( pTable==0 ){    return 0;  }  if( argv[1] ){    pIndex = sqlite3FindIndex(pInfo->db, argv[1], pInfo->zDatabase);  }else{    pIndex = 0;  }  n = pIndex ? pIndex->nColumn : 0;  z = argv[2];  for(i=0; *z && i<=n; i++){    v = 0;    while( (c=z[0])>='0' && c<='9' ){      v = v*10 + c - '0';      z++;    }    if( i==0 ) pTable->nRowEst = v;    if( pIndex==0 ) break;    pIndex->aiRowEst[i] = v;    if( *z==' ' ) z++;    if( memcmp(z, "unordered", 10)==0 ){      pIndex->bUnordered = 1;      break;    }  }  return 0;}
开发者ID:sunyangkobe,项目名称:db_research,代码行数:53,


示例9: sqlite3VtabCallDestroy

/*** This function is invoked by the vdbe to call the xDestroy method** of the virtual table named zTab in database iDb. This occurs** when a DROP TABLE is mentioned.**** This call is a no-op if zTab is not a virtual table.*/int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){  int rc = SQLITE_OK;  Table *pTab;  pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);  assert(pTab);  if( pTab->pVtab ){    int (*xDestroy)(sqlite3_vtab *pVTab) = pTab->pMod->pModule->xDestroy;    rc = sqlite3SafetyOff(db);    assert( rc==SQLITE_OK );    if( xDestroy ){      rc = xDestroy(pTab->pVtab);    }    sqlite3SafetyOn(db);    if( rc==SQLITE_OK ){      pTab->pVtab = 0;    }  }  return rc;}
开发者ID:Bracket-,项目名称:psp-ports,代码行数:29,


示例10: sqlite3VtabCallDestroy

/*** This function is invoked by the vdbe to call the xDestroy method** of the virtual table named zTab in database iDb. This occurs** when a DROP TABLE is mentioned.**** This call is a no-op if zTab is not a virtual table.*/int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){  int rc = SQLITE_OK;  Table *pTab;  pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);  if( ALWAYS(pTab!=0 && pTab->pVTable!=0) ){    VTable *p = vtabDisconnectAll(db, pTab);    assert( rc==SQLITE_OK );    rc = p->pMod->pModule->xDestroy(p->pVtab);    /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */    if( rc==SQLITE_OK ){      assert( pTab->pVTable==p && p->pNext==0 );      p->pVtab = 0;      pTab->pVTable = 0;      sqlite3VtabUnlock(p);    }  }  return rc;}
开发者ID:AchironOS,项目名称:chromium-2,代码行数:29,


示例11: sqlite3Pragma

//.........这里部分代码省略.........      if( !db->autoCommit ){        sqlite3ErrorMsg(pParse,             "Safety level may not be changed inside a transaction");      }else{        pDb->safety_level = getSafetyLevel(zRight)+1;      }    }  }else#endif /* SQLITE_OMIT_PAGER_PRAGMAS */#ifndef SQLITE_OMIT_FLAG_PRAGMAS  if( flagPragma(pParse, zLeft, zRight) ){    /* The flagPragma() subroutine also generates any necessary code    ** there is nothing more to do here */  }else#endif /* SQLITE_OMIT_FLAG_PRAGMAS */#ifndef SQLITE_OMIT_SCHEMA_PRAGMAS  /*  **   PRAGMA table_info(<table>)  **  ** Return a single row for each column of the named table. The columns of  ** the returned data set are:  **  ** cid:        Column id (numbered from left to right, starting at 0)  ** name:       Column name  ** type:       Column declaration type.  ** notnull:    True if 'NOT NULL' is part of column declaration  ** dflt_value: The default value for the column, if any.  */  if( sqlite3StrICmp(zLeft, "table_info")==0 && zRight ){    Table *pTab;    if( sqlite3ReadSchema(pParse) ) goto pragma_out;    pTab = sqlite3FindTable(db, zRight, zDb);    if( pTab ){      int i;      int nHidden = 0;      Column *pCol;      sqlite3VdbeSetNumCols(v, 6);      pParse->nMem = 6;      sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cid", P4_STATIC);      sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", P4_STATIC);      sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "type", P4_STATIC);      sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "notnull", P4_STATIC);      sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "dflt_value", P4_STATIC);      sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "pk", P4_STATIC);      sqlite3ViewGetColumnNames(pParse, pTab);      for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){        const Token *pDflt;        if( IsHiddenColumn(pCol) ){          nHidden++;          continue;        }        sqlite3VdbeAddOp2(v, OP_Integer, i-nHidden, 1);        sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pCol->zName, 0);        sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,           pCol->zType ? pCol->zType : "", 0);        sqlite3VdbeAddOp2(v, OP_Integer, pCol->notNull, 4);        if( pCol->pDflt && (pDflt = &pCol->pDflt->span)->z ){          sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, (char*)pDflt->z, pDflt->n);        }else{          sqlite3VdbeAddOp2(v, OP_Null, 0, 5);        }        sqlite3VdbeAddOp2(v, OP_Integer, pCol->isPrimKey, 6);        sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);      }
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:67,


示例12: sqlite3InitOne

/*** Attempt to read the database schema and initialize internal** data structures for a single database file.  The index of the** database file is given by iDb.  iDb==0 is used for the main** database.  iDb==1 should never be used.  iDb>=2 is used for** auxiliary databases.  Return one of the SQLITE_ error codes to** indicate success or failure.*/static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){  int rc;  BtCursor *curMain;  int size;  Table *pTab;  char const *azArg[5];  char zDbNum[30];  int meta[10];  InitData initData;  char const *zMasterSchema;  char const *zMasterName = SCHEMA_TABLE(iDb);  /*  ** The master database table has a structure like this  */  static const char master_schema[] =      "CREATE TABLE sqlite_master(/n"     "  type text,/n"     "  name text,/n"     "  tbl_name text,/n"     "  rootpage integer,/n"     "  sql text/n"     ")"  ;#ifndef SQLITE_OMIT_TEMPDB  static const char temp_master_schema[] =      "CREATE TEMP TABLE sqlite_temp_master(/n"     "  type text,/n"     "  name text,/n"     "  tbl_name text,/n"     "  rootpage integer,/n"     "  sql text/n"     ")"  ;#else  #define temp_master_schema 0#endif  assert( iDb>=0 && iDb<db->nDb );  /* zMasterSchema and zInitScript are set to point at the master schema  ** and initialisation script appropriate for the database being  ** initialised. zMasterName is the name of the master table.  */  if( !OMIT_TEMPDB && iDb==1 ){    zMasterSchema = temp_master_schema;  }else{    zMasterSchema = master_schema;  }  zMasterName = SCHEMA_TABLE(iDb);  /* Construct the schema tables.  */  sqlite3SafetyOff(db);  azArg[0] = zMasterName;  azArg[1] = "1";  azArg[2] = zMasterSchema;  sprintf(zDbNum, "%d", iDb);  azArg[3] = zDbNum;  azArg[4] = 0;  initData.db = db;  initData.pzErrMsg = pzErrMsg;  rc = sqlite3InitCallback(&initData, 4, (char **)azArg, 0);  if( rc!=SQLITE_OK ){    sqlite3SafetyOn(db);    return rc;  }  pTab = sqlite3FindTable(db, zMasterName, db->aDb[iDb].zName);  if( pTab ){    pTab->readOnly = 1;  }  sqlite3SafetyOn(db);  /* Create a cursor to hold the database open  */  if( db->aDb[iDb].pBt==0 ){    if( !OMIT_TEMPDB && iDb==1 ) DbSetProperty(db, 1, DB_SchemaLoaded);    return SQLITE_OK;  }  rc = sqlite3BtreeCursor(db->aDb[iDb].pBt, MASTER_ROOT, 0, 0, 0, &curMain);  if( rc!=SQLITE_OK && rc!=SQLITE_EMPTY ){    sqlite3SetString(pzErrMsg, sqlite3ErrStr(rc), (char*)0);    return rc;  }  /* Get the database meta information.  **  ** Meta values are as follows:  **    meta[0]   Schema cookie.  Changes with each schema change.  **    meta[1]   File format of schema layer.  **    meta[2]   Size of the page cache.  **    meta[3]   Use freelist if 0.  Autovacuum if greater than zero.  **    meta[4]   Db text encoding. 1:UTF-8 3:UTF-16 LE 4:UTF-16 BE//.........这里部分代码省略.........
开发者ID:DSD-TELCEL-ESCOM,项目名称:INE-Votation-Distributed-System,代码行数:101,


示例13: openStatTable

/*** This routine generates code that opens the sqlite_stat1 table for** writing with cursor iStatCur. If the library was built with the** SQLITE_ENABLE_STAT2 macro defined, then the sqlite_stat2 table is** opened for writing using cursor (iStatCur+1)**** If the sqlite_stat1 tables does not previously exist, it is created.** Similarly, if the sqlite_stat2 table does not exist and the library** is compiled with SQLITE_ENABLE_STAT2 defined, it is created. **** Argument zWhere may be a pointer to a buffer containing a table name,** or it may be a NULL pointer. If it is not NULL, then all entries in** the sqlite_stat1 and (if applicable) sqlite_stat2 tables associated** with the named table are deleted. If zWhere==0, then code is generated** to delete all stat table entries.*/static void openStatTable(  Parse *pParse,          /* Parsing context */  int iDb,                /* The database we are looking in */  int iStatCur,           /* Open the sqlite_stat1 table on this cursor */  const char *zWhere,     /* Delete entries for this table or index */  const char *zWhereType  /* Either "tbl" or "idx" */){  static const struct {    const char *zName;    const char *zCols;  } aTable[] = {    { "sqlite_stat1", "tbl,idx,stat" },#ifdef SQLITE_ENABLE_STAT2    { "sqlite_stat2", "tbl,idx,sampleno,sample" },#endif  };  int aRoot[] = {0, 0};  u8 aCreateTbl[] = {0, 0};  int i;  sqlite3 *db = pParse->db;  Db *pDb;  Vdbe *v = sqlite3GetVdbe(pParse);  if( v==0 ) return;  assert( sqlite3BtreeHoldsAllMutexes(db) );  assert( sqlite3VdbeDb(v)==db );  pDb = &db->aDb[iDb];  for(i=0; i<ArraySize(aTable); i++){    const char *zTab = aTable[i].zName;    Table *pStat;    if( (pStat = sqlite3FindTable(db, zTab, pDb->zName))==0 ){      /* The sqlite_stat[12] table does not exist. Create it. Note that a       ** side-effect of the CREATE TABLE statement is to leave the rootpage       ** of the new table in register pParse->regRoot. This is important       ** because the OpenWrite opcode below will be needing it. */      sqlite3NestedParse(pParse,          "CREATE TABLE %Q.%s(%s)", pDb->zName, zTab, aTable[i].zCols      );      aRoot[i] = pParse->regRoot;      aCreateTbl[i] = 1;    }else{      /* The table already exists. If zWhere is not NULL, delete all entries       ** associated with the table zWhere. If zWhere is NULL, delete the      ** entire contents of the table. */      aRoot[i] = pStat->tnum;      sqlite3TableLock(pParse, iDb, aRoot[i], 1, zTab);      if( zWhere ){        sqlite3NestedParse(pParse,           "DELETE FROM %Q.%s WHERE %s=%Q", pDb->zName, zTab, zWhereType, zWhere        );      }else{        /* The sqlite_stat[12] table already exists.  Delete all rows. */        sqlite3VdbeAddOp2(v, OP_Clear, aRoot[i], iDb);      }    }  }  /* Open the sqlite_stat[12] tables for writing. */  for(i=0; i<ArraySize(aTable); i++){    sqlite3VdbeAddOp3(v, OP_OpenWrite, iStatCur+i, aRoot[i], iDb);    sqlite3VdbeChangeP4(v, -1, (char *)3, P4_INT32);    sqlite3VdbeChangeP5(v, aCreateTbl[i]);  }}
开发者ID:sunyangkobe,项目名称:db_research,代码行数:82,


示例14: sqlite3AlterFinishAddColumn

/*** This function is called after an "ALTER TABLE ... ADD" statement** has been parsed. Argument pColDef contains the text of the new** column definition.**** The Table structure pParse->pNewTable was extended to include** the new column during parsing.在“ALTER TABLE…添加“声明解析后这个函数被调用。参数pColDef包含新列定义的文本。表结构pParse - > pNewTable扩大到包括在解析新列。*/void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){  Table *pNew;              /* Copy of pParse->pNewTable pParse->pNew表的副本*/  Table *pTab;              /* Table being altered 被修改的表*/  int iDb;                  /* Database number 数据库数*/  const char *zDb;          /* Database name 数据库名*/  const char *zTab;         /* Table name 表名*/  char *zCol;               /* Null-terminated column definition 空值终止列定义*/  Column *pCol;             /* The new column 新列*/  Expr *pDflt;              /* Default value for the new column 为新列默认数值*/  sqlite3 *db;              /* The database connection; 数据库的连接*/  db = pParse->db;  if( pParse->nErr || db->mallocFailed ) return;  pNew = pParse->pNewTable;  assert( pNew );  assert( sqlite3BtreeHoldsAllMutexes(db) );  iDb = sqlite3SchemaToIndex(db, pNew->pSchema);  zDb = db->aDb[iDb].zName;  zTab = &pNew->zName[16];  /* Skip the "sqlite_altertab_" prefix on the name 跳过“sqlite_altertab_”前缀的名称*/  pCol = &pNew->aCol[pNew->nCol-1];  pDflt = pCol->pDflt;  pTab = sqlite3FindTable(db, zTab, zDb);  assert( pTab );#ifndef SQLITE_OMIT_AUTHORIZATION  /* Invoke the authorization callback. 调用授权回调*/  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){    return;  }#endif  /* If the default value for the new column was specified with a   ** literal NULL, then set pDflt to 0. This simplifies checking  ** for an SQL NULL default below.  如果新列的默认值是用文字指定NULL,那么pDflt设置为0。  这简化了检查SQL空下面的默认。  */  if( pDflt && pDflt->op==TK_NULL ){    pDflt = 0;  }  /* Check that the new column is not specified as PRIMARY KEY or UNIQUE.  ** If there is a NOT NULL constraint, then the default value for the  ** column must not be NULL. 检查新列没有指定主键或唯一的。如果有一个非空约束,然后列的默认值不能为空。  */  if( pCol->isPrimKey ){    sqlite3ErrorMsg(pParse, "Cannot add a PRIMARY KEY column");    return;  }  if( pNew->pIndex ){    sqlite3ErrorMsg(pParse, "Cannot add a UNIQUE column");    return;  }  if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){    sqlite3ErrorMsg(pParse,         "Cannot add a REFERENCES column with non-NULL default value");    return;  }  if( pCol->notNull && !pDflt ){    sqlite3ErrorMsg(pParse,         "Cannot add a NOT NULL column with default value NULL");    return;  }  /* Ensure the default expression is something that sqlite3ValueFromExpr()  ** can handle (i.e. not CURRENT_TIME etc.)  确保默认表达式是sqlite3ValueFromExpr()可以处理的事(即不是当前时间等。)  */  if( pDflt ){    sqlite3_value *pVal;    if( sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, &pVal) ){      db->mallocFailed = 1;      return;    }    if( !pVal ){      sqlite3ErrorMsg(pParse, "Cannot add a column with non-constant default");      return;    }    sqlite3ValueFree(pVal);  }  /* Modify the CREATE TABLE statement. 修改CREATE TABLE语句。*/  zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n);  if( zCol ){    char *zEnd = &zCol[pColDef->n-1];    int savedDbFlags = db->flags;//.........这里部分代码省略.........
开发者ID:Guidachengong,项目名称:Sqlite3.07.14,代码行数:101,


示例15: sqlite3InitOne

/*** Attempt to read the database schema and initialize internal** data structures for a single database file.  The index of the** database file is given by iDb.  iDb==0 is used for the main** database.  iDb==1 should never be used.  iDb>=2 is used for** auxiliary databases.  Return one of the SQLITE_ error codes to** indicate success or failure.*/static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){  int rc;  BtCursor *curMain;  int size;  Table *pTab;  Db *pDb;  char const *azArg[4];  int meta[10];  InitData initData;  char const *zMasterSchema;  char const *zMasterName = SCHEMA_TABLE(iDb);  /*  ** The master database table has a structure like this  */  static const char master_schema[] =      "CREATE TABLE sqlite_master(/n"     "  type text,/n"     "  name text,/n"     "  tbl_name text,/n"     "  rootpage integer,/n"     "  sql text/n"     ")"  ;#ifndef SQLITE_OMIT_TEMPDB  static const char temp_master_schema[] =      "CREATE TEMP TABLE sqlite_temp_master(/n"     "  type text,/n"     "  name text,/n"     "  tbl_name text,/n"     "  rootpage integer,/n"     "  sql text/n"     ")"  ;#else  #define temp_master_schema 0#endif  assert( iDb>=0 && iDb<db->nDb );  assert( db->aDb[iDb].pSchema );  /* zMasterSchema and zInitScript are set to point at the master schema  ** and initialisation script appropriate for the database being  ** initialised. zMasterName is the name of the master table.  */  if( !OMIT_TEMPDB && iDb==1 ){    zMasterSchema = temp_master_schema;  }else{    zMasterSchema = master_schema;  }  zMasterName = SCHEMA_TABLE(iDb);  /* Construct the schema tables.  */  sqlite3SafetyOff(db);  azArg[0] = zMasterName;  azArg[1] = "1";  azArg[2] = zMasterSchema;  azArg[3] = 0;  initData.db = db;  initData.iDb = iDb;  initData.pzErrMsg = pzErrMsg;  rc = sqlite3InitCallback(&initData, 3, (char **)azArg, 0);  if( rc ){    sqlite3SafetyOn(db);    return initData.rc;  }  pTab = sqlite3FindTable(db, zMasterName, db->aDb[iDb].zName);  if( pTab ){    pTab->readOnly = 1;  }  sqlite3SafetyOn(db);  /* Create a cursor to hold the database open  */  pDb = &db->aDb[iDb];  if( pDb->pBt==0 ){    if( !OMIT_TEMPDB && iDb==1 ){      DbSetProperty(db, 1, DB_SchemaLoaded);    }    return SQLITE_OK;  }  rc = sqlite3BtreeCursor(pDb->pBt, MASTER_ROOT, 0, 0, 0, &curMain);  if( rc!=SQLITE_OK && rc!=SQLITE_EMPTY ){    sqlite3SetString(pzErrMsg, sqlite3ErrStr(rc), (char*)0);    return rc;  }  /* Get the database meta information.  **  ** Meta values are as follows:  **    meta[0]   Schema cookie.  Changes with each schema change.  **    meta[1]   File format of schema layer.//.........这里部分代码省略.........
开发者ID:9iky6,项目名称:amxmodx,代码行数:101,


示例16: sqlite3AlterRenameTable

/*** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy"** command.*/void sqlite3AlterRenameTable(  Parse *pParse,            /* Parser context. */  SrcList *pSrc,            /* The table to rename. */  Token *pName              /* The new table name. */){  int iDb;                  /* Database that contains the table */  char *zDb;                /* Name of database iDb */  Table *pTab;              /* Table being renamed */  char *zName = 0;          /* NULL-terminated version of pName */  sqlite3 *db = pParse->db; /* Database connection */  int nTabName;             /* Number of UTF-8 characters in zTabName */  const char *zTabName;     /* Original name of the table */  Vdbe *v;#ifndef SQLITE_OMIT_TRIGGER  char *zWhere = 0;         /* Where clause to locate temp triggers */#endif  VTable *pVTab = 0;        /* Non-zero if this is a v-tab with an xRename() */  int savedDbFlags;         /* Saved value of db->flags */  savedDbFlags = db->flags;  if( NEVER(db->mallocFailed) ) goto exit_rename_table;  assert( pSrc->nSrc==1 );  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );  pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);  if( !pTab ) goto exit_rename_table;  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);  zDb = db->aDb[iDb].zName;  db->flags |= SQLITE_PreferBuiltin;  /* Get a NULL terminated version of the new table name. */  zName = sqlite3NameFromToken(db, pName);  if( !zName ) goto exit_rename_table;  /* Check that a table or index named 'zName' does not already exist  ** in database iDb. If so, this is an error.  */  if( sqlite3FindTable(db, zName, zDb) || sqlite3FindIndex(db, zName, zDb) ){    sqlite3ErrorMsg(pParse,        "there is already another table or index with this name: %s", zName);    goto exit_rename_table;  }  /* Make sure it is not a system table being altered, or a reserved name  ** that the table is being renamed to.  */  if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ){    goto exit_rename_table;  }  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto    exit_rename_table;  }#ifndef SQLITE_OMIT_VIEW  if( pTab->pSelect ){    sqlite3ErrorMsg(pParse, "view %s may not be altered", pTab->zName);    goto exit_rename_table;  }#endif#ifndef SQLITE_OMIT_AUTHORIZATION  /* Invoke the authorization callback. */  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){    goto exit_rename_table;  }#endif#ifndef SQLITE_OMIT_VIRTUALTABLE  if( sqlite3ViewGetColumnNames(pParse, pTab) ){    goto exit_rename_table;  }  if( IsVirtual(pTab) ){    pVTab = sqlite3GetVTable(db, pTab);    if( pVTab->pVtab->pModule->xRename==0 ){      pVTab = 0;    }  }#endif  /* Begin a transaction for database iDb.  ** Then modify the schema cookie (since the ALTER TABLE modifies the  ** schema). Open a statement transaction if the table is a virtual  ** table.  */  v = sqlite3GetVdbe(pParse);  if( v==0 ){    goto exit_rename_table;  }  sqlite3BeginWriteOperation(pParse, pVTab!=0, iDb);  sqlite3ChangeCookie(pParse, iDb);  /* If this is a virtual table, invoke the xRename() function if  ** one is defined. The xRename() callback will modify the names  ** of any resources used by the v-table implementation (including other  ** SQLite tables) that are identified by the name of the virtual table.  *///.........这里部分代码省略.........
开发者ID:arizwanp,项目名称:intel_sgx,代码行数:101,


示例17: sqlite3AnalysisLoad

/*** Load the content of the sqlite_stat1 and sqlite_stat2 tables. The** contents of sqlite_stat1 are used to populate the Index.aiRowEst[]** arrays. The contents of sqlite_stat2 are used to populate the** Index.aSample[] arrays.**** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR** is returned. In this case, even if SQLITE_ENABLE_STAT2 was defined ** during compilation and the sqlite_stat2 table is present, no data is ** read from it.**** If SQLITE_ENABLE_STAT2 was defined during compilation and the ** sqlite_stat2 table is not present in the database, SQLITE_ERROR is** returned. However, in this case, data is read from the sqlite_stat1** table (if it is present) before returning.**** If an OOM error occurs, this function always sets db->mallocFailed.** This means if the caller does not care about other errors, the return** code may be ignored.*/int sqlite3AnalysisLoad(sqlite3 *db, int iDb){  analysisInfo sInfo;  HashElem *i;  char *zSql;  int rc;  assert( iDb>=0 && iDb<db->nDb );  assert( db->aDb[iDb].pBt!=0 );  /* Clear any prior statistics */  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );  for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){    Index *pIdx = (Index *) sqliteHashData(i);    sqlite3DefaultRowEst(pIdx);    sqlite3DeleteIndexSamples(db, pIdx);    pIdx->aSample = 0;  }  /* Check to make sure the sqlite_stat1 table exists */  sInfo.db = db;  sInfo.zDatabase = db->aDb[iDb].zName;  if( sqlite3FindTable(db, "sqlite_stat1", sInfo.zDatabase)==0 ){    return SQLITE_ERROR;  }  /* Load new statistics out of the sqlite_stat1 table */  zSql = sqlite3MPrintf(db,       "SELECT tbl, idx, stat FROM %Q.sqlite_stat1", sInfo.zDatabase);  if( zSql==0 ){    rc = SQLITE_NOMEM;  }else{    rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);    sqlite3DbFree(db, zSql);  }  /* Load the statistics from the sqlite_stat2 table. */#ifdef SQLITE_ENABLE_STAT2  if( rc==SQLITE_OK && !sqlite3FindTable(db, "sqlite_stat2", sInfo.zDatabase) ){    rc = SQLITE_ERROR;  }  if( rc==SQLITE_OK ){    sqlite3_stmt *pStmt = 0;    zSql = sqlite3MPrintf(db,         "SELECT idx,sampleno,sample FROM %Q.sqlite_stat2", sInfo.zDatabase);    if( !zSql ){      rc = SQLITE_NOMEM;    }else{      rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);      sqlite3DbFree(db, zSql);    }    if( rc==SQLITE_OK ){      while( sqlite3_step(pStmt)==SQLITE_ROW ){        char *zIndex;   /* Index name */        Index *pIdx;    /* Pointer to the index object */        zIndex = (char *)sqlite3_column_text(pStmt, 0);        pIdx = zIndex ? sqlite3FindIndex(db, zIndex, sInfo.zDatabase) : 0;        if( pIdx ){          int iSample = sqlite3_column_int(pStmt, 1);          if( iSample<SQLITE_INDEX_SAMPLES && iSample>=0 ){            int eType = sqlite3_column_type(pStmt, 2);            if( pIdx->aSample==0 ){              static const int sz = sizeof(IndexSample)*SQLITE_INDEX_SAMPLES;              pIdx->aSample = (IndexSample *)sqlite3DbMallocRaw(0, sz);              if( pIdx->aSample==0 ){                db->mallocFailed = 1;                break;              }	      memset(pIdx->aSample, 0, sz);            }            assert( pIdx->aSample );            {              IndexSample *pSample = &pIdx->aSample[iSample];              pSample->eType = (u8)eType;              if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){//.........这里部分代码省略.........
开发者ID:sunyangkobe,项目名称:db_research,代码行数:101,


示例18: sqlite3AlterFinishAddColumn

/*** This function is called after an "ALTER TABLE ... ADD" statement** has been parsed. Argument pColDef contains the text of the new** column definition.**** The Table structure pParse->pNewTable was extended to include** the new column during parsing.*/void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){  Table *pNew;              /* Copy of pParse->pNewTable */  Table *pTab;              /* Table being altered */  int iDb;                  /* Database number */  const char *zDb;          /* Database name */  const char *zTab;         /* Table name */  char *zCol;               /* Null-terminated column definition */  Column *pCol;             /* The new column */  Expr *pDflt;              /* Default value for the new column */  sqlite3 *db;              /* The database connection; */  Vdbe *v = pParse->pVdbe;  /* The prepared statement under construction */  db = pParse->db;  if( pParse->nErr || db->mallocFailed ) return;  assert( v!=0 );  pNew = pParse->pNewTable;  assert( pNew );  assert( sqlite3BtreeHoldsAllMutexes(db) );  iDb = sqlite3SchemaToIndex(db, pNew->pSchema);  zDb = db->aDb[iDb].zName;  zTab = &pNew->zName[16];  /* Skip the "sqlite_altertab_" prefix on the name */  pCol = &pNew->aCol[pNew->nCol-1];  pDflt = pCol->pDflt;  pTab = sqlite3FindTable(db, zTab, zDb);  assert( pTab );#ifndef SQLITE_OMIT_AUTHORIZATION  /* Invoke the authorization callback. */  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){    return;  }#endif  /* If the default value for the new column was specified with a  ** literal NULL, then set pDflt to 0. This simplifies checking  ** for an SQL NULL default below.  */  if( pDflt && pDflt->op==TK_NULL ){    pDflt = 0;  }  /* Check that the new column is not specified as PRIMARY KEY or UNIQUE.  ** If there is a NOT NULL constraint, then the default value for the  ** column must not be NULL.  */  if( pCol->colFlags & COLFLAG_PRIMKEY ){    sqlite3ErrorMsg(pParse, "Cannot add a PRIMARY KEY column");    return;  }  if( pNew->pIndex ){    sqlite3ErrorMsg(pParse, "Cannot add a UNIQUE column");    return;  }  if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){    sqlite3ErrorMsg(pParse,        "Cannot add a REFERENCES column with non-NULL default value");    return;  }  if( pCol->notNull && !pDflt ){    sqlite3ErrorMsg(pParse,        "Cannot add a NOT NULL column with default value NULL");    return;  }  /* Ensure the default expression is something that sqlite3ValueFromExpr()  ** can handle (i.e. not CURRENT_TIME etc.)  */  if( pDflt ){    sqlite3_value *pVal = 0;    int rc;    rc = sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_BLOB, &pVal);    assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );    if( rc!=SQLITE_OK ){      assert( db->mallocFailed == 1 );      return;    }    if( !pVal ){      sqlite3ErrorMsg(pParse, "Cannot add a column with non-constant default");      return;    }    sqlite3ValueFree(pVal);  }  /* Modify the CREATE TABLE statement. */  zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n);  if( zCol ){    char *zEnd = &zCol[pColDef->n-1];    int savedDbFlags = db->flags;    while( zEnd>zCol && (*zEnd==';' || sqlite3Isspace(*zEnd)) ){      *zEnd-- = '/0';    }//.........这里部分代码省略.........
开发者ID:arizwanp,项目名称:intel_sgx,代码行数:101,


示例19: sqlite3Pragma

//.........这里部分代码省略.........      if( !db->autoCommit ){        sqlite3ErrorMsg(pParse,             "Safety level may not be changed inside a transaction");      }else{        pDb->safety_level = getSafetyLevel(zRight)+1;      }    }  }else#endif /* SQLITE_OMIT_PAGER_PRAGMAS */#ifndef SQLITE_OMIT_FLAG_PRAGMAS  if( flagPragma(pParse, zLeft, zRight) ){    /* The flagPragma() subroutine also generates any necessary code    ** there is nothing more to do here */  }else#endif /* SQLITE_OMIT_FLAG_PRAGMAS */#ifndef SQLITE_OMIT_SCHEMA_PRAGMAS  /*  **   PRAGMA table_info(<table>)  **  ** Return a single row for each column of the named table. The columns of  ** the returned data set are:  **  ** cid:        Column id (numbered from left to right, starting at 0)  ** name:       Column name  ** type:       Column declaration type.  ** notnull:    True if 'NOT NULL' is part of column declaration  ** dflt_value: The default value for the column, if any.  */  if( sqlite3StrICmp(zLeft, "table_info")==0 && zRight ){    Table *pTab;    if( sqlite3ReadSchema(pParse) ) goto pragma_out;    pTab = sqlite3FindTable(db, zRight, zDb);    if( pTab ){      int i;      Column *pCol;      sqlite3VdbeSetNumCols(v, 6);      sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cid", P3_STATIC);      sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", P3_STATIC);      sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "type", P3_STATIC);      sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "notnull", P3_STATIC);      sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "dflt_value", P3_STATIC);      sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "pk", P3_STATIC);      sqlite3ViewGetColumnNames(pParse, pTab);      for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){        sqlite3VdbeAddOp(v, OP_Integer, i, 0);        sqlite3VdbeOp3(v, OP_String8, 0, 0, pCol->zName, 0);        sqlite3VdbeOp3(v, OP_String8, 0, 0,           pCol->zType ? pCol->zType : "numeric", 0);        sqlite3VdbeAddOp(v, OP_Integer, pCol->notNull, 0);        sqlite3ExprCode(pParse, pCol->pDflt);        sqlite3VdbeAddOp(v, OP_Integer, pCol->isPrimKey, 0);        sqlite3VdbeAddOp(v, OP_Callback, 6, 0);      }    }  }else  if( sqlite3StrICmp(zLeft, "index_info")==0 && zRight ){    Index *pIdx;    Table *pTab;    if( sqlite3ReadSchema(pParse) ) goto pragma_out;    pIdx = sqlite3FindIndex(db, zRight, zDb);    if( pIdx ){      int i;      pTab = pIdx->pTable;
开发者ID:tmarques,项目名称:waheela,代码行数:67,


示例20: sqlite3AlterFinishAddColumn

/*** This function is called after an "ALTER TABLE ... ADD" statement** has been parsed. Argument pColDef contains the text of the new** column definition.**** The Table structure pParse->pNewTable was extended to include** the new column during parsing.*/void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){  Table *pNew;              /* Copy of pParse->pNewTable */  Table *pTab;              /* Table being altered */  int iDb;                  /* Database number */  const char *zDb;          /* Database name */  const char *zTab;         /* Table name */  char *zCol;               /* Null-terminated column definition */  Column *pCol;             /* The new column */  Expr *pDflt;              /* Default value for the new column */  if( pParse->nErr ) return;  pNew = pParse->pNewTable;  assert( pNew );  iDb = sqlite3SchemaToIndex(pParse->db, pNew->pSchema);  zDb = pParse->db->aDb[iDb].zName;  zTab = pNew->zName;  pCol = &pNew->aCol[pNew->nCol-1];  pDflt = pCol->pDflt;  pTab = sqlite3FindTable(pParse->db, zTab, zDb);  assert( pTab );#ifndef SQLITE_OMIT_AUTHORIZATION  /* Invoke the authorization callback. */  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){    return;  }#endif  /* If the default value for the new column was specified with a   ** literal NULL, then set pDflt to 0. This simplifies checking  ** for an SQL NULL default below.  */  if( pDflt && pDflt->op==TK_NULL ){    pDflt = 0;  }  /* Check that the new column is not specified as PRIMARY KEY or UNIQUE.  ** If there is a NOT NULL constraint, then the default value for the  ** column must not be NULL.  */  if( pCol->isPrimKey ){    sqlite3ErrorMsg(pParse, "Cannot add a PRIMARY KEY column");    return;  }  if( pNew->pIndex ){    sqlite3ErrorMsg(pParse, "Cannot add a UNIQUE column");    return;  }  if( pCol->notNull && !pDflt ){    sqlite3ErrorMsg(pParse,         "Cannot add a NOT NULL column with default value NULL");    return;  }  /* Ensure the default expression is something that sqlite3ValueFromExpr()  ** can handle (i.e. not CURRENT_TIME etc.)  */  if( pDflt ){    sqlite3_value *pVal;    if( sqlite3ValueFromExpr(pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, &pVal) ){      /* malloc() has failed */      return;    }    if( !pVal ){      sqlite3ErrorMsg(pParse, "Cannot add a column with non-constant default");      return;    }    sqlite3ValueFree(pVal);  }  /* Modify the CREATE TABLE statement. */  zCol = sqliteStrNDup((char*)pColDef->z, pColDef->n);  if( zCol ){    char *zEnd = &zCol[pColDef->n-1];    while( (zEnd>zCol && *zEnd==';') || isspace(*(unsigned char *)zEnd) ){      *zEnd-- = '/0';    }    sqlite3NestedParse(pParse,         "UPDATE %Q.%s SET "          "sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d,length(sql)) "        "WHERE type = 'table' AND name = %Q",       zDb, SCHEMA_TABLE(iDb), pNew->addColOffset, zCol, pNew->addColOffset+1,      zTab    );    sqliteFree(zCol);  }  /* If the default value of the new column is NULL, then set the file  ** format to 2. If the default value of the new column is not NULL,  ** the file format becomes 3.  *///.........这里部分代码省略.........
开发者ID:3rdexp,项目名称:jezzitest,代码行数:101,


示例21: sqlite3AlterRenameTable

/*** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy" ** command. 生成代码来实现“ALTER TABLE xxx重命名yyy”命令。*/void sqlite3AlterRenameTable(  Parse *pParse,            /* Parser context. 语法分析器上下文*/  SrcList *pSrc,            /* The table to rename. 重命名的表*/  Token *pName              /* The new table name. 新表名*/){  int iDb;                  /* Database that contains the table 包含表的数据库*/  char *zDb;                /* Name of database iDb 数据库iDb 的名称*/  Table *pTab;              /* Table being renamed 正在重命名的表*/  char *zName = 0;          /* NULL-terminated version of pName  pName的空值终止版本*/   sqlite3 *db = pParse->db; /* Database connection 数据库的连接*/  int nTabName;             /* Number of UTF-8 characters in zTabName 在 zTabName里的UTF-8类型的数目*/  const char *zTabName;     /* Original name of the table 最初的数据库名称*/  Vdbe *v;#ifndef SQLITE_OMIT_TRIGGER  char *zWhere = 0;         /* Where clause to locate temp triggers Where 子句位于temp触发器*/#endif  VTable *pVTab = 0;        /* Non-zero if this is a v-tab with an xRename() 如果是 一个v-tab 和一个xRename() ,则为零*/  int savedDbFlags;         /* Saved value of db->flags db->flags的保留值*/  savedDbFlags = db->flags;    if( NEVER(db->mallocFailed) ) goto exit_rename_table;  assert( pSrc->nSrc==1 );  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );  pTab = sqlite3LocateTable(pParse, 0, pSrc->a[0].zName, pSrc->a[0].zDatabase);  if( !pTab ) goto exit_rename_table;  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);  zDb = db->aDb[iDb].zName;  db->flags |= SQLITE_PreferBuiltin;  /* Get a NULL terminated version of the new table name. 得到一个空终止版本的新表的名称。*/  zName = sqlite3NameFromToken(db, pName);  if( !zName ) goto exit_rename_table;  /* Check that a table or index named 'zName' does not already exist  ** in database iDb. If so, this is an error.检查一个表或索引名叫“zName”不存在数据库iDb。  如果是这样,这是一个错误。  */  if( sqlite3FindTable(db, zName, zDb) || sqlite3FindIndex(db, zName, zDb) ){    sqlite3ErrorMsg(pParse,         "there is already another table or index with this name: %s", zName);    goto exit_rename_table;  }  /* Make sure it is not a system table being altered, or a reserved name  ** that the table is being renamed to.  确保它不是一个正在被修改的系统表或者一个正在被重命名的保留的名称表  */  if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ){    goto exit_rename_table;  }  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto    exit_rename_table;  }#ifndef SQLITE_OMIT_VIEW  if( pTab->pSelect ){    sqlite3ErrorMsg(pParse, "view %s may not be altered", pTab->zName);    goto exit_rename_table;  }#endif#ifndef SQLITE_OMIT_AUTHORIZATION  /* Invoke the authorization callback. 调用授权回调。*/  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){    goto exit_rename_table;  }#endif#ifndef SQLITE_OMIT_VIRTUALTABLE  if( sqlite3ViewGetColumnNames(pParse, pTab) ){    goto exit_rename_table;  }  if( IsVirtual(pTab) ){    pVTab = sqlite3GetVTable(db, pTab);    if( pVTab->pVtab->pModule->xRename==0 ){      pVTab = 0;    }  }#endif  /* Begin a transaction and code the VerifyCookie for database iDb.   ** Then modify the schema cookie (since the ALTER TABLE modifies the  ** schema). Open a statement transaction if the table is a virtual  ** table.  对于iDb数据库开始一个事务和代码的VerifyCookie。然后修改模式cookie(因为ALTER TABLE修改模式)。如果表是一个虚拟表打开一个声明事务。  */  v = sqlite3GetVdbe(pParse);  if( v==0 ){    goto exit_rename_table;  }  sqlite3BeginWriteOperation(pParse, pVTab!=0, iDb);  sqlite3ChangeCookie(pParse, iDb);//.........这里部分代码省略.........
开发者ID:Guidachengong,项目名称:Sqlite3.07.14,代码行数:101,


示例22: sqlite3AlterRenameTable

/*** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy" ** command. */void sqlite3AlterRenameTable(  Parse *pParse,            /* Parser context. */  SrcList *pSrc,            /* The table to rename. */  Token *pName              /* The new table name. */){  int iDb;                  /* Database that contains the table */  char *zDb;                /* Name of database iDb */  Table *pTab;              /* Table being renamed */  char *zName = 0;          /* NULL-terminated version of pName */   sqlite3 *db = pParse->db; /* Database connection */  int nTabName;             /* Number of UTF-8 characters in zTabName */  const char *zTabName;     /* Original name of the table */  Vdbe *v;#ifndef SQLITE_OMIT_TRIGGER  char *zWhere = 0;         /* Where clause to locate temp triggers */#endif  int isVirtualRename = 0;  /* True if this is a v-table with an xRename() */    if( sqlite3MallocFailed() ) goto exit_rename_table;  assert( pSrc->nSrc==1 );  pTab = sqlite3LocateTable(pParse, pSrc->a[0].zName, pSrc->a[0].zDatabase);  if( !pTab ) goto exit_rename_table;  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);  zDb = db->aDb[iDb].zName;  /* Get a NULL terminated version of the new table name. */  zName = sqlite3NameFromToken(pName);  if( !zName ) goto exit_rename_table;  /* Check that a table or index named 'zName' does not already exist  ** in database iDb. If so, this is an error.  */  if( sqlite3FindTable(db, zName, zDb) || sqlite3FindIndex(db, zName, zDb) ){    sqlite3ErrorMsg(pParse,         "there is already another table or index with this name: %s", zName);    goto exit_rename_table;  }  /* Make sure it is not a system table being altered, or a reserved name  ** that the table is being renamed to.  */  if( strlen(pTab->zName)>6 && 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ){    sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName);    goto exit_rename_table;  }  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){    goto exit_rename_table;  }#ifndef SQLITE_OMIT_AUTHORIZATION  /* Invoke the authorization callback. */  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){    goto exit_rename_table;  }#endif#ifndef SQLITE_OMIT_VIRTUALTABLE  if( sqlite3ViewGetColumnNames(pParse, pTab) ){    goto exit_rename_table;  }  if( IsVirtual(pTab) && pTab->pMod->pModule->xRename ){    isVirtualRename = 1;  }#endif  /* Begin a transaction and code the VerifyCookie for database iDb.   ** Then modify the schema cookie (since the ALTER TABLE modifies the  ** schema). Open a statement transaction if the table is a virtual  ** table.  */  v = sqlite3GetVdbe(pParse);  if( v==0 ){    goto exit_rename_table;  }  sqlite3BeginWriteOperation(pParse, isVirtualRename, iDb);  sqlite3ChangeCookie(db, v, iDb);  /* If this is a virtual table, invoke the xRename() function if  ** one is defined. The xRename() callback will modify the names  ** of any resources used by the v-table implementation (including other  ** SQLite tables) that are identified by the name of the virtual table.  */#ifndef SQLITE_OMIT_VIRTUALTABLE  if( isVirtualRename ){    sqlite3VdbeOp3(v, OP_String8, 0, 0, zName, 0);    sqlite3VdbeOp3(v, OP_VRename, 0, 0, (const char*)pTab->pVtab, P3_VTAB);  }#endif  /* figure out how many UTF-8 characters are in zName */  zTabName = pTab->zName;  nTabName = sqlite3Utf8CharLen(zTabName, -1);  /* Modify the sqlite_master table to use the new table name. */  sqlite3NestedParse(pParse,//.........这里部分代码省略.........
开发者ID:3rdexp,项目名称:jezzitest,代码行数:101,


示例23: sqlite3FkCheck

/*** This function is called when inserting, deleting or updating a row of** table pTab to generate VDBE code to perform foreign key constraint ** processing for the operation.**** For a DELETE operation, parameter regOld is passed the index of the** first register in an array of (pTab->nCol+1) registers containing the** rowid of the row being deleted, followed by each of the column values** of the row being deleted, from left to right. Parameter regNew is passed** zero in this case.**** For an INSERT operation, regOld is passed zero and regNew is passed the** first register of an array of (pTab->nCol+1) registers containing the new** row data.**** For an UPDATE operation, this function is called twice. Once before** the original record is deleted from the table using the calling convention** described for DELETE. Then again after the original record is deleted** but before the new record is inserted using the INSERT convention. */void sqlite3FkCheck(  Parse *pParse,                  /* Parse context */  Table *pTab,                    /* Row is being deleted from this table */   int regOld,                     /* Previous row data is stored here */  int regNew                      /* New row data is stored here */){  sqlite3 *db = pParse->db;       /* Database handle */  FKey *pFKey;                    /* Used to iterate through FKs */  int iDb;                        /* Index of database containing pTab */  const char *zDb;                /* Name of database containing pTab */  int isIgnoreErrors = pParse->disableTriggers;  /* Exactly one of regOld and regNew should be non-zero. */  assert( (regOld==0)!=(regNew==0) );  /* If foreign-keys are disabled, this function is a no-op. */  if( (db->flags&SQLITE_ForeignKeys)==0 ) return;  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);  zDb = db->aDb[iDb].zName;  /* Loop through all the foreign key constraints for which pTab is the  ** child table (the table that the foreign key definition is part of).  */  for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){    Table *pTo;                   /* Parent table of foreign key pFKey */    Index *pIdx = 0;              /* Index on key columns in pTo */    int *aiFree = 0;    int *aiCol;    int iCol;    int i;    int isIgnore = 0;    /* Find the parent table of this foreign key. Also find a unique index     ** on the parent key columns in the parent table. If either of these     ** schema items cannot be located, set an error in pParse and return     ** early.  */    if( pParse->disableTriggers ){      pTo = sqlite3FindTable(db, pFKey->zTo, zDb);    }else{      pTo = sqlite3LocateTable(pParse, 0, pFKey->zTo, zDb);    }    if( !pTo || locateFkeyIndex(pParse, pTo, pFKey, &pIdx, &aiFree) ){      assert( isIgnoreErrors==0 || (regOld!=0 && regNew==0) );      if( !isIgnoreErrors || db->mallocFailed ) return;      if( pTo==0 ){        /* If isIgnoreErrors is true, then a table is being dropped. In this        ** case SQLite runs a "DELETE FROM xxx" on the table being dropped        ** before actually dropping it in order to check FK constraints.        ** If the parent table of an FK constraint on the current table is        ** missing, behave as if it is empty. i.e. decrement the relevant        ** FK counter for each row of the current table with non-NULL keys.        */        Vdbe *v = sqlite3GetVdbe(pParse);        int iJump = sqlite3VdbeCurrentAddr(v) + pFKey->nCol + 1;        for(i=0; i<pFKey->nCol; i++){          int iReg = pFKey->aCol[i].iFrom + regOld + 1;          sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iJump);        }        sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, -1);      }      continue;    }    assert( pFKey->nCol==1 || (aiFree && pIdx) );    if( aiFree ){      aiCol = aiFree;    }else{      iCol = pFKey->aCol[0].iFrom;      aiCol = &iCol;    }    for(i=0; i<pFKey->nCol; i++){      if( aiCol[i]==pTab->iPKey ){        aiCol[i] = -1;      }#ifndef SQLITE_OMIT_AUTHORIZATION      /* Request permission to read the parent key columns. If the       ** authorization callback returns SQLITE_IGNORE, behave as if any      ** values read from the parent table are NULL. */      if( db->xAuth ){        int rcauth;//.........这里部分代码省略.........
开发者ID:77songsong,项目名称:sqlite3,代码行数:101,


示例24: sqlite3_table_column_metadata

int sqlite3_table_column_metadata(  sqlite3 *db,                /* Connection handle */  const char *zDbName,        /* Database name or NULL */  const char *zTableName,     /* Table name */  const char *zColumnName,    /* Column name */  char const **pzDataType,    /* OUTPUT: Declared data type */  char const **pzCollSeq,     /* OUTPUT: Collation sequence name */  int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */  int *pPrimaryKey,           /* OUTPUT: True if column part of PK */  int *pAutoinc               /* OUTPUT: True if colums is auto-increment */){  int rc;  char *zErrMsg = 0;  Table *pTab = 0;  Column *pCol = 0;  int iCol;  char const *zDataType = 0;  char const *zCollSeq = 0;  int notnull = 0;  int primarykey = 0;  int autoinc = 0;  /* Ensure the database schema has been loaded */  if( sqlite3SafetyOn(db) ){    return SQLITE_MISUSE;  }  rc = sqlite3Init(db, &zErrMsg);  if( SQLITE_OK!=rc ){    goto error_out;  }  /* Locate the table in question */  pTab = sqlite3FindTable(db, zTableName, zDbName);  if( !pTab || pTab->pSelect ){    pTab = 0;    goto error_out;  }  /* Find the column for which info is requested */  if( sqlite3IsRowid(zColumnName) ){    iCol = pTab->iPKey;    if( iCol>=0 ){      pCol = &pTab->aCol[iCol];    }  }else{    for(iCol=0; iCol<pTab->nCol; iCol++){      pCol = &pTab->aCol[iCol];      if( 0==sqlite3StrICmp(pCol->zName, zColumnName) ){        break;      }    }    if( iCol==pTab->nCol ){      pTab = 0;      goto error_out;    }  }  /* The following block stores the meta information that will be returned  ** to the caller in local variables zDataType, zCollSeq, notnull, primarykey  ** and autoinc. At this point there are two possibilities:  **   **     1. The specified column name was rowid", "oid" or "_rowid_"   **        and there is no explicitly declared IPK column.   **  **     2. The table is not a view and the column name identified an   **        explicitly declared column. Copy meta information from *pCol.  */   if( pCol ){    zDataType = pCol->zType;    zCollSeq = pCol->zColl;    notnull = (pCol->notNull?1:0);    primarykey  = (pCol->isPrimKey?1:0);    autoinc = ((pTab->iPKey==iCol && pTab->autoInc)?1:0);  }else{    zDataType = "INTEGER";    primarykey = 1;  }  if( !zCollSeq ){    zCollSeq = "BINARY";  }error_out:  if( sqlite3SafetyOff(db) ){    rc = SQLITE_MISUSE;  }  /* Whether the function call succeeded or failed, set the output parameters  ** to whatever their local counterparts contain. If an error did occur,  ** this has the effect of zeroing all output parameters.  */  if( pzDataType ) *pzDataType = zDataType;  if( pzCollSeq ) *pzCollSeq = zCollSeq;  if( pNotNull ) *pNotNull = notnull;  if( pPrimaryKey ) *pPrimaryKey = primarykey;  if( pAutoinc ) *pAutoinc = autoinc;  if( SQLITE_OK==rc && !pTab ){    sqlite3SetString(&zErrMsg, "no such table column: ", zTableName, ".",         zColumnName, 0);//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:sqlitepp-svn,代码行数:101,


示例25: sqlite3AlterRenameTable

/*** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy" ** command. */void sqlite3AlterRenameTable(  Parse *pParse,            /* Parser context. */  SrcList *pSrc,            /* The table to rename. */  Token *pName              /* The new table name. */){  int iDb;                  /* Database that contains the table */  char *zDb;                /* Name of database iDb */  Table *pTab;              /* Table being renamed */  char *zName = 0;          /* NULL-terminated version of pName */   sqlite3 *db = pParse->db; /* Database connection */  Vdbe *v;#ifndef SQLITE_OMIT_TRIGGER  char *zWhere = 0;         /* Where clause to locate temp triggers */#endif    if( sqlite3_malloc_failed ) goto exit_rename_table;  assert( pSrc->nSrc==1 );  pTab = sqlite3LocateTable(pParse, pSrc->a[0].zName, pSrc->a[0].zDatabase);  if( !pTab ) goto exit_rename_table;  iDb = pTab->iDb;  zDb = db->aDb[iDb].zName;  /* Get a NULL terminated version of the new table name. */  zName = sqlite3NameFromToken(pName);  if( !zName ) goto exit_rename_table;  /* Check that a table or index named 'zName' does not already exist  ** in database iDb. If so, this is an error.  */  if( sqlite3FindTable(db, zName, zDb) || sqlite3FindIndex(db, zName, zDb) ){    sqlite3ErrorMsg(pParse,         "there is already another table or index with this name: %s", zName);    goto exit_rename_table;  }  /* Make sure it is not a system table being altered, or a reserved name  ** that the table is being renamed to.  */  if( strlen(pTab->zName)>6 && 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ){    sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName);    goto exit_rename_table;  }  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){    goto exit_rename_table;  }#ifndef SQLITE_OMIT_AUTHORIZATION  /* Invoke the authorization callback. */  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){    goto exit_rename_table;  }#endif  /* Begin a transaction and code the VerifyCookie for database iDb.   ** Then modify the schema cookie (since the ALTER TABLE modifies the  ** schema).  */  v = sqlite3GetVdbe(pParse);  if( v==0 ){    goto exit_rename_table;  }  sqlite3BeginWriteOperation(pParse, 0, iDb);  sqlite3ChangeCookie(db, v, iDb);  /* Modify the sqlite_master table to use the new table name. */  sqlite3NestedParse(pParse,      "UPDATE %Q.%s SET "#ifdef SQLITE_OMIT_TRIGGER          "sql = sqlite_rename_table(sql, %Q), "#else          "sql = CASE "            "WHEN type = 'trigger' THEN sqlite_rename_trigger(sql, %Q)"            "ELSE sqlite_rename_table(sql, %Q) END, "#endif          "tbl_name = %Q, "          "name = CASE "            "WHEN type='table' THEN %Q "            "WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN "              "'sqlite_autoindex_' || %Q || substr(name, %d+18,10) "            "ELSE name END "      "WHERE tbl_name=%Q AND "          "(type='table' OR type='index' OR type='trigger');",       zDb, SCHEMA_TABLE(iDb), zName, zName, zName, #ifndef SQLITE_OMIT_TRIGGER      zName,#endif      zName, strlen(pTab->zName), pTab->zName  );#ifndef SQLITE_OMIT_AUTOINCREMENT  /* If the sqlite_sequence table exists in this database, then update   ** it with the new table name.  */  if( sqlite3FindTable(db, "sqlite_sequence", zDb) ){    sqlite3NestedParse(pParse,//.........这里部分代码省略.........
开发者ID:stephen-hill,项目名称:musicCube,代码行数:101,


示例26: sqlite3DropTriggerPtr

/*** Drop a trigger given a pointer to that trigger.  If nested is false,** then also generate code to remove the trigger from the SQLITE_MASTER** table.*/void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger, int nested){  Table   *pTable;  Vdbe *v;  sqlite *db = pParse->db;  assert( pTrigger->iDb<db->nDb );  pTable = sqlite3FindTable(db,pTrigger->table,db->aDb[pTrigger->iTabDb].zName);  assert(pTable);  assert( pTable->iDb==pTrigger->iDb || pTrigger->iDb==1 );#ifndef SQLITE_OMIT_AUTHORIZATION  {    int code = SQLITE_DROP_TRIGGER;    const char *zDb = db->aDb[pTrigger->iDb].zName;    const char *zTab = SCHEMA_TABLE(pTrigger->iDb);    if( pTrigger->iDb==1 ) code = SQLITE_DROP_TEMP_TRIGGER;    if( sqlite3AuthCheck(pParse, code, pTrigger->name, pTable->zName, zDb) ||      sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){      return;    }  }#endif  /* Generate code to destroy the database record of the trigger.  */  if( pTable!=0 && (v = sqlite3GetVdbe(pParse))!=0 ){    int base;    static VdbeOpList dropTrigger[] = {      { OP_Rewind,     0, ADDR(9),  0},      { OP_String8,     0, 0,        0}, /* 1 */      { OP_Column,     0, 1,        0},      { OP_Ne,         0, ADDR(8),  0},      { OP_String8,     0, 0,        "trigger"},      { OP_Column,     0, 0,        0},      { OP_Ne,         0, ADDR(8),  0},      { OP_Delete,     0, 0,        0},      { OP_Next,       0, ADDR(1),  0}, /* 8 */    };    sqlite3BeginWriteOperation(pParse, 0, pTrigger->iDb);    sqlite3OpenMasterTable(v, pTrigger->iDb);    base = sqlite3VdbeAddOpList(v,  ArraySize(dropTrigger), dropTrigger);    sqlite3VdbeChangeP3(v, base+1, pTrigger->name, 0);    sqlite3ChangeCookie(db, v, pTrigger->iDb);    sqlite3VdbeAddOp(v, OP_Close, 0, 0);  }  /*  ** If this is not an "explain", then delete the trigger structure.  */  if( !pParse->explain ){    const char *zName = pTrigger->name;    int nName = strlen(zName);    if( pTable->pTrigger == pTrigger ){      pTable->pTrigger = pTrigger->pNext;    }else{      Trigger *cc = pTable->pTrigger;      while( cc ){         if( cc->pNext == pTrigger ){          cc->pNext = cc->pNext->pNext;          break;        }        cc = cc->pNext;      }      assert(cc);    }    sqlite3HashInsert(&(db->aDb[pTrigger->iDb].trigHash), zName, nName+1, 0);    sqlite3DeleteTrigger(pTrigger);  }}
开发者ID:open2cerp,项目名称:Open2C-ERP,代码行数:74,


示例27: sqlite3FindTable

/*** Return a pointer to the Table structure for the table that a trigger** is set on.*/static Table *tableOfTrigger(sqlite3 *db, Trigger *pTrigger){  return sqlite3FindTable(db,pTrigger->table,db->aDb[pTrigger->iTabDb].zName);}
开发者ID:huangyt,项目名称:foundations.github.com,代码行数:7,



注:本文中的sqlite3FindTable函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ sqlite3FixExpr函数代码示例
C++ sqlite3ExprDup函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。