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

📄 sqliteint.h

📁 sqlite-3.4.1,嵌入式数据库.是一个功能强大的开源数据库,给学习和研发以及小型公司的发展带来了全所未有的好处.
💻 H
📖 第 1 页 / 共 5 页
字号:
** The Index.onError field determines whether or not the indexed columns** must be unique and what to do if they are not.  When Index.onError=OE_None,** it means this is not a unique index.  Otherwise it is a unique index** and the value of Index.onError indicate the which conflict resolution ** algorithm to employ whenever an attempt is made to insert a non-unique** element.*/struct Index {  char *zName;     /* Name of this index */  int nColumn;     /* Number of columns in the table used by this index */  int *aiColumn;   /* Which columns are used by this index.  1st is 0 */  unsigned *aiRowEst; /* Result of ANALYZE: Est. rows selected by each column */  Table *pTable;   /* The SQL table being indexed */  int tnum;        /* Page containing root of this index in database file */  u8 onError;      /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */  u8 autoIndex;    /* True if is automatically created (ex: by UNIQUE) */  char *zColAff;   /* String defining the affinity of each column */  Index *pNext;    /* The next index associated with the same table */  Schema *pSchema; /* Schema containing this index */  u8 *aSortOrder;  /* Array of size Index.nColumn. True==DESC, False==ASC */  char **azColl;   /* Array of collation sequence names for index */};/*** Each token coming out of the lexer is an instance of** this structure.  Tokens are also used as part of an expression.**** Note if Token.z==0 then Token.dyn and Token.n are undefined and** may contain random values.  Do not make any assuptions about Token.dyn** and Token.n when Token.z==0.*/struct Token {  const unsigned 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 */};/*** An instance of this structure contains information needed to generate** code for a SELECT that contains aggregate functions.**** If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a** pointer to this structure.  The Expr.iColumn field is the index in** AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate** code for that node.**** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the** original Select structure that describes the SELECT statement.  These** fields do not need to be freed when deallocating the AggInfo structure.*/struct AggInfo {  u8 directMode;          /* Direct rendering mode means take data directly                          ** from source tables rather than from accumulators */  u8 useSortingIdx;       /* In direct mode, reference the sorting index rather                          ** than the source table */  int sortingIdx;         /* Cursor number of the sorting index */  ExprList *pGroupBy;     /* The group by clause */  int nSortingColumn;     /* Number of columns in the sorting index */  struct AggInfo_col {    /* For each column used in source tables */    Table *pTab;             /* Source table */    int iTable;              /* Cursor number of the source table */    int iColumn;             /* Column number within the source table */    int iSorterColumn;       /* Column number in the sorting index */    int iMem;                /* Memory location that acts as accumulator */    Expr *pExpr;             /* The original expression */  } *aCol;  int nColumn;            /* Number of used entries in aCol[] */  int nColumnAlloc;       /* Number of slots allocated for aCol[] */  int nAccumulator;       /* Number of columns that show through to the output.                          ** Additional columns are used only as parameters to                          ** aggregate functions */  struct AggInfo_func {   /* For each aggregate function */    Expr *pExpr;             /* Expression encoding the function */    FuncDef *pFunc;          /* The aggregate function implementation */    int iMem;                /* Memory location that acts as accumulator */    int iDistinct;           /* Ephermeral table used to enforce DISTINCT */  } *aFunc;  int nFunc;              /* Number of entries in aFunc[] */  int nFuncAlloc;         /* Number of slots allocated for aFunc[] */};/*** 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.**** If the expression is a subquery then Expr.iColumn holds an integer** register number containing the result of the subquery.  If the** subquery gives a constant result, then iTable is -1.  If the subquery** gives a different answer at different times during statement processing** then iTable is the address of a subroutine that computes the subquery.**** 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.**** If the Expr is of type OP_Column, and the table it is selecting from** is a disk table or the "old.*" pseudo-table, then pTab points to the** corresponding table definition.*/struct Expr {  u8 op;                 /* Operation performed by this node */  char affinity;         /* The affinity of the column or 0 if not a column */  u16 flags;             /* Various flags.  See below */  CollSeq *pColl;        /* The collation type of the column or 0 */  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. */  AggInfo *pAggInfo;     /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */  int iAgg;              /* Which entry in pAggInfo->aCol[] or ->aFunc[] */  int iRightJoinTable;   /* If EP_FromJoin, the right table of the join */  Select *pSelect;       /* When the expression is a sub-select.  Also the                         ** right side of "<expr> IN (<select>)" */  Table *pTab;           /* Table for OP_Column expressions. */  Schema *pSchema;#if SQLITE_MAX_EXPR_DEPTH>0  int nHeight;           /* Height of the tree headed by this node */#endif};/*** The following are the meanings of bits in the Expr.flags field.*/#define EP_FromJoin     0x01  /* Originated in ON or USING clause of a join */#define EP_Agg          0x02  /* Contains one or more aggregate functions */#define EP_Resolved     0x04  /* IDs have been resolved to COLUMNs */#define EP_Error        0x08  /* Expression contains one or more errors */#define EP_Distinct     0x10  /* Aggregate function with DISTINCT keyword */#define EP_VarSelect    0x20  /* pSelect is correlated, not constant */#define EP_Dequoted     0x40  /* True if the string has been dequoted */#define EP_InfixFunc    0x80  /* True for an infix function: LIKE, GLOB, etc */#define EP_ExpCollate  0x100  /* Collating sequence specified explicitly *//*** 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 */  int iECursor;          /* VDBE Cursor associated with this ExprList */  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 {  struct IdList_item {    char *zName;      /* Name of the identifier */    int idx;          /* Index in some Table.aCol[] of a column named zName */  } *a;  int nId;         /* Number of identifiers on the list */  int nAlloc;      /* Number of entries allocated for a[] below */};/*** The bitmask datatype defined below is used for various optimizations.**** Changing this from a 64-bit to a 32-bit type limits the number of** tables in a join to 32 instead of 64.  But it also reduces the size** of the library by 738 bytes on ix86.*/typedef u64 Bitmask;/*** 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.**** The jointype starts out showing the join type between the current table** and the next table on the list.  The parser builds the list this way.** But sqlite3SrcListShiftJoinType() later shifts the jointypes so that each** jointype expresses the join between the table and the previous table.*/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 */    u8 isPopulated;   /* Temporary table associated with SELECT is populated */    u8 jointype;      /* Type of join between this able and the previous */    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 */    Bitmask colUsed;  /* Bit N (1<<N) set if column N or pTab is used */  } 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_CROSS     0x0002    /* Explicit use of the CROSS keyword */#define JT_NATURAL   0x0004    /* True for a "natural" join */#define JT_LEFT      0x0008    /* Left outer join */#define JT_RIGHT     0x0010    /* Right outer join */#define JT_OUTER     0x0020    /* The "OUTER" keyword is present */#define JT_ERROR     0x0040    /* 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.**** The pIdxInfo and pBestIdx fields are used to help pick the best** index on a virtual table.  The pIdxInfo pointer contains indexing** information for the i-th table in the FROM clause before reordering.** All the pIdxInfo pointers are freed by whereInfoFree() in where.c.** The pBestIdx pointer is a copy of pIdxInfo for the i-th table after** FROM clause ordering.  This is a little confusing so I will repeat** it in different words.  WhereInfo.a[i].pIdxInfo is index information ** for WhereInfo.pTabList.a[i].  WhereInfo.a[i].pBestInfo is the** index information for the i-th loop of the join.  pBestInfo is always** either NULL or a copy of some pIdxInfo.  So for cleanup it is ** sufficient to free all of the pIdxInfo pointers.** */

⌨️ 快捷键说明

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