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

📄 sqliteint.h

📁 sqlite数据库管理系统开放源码
💻 H
📖 第 1 页 / 共 4 页
字号:
** and Token.n when Token.z==0.*/struct Token {  const char *z;      /* Text of the token.  Not NULL-terminated! */  unsigned dyn  : 1;  /* True for malloced memory, false for static */  unsigned n    : 31; /* Number of characters in this token */};/*** Each node of an expression in the parse tree is an instance** of this structure.**** Expr.op is the opcode.  The integer parser token codes are reused** as opcodes here.  For example, the parser defines TK_GE to be an integer** code representing the ">=" operator.  This same integer code is reused** to represent the greater-than-or-equal-to operator in the expression** tree.**** Expr.pRight and Expr.pLeft are subexpressions.  Expr.pList is a list** of argument if the expression is a function.**** Expr.token is the operator token for this node.  For some expressions** that have subexpressions, Expr.token can be the complete text that gave** rise to the Expr.  In the latter case, the token is marked as being** a compound token.**** An expression of the form ID or ID.ID refers to a column in a table.** For such expressions, Expr.op is set to TK_COLUMN and Expr.iTable is** the integer cursor number of a VDBE cursor pointing to that table and** Expr.iColumn is the column number for the specific column.  If the** expression is used as a result in an aggregate SELECT, then the** value is also stored in the Expr.iAgg column in the aggregate so that** it can be accessed after all aggregates are computed.**** If the expression is a function, the Expr.iTable is an integer code** representing which function.  If the expression is an unbound variable** marker (a question mark character '?' in the original SQL) then the** Expr.iTable holds the index number for that variable.**** The Expr.pSelect field points to a SELECT statement.  The SELECT might** be the right operand of an IN operator.  Or, if a scalar SELECT appears** in an expression the opcode is TK_SELECT and Expr.pSelect is the only** operand.*/struct Expr {  u8 op;                 /* Operation performed by this node */  u8 dataType;           /* Either SQLITE_SO_TEXT or SQLITE_SO_NUM */  u8 iDb;                /* Database referenced by this expression */  u8 flags;              /* Various flags.  See below */  Expr *pLeft, *pRight;  /* Left and right subnodes */  ExprList *pList;       /* A list of expressions used as function arguments                         ** or in "<expr> IN (<expr-list)" */  Token token;           /* An operand token */  Token span;            /* Complete text of the expression */  int iTable, iColumn;   /* When op==TK_COLUMN, then this expr node means the                         ** iColumn-th field of the iTable-th table. */  int iAgg;              /* When op==TK_COLUMN and pParse->useAgg==TRUE, pull                         ** result from the iAgg-th element of the aggregator */  Select *pSelect;       /* When the expression is a sub-select.  Also the                         ** right side of "<expr> IN (<select>)" */};/*** The following are the meanings of bits in the Expr.flags field.*/#define EP_FromJoin     0x0001  /* Originated in ON or USING clause of a join *//*** These macros can be used to test, set, or clear bits in the ** Expr.flags field.*/#define ExprHasProperty(E,P)     (((E)->flags&(P))==(P))#define ExprHasAnyProperty(E,P)  (((E)->flags&(P))!=0)#define ExprSetProperty(E,P)     (E)->flags|=(P)#define ExprClearProperty(E,P)   (E)->flags&=~(P)/*** A list of expressions.  Each expression may optionally have a** name.  An expr/name combination can be used in several ways, such** as the list of "expr AS ID" fields following a "SELECT" or in the** list of "ID = expr" items in an UPDATE.  A list of expressions can** also be used as the argument to a function, in which case the a.zName** field is not used.*/struct ExprList {  int nExpr;             /* Number of expressions on the list */  int nAlloc;            /* Number of entries allocated below */  struct ExprList_item {    Expr *pExpr;           /* The list of expressions */    char *zName;           /* Token associated with this expression */    u8 sortOrder;          /* 1 for DESC or 0 for ASC */    u8 isAgg;              /* True if this is an aggregate like count(*) */    u8 done;               /* A flag to indicate when processing is finished */  } *a;                  /* One entry for each expression */};/*** An instance of this structure can hold a simple list of identifiers,** such as the list "a,b,c" in the following statements:****      INSERT INTO t(a,b,c) VALUES ...;**      CREATE INDEX idx ON t(a,b,c);**      CREATE TRIGGER trig BEFORE UPDATE ON t(a,b,c) ...;**** The IdList.a.idx field is used when the IdList represents the list of** column names after a table name in an INSERT statement.  In the statement****     INSERT INTO t(a,b,c) ...**** If "a" is the k-th column of table "t", then IdList.a[0].idx==k.*/struct IdList {  int nId;         /* Number of identifiers on the list */  int nAlloc;      /* Number of entries allocated for a[] below */  struct IdList_item {    char *zName;      /* Name of the identifier */    int idx;          /* Index in some Table.aCol[] of a column named zName */  } *a;};/*** The following structure describes the FROM clause of a SELECT statement.** Each table or subquery in the FROM clause is a separate element of** the SrcList.a[] array.**** With the addition of multiple database support, the following structure** can also be used to describe a particular table such as the table that** is modified by an INSERT, DELETE, or UPDATE statement.  In standard SQL,** such a table must be a simple name: ID.  But in SQLite, the table can** now be identified by a database name, a dot, then the table name: ID.ID.*/struct SrcList {  i16 nSrc;        /* Number of tables or subqueries in the FROM clause */  i16 nAlloc;      /* Number of entries allocated in a[] below */  struct SrcList_item {    char *zDatabase;  /* Name of database holding this table */    char *zName;      /* Name of the table */    char *zAlias;     /* The "B" part of a "A AS B" phrase.  zName is the "A" */    Table *pTab;      /* An SQL table corresponding to zName */    Select *pSelect;  /* A SELECT statement used in place of a table name */    int jointype;     /* Type of join between this table and the next */    int iCursor;      /* The VDBE cursor number used to access this table */    Expr *pOn;        /* The ON clause of a join */    IdList *pUsing;   /* The USING clause of a join */  } a[1];             /* One entry for each identifier on the list */};/*** Permitted values of the SrcList.a.jointype field*/#define JT_INNER     0x0001    /* Any kind of inner or cross join */#define JT_NATURAL   0x0002    /* True for a "natural" join */#define JT_LEFT      0x0004    /* Left outer join */#define JT_RIGHT     0x0008    /* Right outer join */#define JT_OUTER     0x0010    /* The "OUTER" keyword is present */#define JT_ERROR     0x0020    /* unknown or unsupported join type *//*** For each nested loop in a WHERE clause implementation, the WhereInfo** structure contains a single instance of this structure.  This structure** is intended to be private the the where.c module and should not be** access or modified by other modules.*/struct WhereLevel {  int iMem;            /* Memory cell used by this level */  Index *pIdx;         /* Index used */  int iCur;            /* Cursor number used for this index */  int score;           /* How well this indexed scored */  int brk;             /* Jump here to break out of the loop */  int cont;            /* Jump here to continue with the next loop cycle */  int op, p1, p2;      /* Opcode used to terminate the loop */  int iLeftJoin;       /* Memory cell used to implement LEFT OUTER JOIN */  int top;             /* First instruction of interior of the loop */  int inOp, inP1, inP2;/* Opcode used to implement an IN operator */  int bRev;            /* Do the scan in the reverse direction */};/*** The WHERE clause processing routine has two halves.  The** first part does the start of the WHERE loop and the second** half does the tail of the WHERE loop.  An instance of** this structure is returned by the first half and passed** into the second half to give some continuity.*/struct WhereInfo {  Parse *pParse;  SrcList *pTabList;   /* List of tables in the join */  int iContinue;       /* Jump here to continue with next record */  int iBreak;          /* Jump here to break out of the loop */  int nLevel;          /* Number of nested loop */  int savedNTab;       /* Value of pParse->nTab before WhereBegin() */  int peakNTab;        /* Value of pParse->nTab after WhereBegin() */  WhereLevel a[1];     /* Information about each nest loop in the WHERE */};/*** An instance of the following structure contains all information** needed to generate code for a single SELECT statement.**** The zSelect field is used when the Select structure must be persistent.** Normally, the expression tree points to tokens in the original input** string that encodes the select.  But if the Select structure must live** longer than its input string (for example when it is used to describe** a VIEW) we have to make a copy of the input string so that the nodes** of the expression tree will have something to point to.  zSelect is used** to hold that copy.**** nLimit is set to -1 if there is no LIMIT clause.  nOffset is set to 0.** If there is a LIMIT clause, the parser sets nLimit to the value of the** limit and nOffset to the value of the offset (or 0 if there is not** offset).  But later on, nLimit and nOffset become the memory locations** in the VDBE that record the limit and offset counters.*/struct Select {  ExprList *pEList;      /* The fields of the result */  u8 op;                 /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */  u8 isDistinct;         /* True if the DISTINCT keyword is present */  SrcList *pSrc;         /* The FROM clause */  Expr *pWhere;          /* The WHERE clause */  ExprList *pGroupBy;    /* The GROUP BY clause */  Expr *pHaving;         /* The HAVING clause */  ExprList *pOrderBy;    /* The ORDER BY clause */  Select *pPrior;        /* Prior select in a compound select statement */  int nLimit, nOffset;   /* LIMIT and OFFSET values.  -1 means not used */  int iLimit, iOffset;   /* Memory registers holding LIMIT & OFFSET counters */  char *zSelect;         /* Complete text of the SELECT command */};/*** The results of a select can be distributed in several ways.*/#define SRT_Callback     1  /* Invoke a callback with each row of result */#define SRT_Mem          2  /* Store result in a memory cell */#define SRT_Set          3  /* Store result as unique keys in a table */#define SRT_Union        5  /* Store result as keys in a table */#define SRT_Except       6  /* Remove result from a UNION table */#define SRT_Table        7  /* Store result as data with a unique key */#define SRT_TempTable    8  /* Store result in a trasient table */#define SRT_Discard      9  /* Do not save the results anywhere */#define SRT_Sorter      10  /* Store results in the sorter */#define SRT_Subroutine  11  /* Call a subroutine to handle results *//*** When a SELECT uses aggregate functions (like "count(*)" or "avg(f1)")** we have to do some additional analysis of expressions.  An instance** of the following structure holds information about a single subexpression** somewhere in the SELECT statement.  An array of these structures holds** all the information we need to generate code for aggregate** expressions.**** Note that when analyzing a SELECT containing aggregates, both** non-aggregate field variables and aggregate functions are stored** in the AggExpr array of the Parser structure.**** The pExpr field points to an expression that is part of either the** field list, the GROUP BY clause, the HAVING clause or the ORDER BY** clause.  The expression will be freed when those clauses are cleaned** up.  Do not try to delete the expression attached to AggExpr.pExpr.**** If AggExpr.pExpr==0, that means the expression is "count(*)".*/struct AggExpr {  int isAgg;        /* if TRUE contains an aggregate function */  Expr *pExpr;      /* The expression */  FuncDef *pFunc;   /* Information about the aggregate function */};/*** An SQL parser context.  A copy of this structure is passed through** the parser and down into all the parser action routine in order to** carry around information that is global to the entire parse.*/struct Parse {  sqlite *db;          /* The main database structure */  int rc;              /* Return code from execution */  char *zErrMsg;       /* An error message */  Token sErrToken;     /* The token at which the error occurred */  Token sFirstToken;   /* The first token parsed */  Token sLastToken;    /* The last token parsed */  const char *zTail;   /* All SQL text past the last semicolon parsed */  Table *pNewTable;    /* A table being constructed by CREATE TABLE */  Vdbe *pVdbe;         /* An engine for executing database bytecode */  u8 colNamesSet;      /* TRUE after OP_ColumnName has been issued to pVdbe */  u8 explain;          /* True if the EXPLAIN flag is found on the query */  u8 nameClash;        /* A permanent table name clashes with temp table name */  u8 useAgg;           /* If true, extract field values from the aggregator                       ** while generating expressions.  Normally false */  int nErr;            /* Number of errors seen */  int nTab;            /* Number of previously allocated VDBE cursors */  int nMem;            /* Number of memory cells used so far */  int nSet;            /* Number of sets used so far */  int nAgg;            /* Number of aggregate expressions */  int nVar;            /* Number of '?' variables seen in the SQL so far */  AggExpr *aAgg;       /* An array of aggregate expressions */  const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */  Trigger *pNewTrigger;     /* Trigger under construct by a CREATE TRIGGER */  TriggerStack *trigStack;  /* Trigger actions being coded */};/*** An instance of the following structure can be declared on a stack and used** to save the Parse.zAuthContext value so that it can be restored later.*/struct AuthContext {  const char *zAuthContext;   /* Put saved Parse.zAuthContext here */  Parse *pParse;              /* The Parse structure */};/*** Bitfield flags for P2 value in OP_PutIntKey and OP_Delete*/#define OPFLAG_NCHANGE   1    /* Set to update db->nChange */#define OPFLAG_LASTROWID 2    /* Set to update db->lastRowid */#define OPFLAG_CSCHANGE  4    /* Set to update db->csChange *//* * Each trigger present in the database schema is stored as an instance of * struct Trigger. 

⌨️ 快捷键说明

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