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

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

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

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

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

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


示例2: analyzeTable

/*** Generate code that will do an analysis of a single table in** a database.*/static void analyzeTable(Parse *pParse, Table *pTab){  int iDb;  int iStatCur;  assert( pTab!=0 );  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);  sqlite3BeginWriteOperation(pParse, 0, iDb);  iStatCur = pParse->nTab++;  openStatTable(pParse, iDb, iStatCur, pTab->zName);  analyzeOneTable(pParse, pTab, iStatCur, pParse->nMem);  loadAnalysis(pParse, iDb);}
开发者ID:GameLemur,项目名称:nebula-device3,代码行数:16,


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


示例4: analyzeDatabase

/*** Generate code that will do an analysis of an entire database*/static void analyzeDatabase(Parse *pParse, int iDb){  sqlite3 *db = pParse->db;  HashElem *k;  int iStatCur;  int iMem;  sqlite3BeginWriteOperation(pParse, 0, iDb);  iStatCur = pParse->nTab++;  openStatTable(pParse, iDb, iStatCur, 0);  iMem = pParse->nMem;  for(k=sqliteHashFirst(&db->aDb[iDb].tblHash);  k; k=sqliteHashNext(k)){    Table *pTab = (Table*)sqliteHashData(k);    analyzeOneTable(pParse, pTab, iStatCur, iMem);  }  loadAnalysis(pParse, iDb);}
开发者ID:stephen-hill,项目名称:musicCube,代码行数:19,


示例5: analyzeDatabase

/*** Generate code that will do an analysis of an entire database*/static void analyzeDatabase(Parse *pParse, int iDb){  sqlite3 *db = pParse->db;  Schema *pSchema = db->aDb[iDb].pSchema;    /* Schema of database iDb */  HashElem *k;  int iStatCur;  int iMem;  sqlite3BeginWriteOperation(pParse, 0, iDb);  iStatCur = pParse->nTab;  pParse->nTab += 2;  openStatTable(pParse, iDb, iStatCur, 0);  iMem = pParse->nMem+1;  for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){    Table *pTab = (Table*)sqliteHashData(k);    analyzeOneTable(pParse, pTab, iStatCur, iMem);  }  loadAnalysis(pParse, iDb);}
开发者ID:tantalor,项目名称:sqlite-3.7.3.p1,代码行数:21,


示例6: analyzeTable

/*** Generate code that will do an analysis of a single table in** a database.  If pOnlyIdx is not NULL then it is a single index** in pTab that should be analyzed.*/static void analyzeTable(Parse *pParse, Table *pTab, Index *pOnlyIdx){  int iDb;  int iStatCur;  assert( pTab!=0 );  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);  sqlite3BeginWriteOperation(pParse, 0, iDb);  iStatCur = pParse->nTab;  pParse->nTab += 2;  if( pOnlyIdx ){    openStatTable(pParse, iDb, iStatCur, pOnlyIdx->zName, "idx");  }else{    openStatTable(pParse, iDb, iStatCur, pTab->zName, "tbl");  }  analyzeOneTable(pParse, pTab, pOnlyIdx, iStatCur, pParse->nMem+1);  loadAnalysis(pParse, iDb);}
开发者ID:sunyangkobe,项目名称:db_research,代码行数:23,


示例7: sqlite3DeleteFrom

//.........这里部分代码省略.........    goto delete_from_cleanup;  }  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);  assert( iDb<db->nDb );  zDb = db->aDb[iDb].zName;  rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb);  assert( rcauth==SQLITE_OK || rcauth==SQLITE_DENY || rcauth==SQLITE_IGNORE );  if( rcauth==SQLITE_DENY ){    goto delete_from_cleanup;  }  assert(!isView || pTrigger);  /* Assign  cursor number to the table and all its indices.  */  assert( pTabList->nSrc==1 );  iCur = pTabList->a[0].iCursor = pParse->nTab++;  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){    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  ** a ephemeral table.  */#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)  if( isView ){    sqlite3MaterializeView(pParse, pTab, pWhere, iCur);  }#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);  }#ifndef SQLITE_OMIT_TRUNCATE_OPTIMIZATION  /* Special case: A DELETE without a WHERE clause deletes everything.  ** It is easier just to erase the whole table. Prior to version 3.6.5,  ** this optimization caused the row change count (the value returned by   ** API function sqlite3_count_changes) to be set incorrectly.  */
开发者ID:Mars-Wu,项目名称:djyos,代码行数:67,


示例8: sqlite3FinishTrigger

/* ** This routine is called after all of the trigger actions have been parsed ** in order to complete the process of building the trigger. */SQLITE_PRIVATE void sqlite3FinishTrigger(                                         Parse *pParse,          /* Parser context */                                         TriggerStep *pStepList, /* The triggered program */                                         Token *pAll             /* Token that describes the complete CREATE TRIGGER */){    Trigger *pTrig = pParse->pNewTrigger;   /* Trigger being finished */    char *zName;                            /* Name of trigger */    sqlite3 *db = pParse->db;               /* The database */    DbFixer sFix;                           /* Fixer object */    int iDb;                                /* Database containing the trigger */    Token nameToken;                        /* Trigger name for error reporting */        pParse->pNewTrigger = 0;    if( NEVER(pParse->nErr) || !pTrig ) goto triggerfinish_cleanup;    zName = pTrig->zName;    iDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema);    pTrig->step_list = pStepList;    while( pStepList ){        pStepList->pTrig = pTrig;        pStepList = pStepList->pNext;    }    nameToken.z = pTrig->zName;    nameToken.n = sqlite3Strlen30(nameToken.z);    sqlite3FixInit(&sFix, pParse, iDb, "trigger", &nameToken);    if( sqlite3FixTriggerStep(&sFix, pTrig->step_list)       || sqlite3FixExpr(&sFix, pTrig->pWhen)       ){        goto triggerfinish_cleanup;    }        /* if we are not initializing,     ** build the sqlite_master entry     */    if( !db->init.busy ){        Vdbe *v;        char *z;                /* Make an entry in the sqlite_master table */        v = sqlite3GetVdbe(pParse);        if( v==0 ) goto triggerfinish_cleanup;        sqlite3BeginWriteOperation(pParse, 0, iDb);        z = sqlite3DbStrNDup(db, (char*)pAll->z, pAll->n);        sqlite3NestedParse(pParse,                           "INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')",                           db->aDb[iDb].zName, SCHEMA_TABLE(iDb), zName,                           pTrig->table, z);        sqlite3DbFree(db, z);        sqlite3ChangeCookie(pParse, iDb);        sqlite3VdbeAddParseSchemaOp(v, iDb,                                    sqlite3MPrintf(db, "type='trigger' AND name='%q'", zName));    }        if( db->init.busy ){        Trigger *pLink = pTrig;        Hash *pHash = &db->aDb[iDb].pSchema->trigHash;        assert( sqlite3SchemaMutexHeld(db, iDb, 0) );        pTrig = sqlite3HashInsert(pHash, zName, sqlite3Strlen30(zName), pTrig);        if( pTrig ){            db->mallocFailed = 1;        }else if( pLink->pSchema==pLink->pTabSchema ){            Table *pTab;            int n = sqlite3Strlen30(pLink->table);            pTab = sqlite3HashFind(&pLink->pTabSchema->tblHash, pLink->table, n);            assert( pTab!=0 );            pLink->pNext = pTab->pTrigger;            pTab->pTrigger = pLink;        }    }    triggerfinish_cleanup:    sqlite3DeleteTrigger(db, pTrig);    assert( !pParse->pNewTrigger );    sqlite3DeleteTriggerStep(db, pStepList);}
开发者ID:pchernev,项目名称:Objective-C-iOS-Categories,代码行数:78,


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


示例10: sqlite3AlterBeginAddColumn

/*** This function is called by the parser after the table-name in** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument ** pSrc is the full-name of the table being altered.**** This routine makes a (partial) copy of the Table structure** for the table being altered and sets Parse.pNewTable to point** to it. Routines called by the parser as the column definition** is parsed (i.e. sqlite3AddColumn()) add the new Column data to ** the copy. The copy of the Table structure is deleted by tokenize.c ** after parsing is finished.**** Routine sqlite3AlterFinishAddColumn() will be called to complete** coding the "ALTER TABLE ... ADD" statement.*/void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){  Table *pNew;  Table *pTab;  Vdbe *v;  int iDb;  int i;  int nAlloc;  /* Look up the table being altered. */  assert( pParse->pNewTable==0 );  if( sqlite3MallocFailed() ) goto exit_begin_add_column;  pTab = sqlite3LocateTable(pParse, pSrc->a[0].zName, pSrc->a[0].zDatabase);  if( !pTab ) goto exit_begin_add_column;#ifndef SQLITE_OMIT_VIRTUALTABLE  if( IsVirtual(pTab) ){    sqlite3ErrorMsg(pParse, "virtual tables may not be altered");    goto exit_begin_add_column;  }#endif  /* Make sure this is not an attempt to ALTER a view. */  if( pTab->pSelect ){    sqlite3ErrorMsg(pParse, "Cannot add a column to a view");    goto exit_begin_add_column;  }  assert( pTab->addColOffset>0 );  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);  /* Put a copy of the Table struct in Parse.pNewTable for the  ** sqlite3AddColumn() function and friends to modify.  */  pNew = (Table *)sqliteMalloc(sizeof(Table));  if( !pNew ) goto exit_begin_add_column;  pParse->pNewTable = pNew;  pNew->nRef = 1;  pNew->nCol = pTab->nCol;  assert( pNew->nCol>0 );  nAlloc = (((pNew->nCol-1)/8)*8)+8;  assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );  pNew->aCol = (Column *)sqliteMalloc(sizeof(Column)*nAlloc);  pNew->zName = sqliteStrDup(pTab->zName);  if( !pNew->aCol || !pNew->zName ){    goto exit_begin_add_column;  }  memcpy(pNew->aCol, pTab->aCol, sizeof(Column)*pNew->nCol);  for(i=0; i<pNew->nCol; i++){    Column *pCol = &pNew->aCol[i];    pCol->zName = sqliteStrDup(pCol->zName);    pCol->zColl = 0;    pCol->zType = 0;    pCol->pDflt = 0;  }  pNew->pSchema = pParse->db->aDb[iDb].pSchema;  pNew->addColOffset = pTab->addColOffset;  pNew->nRef = 1;  /* Begin a transaction and increment the schema cookie.  */  sqlite3BeginWriteOperation(pParse, 0, iDb);  v = sqlite3GetVdbe(pParse);  if( !v ) goto exit_begin_add_column;  sqlite3ChangeCookie(pParse->db, v, iDb);exit_begin_add_column:  sqlite3SrcListDelete(pSrc);  return;}
开发者ID:3rdexp,项目名称:jezzitest,代码行数:83,


示例11: 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 ){    Vdbe *v;    char *z;    /* Make an entry in the sqlite_master table */    v = sqlite3GetVdbe(pParse);    if( v==0 ) goto triggerfinish_cleanup;    sqlite3BeginWriteOperation(pParse, 0, iDb);    z = sqlite3DbStrNDup(db, (char*)pAll->z, pAll->n);    sqlite3NestedParse(pParse,       "INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')",       db->aDb[iDb].zName, SCHEMA_TABLE(iDb), pTrig->name,       pTrig->table, z);    sqlite3DbFree(db, z);    sqlite3ChangeCookie(pParse, iDb);    sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 0, 0, sqlite3MPrintf(        db, "type='trigger' AND name='%q'", pTrig->name), P4_DYNAMIC    );  }  if( db->init.busy ){    int n;    Table *pTab;    Trigger *pDel;    pDel = sqlite3HashInsert(&db->aDb[iDb].pSchema->trigHash,                      pTrig->name, sqlite3Strlen30(pTrig->name), pTrig);    if( pDel ){      assert( pDel==pTrig );      db->mallocFailed = 1;      goto triggerfinish_cleanup;    }    n = sqlite3Strlen30(pTrig->table) + 1;    pTab = sqlite3HashFind(&pTrig->pTabSchema->tblHash, pTrig->table, n);    assert( pTab!=0 );    pTrig->pNext = pTab->pTrigger;    pTab->pTrigger = pTrig;    pTrig = 0;  }triggerfinish_cleanup:  sqlite3DeleteTrigger(db, pTrig);  assert( !pParse->pNewTrigger );  sqlite3DeleteTriggerStep(db, pStepList);}
开发者ID:erik-knudsen,项目名称:eCos-enhancements,代码行数:75,


示例12: sqlite3AlterRenameTable

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


示例13: sqlite3Update

//.........这里部分代码省略.........    }else{      reg = 0;      for(i=0; i<pIdx->nColumn; i++){        if( aXRef[pIdx->aiColumn[i]]>=0 ){          reg = ++pParse->nMem;          break;        }      }    }    aRegIdx[j] = reg;  }  /* Allocate a block of register used to store the change record  ** sent to sqlite3GenerateConstraintChecks().  There are either  ** one or two registers for holding the rowid.  One rowid register  ** is used if chngRowid is false and two are used if chngRowid is  ** true.  Following these are pTab->nCol register holding column  ** data.  */  regOldRowid = regNewRowid = pParse->nMem + 1;  pParse->nMem += pTab->nCol + 1;  if( chngRowid ){    regNewRowid++;    pParse->nMem++;  }  regData = regNewRowid+1;   /* Begin generating code.  */  v = sqlite3GetVdbe(pParse);  if( v==0 ) goto update_cleanup;  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);  sqlite3BeginWriteOperation(pParse, 1, iDb);#ifndef SQLITE_OMIT_VIRTUALTABLE  /* Virtual tables must be handled separately */  if( IsVirtual(pTab) ){    updateVirtualTable(pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef,                       pWhere);    pWhere = 0;    pTabList = 0;    goto update_cleanup;  }#endif  /* Start the view context  */  if( isView ){    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);  }  /* Generate the code for triggers.  */  if( triggers_exist ){    int iGoto;    /* Create pseudo-tables for NEW and OLD    */    sqlite3VdbeAddOp2(v, OP_SetNumColumns, 0, pTab->nCol);    sqlite3VdbeAddOp2(v, OP_OpenPseudo, oldIdx, 0);    sqlite3VdbeAddOp2(v, OP_SetNumColumns, 0, pTab->nCol);    sqlite3VdbeAddOp2(v, OP_OpenPseudo, newIdx, 0);    iGoto = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0);    addr = sqlite3VdbeMakeLabel(v);
开发者ID:DoganA,项目名称:nightingale-deps,代码行数:67,


示例14: sqlite3AlterRenameTable

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


示例15: sqlite3Update

//.........这里部分代码省略.........  */  pTabList->a[0].colUsed = 0;  hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngKey);  /* There is one entry in the aRegIdx[] array for each index on the table  ** being updated.  Fill in aRegIdx[] with a register number that will hold  ** the key for accessing each index.  **  ** FIXME:  Be smarter about omitting indexes that use expressions.  */  for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){    int reg;    if( chngKey || hasFK || pIdx->pPartIdxWhere || pIdx==pPk ){      reg = ++pParse->nMem;    }else{      reg = 0;      for(i=0; i<pIdx->nKeyCol; i++){        i16 iIdxCol = pIdx->aiColumn[i];        if( iIdxCol<0 || aXRef[iIdxCol]>=0 ){          reg = ++pParse->nMem;          break;        }      }    }    if( reg==0 ) aToOpen[j+1] = 0;    aRegIdx[j] = reg;  }  /* Begin generating code. */  v = sqlite3GetVdbe(pParse);  if( v==0 ) goto update_cleanup;  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);  sqlite3BeginWriteOperation(pParse, 1, iDb);  /* Allocate required registers. */  if( !IsVirtual(pTab) ){    regRowSet = ++pParse->nMem;    regOldRowid = regNewRowid = ++pParse->nMem;    if( chngPk || pTrigger || hasFK ){      regOld = pParse->nMem + 1;      pParse->nMem += pTab->nCol;    }    if( chngKey || pTrigger || hasFK ){      regNewRowid = ++pParse->nMem;    }    regNew = pParse->nMem + 1;    pParse->nMem += pTab->nCol;  }  /* Start the view context. */  if( isView ){    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);  }  /* If we are trying to update a view, realize that view into  ** an ephemeral table.  */#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)  if( isView ){    sqlite3MaterializeView(pParse, pTab, pWhere, iDataCur);  }#endif  /* Resolve the column names in all the expressions in the  ** WHERE clause.
开发者ID:hoangdoanh,项目名称:sqlite,代码行数:67,


示例16: sqlite3AlterRenameTable

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


示例17: sqlite3Update

//.........这里部分代码省略.........      i = 0;    }else{      for(i=0; i<pIdx->nColumn; i++){        if( aXRef[pIdx->aiColumn[i]]>=0 ) break;      }    }    if( i<pIdx->nColumn ){      if( sqlite3CheckIndexCollSeq(pParse, pIdx) ) goto update_cleanup;      apIdx[nIdx++] = pIdx;      aIdxUsed[j] = 1;    }else{      aIdxUsed[j] = 0;    }  }  /* Resolve the column names in all the expressions in the  ** WHERE clause.  */  if( sqlite3ExprResolveNames(&sNC, pWhere) ){    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 ){
开发者ID:BackupTheBerlios,项目名称:kslovar-svn,代码行数:67,


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


示例19: sqlite3DeleteFrom

//.........这里部分代码省略.........    goto delete_from_cleanup;  }  /* Allocate a cursor used to store the old.* data for a trigger.  */  if( triggers_exist ){     oldIdx = pParse->nTab++;  }  /* Resolve the column names in the WHERE clause.  */  assert( pTabList->nSrc==1 );  iCur = pTabList->a[0].iCursor = pParse->nTab++;  memset(&sNC, 0, sizeof(sNC));  sNC.pParse = pParse;  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);
开发者ID:webmaster4world,项目名称:manual-indexing,代码行数:67,


示例20: sqlite3Update

//.........这里部分代码省略.........  for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){    int reg;    if( chngKey || hasFK>1 || pIdx==pPk     || indexWhereClauseMightChange(pIdx,aXRef,chngRowid)    ){      reg = ++pParse->nMem;      pParse->nMem += pIdx->nColumn;    }else{      reg = 0;      for(i=0; i<pIdx->nKeyCol; i++){        if( indexColumnIsBeingUpdated(pIdx, i, aXRef, chngRowid) ){          reg = ++pParse->nMem;          pParse->nMem += pIdx->nColumn;          if( onError==OE_Default && pIdx->onError==OE_Replace ){            bReplace = 1;          }          break;        }      }    }    if( reg==0 ) aToOpen[j+1] = 0;    aRegIdx[j] = reg;  }  if( bReplace ){    /* If REPLACE conflict resolution might be invoked, open cursors on all     ** indexes in case they are needed to delete records.  */    memset(aToOpen, 1, nIdx+1);  }  /* Begin generating code. */  v = sqlite3GetVdbe(pParse);  if( v==0 ) goto update_cleanup;  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);  sqlite3BeginWriteOperation(pParse, pTrigger || hasFK, iDb);  /* Allocate required registers. */  if( !IsVirtual(pTab) ){    regRowSet = ++pParse->nMem;    regOldRowid = regNewRowid = ++pParse->nMem;    if( chngPk || pTrigger || hasFK ){      regOld = pParse->nMem + 1;      pParse->nMem += pTab->nCol;    }    if( chngKey || pTrigger || hasFK ){      regNewRowid = ++pParse->nMem;    }    regNew = pParse->nMem + 1;    pParse->nMem += pTab->nCol;  }  /* Start the view context. */  if( isView ){    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);  }  /* If we are trying to update a view, realize that view into  ** an ephemeral table.  */#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)  if( isView ){    sqlite3MaterializeView(pParse, pTab,         pWhere, pOrderBy, pLimit, iDataCur    );    pOrderBy = 0;    pLimit = 0;  }
开发者ID:SCALE-GmbH,项目名称:sqlcipher,代码行数:67,


示例21: sqlite3AlterBeginAddColumn

/*** This function is called by the parser after the table-name in** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument ** pSrc is the full-name of the table being altered.**** This routine makes a (partial) copy of the Table structure** for the table being altered and sets Parse.pNewTable to point** to it. Routines called by the parser as the column definition** is parsed (i.e. sqlite3AddColumn()) add the new Column data to ** the copy. The copy of the Table structure is deleted by tokenize.c ** after parsing is finished.**** Routine sqlite3AlterFinishAddColumn() will be called to complete** coding the "ALTER TABLE ... ADD" statement.*/void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){  Table *pNew;  Table *pTab;  Vdbe *v;  int iDb;  int i;  int nAlloc;  sqlite3 *db = pParse->db;  /* Look up the table being altered. */  assert( pParse->pNewTable==0 );  assert( sqlite3BtreeHoldsAllMutexes(db) );  if( db->mallocFailed ) goto exit_begin_add_column;  pTab = sqlite3LocateTable(pParse, 0, pSrc->a[0].zName, pSrc->a[0].zDatabase);  if( !pTab ) goto exit_begin_add_column;#ifndef SQLITE_OMIT_VIRTUALTABLE  if( IsVirtual(pTab) ){    sqlite3ErrorMsg(pParse, "virtual tables may not be altered");    goto exit_begin_add_column;  }#endif  /* Make sure this is not an attempt to ALTER a view. */  if( pTab->pSelect ){    sqlite3ErrorMsg(pParse, "Cannot add a column to a view");    goto exit_begin_add_column;  }  assert( pTab->addColOffset>0 );  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);  /* Put a copy of the Table struct in Parse.pNewTable for the  ** sqlite3AddColumn() function and friends to modify.  But modify  ** the name by adding an "sqlite_altertab_" prefix.  By adding this  ** prefix, we insure that the name will not collide with an existing  ** table because user table are not allowed to have the "sqlite_"  ** prefix on their name.  */  pNew = (Table*)sqlite3DbMallocZero(db, sizeof(Table));  if( !pNew ) goto exit_begin_add_column;  pParse->pNewTable = pNew;  pNew->nRef = 1;  pNew->db = db;  pNew->nCol = pTab->nCol;  assert( pNew->nCol>0 );  nAlloc = (((pNew->nCol-1)/8)*8)+8;  assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );  pNew->aCol = (Column*)sqlite3DbMallocZero(db, sizeof(Column)*nAlloc);  pNew->zName = sqlite3MPrintf(db, "sqlite_altertab_%s", pTab->zName);  if( !pNew->aCol || !pNew->zName ){    db->mallocFailed = 1;    goto exit_begin_add_column;  }  memcpy(pNew->aCol, pTab->aCol, sizeof(Column)*pNew->nCol);  for(i=0; i<pNew->nCol; i++){    Column *pCol = &pNew->aCol[i];    pCol->zName = sqlite3DbStrDup(db, pCol->zName);    pCol->zColl = 0;    pCol->zType = 0;    pCol->pDflt = 0;  }  pNew->pSchema = db->aDb[iDb].pSchema;  pNew->addColOffset = pTab->addColOffset;  pNew->nRef = 1;  /* Begin a transaction and increment the schema cookie.  */  sqlite3BeginWriteOperation(pParse, 0, iDb);  v = sqlite3GetVdbe(pParse);  if( !v ) goto exit_begin_add_column;  sqlite3ChangeCookie(pParse, iDb);exit_begin_add_column:  sqlite3SrcListDelete(db, pSrc);  return;}
开发者ID:qiuping,项目名称:sqlcipher,代码行数:91,


示例22: sqlite3Update

//.........这里部分代码省略.........  hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngRowid);  /* Allocate memory for the array aRegIdx[].  There is one entry in the  ** array for each index associated with table being updated.  Fill in  ** the value with a register number for indices that are to be used  ** and with zero for unused indices.  */  for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}  if( nIdx>0 ){    aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx );    if( aRegIdx==0 ) goto update_cleanup;  }  for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){    int reg;    if( chngRowid ){      reg = ++pParse->nMem;    }else{      reg = 0;      for(i=0; i<pIdx->nColumn; i++){        if( aXRef[pIdx->aiColumn[i]]>=0 ){          reg = ++pParse->nMem;          break;        }      }    }    aRegIdx[j] = reg;  }  /* Begin generating code. */  v = sqlite3GetVdbe(pParse);  if( v==0 ) goto update_cleanup;  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);  sqlite3BeginWriteOperation(pParse, 1, iDb);#ifndef SQLITE_OMIT_VIRTUALTABLE  /* Virtual tables must be handled separately */  if( IsVirtual(pTab) ){    updateVirtualTable(pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef,                       pWhere);    pWhere = 0;    pTabList = 0;    goto update_cleanup;  }#endif  /* Allocate required registers. */  regOldRowid = regNewRowid = ++pParse->nMem;  if( pTrigger || hasFK ){    regOld = pParse->nMem + 1;    pParse->nMem += pTab->nCol;  }  if( chngRowid || pTrigger || hasFK ){    regNewRowid = ++pParse->nMem;  }  regNew = pParse->nMem + 1;  pParse->nMem += pTab->nCol;  regRec = ++pParse->nMem;  /* Start the view context. */  if( isView ){    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);  }  /* If we are trying to update a view, realize that view into  ** a ephemeral table.
开发者ID:Sheridan,项目名称:sqlite,代码行数:67,


示例23: sqlite3AlterRenameTable

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


示例24: sqlite3DeleteFrom

//.........这里部分代码省略.........  /* If pTab is really a view, make sure it has been initialized.  */  if( sqlite3ViewGetColumnNames(pParse, pTab) ){    goto delete_from_cleanup;  }  /* Allocate a cursor used to store the old.* data for a trigger.  */  if( triggers_exist ){     oldIdx = pParse->nTab++;  }  /* Assign  cursor number to the table and all its indices.  */  assert( pTabList->nSrc==1 );  iCur = pTabList->a[0].iCursor = pParse->nTab++;  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){    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, triggers_exist, iDb);  if( triggers_exist ){    int orconf = ((pParse->trigStack)?pParse->trigStack->orconf:OE_Default);    int iGoto = sqlite3VdbeAddOp0(v, OP_Goto);    addr = sqlite3VdbeMakeLabel(v);    iBeginBeforeTrigger = sqlite3VdbeCurrentAddr(v);    (void)sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TRIGGER_BEFORE, pTab,        -1, oldIdx, orconf, addr, &old_col_mask, 0);    iEndBeforeTrigger = sqlite3VdbeAddOp0(v, OP_Goto);    iBeginAfterTrigger = sqlite3VdbeCurrentAddr(v);    (void)sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TRIGGER_AFTER, pTab, -1,        oldIdx, orconf, addr, &old_col_mask, 0);    iEndAfterTrigger = sqlite3VdbeAddOp0(v, OP_Goto);    sqlite3VdbeJumpHere(v, iGoto);  }  /* If we are trying to delete from a view, realize that view into  ** a ephemeral table.  */#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)  if( isView ){    sqlite3MaterializeView(pParse, pTab, pWhere, iCur);  }#endif  /* Resolve the column names in the WHERE clause.  */  memset(&sNC, 0, sizeof(sNC));  sNC.pParse = pParse;
开发者ID:kfengbest,项目名称:GenericDB,代码行数: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: sqlite3Update

//.........这里部分代码省略.........        aXRef[j] = -1;      }    }#endif  }  hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngRowid);  for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}  if( nIdx>0 ){    aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx );    if( aRegIdx==0 ) goto update_cleanup;  }  for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){    int reg;    if( chngRowid ){      reg = ++pParse->nMem;    }else{      reg = 0;      for(i=0; i<pIdx->nColumn; i++){        if( aXRef[pIdx->aiColumn[i]]>=0 ){          reg = ++pParse->nMem;          break;        }      }    }    aRegIdx[j] = reg;  }    v = sqlite3GetVdbe(pParse);  if( v==0 ) goto update_cleanup;  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);  sqlite3BeginWriteOperation(pParse, 1, iDb);#ifndef SQLITE_OMIT_VIRTUALTABLE    if( IsVirtual(pTab) ){    updateVirtualTable(pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef,                       pWhere);    pWhere = 0;    pTabList = 0;    goto update_cleanup;  }#endif    regOldRowid = regNewRowid = ++pParse->nMem;  if( pTrigger || hasFK ){    regOld = pParse->nMem + 1;    pParse->nMem += pTab->nCol;  }  if( chngRowid || pTrigger || hasFK ){    regNewRowid = ++pParse->nMem;  }  regNew = pParse->nMem + 1;  pParse->nMem += pTab->nCol;    if( isView ){    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);  }#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)  if( isView ){    sqlite3MaterializeView(pParse, pTab, pWhere, iCur);
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:67,


示例27: sqlite3DeleteFrom

//.........这里部分代码省略.........    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);  }#ifndef SQLITE_OMIT_TRUNCATE_OPTIMIZATION  /* Special case: A DELETE without a WHERE clause deletes everything.  ** It is easier just to erase the whole table. Prior to version 3.6.5,  ** this optimization caused the row change count (the value returned by 
开发者ID:chinesemanbobo,项目名称:PPDemo,代码行数:67,


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



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


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