diff options
author | Wez Furlong <wez@php.net> | 2004-07-10 12:27:51 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2004-07-10 12:27:51 +0000 |
commit | e563b4eafa63ba8beb88defa1e36f037a7a97a60 (patch) | |
tree | 2e72dfa1c4b7fe62fde9ab326a67047ba2f4cc9e /ext/sqlite/libsqlite/src/sqliteInt.h | |
parent | cd732f1a3f5df97407797fe7ebb97830552479ad (diff) | |
download | php-git-e563b4eafa63ba8beb88defa1e36f037a7a97a60.tar.gz |
Upgrade bundled library to 2.8.14 + misc fixes
(http://www.sqlite.org/cvstrac/chngview?cn=1742)
Diffstat (limited to 'ext/sqlite/libsqlite/src/sqliteInt.h')
-rw-r--r-- | ext/sqlite/libsqlite/src/sqliteInt.h | 95 |
1 files changed, 72 insertions, 23 deletions
diff --git a/ext/sqlite/libsqlite/src/sqliteInt.h b/ext/sqlite/libsqlite/src/sqliteInt.h index 04a90dccf2..57e3ab6e36 100644 --- a/ext/sqlite/libsqlite/src/sqliteInt.h +++ b/ext/sqlite/libsqlite/src/sqliteInt.h @@ -16,7 +16,6 @@ #include "config.h" #include "sqlite.h" #include "hash.h" -#include "vdbe.h" #include "parse.h" #include "btree.h" #include <stdio.h> @@ -106,6 +105,9 @@ #ifndef UINT8_TYPE # define UINT8_TYPE unsigned char #endif +#ifndef INT8_TYPE +# define INT8_TYPE signed char +#endif #ifndef INTPTR_TYPE # if SQLITE_PTR_SZ==4 # define INTPTR_TYPE int @@ -116,10 +118,16 @@ typedef UINT32_TYPE u32; /* 4-byte unsigned integer */ typedef UINT16_TYPE u16; /* 2-byte unsigned integer */ typedef UINT8_TYPE u8; /* 1-byte unsigned integer */ +typedef UINT8_TYPE i8; /* 1-byte signed integer */ typedef INTPTR_TYPE ptr; /* Big enough to hold a pointer */ typedef unsigned INTPTR_TYPE uptr; /* Big enough to hold a pointer */ /* +** Defer sourcing vdbe.h until after the "u8" typedef is defined. +*/ +#include "vdbe.h" + +/* ** Most C compilers these days recognize "long double", don't they? ** Just in case we encounter one that does not, we will create a macro ** for long double so that it can be easily changed to just "double". @@ -174,6 +182,7 @@ typedef unsigned INTPTR_TYPE uptr; /* Big enough to hold a pointer */ # define sqliteStrNDup(X,Y) sqliteStrNDup_(X,Y,__FILE__,__LINE__) void sqliteStrRealloc(char**); #else +# define sqliteRealloc_(X,Y) sqliteRealloc(X,Y) # define sqliteStrRealloc(X) #endif @@ -254,6 +263,8 @@ struct Db { Hash aFKey; /* Foreign keys indexed by to-table */ u8 inTrans; /* 0: not writable. 1: Transaction. 2: Checkpoint */ u16 flags; /* Flags associated with this database */ + void *pAux; /* Auxiliary data. Usually NULL */ + void (*xFreeAux)(void*); /* Routine to free pAux */ }; /* @@ -307,6 +318,24 @@ struct Db { ** 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 */ @@ -316,18 +345,27 @@ struct sqlite { 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 temp_store; /* 1=file, 2=memory, 0=compile-time default */ 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 */ + int lastRowid; /* ROWID of most recent insert (see above) */ int priorNewRowid; /* Last randomly generated ROWID */ - int onError; /* Default conflict algorithm */ int magic; /* Magic number for detect library misuse */ - int nChange; /* Number of rows changed */ + 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 */ @@ -356,10 +394,11 @@ struct sqlite { #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_CountRows 0x00000040 /* Count rows changed by INSERT, */ +#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 0x00000080 /* Invoke the callback once if the */ +#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 */ @@ -384,10 +423,12 @@ 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 */ - int nArg; /* Number of arguments */ - int dataType; /* Datatype of the result */ - void *pUserData; /* User data parameter */ - FuncDef *pNext; /* Next function with same name */ + 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 */ }; /* @@ -401,6 +442,7 @@ struct 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 */ }; /* @@ -585,6 +627,10 @@ struct 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 char *z; /* Text of the token. Not NULL-terminated! */ @@ -859,8 +905,6 @@ struct AggExpr { struct Parse { sqlite *db; /* The main database structure */ int rc; /* Return code from execution */ - sqlite_callback xCallback; /* The callback function */ - void *pArg; /* First argument to the callback function */ char *zErrMsg; /* An error message */ Token sErrToken; /* The token at which the error occurred */ Token sFirstToken; /* The first token parsed */ @@ -870,13 +914,9 @@ struct Parse { 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 initFlag; /* True if reparsing CREATE TABLEs */ 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 */ - u8 iDb; /* Index of database whose schema is being parsed */ - u8 useCallback; /* True if callbacks should be used to report results */ - int newTnum; /* Table number to use when reparsing CREATE TABLEs */ int nErr; /* Number of errors seen */ int nTab; /* Number of previously allocated VDBE cursors */ int nMem; /* Number of memory cells used so far */ @@ -899,6 +939,13 @@ struct AuthContext { }; /* +** 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. * @@ -1067,7 +1114,8 @@ void sqliteRealToSortable(double r, char *); char *sqliteStrNDup(const char*, int); # define sqliteCheckMemory(a,b) #endif -char *sqliteMPrintf(const char *,...); +char *sqliteMPrintf(const char*, ...); +char *sqliteVMPrintf(const char*, va_list); void sqliteSetString(char **, const char *, ...); void sqliteSetNString(char **, ...); void sqliteErrorMsg(Parse*, const char*, ...); @@ -1126,6 +1174,7 @@ void sqliteUpdate(Parse*, SrcList*, ExprList*, Expr*, int); WhereInfo *sqliteWhereBegin(Parse*, SrcList*, Expr*, int, ExprList**); void sqliteWhereEnd(WhereInfo*); void sqliteExprCode(Parse*, Expr*); +int sqliteExprCodeExprList(Parse*, ExprList*, int); void sqliteExprIfTrue(Parse*, Expr*, int, int); void sqliteExprIfFalse(Parse*, Expr*, int, int); Table *sqliteFindTable(sqlite*,const char*, const char*); @@ -1145,8 +1194,7 @@ int sqliteFuncId(Token*); int sqliteExprResolveIds(Parse*, SrcList*, ExprList*, Expr*); int sqliteExprAnalyzeAggregates(Parse*, Expr*); Vdbe *sqliteGetVdbe(Parse*); -int sqliteRandomByte(void); -int sqliteRandomInteger(void); +void sqliteRandomness(int, void*); void sqliteRollbackAll(sqlite*); void sqliteCodeVerifySchema(Parse*, int); void sqliteBeginTransaction(Parse*, int); @@ -1159,6 +1207,7 @@ void sqliteGenerateRowDelete(sqlite*, Vdbe*, Table*, int, int); void sqliteGenerateRowIndexDelete(sqlite*, Vdbe*, Table*, int, char*); void sqliteGenerateConstraintChecks(Parse*,Table*,int,char*,int,int,int,int); void sqliteCompleteInsertion(Parse*, Table*, int, char*, int, int, int); +int sqliteOpenTableAndIndices(Parse*, Table*, int); void sqliteBeginWriteOperation(Parse*, int, int); void sqliteEndWriteOperation(Parse*); Expr *sqliteExprDup(Expr*); @@ -1202,7 +1251,7 @@ void sqliteDeferForeignKey(Parse*, int); # define sqliteAuthContextPush(a,b,c) # define sqliteAuthContextPop(a) ((void)(a)) #endif -void sqliteAttach(Parse*, Token*, Token*); +void sqliteAttach(Parse*, Token*, Token*, Token*); void sqliteDetach(Parse*, Token*); int sqliteBtreeFactory(const sqlite *db, const char *zFilename, int mode, int nPg, Btree **ppBtree); @@ -1212,6 +1261,6 @@ int sqliteFixSelect(DbFixer*, Select*); int sqliteFixExpr(DbFixer*, Expr*); int sqliteFixExprList(DbFixer*, ExprList*); int sqliteFixTriggerStep(DbFixer*, TriggerStep*); -double sqliteAtoF(const char *z); -int sqlite_snprintf(int,char*,const char*,...); +double sqliteAtoF(const char *z, const char **); +char *sqlite_snprintf(int,char*,const char*,...); int sqliteFitsIn32Bits(const char *); |