本文整理汇总了C#中ExprList类的典型用法代码示例。如果您正苦于以下问题:C# ExprList类的具体用法?C# ExprList怎么用?C# ExprList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExprList类属于命名空间,在下文中一共展示了ExprList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveAlias
static void ResolveAlias(Parse parse, ExprList list, int colId, Expr expr, string type, int subqueries)
{
Debug.Assert(colId >= 0 && colId < list.Exprs);
Expr orig = list.Ids[colId].Expr; // The iCol-th column of the result set
Debug.Assert(orig != null);
Debug.Assert((orig.Flags & EP.Resolved) != 0);
Context ctx = parse.Ctx; // The database connection
Expr dup = Expr.Dup(ctx, orig, 0); // Copy of pOrig
if (orig.OP != TK.COLUMN && (type.Length == 0 || type[0] != 'G'))
{
IncrAggFunctionDepth(dup, subqueries);
dup = Expr.PExpr_(parse, TK.AS, dup, null, null);
if (dup == null) return;
if (list.Ids[colId].Alias == 0)
list.Ids[colId].Alias = (ushort)(++parse.Alias.length);
dup.TableId = list.Ids[colId].Alias;
}
if (expr.OP == TK.COLLATE)
dup = Expr.AddCollateString(parse, dup, expr.u.Token);
// Before calling sqlite3ExprDelete(), set the EP_Static flag. This prevents ExprDelete() from deleting the Expr structure itself,
// allowing it to be repopulated by the memcpy() on the following line.
E.ExprSetProperty(expr, EP.Static);
Expr.Delete(ctx, ref expr);
expr.memcpy(dup);
if (!E.ExprHasProperty(expr, EP.IntValue) && expr.u.Token != null)
{
Debug.Assert((dup.Flags & (EP.Reduced | EP.TokenOnly)) == 0);
dup.u.Token = expr.u.Token;
dup.Flags2 |= EP2.MallocedToken;
}
C._tagfree(ctx, ref dup);
}
示例2: resolveAlias
/*
** 2008 August 18
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains routines used for walking the parser tree and
** resolve all identifiers by associating them with a particular
** table and column.
*************************************************************************
** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
** C#-SQLite is an independent reimplementation of the SQLite software library
**
** SQLITE_SOURCE_ID: 2010-01-05 15:30:36 28d0d7710761114a44a1a3a425a6883c661f06e7
**
** $Header$
*************************************************************************
*/
//#include "sqliteInt.h"
//#include <stdlib.h>
//#include <string.h>
/*
** Turn the pExpr expression into an alias for the iCol-th column of the
** result set in pEList.
**
** If the result set column is a simple column reference, then this routine
** makes an exact copy. But for any other kind of expression, this
** routine make a copy of the result set column as the argument to the
** TK_AS operator. The TK_AS operator causes the expression to be
** evaluated just once and then reused for each alias.
**
** The reason for suppressing the TK_AS term when the expression is a simple
** column reference is so that the column reference will be recognized as
** usable by indices within the WHERE clause processing logic.
**
** Hack: The TK_AS operator is inhibited if zType[0]=='G'. This means
** that in a GROUP BY clause, the expression is evaluated twice. Hence:
**
** SELECT random()%5 AS x, count(*) FROM tab GROUP BY x
**
** Is equivalent to:
**
** SELECT random()%5 AS x, count(*) FROM tab GROUP BY random()%5
**
** The result of random()%5 in the GROUP BY clause is probably different
** from the result in the result-set. We might fix this someday. Or
** then again, we might not...
*/
static void resolveAlias(
Parse pParse, /* Parsing context */
ExprList pEList, /* A result set */
int iCol, /* A column in the result set. 0..pEList.nExpr-1 */
Expr pExpr, /* Transform this into an alias to the result set */
string zType /* "GROUP" or "ORDER" or "" */
)
{
Expr pOrig; /* The iCol-th column of the result set */
Expr pDup; /* Copy of pOrig */
sqlite3 db; /* The database connection */
Debug.Assert( iCol >= 0 && iCol < pEList.nExpr );
pOrig = pEList.a[iCol].pExpr;
Debug.Assert( pOrig != null );
Debug.Assert( ( pOrig.flags & EP_Resolved ) != 0 );
db = pParse.db;
if ( pOrig.op != TK_COLUMN && ( zType.Length == 0 || zType[0] != 'G' ) )
{
pDup = sqlite3ExprDup( db, pOrig, 0 );
pDup = sqlite3PExpr( pParse, TK_AS, pDup, null, null );
if ( pDup == null ) return;
if ( pEList.a[iCol].iAlias == 0 )
{
pEList.a[iCol].iAlias = (u16)( ++pParse.nAlias );
}
pDup.iTable = pEList.a[iCol].iAlias;
}
else if ( ExprHasProperty( pOrig, EP_IntValue ) || pOrig.u.zToken == null )
{
pDup = sqlite3ExprDup( db, pOrig, 0 );
if ( pDup == null ) return;
}
else
{
string zToken = pOrig.u.zToken;
Debug.Assert( zToken != null );
pOrig.u.zToken = null;
pDup = sqlite3ExprDup( db, pOrig, 0 );
pOrig.u.zToken = zToken;
if ( pDup == null ) return;
Debug.Assert( ( pDup.flags & ( EP_Reduced | EP_TokenOnly ) ) == 0 );
pDup.flags2 |= EP2_MallocedToken;
pDup.u.zToken = zToken;// sqlite3DbStrDup( db, zToken );
}
//.........这里部分代码省略.........
示例3: checkColumnOverlap
/*
** pEList is the SET clause of an UPDATE statement. Each entry
** in pEList is of the format <id>=<expr>. If any of the entries
** in pEList have an <id> which matches an identifier in pIdList,
** then return TRUE. If pIdList==NULL, then it is considered a
** wildcard that matches anything. Likewise if pEList==NULL then
** it matches anything so always return true. Return false only
** if there is no match.
*/
static int checkColumnOverlap(IdList pIdList, ExprList pEList)
{
int e;
if (pIdList == null || NEVER(pEList == null))
return 1;
for (e = 0; e < pEList.nExpr; e++)
{
if (sqlite3IdListIndex(pIdList, pEList.a[e].zName) >= 0)
return 1;
}
return 0;
}
示例4: Mapping
/// <summary>
/// </summary>
/// <param name="@object"></param>
/// <param name="parameter">ÐèÒª StringComparer.OrdinalIgnoreCase</param>
/// <exception cref="System.MemberAccessException" />
/// <exception cref="System.Reflection.TargetInvocationException" />
public static void Mapping(object @object, IDictionary<string, object> parameter)
{
ThrowHelper.ThrowIfNull(@object, "object");
ThrowHelper.ThrowIfNull(parameter, "parameter");
var type = @object.GetType();
var pds = GetDescriptors(type);
PropertyInfo pd = null;
Type cls = null;
object obj = null;
object value = null;
for (var i = 0; i < pds.Length; i++)
{
pd = pds[i];
obj = parameter.GetValue(pd.Name);
value = obj;
cls = pd.PropertyType;
if (obj is string)
{
var @string = (string)obj;
if ([email protected]())
{
@string = ConfigUtil.Filter(@string);
}
if (IsPrimitiveType(cls))
{
value = Convert(cls, @string);
}
}
#if CONFG_BEAN
else if (obj is BeanConfig)
{
value = CreateBean((BeanConfig) obj);
}
else if (obj is IList<BeanConfig>)
{
var list = new ExprList<object>();
foreach (var beanconfig in (IList<BeanConfig>) obj)
{
list.Add(CreateBean(beanconfig));
}
value = list.ToArray();
}
#endif
if (cls != null && value != null)
{
pd.SetValue(@object, value, null);
}
}
}
示例5: sqlite3WalkExprList
/*
** Call sqlite3WalkExpr() for every expression in list p or until
** an abort request is seen.
*/
static int sqlite3WalkExprList( Walker pWalker, ExprList p )
{
int i;
ExprList_item pItem;
if ( p != null )
{
for ( i = p.nExpr; i > 0; i-- )
{//, pItem++){
pItem = p.a[p.nExpr - i];
if ( sqlite3WalkExpr( pWalker, ref pItem.pExpr ) != 0 ) return WRC_Abort;
}
}
return WRC_Continue;
}
示例6: sqlite3SelectNew
static Select sqlite3SelectNew(
Parse pParse, /* Parsing context */
ExprList pEList, /* which columns to include in the result */
SrcList pSrc, /* the FROM clause -- which tables to scan */
Expr pWhere, /* the WHERE clause */
ExprList pGroupBy, /* the GROUP BY clause */
Expr pHaving, /* the HAVING clause */
ExprList pOrderBy, /* the ORDER BY clause */
int isDistinct, /* true if the DISTINCT keyword is present */
Expr pLimit, /* LIMIT value. NULL means not used */
Expr pOffset /* OFFSET value. NULL means no offset */
)
{
Select pNew;
// Select standin;
sqlite3 db = pParse.db;
pNew = new Select();//sqlite3DbMallocZero(db, sizeof(*pNew) );
Debug.Assert( //db.mallocFailed != 0 ||
null == pOffset || pLimit != null ); /* OFFSET implies LIMIT */
//if( pNew==null ){
// pNew = standin;
// memset(pNew, 0, sizeof(*pNew));
//}
if ( pEList == null )
{
pEList = sqlite3ExprListAppend( pParse, null, sqlite3Expr( db, TK_ALL, null ) );
}
pNew.pEList = pEList;
pNew.pSrc = pSrc;
pNew.pWhere = pWhere;
pNew.pGroupBy = pGroupBy;
pNew.pHaving = pHaving;
pNew.pOrderBy = pOrderBy;
pNew.selFlags = (u16)( isDistinct != 0 ? SF_Distinct : 0 );
pNew.op = TK_SELECT;
pNew.pLimit = pLimit;
pNew.pOffset = pOffset;
Debug.Assert( pOffset == null || pLimit != null );
pNew.addrOpenEphm[0] = -1;
pNew.addrOpenEphm[1] = -1;
pNew.addrOpenEphm[2] = -1;
//if ( db.mallocFailed != 0 )
//{
// clearSelect( db, pNew );
// //if ( pNew != standin ) sqlite3DbFree( db, ref pNew );
// pNew = null;
//}
return pNew;
}
示例7: New
public static Select New(Parse parse, ExprList list, SrcList src, Expr where_, ExprList groupBy, Expr having, ExprList orderBy, SF selFlags, Expr limit, Expr offset)
{
Context ctx = parse.Ctx;
Select newSelect = new Select();
Debug.Assert(ctx.MallocFailed || offset == null || limit != null); // OFFSET implies LIMIT
// Select standin;
if (newSelect == null)
{
Debug.Assert(ctx.MallocFailed);
//newSelect = standin;
//_memset(newSelect, 0, sizeof(newSelect));
}
if (list == null)
list = Expr.ListAppend(parse, null, Expr.Expr_(ctx, TK.ALL, null));
newSelect.EList = list;
if (src == null) src = new SrcList();
newSelect.Src = src;
newSelect.Where = where_;
newSelect.GroupBy = groupBy;
newSelect.Having = having;
newSelect.OrderBy = orderBy;
newSelect.SelFlags = selFlags;
newSelect.OP = TK.SELECT;
newSelect.Limit = limit;
newSelect.Offset = offset;
Debug.Assert(offset == null || limit != null);
newSelect.AddrOpenEphms[0] = (OP) - 1;
newSelect.AddrOpenEphms[1] = (OP) - 1;
newSelect.AddrOpenEphms[2] = (OP) - 1;
if (ctx.MallocFailed)
{
ClearSelect(ctx, newSelect);
//if (newSelect != standin) C._tagfree(ctx, ref newSelect);
newSelect = null;
}
else
Debug.Assert(newSelect.Src != null || parse.Errs > 0);
//Debug.Assert(newSelect != standin);
return newSelect;
}
示例8: generateColumnNames
/*
** Generate code that will tell the VDBE the names of columns
** in the result set. This information is used to provide the
** azCol[] values in the callback.
*/
static void generateColumnNames(
Parse pParse, /* Parser context */
SrcList pTabList, /* List of tables */
ExprList pEList /* Expressions defining the result set */
)
{
Vdbe v = pParse.pVdbe;
int i, j;
sqlite3 db = pParse.db;
bool fullNames;
bool shortNames;
#if !SQLITE_OMIT_EXPLAIN
/* If this is an EXPLAIN, skip this step */
if ( pParse.explain != 0 )
{
return;
}
#endif
if ( pParse.colNamesSet != 0 || NEVER( v == null ) /*|| db.mallocFailed != 0 */ )
return;
pParse.colNamesSet = 1;
fullNames = ( db.flags & SQLITE_FullColNames ) != 0;
shortNames = ( db.flags & SQLITE_ShortColNames ) != 0;
sqlite3VdbeSetNumCols( v, pEList.nExpr );
for ( i = 0; i < pEList.nExpr; i++ )
{
Expr p;
p = pEList.a[i].pExpr;
if ( NEVER( p == null ) )
continue;
if ( pEList.a[i].zName != null )
{
string zName = pEList.a[i].zName;
sqlite3VdbeSetColName( v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT );
}
else if ( ( p.op == TK_COLUMN || p.op == TK_AGG_COLUMN ) && pTabList != null )
{
Table pTab;
string zCol;
int iCol = p.iColumn;
for ( j = 0; ALWAYS( j < pTabList.nSrc ); j++ )
{
if ( pTabList.a[j].iCursor == p.iTable )
break;
}
Debug.Assert( j < pTabList.nSrc );
pTab = pTabList.a[j].pTab;
if ( iCol < 0 )
iCol = pTab.iPKey;
Debug.Assert( iCol == -1 || ( iCol >= 0 && iCol < pTab.nCol ) );
if ( iCol < 0 )
{
zCol = "rowid";
}
else
{
zCol = pTab.aCol[iCol].zName;
}
if ( !shortNames && !fullNames )
{
sqlite3VdbeSetColName( v, i, COLNAME_NAME,
pEList.a[i].zSpan, SQLITE_DYNAMIC );//sqlite3DbStrDup(db, pEList->a[i].zSpan), SQLITE_DYNAMIC);
}
else if ( fullNames )
{
string zName;
zName = sqlite3MPrintf( db, "%s.%s", pTab.zName, zCol );
sqlite3VdbeSetColName( v, i, COLNAME_NAME, zName, SQLITE_DYNAMIC );
}
else
{
sqlite3VdbeSetColName( v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT );
}
}
else
{
sqlite3VdbeSetColName( v, i, COLNAME_NAME,
pEList.a[i].zSpan, SQLITE_DYNAMIC );//sqlite3DbStrDup(db, pEList->a[i].zSpan), SQLITE_DYNAMIC);
}
}
generateColumnTypes( pParse, pTabList, pEList );
}
示例9: selectInnerLoop
/*
** This routine generates the code for the inside of the inner loop
** of a SELECT.
**
** If srcTab and nColumn are both zero, then the pEList expressions
** are evaluated in order to get the data for this row. If nColumn>0
** then data is pulled from srcTab and pEList is used only to get the
** datatypes for each column.
*/
static void selectInnerLoop(
Parse pParse, /* The parser context */
Select p, /* The complete select statement being coded */
ExprList pEList, /* List of values being extracted */
int srcTab, /* Pull data from this table */
int nColumn, /* Number of columns in the source table */
ExprList pOrderBy, /* If not NULL, sort results using this key */
int distinct, /* If >=0, make sure results are distinct */
SelectDest pDest, /* How to dispose of the results */
int iContinue, /* Jump here to continue with next row */
int iBreak /* Jump here to break out of the inner loop */
)
{
Vdbe v = pParse.pVdbe;
int i;
bool hasDistinct; /* True if the DISTINCT keyword is present */
int regResult; /* Start of memory holding result set */
int eDest = pDest.eDest; /* How to dispose of results */
int iParm = pDest.iParm; /* First argument to disposal method */
int nResultCol; /* Number of result columns */
Debug.Assert( v != null );
if ( NEVER( v == null ) )
return;
Debug.Assert( pEList != null );
hasDistinct = distinct >= 0;
if ( pOrderBy == null && !hasDistinct )
{
codeOffset( v, p, iContinue );
}
/* Pull the requested columns.
*/
if ( nColumn > 0 )
{
nResultCol = nColumn;
}
else
{
nResultCol = pEList.nExpr;
}
if ( pDest.iMem == 0 )
{
pDest.iMem = pParse.nMem + 1;
pDest.nMem = nResultCol;
pParse.nMem += nResultCol;
}
else
{
Debug.Assert( pDest.nMem == nResultCol );
}
regResult = pDest.iMem;
if ( nColumn > 0 )
{
for ( i = 0; i < nColumn; i++ )
{
sqlite3VdbeAddOp3( v, OP_Column, srcTab, i, regResult + i );
}
}
else if ( eDest != SRT_Exists )
{
/* If the destination is an EXISTS(...) expression, the actual
** values returned by the SELECT are not required.
*/
sqlite3ExprCacheClear( pParse );
sqlite3ExprCodeExprList( pParse, pEList, regResult, eDest == SRT_Output );
}
nColumn = nResultCol;
/* If the DISTINCT keyword was present on the SELECT statement
** and this row has been seen before, then do not make this row
** part of the result.
*/
if ( hasDistinct )
{
Debug.Assert( pEList != null );
Debug.Assert( pEList.nExpr == nColumn );
codeDistinct( pParse, distinct, iContinue, nColumn, regResult );
if ( pOrderBy == null )
{
codeOffset( v, p, iContinue );
}
}
switch ( eDest )
{
/* In this mode, write each query result to the key of the temporary
** table iParm.
*/
#if !SQLITE_OMIT_COMPOUND_SELECT
case SRT_Union:
//.........这里部分代码省略.........
示例10: sqlite3PrintExprList
void sqlite3PrintExprList( ExprList pList )
{
int i;
for ( i = 0; i < pList.nExpr; i++ )
{
sqlite3PrintExpr( pList.a[i].pExpr );
if ( i < pList.nExpr - 1 )
{
sqlite3DebugPrintf( ", " );
}
}
}
示例11: pushOntoSorter
/*
** Insert code into "v" that will push the record on the top of the
** stack into the sorter.
*/
static void pushOntoSorter(
Parse pParse, /* Parser context */
ExprList pOrderBy, /* The ORDER BY clause */
Select pSelect, /* The whole SELECT statement */
int regData /* Register holding data to be sorted */
)
{
Vdbe v = pParse.pVdbe;
int nExpr = pOrderBy.nExpr;
int regBase = sqlite3GetTempRange( pParse, nExpr + 2 );
int regRecord = sqlite3GetTempReg( pParse );
sqlite3ExprCacheClear( pParse );
sqlite3ExprCodeExprList( pParse, pOrderBy, regBase, false );
sqlite3VdbeAddOp2( v, OP_Sequence, pOrderBy.iECursor, regBase + nExpr );
sqlite3ExprCodeMove( pParse, regData, regBase + nExpr + 1, 1 );
sqlite3VdbeAddOp3( v, OP_MakeRecord, regBase, nExpr + 2, regRecord );
sqlite3VdbeAddOp2( v, OP_IdxInsert, pOrderBy.iECursor, regRecord );
sqlite3ReleaseTempReg( pParse, regRecord );
sqlite3ReleaseTempRange( pParse, regBase, nExpr + 2 );
if ( pSelect.iLimit != 0 )
{
int addr1, addr2;
int iLimit;
if ( pSelect.iOffset != 0 )
{
iLimit = pSelect.iOffset + 1;
}
else
{
iLimit = pSelect.iLimit;
}
addr1 = sqlite3VdbeAddOp1( v, OP_IfZero, iLimit );
sqlite3VdbeAddOp2( v, OP_AddImm, iLimit, -1 );
addr2 = sqlite3VdbeAddOp0( v, OP_Goto );
sqlite3VdbeJumpHere( v, addr1 );
sqlite3VdbeAddOp1( v, OP_Last, pOrderBy.iECursor );
sqlite3VdbeAddOp1( v, OP_Delete, pOrderBy.iECursor );
sqlite3VdbeJumpHere( v, addr2 );
}
}
示例12: sqlite3TriggersExist
/*
** Return a list of all triggers on table pTab if there exists at least
** one trigger that must be fired when an operation of type 'op' is
** performed on the table, and, if that operation is an UPDATE, if at
** least one of the columns in pChanges is being modified.
*/
static Trigger sqlite3TriggersExist(
Parse pParse, /* Parse context */
Table pTab, /* The table the contains the triggers */
int op, /* one of TK_DELETE, TK_INSERT, TK_UPDATE */
ExprList pChanges, /* Columns that change in an UPDATE statement */
out int pMask /* OUT: Mask of TRIGGER_BEFORE|TRIGGER_AFTER */
)
{
int mask = 0;
Trigger pList = null;
Trigger p;
if ( ( pParse.db.flags & SQLITE_EnableTrigger ) != 0 )
{
pList = sqlite3TriggerList( pParse, pTab );
}
Debug.Assert( pList == null || IsVirtual( pTab ) == false );
for ( p = pList; p != null; p = p.pNext )
{
if ( p.op == op && checkColumnOverlap( p.pColumns, pChanges ) != 0 )
{
mask |= p.tr_tm;
}
}
//if ( pMask != 0 )
{
pMask = mask;
}
return ( mask != 0 ? pList : null );
}
示例13: sqlite3Update
/*
** Process an UPDATE statement.
**
** UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL;
** \_______/ \________/ \______/ \________________/
* onError pTabList pChanges pWhere
*/
static void sqlite3Update(
Parse pParse, /* The parser context */
SrcList pTabList, /* The table in which we should change things */
ExprList pChanges, /* Things to be changed */
Expr pWhere, /* The WHERE clause. May be null */
int onError /* How to handle constraint errors */
)
{
int i, j; /* Loop counters */
Table pTab; /* The table to be updated */
int addr = 0; /* VDBE instruction address of the start of the loop */
WhereInfo pWInfo; /* Information about the WHERE clause */
Vdbe v; /* The virtual database engine */
Index pIdx; /* For looping over indices */
int nIdx; /* Number of indices that need updating */
int iCur; /* VDBE Cursor number of pTab */
sqlite3 db; /* The database structure */
int[] aRegIdx = null; /* One register assigned to each index to be updated */
int[] aXRef = null; /* aXRef[i] is the index in pChanges.a[] of the
** an expression for the i-th column of the table.
** aXRef[i]==-1 if the i-th column is not changed. */
bool chngRowid; /* True if the record number is being changed */
Expr pRowidExpr = null; /* Expression defining the new record number */
bool openAll = false; /* True if all indices need to be opened */
AuthContext sContext; /* The authorization context */
NameContext sNC; /* The name-context to resolve expressions in */
int iDb; /* Database containing the table being updated */
int j1; /* Addresses of jump instructions */
u8 okOnePass; /* True for one-pass algorithm without the FIFO */
#if !SQLITE_OMIT_TRIGGER
bool isView = false; /* Trying to update a view */
Trigger pTrigger; /* List of triggers on pTab, if required */
#endif
int iBeginAfterTrigger = 0; /* Address of after trigger program */
int iEndAfterTrigger = 0; /* Exit of after trigger program */
int iBeginBeforeTrigger = 0; /* Address of before trigger program */
int iEndBeforeTrigger = 0; /* Exit of before trigger program */
u32 old_col_mask = 0; /* Mask of OLD.* columns in use */
u32 new_col_mask = 0; /* Mask of NEW.* columns in use */
int newIdx = -1; /* index of trigger "new" temp table */
int oldIdx = -1; /* index of trigger "old" temp table */
/* Register Allocations */
int regRowCount = 0; /* A count of rows changed */
int regOldRowid; /* The old rowid */
int regNewRowid; /* The new rowid */
int regData; /* New data for the row */
int regRowSet = 0; /* Rowset of rows to be updated */
sContext = new AuthContext(); //memset( &sContext, 0, sizeof( sContext ) );
db = pParse.db;
if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ )
{
goto update_cleanup;
}
Debug.Assert( pTabList.nSrc == 1 );
/* Locate the table which we want to update.
*/
pTab = sqlite3SrcListLookup( pParse, pTabList );
if ( pTab == null ) goto update_cleanup;
iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema );
/* Figure out if we have any triggers and if the table being
** updated is a view
*/
#if !SQLITE_OMIT_TRIGGER
int iDummy = 0;
pTrigger = sqlite3TriggersExist( pParse, pTab, TK_UPDATE, pChanges, ref iDummy );
isView = pTab.pSelect != null;
#else
const Trigger pTrigger = null;
#if !SQLITE_OMIT_VIEW
const bool isView = false;
#endif
#endif
#if SQLITE_OMIT_VIEW
// # undef isView
const bool isView = false;
#endif
if ( sqlite3ViewGetColumnNames( pParse, pTab ) != 0 )
{
goto update_cleanup;
}
if ( sqlite3IsReadOnly( pParse, pTab, ( pTrigger != null ? 1 : 0 ) ) )
{
goto update_cleanup;
}
aXRef = new int[pTab.nCol];// sqlite3DbMallocRaw(db, sizeof(int) * pTab.nCol);
//if ( aXRef == null ) goto update_cleanup;
//.........这里部分代码省略.........
示例14: sqlite3TriggerColmask
/*
** Triggers may access values stored in the old.* or new.* pseudo-table.
** This function returns a 32-bit bitmask indicating which columns of the
** old.* or new.* tables actually are used by triggers. This information
** may be used by the caller, for example, to avoid having to load the entire
** old.* record into memory when executing an UPDATE or DELETE command.
**
** Bit 0 of the returned mask is set if the left-most column of the
** table may be accessed using an [old|new].<col> reference. Bit 1 is set if
** the second leftmost column value is required, and so on. If there
** are more than 32 columns in the table, and at least one of the columns
** with an index greater than 32 may be accessed, 0xffffffff is returned.
**
** It is not possible to determine if the old.rowid or new.rowid column is
** accessed by triggers. The caller must always assume that it is.
**
** Parameter isNew must be either 1 or 0. If it is 0, then the mask returned
** applies to the old.* table. If 1, the new.* table.
**
** Parameter tr_tm must be a mask with one or both of the TRIGGER_BEFORE
** and TRIGGER_AFTER bits set. Values accessed by BEFORE triggers are only
** included in the returned mask if the TRIGGER_BEFORE bit is set in the
** tr_tm parameter. Similarly, values accessed by AFTER triggers are only
** included in the returned mask if the TRIGGER_AFTER bit is set in tr_tm.
*/
static u32 sqlite3TriggerColmask(
Parse pParse, /* Parse context */
Trigger pTrigger, /* List of triggers on table pTab */
ExprList pChanges, /* Changes list for any UPDATE OF triggers */
int isNew, /* 1 for new.* ref mask, 0 for old.* ref mask */
int tr_tm, /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */
Table pTab, /* The table to code triggers from */
int orconf /* Default ON CONFLICT policy for trigger steps */
)
{
int op = pChanges != null ? TK_UPDATE : TK_DELETE;
u32 mask = 0;
Trigger p;
Debug.Assert( isNew == 1 || isNew == 0 );
for ( p = pTrigger; p != null; p = p.pNext )
{
if ( p.op == op && ( tr_tm & p.tr_tm ) != 0
&& checkColumnOverlap( p.pColumns, pChanges ) != 0
)
{
TriggerPrg pPrg;
pPrg = getRowTrigger( pParse, p, pTab, orconf );
if ( pPrg != null )
{
mask |= pPrg.aColmask[isNew];
}
}
}
return mask;
}
示例15: sqlite3TriggerInsertStep
static 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;
Debug.Assert( pEList == null || pSelect == null );
Debug.Assert( pEList != null || pSelect != null /*|| db.mallocFailed != 0 */ );
pTriggerStep = triggerStepAllocate( db, TK_INSERT, pTableName );
//if ( pTriggerStep != null )
//{
pTriggerStep.pSelect = sqlite3SelectDup( db, pSelect, EXPRDUP_REDUCE );
pTriggerStep.pIdList = pColumn;
pTriggerStep.pExprList = sqlite3ExprListDup( db, pEList, EXPRDUP_REDUCE );
pTriggerStep.orconf = orconf;
//}
//else
//{
// sqlite3IdListDelete( db, ref pColumn );
//}
sqlite3ExprListDelete( db, ref pEList );
sqlite3SelectDelete( db, ref pSelect );
return pTriggerStep;
}