本文整理汇总了C#中DbFixer类的典型用法代码示例。如果您正苦于以下问题:C# DbFixer类的具体用法?C# DbFixer怎么用?C# DbFixer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DbFixer类属于命名空间,在下文中一共展示了DbFixer类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: sqlite3CreateView
// The parser calls this routine in order to create a new VIEW
internal static void sqlite3CreateView(Parse pParse, Token pBegin, Token pName1, Token pName2, Select pSelect, int isTemp, int noErr)
{
var sFix = new DbFixer();
var db = pParse.db;
if (pParse.nVar > 0)
{
sqlite3ErrorMsg(pParse, "parameters are not allowed in views");
sqlite3SelectDelete(db, ref pSelect);
return;
}
Token pName = null;
sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0, noErr);
var p = pParse.pNewTable;
if (p == null || pParse.nErr != 0)
{
sqlite3SelectDelete(db, ref pSelect);
return;
}
sqlite3TwoPartName(pParse, pName1, pName2, ref pName);
var iDb = sqlite3SchemaToIndex(db, p.pSchema);
if (sqlite3FixInit(sFix, pParse, iDb, "view", pName) != 0 && sqlite3FixSelect(sFix, pSelect) != 0)
{
sqlite3SelectDelete(db, ref pSelect);
return;
}
// Make a copy of the entire SELECT statement that defines the view. This will force all the Expr.token.z values to be dynamically
// allocated rather than point to the input string - which means that they will persist after the current sqlite3_exec() call returns.
p.pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
sqlite3SelectDelete(db, ref pSelect);
if (0 == db.init.busy)
sqlite3ViewGetColumnNames(pParse, p);
// Locate the end of the CREATE VIEW statement. Make sEnd point to the end.
var sEnd = pParse.sLastToken;
if (Check.ALWAYS(sEnd.z[0] != 0) && sEnd.z[0] != ';')
sEnd.z = sEnd.z.Substring(sEnd.n);
sEnd.n = 0;
var n = (int)(pBegin.z.Length - sEnd.z.Length);
var z = pBegin.z;
while (Check.ALWAYS(n > 0) && sqlite3Isspace(z[n - 1]))
n--;
sEnd.z = z.Substring(n - 1);
sEnd.n = 1;
// Use sqlite3EndTable() to add the view to the SQLITE_MASTER table
sqlite3EndTable(pParse, null, sEnd, null);
return;
}
开发者ID:JiujiangZhu,项目名称:feaserver,代码行数:47,代码来源:Build+View.cs
示例2: sqlite3FinishTrigger
/*
** This routine is called after all of the trigger actions have been parsed
** in order to complete the process of building the trigger.
*/
static void sqlite3FinishTrigger(
Parse pParse, /* Parser context */
TriggerStep pStepList, /* The triggered program */
Token pAll /* Token that describes the complete CREATE TRIGGER */
)
{
Trigger pTrig = pParse.pNewTrigger; /* Trigger being finished */
string zName; /* Name of trigger */
sqlite3 db = pParse.db; /* The database */
DbFixer sFix = new DbFixer(); /* Fixer object */
int iDb; /* Database containing the trigger */
Token nameToken = new Token(); /* Trigger name for error reporting */
pParse.pNewTrigger = null;
if ( NEVER( pParse.nErr != 0 ) || pTrig == null )
goto triggerfinish_cleanup;
zName = pTrig.zName;
iDb = sqlite3SchemaToIndex( pParse.db, pTrig.pSchema );
pTrig.step_list = pStepList;
while ( pStepList != null )
{
pStepList.pTrig = pTrig;
pStepList = pStepList.pNext;
}
nameToken.z = pTrig.zName;
nameToken.n = sqlite3Strlen30( nameToken.z );
if ( sqlite3FixInit( sFix, pParse, iDb, "trigger", nameToken ) != 0
&& sqlite3FixTriggerStep( sFix, pTrig.step_list ) != 0 )
{
goto triggerfinish_cleanup;
}
/* if we are not initializing,
** build the sqlite_master entry
*/
if ( 0 == db.init.busy )
{
Vdbe v;
string z;
/* Make an entry in the sqlite_master table */
v = sqlite3GetVdbe( pParse );
if ( v == null )
goto triggerfinish_cleanup;
sqlite3BeginWriteOperation( pParse, 0, iDb );
z = pAll.z.Substring( 0, pAll.n );//sqlite3DbStrNDup( db, (char*)pAll.z, pAll.n );
sqlite3NestedParse( pParse,
"INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')",
db.aDb[iDb].zName, SCHEMA_TABLE( iDb ), zName,
pTrig.table, z );
sqlite3DbFree( db, ref z );
sqlite3ChangeCookie( pParse, iDb );
sqlite3VdbeAddParseSchemaOp( v, iDb,
sqlite3MPrintf( db, "type='trigger' AND name='%q'", zName ) );
}
if ( db.init.busy != 0 )
{
Trigger pLink = pTrig;
Hash pHash = db.aDb[iDb].pSchema.trigHash;
Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) );
pTrig = sqlite3HashInsert( ref pHash, zName, sqlite3Strlen30( zName ), pTrig );
if ( pTrig != null )
{
//db.mallocFailed = 1;
}
else if ( pLink.pSchema == pLink.pTabSchema )
{
Table pTab;
int n = sqlite3Strlen30( pLink.table );
pTab = sqlite3HashFind( pLink.pTabSchema.tblHash, pLink.table, n, (Table)null );
Debug.Assert( pTab != null );
pLink.pNext = pTab.pTrigger;
pTab.pTrigger = pLink;
}
}
triggerfinish_cleanup:
sqlite3DeleteTrigger( db, ref pTrig );
Debug.Assert( pParse.pNewTrigger == null );
sqlite3DeleteTriggerStep( db, ref pStepList );
}
开发者ID:z0rg1nc,项目名称:CsharpSqliteFork,代码行数:87,代码来源:trigger_c.cs
示例3: sqlite3BeginTrigger
/*
** This is called by the parser when it sees a CREATE TRIGGER statement
** up to the point of the BEGIN before the trigger actions. A Trigger
** structure is generated based on the information available and stored
** in pParse.pNewTrigger. After the trigger actions have been parsed, the
** sqlite3FinishTrigger() function is called to complete the trigger
** construction process.
*/
static void sqlite3BeginTrigger(
Parse pParse, /* The parse context of the CREATE TRIGGER statement */
Token pName1, /* The name of the trigger */
Token pName2, /* The name of the trigger */
int tr_tm, /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */
int op, /* One of TK_INSERT, TK_UPDATE, TK_DELETE */
IdList pColumns, /* column list if this is an UPDATE OF trigger */
SrcList pTableName,/* The name of the table/view the trigger applies to */
Expr pWhen, /* WHEN clause */
int isTemp, /* True if the TEMPORARY keyword is present */
int noErr /* Suppress errors if the trigger already exists */
)
{
Trigger pTrigger = null; /* The new trigger */
Table pTab; /* Table that the trigger fires off of */
string zName = null; /* Name of the trigger */
sqlite3 db = pParse.db; /* The database connection */
int iDb; /* The database to store the trigger in */
Token pName = null; /* The unqualified db name */
DbFixer sFix = new DbFixer(); /* State vector for the DB fixer */
int iTabDb; /* Index of the database holding pTab */
Debug.Assert( pName1 != null ); /* pName1.z might be NULL, but not pName1 itself */
Debug.Assert( pName2 != null );
Debug.Assert( op == TK_INSERT || op == TK_UPDATE || op == TK_DELETE );
Debug.Assert( op > 0 && op < 0xff );
if ( isTemp != 0 )
{
/* If TEMP was specified, then the trigger name may not be qualified. */
if ( pName2.n > 0 )
{
sqlite3ErrorMsg( pParse, "temporary trigger may not have qualified name" );
goto trigger_cleanup;
}
iDb = 1;
pName = pName1;
}
else
{
/* Figure out the db that the the trigger will be created in */
iDb = sqlite3TwoPartName( pParse, pName1, pName2, ref pName );
if ( iDb < 0 )
{
goto trigger_cleanup;
}
}
if ( null == pTableName ) //|| db.mallocFailed
{
goto trigger_cleanup;
}
/* A long-standing parser bug is that this syntax was allowed:
**
** CREATE TRIGGER attached.demo AFTER INSERT ON attached.tab ....
** ^^^^^^^^
**
** To maintain backwards compatibility, ignore the database
** name on pTableName if we are reparsing our of SQLITE_MASTER.
*/
if ( db.init.busy != 0 && iDb != 1 )
{
//sqlite3DbFree( db, pTableName.a[0].zDatabase );
pTableName.a[0].zDatabase = null;
}
/* If the trigger name was unqualified, and the table is a temp table,
** then set iDb to 1 to create the trigger in the temporary database.
** If sqlite3SrcListLookup() returns 0, indicating the table does not
** exist, the error is caught by the block below.
*/
if ( pTableName == null /*|| db.mallocFailed != 0 */ )
{
goto trigger_cleanup;
}
pTab = sqlite3SrcListLookup( pParse, pTableName );
if ( db.init.busy == 0 && pName2.n == 0 && pTab != null
&& pTab.pSchema == db.aDb[1].pSchema )
{
iDb = 1;
}
/* Ensure the table name matches database name and that the table exists */
// if ( db.mallocFailed != 0 ) goto trigger_cleanup;
Debug.Assert( pTableName.nSrc == 1 );
if ( sqlite3FixInit( sFix, pParse, iDb, "trigger", pName ) != 0 &&
sqlite3FixSrcList( sFix, pTableName ) != 0 )
{
goto trigger_cleanup;
}
pTab = sqlite3SrcListLookup( pParse, pTableName );
if ( pTab == null )
{
//.........这里部分代码省略.........
开发者ID:z0rg1nc,项目名称:CsharpSqliteFork,代码行数:101,代码来源:trigger_c.cs
示例4: sqlite3FixTriggerStep
static int sqlite3FixTriggerStep(
DbFixer pFix, /* Context of the fixation */
TriggerStep pStep /* The trigger step be fixed to one database */
)
{
while ( pStep != null )
{
if ( sqlite3FixSelect( pFix, pStep.pSelect ) != 0 )
{
return 1;
}
if ( sqlite3FixExpr( pFix, pStep.pWhere ) != 0 )
{
return 1;
}
if ( sqlite3FixExprList( pFix, pStep.pExprList ) != 0 )
{
return 1;
}
pStep = pStep.pNext;
}
return 0;
}
开发者ID:HansMaiser,项目名称:Vocaluxe,代码行数:23,代码来源:attach_c.cs
示例5: sqlite3FixExprList
static int sqlite3FixExprList(
DbFixer pFix, /* Context of the fixation */
ExprList pList /* The expression to be fixed to one database */
)
{
int i;
ExprList_item pItem;
if ( pList == null )
return 0;
for ( i = 0; i < pList.nExpr; i++ )//, pItem++ )
{
pItem = pList.a[i];
if ( sqlite3FixExpr( pFix, pItem.pExpr ) != 0 )
{
return 1;
}
}
return 0;
}
开发者ID:HansMaiser,项目名称:Vocaluxe,代码行数:19,代码来源:attach_c.cs
示例6: sqlite3FixExpr
static int sqlite3FixExpr(
DbFixer pFix, /* Context of the fixation */
Expr pExpr /* The expression to be fixed to one database */
)
{
while ( pExpr != null )
{
if ( ExprHasAnyProperty( pExpr, EP_TokenOnly ) )
break;
if ( ExprHasProperty( pExpr, EP_xIsSelect ) )
{
if ( sqlite3FixSelect( pFix, pExpr.x.pSelect ) != 0 )
return 1;
}
else
{
if ( sqlite3FixExprList( pFix, pExpr.x.pList ) != 0 )
return 1;
}
if ( sqlite3FixExpr( pFix, pExpr.pRight ) != 0 )
{
return 1;
}
pExpr = pExpr.pLeft;
}
return 0;
}
开发者ID:HansMaiser,项目名称:Vocaluxe,代码行数:27,代码来源:attach_c.cs
示例7: sqlite3FixSelect
static int sqlite3FixSelect(
DbFixer pFix, /* Context of the fixation */
Select pSelect /* The SELECT statement to be fixed to one database */
)
{
while ( pSelect != null )
{
if ( sqlite3FixExprList( pFix, pSelect.pEList ) != 0 )
{
return 1;
}
if ( sqlite3FixSrcList( pFix, pSelect.pSrc ) != 0 )
{
return 1;
}
if ( sqlite3FixExpr( pFix, pSelect.pWhere ) != 0 )
{
return 1;
}
if ( sqlite3FixExpr( pFix, pSelect.pHaving ) != 0 )
{
return 1;
}
pSelect = pSelect.pPrior;
}
return 0;
}
开发者ID:HansMaiser,项目名称:Vocaluxe,代码行数:27,代码来源:attach_c.cs
示例8: sqlite3FixSrcList
/*
** The following set of routines walk through the parse tree and assign
** a specific database to all table references where the database name
** was left unspecified in the original SQL statement. The pFix structure
** must have been initialized by a prior call to sqlite3FixInit().
**
** These routines are used to make sure that an index, trigger, or
** view in one database does not refer to objects in a different database.
** (Exception: indices, triggers, and views in the TEMP database are
** allowed to refer to anything.) If a reference is explicitly made
** to an object in a different database, an error message is added to
** pParse.zErrMsg and these routines return non-zero. If everything
** checks out, these routines return 0.
*/
static int sqlite3FixSrcList(
DbFixer pFix, /* Context of the fixation */
SrcList pList /* The Source list to check and modify */
)
{
int i;
string zDb;
SrcList_item pItem;
if ( NEVER( pList == null ) )
return 0;
zDb = pFix.zDb;
for ( i = 0; i < pList.nSrc; i++ )
{//, pItem++){
pItem = pList.a[i];
if ( pItem.zDatabase == null )
{
pItem.zDatabase = zDb;// sqlite3DbStrDup( pFix.pParse.db, zDb );
}
else if ( !pItem.zDatabase.Equals( zDb ,StringComparison.InvariantCultureIgnoreCase ) )
{
sqlite3ErrorMsg( pFix.pParse,
"%s %T cannot reference objects in database %s",
pFix.zType, pFix.pName, pItem.zDatabase );
return 1;
}
#if !SQLITE_OMIT_VIEW || !SQLITE_OMIT_TRIGGER
if ( sqlite3FixSelect( pFix, pItem.pSelect ) != 0 )
return 1;
if ( sqlite3FixExpr( pFix, pItem.pOn ) != 0 )
return 1;
#endif
}
return 0;
}
开发者ID:HansMaiser,项目名称:Vocaluxe,代码行数:49,代码来源:attach_c.cs
示例9: sqlite3FixInit
/*
** Initialize a DbFixer structure. This routine must be called prior
** to passing the structure to one of the sqliteFixAAAA() routines below.
**
** The return value indicates whether or not fixation is required. TRUE
** means we do need to fix the database references, FALSE means we do not.
*/
static int sqlite3FixInit(
DbFixer pFix, /* The fixer to be initialized */
Parse pParse, /* Error messages will be written here */
int iDb, /* This is the database that must be used */
string zType, /* "view", "trigger", or "index" */
Token pName /* Name of the view, trigger, or index */
)
{
sqlite3 db;
if ( NEVER( iDb < 0 ) || iDb == 1 )
return 0;
db = pParse.db;
Debug.Assert( db.nDb > iDb );
pFix.pParse = pParse;
pFix.zDb = db.aDb[iDb].zName;
pFix.zType = zType;
pFix.pName = pName;
return 1;
}
开发者ID:HansMaiser,项目名称:Vocaluxe,代码行数:27,代码来源:attach_c.cs
示例10: sqlite3CreateIndex
static Index sqlite3CreateIndex(Parse pParse, Token pName1, Token pName2, SrcList pTblName, ExprList pList, int onError, Token pStart, Token pEnd, int sortOrder, int ifNotExist)
{
Index pRet = null; /* Pointer to return */
Table pTab = null; /* Table to be indexed */
Index pIndex = null; /* The index to be created */
string zName = null; /* Name of the index */
int nName; /* Number of characters in zName */
var nullId = new Token();
var sFix = new DbFixer();
int sortOrderMask; /* 1 to honor DESC in index. 0 to ignore. */
var db = pParse.db;
Db pDb; /* The specific table containing the indexed database */
Token pName = null; /* Unqualified name of the index to create */
ExprList_item pListItem; /* For looping over pList */
int nCol;
int nExtra = 0;
var zExtra = new StringBuilder();
Debug.Assert(pStart == null || pEnd != null); /* pEnd must be non-NULL if pStart is */
Debug.Assert(pParse.nErr == 0); /* Never called with prior errors */
if (IN_DECLARE_VTAB(pParse))
goto exit_create_index;
if (SQLITE_OK != sqlite3ReadSchema(pParse))
goto exit_create_index;
// Find the table that is to be indexed. Return early if not found.
if (pTblName != null)
{
// Use the two-part index name to determine the database to search for the table. 'Fix' the table name to this db
// before looking up the table.
Debug.Assert(pName1 != null && pName2 != null);
var iDb = sqlite3TwoPartName(pParse, pName1, pName2, ref pName);
if (iDb < 0)
goto exit_create_index;
#if !SQLITE_OMIT_TEMPDB
// If the index name was unqualified, check if the the table is a temp table. If so, set the database to 1. Do not do this
// if initialising a database schema.
if (0 == db.init.busy)
{
pTab = sqlite3SrcListLookup(pParse, pTblName);
if (pName2.n == 0 && pTab != null && pTab.pSchema == db.aDb[1].pSchema)
iDb = 1;
}
#endif
if (sqlite3FixInit(sFix, pParse, iDb, "index", pName) != 0 && sqlite3FixSrcList(sFix, pTblName) != 0)
// Because the parser constructs pTblName from a single identifier, sqlite3FixSrcList can never fail.
Debugger.Break();
pTab = sqlite3LocateTable(pParse, 0, pTblName.a[0].zName,
pTblName.a[0].zDatabase);
if (pTab == null)
goto exit_create_index;
Debug.Assert(db.aDb[iDb].pSchema == pTab.pSchema);
}
else
{
Debug.Assert(pName == null);
pTab = pParse.pNewTable;
if (pTab == null)
goto exit_create_index;
iDb = sqlite3SchemaToIndex(db, pTab.pSchema);
}
pDb = db.aDb[iDb];
Debug.Assert(pTab != null);
Debug.Assert(pParse.nErr == 0);
if (pTab.zName.StartsWith("sqlite_", System.StringComparison.InvariantCultureIgnoreCase) && !pTab.zName.StartsWith("sqlite_altertab_", System.StringComparison.InvariantCultureIgnoreCase))
{
sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab.zName);
goto exit_create_index;
}
#if !SQLITE_OMIT_VIEW
if (pTab.pSelect != null)
{
sqlite3ErrorMsg(pParse, "views may not be indexed");
goto exit_create_index;
}
#endif
if (IsVirtual(pTab))
{
sqlite3ErrorMsg(pParse, "virtual tables may not be indexed");
goto exit_create_index;
}
// Find the name of the index. Make sure there is not already another index or table with the same name.
// Exception: If we are reading the names of permanent indices from the sqlite_master table (because some other process changed the schema) and
// one of the index names collides with the name of a temporary table or index, then we will continue to process this index.
// If pName==0 it means that we are dealing with a primary key or UNIQUE constraint. We have to invent our own name.
if (pName != null)
{
zName = sqlite3NameFromToken(db, pName);
if (zName == null)
goto exit_create_index;
if (SQLITE_OK != sqlite3CheckObjectName(pParse, zName))
goto exit_create_index;
if (0 == db.init.busy)
if (sqlite3FindTable(db, zName, null) != null)
{
sqlite3ErrorMsg(pParse, "there is already a table named %s", zName);
goto exit_create_index;
}
if (sqlite3FindIndex(db, zName, pDb.zName) != null)
{
if (ifNotExist == 0)
//.........这里部分代码省略.........
开发者ID:JiujiangZhu,项目名称:feaserver,代码行数:101,代码来源:Build+Index.cs
注:本文中的DbFixer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论