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

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

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

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

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

示例1: sqlite3MaterializeView

/*** Evaluate a view and store its result in an ephemeral table.  The** pWhere argument is an optional WHERE clause that restricts the** set of rows in the view that are to be added to the ephemeral table.*/void sqlite3MaterializeView(  Parse *pParse,       /* Parsing context */  Table *pView,        /* View definition */  Expr *pWhere,        /* Optional WHERE clause to be added */  int iCur             /* Cursor number for ephemerial table */){  SelectDest dest;  Select *pDup;  sqlite3 *db = pParse->db;  pDup = sqlite3SelectDup(db, pView->pSelect, 0);  if( pWhere ){    SrcList *pFrom;        pWhere = sqlite3ExprDup(db, pWhere, 0);    pFrom = sqlite3SrcListAppend(db, 0, 0, 0);    if( pFrom ){      assert( pFrom->nSrc==1 );      pFrom->a[0].zAlias = sqlite3DbStrDup(db, pView->zName);      pFrom->a[0].pSelect = pDup;      assert( pFrom->a[0].pOn==0 );      assert( pFrom->a[0].pUsing==0 );    }else{      sqlite3SelectDelete(db, pDup);    }    pDup = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0);    if( pDup ) pDup->selFlags |= SF_Materialize;  }  sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur);  sqlite3Select(pParse, pDup, &dest);  sqlite3SelectDelete(db, pDup);}
开发者ID:Mars-Wu,项目名称:djyos,代码行数:37,


示例2: algorithm

/*** Build a trigger step out of an INSERT statement.  Return a pointer** to the new trigger step.**** The parser calls this routine when it sees an INSERT inside the** body of a trigger.*/TriggerStep *sqlite3TriggerInsertStep(  sqlite3 *db,        /* The database connection */  Token *pTableName,  /* Name of the table into which we insert */  IdList *pColumn,    /* List of columns in pTableName to insert into */  ExprList *pEList,   /* The VALUE clause: a list of values to be inserted */  Select *pSelect,    /* A SELECT statement that supplies values */  int orconf          /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */){  TriggerStep *pTriggerStep;  assert(pEList == 0 || pSelect == 0);  assert(pEList != 0 || pSelect != 0 || db->mallocFailed);  pTriggerStep = (TriggerStep*)sqlite3DbMallocZero(db, sizeof(TriggerStep));  if( pTriggerStep ){    pTriggerStep->op = TK_INSERT;    pTriggerStep->pSelect = pSelect;    pTriggerStep->target  = *pTableName;    pTriggerStep->pIdList = pColumn;    pTriggerStep->pExprList = pEList;    pTriggerStep->orconf = orconf;    sqlitePersistTriggerStep(db, pTriggerStep);  }else{    sqlite3IdListDelete(pColumn);    sqlite3ExprListDelete(pEList);    sqlite3SelectDelete(pSelect);  }  return pTriggerStep;}
开发者ID:DoktahWorm,项目名称:rhodes,代码行数:37,


示例3: sqlitePersistTriggerStep

/*** Make a copy of all components of the given trigger step.  This has** the effect of copying all Expr.token.z values into memory obtained** from sqlite3_malloc().  As initially created, the Expr.token.z values** all point to the input string that was fed to the parser.  But that** string is ephemeral - it will go away as soon as the sqlite3_exec()** call that started the parser exits.  This routine makes a persistent** copy of all the Expr.token.z strings so that the TriggerStep structure** will be valid even after the sqlite3_exec() call returns.*/static void sqlitePersistTriggerStep(sqlite3 *db, TriggerStep *p){  if( p->target.z ){    p->target.z = (u8*)sqlite3DbStrNDup(db, (char*)p->target.z, p->target.n);    p->target.dyn = 1;  }  if( p->pSelect ){    Select *pNew = sqlite3SelectDup(db, p->pSelect);    sqlite3SelectDelete(db, p->pSelect);    p->pSelect = pNew;  }  if( p->pWhere ){    Expr *pNew = sqlite3ExprDup(db, p->pWhere);    sqlite3ExprDelete(db, p->pWhere);    p->pWhere = pNew;  }  if( p->pExprList ){    ExprList *pNew = sqlite3ExprListDup(db, p->pExprList);    sqlite3ExprListDelete(db, p->pExprList);    p->pExprList = pNew;  }  if( p->pIdList ){    IdList *pNew = sqlite3IdListDup(db, p->pIdList);    sqlite3IdListDelete(db, p->pIdList);    p->pIdList = pNew;  }}
开发者ID:erik-knudsen,项目名称:eCos-enhancements,代码行数:36,


示例4: algorithm

/* ** Build a trigger step out of an INSERT statement.  Return a pointer ** to the new trigger step. ** ** The parser calls this routine when it sees an INSERT inside the ** body of a trigger. */SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(                                                     sqlite3 *db,        /* The database connection */                                                     Token *pTableName,  /* Name of the table into which we insert */                                                     IdList *pColumn,    /* List of columns in pTableName to insert into */                                                     ExprList *pEList,   /* The VALUE clause: a list of values to be inserted */                                                     Select *pSelect,    /* A SELECT statement that supplies values */                                                     u8 orconf           /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */){    TriggerStep *pTriggerStep;        assert(pEList == 0 || pSelect == 0);    assert(pEList != 0 || pSelect != 0 || db->mallocFailed);        pTriggerStep = triggerStepAllocate(db, TK_INSERT, pTableName);    if( pTriggerStep ){        pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);        pTriggerStep->pIdList = pColumn;        pTriggerStep->pExprList = sqlite3ExprListDup(db, pEList, EXPRDUP_REDUCE);        pTriggerStep->orconf = orconf;    }else{        sqlite3IdListDelete(db, pColumn);    }    sqlite3ExprListDelete(db, pEList);    sqlite3SelectDelete(db, pSelect);        return pTriggerStep;}
开发者ID:pchernev,项目名称:Objective-C-iOS-Categories,代码行数:34,


示例5: sqlitePersistTriggerStep

/*** Make a copy of all components of the given trigger step.  This has** the effect of copying all Expr.token.z values into memory obtained** from sqliteMalloc().  As initially created, the Expr.token.z values** all point to the input string that was fed to the parser.  But that** string is ephemeral - it will go away as soon as the sqlite3_exec()** call that started the parser exits.  This routine makes a persistent** copy of all the Expr.token.z strings so that the TriggerStep structure** will be valid even after the sqlite3_exec() call returns.*/static void sqlitePersistTriggerStep(TriggerStep *p){  if( p->target.z ){    p->target.z = sqliteStrNDup(p->target.z, p->target.n);    p->target.dyn = 1;  }  if( p->pSelect ){    Select *pNew = sqlite3SelectDup(p->pSelect);    sqlite3SelectDelete(p->pSelect);    p->pSelect = pNew;  }  if( p->pWhere ){    Expr *pNew = sqlite3ExprDup(p->pWhere);    sqlite3ExprDelete(p->pWhere);    p->pWhere = pNew;  }  if( p->pExprList ){    ExprList *pNew = sqlite3ExprListDup(p->pExprList);    sqlite3ExprListDelete(p->pExprList);    p->pExprList = pNew;  }  if( p->pIdList ){    IdList *pNew = sqlite3IdListDup(p->pIdList);    sqlite3IdListDelete(p->pIdList);    p->pIdList = pNew;  }}
开发者ID:open2cerp,项目名称:Open2C-ERP,代码行数:36,


示例6: sqlite3MaterializeView

/*** Evaluate a view and store its result in an ephemeral table.  The** pWhere argument is an optional WHERE clause that restricts the** set of rows in the view that are to be added to the ephemeral table.*/void sqlite3MaterializeView(  Parse *pParse,       /* Parsing context */  Table *pView,        /* View definition */  Expr *pWhere,        /* Optional WHERE clause to be added */  int iCur             /* Cursor number for ephemerial table */){  SelectDest dest;  Select *pDup;  sqlite3 *db = pParse->db;  pDup = sqlite3SelectDup(db, pView->pSelect);  if( pWhere ){    SrcList *pFrom;    Token viewName;        pWhere = sqlite3ExprDup(db, pWhere);    viewName.z = (u8*)pView->zName;    viewName.n = (unsigned int)sqlite3Strlen30((const char*)viewName.z);    pFrom = sqlite3SrcListAppendFromTerm(pParse, 0, 0, 0, &viewName, pDup, 0,0);    pDup = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0);  }  sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur);  sqlite3Select(pParse, pDup, &dest);  sqlite3SelectDelete(db, pDup);}
开发者ID:kfengbest,项目名称:GenericDB,代码行数:30,


示例7: sqlite3MaterializeView

/*** Evaluate a view and store its result in an ephemeral table.  The** pWhere argument is an optional WHERE clause that restricts the** set of rows in the view that are to be added to the ephemeral table.*/void sqlite3MaterializeView(  Parse *pParse,       /* Parsing context */  Table *pView,        /* View definition */  Expr *pWhere,        /* Optional WHERE clause to be added */  int iCur             /* Cursor number for ephemeral table */){  SelectDest dest;  Select *pSel;  SrcList *pFrom;  sqlite3 *db = pParse->db;  int iDb = sqlite3SchemaToIndex(db, pView->pSchema);  pWhere = sqlite3ExprDup(db, pWhere, 0);  pFrom = sqlite3SrcListAppend(db, 0, 0, 0);  if( pFrom ){    assert( pFrom->nSrc==1 );    pFrom->a[0].zName = sqlite3DbStrDup(db, pView->zName);    pFrom->a[0].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zDbSName);    assert( pFrom->a[0].pOn==0 );    assert( pFrom->a[0].pUsing==0 );  }  pSel = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0,                           SF_IncludeHidden, 0, 0);  sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur);  sqlite3Select(pParse, pSel, &dest);  sqlite3SelectDelete(db, pSel);}
开发者ID:chinesemanbobo,项目名称:PPDemo,代码行数:31,


示例8: fkTriggerDelete

/*** The second argument is a Trigger structure allocated by the ** fkActionTrigger() routine. This function deletes the Trigger structure** and all of its sub-components.**** The Trigger structure or any of its sub-components may be allocated from** the lookaside buffer belonging to database handle dbMem.*/static void fkTriggerDelete(sqlite3 *dbMem, Trigger *p){  if( p ){    TriggerStep *pStep = p->step_list;    sqlite3ExprDelete(dbMem, pStep->pWhere);    sqlite3ExprListDelete(dbMem, pStep->pExprList);    sqlite3SelectDelete(dbMem, pStep->pSelect);    sqlite3ExprDelete(dbMem, p->pWhen);    sqlite3DbFree(dbMem, p);  }}
开发者ID:77songsong,项目名称:sqlite3,代码行数:18,


示例9: sqlite3DbMallocZero

/* ** Turn a SELECT statement (that the pSelect parameter points to) into ** a trigger step.  Return a pointer to a TriggerStep structure. ** ** The parser calls this routine when it finds a SELECT statement in ** body of a TRIGGER. */SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3 *db, Select *pSelect){    TriggerStep *pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep));    if( pTriggerStep==0 ) {        sqlite3SelectDelete(db, pSelect);        return 0;    }    pTriggerStep->op = TK_SELECT;    pTriggerStep->pSelect = pSelect;    pTriggerStep->orconf = OE_Default;    return pTriggerStep;}
开发者ID:pchernev,项目名称:Objective-C-iOS-Categories,代码行数:18,


示例10: sqlite3DeleteTriggerStep

/* ** Delete a linked list of TriggerStep structures. */SQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3 *db, TriggerStep *pTriggerStep){    while( pTriggerStep ){        TriggerStep * pTmp = pTriggerStep;        pTriggerStep = pTriggerStep->pNext;                sqlite3ExprDelete(db, pTmp->pWhere);        sqlite3ExprListDelete(db, pTmp->pExprList);        sqlite3SelectDelete(db, pTmp->pSelect);        sqlite3IdListDelete(db, pTmp->pIdList);                sqlite3DbFree(db, pTmp);    }}
开发者ID:pchernev,项目名称:Objective-C-iOS-Categories,代码行数:16,


示例11: sqliteMalloc

/*** Turn a SELECT statement (that the pSelect parameter points to) into** a trigger step.  Return a pointer to a TriggerStep structure.**** The parser calls this routine when it finds a SELECT statement in** body of a TRIGGER.  */TriggerStep *sqlite3TriggerSelectStep(Select *pSelect){  TriggerStep *pTriggerStep = sqliteMalloc(sizeof(TriggerStep));  if( pTriggerStep==0 ) {    sqlite3SelectDelete(pSelect);    return 0;  }  pTriggerStep->op = TK_SELECT;  pTriggerStep->pSelect = pSelect;  pTriggerStep->orconf = OE_Default;  sqlitePersistTriggerStep(pTriggerStep);  return pTriggerStep;}
开发者ID:Matrix0xCC,项目名称:lemon,代码行数:21,


示例12: sqlite3DeleteTriggerStep

/*** Delete a linked list of TriggerStep structures.*/void sqlite3DeleteTriggerStep(TriggerStep *pTriggerStep){  while( pTriggerStep ){    TriggerStep * pTmp = pTriggerStep;    pTriggerStep = pTriggerStep->pNext;    if( pTmp->target.dyn ) sqliteFree((char*)pTmp->target.z);    sqlite3ExprDelete(pTmp->pWhere);    sqlite3ExprListDelete(pTmp->pExprList);    sqlite3SelectDelete(pTmp->pSelect);    sqlite3IdListDelete(pTmp->pIdList);    sqliteFree(pTmp);  }}
开发者ID:open2cerp,项目名称:Open2C-ERP,代码行数:17,


示例13: sizeof

/*** Turn a SELECT statement (that the pSelect parameter points to) into** a trigger step.  Return a pointer to a TriggerStep structure.**** The parser calls this routine when it finds a SELECT statement in** body of a TRIGGER.  */TriggerStep *sqlite3TriggerSelectStep(sqlite3 *db, Select *pSelect){  TriggerStep *pTriggerStep = (TriggerStep*)sqlite3DbMallocZero(db, sizeof(TriggerStep));  if( pTriggerStep==0 ) {    sqlite3SelectDelete(pSelect);    return 0;  }  pTriggerStep->op = TK_SELECT;  pTriggerStep->pSelect = pSelect;  pTriggerStep->orconf = OE_Default;  sqlitePersistTriggerStep(db, pTriggerStep);  return pTriggerStep;}
开发者ID:DoktahWorm,项目名称:rhodes,代码行数:21,


示例14: sqlite3DbMallocZero

/*** Turn a SELECT statement (that the pSelect parameter points to) into** a trigger step.  Return a pointer to a TriggerStep structure.**** The parser calls this routine when it finds a SELECT statement in** body of a TRIGGER.  */TriggerStep *sqlite3TriggerSelectStep(  sqlite3 *db,                /* Database connection */  Select *pSelect,            /* The SELECT statement */  const char *zStart,         /* Start of SQL text */  const char *zEnd            /* End of SQL text */){  TriggerStep *pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep));  if( pTriggerStep==0 ) {    sqlite3SelectDelete(db, pSelect);    return 0;  }  pTriggerStep->op = TK_SELECT;  pTriggerStep->pSelect = pSelect;  pTriggerStep->orconf = OE_Default;  pTriggerStep->zSpan = triggerSpanDup(db, zStart, zEnd);  return pTriggerStep;}
开发者ID:cris-auts,项目名称:linux_c_study,代码行数:24,


示例15: sqlite3MaterializeView

/*** Evaluate a view and store its result in an ephemeral table.  The** pWhere argument is an optional WHERE clause that restricts the** set of rows in the view that are to be added to the ephemeral table.*/void sqlite3MaterializeView(  Parse *pParse,       /* Parsing context */  Select *pView,       /* View definition */  Expr *pWhere,        /* Optional WHERE clause to be added */  int iCur             /* Cursor number for ephemerial table */){  SelectDest dest;  Select *pDup;  sqlite3 *db = pParse->db;  pDup = sqlite3SelectDup(db, pView);  if( pWhere ){    SrcList *pFrom;        pWhere = sqlite3ExprDup(db, pWhere);    pFrom = sqlite3SrcListAppendFromTerm(pParse, 0, 0, 0, 0, pDup, 0, 0);    pDup = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0);  }  sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur);  sqlite3Select(pParse, pDup, &dest, 0, 0, 0);  sqlite3SelectDelete(db, pDup);}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:27,


示例16: algorithm

/*** Build a trigger step out of an INSERT statement.  Return a pointer** to the new trigger step.**** The parser calls this routine when it sees an INSERT inside the** body of a trigger.*/TriggerStep *sqlite3TriggerInsertStep(  Parse *pParse,      /* Parser */  Token *pTableName,  /* Name of the table into which we insert */  IdList *pColumn,    /* List of columns in pTableName to insert into */  Select *pSelect,    /* A SELECT statement that supplies values */  u8 orconf,          /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */  Upsert *pUpsert,    /* ON CONFLICT clauses for upsert */  const char *zStart, /* Start of SQL text */  const char *zEnd    /* End of SQL text */){  sqlite3 *db = pParse->db;  TriggerStep *pTriggerStep;  assert(pSelect != 0 || db->mallocFailed);  pTriggerStep = triggerStepAllocate(pParse, TK_INSERT, pTableName,zStart,zEnd);  if( pTriggerStep ){    if( IN_RENAME_OBJECT ){      pTriggerStep->pSelect = pSelect;      pSelect = 0;    }else{      pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);    }    pTriggerStep->pIdList = pColumn;    pTriggerStep->pUpsert = pUpsert;    pTriggerStep->orconf = orconf;  }else{    testcase( pColumn );    sqlite3IdListDelete(db, pColumn);    testcase( pUpsert );    sqlite3UpsertDelete(db, pUpsert);  }  sqlite3SelectDelete(db, pSelect);  return pTriggerStep;}
开发者ID:cris-auts,项目名称:linux_c_study,代码行数:43,


示例17: sqlite3DeleteFrom

//.........这里部分代码省略.........  /* 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);      sqlite3VdbeAddOp(v, OP_Next, iCur, addr);      sqlite3VdbeResolveLabel(v, endOfLoop);      sqlite3VdbeAddOp(v, OP_Close, iCur, 0);    }    if( !isView ){      sqlite3VdbeAddOp(v, OP_Clear, pTab->tnum, pTab->iDb);      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){        sqlite3VdbeAddOp(v, OP_Clear, pIdx->tnum, pIdx->iDb);
开发者ID:webmaster4world,项目名称:manual-indexing,代码行数:67,


示例18: sqlite3Update

//.........这里部分代码省略.........      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 ){    /* Create pseudo-tables for NEW and OLD    */    sqlite3VdbeAddOp(v, OP_OpenPseudo, oldIdx, 0);    sqlite3VdbeAddOp(v, OP_SetNumColumns, oldIdx, pTab->nCol);    sqlite3VdbeAddOp(v, OP_OpenPseudo, newIdx, 0);    sqlite3VdbeAddOp(v, OP_SetNumColumns, newIdx, pTab->nCol);    /* The top of the update loop for when there are triggers.    */
开发者ID:BackupTheBerlios,项目名称:kslovar-svn,代码行数:67,


示例19: IN

/*** Generate an expression tree to implement the WHERE, ORDER BY,** and LIMIT/OFFSET portion of DELETE and UPDATE statements.****     DELETE FROM table_wxyz WHERE a<5 ORDER BY a LIMIT 1;**                            /__________________________/**                               pLimitWhere (pInClause)*/Expr *sqlite3LimitWhere(  Parse *pParse,               /* The parser context */  SrcList *pSrc,               /* the FROM clause -- which tables to scan */  Expr *pWhere,                /* The WHERE clause.  May be null */  ExprList *pOrderBy,          /* The ORDER BY clause.  May be null */  Expr *pLimit,                /* The LIMIT clause.  May be null */  Expr *pOffset,               /* The OFFSET clause.  May be null */  char *zStmtType              /* Either DELETE or UPDATE.  For error messages. */){  Expr *pWhereRowid = NULL;    /* WHERE rowid .. */  Expr *pInClause = NULL;      /* WHERE rowid IN ( select ) */  Expr *pSelectRowid = NULL;   /* SELECT rowid ... */  ExprList *pEList = NULL;     /* Expression list contaning only pSelectRowid */  SrcList *pSelectSrc = NULL;  /* SELECT rowid FROM x ... (dup of pSrc) */  Select *pSelect = NULL;      /* Complete SELECT tree */  /* Check that there isn't an ORDER BY without a LIMIT clause.  */  if( pOrderBy && (pLimit == 0) ) {    sqlite3ErrorMsg(pParse, "ORDER BY without LIMIT on %s", zStmtType);    goto limit_where_cleanup_2;  }  /* We only need to generate a select expression if there  ** is a limit/offset term to enforce.  */  if( pLimit == 0 ) {    /* if pLimit is null, pOffset will always be null as well. */    assert( pOffset == 0 );    return pWhere;  }  /* Generate a select expression tree to enforce the limit/offset   ** term for the DELETE or UPDATE statement.  For example:  **   DELETE FROM table_a WHERE col1=1 ORDER BY col2 LIMIT 1 OFFSET 1  ** becomes:  **   DELETE FROM table_a WHERE rowid IN (   **     SELECT rowid FROM table_a WHERE col1=1 ORDER BY col2 LIMIT 1 OFFSET 1  **   );  */  pSelectRowid = sqlite3PExpr(pParse, TK_ROW, 0, 0, 0);  if( pSelectRowid == 0 ) goto limit_where_cleanup_2;  pEList = sqlite3ExprListAppend(pParse, 0, pSelectRowid);  if( pEList == 0 ) goto limit_where_cleanup_2;  /* duplicate the FROM clause as it is needed by both the DELETE/UPDATE tree  ** and the SELECT subtree. */  pSelectSrc = sqlite3SrcListDup(pParse->db, pSrc, 0);  if( pSelectSrc == 0 ) {    sqlite3ExprListDelete(pParse->db, pEList);    goto limit_where_cleanup_2;  }  /* generate the SELECT expression tree. */  pSelect = sqlite3SelectNew(pParse,pEList,pSelectSrc,pWhere,0,0,                             pOrderBy,0,pLimit,pOffset);  if( pSelect == 0 ) return 0;  /* now generate the new WHERE rowid IN clause for the DELETE/UDPATE */  pWhereRowid = sqlite3PExpr(pParse, TK_ROW, 0, 0, 0);  if( pWhereRowid == 0 ) goto limit_where_cleanup_1;  pInClause = sqlite3PExpr(pParse, TK_IN, pWhereRowid, 0, 0);  if( pInClause == 0 ) goto limit_where_cleanup_1;  pInClause->x.pSelect = pSelect;  pInClause->flags |= EP_xIsSelect;  sqlite3ExprSetHeight(pParse, pInClause);  return pInClause;  /* something went wrong. clean up anything allocated. */limit_where_cleanup_1:  sqlite3SelectDelete(pParse->db, pSelect);  return 0;limit_where_cleanup_2:  sqlite3ExprDelete(pParse->db, pWhere);  sqlite3ExprListDelete(pParse->db, pOrderBy);  sqlite3ExprDelete(pParse->db, pLimit);  sqlite3ExprDelete(pParse->db, pOffset);  return 0;}
开发者ID:Mars-Wu,项目名称:djyos,代码行数:90,


示例20: codeTriggerProgram

/* ** Generate VDBE code for the statements inside the body of a single ** trigger. */static int codeTriggerProgram(                              Parse *pParse,            /* The parser context */                              TriggerStep *pStepList,   /* List of statements inside the trigger body */                              int orconf                /* Conflict algorithm. (OE_Abort, etc) */){    TriggerStep *pStep;    Vdbe *v = pParse->pVdbe;    sqlite3 *db = pParse->db;        assert( pParse->pTriggerTab && pParse->pToplevel );    assert( pStepList );    assert( v!=0 );    for(pStep=pStepList; pStep; pStep=pStep->pNext){        /* Figure out the ON CONFLICT policy that will be used for this step         ** of the trigger program. If the statement that caused this trigger         ** to fire had an explicit ON CONFLICT, then use it. Otherwise, use         ** the ON CONFLICT policy that was specified as part of the trigger         ** step statement. Example:         **         **   CREATE TRIGGER AFTER INSERT ON t1 BEGIN;         **     INSERT OR REPLACE INTO t2 VALUES(new.a, new.b);         **   END;         **         **   INSERT INTO t1 ... ;            -- insert into t2 uses REPLACE policy         **   INSERT OR IGNORE INTO t1 ... ;  -- insert into t2 uses IGNORE policy         */        pParse->eOrconf = (orconf==OE_Default)?pStep->orconf:(u8)orconf;                /* Clear the cookieGoto flag. When coding triggers, the cookieGoto         ** variable is used as a flag to indicate to sqlite3ExprCodeConstants()         ** that it is not safe to refactor constants (this happens after the         ** start of the first loop in the SQL statement is coded - at that         ** point code may be conditionally executed, so it is no longer safe to         ** initialize constant register values).  */        assert( pParse->cookieGoto==0 || pParse->cookieGoto==-1 );        pParse->cookieGoto = 0;                switch( pStep->op ){            case TK_UPDATE: {                sqlite3Update(pParse,                              targetSrcList(pParse, pStep),                              sqlite3ExprListDup(db, pStep->pExprList, 0),                              sqlite3ExprDup(db, pStep->pWhere, 0),                              pParse->eOrconf                              );                break;            }            case TK_INSERT: {                sqlite3Insert(pParse,                              targetSrcList(pParse, pStep),                              sqlite3ExprListDup(db, pStep->pExprList, 0),                              sqlite3SelectDup(db, pStep->pSelect, 0),                              sqlite3IdListDup(db, pStep->pIdList),                              pParse->eOrconf                              );                break;            }            case TK_DELETE: {                sqlite3DeleteFrom(pParse,                                  targetSrcList(pParse, pStep),                                  sqlite3ExprDup(db, pStep->pWhere, 0)                                  );                break;            }            default: assert( pStep->op==TK_SELECT ); {                SelectDest sDest;                Select *pSelect = sqlite3SelectDup(db, pStep->pSelect, 0);                sqlite3SelectDestInit(&sDest, SRT_Discard, 0);                sqlite3Select(pParse, pSelect, &sDest);                sqlite3SelectDelete(db, pSelect);                break;            }        }        if( pStep->op!=TK_SELECT ){            sqlite3VdbeAddOp0(v, OP_ResetCount);        }    }        return 0;}
开发者ID:pchernev,项目名称:Objective-C-iOS-Categories,代码行数:84,


示例21: First

//.........这里部分代码省略.........          pNew = sqlite3PExpr(pParse, TK_DOT,             sqlite3PExpr(pParse, TK_ID, 0, 0, &tNew),            sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol)          , 0);        }else if( action==OE_SetDflt ){          Expr *pDflt = pFKey->pFrom->aCol[iFromCol].pDflt;          if( pDflt ){            pNew = sqlite3ExprDup(db, pDflt, 0);          }else{            pNew = sqlite3PExpr(pParse, TK_NULL, 0, 0, 0);          }        }else{          pNew = sqlite3PExpr(pParse, TK_NULL, 0, 0, 0);        }        pList = sqlite3ExprListAppend(pParse, pList, pNew);        sqlite3ExprListSetName(pParse, pList, &tFromCol, 0);      }    }    sqlite3DbFree(db, aiCol);    zFrom = pFKey->pFrom->zName;    nFrom = sqlite3Strlen30(zFrom);    if( action==OE_Restrict ){      Token tFrom;      Expr *pRaise;       tFrom.z = zFrom;      tFrom.n = nFrom;      pRaise = sqlite3Expr(db, TK_RAISE, "foreign key constraint failed");      if( pRaise ){        pRaise->affinity = OE_Abort;      }      pSelect = sqlite3SelectNew(pParse,           sqlite3ExprListAppend(pParse, 0, pRaise),          sqlite3SrcListAppend(db, 0, &tFrom, 0),          pWhere,          0, 0, 0, 0, 0, 0      );      pWhere = 0;    }    /* Disable lookaside memory allocation */    enableLookaside = db->lookaside.bEnabled;    db->lookaside.bEnabled = 0;    pTrigger = (Trigger *)sqlite3DbMallocZero(db,         sizeof(Trigger) +         /* struct Trigger */        sizeof(TriggerStep) +     /* Single step in trigger program */        nFrom + 1                 /* Space for pStep->target.z */    );    if( pTrigger ){      pStep = pTrigger->step_list = (TriggerStep *)&pTrigger[1];      pStep->target.z = (char *)&pStep[1];      pStep->target.n = nFrom;      memcpy((char *)pStep->target.z, zFrom, nFrom);        pStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);      pStep->pExprList = sqlite3ExprListDup(db, pList, EXPRDUP_REDUCE);      pStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);      if( pWhen ){        pWhen = sqlite3PExpr(pParse, TK_NOT, pWhen, 0, 0);        pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);      }    }    /* Re-enable the lookaside buffer, if it was disabled earlier. */    db->lookaside.bEnabled = enableLookaside;    sqlite3ExprDelete(db, pWhere);    sqlite3ExprDelete(db, pWhen);    sqlite3ExprListDelete(db, pList);    sqlite3SelectDelete(db, pSelect);    if( db->mallocFailed==1 ){      fkTriggerDelete(db, pTrigger);      return 0;    }    assert( pStep!=0 );    switch( action ){      case OE_Restrict:        pStep->op = TK_SELECT;         break;      case OE_Cascade:         if( !pChanges ){           pStep->op = TK_DELETE;           break;         }      default:        pStep->op = TK_UPDATE;    }    pStep->pTrig = pTrigger;    pTrigger->pSchema = pTab->pSchema;    pTrigger->pTabSchema = pTab->pSchema;    pFKey->apTrigger[iAction] = pTrigger;    pTrigger->op = (pChanges ? TK_UPDATE : TK_DELETE);  }  return pTrigger;}
开发者ID:77songsong,项目名称:sqlite3,代码行数:101,


示例22: codeTriggerProgram

/*** Generate VDBE code for the statements inside the body of a single ** trigger.*/static int codeTriggerProgram(  Parse *pParse,            /* The parser context */  TriggerStep *pStepList,   /* List of statements inside the trigger body */  int orconf                /* Conflict algorithm. (OE_Abort, etc) */  ){  TriggerStep *pStep;  Vdbe *v = pParse->pVdbe;  sqlite3 *db = pParse->db;  assert( pParse->pTriggerTab && pParse->pToplevel );  assert( pStepList );  assert( v!=0 );  for(pStep=pStepList; pStep; pStep=pStep->pNext){    /* Figure out the ON CONFLICT policy that will be used for this step    ** of the trigger program. If the statement that caused this trigger    ** to fire had an explicit ON CONFLICT, then use it. Otherwise, use    ** the ON CONFLICT policy that was specified as part of the trigger    ** step statement. Example:    **    **   CREATE TRIGGER AFTER INSERT ON t1 BEGIN;    **     INSERT OR REPLACE INTO t2 VALUES(new.a, new.b);    **   END;    **    **   INSERT INTO t1 ... ;            -- insert into t2 uses REPLACE policy    **   INSERT OR IGNORE INTO t1 ... ;  -- insert into t2 uses IGNORE policy    */    pParse->eOrconf = (orconf==OE_Default)?pStep->orconf:(u8)orconf;    assert( pParse->okConstFactor==0 );    switch( pStep->op ){      case TK_UPDATE: {        sqlite3Update(pParse,           targetSrcList(pParse, pStep),          sqlite3ExprListDup(db, pStep->pExprList, 0),           sqlite3ExprDup(db, pStep->pWhere, 0),           pParse->eOrconf        );        break;      }      case TK_INSERT: {        sqlite3Insert(pParse,           targetSrcList(pParse, pStep),          sqlite3SelectDup(db, pStep->pSelect, 0),           sqlite3IdListDup(db, pStep->pIdList),           pParse->eOrconf        );        break;      }      case TK_DELETE: {        sqlite3DeleteFrom(pParse,           targetSrcList(pParse, pStep),          sqlite3ExprDup(db, pStep->pWhere, 0)        );        break;      }      default: assert( pStep->op==TK_SELECT ); {        SelectDest sDest;        Select *pSelect = sqlite3SelectDup(db, pStep->pSelect, 0);        sqlite3SelectDestInit(&sDest, SRT_Discard, 0);        sqlite3Select(pParse, pSelect, &sDest);        sqlite3SelectDelete(db, pSelect);        break;      }    }     if( pStep->op!=TK_SELECT ){      sqlite3VdbeAddOp0(v, OP_ResetCount);    }  }  return 0;}
开发者ID:AchironOS,项目名称:chromium-2,代码行数:75,


示例23: codeTriggerProgram

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


示例24: updateVirtualTable

/*** Generate code for an UPDATE of a virtual table.**** The strategy is that we create an ephemerial table that contains** for each row to be changed:****   (A)  The original rowid of that row.**   (B)  The revised rowid for the row. (note1)**   (C)  The content of every column in the row.**** Then we loop over this ephemeral table and for each row in** the ephermeral table call VUpdate.**** When finished, drop the ephemeral table.**** (note1) Actually, if we know in advance that (A) is always the same** as (B) we only store (A), then duplicate (A) when pulling** it out of the ephemeral table before calling VUpdate.*/static void updateVirtualTable(  Parse *pParse,       /* The parsing context */  SrcList *pSrc,       /* The virtual table to be modified */  Table *pTab,         /* The virtual table */  ExprList *pChanges,  /* The columns to change in the UPDATE statement */  Expr *pRowid,        /* Expression used to recompute the rowid */  int *aXRef,          /* Mapping from columns of pTab to entries in pChanges */  Expr *pWhere         /* WHERE clause of the UPDATE statement */){  Vdbe *v = pParse->pVdbe;  /* Virtual machine under construction */  ExprList *pEList = 0;     /* The result set of the SELECT statement */  Select *pSelect = 0;      /* The SELECT statement */  Expr *pExpr;              /* Temporary expression */  int ephemTab;             /* Table holding the result of the SELECT */  int i;                    /* Loop counter */  int addr;                 /* Address of top of loop */  int iReg;                 /* First register in set passed to OP_VUpdate */  sqlite3 *db = pParse->db; /* Database connection */  const char *pVTab = (const char*)sqlite3GetVTable(db, pTab);  SelectDest dest;  /* Construct the SELECT statement that will find the new values for  ** all updated rows.   */  pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ID, "_rowid_"));  if( pRowid ){    pEList = sqlite3ExprListAppend(pParse, pEList,                                   sqlite3ExprDup(db, pRowid, 0));  }  assert( pTab->iPKey<0 );  for(i=0; i<pTab->nCol; i++){    if( aXRef[i]>=0 ){      pExpr = sqlite3ExprDup(db, pChanges->a[aXRef[i]].pExpr, 0);    }else{      pExpr = sqlite3Expr(db, TK_ID, pTab->aCol[i].zName);    }    pEList = sqlite3ExprListAppend(pParse, pEList, pExpr);  }  pSelect = sqlite3SelectNew(pParse, pEList, pSrc, pWhere, 0, 0, 0, 0, 0, 0);    /* Create the ephemeral table into which the update results will  ** be stored.  */  assert( v );  ephemTab = pParse->nTab++;  sqlite3VdbeAddOp2(v, OP_OpenEphemeral, ephemTab, pTab->nCol+1+(pRowid!=0));  sqlite3VdbeChangeP5(v, BTREE_UNORDERED);  /* fill the ephemeral table   */  sqlite3SelectDestInit(&dest, SRT_Table, ephemTab);  sqlite3Select(pParse, pSelect, &dest);  /* Generate code to scan the ephemeral table and call VUpdate. */  iReg = ++pParse->nMem;  pParse->nMem += pTab->nCol+1;  addr = sqlite3VdbeAddOp2(v, OP_Rewind, ephemTab, 0);  sqlite3VdbeAddOp3(v, OP_Column,  ephemTab, 0, iReg);  sqlite3VdbeAddOp3(v, OP_Column, ephemTab, (pRowid?1:0), iReg+1);  for(i=0; i<pTab->nCol; i++){    sqlite3VdbeAddOp3(v, OP_Column, ephemTab, i+1+(pRowid!=0), iReg+2+i);  }  sqlite3VtabMakeWritable(pParse, pTab);  sqlite3VdbeAddOp4(v, OP_VUpdate, 0, pTab->nCol+2, iReg, pVTab, P4_VTAB);  sqlite3MayAbort(pParse);  sqlite3VdbeAddOp2(v, OP_Next, ephemTab, addr+1);  sqlite3VdbeJumpHere(v, addr);  sqlite3VdbeAddOp2(v, OP_Close, ephemTab, 0);  /* Cleanup */  sqlite3SelectDelete(db, pSelect);  }
开发者ID:Sheridan,项目名称:sqlite,代码行数:91,


示例25: codeTriggerProgram

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


示例26: updateVirtualTable

/*** Generate code for an UPDATE of a virtual table.**** The strategy is that we create an ephemerial table that contains** for each row to be changed:****   (A)  The original rowid of that row.**   (B)  The revised rowid for the row. (note1)**   (C)  The content of every column in the row.**** Then we loop over this ephemeral table and for each row in** the ephermeral table call VUpdate.**** When finished, drop the ephemeral table.**** (note1) Actually, if we know in advance that (A) is always the same** as (B) we only store (A), then duplicate (A) when pulling** it out of the ephemeral table before calling VUpdate.*/static void updateVirtualTable(  Parse *pParse,       /* The parsing context */  SrcList *pSrc,       /* The virtual table to be modified */  Table *pTab,         /* The virtual table */  ExprList *pChanges,  /* The columns to change in the UPDATE statement */  Expr *pRowid,        /* Expression used to recompute the rowid */  int *aXRef,          /* Mapping from columns of pTab to entries in pChanges */  Expr *pWhere         /* WHERE clause of the UPDATE statement */){  Vdbe *v = pParse->pVdbe;  /* Virtual machine under construction */  ExprList *pEList = 0;     /* The result set of the SELECT statement */  Select *pSelect = 0;      /* The SELECT statement */  Expr *pExpr;              /* Temporary expression */  int ephemTab;             /* Table holding the result of the SELECT */  int i;                    /* Loop counter */  int addr;                 /* Address of top of loop */  /* Construct the SELECT statement that will find the new values for  ** all updated rows.   */  pEList = sqlite3ExprListAppend(0, sqlite3CreateIdExpr("_rowid_"), 0);  if( pRowid ){    pEList = sqlite3ExprListAppend(pEList, sqlite3ExprDup(pRowid), 0);  }  assert( pTab->iPKey<0 );  for(i=0; i<pTab->nCol; i++){    if( aXRef[i]>=0 ){      pExpr = sqlite3ExprDup(pChanges->a[aXRef[i]].pExpr);    }else{      pExpr = sqlite3CreateIdExpr(pTab->aCol[i].zName);    }    pEList = sqlite3ExprListAppend(pEList, pExpr, 0);  }  pSelect = sqlite3SelectNew(pEList, pSrc, pWhere, 0, 0, 0, 0, 0, 0);    /* Create the ephemeral table into which the update results will  ** be stored.  */  assert( v );  ephemTab = pParse->nTab++;  sqlite3VdbeAddOp(v, OP_OpenEphemeral, ephemTab, pTab->nCol+1+(pRowid!=0));  /* fill the ephemeral table   */  sqlite3Select(pParse, pSelect, SRT_Table, ephemTab, 0, 0, 0, 0);  /*  ** Generate code to scan the ephemeral table and call VDelete and  ** VInsert  */  sqlite3VdbeAddOp(v, OP_Rewind, ephemTab, 0);  addr = sqlite3VdbeCurrentAddr(v);  sqlite3VdbeAddOp(v, OP_Column,  ephemTab, 0);  if( pRowid ){    sqlite3VdbeAddOp(v, OP_Column, ephemTab, 1);  }else{    sqlite3VdbeAddOp(v, OP_Dup, 0, 0);  }  for(i=0; i<pTab->nCol; i++){    sqlite3VdbeAddOp(v, OP_Column, ephemTab, i+1+(pRowid!=0));  }  pParse->pVirtualLock = pTab;  sqlite3VdbeOp3(v, OP_VUpdate, 0, pTab->nCol+2,                      (const char*)pTab->pVtab, P3_VTAB);  sqlite3VdbeAddOp(v, OP_Next, ephemTab, addr);  sqlite3VdbeAddOp(v, OP_Close, ephemTab, 0);  /* Cleanup */  sqlite3SelectDelete(pSelect);  }
开发者ID:GameLemur,项目名称:nebula-device3,代码行数:89,


示例27: updateVirtualTable

static void updateVirtualTable(  Parse *pParse,         SrcList *pSrc,         Table *pTab,           ExprList *pChanges,    Expr *pRowid,          int *aXRef,            Expr *pWhere         ){  Vdbe *v = pParse->pVdbe;    ExprList *pEList = 0;       Select *pSelect = 0;        Expr *pExpr;                int ephemTab;               int i;                      int addr;                   int iReg;                   sqlite3 *db = pParse->db;   const char *pVTab = (const char*)sqlite3GetVTable(db, pTab);  SelectDest dest;  pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ID, "_rowid_"));  if( pRowid ){    pEList = sqlite3ExprListAppend(pParse, pEList,                                   sqlite3ExprDup(db, pRowid, 0));  }  assert( pTab->iPKey<0 );  for(i=0; i<pTab->nCol; i++){    if( aXRef[i]>=0 ){      pExpr = sqlite3ExprDup(db, pChanges->a[aXRef[i]].pExpr, 0);    }else{      pExpr = sqlite3Expr(db, TK_ID, pTab->aCol[i].zName);    }    pEList = sqlite3ExprListAppend(pParse, pEList, pExpr);  }  pSelect = sqlite3SelectNew(pParse, pEList, pSrc, pWhere, 0, 0, 0, 0, 0, 0);    assert( v );  ephemTab = pParse->nTab++;  sqlite3VdbeAddOp2(v, OP_OpenEphemeral, ephemTab, pTab->nCol+1+(pRowid!=0));  sqlite3VdbeChangeP5(v, BTREE_UNORDERED);  sqlite3SelectDestInit(&dest, SRT_Table, ephemTab);  sqlite3Select(pParse, pSelect, &dest);    iReg = ++pParse->nMem;  pParse->nMem += pTab->nCol+1;  addr = sqlite3VdbeAddOp2(v, OP_Rewind, ephemTab, 0);  sqlite3VdbeAddOp3(v, OP_Column,  ephemTab, 0, iReg);  sqlite3VdbeAddOp3(v, OP_Column, ephemTab, (pRowid?1:0), iReg+1);  for(i=0; i<pTab->nCol; i++){    sqlite3VdbeAddOp3(v, OP_Column, ephemTab, i+1+(pRowid!=0), iReg+2+i);  }  sqlite3VtabMakeWritable(pParse, pTab);  sqlite3VdbeAddOp4(v, OP_VUpdate, 0, pTab->nCol+2, iReg, pVTab, P4_VTAB);  sqlite3MayAbort(pParse);  sqlite3VdbeAddOp2(v, OP_Next, ephemTab, addr+1);  sqlite3VdbeJumpHere(v, addr);  sqlite3VdbeAddOp2(v, OP_Close, ephemTab, 0);    sqlite3SelectDelete(db, pSelect);  }
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:64,



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


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