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

📄 sqliteint.h

📁 sqlite数据库管理系统开放源码
💻 H
📖 第 1 页 / 共 4 页
字号:
**                       text datatypes.**** The sqlite.temp_store determines where temporary database files** are stored.  If 1, then a file is created to hold those tables.  If** 2, then they are held in memory.  0 means use the default value in** the TEMP_STORE macro.**** The sqlite.lastRowid records the last insert rowid generated by an** insert statement.  Inserts on views do not affect its value.  Each** trigger has its own context, so that lastRowid can be updated inside** triggers as usual.  The previous value will be restored once the trigger** exits.  Upon entering a before or instead of trigger, lastRowid is no** longer (since after version 2.8.12) reset to -1.**** The sqlite.nChange does not count changes within triggers and keeps no** context.  It is reset at start of sqlite_exec.** The sqlite.lsChange represents the number of changes made by the last** insert, update, or delete statement.  It remains constant throughout the** length of a statement and is then updated by OP_SetCounts.  It keeps a** context stack just like lastRowid so that the count of changes** within a trigger is not seen outside the trigger.  Changes to views do not** affect the value of lsChange.** The sqlite.csChange keeps track of the number of current changes (since** the last statement) and is used to update sqlite_lsChange.*/struct sqlite {  int nDb;                      /* Number of backends currently in use */  Db *aDb;                      /* All backends */  Db aDbStatic[2];              /* Static space for the 2 default backends */  int flags;                    /* Miscellanous flags. See below */  u8 file_format;               /* What file format version is this database? */  u8 safety_level;              /* How aggressive at synching data to disk */  u8 want_to_close;             /* Close after all VDBEs are deallocated */  u8 temp_store;                /* 1=file, 2=memory, 0=compile-time default */  u8 onError;                   /* Default conflict algorithm */  int next_cookie;              /* Next value of aDb[0].schema_cookie */  int cache_size;               /* Number of pages to use in the cache */  int nTable;                   /* Number of tables in the database */  void *pBusyArg;               /* 1st Argument to the busy callback */  int (*xBusyCallback)(void *,const char*,int);  /* The busy callback */  void *pCommitArg;             /* Argument to xCommitCallback() */     int (*xCommitCallback)(void*);/* Invoked at every commit. */  Hash aFunc;                   /* All functions that can be in SQL exprs */  int lastRowid;                /* ROWID of most recent insert (see above) */  int priorNewRowid;            /* Last randomly generated ROWID */  int magic;                    /* Magic number for detect library misuse */  int nChange;                  /* Number of rows changed (see above) */  int lsChange;                 /* Last statement change count (see above) */  int csChange;                 /* Current statement change count (see above) */  struct sqliteInitInfo {       /* Information used during initialization */    int iDb;                       /* When back is being initialized */    int newTnum;                   /* Rootpage of table being initialized */    u8 busy;                       /* TRUE if currently initializing */  } init;  struct Vdbe *pVdbe;           /* List of active virtual machines */  void (*xTrace)(void*,const char*);     /* Trace function */  void *pTraceArg;                       /* Argument to the trace function */#ifndef SQLITE_OMIT_AUTHORIZATION  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*);                                /* Access authorization function */  void *pAuthArg;               /* 1st argument to the access auth function */#endif#ifndef SQLITE_OMIT_PROGRESS_CALLBACK  int (*xProgress)(void *);     /* The progress callback */  void *pProgressArg;           /* Argument to the progress callback */  int nProgressOps;             /* Number of opcodes for progress callback */#endif};/*** Possible values for the sqlite.flags and or Db.flags fields.**** On sqlite.flags, the SQLITE_InTrans value means that we have** executed a BEGIN.  On Db.flags, SQLITE_InTrans means a statement** transaction is active on that particular database file.*/#define SQLITE_VdbeTrace      0x00000001  /* True to trace VDBE execution */#define SQLITE_Initialized    0x00000002  /* True after initialization */#define SQLITE_Interrupt      0x00000004  /* Cancel current operation */#define SQLITE_InTrans        0x00000008  /* True if in a transaction */#define SQLITE_InternChanges  0x00000010  /* Uncommitted Hash table changes */#define SQLITE_FullColNames   0x00000020  /* Show full column names on SELECT */#define SQLITE_ShortColNames  0x00000040  /* Show short columns names */#define SQLITE_CountRows      0x00000080  /* Count rows changed by INSERT, */                                          /*   DELETE, or UPDATE and return */                                          /*   the count using a callback. */#define SQLITE_NullCallback   0x00000100  /* Invoke the callback once if the */                                          /*   result set is empty */#define SQLITE_ReportTypes    0x00000200  /* Include information on datatypes */                                          /*   in 4th argument of callback *//*** Possible values for the sqlite.magic field.** The numbers are obtained at random and have no special meaning, other** than being distinct from one another.*/#define SQLITE_MAGIC_OPEN     0xa029a697  /* Database is open */#define SQLITE_MAGIC_CLOSED   0x9f3c2d33  /* Database is closed */#define SQLITE_MAGIC_BUSY     0xf03b7906  /* Database currently in use */#define SQLITE_MAGIC_ERROR    0xb5357930  /* An SQLITE_MISUSE error occurred *//*** Each SQL function is defined by an instance of the following** structure.  A pointer to this structure is stored in the sqlite.aFunc** hash table.  When multiple functions have the same name, the hash table** points to a linked list of these structures.*/struct FuncDef {  void (*xFunc)(sqlite_func*,int,const char**);  /* Regular function */  void (*xStep)(sqlite_func*,int,const char**);  /* Aggregate function step */  void (*xFinalize)(sqlite_func*);           /* Aggregate function finializer */  signed char nArg;         /* Number of arguments.  -1 means unlimited */  signed char dataType;     /* Arg that determines datatype.  -1=NUMERIC, */                            /* -2=TEXT. -3=SQLITE_ARGS */  u8 includeTypes;          /* Add datatypes to args of xFunc and xStep */  void *pUserData;          /* User data parameter */  FuncDef *pNext;           /* Next function with same name */};/*** information about each column of an SQL table is held in an instance** of this structure.*/struct Column {  char *zName;     /* Name of this column */  char *zDflt;     /* Default value of this column */  char *zType;     /* Data type for this column */  u8 notNull;      /* True if there is a NOT NULL constraint */  u8 isPrimKey;    /* True if this column is part of the PRIMARY KEY */  u8 sortOrder;    /* Some combination of SQLITE_SO_... values */  u8 dottedName;   /* True if zName contains a "." character */};/*** The allowed sort orders.**** The TEXT and NUM values use bits that do not overlap with DESC and ASC.** That way the two can be combined into a single number.*/#define SQLITE_SO_UNK       0  /* Use the default collating type.  (SCT_NUM) */#define SQLITE_SO_TEXT      2  /* Sort using memcmp() */#define SQLITE_SO_NUM       4  /* Sort using sqliteCompare() */#define SQLITE_SO_TYPEMASK  6  /* Mask to extract the collating sequence */#define SQLITE_SO_ASC       0  /* Sort in ascending order */#define SQLITE_SO_DESC      1  /* Sort in descending order */#define SQLITE_SO_DIRMASK   1  /* Mask to extract the sort direction *//*** Each SQL table is represented in memory by an instance of the** following structure.**** Table.zName is the name of the table.  The case of the original** CREATE TABLE statement is stored, but case is not significant for** comparisons.**** Table.nCol is the number of columns in this table.  Table.aCol is a** pointer to an array of Column structures, one for each column.**** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of** the column that is that key.   Otherwise Table.iPKey is negative.  Note** that the datatype of the PRIMARY KEY must be INTEGER for this field to** be set.  An INTEGER PRIMARY KEY is used as the rowid for each row of** the table.  If a table has no INTEGER PRIMARY KEY, then a random rowid** is generated for each row of the table.  Table.hasPrimKey is true if** the table has any PRIMARY KEY, INTEGER or otherwise.**** Table.tnum is the page number for the root BTree page of the table in the** database file.  If Table.iDb is the index of the database table backend** in sqlite.aDb[].  0 is for the main database and 1 is for the file that** holds temporary tables and indices.  If Table.isTransient** is true, then the table is stored in a file that is automatically deleted** when the VDBE cursor to the table is closed.  In this case Table.tnum ** refers VDBE cursor number that holds the table open, not to the root** page number.  Transient tables are used to hold the results of a** sub-query that appears instead of a real table name in the FROM clause ** of a SELECT statement.*/struct Table {  char *zName;     /* Name of the table */  int nCol;        /* Number of columns in this table */  Column *aCol;    /* Information about each column */  int iPKey;       /* If not less then 0, use aCol[iPKey] as the primary key */  Index *pIndex;   /* List of SQL indexes on this table. */  int tnum;        /* Root BTree node for this table (see note above) */  Select *pSelect; /* NULL for tables.  Points to definition if a view. */  u8 readOnly;     /* True if this table should not be written by the user */  u8 iDb;          /* Index into sqlite.aDb[] of the backend for this table */  u8 isTransient;  /* True if automatically deleted when VDBE finishes */  u8 hasPrimKey;   /* True if there exists a primary key */  u8 keyConf;      /* What to do in case of uniqueness conflict on iPKey */  Trigger *pTrigger; /* List of SQL triggers on this table */  FKey *pFKey;       /* Linked list of all foreign keys in this table */};/*** Each foreign key constraint is an instance of the following structure.**** A foreign key is associated with two tables.  The "from" table is** the table that contains the REFERENCES clause that creates the foreign** key.  The "to" table is the table that is named in the REFERENCES clause.** Consider this example:****     CREATE TABLE ex1(**       a INTEGER PRIMARY KEY,**       b INTEGER CONSTRAINT fk1 REFERENCES ex2(x)**     );**** For foreign key "fk1", the from-table is "ex1" and the to-table is "ex2".**** Each REFERENCES clause generates an instance of the following structure** which is attached to the from-table.  The to-table need not exist when** the from-table is created.  The existance of the to-table is not checked** until an attempt is made to insert data into the from-table.**** The sqlite.aFKey hash table stores pointers to this structure** given the name of a to-table.  For each to-table, all foreign keys** associated with that table are on a linked list using the FKey.pNextTo** field.*/struct FKey {  Table *pFrom;     /* The table that constains the REFERENCES clause */  FKey *pNextFrom;  /* Next foreign key in pFrom */  char *zTo;        /* Name of table that the key points to */  FKey *pNextTo;    /* Next foreign key that points to zTo */  int nCol;         /* Number of columns in this key */  struct sColMap {  /* Mapping of columns in pFrom to columns in zTo */    int iFrom;         /* Index of column in pFrom */    char *zCol;        /* Name of column in zTo.  If 0 use PRIMARY KEY */  } *aCol;          /* One entry for each of nCol column s */  u8 isDeferred;    /* True if constraint checking is deferred till COMMIT */  u8 updateConf;    /* How to resolve conflicts that occur on UPDATE */  u8 deleteConf;    /* How to resolve conflicts that occur on DELETE */  u8 insertConf;    /* How to resolve conflicts that occur on INSERT */};/*** SQLite supports many different ways to resolve a contraint** error.  ROLLBACK processing means that a constraint violation** causes the operation in process to fail and for the current transaction** to be rolled back.  ABORT processing means the operation in process** fails and any prior changes from that one operation are backed out,** but the transaction is not rolled back.  FAIL processing means that** the operation in progress stops and returns an error code.  But prior** changes due to the same operation are not backed out and no rollback** occurs.  IGNORE means that the particular row that caused the constraint** error is not inserted or updated.  Processing continues and no error** is returned.  REPLACE means that preexisting database rows that caused** a UNIQUE constraint violation are removed so that the new insert or** update can proceed.  Processing continues and no error is reported.**** RESTRICT, SETNULL, and CASCADE actions apply only to foreign keys.** RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the** same as ROLLBACK for DEFERRED keys.  SETNULL means that the foreign** key is set to NULL.  CASCADE means that a DELETE or UPDATE of the** referenced table row is propagated into the row that holds the** foreign key.** ** The following symbolic values are used to record which type** of action to take.*/#define OE_None     0   /* There is no constraint to check */#define OE_Rollback 1   /* Fail the operation and rollback the transaction */#define OE_Abort    2   /* Back out changes but do no rollback transaction */#define OE_Fail     3   /* Stop the operation but leave all prior changes */#define OE_Ignore   4   /* Ignore the error. Do not do the INSERT or UPDATE */#define OE_Replace  5   /* Delete existing record, then do INSERT or UPDATE */#define OE_Restrict 6   /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */#define OE_SetNull  7   /* Set the foreign key value to NULL */#define OE_SetDflt  8   /* Set the foreign key value to its default */#define OE_Cascade  9   /* Cascade the changes */#define OE_Default  99  /* Do whatever the default action is *//*** Each SQL index is represented in memory by an** instance of the following structure.**** The columns of the table that are to be indexed are described** by the aiColumn[] field of this structure.  For example, suppose** we have the following table and index:****     CREATE TABLE Ex1(c1 int, c2 int, c3 text);**     CREATE INDEX Ex2 ON Ex1(c3,c1);**** In the Table structure describing Ex1, nCol==3 because there are** three columns in the table.  In the Index structure describing** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed.** The value of aiColumn is {2, 0}.  aiColumn[0]==2 because the ** first column to be indexed (c3) has an index of 2 in Ex1.aCol[].** The second column to be indexed (c1) has an index of 0 in** Ex1.aCol[], hence Ex2.aiColumn[1]==0.**** 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 */  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) */  u8 iDb;          /* Index in sqlite.aDb[] of where this index is stored */  Index *pNext;    /* The next index associated with the same table */};/*** 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

⌨️ 快捷键说明

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