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

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

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

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

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

示例1: sqlite3DropTrigger

/*** This function is called to drop a trigger from the database schema. **** This may be called directly from the parser and therefore identifies** the trigger by name.  The sqlite3DropTriggerPtr() routine does the** same job as this routine except it takes a pointer to the trigger** instead of the trigger name.**/void sqlite3DropTrigger(Parse *pParse, SrcList *pName){  Trigger *pTrigger = 0;  int i;  const char *zDb;  const char *zName;  int nName;  sqlite *db = pParse->db;  if( sqlite3_malloc_failed ) goto drop_trigger_cleanup;  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){    goto drop_trigger_cleanup;  }  assert( pName->nSrc==1 );  zDb = pName->a[0].zDatabase;  zName = pName->a[0].zName;  nName = strlen(zName);  for(i=0; i<db->nDb; i++){    int j = (i<2) ? i^1 : i;  /* Search TEMP before MAIN */    if( zDb && sqlite3StrICmp(db->aDb[j].zName, zDb) ) continue;    pTrigger = sqlite3HashFind(&(db->aDb[j].trigHash), zName, nName+1);    if( pTrigger ) break;  }  if( !pTrigger ){    sqlite3ErrorMsg(pParse, "no such trigger: %S", pName, 0);    goto drop_trigger_cleanup;  }  sqlite3DropTriggerPtr(pParse, pTrigger, 0);drop_trigger_cleanup:  sqlite3SrcListDelete(pName);}
开发者ID:open2cerp,项目名称:Open2C-ERP,代码行数:40,


示例2: sqlite3DeleteFree

void sqlite3DeleteFree(Delete* deleteObj) {    if (deleteObj == NULL) { return; }    sqlite3SrcListDelete(deleteObj->pTabList);    sqlite3ExprDelete(deleteObj->pWhere);    sqlite3ExprDelete(deleteObj->pLimit);    sqlite3ExprDelete(deleteObj->pOffset);    sqliteFree(deleteObj);}
开发者ID:rannger,项目名称:Matrix,代码行数:9,


示例3: sqlite3DropTrigger

/*** This function is called to drop a trigger from the database schema.**** This may be called directly from the parser and therefore identifies** the trigger by name.  The sqlite3DropTriggerPtr() routine does the** same job as this routine except it takes a pointer to the trigger** instead of the trigger name.**/void sqlite3DropTrigger(Parse *pParse, SrcList *pName, int noErr){    Trigger *pTrigger = 0;    int i;    const char *zDb;    const char *zName;    int nName;    sqlite3 *db = pParse->db;    if (db->mallocFailed) goto drop_trigger_cleanup;    if (SQLITE_OK != sqlite3ReadSchema(pParse)){        goto drop_trigger_cleanup;    }    assert(pName->nSrc == 1);    zDb = pName->a[0].zDatabase;    zName = pName->a[0].zName;    nName = sqlite3Strlen30(zName);    assert(zDb != 0 || sqlite3BtreeHoldsAllMutexes(db));    for (i = OMIT_TEMPDB; i < db->nDb; i++){        int j = (i < 2) ? i ^ 1 : i;  /* Search TEMP before MAIN */        if (zDb && sqlite3StrICmp(db->aDb[j].zName, zDb)) continue;        assert(sqlite3SchemaMutexHeld(db, j, 0));        pTrigger = sqlite3HashFind(&(db->aDb[j].pSchema->trigHash), zName, nName);        if (pTrigger) break;    }    if (!pTrigger){        if (!noErr){            sqlite3ErrorMsg(pParse, "no such trigger: %S", pName, 0);        }        else{            sqlite3CodeVerifyNamedSchema(pParse, zDb);        }        pParse->checkSchema = 1;        goto drop_trigger_cleanup;    }    sqlite3DropTriggerPtr(pParse, pTrigger);drop_trigger_cleanup:    sqlite3SrcListDelete(db, pName);}
开发者ID:scott-zgeng,项目名称:thor,代码行数:48,


示例4: sqlite3Update

//.........这里部分代码省略.........    /* Compute new data for this record.      */    for(i=0; i<pTab->nCol; i++){      if( i==pTab->iPKey ){        sqlite3VdbeAddOp(v, OP_String8, 0, 0);        continue;      }      j = aXRef[i];      if( j<0 ){        sqlite3VdbeAddOp(v, OP_Column, iCur, i);        sqlite3ColumnDefault(v, pTab, i);      }else{        sqlite3ExprCode(pParse, pChanges->a[j].pExpr);      }    }    /* Do constraint checks    */    sqlite3GenerateConstraintChecks(pParse, pTab, iCur, aIdxUsed, chngRecno, 1,                                   onError, addr);    /* Delete the old indices for the current record.    */    sqlite3GenerateRowIndexDelete(db, v, pTab, iCur, aIdxUsed);    /* If changing the record number, delete the old record.    */    if( chngRecno ){      sqlite3VdbeAddOp(v, OP_Delete, iCur, 0);    }    /* Create the new index entries and the new record.    */    sqlite3CompleteInsertion(pParse, pTab, iCur, aIdxUsed, chngRecno, 1, -1);  }  /* Increment the row counter   */  if( db->flags & SQLITE_CountRows && !pParse->trigStack){    sqlite3VdbeAddOp(v, OP_AddImm, 1, 0);  }  /* If there are triggers, close all the cursors after each iteration  ** through the loop.  The fire the after triggers.  */  if( triggers_exist ){    if( !isView ){      for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){        if( openAll || aIdxUsed[i] )          sqlite3VdbeAddOp(v, OP_Close, iCur+i+1, 0);      }      sqlite3VdbeAddOp(v, OP_Close, iCur, 0);    }    if( sqlite3CodeRowTrigger(pParse, TK_UPDATE, pChanges, TRIGGER_AFTER, pTab,           newIdx, oldIdx, onError, addr) ){      goto update_cleanup;    }  }  /* Repeat the above with the next record to be updated, until  ** all record selected by the WHERE clause have been updated.  */  sqlite3VdbeAddOp(v, OP_Goto, 0, addr);  sqlite3VdbeChangeP2(v, addr, sqlite3VdbeCurrentAddr(v));  sqlite3VdbeAddOp(v, OP_ListReset, 0, 0);  /* Close all tables if there were no FOR EACH ROW triggers */  if( !triggers_exist ){    for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){      if( openAll || aIdxUsed[i] ){        sqlite3VdbeAddOp(v, OP_Close, iCur+i+1, 0);      }    }    sqlite3VdbeAddOp(v, OP_Close, iCur, 0);  }else{    sqlite3VdbeAddOp(v, OP_Close, newIdx, 0);    sqlite3VdbeAddOp(v, OP_Close, oldIdx, 0);  }  /*  ** Return the number of rows that were changed. If this routine is   ** generating code because of a call to sqlite3NestedParse(), do not  ** invoke the callback function.  */  if( db->flags & SQLITE_CountRows && !pParse->trigStack && pParse->nested==0 ){    sqlite3VdbeAddOp(v, OP_Callback, 1, 0);    sqlite3VdbeSetNumCols(v, 1);    sqlite3VdbeSetColName(v, 0, "rows updated", P3_STATIC);  }update_cleanup:  sqlite3AuthContextPop(&sContext);  sqliteFree(apIdx);  sqliteFree(aXRef);  sqlite3SrcListDelete(pTabList);  sqlite3ExprListDelete(pChanges);  sqlite3ExprDelete(pWhere);  return;}
开发者ID:BackupTheBerlios,项目名称:kslovar-svn,代码行数:101,


示例5: sqlite3Update

//.........这里部分代码省略.........        regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace);    /* Do FK constraint checks. */    if( hasFK ){      sqlite3FkCheck(pParse, pTab, regOldRowid, 0, aXRef, chngKey);    }    /* Delete the index entries associated with the current record.  */    if( bReplace || chngKey ){      if( pPk ){        addr1 = sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, 0, regKey, nKey);      }else{        addr1 = sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, 0, regOldRowid);      }      VdbeCoverageNeverTaken(v);    }    sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur, aRegIdx, -1);      /* If changing the record number, delete the old record.  */    if( hasFK || chngKey || pPk!=0 ){      sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, 0);    }    if( bReplace || chngKey ){      sqlite3VdbeJumpHere(v, addr1);    }    if( hasFK ){      sqlite3FkCheck(pParse, pTab, 0, regNewRowid, aXRef, chngKey);    }      /* Insert the new index entries and the new record. */    sqlite3CompleteInsertion(pParse, pTab, iDataCur, iIdxCur,                             regNewRowid, aRegIdx, 1, 0, 0);    /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to    ** handle rows (possibly in other tables) that refer via a foreign key    ** to the row just updated. */     if( hasFK ){      sqlite3FkActions(pParse, pTab, pChanges, regOldRowid, aXRef, chngKey);    }  }  /* Increment the row counter   */  if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab){    sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);  }  sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges,       TRIGGER_AFTER, pTab, regOldRowid, onError, labelContinue);  /* Repeat the above with the next record to be updated, until  ** all record selected by the WHERE clause have been updated.  */  if( okOnePass ){    /* Nothing to do at end-of-loop for a single-pass */  }else if( pPk ){    sqlite3VdbeResolveLabel(v, labelContinue);    sqlite3VdbeAddOp2(v, OP_Next, iEph, addrTop); VdbeCoverage(v);  }else{    sqlite3VdbeGoto(v, labelContinue);  }  sqlite3VdbeResolveLabel(v, labelBreak);  /* Close all tables */  for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){    assert( aRegIdx );    if( aToOpen[i+1] ){      sqlite3VdbeAddOp2(v, OP_Close, iIdxCur+i, 0);    }  }  if( iDataCur<iIdxCur ) sqlite3VdbeAddOp2(v, OP_Close, iDataCur, 0);  /* Update the sqlite_sequence table by storing the content of the  ** maximum rowid counter values recorded while inserting into  ** autoincrement tables.  */  if( pParse->nested==0 && pParse->pTriggerTab==0 ){    sqlite3AutoincrementEnd(pParse);  }  /*  ** Return the number of rows that were changed. If this routine is   ** generating code because of a call to sqlite3NestedParse(), do not  ** invoke the callback function.  */  if( (db->flags&SQLITE_CountRows) && !pParse->pTriggerTab && !pParse->nested ){    sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);    sqlite3VdbeSetNumCols(v, 1);    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC);  }update_cleanup:  sqlite3AuthContextPop(&sContext);  sqlite3DbFree(db, aXRef); /* Also frees aRegIdx[] and aToOpen[] */  sqlite3SrcListDelete(db, pTabList);  sqlite3ExprListDelete(db, pChanges);  sqlite3ExprDelete(db, pWhere);  return;}
开发者ID:hoangdoanh,项目名称:sqlite,代码行数:101,


示例6: sqlite3AlterRenameTable

//.........这里部分代码省略.........    sqlite3VdbeAddOp4(v, OP_String8, 0, i, 0, zName, 0);    sqlite3VdbeAddOp4(v, OP_VRename, i, 0, 0,(const char*)pVTab, P4_VTAB);    sqlite3MayAbort(pParse);  }#endif  /* figure out how many UTF-8 characters are in zName 算出在zName里有多少utf - 8字符*/  zTabName = pTab->zName;  nTabName = sqlite3Utf8CharLen(zTabName, -1);#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)  if( db->flags&SQLITE_ForeignKeys ){    /* If foreign-key support is enabled, rewrite the CREATE TABLE     ** statements corresponding to all child tables of foreign key constraints    ** for which the renamed table is the parent table.     如果启用了外键的支持,重写CREATE TABLE语句对应的所有子表的外键约束重命名表的父表。*/    if( (zWhere=whereForeignKeys(pParse, pTab))!=0 ){      sqlite3NestedParse(pParse,           "UPDATE /"%w/".%s SET "              "sql = sqlite_rename_parent(sql, %Q, %Q) "              "WHERE %s;", zDb, SCHEMA_TABLE(iDb), zTabName, zName, zWhere);      sqlite3DbFree(db, zWhere);    }  }#endif  /* Modify the sqlite_master table to use the new table name. 修改sqlite_master表来使用新的表名。*/  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) "            "ELSE name END "      "WHERE tbl_name=%Q COLLATE nocase AND "          "(type='table' OR type='index' OR type='trigger');",       zDb, SCHEMA_TABLE(iDb), zName, zName, zName, #ifndef SQLITE_OMIT_TRIGGER      zName,#endif      zName, nTabName, zTabName  );#ifndef SQLITE_OMIT_AUTOINCREMENT  /* If the sqlite_sequence table exists in this database, then update   ** it with the new table name.  如果sqlite_sequence表存在于这个数据库中,那么用新表的名称更新它  */  if( sqlite3FindTable(db, "sqlite_sequence", zDb) ){    sqlite3NestedParse(pParse,        "UPDATE /"%w/".sqlite_sequence set name = %Q WHERE name = %Q",        zDb, zName, pTab->zName);  }#endif#ifndef SQLITE_OMIT_TRIGGER  /* If there are TEMP triggers on this table, modify the sqlite_temp_master  ** table. Don't do this if the table being ALTERed is itself located in  ** the temp database.  如果在这个表上有临时触发器,修改sqlite_temp_master表,  如果表被修改本身就是位于临时数据库,不要做这些。  */  if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){    sqlite3NestedParse(pParse,         "UPDATE sqlite_temp_master SET "            "sql = sqlite_rename_trigger(sql, %Q), "            "tbl_name = %Q "            "WHERE %s;", zName, zName, zWhere);    sqlite3DbFree(db, zWhere);  }#endif#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)  if( db->flags&SQLITE_ForeignKeys ){    FKey *p;    for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){      Table *pFrom = p->pFrom;      if( pFrom!=pTab ){        reloadTableSchema(pParse, p->pFrom, pFrom->zName);      }    }  }#endif  /* Drop and reload the internal table schema. 删除和重新加载内部表模式。*/  reloadTableSchema(pParse, pTab, zName);exit_rename_table:  sqlite3SrcListDelete(db, pSrc);  sqlite3DbFree(db, zName);  db->flags = savedDbFlags;}
开发者ID:Guidachengong,项目名称:Sqlite3.07.14,代码行数:101,


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


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


示例9: sqlite3Update

//.........这里部分代码省略.........    ** some of the columns of the row being updated. Load the values for     ** all columns not modified by the update statement into their     ** registers in case this has happened.    */    for(i=0; i<pTab->nCol; i++){      if( aXRef[i]<0 && i!=pTab->iPKey ){        sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regNew+i);        sqlite3ColumnDefault(v, pTab, i, regNew+i);      }    }  }  if( !isView ){    int j1;                       /* Address of jump instruction */    /* Do constraint checks. */    sqlite3GenerateConstraintChecks(pParse, pTab, iCur, regNewRowid,        aRegIdx, (chngRowid?regOldRowid:0), 1, onError, addr, 0);    /* Do FK constraint checks. */    if( hasFK ){      sqlite3FkCheck(pParse, pTab, regOldRowid, 0);    }    /* Delete the index entries associated with the current record.  */    j1 = sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regOldRowid);    sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, aRegIdx);      /* If changing the record number, delete the old record.  */    if( hasFK || chngRowid ){      sqlite3VdbeAddOp2(v, OP_Delete, iCur, 0);    }    sqlite3VdbeJumpHere(v, j1);    if( hasFK ){      sqlite3FkCheck(pParse, pTab, 0, regNewRowid);    }      /* Insert the new index entries and the new record. */    sqlite3CompleteInsertion(pParse, pTab, iCur, regNewRowid, aRegIdx, 1, 0, 0);    /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to    ** handle rows (possibly in other tables) that refer via a foreign key    ** to the row just updated. */     if( hasFK ){      sqlite3FkActions(pParse, pTab, pChanges, regOldRowid);    }  }  /* Increment the row counter   */  if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab){    sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);  }  sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges,       TRIGGER_AFTER, pTab, regOldRowid, onError, addr);  /* Repeat the above with the next record to be updated, until  ** all record selected by the WHERE clause have been updated.  */  sqlite3VdbeAddOp2(v, OP_Goto, 0, addr);  sqlite3VdbeJumpHere(v, addr);  /* Close all tables */  for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){    if( openAll || aRegIdx[i]>0 ){      sqlite3VdbeAddOp2(v, OP_Close, iCur+i+1, 0);    }  }  sqlite3VdbeAddOp2(v, OP_Close, iCur, 0);  /* Update the sqlite_sequence table by storing the content of the  ** maximum rowid counter values recorded while inserting into  ** autoincrement tables.  */  if( pParse->nested==0 && pParse->pTriggerTab==0 ){    sqlite3AutoincrementEnd(pParse);  }  /*  ** Return the number of rows that were changed. If this routine is   ** generating code because of a call to sqlite3NestedParse(), do not  ** invoke the callback function.  */  if( (db->flags&SQLITE_CountRows) && !pParse->pTriggerTab && !pParse->nested ){    sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);    sqlite3VdbeSetNumCols(v, 1);    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC);  }update_cleanup:  sqlite3AuthContextPop(&sContext);  sqlite3DbFree(db, aRegIdx);  sqlite3DbFree(db, aXRef);  sqlite3SrcListDelete(db, pTabList);  sqlite3ExprListDelete(db, pChanges);  sqlite3ExprDelete(db, pWhere);  return;}
开发者ID:Sheridan,项目名称:sqlite,代码行数:101,


示例10: sqlite3AlterRenameTable

//.........这里部分代码省略.........  /* 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,        "UPDATE %Q.sqlite_sequence set name = %Q WHERE name = %Q",        zDb, zName, pTab->zName);  }#endif#ifndef SQLITE_OMIT_TRIGGER  /* If there are TEMP triggers on this table, modify the sqlite_temp_master  ** table. Don't do this if the table being ALTERed is itself located in  ** the temp database.  */  if( (zWhere=whereTempTriggers(pParse, pTab)) ){    sqlite3NestedParse(pParse,         "UPDATE sqlite_temp_master SET "            "sql = sqlite_rename_trigger(sql, %Q), "            "tbl_name = %Q "            "WHERE %s;", zName, zName, zWhere);    sqliteFree(zWhere);  }#endif  /* Drop and reload the internal table schema. */  reloadTableSchema(pParse, pTab, zName);exit_rename_table:  sqlite3SrcListDelete(pSrc);  sqliteFree(zName);}
开发者ID:stephen-hill,项目名称:musicCube,代码行数:101,


示例11: sqlite3Update

//.........这里部分代码省略.........    ** will be after the update. (The old record number is currently    ** on top of the stack.)    */    if( chngRowid ){      sqlite3ExprCode(pParse, pRowidExpr, regNewRowid);      sqlite3VdbeAddOp1(v, OP_MustBeInt, regNewRowid);    }    /* Compute new data for this record.      */    for(i=0; i<pTab->nCol; i++){      if( i==pTab->iPKey ){        sqlite3VdbeAddOp2(v, OP_Null, 0, regData+i);        continue;      }      j = aXRef[i];      if( j<0 ){        sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regData+i);        sqlite3ColumnDefault(v, pTab, i);      }else{        sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regData+i);      }    }    /* Do constraint checks    */    sqlite3GenerateConstraintChecks(pParse, pTab, iCur, regNewRowid,                                    aRegIdx, chngRowid, 1,                                    onError, addr);    /* Delete the old indices for the current record.    */    j1 = sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regOldRowid);    sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, aRegIdx);    /* If changing the record number, delete the old record.    */    if( chngRowid ){      sqlite3VdbeAddOp2(v, OP_Delete, iCur, 0);    }    sqlite3VdbeJumpHere(v, j1);    /* Create the new index entries and the new record.    */    sqlite3CompleteInsertion(pParse, pTab, iCur, regNewRowid,                              aRegIdx, 1, -1, 0);  }  /* Increment the row counter   */  if( db->flags & SQLITE_CountRows && !pParse->trigStack){    sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);  }  /* If there are triggers, close all the cursors after each iteration  ** through the loop.  The fire the after triggers.  */  if( triggers_exist ){    sqlite3VdbeAddOp2(v, OP_Goto, 0, iBeginAfterTrigger);    sqlite3VdbeJumpHere(v, iEndAfterTrigger);  }  /* Repeat the above with the next record to be updated, until  ** all record selected by the WHERE clause have been updated.  */  sqlite3VdbeAddOp2(v, OP_Goto, 0, addr);  sqlite3VdbeJumpHere(v, addr);  /* Close all tables */  for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){    if( openAll || aRegIdx[i]>0 ){      sqlite3VdbeAddOp2(v, OP_Close, iCur+i+1, 0);    }  }  sqlite3VdbeAddOp2(v, OP_Close, iCur, 0);  if( triggers_exist ){    sqlite3VdbeAddOp2(v, OP_Close, newIdx, 0);    sqlite3VdbeAddOp2(v, OP_Close, oldIdx, 0);  }  /*  ** Return the number of rows that were changed. If this routine is   ** generating code because of a call to sqlite3NestedParse(), do not  ** invoke the callback function.  */  if( db->flags & SQLITE_CountRows && !pParse->trigStack && pParse->nested==0 ){    sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);    sqlite3VdbeSetNumCols(v, 1);    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC);  }update_cleanup:  sqlite3AuthContextPop(&sContext);  sqlite3DbFree(db, aRegIdx);  sqlite3DbFree(db, aXRef);  sqlite3SrcListDelete(db, pTabList);  sqlite3ExprListDelete(db, pChanges);  sqlite3ExprDelete(db, pWhere);  return;}
开发者ID:DoganA,项目名称:nightingale-deps,代码行数:101,


示例12: sqlite3FkCheck

//.........这里部分代码省略.........          sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iJump);        }        sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, -1);      }      continue;    }    assert( pFKey->nCol==1 || (aiFree && pIdx) );    if( aiFree ){      aiCol = aiFree;    }else{      iCol = pFKey->aCol[0].iFrom;      aiCol = &iCol;    }    for(i=0; i<pFKey->nCol; i++){      if( aiCol[i]==pTab->iPKey ){        aiCol[i] = -1;      }#ifndef SQLITE_OMIT_AUTHORIZATION      /* Request permission to read the parent key columns. If the       ** authorization callback returns SQLITE_IGNORE, behave as if any      ** values read from the parent table are NULL. */      if( db->xAuth ){        int rcauth;        char *zCol = pTo->aCol[pIdx ? pIdx->aiColumn[i] : pTo->iPKey].zName;        rcauth = sqlite3AuthReadCol(pParse, pTo->zName, zCol, iDb);        isIgnore = (rcauth==SQLITE_IGNORE);      }#endif    }    /* Take a shared-cache advisory read-lock on the parent table. Allocate     ** a cursor to use to search the unique index on the parent key columns     ** in the parent table.  */    sqlite3TableLock(pParse, iDb, pTo->tnum, 0, pTo->zName);    pParse->nTab++;    if( regOld!=0 ){      /* A row is being removed from the child table. Search for the parent.      ** If the parent does not exist, removing the child row resolves an       ** outstanding foreign key constraint violation. */      fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regOld, -1,isIgnore);    }    if( regNew!=0 ){      /* A row is being added to the child table. If a parent row cannot      ** be found, adding the child row has violated the FK constraint. */       fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regNew, +1,isIgnore);    }    sqlite3DbFree(db, aiFree);  }  /* Loop through all the foreign key constraints that refer to this table */  for(pFKey = sqlite3FkReferences(pTab); pFKey; pFKey=pFKey->pNextTo){    Index *pIdx = 0;              /* Foreign key index for pFKey */    SrcList *pSrc;    int *aiCol = 0;    if( !pFKey->isDeferred && !pParse->pToplevel && !pParse->isMultiWrite ){      assert( regOld==0 && regNew!=0 );      /* Inserting a single row into a parent table cannot cause an immediate      ** foreign key violation. So do nothing in this case.  */      continue;    }    if( locateFkeyIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ){      if( !isIgnoreErrors || db->mallocFailed ) return;      continue;    }    assert( aiCol || pFKey->nCol==1 );    /* Create a SrcList structure containing a single table (the table     ** the foreign key that refers to this table is attached to). This    ** is required for the sqlite3WhereXXX() interface.  */    pSrc = sqlite3SrcListAppend(db, 0, 0, 0);    if( pSrc ){      struct SrcList_item *pItem = pSrc->a;      pItem->pTab = pFKey->pFrom;      pItem->zName = pFKey->pFrom->zName;      pItem->pTab->nRef++;      pItem->iCursor = pParse->nTab++;        if( regNew!=0 ){        fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1);      }      if( regOld!=0 ){        /* If there is a RESTRICT action configured for the current operation        ** on the parent table of this FK, then throw an exception         ** immediately if the FK constraint is violated, even if this is a        ** deferred trigger. That's what RESTRICT means. To defer checking        ** the constraint, the FK should specify NO ACTION (represented        ** using OE_None). NO ACTION is the default.  */        fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1);      }      pItem->zName = 0;      sqlite3SrcListDelete(db, pSrc);    }    sqlite3DbFree(db, aiCol);  }}
开发者ID:77songsong,项目名称:sqlite3,代码行数:101,


示例13: sqlite3Update

//.........这里部分代码省略.........    ** pre-update hook. If the caller invokes preupdate_new(), the returned    ** value is copied from memory cell (regNewRowid+1+iCol), where iCol    ** is the column index supplied by the user.    */    assert( regNew==regNewRowid+1 );#ifdef SQLITE_ENABLE_PREUPDATE_HOOK    sqlite3VdbeAddOp3(v, OP_Delete, iDataCur,        OPFLAG_ISUPDATE | ((hasFK>1 || chngKey) ? 0 : OPFLAG_ISNOOP),        regNewRowid    );    if( eOnePass==ONEPASS_MULTI ){      assert( hasFK==0 && chngKey==0 );      sqlite3VdbeChangeP5(v, OPFLAG_SAVEPOSITION);    }    if( !pParse->nested ){      sqlite3VdbeAppendP4(v, pTab, P4_TABLE);    }#else    if( hasFK>1 || chngKey ){      sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, 0);    }#endif    if( bReplace || chngKey ){      sqlite3VdbeJumpHere(v, addr1);    }    if( hasFK ){      sqlite3FkCheck(pParse, pTab, 0, regNewRowid, aXRef, chngKey);    }      /* Insert the new index entries and the new record. */    sqlite3CompleteInsertion(        pParse, pTab, iDataCur, iIdxCur, regNewRowid, aRegIdx,         OPFLAG_ISUPDATE | (eOnePass==ONEPASS_MULTI ? OPFLAG_SAVEPOSITION : 0),         0, 0    );    /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to    ** handle rows (possibly in other tables) that refer via a foreign key    ** to the row just updated. */     if( hasFK ){      sqlite3FkActions(pParse, pTab, pChanges, regOldRowid, aXRef, chngKey);    }  }  /* Increment the row counter   */  if( regRowCount ){    sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);  }  sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges,       TRIGGER_AFTER, pTab, regOldRowid, onError, labelContinue);  /* Repeat the above with the next record to be updated, until  ** all record selected by the WHERE clause have been updated.  */  if( eOnePass==ONEPASS_SINGLE ){    /* Nothing to do at end-of-loop for a single-pass */  }else if( eOnePass==ONEPASS_MULTI ){    sqlite3VdbeResolveLabel(v, labelContinue);    sqlite3WhereEnd(pWInfo);  }else if( pPk ){    sqlite3VdbeResolveLabel(v, labelContinue);    sqlite3VdbeAddOp2(v, OP_Next, iEph, addrTop); VdbeCoverage(v);  }else{    sqlite3VdbeGoto(v, labelContinue);  }  sqlite3VdbeResolveLabel(v, labelBreak);  /* Update the sqlite_sequence table by storing the content of the  ** maximum rowid counter values recorded while inserting into  ** autoincrement tables.  */  if( pParse->nested==0 && pParse->pTriggerTab==0 && pUpsert==0 ){    sqlite3AutoincrementEnd(pParse);  }  /*  ** Return the number of rows that were changed, if we are tracking  ** that information.  */  if( regRowCount ){    sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);    sqlite3VdbeSetNumCols(v, 1);    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC);  }update_cleanup:  sqlite3AuthContextPop(&sContext);  sqlite3DbFree(db, aXRef); /* Also frees aRegIdx[] and aToOpen[] */  sqlite3SrcListDelete(db, pTabList);  sqlite3ExprListDelete(db, pChanges);  sqlite3ExprDelete(db, pWhere);#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT)   sqlite3ExprListDelete(db, pOrderBy);  sqlite3ExprDelete(db, pLimit);#endif  return;}
开发者ID:SCALE-GmbH,项目名称:sqlcipher,代码行数:101,


示例14: sqlite3DeleteFrom

//.........这里部分代码省略.........    */    if( triggers_exist ){      sqlite3VdbeAddOp(v, OP_OpenPseudo, oldIdx, 0);      sqlite3VdbeAddOp(v, OP_SetNumColumns, oldIdx, pTab->nCol);    }    /* Delete every item whose key was written to the list during the    ** database scan.  We have to delete items after the scan is complete    ** because deleting an item can change the scan order.    */    sqlite3VdbeAddOp(v, OP_ListRewind, 0, 0);    end = sqlite3VdbeMakeLabel(v);    /* This is the beginning of the delete loop when there are    ** row triggers.    */    if( triggers_exist ){      addr = sqlite3VdbeAddOp(v, OP_ListRead, 0, end);      if( !isView ){        sqlite3VdbeAddOp(v, OP_Dup, 0, 0);        sqlite3OpenTableForReading(v, iCur, pTab);      }      sqlite3VdbeAddOp(v, OP_MoveGe, iCur, 0);      sqlite3VdbeAddOp(v, OP_Recno, iCur, 0);      sqlite3VdbeAddOp(v, OP_RowData, iCur, 0);      sqlite3VdbeAddOp(v, OP_PutIntKey, oldIdx, 0);      if( !isView ){        sqlite3VdbeAddOp(v, OP_Close, iCur, 0);      }      (void)sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TRIGGER_BEFORE, pTab,          -1, oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default,          addr);    }    if( !isView ){      /* Open cursors for the table we are deleting from and all its      ** indices.  If there are row triggers, this happens inside the      ** OP_ListRead loop because the cursor have to all be closed      ** before the trigger fires.  If there are no row triggers, the      ** cursors are opened only once on the outside the loop.      */      sqlite3OpenTableAndIndices(pParse, pTab, iCur, OP_OpenWrite);      /* This is the beginning of the delete loop when there are no      ** row triggers */      if( !triggers_exist ){         addr = sqlite3VdbeAddOp(v, OP_ListRead, 0, end);      }      /* Delete the row */      sqlite3GenerateRowDelete(db, v, pTab, iCur, pParse->nested==0);    }    /* If there are row triggers, close all cursors then invoke    ** the AFTER triggers    */    if( triggers_exist ){      if( !isView ){        for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){          sqlite3VdbeAddOp(v, OP_Close, iCur + i, pIdx->tnum);        }        sqlite3VdbeAddOp(v, OP_Close, iCur, 0);      }      (void)sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TRIGGER_AFTER, pTab, -1,          oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default,          addr);    }    /* End of the delete loop */    sqlite3VdbeAddOp(v, OP_Goto, 0, addr);    sqlite3VdbeResolveLabel(v, end);    sqlite3VdbeAddOp(v, OP_ListReset, 0, 0);    /* Close the cursors after the loop if there are no row triggers */    if( !triggers_exist ){      for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){        sqlite3VdbeAddOp(v, OP_Close, iCur + i, pIdx->tnum);      }      sqlite3VdbeAddOp(v, OP_Close, iCur, 0);    }  }  /*  ** Return the number of rows that were deleted. If this routine is   ** generating code because of a call to sqlite3NestedParse(), do not  ** invoke the callback function.  */  if( db->flags & SQLITE_CountRows && pParse->nested==0 && !pParse->trigStack ){    sqlite3VdbeAddOp(v, OP_Callback, 1, 0);    sqlite3VdbeSetNumCols(v, 1);    sqlite3VdbeSetColName(v, 0, "rows deleted", P3_STATIC);  }delete_from_cleanup:  sqlite3AuthContextPop(&sContext);  sqlite3SrcListDelete(pTabList);  sqlite3ExprDelete(pWhere);  return;}
开发者ID:webmaster4world,项目名称:manual-indexing,代码行数:101,


示例15: sqlite3AlterRenameTable

//.........这里部分代码省略.........  */#ifndef SQLITE_OMIT_VIRTUALTABLE  if( pVTab ){    int i = ++pParse->nMem;    sqlite3VdbeLoadString(v, i, zName);    sqlite3VdbeAddOp4(v, OP_VRename, i, 0, 0,(const char*)pVTab, P4_VTAB);    sqlite3MayAbort(pParse);  }#endif  /* figure out how many UTF-8 characters are in zName */  zTabName = pTab->zName;  nTabName = sqlite3Utf8CharLen(zTabName, -1);#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)  if( db->flags&SQLITE_ForeignKeys ){    /* If foreign-key support is enabled, rewrite the CREATE TABLE    ** statements corresponding to all child tables of foreign key constraints    ** for which the renamed table is the parent table.  */    if( (zWhere=whereForeignKeys(pParse, pTab))!=0 ){      sqlite3NestedParse(pParse,          "UPDATE /"%w/".%s SET "              "sql = sqlite_rename_parent(sql, %Q, %Q) "              "WHERE %s;", zDb, SCHEMA_TABLE(iDb), zTabName, zName, zWhere);      sqlite3DbFree(db, zWhere);    }  }#endif  /* 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) "            "ELSE name END "      "WHERE tbl_name=%Q COLLATE nocase AND "          "(type='table' OR type='index' OR type='trigger');",      zDb, SCHEMA_TABLE(iDb), zName, zName, zName,#ifndef SQLITE_OMIT_TRIGGER      zName,#endif      zName, nTabName, zTabName  );#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,        "UPDATE /"%w/".sqlite_sequence set name = %Q WHERE name = %Q",        zDb, zName, pTab->zName);  }#endif#ifndef SQLITE_OMIT_TRIGGER  /* If there are TEMP triggers on this table, modify the sqlite_temp_master  ** table. Don't do this if the table being ALTERed is itself located in  ** the temp database.  */  if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){    sqlite3NestedParse(pParse,        "UPDATE sqlite_temp_master SET "            "sql = sqlite_rename_trigger(sql, %Q), "            "tbl_name = %Q "            "WHERE %s;", zName, zName, zWhere);    sqlite3DbFree(db, zWhere);  }#endif#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)  if( db->flags&SQLITE_ForeignKeys ){    FKey *p;    for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){      Table *pFrom = p->pFrom;      if( pFrom!=pTab ){        reloadTableSchema(pParse, p->pFrom, pFrom->zName);      }    }  }#endif  /* Drop and reload the internal table schema. */  reloadTableSchema(pParse, pTab, zName);exit_rename_table:  sqlite3SrcListDelete(db, pSrc);  sqlite3DbFree(db, zName);  db->flags = savedDbFlags;}
开发者ID:arizwanp,项目名称:intel_sgx,代码行数:101,


示例16: sqlite3DeleteFrom

//.........这里部分代码省略.........    if( triggers_exist ){      sqlite3VdbeAddOp2(v, OP_SetNumColumns, 0, pTab->nCol);      sqlite3VdbeAddOp1(v, OP_OpenPseudo, oldIdx);    }    /* Delete every item whose key was written to the list during the    ** database scan.  We have to delete items after the scan is complete    ** because deleting an item can change the scan order.    */    end = sqlite3VdbeMakeLabel(v);    if( !isView ){      /* Open cursors for the table we are deleting from and       ** all its indices.      */      sqlite3OpenTableAndIndices(pParse, pTab, iCur, OP_OpenWrite);    }    /* This is the beginning of the delete loop. If a trigger encounters    ** an IGNORE constraint, it jumps back to here.    */    if( triggers_exist ){      sqlite3VdbeResolveLabel(v, addr);    }    addr = sqlite3VdbeAddOp3(v, OP_RowSetRead, iRowSet, end, iRowid);    if( triggers_exist ){      int iData = ++pParse->nMem;   /* For storing row data of OLD table */      /* If the record is no longer present in the table, jump to the      ** next iteration of the loop through the contents of the fifo.      */      sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, iRowid);      /* Populate the OLD.* pseudo-table */      if( old_col_mask ){        sqlite3VdbeAddOp2(v, OP_RowData, iCur, iData);      }else{        sqlite3VdbeAddOp2(v, OP_Null, 0, iData);      }      sqlite3VdbeAddOp3(v, OP_Insert, oldIdx, iData, iRowid);      /* Jump back and run the BEFORE triggers */      sqlite3VdbeAddOp2(v, OP_Goto, 0, iBeginBeforeTrigger);      sqlite3VdbeJumpHere(v, iEndBeforeTrigger);    }    if( !isView ){      /* Delete the row */#ifndef SQLITE_OMIT_VIRTUALTABLE      if( IsVirtual(pTab) ){        const char *pVtab = (const char *)pTab->pVtab;        sqlite3VtabMakeWritable(pParse, pTab);        sqlite3VdbeAddOp4(v, OP_VUpdate, 0, 1, iRowid, pVtab, P4_VTAB);      }else#endif      {        sqlite3GenerateRowDelete(pParse, pTab, iCur, iRowid, pParse->nested==0);      }    }    /* If there are row triggers, close all cursors then invoke    ** the AFTER triggers    */    if( triggers_exist ){      /* Jump back and run the AFTER triggers */      sqlite3VdbeAddOp2(v, OP_Goto, 0, iBeginAfterTrigger);      sqlite3VdbeJumpHere(v, iEndAfterTrigger);    }    /* End of the delete loop */    sqlite3VdbeAddOp2(v, OP_Goto, 0, addr);    sqlite3VdbeResolveLabel(v, end);    /* Close the cursors after the loop if there are no row triggers */    if( !isView  && !IsVirtual(pTab) ){      for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){        sqlite3VdbeAddOp2(v, OP_Close, iCur + i, pIdx->tnum);      }      sqlite3VdbeAddOp1(v, OP_Close, iCur);    }  }  /*  ** Return the number of rows that were deleted. If this routine is   ** generating code because of a call to sqlite3NestedParse(), do not  ** invoke the callback function.  */  if( db->flags & SQLITE_CountRows && pParse->nested==0 && !pParse->trigStack ){    sqlite3VdbeAddOp2(v, OP_ResultRow, memCnt, 1);    sqlite3VdbeSetNumCols(v, 1);    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows deleted", SQLITE_STATIC);  }delete_from_cleanup:  sqlite3AuthContextPop(&sContext);  sqlite3SrcListDelete(db, pTabList);  sqlite3ExprDelete(db, pWhere);  return;}
开发者ID:kfengbest,项目名称:GenericDB,代码行数:101,


示例17: sqlite3AlterRenameTable

//.........这里部分代码省略.........  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,      "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, nTabName, zTabName  );#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,        "UPDATE %Q.sqlite_sequence set name = %Q WHERE name = %Q",        zDb, zName, pTab->zName);  }#endif#ifndef SQLITE_OMIT_TRIGGER  /* If there are TEMP triggers on this table, modify the sqlite_temp_master  ** table. Don't do this if the table being ALTERed is itself located in  ** the temp database.  */  if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){    sqlite3NestedParse(pParse,         "UPDATE sqlite_temp_master SET "            "sql = sqlite_rename_trigger(sql, %Q), "            "tbl_name = %Q "            "WHERE %s;", zName, zName, zWhere);    sqliteFree(zWhere);  }#endif  /* Drop and reload the internal table schema. */  reloadTableSchema(pParse, pTab, zName);exit_rename_table:  sqlite3SrcListDelete(pSrc);  sqliteFree(zName);}
开发者ID:3rdexp,项目名称:jezzitest,代码行数:101,


示例18: sqlite3Update

//.........这里部分代码省略.........      j = aXRef[i];      if( j>=0 ){        sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i);      }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask&(1<<i)) ){        testcase( i==31 );        testcase( i==32 );        sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regNew+i);        sqlite3ColumnDefault(v, pTab, i, regNew+i);      }    }  }  if( tmask&TRIGGER_BEFORE ){    sqlite3VdbeAddOp2(v, OP_Affinity, regNew, pTab->nCol);    sqlite3TableAffinityStr(v, pTab);    sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges,         TRIGGER_BEFORE, pTab, regOldRowid, onError, addr);    sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid);    for(i=0; i<pTab->nCol; i++){      if( aXRef[i]<0 && i!=pTab->iPKey ){        sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regNew+i);        sqlite3ColumnDefault(v, pTab, i, regNew+i);      }    }  }  if( !isView ){    int j1;                               sqlite3GenerateConstraintChecks(pParse, pTab, iCur, regNewRowid,        aRegIdx, (chngRowid?regOldRowid:0), 1, onError, addr, 0);        if( hasFK ){      sqlite3FkCheck(pParse, pTab, regOldRowid, 0);    }        j1 = sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regOldRowid);    sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, aRegIdx);          if( hasFK || chngRowid ){      sqlite3VdbeAddOp2(v, OP_Delete, iCur, 0);    }    sqlite3VdbeJumpHere(v, j1);    if( hasFK ){      sqlite3FkCheck(pParse, pTab, 0, regNewRowid);    }          sqlite3CompleteInsertion(pParse, pTab, iCur, regNewRowid, aRegIdx, 1, 0, 0);     if( hasFK ){      sqlite3FkActions(pParse, pTab, pChanges, regOldRowid);    }  }  if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab){    sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);  }  sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges,       TRIGGER_AFTER, pTab, regOldRowid, onError, addr);  sqlite3VdbeAddOp2(v, OP_Goto, 0, addr);  sqlite3VdbeJumpHere(v, addr);    for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){    if( openAll || aRegIdx[i]>0 ){      sqlite3VdbeAddOp2(v, OP_Close, iCur+i+1, 0);    }  }  sqlite3VdbeAddOp2(v, OP_Close, iCur, 0);  if( pParse->nested==0 && pParse->pTriggerTab==0 ){    sqlite3AutoincrementEnd(pParse);  }  if( (db->flags&SQLITE_CountRows) && !pParse->pTriggerTab && !pParse->nested ){    sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);    sqlite3VdbeSetNumCols(v, 1);    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC);  }update_cleanup:  sqlite3AuthContextPop(&sContext);  sqlite3DbFree(db, aRegIdx);  sqlite3DbFree(db, aXRef);  sqlite3SrcListDelete(db, pTabList);  sqlite3ExprListDelete(db, pChanges);  sqlite3ExprDelete(db, pWhere);  return;}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:101,


示例19: sqlite3BeginTrigger

//.........这里部分代码省略.........  pTab = sqlite3SrcListLookup(pParse, pTableName);  if( pName2->n==0 && pTab && pTab->iDb==1 ){    iDb = 1;  }  /* Ensure the table name matches database name and that the table exists */  if( sqlite3_malloc_failed ) goto trigger_cleanup;  assert( pTableName->nSrc==1 );  if( sqlite3FixInit(&sFix, pParse, iDb, "trigger", pName) &&       sqlite3FixSrcList(&sFix, pTableName) ){    goto trigger_cleanup;  }  pTab = sqlite3SrcListLookup(pParse, pTableName);  if( !pTab ){    /* The table does not exist. */    goto trigger_cleanup;  }  /* Check that the trigger name is not reserved and that no trigger of the  ** specified name exists */  zName = sqlite3NameFromToken(pName);  if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){    goto trigger_cleanup;  }  if( sqlite3HashFind(&(db->aDb[iDb].trigHash), zName,pName->n+1) ){    sqlite3ErrorMsg(pParse, "trigger %T already exists", pName);    goto trigger_cleanup;  }  /* Do not create a trigger on a system table */  if( (iDb!=1 && sqlite3StrICmp(pTab->zName, MASTER_NAME)==0) ||       (iDb==1 && sqlite3StrICmp(pTab->zName, TEMP_MASTER_NAME)==0)   ){    sqlite3ErrorMsg(pParse, "cannot create trigger on system table");    pParse->nErr++;    goto trigger_cleanup;  }  /* INSTEAD of triggers are only for views and views only support INSTEAD  ** of triggers.  */  if( pTab->pSelect && tr_tm!=TK_INSTEAD ){    sqlite3ErrorMsg(pParse, "cannot create %s trigger on view: %S",         (tr_tm == TK_BEFORE)?"BEFORE":"AFTER", pTableName, 0);    goto trigger_cleanup;  }  if( !pTab->pSelect && tr_tm==TK_INSTEAD ){    sqlite3ErrorMsg(pParse, "cannot create INSTEAD OF"        " trigger on table: %S", pTableName, 0);    goto trigger_cleanup;  }#ifndef SQLITE_OMIT_AUTHORIZATION  {    int code = SQLITE_CREATE_TRIGGER;    const char *zDb = db->aDb[pTab->iDb].zName;    const char *zDbTrig = isTemp ? db->aDb[1].zName : zDb;    if( pTab->iDb==1 || isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER;    if( sqlite3AuthCheck(pParse, code, zName, pTab->zName, zDbTrig) ){      goto trigger_cleanup;    }    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(pTab->iDb), 0, zDb)){      goto trigger_cleanup;    }  }#endif  /* INSTEAD OF triggers can only appear on views and BEFORE triggers  ** cannot appear on views.  So we might as well translate every  ** INSTEAD OF trigger into a BEFORE trigger.  It simplifies code  ** elsewhere.  */  if (tr_tm == TK_INSTEAD){    tr_tm = TK_BEFORE;  }  /* Build the Trigger object */  pTrigger = (Trigger*)sqliteMalloc(sizeof(Trigger));  if( pTrigger==0 ) goto trigger_cleanup;  pTrigger->name = zName;  zName = 0;  pTrigger->table = sqliteStrDup(pTableName->a[0].zName);  if( sqlite3_malloc_failed ) goto trigger_cleanup;  pTrigger->iDb = iDb;  pTrigger->iTabDb = pTab->iDb;  pTrigger->op = op;  pTrigger->tr_tm = tr_tm;  pTrigger->pWhen = sqlite3ExprDup(pWhen);  pTrigger->pColumns = sqlite3IdListDup(pColumns);  pTrigger->foreach = foreach;  sqlite3TokenCopy(&pTrigger->nameToken,pName);  assert( pParse->pNewTrigger==0 );  pParse->pNewTrigger = pTrigger;trigger_cleanup:  sqliteFree(zName);  sqlite3SrcListDelete(pTableName);  sqlite3IdListDelete(pColumns);  sqlite3ExprDelete(pWhen);}
开发者ID:open2cerp,项目名称:Open2C-ERP,代码行数:101,


示例20: sqlite3BeginTrigger

//.........这里部分代码省略.........             */            db->init.orphanTrigger = 1;        }        goto trigger_cleanup;    }    if( IsVirtual(pTab) ){        sqlite3ErrorMsg(pParse, "cannot create triggers on virtual tables");        goto trigger_cleanup;    }        /* Check that the trigger name is not reserved and that no trigger of the     ** specified name exists */    zName = sqlite3NameFromToken(db, pName);    if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){        goto trigger_cleanup;    }    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );    if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),                        zName, sqlite3Strlen30(zName)) ){        if( !noErr ){            sqlite3ErrorMsg(pParse, "trigger %T already exists", pName);        }else{            assert( !db->init.busy );            sqlite3CodeVerifySchema(pParse, iDb);        }        goto trigger_cleanup;    }        /* Do not create a trigger on a system table */    if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){        sqlite3ErrorMsg(pParse, "cannot create trigger on system table");        pParse->nErr++;        goto trigger_cleanup;    }        /* INSTEAD of triggers are only for views and views only support INSTEAD     ** of triggers.     */    if( pTab->pSelect && tr_tm!=TK_INSTEAD ){        sqlite3ErrorMsg(pParse, "cannot create %s trigger on view: %S",                        (tr_tm == TK_BEFORE)?"BEFORE":"AFTER", pTableName, 0);        goto trigger_cleanup;    }    if( !pTab->pSelect && tr_tm==TK_INSTEAD ){        sqlite3ErrorMsg(pParse, "cannot create INSTEAD OF"                        " trigger on table: %S", pTableName, 0);        goto trigger_cleanup;    }    iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);    #ifndef SQLITE_OMIT_AUTHORIZATION    {        int code = SQLITE_CREATE_TRIGGER;        const char *zDb = db->aDb[iTabDb].zName;        const char *zDbTrig = isTemp ? db->aDb[1].zName : zDb;        if( iTabDb==1 || isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER;        if( sqlite3AuthCheck(pParse, code, zName, pTab->zName, zDbTrig) ){            goto trigger_cleanup;        }        if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iTabDb),0,zDb)){            goto trigger_cleanup;        }    }#endif        /* INSTEAD OF triggers can only appear on views and BEFORE triggers     ** cannot appear on views.  So we might as well translate every     ** INSTEAD OF trigger into a BEFORE trigger.  It simplifies code     ** elsewhere.     */    if (tr_tm == TK_INSTEAD){        tr_tm = TK_BEFORE;    }        /* Build the Trigger object */    pTrigger = (Trigger*)sqlite3DbMallocZero(db, sizeof(Trigger));    if( pTrigger==0 ) goto trigger_cleanup;    pTrigger->zName = zName;    zName = 0;    pTrigger->table = sqlite3DbStrDup(db, pTableName->a[0].zName);    pTrigger->pSchema = db->aDb[iDb].pSchema;    pTrigger->pTabSchema = pTab->pSchema;    pTrigger->op = (u8)op;    pTrigger->tr_tm = tr_tm==TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER;    pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);    pTrigger->pColumns = sqlite3IdListDup(db, pColumns);    assert( pParse->pNewTrigger==0 );    pParse->pNewTrigger = pTrigger;    trigger_cleanup:    sqlite3DbFree(db, zName);    sqlite3SrcListDelete(db, pTableName);    sqlite3IdListDelete(db, pColumns);    sqlite3ExprDelete(db, pWhen);    if( !pParse->pNewTrigger ){        sqlite3DeleteTrigger(db, pTrigger);    }else{        assert( pParse->pNewTrigger==pTrigger );    }}
开发者ID:pchernev,项目名称:Objective-C-iOS-Categories,代码行数:101,


示例21: sqlite3DeleteFrom

//.........这里部分代码省略.........        iAddrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);      }      testcase( IsVirtual(pTab) );      sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, OPFLAG_FORDELETE,                                 iTabCur, aToOpen, &iDataCur, &iIdxCur);      assert( pPk || IsVirtual(pTab) || iDataCur==iTabCur );      assert( pPk || IsVirtual(pTab) || iIdxCur==iDataCur+1 );      if( eOnePass==ONEPASS_MULTI ) sqlite3VdbeJumpHere(v, iAddrOnce);    }      /* Set up a loop over the rowids/primary-keys that were found in the    ** where-clause loop above.    */    if( eOnePass!=ONEPASS_OFF ){      assert( nKey==nPk );  /* OP_Found will use an unpacked key */      if( !IsVirtual(pTab) && aToOpen[iDataCur-iTabCur] ){        assert( pPk!=0 || pTab->pSelect!=0 );        sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, addrBypass, iKey, nKey);        VdbeCoverage(v);      }    }else if( pPk ){      addrLoop = sqlite3VdbeAddOp1(v, OP_Rewind, iEphCur); VdbeCoverage(v);      sqlite3VdbeAddOp2(v, OP_RowKey, iEphCur, iKey);      assert( nKey==0 );  /* OP_Found will use a composite key */    }else{      addrLoop = sqlite3VdbeAddOp3(v, OP_RowSetRead, iRowSet, 0, iKey);      VdbeCoverage(v);      assert( nKey==1 );    }        /* Delete the row */#ifndef SQLITE_OMIT_VIRTUALTABLE    if( IsVirtual(pTab) ){      const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);      sqlite3VtabMakeWritable(pParse, pTab);      sqlite3VdbeAddOp4(v, OP_VUpdate, 0, 1, iKey, pVTab, P4_VTAB);      sqlite3VdbeChangeP5(v, OE_Abort);      assert( eOnePass==ONEPASS_OFF || eOnePass==ONEPASS_SINGLE );      sqlite3MayAbort(pParse);      if( eOnePass==ONEPASS_SINGLE && sqlite3IsToplevel(pParse) ){        pParse->isMultiWrite = 0;      }    }else#endif    {      int count = (pParse->nested==0);    /* True to count changes */      int iIdxNoSeek = -1;      if( bComplex==0 && aiCurOnePass[1]!=iDataCur ){        iIdxNoSeek = aiCurOnePass[1];      }      sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,          iKey, nKey, count, OE_Default, eOnePass, iIdxNoSeek);    }      /* End of the loop over all rowids/primary-keys. */    if( eOnePass!=ONEPASS_OFF ){      sqlite3VdbeResolveLabel(v, addrBypass);      sqlite3WhereEnd(pWInfo);    }else if( pPk ){      sqlite3VdbeAddOp2(v, OP_Next, iEphCur, addrLoop+1); VdbeCoverage(v);      sqlite3VdbeJumpHere(v, addrLoop);    }else{      sqlite3VdbeGoto(v, addrLoop);      sqlite3VdbeJumpHere(v, addrLoop);    }           /* Close the cursors open on the table and its indexes. */    if( !isView && !IsVirtual(pTab) ){      if( !pPk ) sqlite3VdbeAddOp1(v, OP_Close, iDataCur);      for(i=0, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){        sqlite3VdbeAddOp1(v, OP_Close, iIdxCur + i);      }    }  } /* End non-truncate path */  /* Update the sqlite_sequence table by storing the content of the  ** maximum rowid counter values recorded while inserting into  ** autoincrement tables.  */  if( pParse->nested==0 && pParse->pTriggerTab==0 ){    sqlite3AutoincrementEnd(pParse);  }  /* Return the number of rows that were deleted. If this routine is   ** generating code because of a call to sqlite3NestedParse(), do not  ** invoke the callback function.  */  if( (db->flags&SQLITE_CountRows) && !pParse->nested && !pParse->pTriggerTab ){    sqlite3VdbeAddOp2(v, OP_ResultRow, memCnt, 1);    sqlite3VdbeSetNumCols(v, 1);    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows deleted", SQLITE_STATIC);  }delete_from_cleanup:  sqlite3AuthContextPop(&sContext);  sqlite3SrcListDelete(db, pTabList);  sqlite3ExprDelete(db, pWhere);  sqlite3DbFree(db, aToOpen);  return;}
开发者ID:chinesemanbobo,项目名称:PPDemo,代码行数:101,


示例22: sqlite3DeleteFrom

//.........这里部分代码省略.........   && 0==sqlite3FkRequired(pParse, pTab, 0, 0)  ){    assert( !isView );    sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt,                      pTab->zName, P4_STATIC);    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){      assert( pIdx->pSchema==pTab->pSchema );      sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);    }  }else#endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */  /* The usual case: There is a WHERE clause so we have to scan through  ** the table and pick which records to delete.  */  {    int iRowSet = ++pParse->nMem;   /* Register for rowset of rows to delete */    int iRowid = ++pParse->nMem;    /* Used for storing rowid values. */    int regRowid;                   /* Actual register containing rowids */    /* Collect rowids of every row to be deleted.    */    sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet);    pWInfo = sqlite3WhereBegin(        pParse, pTabList, pWhere, 0, 0, WHERE_DUPLICATES_OK, 0    );    if( pWInfo==0 ) goto delete_from_cleanup;    regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid, 0);    sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, regRowid);    if( db->flags & SQLITE_CountRows ){      sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);    }    sqlite3WhereEnd(pWInfo);    /* Delete every item whose key was written to the list during the    ** database scan.  We have to delete items after the scan is complete    ** because deleting an item can change the scan order.  */    end = sqlite3VdbeMakeLabel(v);    /* Unless this is a view, open cursors for the table we are     ** deleting from and all its indices. If this is a view, then the    ** only effect this statement has is to fire the INSTEAD OF     ** triggers.  */    if( !isView ){      sqlite3OpenTableAndIndices(pParse, pTab, iCur, OP_OpenWrite);    }    addr = sqlite3VdbeAddOp3(v, OP_RowSetRead, iRowSet, end, iRowid);    /* Delete the row */#ifndef SQLITE_OMIT_VIRTUALTABLE    if( IsVirtual(pTab) ){      const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);      sqlite3VtabMakeWritable(pParse, pTab);      sqlite3VdbeAddOp4(v, OP_VUpdate, 0, 1, iRowid, pVTab, P4_VTAB);      sqlite3VdbeChangeP5(v, OE_Abort);      sqlite3MayAbort(pParse);    }else#endif    {      int count = (pParse->nested==0);    /* True to count changes */      sqlite3GenerateRowDelete(pParse, pTab, iCur, iRowid, count, pTrigger, OE_Default);    }    /* End of the delete loop */    sqlite3VdbeAddOp2(v, OP_Goto, 0, addr);    sqlite3VdbeResolveLabel(v, end);    /* Close the cursors open on the table and its indexes. */    if( !isView && !IsVirtual(pTab) ){      for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){        sqlite3VdbeAddOp2(v, OP_Close, iCur + i, pIdx->tnum);      }      sqlite3VdbeAddOp1(v, OP_Close, iCur);    }  }  /* Update the sqlite_sequence table by storing the content of the  ** maximum rowid counter values recorded while inserting into  ** autoincrement tables.  */  if( pParse->nested==0 && pParse->pTriggerTab==0 ){    sqlite3AutoincrementEnd(pParse);  }  /* Return the number of rows that were deleted. If this routine is   ** generating code because of a call to sqlite3NestedParse(), do not  ** invoke the callback function.  */  if( (db->flags&SQLITE_CountRows) && !pParse->nested && !pParse->pTriggerTab ){    sqlite3VdbeAddOp2(v, OP_ResultRow, memCnt, 1);    sqlite3VdbeSetNumCols(v, 1);    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows deleted", SQLITE_STATIC);  }delete_from_cleanup:  sqlite3AuthContextPop(&sContext);  sqlite3SrcListDelete(db, pTabList);  sqlite3ExprDelete(db, pWhere);  return;}
开发者ID:Mars-Wu,项目名称:djyos,代码行数:101,



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


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