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

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

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

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

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

示例1: sqlite3Vacuum

/*** 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 ) {        sqlite3VdbeAddOp2(v, OP_Vacuum, 0, 0);    }    return;}
开发者ID:pyq881120,项目名称:urltraveler,代码行数:17,


示例2: sqlite3Vacuum

/*** 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, Token *pTableName){  Vdbe *v = sqlite3GetVdbe(pParse);  if( v ){    sqlite3VdbeAddOp(v, OP_Vacuum, 0, 0);  }  return;}
开发者ID:open2cerp,项目名称:Open2C-ERP,代码行数:17,


示例3: sqlite3CodeRowTriggerDirect

/*** Generate code for the trigger program associated with trigger p on ** table pTab. The reg, orconf and ignoreJump parameters passed to this** function are the same as those described in the header function for** sqlite3CodeRowTrigger()*/void sqlite3CodeRowTriggerDirect(  Parse *pParse,       /* Parse context */  Trigger *p,          /* Trigger to code */  Table *pTab,         /* The table to code triggers from */  int reg,             /* Reg array containing OLD.* and NEW.* values */  int orconf,          /* ON CONFLICT policy */  int ignoreJump       /* Instruction to jump to for RAISE(IGNORE) */){  Vdbe *v = sqlite3GetVdbe(pParse); /* Main VM */  TriggerPrg *pPrg;  pPrg = getRowTrigger(pParse, p, pTab, orconf);  assert( pPrg || pParse->nErr || pParse->db->mallocFailed );  /* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program   ** is a pointer to the sub-vdbe containing the trigger program.  */  if( pPrg ){    int bRecursive = (p->zName && 0==(pParse->db->flags&SQLITE_RecTriggers));    sqlite3VdbeAddOp3(v, OP_Program, reg, ignoreJump, ++pParse->nMem);    sqlite3VdbeChangeP4(v, -1, (const char *)pPrg->pProgram, P4_SUBPROGRAM);    VdbeComment(        (v, "Call: %s.%s", (p->zName?p->zName:"fkey"), onErrorText(orconf)));    /* Set the P5 operand of the OP_Program instruction to non-zero if    ** recursive invocation of this trigger program is disallowed. Recursive    ** invocation is disallowed if (a) the sub-program is really a trigger,    ** not a foreign key action, and (b) the flag to enable recursive triggers    ** is clear.  */    sqlite3VdbeChangeP5(v, (u8)bRecursive);  }}
开发者ID:doushinide,项目名称:uffs,代码行数:37,


示例4: codec_vdbe_return_static_string

/* Generate code to return a string value */static void codec_vdbe_return_static_string(Parse *pParse, const char *zLabel, const char *value){  Vdbe *v = sqlite3GetVdbe(pParse);  sqlite3VdbeSetNumCols(v, 1);  sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC);  sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, value, 0);  sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);}
开发者ID:0xr0ot,项目名称:sqlcipher,代码行数:8,


示例5: sqlite3Vacuum

/*** The VACUUM command is used to clean up the database,** collapse free space, etc.  It is modelled after the VACUUM command** in PostgreSQL.  The VACUUM command works as follows:****   (1)  Create a new transient database file**   (2)  Copy all content from the database being vacuumed into**        the new transient database file**   (3)  Copy content from the transient database back into the**        original database.**** The transient database requires temporary disk space approximately** equal to the size of the original database.  The copy operation of** step (3) requires additional temporary disk space approximately equal** to the size of the original database for the rollback journal.** Hence, temporary disk space that is approximately 2x the size of the** original database is required.  Every page of the database is written** approximately 3 times:  Once for step (2) and twice for step (3).** Two writes per page are required in step (3) because the original** database content must be written into the rollback journal prior to** overwriting the database with the vacuumed content.**** Only 1x temporary space and only 1x writes would be required if** the copy of step (3) were replaced by deleting the original database** and renaming the transient database as the original.  But that will** not work if other processes are attached to the original database.** And a power loss in between deleting the original and renaming the** transient would cause the database file to appear to be deleted** following reboot.*/void sqlite3Vacuum(Parse *pParse, Token *pNm, Expr *pInto){  Vdbe *v = sqlite3GetVdbe(pParse);  int iDb = 0;  if( v==0 ) goto build_vacuum_end;  if( pNm ){#ifndef SQLITE_BUG_COMPATIBLE_20160819    /* Default behavior:  Report an error if the argument to VACUUM is    ** not recognized */    iDb = sqlite3TwoPartName(pParse, pNm, pNm, &pNm);    if( iDb<0 ) goto build_vacuum_end;#else    /* When SQLITE_BUG_COMPATIBLE_20160819 is defined, unrecognized arguments    ** to VACUUM are silently ignored.  This is a back-out of a bug fix that    ** occurred on 2016-08-19 (https://www.sqlite.org/src/info/083f9e6270).    ** The buggy behavior is required for binary compatibility with some    ** legacy applications. */    iDb = sqlite3FindDb(pParse->db, pNm);    if( iDb<0 ) iDb = 0;#endif  }  if( iDb!=1 ){    int iIntoReg = 0;    if( pInto && sqlite3ResolveSelfReference(pParse,0,0,pInto,0)==0 ){      iIntoReg = ++pParse->nMem;      sqlite3ExprCode(pParse, pInto, iIntoReg);    }    sqlite3VdbeAddOp2(v, OP_Vacuum, iDb, iIntoReg);    sqlite3VdbeUsesBtree(v, iDb);  }build_vacuum_end:  sqlite3ExprDelete(pParse->db, pInto);  return;}
开发者ID:SCALE-GmbH,项目名称:sqlcipher,代码行数:63,


示例6: flagPragma

/*** Check to see if zRight and zLeft refer to a pragma that queries** or changes one of the flags in db->flags.  Return 1 if so and 0 if not.** Also, implement the pragma.*/static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){  static const struct sPragmaType {    const char *zName;  /* Name of the pragma */    int mask;           /* Mask for the db->flags value */  } aPragma[] = {    { "full_column_names",        SQLITE_FullColNames  },    { "short_column_names",       SQLITE_ShortColNames },    { "count_changes",            SQLITE_CountRows     },    { "empty_result_callbacks",   SQLITE_NullCallback  },    { "legacy_file_format",       SQLITE_LegacyFileFmt },    { "fullfsync",                SQLITE_FullFSync     },#ifdef SQLITE_DEBUG    { "sql_trace",                SQLITE_SqlTrace      },    { "vdbe_listing",             SQLITE_VdbeListing   },    { "vdbe_trace",               SQLITE_VdbeTrace     },#endif#ifndef SQLITE_OMIT_CHECK    { "ignore_check_constraints", SQLITE_IgnoreChecks  },#endif    /* The following is VERY experimental */    { "writable_schema",          SQLITE_WriteSchema|SQLITE_RecoveryMode },    { "omit_readlock",            SQLITE_NoReadlock    },    /* TODO: Maybe it shouldn't be possible to change the ReadUncommitted    ** flag if there are any active statements. */    { "read_uncommitted",         SQLITE_ReadUncommitted },  };  int i;  const struct sPragmaType *p;  for(i=0, p=aPragma; i<sizeof(aPragma)/sizeof(aPragma[0]); i++, p++){    if( sqlite3StrICmp(zLeft, p->zName)==0 ){      sqlite3 *db = pParse->db;      Vdbe *v;      v = sqlite3GetVdbe(pParse);      if( v ){        if( zRight==0 ){          returnSingleInt(pParse, p->zName, (db->flags & p->mask)!=0 );        }else{          if( getBoolean(zRight) ){            db->flags |= p->mask;          }else{            db->flags &= ~p->mask;          }          /* Many of the flag-pragmas modify the code generated by the SQL           ** compiler (eg. count_changes). So add an opcode to expire all          ** compiled SQL statements after modifying a pragma value.          */          sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);        }      }      return 1;    }  }  return 0;}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:62,


示例7: returnSingleInt

/*** Generate code to return a single integer value.*/static void returnSingleInt(Parse *pParse, const char *zLabel, int value){  Vdbe *v = sqlite3GetVdbe(pParse);  sqlite3VdbeAddOp(v, OP_Integer, value, 0);  if( pParse->explain==0 ){    sqlite3VdbeSetNumCols(v, 1);    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, P3_STATIC);  }  sqlite3VdbeAddOp(v, OP_Callback, 1, 0);}
开发者ID:tmarques,项目名称:waheela,代码行数:12,


示例8: returnSingleInt

/*** Generate code to return a single integer value.*/static void returnSingleInt(Parse *pParse, const char *zLabel, int value){  Vdbe *v = sqlite3GetVdbe(pParse);  int mem = ++pParse->nMem;  sqlite3VdbeAddOp2(v, OP_Integer, value, mem);  if( pParse->explain==0 ){    sqlite3VdbeSetNumCols(v, 1);    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, P4_STATIC);  }  sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:13,


示例9: sqlite3DropTriggerPtr

/*** Drop a trigger given a pointer to that trigger. */void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){  Table   *pTable;  Vdbe *v;  sqlite3 *db = pParse->db;  int iDb;  iDb = sqlite3SchemaToIndex(pParse->db, pTrigger->pSchema);  assert( iDb>=0 && iDb<db->nDb );  pTable = tableOfTrigger(pTrigger);  assert( pTable );  assert( pTable->pSchema==pTrigger->pSchema || iDb==1 );#ifndef SQLITE_OMIT_AUTHORIZATION  {    int code = SQLITE_DROP_TRIGGER;    const char *zDb = db->aDb[iDb].zName;    const char *zTab = SCHEMA_TABLE(iDb);    if( iDb==1 ) code = SQLITE_DROP_TEMP_TRIGGER;    if( sqlite3AuthCheck(pParse, code, pTrigger->zName, pTable->zName, zDb) ||      sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){      return;    }  }#endif  /* Generate code to destroy the database record of the trigger.  */  assert( pTable!=0 );  if( (v = sqlite3GetVdbe(pParse))!=0 ){    int base;    static const int iLn = VDBE_OFFSET_LINENO(2);    static const VdbeOpList dropTrigger[] = {      { OP_Rewind,     0, ADDR(9),  0},      { OP_String8,    0, 1,        0}, /* 1 */      { OP_Column,     0, 1,        2},      { OP_Ne,         2, ADDR(8),  1},      { OP_String8,    0, 1,        0}, /* 4: "trigger" */      { OP_Column,     0, 0,        2},      { OP_Ne,         2, ADDR(8),  1},      { OP_Delete,     0, 0,        0},      { OP_Next,       0, ADDR(1),  0}, /* 8 */    };    sqlite3BeginWriteOperation(pParse, 0, iDb);    sqlite3OpenMasterTable(pParse, iDb);    base = sqlite3VdbeAddOpList(v,  ArraySize(dropTrigger), dropTrigger, iLn);    sqlite3VdbeChangeP4(v, base+1, pTrigger->zName, P4_TRANSIENT);    sqlite3VdbeChangeP4(v, base+4, "trigger", P4_STATIC);    sqlite3ChangeCookie(pParse, iDb);    sqlite3VdbeAddOp2(v, OP_Close, 0, 0);    sqlite3VdbeAddOp4(v, OP_DropTrigger, iDb, 0, 0, pTrigger->zName, 0);    if( pParse->nMem<3 ){      pParse->nMem = 3;    }  }}
开发者ID:AchironOS,项目名称:chromium-2,代码行数:58,


示例10: 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,


示例11: 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;  sqlite3 *db = pParse->db;  int iDb;  iDb = pTrigger->iDb;  assert( iDb>=0 && iDb<db->nDb );  pTable = tableOfTrigger(db, pTrigger);  assert(pTable);  assert( pTable->iDb==iDb || iDb==1 );#ifndef SQLITE_OMIT_AUTHORIZATION  {    int code = SQLITE_DROP_TRIGGER;    const char *zDb = db->aDb[iDb].zName;    const char *zTab = SCHEMA_TABLE(iDb);    if( 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 const 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, iDb);    sqlite3OpenMasterTable(v, iDb);    base = sqlite3VdbeAddOpList(v,  ArraySize(dropTrigger), dropTrigger);    sqlite3VdbeChangeP3(v, base+1, pTrigger->name, 0);    sqlite3ChangeCookie(db, v, iDb);    sqlite3VdbeAddOp(v, OP_Close, 0, 0);    sqlite3VdbeOp3(v, OP_DropTrigger, iDb, 0, pTrigger->name, 0);  }}
开发者ID:huangyt,项目名称:foundations.github.com,代码行数:54,


示例12: sqlite3OpenTable

/*** Generate code that will open a table for reading.*/void sqlite3OpenTable(  Parse *p,       /* Generate code into this VDBE */  int iCur,       /* The cursor number of the table */  int iDb,        /* The database index in sqlite3.aDb[] */  Table *pTab,    /* The table to be opened */  int opcode      /* OP_OpenRead or OP_OpenWrite */){  Vdbe *v = sqlite3GetVdbe(p);  assert( opcode==OP_OpenWrite || opcode==OP_OpenRead );  sqlite3TableLock(p, iDb, pTab->tnum, (opcode==OP_OpenWrite), pTab->zName);  sqlite3VdbeAddOp(v, OP_Integer, iDb, 0);  VdbeComment((v, "# %s", pTab->zName));  sqlite3VdbeAddOp(v, opcode, iCur, pTab->tnum);  sqlite3VdbeAddOp(v, OP_SetNumColumns, iCur, pTab->nCol);}
开发者ID:DrEastex,项目名称:Platinum,代码行数:18,


示例13: flagPragma

/*** Check to see if zRight and zLeft refer to a pragma that queries** or changes one of the flags in db->flags.  Return 1 if so and 0 if not.** Also, implement the pragma.*/static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){  static const struct sPragmaType {    const char *zName;  /* Name of the pragma */    int mask;           /* Mask for the db->flags value */  } aPragma[] = {    { "vdbe_trace",               SQLITE_VdbeTrace     },    { "sql_trace",                SQLITE_SqlTrace      },    { "vdbe_listing",             SQLITE_VdbeListing   },    { "full_column_names",        SQLITE_FullColNames  },    { "short_column_names",       SQLITE_ShortColNames },    { "count_changes",            SQLITE_CountRows     },    { "empty_result_callbacks",   SQLITE_NullCallback  },    /* The following is VERY experimental */    { "writable_schema",          SQLITE_WriteSchema   },    { "omit_readlock",            SQLITE_NoReadlock    },  };  int i;  const struct sPragmaType *p;  for(i=0, p=aPragma; i<sizeof(aPragma)/sizeof(aPragma[0]); i++, p++){    if( sqlite3StrICmp(zLeft, p->zName)==0 ){      sqlite3 *db = pParse->db;      Vdbe *v;      v = sqlite3GetVdbe(pParse);      if( v ){        if( zRight==0 ){          returnSingleInt(pParse, p->zName, (db->flags & p->mask)!=0 );        }else{          if( getBoolean(zRight) ){            db->flags |= p->mask;          }else{            db->flags &= ~p->mask;          }        }        /* If one of these pragmas is executed, any prepared statements        ** need to be recompiled.        */        sqlite3VdbeAddOp(v, OP_Expire, 0, 0);      }      return 1;    }  }  return 0;}
开发者ID:BackupTheBerlios,项目名称:snalp-svn,代码行数:48,


示例14: 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,


示例15: sqlite3Detach

/*** This routine is called by the parser to process a DETACH statement:****    DETACH DATABASE dbname**** The pDbname argument is the name of the database in the DETACH statement.*/void sqlite3Detach(Parse *pParse, Token *pDbname){  int i;  sqlite3 *db;  Vdbe *v;  Db *pDb = 0;  char *zName;  v = sqlite3GetVdbe(pParse);  if( !v ) return;  sqlite3VdbeAddOp(v, OP_Expire, 0, 0);  sqlite3VdbeAddOp(v, OP_Halt, 0, 0);  if( pParse->explain ) return;  db = pParse->db;  zName = sqlite3NameFromToken(pDbname);  if( zName==0 ) return;  for(i=0; i<db->nDb; i++){    pDb = &db->aDb[i];    if( pDb->pBt==0 ) continue;    if( sqlite3StrICmp(pDb->zName, zName)==0 ) break;  }  if( i>=db->nDb ){    sqlite3ErrorMsg(pParse, "no such database: %z", zName);    return;  }  if( i<2 ){    sqlite3ErrorMsg(pParse, "cannot detach database %z", zName);    return;  }  sqliteFree(zName);  if( !db->autoCommit ){    sqlite3ErrorMsg(pParse, "cannot DETACH database within transaction");    pParse->rc = SQLITE_ERROR;    return;  }#ifndef SQLITE_OMIT_AUTHORIZATION  if( sqlite3AuthCheck(pParse,SQLITE_DETACH,db->aDb[i].zName,0,0)!=SQLITE_OK ){    return;  }#endif /* SQLITE_OMIT_AUTHORIZATION */  sqlite3BtreeClose(pDb->pBt);  pDb->pBt = 0;  sqlite3ResetInternalSchema(db, 0);}
开发者ID:stephen-hill,项目名称:musicCube,代码行数:50,


示例16: reloadTableSchema

/*** Generate code to drop and reload the internal representation of table** pTab from the database, including triggers and temporary triggers.** Argument zName is the name of the table in the database schema at** the time the generated code is executed. This can be different from** pTab->zName if this function is being called to code part of an ** "ALTER TABLE RENAME TO" statement.生成代码删除和重新加载从数据库表pTab的内部表达示,包括触发器和临时触发器。参数zName在数据库模式中的表的名称生成的代码执行。这可以不同于pTab - > zName如果这个函数被调用的代码的一部分“ALTER TABLE RENAME TO”声明。*/static void reloadTableSchema(Parse *pParse, Table *pTab, const char *zName){  Vdbe *v;  char *zWhere;  int iDb;                   /* Index of database containing pTab 包含pTab数据库索引*/#ifndef SQLITE_OMIT_TRIGGER  Trigger *pTrig;#endif  v = sqlite3GetVdbe(pParse);  if( NEVER(v==0) ) return;  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);  assert( iDb>=0 );#ifndef SQLITE_OMIT_TRIGGER  /* Drop any table triggers from the internal schema. 降低任何表触发器内部模式。*/  for(pTrig=sqlite3TriggerList(pParse, pTab); pTrig; pTrig=pTrig->pNext){    int iTrigDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema);    assert( iTrigDb==iDb || iTrigDb==1 );    sqlite3VdbeAddOp4(v, OP_DropTrigger, iTrigDb, 0, 0, pTrig->zName, 0);  }#endif  /* Drop the table and index from the internal schema.  从内部模式中降低表和索引*/  sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);  /* Reload the table, index and permanent trigger schemas. 重载表、索引和不变的触发器模式*/  zWhere = sqlite3MPrintf(pParse->db, "tbl_name=%Q", zName);  if( !zWhere ) return;  sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);#ifndef SQLITE_OMIT_TRIGGER  /* Now, if the table is not stored in the temp database, reload any temp   ** triggers. Don't use IN(...) in case SQLITE_OMIT_SUBQUERY is defined.   现在,如果表没有在临时数据库中存储,那么重载任何临时触发器。  不要用IN(...)在 SQLITE_OMIT_SUBQUERY被默认的情况下。  */  if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){    sqlite3VdbeAddParseSchemaOp(v, 1, zWhere);  }#endif}
开发者ID:Guidachengong,项目名称:Sqlite3.07.14,代码行数:54,


示例17: sqlite3MinimumFileFormat

/*** Generate code to make sure the file format number is at least minFormat.** The generated code will increase the file format number if necessary.*/void sqlite3MinimumFileFormat(Parse *pParse, int iDb, int minFormat){  Vdbe *v;  v = sqlite3GetVdbe(pParse);  /* The VDBE should have been allocated before this routine is called.  ** If that allocation failed, we would have quit before reaching this  ** point */  if( ALWAYS(v) ){    int r1 = sqlite3GetTempReg(pParse);    int r2 = sqlite3GetTempReg(pParse);    int j1;    sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);    sqlite3VdbeUsesBtree(v, iDb);    sqlite3VdbeAddOp2(v, OP_Integer, minFormat, r2);    j1 = sqlite3VdbeAddOp3(v, OP_Ge, r2, 0, r1);    sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, r2);    sqlite3VdbeJumpHere(v, j1);    sqlite3ReleaseTempReg(pParse, r1);    sqlite3ReleaseTempReg(pParse, r2);  }}
开发者ID:Adoni,项目名称:WiEngine,代码行数:24,


示例18: reloadTableSchema

/*** Generate code to drop and reload the internal representation of table** pTab from the database, including triggers and temporary triggers.** Argument zName is the name of the table in the database schema at** the time the generated code is executed. This can be different from** pTab->zName if this function is being called to code part of an ** "ALTER TABLE RENAME TO" statement.*/static void reloadTableSchema(Parse *pParse, Table *pTab, const char *zName){  Vdbe *v;  char *zWhere;  int iDb;                   /* Index of database containing pTab */#ifndef SQLITE_OMIT_TRIGGER  Trigger *pTrig;#endif  v = sqlite3GetVdbe(pParse);  if( !v ) return;  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);  assert( iDb>=0 );#ifndef SQLITE_OMIT_TRIGGER  /* Drop any table triggers from the internal schema. */  for(pTrig=pTab->pTrigger; pTrig; pTrig=pTrig->pNext){    int iTrigDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema);    assert( iTrigDb==iDb || iTrigDb==1 );    sqlite3VdbeAddOp4(v, OP_DropTrigger, iTrigDb, 0, 0, pTrig->name, 0);  }#endif  /* Drop the table and index from the internal schema */  sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);  /* Reload the table, index and permanent trigger schemas. */  zWhere = sqlite3MPrintf(pParse->db, "tbl_name=%Q", zName);  if( !zWhere ) return;  sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 0, 0, zWhere, P4_DYNAMIC);#ifndef SQLITE_OMIT_TRIGGER  /* Now, if the table is not stored in the temp database, reload any temp   ** triggers. Don't use IN(...) in case SQLITE_OMIT_SUBQUERY is defined.   */  if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){    sqlite3VdbeAddOp4(v, OP_ParseSchema, 1, 0, 0, zWhere, P4_DYNAMIC);  }#endif}
开发者ID:qiuping,项目名称:sqlcipher,代码行数:48,


示例19: sqlite3FkDropTable

/*** This function is called to generate code that runs when table pTab is** being dropped from the database. The SrcList passed as the second argument** to this function contains a single entry guaranteed to resolve to** table pTab.**** Normally, no code is required. However, if either****   (a) The table is the parent table of a FK constraint, or**   (b) The table is the child table of a deferred FK constraint and it is**       determined at runtime that there are outstanding deferred FK **       constraint violations in the database,**** then the equivalent of "DELETE FROM <tbl>" is executed before dropping** the table from the database. Triggers are disabled while running this** DELETE, but foreign key actions are not.*/void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){  sqlite3 *db = pParse->db;  if( (db->flags&SQLITE_ForeignKeys) && !IsVirtual(pTab) && !pTab->pSelect ){    int iSkip = 0;    Vdbe *v = sqlite3GetVdbe(pParse);    assert( v );                  /* VDBE has already been allocated */    if( sqlite3FkReferences(pTab)==0 ){      /* Search for a deferred foreign key constraint for which this table      ** is the child table. If one cannot be found, return without       ** generating any VDBE code. If one can be found, then jump over      ** the entire DELETE if there are no outstanding deferred constraints      ** when this statement is run.  */      FKey *p;      for(p=pTab->pFKey; p; p=p->pNextFrom){        if( p->isDeferred ) break;      }      if( !p ) return;      iSkip = sqlite3VdbeMakeLabel(v);      sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip);    }    pParse->disableTriggers = 1;    sqlite3DeleteFrom(pParse, sqlite3SrcListDup(db, pName, 0), 0);    pParse->disableTriggers = 0;    /* If the DELETE has generated immediate foreign key constraint     ** violations, halt the VDBE and return an error at this point, before    ** any modifications to the schema are made. This is because statement    ** transactions are not able to rollback schema changes.  */    sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);    sqlite3HaltConstraint(        pParse, OE_Abort, "foreign key constraint failed", P4_STATIC    );    if( iSkip ){      sqlite3VdbeResolveLabel(v, iSkip);    }  }}
开发者ID:77songsong,项目名称:sqlite3,代码行数:57,


示例20: sqlite3OpenTableAndIndices

/*** Generate code that will open cursors for a table and for all** indices of that table.  The "base" parameter is the cursor number used** for the table.  Indices are opened on subsequent cursors.*/void sqlite3OpenTableAndIndices(  Parse *pParse,   /* Parsing context */  Table *pTab,     /* Table to be opened */  int base,        /* Cursor number assigned to the table */  int op           /* OP_OpenRead or OP_OpenWrite */){  int i;  Index *pIdx;  Vdbe *v = sqlite3GetVdbe(pParse);  assert( v!=0 );  sqlite3VdbeAddOp(v, OP_Integer, pTab->iDb, 0);  sqlite3VdbeAddOp(v, op, base, pTab->tnum);  sqlite3VdbeAddOp(v, OP_SetNumColumns, base, pTab->nCol);  for(i=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){    sqlite3VdbeAddOp(v, OP_Integer, pIdx->iDb, 0);    sqlite3VdbeOp3(v, op, i+base, pIdx->tnum,                   (char*)&pIdx->keyInfo, P3_KEYINFO);  }  if( pParse->nTab<=base+i ){    pParse->nTab = base+i;  }}
开发者ID:kanbang,项目名称:Colt,代码行数:27,


示例21: sqlite3CompleteInsertion

/*** This routine generates code to finish the INSERT or UPDATE operation** that was started by a prior call to sqlite3GenerateConstraintChecks.** The stack must contain keys for all active indices followed by data** and the recno for the new entry.  This routine creates the new** entries in all indices and in the main table.**** The arguments to this routine should be the same as the first six** arguments to sqlite3GenerateConstraintChecks.*/void sqlite3CompleteInsertion(  Parse *pParse,      /* The parser context */  Table *pTab,        /* the table into which we are inserting */  int base,           /* Index of a read/write cursor pointing at pTab */  char *aIdxUsed,     /* Which indices are used.  NULL means all are used */  int recnoChng,      /* True if the record number will change */  int isUpdate,       /* True for UPDATE, False for INSERT */  int newIdx          /* Index of NEW table for triggers.  -1 if none */){  int i;  Vdbe *v;  int nIdx;  Index *pIdx;  int pik_flags;  v = sqlite3GetVdbe(pParse);  assert( v!=0 );  assert( pTab->pSelect==0 );  /* This table is not a VIEW */  for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}  for(i=nIdx-1; i>=0; i--){    if( aIdxUsed && aIdxUsed[i]==0 ) continue;    sqlite3VdbeAddOp(v, OP_IdxPut, base+i+1, 0);  }  sqlite3VdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0);  sqlite3TableAffinityStr(v, pTab);  if( newIdx>=0 ){    sqlite3VdbeAddOp(v, OP_Dup, 1, 0);    sqlite3VdbeAddOp(v, OP_Dup, 1, 0);    sqlite3VdbeAddOp(v, OP_PutIntKey, newIdx, 0);  }  pik_flags = (OPFLAG_NCHANGE|(isUpdate?0:OPFLAG_LASTROWID));  sqlite3VdbeAddOp(v, OP_PutIntKey, base, pik_flags);    if( isUpdate && recnoChng ){    sqlite3VdbeAddOp(v, OP_Pop, 1, 0);  }}
开发者ID:kanbang,项目名称:Colt,代码行数:47,


示例22: reloadTableSchema

/*** Generate code to drop and reload the internal representation of table** pTab from the database, including triggers and temporary triggers.** Argument zName is the name of the table in the database schema at** the time the generated code is executed. This can be different from** pTab->zName if this function is being called to code part of an ** "ALTER TABLE RENAME TO" statement.*/static void reloadTableSchema(Parse *pParse, Table *pTab, const char *zName){  Vdbe *v;  char *zWhere;  int iDb;#ifndef SQLITE_OMIT_TRIGGER  Trigger *pTrig;#endif  v = sqlite3GetVdbe(pParse);  if( !v ) return;  iDb = pTab->iDb;#ifndef SQLITE_OMIT_TRIGGER  /* Drop any table triggers from the internal schema. */  for(pTrig=pTab->pTrigger; pTrig; pTrig=pTrig->pNext){    assert( pTrig->iDb==iDb || pTrig->iDb==1 );    sqlite3VdbeOp3(v, OP_DropTrigger, pTrig->iDb, 0, pTrig->name, 0);  }#endif  /* Drop the table and index from the internal schema */  sqlite3VdbeOp3(v, OP_DropTable, iDb, 0, pTab->zName, 0);  /* Reload the table, index and permanent trigger schemas. */  zWhere = sqlite3MPrintf("tbl_name=%Q", zName);  if( !zWhere ) return;  sqlite3VdbeOp3(v, OP_ParseSchema, iDb, 0, zWhere, P3_DYNAMIC);#ifndef SQLITE_OMIT_TRIGGER  /* Now, if the table is not stored in the temp database, reload any temp   ** triggers. Don't use IN(...) in case SQLITE_OMIT_SUBQUERY is defined.   */  if( (zWhere=whereTempTriggers(pParse, pTab)) ){    sqlite3VdbeOp3(v, OP_ParseSchema, 1, 0, zWhere, P3_DYNAMIC);  }#endif}
开发者ID:stephen-hill,项目名称:musicCube,代码行数:45,


示例23: sqlite3DropTriggerPtr

/*** Drop a trigger given a pointer to that trigger. */void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){  Table   *pTable;  Vdbe *v;  sqlite3 *db = pParse->db;  int iDb;  iDb = sqlite3SchemaToIndex(pParse->db, pTrigger->pSchema);  assert( iDb>=0 && iDb<db->nDb );  pTable = tableOfTrigger(pTrigger);  assert( pTable );  assert( pTable->pSchema==pTrigger->pSchema || iDb==1 );#ifndef SQLITE_OMIT_AUTHORIZATION  {    int code = SQLITE_DROP_TRIGGER;    const char *zDb = db->aDb[iDb].zDbSName;    const char *zTab = SCHEMA_TABLE(iDb);    if( iDb==1 ) code = SQLITE_DROP_TEMP_TRIGGER;    if( sqlite3AuthCheck(pParse, code, pTrigger->zName, pTable->zName, zDb) ||      sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){      return;    }  }#endif  /* Generate code to destroy the database record of the trigger.  */  assert( pTable!=0 );  if( (v = sqlite3GetVdbe(pParse))!=0 ){    sqlite3NestedParse(pParse,       "DELETE FROM %Q.%s WHERE name=%Q AND type='trigger'",       db->aDb[iDb].zDbSName, MASTER_NAME, pTrigger->zName    );    sqlite3ChangeCookie(pParse, iDb);    sqlite3VdbeAddOp4(v, OP_DropTrigger, iDb, 0, 0, pTrigger->zName, 0);  }}
开发者ID:cznic,项目名称:cc,代码行数:39,


示例24: sqlite3DeleteFrom

//.........这里部分代码省略.........  if( sqlite3ViewGetColumnNames(pParse, pTab) ){    goto delete_from_cleanup;  }  if( sqlite3IsReadOnly(pParse, pTab, (pTrigger?1:0)) ){    goto delete_from_cleanup;  }  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);  assert( iDb<db->nDb );  rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0,                             db->aDb[iDb].zDbSName);  assert( rcauth==SQLITE_OK || rcauth==SQLITE_DENY || rcauth==SQLITE_IGNORE );  if( rcauth==SQLITE_DENY ){    goto delete_from_cleanup;  }  assert(!isView || pTrigger);  /* Assign cursor numbers to the table and all its indices.  */  assert( pTabList->nSrc==1 );  iTabCur = pTabList->a[0].iCursor = pParse->nTab++;  for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){    pParse->nTab++;  }  /* Start the view context  */  if( isView ){    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);  }  /* Begin generating code.  */  v = sqlite3GetVdbe(pParse);  if( v==0 ){    goto delete_from_cleanup;  }  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);  sqlite3BeginWriteOperation(pParse, 1, iDb);  /* If we are trying to delete from a view, realize that view into  ** an ephemeral table.  */#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)  if( isView ){    sqlite3MaterializeView(pParse, pTab, pWhere, iTabCur);    iDataCur = iIdxCur = iTabCur;  }#endif  /* Resolve the column names in the WHERE clause.  */  memset(&sNC, 0, sizeof(sNC));  sNC.pParse = pParse;  sNC.pSrcList = pTabList;  if( sqlite3ResolveExprNames(&sNC, pWhere) ){    goto delete_from_cleanup;  }  /* Initialize the counter of the number of rows deleted, if  ** we are counting rows.  */  if( db->flags & SQLITE_CountRows ){    memCnt = ++pParse->nMem;    sqlite3VdbeAddOp2(v, OP_Integer, 0, memCnt);  }
开发者ID:chinesemanbobo,项目名称:PPDemo,代码行数:67,


示例25: sqlite3FinishTrigger

/*** This routine is called after all of the trigger actions have been parsed** in order to complete the process of building the trigger.*/void sqlite3FinishTrigger(  Parse *pParse,          /* Parser context */  TriggerStep *pStepList, /* The triggered program */  Token *pAll             /* Token that describes the complete CREATE TRIGGER */){  Trigger *nt = 0;          /* The trigger whose construction is finishing up */  sqlite *db = pParse->db;  /* The database */  DbFixer sFix;  if( pParse->nErr || pParse->pNewTrigger==0 ) goto triggerfinish_cleanup;  nt = pParse->pNewTrigger;  pParse->pNewTrigger = 0;  nt->step_list = pStepList;  while( pStepList ){    pStepList->pTrig = nt;    pStepList = pStepList->pNext;  }  if( sqlite3FixInit(&sFix, pParse, nt->iDb, "trigger", &nt->nameToken)           && sqlite3FixTriggerStep(&sFix, nt->step_list) ){    goto triggerfinish_cleanup;  }  /* if we are not initializing, and this trigger is not on a TEMP table,   ** build the sqlite_master entry  */  if( !db->init.busy ){    static VdbeOpList insertTrig[] = {      { OP_NewRecno,   0, 0,  0          },      { OP_String8,     0, 0,  "trigger"  },      { OP_String8,     0, 0,  0          },  /* 2: trigger name */      { OP_String8,     0, 0,  0          },  /* 3: table name */      { OP_Integer,    0, 0,  0          },      { OP_String8,     0, 0,  "CREATE TRIGGER "},      { OP_String8,     0, 0,  0          },  /* 6: SQL */      { OP_Concat8,     2, 0,  0          },       { OP_MakeRecord, 5, 0,  "tttit"    },      { OP_PutIntKey,  0, 0,  0          },    };    int addr;    Vdbe *v;    /* Make an entry in the sqlite_master table */    v = sqlite3GetVdbe(pParse);    if( v==0 ) goto triggerfinish_cleanup;    sqlite3BeginWriteOperation(pParse, 0, nt->iDb);    sqlite3OpenMasterTable(v, nt->iDb);    addr = sqlite3VdbeAddOpList(v, ArraySize(insertTrig), insertTrig);    sqlite3VdbeChangeP3(v, addr+2, nt->name, 0);     sqlite3VdbeChangeP3(v, addr+3, nt->table, 0);     sqlite3VdbeChangeP3(v, addr+6, pAll->z, pAll->n);    if( nt->iDb!=0 ){      sqlite3ChangeCookie(db, v, nt->iDb);    }    sqlite3VdbeAddOp(v, OP_Close, 0, 0);    sqlite3EndWriteOperation(pParse);  }  if( !pParse->explain ){    Table *pTab;    sqlite3HashInsert(&db->aDb[nt->iDb].trigHash,                      nt->name, strlen(nt->name)+1, nt);    pTab = sqlite3LocateTable(pParse, nt->table, db->aDb[nt->iTabDb].zName);    assert( pTab!=0 );    nt->pNext = pTab->pTrigger;    pTab->pTrigger = nt;    nt = 0;  }triggerfinish_cleanup:  sqlite3DeleteTrigger(nt);  sqlite3DeleteTrigger(pParse->pNewTrigger);  pParse->pNewTrigger = 0;  sqlite3DeleteTriggerStep(pStepList);}
开发者ID:open2cerp,项目名称:Open2C-ERP,代码行数:78,


示例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: sqlite3VtabFinishParse

/*** The parser calls this routine after the CREATE VIRTUAL TABLE statement** has been completely parsed.*/void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){  Table *pTab = pParse->pNewTable;  /* The table being constructed */  sqlite3 *db = pParse->db;         /* The database connection */  if( pTab==0 ) return;  addArgumentToVtab(pParse);  pParse->sArg.z = 0;  if( pTab->nModuleArg<1 ) return;    /* If the CREATE VIRTUAL TABLE statement is being entered for the  ** first time (in other words if the virtual table is actually being  ** created now instead of just being read out of sqlite_master) then  ** do additional initialization work and store the statement text  ** in the sqlite_master table.  */  if( !db->init.busy ){    char *zStmt;    char *zWhere;    int iDb;    int iReg;    Vdbe *v;    /* Compute the complete text of the CREATE VIRTUAL TABLE statement */    if( pEnd ){      pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n;    }    zStmt = sqlite3MPrintf(db, "CREATE VIRTUAL TABLE %T", &pParse->sNameToken);    /* A slot for the record has already been allocated in the     ** SQLITE_MASTER table.  We just need to update that slot with all    ** the information we've collected.      **    ** The VM register number pParse->regRowid holds the rowid of an    ** entry in the sqlite_master table tht was created for this vtab    ** by sqlite3StartTable().    */    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);    sqlite3NestedParse(pParse,      "UPDATE %Q.%s "         "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q "       "WHERE rowid=#%d",      db->aDb[iDb].zDbSName, MASTER_NAME,      pTab->zName,      pTab->zName,      zStmt,      pParse->regRowid    );    sqlite3DbFree(db, zStmt);    v = sqlite3GetVdbe(pParse);    sqlite3ChangeCookie(pParse, iDb);    sqlite3VdbeAddOp0(v, OP_Expire);    zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);    sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);    iReg = ++pParse->nMem;    sqlite3VdbeLoadString(v, iReg, pTab->zName);    sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg);  }  /* If we are rereading the sqlite_master table create the in-memory  ** record of the table. The xConnect() method is not called until  ** the first time the virtual table is used in an SQL statement. This  ** allows a schema that contains virtual tables to be loaded before  ** the required virtual table implementations are registered.  */  else {    Table *pOld;    Schema *pSchema = pTab->pSchema;    const char *zName = pTab->zName;    assert( sqlite3SchemaMutexHeld(db, 0, pSchema) );    pOld = sqlite3HashInsert(&pSchema->tblHash, zName, pTab);    if( pOld ){      sqlite3OomFault(db);      assert( pTab==pOld );  /* Malloc must have failed inside HashInsert() */      return;    }    pParse->pNewTable = 0;  }}
开发者ID:wangyiran126,项目名称:sqlite,代码行数:83,



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


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