⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sqliteint.h

📁 sqlite 嵌入式数据库的源码
💻 H
📖 第 1 页 / 共 5 页
字号:
/*** A trigger is either a BEFORE or an AFTER trigger.  The following constants** determine which. **** If there are multiple triggers, you might of some BEFORE and some AFTER.** In that cases, the constants below can be ORed together.*/#define TRIGGER_BEFORE  1#define TRIGGER_AFTER   2/* * An instance of struct TriggerStep is used to store a single SQL statement * that is a part of a trigger-program.  * * Instances of struct TriggerStep are stored in a singly linked list (linked * using the "pNext" member) referenced by the "step_list" member of the  * associated struct Trigger instance. The first element of the linked list is * the first step of the trigger-program. *  * The "op" member indicates whether this is a "DELETE", "INSERT", "UPDATE" or * "SELECT" statement. The meanings of the other members is determined by the  * value of "op" as follows: * * (op == TK_INSERT) * orconf    -> stores the ON CONFLICT algorithm * pSelect   -> If this is an INSERT INTO ... SELECT ... statement, then *              this stores a pointer to the SELECT statement. Otherwise NULL. * target    -> A token holding the name of the table to insert into. * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then *              this stores values to be inserted. Otherwise NULL. * pIdList   -> If this is an INSERT INTO ... (<column-names>) VALUES ...  *              statement, then this stores the column-names to be *              inserted into. * * (op == TK_DELETE) * target    -> A token holding the name of the table to delete from. * pWhere    -> The WHERE clause of the DELETE statement if one is specified. *              Otherwise NULL. *  * (op == TK_UPDATE) * target    -> A token holding the name of the table to update rows of. * pWhere    -> The WHERE clause of the UPDATE statement if one is specified. *              Otherwise NULL. * pExprList -> A list of the columns to update and the expressions to update *              them to. See sqlite3Update() documentation of "pChanges" *              argument. *  */struct TriggerStep {  int op;              /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */  int orconf;          /* OE_Rollback etc. */  Trigger *pTrig;      /* The trigger that this step is a part of */  Select *pSelect;     /* Valid for SELECT and sometimes 			  INSERT steps (when pExprList == 0) */  Token target;        /* Valid for DELETE, UPDATE, INSERT steps */  Expr *pWhere;        /* Valid for DELETE, UPDATE steps */  ExprList *pExprList; /* Valid for UPDATE statements and sometimes 			   INSERT steps (when pSelect == 0)         */  IdList *pIdList;     /* Valid for INSERT statements only */  TriggerStep * pNext; /* Next in the link-list */};/* * An instance of struct TriggerStack stores information required during code * generation of a single trigger program. While the trigger program is being * coded, its associated TriggerStack instance is pointed to by the * "pTriggerStack" member of the Parse structure. * * The pTab member points to the table that triggers are being coded on. The  * newIdx member contains the index of the vdbe cursor that points at the temp * table that stores the new.* references. If new.* references are not valid * for the trigger being coded (for example an ON DELETE trigger), then newIdx * is set to -1. The oldIdx member is analogous to newIdx, for old.* references. * * The ON CONFLICT policy to be used for the trigger program steps is stored  * as the orconf member. If this is OE_Default, then the ON CONFLICT clause  * specified for individual triggers steps is used. * * struct TriggerStack has a "pNext" member, to allow linked lists to be * constructed. When coding nested triggers (triggers fired by other triggers) * each nested trigger stores its parent trigger's TriggerStack as the "pNext"  * pointer. Once the nested trigger has been coded, the pNext value is restored * to the pTriggerStack member of the Parse stucture and coding of the parent * trigger continues. * * Before a nested trigger is coded, the linked list pointed to by the  * pTriggerStack is scanned to ensure that the trigger is not about to be coded * recursively. If this condition is detected, the nested trigger is not coded. */struct TriggerStack {  Table *pTab;         /* Table that triggers are currently being coded on */  int newIdx;          /* Index of vdbe cursor to "new" temp table */  int oldIdx;          /* Index of vdbe cursor to "old" temp table */  int orconf;          /* Current orconf policy */  int ignoreJump;      /* where to jump to for a RAISE(IGNORE) */  Trigger *pTrigger;   /* The trigger currently being coded */  TriggerStack *pNext; /* Next trigger down on the trigger stack */};/*** The following structure contains information used by the sqliteFix...** routines as they walk the parse tree to make database references** explicit.  */typedef struct DbFixer DbFixer;struct DbFixer {  Parse *pParse;      /* The parsing context.  Error messages written here */  const char *zDb;    /* Make sure all objects are contained in this database */  const char *zType;  /* Type of the container - used for error messages */  const Token *pName; /* Name of the container - used for error messages */};/*** A pointer to this structure is used to communicate information** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback.*/typedef struct {  sqlite3 *db;        /* The database being initialized */  char **pzErrMsg;    /* Error message stored here */} InitData;/* * This global flag is set for performance testing of triggers. When it is set * SQLite will perform the overhead of building new and old trigger references  * even when no triggers exist */extern int sqlite3_always_code_trigger_setup;/*** Internal function prototypes*/int sqlite3StrICmp(const char *, const char *);int sqlite3StrNICmp(const char *, const char *, int);int sqlite3HashNoCase(const char *, int);int sqlite3IsNumber(const char*, int*, u8);int sqlite3Compare(const char *, const char *);int sqlite3SortCompare(const char *, const char *);void sqlite3RealToSortable(double r, char *);#ifdef SQLITE_MEMDEBUG  void *sqlite3Malloc_(int,int,char*,int);  void sqlite3Free_(void*,char*,int);  void *sqlite3Realloc_(void*,int,char*,int);  char *sqlite3StrDup_(const char*,char*,int);  char *sqlite3StrNDup_(const char*, int,char*,int);  void sqlite3CheckMemory(void*,int);#else  void *sqlite3Malloc(int);  void *sqlite3MallocRaw(int);  void sqlite3Free(void*);  void *sqlite3Realloc(void*,int);  char *sqlite3StrDup(const char*);  char *sqlite3StrNDup(const char*, int);# define sqlite3CheckMemory(a,b)# define sqlite3MallocX sqlite3Malloc#endifvoid sqlite3FreeX(void*);void *sqlite3MallocX(int);char *sqlite3MPrintf(const char*, ...);char *sqlite3VMPrintf(const char*, va_list);void sqlite3DebugPrintf(const char*, ...);void *sqlite3TextToPtr(const char*);void sqlite3SetString(char **, ...);void sqlite3ErrorMsg(Parse*, const char*, ...);void sqlite3Dequote(char*);int sqlite3KeywordCode(const char*, int);int sqlite3RunParser(Parse*, const char*, char **);void sqlite3FinishCoding(Parse*);Expr *sqlite3Expr(int, Expr*, Expr*, const Token*);Expr *sqlite3RegisterExpr(Parse*,Token*);Expr *sqlite3ExprAnd(Expr*, Expr*);void sqlite3ExprSpan(Expr*,Token*,Token*);Expr *sqlite3ExprFunction(ExprList*, Token*);void sqlite3ExprAssignVarNumber(Parse*, Expr*);void sqlite3ExprDelete(Expr*);ExprList *sqlite3ExprListAppend(ExprList*,Expr*,Token*);void sqlite3ExprListDelete(ExprList*);int sqlite3Init(sqlite3*, char**);int sqlite3InitCallback(void*, int, char**, char**);void sqlite3Pragma(Parse*,Token*,Token*,Token*,int);void sqlite3ResetInternalSchema(sqlite3*, int);void sqlite3BeginParse(Parse*,int);void sqlite3RollbackInternalChanges(sqlite3*);void sqlite3CommitInternalChanges(sqlite3*);Table *sqlite3ResultSetOfSelect(Parse*,char*,Select*);void sqlite3OpenMasterTable(Vdbe *v, int);void sqlite3StartTable(Parse*,Token*,Token*,Token*,int,int);void sqlite3AddColumn(Parse*,Token*);void sqlite3AddNotNull(Parse*, int);void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int);void sqlite3AddColumnType(Parse*,Token*,Token*);void sqlite3AddDefaultValue(Parse*,Expr*);void sqlite3AddCollateType(Parse*, const char*, int);void sqlite3EndTable(Parse*,Token*,Token*,Select*);#ifndef SQLITE_OMIT_VIEW  void sqlite3CreateView(Parse*,Token*,Token*,Token*,Select*,int);  int sqlite3ViewGetColumnNames(Parse*,Table*);#else# define sqlite3ViewGetColumnNames(A,B) 0#endifvoid sqlite3DropTable(Parse*, SrcList*, int);void sqlite3DeleteTable(sqlite3*, Table*);void sqlite3Insert(Parse*, SrcList*, ExprList*, Select*, IdList*, int);IdList *sqlite3IdListAppend(IdList*, Token*);int sqlite3IdListIndex(IdList*,const char*);SrcList *sqlite3SrcListAppend(SrcList*, Token*, Token*);void sqlite3SrcListAddAlias(SrcList*, Token*);void sqlite3SrcListAssignCursors(Parse*, SrcList*);void sqlite3IdListDelete(IdList*);void sqlite3SrcListDelete(SrcList*);void sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,                        Token*);void sqlite3DropIndex(Parse*, SrcList*);void sqlite3AddKeyType(Vdbe*, ExprList*);void sqlite3AddIdxKeyType(Vdbe*, Index*);int sqlite3Select(Parse*, Select*, int, int, Select*, int, int*, char *aff);Select *sqlite3SelectNew(ExprList*,SrcList*,Expr*,ExprList*,Expr*,ExprList*,                        int,Expr*,Expr*);void sqlite3SelectDelete(Select*);void sqlite3SelectUnbind(Select*);Table *sqlite3SrcListLookup(Parse*, SrcList*);int sqlite3IsReadOnly(Parse*, Table*, int);void sqlite3OpenTableForReading(Vdbe*, int iCur, Table*);void sqlite3OpenTable(Vdbe*, int iCur, Table*, int);void sqlite3DeleteFrom(Parse*, SrcList*, Expr*);void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**);void sqlite3WhereEnd(WhereInfo*);void sqlite3ExprCode(Parse*, Expr*);void sqlite3ExprCodeAndCache(Parse*, Expr*);int sqlite3ExprCodeExprList(Parse*, ExprList*);void sqlite3ExprIfTrue(Parse*, Expr*, int, int);void sqlite3ExprIfFalse(Parse*, Expr*, int, int);void sqlite3NextedParse(Parse*, const char*, ...);Table *sqlite3FindTable(sqlite3*,const char*, const char*);Table *sqlite3LocateTable(Parse*,const char*, const char*);Index *sqlite3FindIndex(sqlite3*,const char*, const char*);void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);void sqlite3Vacuum(Parse*, Token*);int sqlite3RunVacuum(char**, sqlite3*);char *sqlite3NameFromToken(Token*);int sqlite3ExprCheck(Parse*, Expr*, int, int*);int sqlite3ExprCompare(Expr*, Expr*);int sqliteFuncId(Token*);int sqlite3ExprResolveNames(NameContext *, Expr *);int sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);Vdbe *sqlite3GetVdbe(Parse*);void sqlite3Randomness(int, void*);void sqlite3RollbackAll(sqlite3*);void sqlite3CodeVerifySchema(Parse*, int);void sqlite3BeginTransaction(Parse*, int);void sqlite3CommitTransaction(Parse*);void sqlite3RollbackTransaction(Parse*);int sqlite3ExprIsConstant(Expr*);int sqlite3ExprIsInteger(Expr*, int*);int sqlite3IsRowid(const char*);void sqlite3GenerateRowDelete(sqlite3*, Vdbe*, Table*, int, int);void sqlite3GenerateRowIndexDelete(sqlite3*, Vdbe*, Table*, int, char*);void sqlite3GenerateIndexKey(Vdbe*, Index*, int);void sqlite3GenerateConstraintChecks(Parse*,Table*,int,char*,int,int,int,int);void sqlite3CompleteInsertion(Parse*, Table*, int, char*, int, int, int);void sqlite3OpenTableAndIndices(Parse*, Table*, int, int);void sqlite3BeginWriteOperation(Parse*, int, int);Expr *sqlite3ExprDup(Expr*);void sqlite3TokenCopy(Token*, Token*);ExprList *sqlite3ExprListDup(ExprList*);SrcList *sqlite3SrcListDup(SrcList*);IdList *sqlite3IdListDup(IdList*);Select *sqlite3SelectDup(Select*);FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,int);void sqlite3RegisterBuiltinFunctions(sqlite3*);void sqlite3RegisterDateTimeFunctions(sqlite3*);int sqlite3SafetyOn(sqlite3*);int sqlite3SafetyOff(sqlite3*);int sqlite3SafetyCheck(sqlite3*);void sqlite3ChangeCookie(sqlite3*, Vdbe*, int);#ifndef SQLITE_OMIT_TRIGGER  void sqlite3BeginTrigger(Parse*, Token*,Token*,int,int,IdList*,SrcList*,                           int,Expr*,int);  void sqlite3FinishTrigger(Parse*, TriggerStep*, Token*);  void sqlite3DropTrigger(Parse*, SrcList*);  void sqlite3DropTriggerPtr(Parse*, Trigger*, int);  int sqlite3TriggersExist(Parse*, Table*, int, ExprList*);  int sqlite3CodeRowTrigger(Parse*, int, ExprList*, int, Table *, int, int,                            int, int);  void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);  void sqlite3DeleteTriggerStep(TriggerStep*);  TriggerStep *sqlite3TriggerSelectStep(Select*);  TriggerStep *sqlite3TriggerInsertStep(Token*, IdList*, ExprList*,Select*,int);  Trigger

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -