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

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

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

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

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

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


示例2: sqlite3OpenTableForReading

/*** Generate code that will open a table for reading.*/void sqlite3OpenTableForReading(  Vdbe *v,        /* Generate code into this VDBE */  int iCur,       /* The cursor number of the table */  Table *pTab     /* The table to be opened */){  sqlite3VdbeAddOp(v, OP_Integer, pTab->iDb, 0);  sqlite3VdbeAddOp(v, OP_OpenRead, iCur, pTab->tnum);  VdbeComment((v, "# %s", pTab->zName));  sqlite3VdbeAddOp(v, OP_SetNumColumns, iCur, pTab->nCol);}
开发者ID:webmaster4world,项目名称:manual-indexing,代码行数:13,


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


示例4: sqlite3GenerateRowDelete

/*** This routine generates VDBE code that causes a single row of a** single table to be deleted.**** The VDBE must be in a particular state when this routine is called.** These are the requirements:****   1.  A read/write cursor pointing to pTab, the table containing the row**       to be deleted, must be opened as cursor number "base".****   2.  Read/write cursors for all indices of pTab must be open as**       cursor number base+i for the i-th index.****   3.  The record number of the row to be deleted must be on the top**       of the stack.**** This routine pops the top of the stack to remove the record number** and then generates code to remove both the table record and all index** entries that point to that record.*/void sqlite3GenerateRowDelete(  sqlite3 *db,       /* The database containing the index */  Vdbe *v,           /* Generate code into this VDBE */  Table *pTab,       /* Table containing the row to be deleted */  int iCur,          /* Cursor number for the table */  int count          /* Increment the row change counter */){  int addr;  addr = sqlite3VdbeAddOp(v, OP_NotExists, iCur, 0);  sqlite3GenerateRowIndexDelete(db, v, pTab, iCur, 0);  sqlite3VdbeAddOp(v, OP_Delete, iCur, (count?OPFLAG_NCHANGE:0));  sqlite3VdbeChangeP2(v, addr, sqlite3VdbeCurrentAddr(v));}
开发者ID:webmaster4world,项目名称:manual-indexing,代码行数:33,


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


示例6: 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;  int iDb;  Index *pIdx;  Vdbe *v;  if( IsVirtual(pTab) ) return;  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);  v = sqlite3GetVdbe(pParse);  assert( v!=0 );  sqlite3OpenTable(pParse, base, iDb, pTab, op);  for(i=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){    KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx);    assert( pIdx->pSchema==pTab->pSchema );    sqlite3VdbeAddOp(v, OP_Integer, iDb, 0);    VdbeComment((v, "# %s", pIdx->zName));    sqlite3VdbeOp3(v, op, i+base, pIdx->tnum, (char*)pKey, P3_KEYINFO_HANDOFF);  }  if( pParse->nTab<=base+i ){    pParse->nTab = base+i;  }}
开发者ID:nilsvanvelzen,项目名称:OpenDA,代码行数:32,


示例7: sqlite3GenerateRowDelete

/*** This routine generates VDBE code that causes a single row of a** single table to be deleted.**** The VDBE must be in a particular state when this routine is called.** These are the requirements:****   1.  A read/write cursor pointing to pTab, the table containing the row**       to be deleted, must be opened as cursor number "base".****   2.  Read/write cursors for all indices of pTab must be open as**       cursor number base+i for the i-th index.****   3.  The record number of the row to be deleted must be on the top**       of the stack.**** This routine pops the top of the stack to remove the record number** and then generates code to remove both the table record and all index** entries that point to that record.*/void sqlite3GenerateRowDelete(  sqlite3 *db,       /* The database containing the index */  Vdbe *v,           /* Generate code into this VDBE */  Table *pTab,       /* Table containing the row to be deleted */  int iCur,          /* Cursor number for the table */  int count          /* Increment the row change counter */){  int addr;  addr = sqlite3VdbeAddOp(v, OP_NotExists, iCur, 0);  sqlite3GenerateRowIndexDelete(v, pTab, iCur, 0);  sqlite3VdbeAddOp(v, OP_Delete, iCur, (count?OPFLAG_NCHANGE:0));  if( count ){    sqlite3VdbeChangeP3(v, -1, pTab->zName, P3_STATIC);  }  sqlite3VdbeJumpHere(v, addr);}
开发者ID:Nephyrin,项目名称:-furry-octo-nemesis,代码行数:36,


示例8: 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 ){    sqlite3VdbeAddOp(v, OP_Vacuum, 0, 0);  }  return;}
开发者ID:WeyrSDev,项目名称:gamecode3,代码行数:17,


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


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


示例11: sqlite3GenerateIndexKey

/*** Generate code that will assemble an index key and put it on the top** of the tack.  The key with be for index pIdx which is an index on pTab.** iCur is the index of a cursor open on the pTab table and pointing to** the entry that needs indexing.*/void sqlite3GenerateIndexKey(    Vdbe *v,           /* Generate code into this VDBE */    Index *pIdx,       /* The index for which to generate a key */    int iCur           /* Cursor number for the pIdx->pTable table */) {    int j;    Table *pTab = pIdx->pTable;    sqlite3VdbeAddOp(v, OP_Recno, iCur, 0);    for(j=0; j<pIdx->nColumn; j++) {        int idx = pIdx->aiColumn[j];        if( idx==pTab->iPKey ) {            sqlite3VdbeAddOp(v, OP_Dup, j, 0);        } else {            sqlite3VdbeAddOp(v, OP_Column, iCur, idx);        }    }    sqlite3VdbeAddOp(v, OP_MakeRecord, pIdx->nColumn, (1<<24));    sqlite3IndexAffinityStr(v, pIdx);}
开发者ID:open2cerp,项目名称:Open2C-ERP,代码行数:26,


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


示例13: 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->name, 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 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(pParse, 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:DoktahWorm,项目名称:rhodes,代码行数:53,


示例14: sqlite3GenerateRowIndexDelete

/*** This routine generates VDBE code that causes the deletion of all** index entries associated with a single row of a single table.**** The VDBE must be in a particular state when this routine is called.** These are the requirements:****   1.  A read/write cursor pointing to pTab, the table containing the row**       to be deleted, must be opened as cursor number "iCur".****   2.  Read/write cursors for all indices of pTab must be open as**       cursor number iCur+i for the i-th index.****   3.  The "iCur" cursor must be pointing to the row that is to be**       deleted.*/void sqlite3GenerateRowIndexDelete(  Vdbe *v,           /* Generate code into this VDBE */  Table *pTab,       /* Table containing the row to be deleted */  int iCur,          /* Cursor number for the table */  char *aIdxUsed     /* Only delete if aIdxUsed!=0 && aIdxUsed[i]!=0 */){  int i;  Index *pIdx;  for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){    if( aIdxUsed!=0 && aIdxUsed[i-1]==0 ) continue;    sqlite3GenerateIndexKey(v, pIdx, iCur);    sqlite3VdbeAddOp(v, OP_IdxDelete, iCur+i, 0);  }}
开发者ID:Nephyrin,项目名称:-furry-octo-nemesis,代码行数:31,


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


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


示例17: sqlite3Pragma

/*** Process a pragma statement.  **** Pragmas are of this form:****      PRAGMA [database.]id [= value]**** The identifier might also be a string.  The value is a string, and** identifier, or a number.  If minusFlag is true, then the value is** a number that was preceded by a minus sign.**** If the left side is "database.id" then pId1 is the database name** and pId2 is the id.  If the left side is just "id" then pId1 is the** id and pId2 is any empty string.*/void sqlite3Pragma(  Parse *pParse,   Token *pId1,        /* First part of [database.]id field */  Token *pId2,        /* Second part of [database.]id field, or NULL */  Token *pValue,      /* Token for <value>, or NULL */  int minusFlag       /* True if a '-' sign preceded <value> */){  char *zLeft = 0;       /* Nul-terminated UTF-8 string <id> */  char *zRight = 0;      /* Nul-terminated UTF-8 string <value>, or NULL */  const char *zDb = 0;   /* The database name */  Token *pId;            /* Pointer to <id> token */  int iDb;               /* Database index for <database> */  sqlite3 *db = pParse->db;  Db *pDb;  Vdbe *v = sqlite3GetVdbe(pParse);  if( v==0 ) return;  /* Interpret the [database.] part of the pragma statement. iDb is the  ** index of the database this pragma is being applied to in db.aDb[]. */  iDb = sqlite3TwoPartName(pParse, pId1, pId2, &pId);  if( iDb<0 ) return;  pDb = &db->aDb[iDb];  zLeft = sqlite3NameFromToken(pId);  if( !zLeft ) return;  if( minusFlag ){    zRight = sqlite3MPrintf("-%T", pValue);  }else{    zRight = sqlite3NameFromToken(pValue);  }  zDb = ((iDb>0)?pDb->zName:0);  if( sqlite3AuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight, zDb) ){    goto pragma_out;  } #ifndef SQLITE_OMIT_PAGER_PRAGMAS  /*  **  PRAGMA [database.]default_cache_size  **  PRAGMA [database.]default_cache_size=N  **  ** The first form reports the current persistent setting for the  ** page cache size.  The value returned is the maximum number of  ** pages in the page cache.  The second form sets both the current  ** page cache size value and the persistent page cache size value  ** stored in the database file.  **  ** The default cache size is stored in meta-value 2 of page 1 of the  ** database file.  The cache size is actually the absolute value of  ** this memory location.  The sign of meta-value 2 determines the  ** synchronous setting.  A negative value means synchronous is off  ** and a positive value means synchronous is on.  */  if( sqlite3StrICmp(zLeft,"default_cache_size")==0 ){    static const VdbeOpList getCacheSize[] = {      { OP_ReadCookie,  0, 2,        0},  /* 0 */      { OP_AbsValue,    0, 0,        0},      { OP_Dup,         0, 0,        0},      { OP_Integer,     0, 0,        0},      { OP_Ne,          0, 6,        0},      { OP_Integer,     0, 0,        0},  /* 5 */      { OP_Callback,    1, 0,        0},    };    int addr;    if( sqlite3ReadSchema(pParse) ) goto pragma_out;    if( !zRight ){      sqlite3VdbeSetNumCols(v, 1);      sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cache_size", P3_STATIC);      addr = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize);      sqlite3VdbeChangeP1(v, addr, iDb);      sqlite3VdbeChangeP1(v, addr+5, MAX_PAGES);    }else{      int size = atoi(zRight);      if( size<0 ) size = -size;      sqlite3BeginWriteOperation(pParse, 0, iDb);      sqlite3VdbeAddOp(v, OP_Integer, size, 0);      sqlite3VdbeAddOp(v, OP_ReadCookie, iDb, 2);      addr = sqlite3VdbeAddOp(v, OP_Integer, 0, 0);      sqlite3VdbeAddOp(v, OP_Ge, 0, addr+3);      sqlite3VdbeAddOp(v, OP_Negative, 0, 0);      sqlite3VdbeAddOp(v, OP_SetCookie, iDb, 2);      pDb->pSchema->cache_size = size;      sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);    }  }else//.........这里部分代码省略.........
开发者ID:tmarques,项目名称:waheela,代码行数:101,


示例18: codeTriggerProgram

/*** Generate VDBE code for zero or more statements inside the body of a** trigger.  */static int codeTriggerProgram(  Parse *pParse,            /* The parser context */  TriggerStep *pStepList,   /* List of statements inside the trigger body */  int orconfin              /* Conflict algorithm. (OE_Abort, etc) */  ){  TriggerStep * pTriggerStep = pStepList;  int orconf;  Vdbe *v = pParse->pVdbe;  sqlite3 *db = pParse->db;  assert( pTriggerStep!=0 );  assert( v!=0 );  sqlite3VdbeAddOp(v, OP_ContextPush, 0, 0);  VdbeComment((v, "# begin trigger %s", pStepList->pTrig->name));  while( pTriggerStep ){    orconf = (orconfin == OE_Default)?pTriggerStep->orconf:orconfin;    pParse->trigStack->orconf = orconf;    switch( pTriggerStep->op ){      case TK_SELECT: {        Select *ss = sqlite3SelectDup(db, pTriggerStep->pSelect);        if( ss ){          sqlite3SelectResolve(pParse, ss, 0);          sqlite3Select(pParse, ss, SRT_Discard, 0, 0, 0, 0, 0);          sqlite3SelectDelete(ss);        }        break;      }      case TK_UPDATE: {        SrcList *pSrc;        pSrc = targetSrcList(pParse, pTriggerStep);        sqlite3VdbeAddOp(v, OP_ResetCount, 0, 0);        sqlite3Update(pParse, pSrc,                sqlite3ExprListDup(db, pTriggerStep->pExprList),                 sqlite3ExprDup(db, pTriggerStep->pWhere), orconf);        sqlite3VdbeAddOp(v, OP_ResetCount, 1, 0);        break;      }      case TK_INSERT: {        SrcList *pSrc;        pSrc = targetSrcList(pParse, pTriggerStep);        sqlite3VdbeAddOp(v, OP_ResetCount, 0, 0);        sqlite3Insert(pParse, pSrc,          sqlite3ExprListDup(db, pTriggerStep->pExprList),           sqlite3SelectDup(db, pTriggerStep->pSelect),           sqlite3IdListDup(db, pTriggerStep->pIdList), orconf);        sqlite3VdbeAddOp(v, OP_ResetCount, 1, 0);        break;      }      case TK_DELETE: {        SrcList *pSrc;        sqlite3VdbeAddOp(v, OP_ResetCount, 0, 0);        pSrc = targetSrcList(pParse, pTriggerStep);        sqlite3DeleteFrom(pParse, pSrc,                           sqlite3ExprDup(db, pTriggerStep->pWhere));        sqlite3VdbeAddOp(v, OP_ResetCount, 1, 0);        break;      }      default:        assert(0);    }     pTriggerStep = pTriggerStep->pNext;  }  sqlite3VdbeAddOp(v, OP_ContextPop, 0, 0);  VdbeComment((v, "# end trigger %s", pStepList->pTrig->name));  return 0;}
开发者ID:DoktahWorm,项目名称:rhodes,代码行数:71,


示例19: sqlite3DeleteFrom

//.........这里部分代码省略.........  sNC.pSrcList = pTabList;  if( sqlite3ExprResolveNames(&sNC, pWhere) ){    goto delete_from_cleanup;  }  /* 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, triggers_exist, pTab->iDb);  /* If we are trying to delete from a view, construct that view into  ** a temporary table.  */  if( isView ){    Select *pView = sqlite3SelectDup(pTab->pSelect);    sqlite3Select(pParse, pView, SRT_TempTable, iCur, 0, 0, 0, 0);    sqlite3SelectDelete(pView);  }  /* Initialize the counter of the number of rows deleted, if  ** we are counting rows.  */  if( db->flags & SQLITE_CountRows ){    sqlite3VdbeAddOp(v, OP_Integer, 0, 0);  }  /* Special case: A DELETE without a WHERE clause deletes everything.  ** It is easier just to erase the whole table.  Note, however, that  ** this means that the row change count will be incorrect.  */  if( pWhere==0 && !triggers_exist ){    if( db->flags & SQLITE_CountRows ){      /* If counting rows deleted, just count the total number of      ** entries in the table. */      int endOfLoop = sqlite3VdbeMakeLabel(v);      int addr;      if( !isView ){        sqlite3OpenTableForReading(v, iCur, pTab);      }      sqlite3VdbeAddOp(v, OP_Rewind, iCur, sqlite3VdbeCurrentAddr(v)+2);      addr = sqlite3VdbeAddOp(v, OP_AddImm, 1, 0);      sqlite3VdbeAddOp(v, OP_Next, iCur, addr);      sqlite3VdbeResolveLabel(v, endOfLoop);      sqlite3VdbeAddOp(v, OP_Close, iCur, 0);    }    if( !isView ){      sqlite3VdbeAddOp(v, OP_Clear, pTab->tnum, pTab->iDb);      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){        sqlite3VdbeAddOp(v, OP_Clear, pIdx->tnum, pIdx->iDb);      }    }  }  /* The usual case: There is a WHERE clause so we have to scan through  ** the table and pick which records to delete.  */
开发者ID:webmaster4world,项目名称:manual-indexing,代码行数:67,


示例20: 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 *pTrig = 0;     /* The trigger whose construction is finishing up */  sqlite3 *db = pParse->db;  /* The database */  DbFixer sFix;  int iDb;                   /* Database containing the trigger */  pTrig = pParse->pNewTrigger;  pParse->pNewTrigger = 0;  if( pParse->nErr || !pTrig ) goto triggerfinish_cleanup;  iDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema);  pTrig->step_list = pStepList;  while( pStepList ){    pStepList->pTrig = pTrig;    pStepList = pStepList->pNext;  }  if( sqlite3FixInit(&sFix, pParse, iDb, "trigger", &pTrig->nameToken)           && sqlite3FixTriggerStep(&sFix, pTrig->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 const VdbeOpList insertTrig[] = {      { OP_NewRowid,   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_Concat,     0, 0,  0          },       { OP_MakeRecord, 5, 0,  "aaada"    },      { OP_Insert,     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, iDb);    sqlite3OpenMasterTable(pParse, iDb);    addr = sqlite3VdbeAddOpList(v, ArraySize(insertTrig), insertTrig);    sqlite3VdbeChangeP3(v, addr+2, pTrig->name, 0);     sqlite3VdbeChangeP3(v, addr+3, pTrig->table, 0);     sqlite3VdbeChangeP3(v, addr+6, (char*)pAll->z, pAll->n);    sqlite3ChangeCookie(db, v, iDb);    sqlite3VdbeAddOp(v, OP_Close, 0, 0);    sqlite3VdbeOp3(v, OP_ParseSchema, iDb, 0, sqlite3MPrintf(        db, "type='trigger' AND name='%q'", pTrig->name), P3_DYNAMIC    );  }  if( db->init.busy ){    int n;    Table *pTab;    Trigger *pDel;    pDel = (Trigger*)sqlite3HashInsert(&db->aDb[iDb].pSchema->trigHash,                      pTrig->name, strlen(pTrig->name), pTrig);    if( pDel ){      assert( pDel==pTrig );      db->mallocFailed = 1;      goto triggerfinish_cleanup;    }    n = strlen(pTrig->table) + 1;    pTab = (Table*)sqlite3HashFind(&pTrig->pTabSchema->tblHash, pTrig->table, n);    assert( pTab!=0 );    pTrig->pNext = pTab->pTrigger;    pTab->pTrigger = pTrig;    pTrig = 0;  }triggerfinish_cleanup:  sqlite3DeleteTrigger(pTrig);  assert( !pParse->pNewTrigger );  sqlite3DeleteTriggerStep(pStepList);}
开发者ID:DoktahWorm,项目名称:rhodes,代码行数:87,


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


示例22: codeTriggerProgram

/*** Generate VDBE code for zero or more statements inside the body of a** trigger.  */static int codeTriggerProgram(  Parse *pParse,            /* The parser context */  TriggerStep *pStepList,   /* List of statements inside the trigger body */  int orconfin              /* Conflict algorithm. (OE_Abort, etc) */  ){  TriggerStep * pTriggerStep = pStepList;  int orconf;  while( pTriggerStep ){    int saveNTab = pParse->nTab;     orconf = (orconfin == OE_Default)?pTriggerStep->orconf:orconfin;    pParse->trigStack->orconf = orconf;    switch( pTriggerStep->op ){      case TK_SELECT: {	Select * ss = sqlite3SelectDup(pTriggerStep->pSelect);		  	assert(ss);	assert(ss->pSrc);	sqlite3Select(pParse, ss, SRT_Discard, 0, 0, 0, 0, 0);	sqlite3SelectDelete(ss);	break;      }      case TK_UPDATE: {        SrcList *pSrc;        pSrc = targetSrcList(pParse, pTriggerStep);        sqlite3VdbeAddOp(pParse->pVdbe, OP_ResetCount, 0, 0);        sqlite3VdbeAddOp(pParse->pVdbe, OP_ListPush, 0, 0);        sqlite3Update(pParse, pSrc,		sqlite3ExprListDup(pTriggerStep->pExprList), 		sqlite3ExprDup(pTriggerStep->pWhere), orconf);        sqlite3VdbeAddOp(pParse->pVdbe, OP_ListPop, 0, 0);        sqlite3VdbeAddOp(pParse->pVdbe, OP_ResetCount, 1, 0);        break;      }      case TK_INSERT: {        SrcList *pSrc;        pSrc = targetSrcList(pParse, pTriggerStep);        sqlite3VdbeAddOp(pParse->pVdbe, OP_ResetCount, 0, 0);        sqlite3Insert(pParse, pSrc,          sqlite3ExprListDup(pTriggerStep->pExprList),           sqlite3SelectDup(pTriggerStep->pSelect),           sqlite3IdListDup(pTriggerStep->pIdList), orconf);        sqlite3VdbeAddOp(pParse->pVdbe, OP_ResetCount, 1, 0);        break;      }      case TK_DELETE: {        SrcList *pSrc;        sqlite3VdbeAddOp(pParse->pVdbe, OP_ResetCount, 0, 0);        sqlite3VdbeAddOp(pParse->pVdbe, OP_ListPush, 0, 0);        pSrc = targetSrcList(pParse, pTriggerStep);        sqlite3DeleteFrom(pParse, pSrc, sqlite3ExprDup(pTriggerStep->pWhere));        sqlite3VdbeAddOp(pParse->pVdbe, OP_ListPop, 0, 0);        sqlite3VdbeAddOp(pParse->pVdbe, OP_ResetCount, 1, 0);        break;      }      default:        assert(0);    }     pParse->nTab = saveNTab;    pTriggerStep = pTriggerStep->pNext;  }  return 0;}
开发者ID:open2cerp,项目名称:Open2C-ERP,代码行数:68,


示例23: sqlite3Update

//.........这里部分代码省略.........    goto update_cleanup;  }  /* Start the view context  */  if( isView ){    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);  }  /* Begin generating code.  */  v = sqlite3GetVdbe(pParse);  if( v==0 ) goto update_cleanup;  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);  sqlite3BeginWriteOperation(pParse, 1, pTab->iDb);  /* If we are trying to update a view, construct that view into  ** a temporary table.  */  if( isView ){    Select *pView;    pView = sqlite3SelectDup(pTab->pSelect);    sqlite3Select(pParse, pView, SRT_TempTable, iCur, 0, 0, 0, 0);    sqlite3SelectDelete(pView);  }  /* Begin the database scan  */  pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0);  if( pWInfo==0 ) goto update_cleanup;  /* Remember the index of every item to be updated.  */  sqlite3VdbeAddOp(v, OP_Recno, iCur, 0);  sqlite3VdbeAddOp(v, OP_ListWrite, 0, 0);  /* End the database scan loop.  */  sqlite3WhereEnd(pWInfo);  /* Initialize the count of updated rows  */  if( db->flags & SQLITE_CountRows && !pParse->trigStack ){    sqlite3VdbeAddOp(v, OP_Integer, 0, 0);  }  if( triggers_exist ){    /* Create pseudo-tables for NEW and OLD    */    sqlite3VdbeAddOp(v, OP_OpenPseudo, oldIdx, 0);    sqlite3VdbeAddOp(v, OP_SetNumColumns, oldIdx, pTab->nCol);    sqlite3VdbeAddOp(v, OP_OpenPseudo, newIdx, 0);    sqlite3VdbeAddOp(v, OP_SetNumColumns, newIdx, pTab->nCol);    /* The top of the update loop for when there are triggers.    */    sqlite3VdbeAddOp(v, OP_ListRewind, 0, 0);    addr = sqlite3VdbeAddOp(v, OP_ListRead, 0, 0);    sqlite3VdbeAddOp(v, OP_Dup, 0, 0);    /* Open a cursor and make it point to the record that is    ** being updated.    */    sqlite3VdbeAddOp(v, OP_Dup, 0, 0);    if( !isView ){      sqlite3OpenTableForReading(v, iCur, pTab);
开发者ID:BackupTheBerlios,项目名称:kslovar-svn,代码行数:67,


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


示例25: codeAttach

/*** This procedure generates VDBE code for a single invocation of either the** sqlite_detach() or sqlite_attach() SQL user functions.*/static void codeAttach(  Parse *pParse,       /* The parser context */  int type,            /* Either SQLITE_ATTACH or SQLITE_DETACH */  const char *zFunc,   /* Either "sqlite_attach" or "sqlite_detach */  int nFunc,           /* Number of args to pass to zFunc */  Expr *pAuthArg,      /* Expression to pass to authorization callback */  Expr *pFilename,     /* Name of database file */  Expr *pDbname,       /* Name of the database to use internally */  Expr *pKey           /* Database key for encryption extension */){  int rc;  NameContext sName;  Vdbe *v;  FuncDef *pFunc;  sqlite3* db = pParse->db;#ifndef SQLITE_OMIT_AUTHORIZATION  assert( sqlite3ThreadDataReadOnly()->mallocFailed || pAuthArg );  if( pAuthArg ){    char *zAuthArg = sqlite3NameFromToken(&pAuthArg->span);    if( !zAuthArg ){      goto attach_end;    }    rc = sqlite3AuthCheck(pParse, type, zAuthArg, 0, 0);    sqliteFree(zAuthArg);    if(rc!=SQLITE_OK ){      goto attach_end;    }  }#endif /* SQLITE_OMIT_AUTHORIZATION */  memset(&sName, 0, sizeof(NameContext));  sName.pParse = pParse;  if(       SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) ||      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) ||      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey))  ){    pParse->nErr++;    goto attach_end;  }  v = sqlite3GetVdbe(pParse);  sqlite3ExprCode(pParse, pFilename);  sqlite3ExprCode(pParse, pDbname);  sqlite3ExprCode(pParse, pKey);  assert(v || sqlite3ThreadDataReadOnly()->mallocFailed);  if( v ){    sqlite3VdbeAddOp(v, OP_Function, 0, nFunc);    pFunc = sqlite3FindFunction(db, zFunc, strlen(zFunc), nFunc, SQLITE_UTF8,0);    sqlite3VdbeChangeP3(v, -1, (char *)pFunc, P3_FUNCDEF);    /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this    ** statement only). For DETACH, set it to false (expire all existing    ** statements).    */    sqlite3VdbeAddOp(v, OP_Expire, (type==SQLITE_ATTACH), 0);  }  attach_end:  sqlite3ExprDelete(pFilename);  sqlite3ExprDelete(pDbname);  sqlite3ExprDelete(pKey);}
开发者ID:MagicalTux,项目名称:nezumi,代码行数:70,


示例26: sqlite3CodeRowTrigger

/*** This is called to code FOR EACH ROW triggers.**** When the code that this function generates is executed, the following ** must be true:**** 1. No cursors may be open in the main database.  (But newIdx and oldIdx**    can be indices of cursors in temporary tables.  See below.)**** 2. If the triggers being coded are ON INSERT or ON UPDATE triggers, then**    a temporary vdbe cursor (index newIdx) must be open and pointing at**    a row containing values to be substituted for new.* expressions in the**    trigger program(s).**** 3. If the triggers being coded are ON DELETE or ON UPDATE triggers, then**    a temporary vdbe cursor (index oldIdx) must be open and pointing at**    a row containing values to be substituted for old.* expressions in the**    trigger program(s).***/int sqlite3CodeRowTrigger(  Parse *pParse,       /* Parse context */  int op,              /* One of TK_UPDATE, TK_INSERT, TK_DELETE */  ExprList *pChanges,  /* Changes list for any UPDATE OF triggers */  int tr_tm,           /* One of TK_BEFORE, TK_AFTER */  Table *pTab,         /* The table to code triggers from */  int newIdx,          /* The indice of the "new" row to access */  int oldIdx,          /* The indice of the "old" row to access */  int orconf,          /* ON CONFLICT policy */  int ignoreJump       /* Instruction to jump to for RAISE(IGNORE) */){  Trigger * pTrigger;  TriggerStack * pTriggerStack;  assert(op == TK_UPDATE || op == TK_INSERT || op == TK_DELETE);  assert(tr_tm == TK_BEFORE || tr_tm == TK_AFTER );  assert(newIdx != -1 || oldIdx != -1);  pTrigger = pTab->pTrigger;  while( pTrigger ){    int fire_this = 0;    /* determine whether we should code this trigger */    if( pTrigger->op == op && pTrigger->tr_tm == tr_tm &&         pTrigger->foreach == TK_ROW ){      fire_this = 1;      pTriggerStack = pParse->trigStack;      while( pTriggerStack ){        if( pTriggerStack->pTrigger == pTrigger ){	  fire_this = 0;	}        pTriggerStack = pTriggerStack->pNext;      }      if( op == TK_UPDATE && pTrigger->pColumns &&          !checkColumnOverLap(pTrigger->pColumns, pChanges) ){        fire_this = 0;      }    }    if( fire_this && (pTriggerStack = sqliteMalloc(sizeof(TriggerStack)))!=0 ){      int endTrigger;      SrcList dummyTablist;      Expr * whenExpr;      AuthContext sContext;      dummyTablist.nSrc = 0;      /* Push an entry on to the trigger stack */      pTriggerStack->pTrigger = pTrigger;      pTriggerStack->newIdx = newIdx;      pTriggerStack->oldIdx = oldIdx;      pTriggerStack->pTab = pTab;      pTriggerStack->pNext = pParse->trigStack;      pTriggerStack->ignoreJump = ignoreJump;      pParse->trigStack = pTriggerStack;      sqlite3AuthContextPush(pParse, &sContext, pTrigger->name);      /* code the WHEN clause */      endTrigger = sqlite3VdbeMakeLabel(pParse->pVdbe);      whenExpr = sqlite3ExprDup(pTrigger->pWhen);      if( sqlite3ExprResolveIds(pParse, &dummyTablist, 0, whenExpr) ){        pParse->trigStack = pParse->trigStack->pNext;        sqliteFree(pTriggerStack);        sqlite3ExprDelete(whenExpr);        return 1;      }      sqlite3ExprIfFalse(pParse, whenExpr, endTrigger, 1);      sqlite3ExprDelete(whenExpr);      sqlite3VdbeAddOp(pParse->pVdbe, OP_ContextPush, 0, 0);      codeTriggerProgram(pParse, pTrigger->step_list, orconf);       sqlite3VdbeAddOp(pParse->pVdbe, OP_ContextPop, 0, 0);      /* Pop the entry off the trigger stack */      pParse->trigStack = pParse->trigStack->pNext;      sqlite3AuthContextPop(&sContext);      sqliteFree(pTriggerStack);      sqlite3VdbeResolveLabel(pParse->pVdbe, endTrigger);//.........这里部分代码省略.........
开发者ID:open2cerp,项目名称:Open2C-ERP,代码行数:101,


示例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;        /* The table being constructed */  sqlite3 *db;        /* The database connection */  char *zModule;      /* The module name of the table: USING modulename */  Module *pMod = 0;  addArgumentToVtab(pParse);  pParse->sArg.z = 0;  /* Lookup the module name. */  pTab = pParse->pNewTable;  if( pTab==0 ) return;  db = pParse->db;  if( pTab->nModuleArg<1 ) return;  zModule = pTab->azModuleArg[0];  pMod = (Module *)sqlite3HashFind(&db->aModule, zModule, strlen(zModule));  pTab->pMod = pMod;    /* 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;    Vdbe *v;    /* Compute the complete text of the CREATE VIRTUAL TABLE statement */    if( pEnd ){      pParse->sNameToken.n = pEnd->z - pParse->sNameToken.z + pEnd->n;    }    zStmt = sqlite3MPrintf("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 top of the stack is the rootpage allocated by sqlite3StartTable().    ** This value is always 0 and is ignored, a virtual table does not have a    ** rootpage. The next entry on the stack is the rowid of the record    ** in the sqlite_master table.    */    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);    sqlite3NestedParse(pParse,      "UPDATE %Q.%s "         "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q "       "WHERE rowid=#1",      db->aDb[iDb].zName, SCHEMA_TABLE(iDb),      pTab->zName,      pTab->zName,      zStmt    );    sqliteFree(zStmt);    v = sqlite3GetVdbe(pParse);    sqlite3ChangeCookie(db, v, iDb);    sqlite3VdbeAddOp(v, OP_Expire, 0, 0);    zWhere = sqlite3MPrintf("name='%q'", pTab->zName);    sqlite3VdbeOp3(v, OP_ParseSchema, iDb, 1, zWhere, P3_DYNAMIC);    sqlite3VdbeOp3(v, OP_VCreate, iDb, 0, pTab->zName, strlen(pTab->zName) + 1);  }  /* If we are rereading the sqlite_master table create the in-memory  ** record of the table. If the module has already been registered,  ** also call the xConnect method here.  */  else {    Table *pOld;    Schema *pSchema = pTab->pSchema;    const char *zName = pTab->zName;    int nName = strlen(zName) + 1;    pOld = sqlite3HashInsert(&pSchema->tblHash, zName, nName, pTab);    if( pOld ){      assert( pTab==pOld );  /* Malloc must have failed inside HashInsert() */      return;    }    pSchema->db = pParse->db;    pParse->pNewTable = 0;  }}
开发者ID:Bracket-,项目名称:psp-ports,代码行数:87,



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


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