| | @@ -381,11 +381,11 @@ |
| 381 | 381 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 382 | 382 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 383 | 383 | */ |
| 384 | 384 | #define SQLITE_VERSION "3.15.0" |
| 385 | 385 | #define SQLITE_VERSION_NUMBER 3015000 |
| 386 | | -#define SQLITE_SOURCE_ID "2016-09-28 16:05:53 40c0fb0af678797c39a99853f9f4102464c16f4b" |
| 386 | +#define SQLITE_SOURCE_ID "2016-10-01 23:55:23 fe07609efc31c4639c40fbda501c55f443756ad2" |
| 387 | 387 | |
| 388 | 388 | /* |
| 389 | 389 | ** CAPI3REF: Run-Time Library Version Numbers |
| 390 | 390 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 391 | 391 | ** |
| | @@ -15515,39 +15515,27 @@ |
| 15515 | 15515 | u8 mayAbort; /* True if statement may throw an ABORT exception */ |
| 15516 | 15516 | u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */ |
| 15517 | 15517 | u8 okConstFactor; /* OK to factor out constants */ |
| 15518 | 15518 | u8 disableLookaside; /* Number of times lookaside has been disabled */ |
| 15519 | 15519 | u8 nColCache; /* Number of entries in aColCache[] */ |
| 15520 | | - int aTempReg[8]; /* Holding area for temporary registers */ |
| 15521 | 15520 | int nRangeReg; /* Size of the temporary register block */ |
| 15522 | 15521 | int iRangeReg; /* First register in temporary register block */ |
| 15523 | 15522 | int nErr; /* Number of errors seen */ |
| 15524 | 15523 | int nTab; /* Number of previously allocated VDBE cursors */ |
| 15525 | 15524 | int nMem; /* Number of memory cells used so far */ |
| 15526 | | - int nSet; /* Number of sets used so far */ |
| 15527 | 15525 | int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */ |
| 15528 | 15526 | int szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */ |
| 15529 | | - int iFixedOp; /* Never back out opcodes iFixedOp-1 or earlier */ |
| 15530 | 15527 | int ckBase; /* Base register of data during check constraints */ |
| 15531 | 15528 | int iSelfTab; /* Table of an index whose exprs are being coded */ |
| 15532 | 15529 | int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */ |
| 15533 | 15530 | int iCacheCnt; /* Counter used to generate aColCache[].lru values */ |
| 15534 | 15531 | int nLabel; /* Number of labels used */ |
| 15535 | 15532 | int *aLabel; /* Space to hold the labels */ |
| 15536 | | - struct yColCache { |
| 15537 | | - int iTable; /* Table cursor number */ |
| 15538 | | - i16 iColumn; /* Table column number */ |
| 15539 | | - u8 tempReg; /* iReg is a temp register that needs to be freed */ |
| 15540 | | - int iLevel; /* Nesting level */ |
| 15541 | | - int iReg; /* Reg with value of this column. 0 means none. */ |
| 15542 | | - int lru; /* Least recently used entry has the smallest value */ |
| 15543 | | - } aColCache[SQLITE_N_COLCACHE]; /* One for each column cache entry */ |
| 15544 | 15533 | ExprList *pConstExpr;/* Constant expressions */ |
| 15545 | 15534 | Token constraintName;/* Name of the constraint currently being parsed */ |
| 15546 | 15535 | yDbMask writeMask; /* Start a write transaction on these databases */ |
| 15547 | 15536 | yDbMask cookieMask; /* Bitmask of schema verified databases */ |
| 15548 | | - int cookieValue[SQLITE_MAX_ATTACHED+2]; /* Values of cookies to verify */ |
| 15549 | 15537 | int regRowid; /* Register holding rowid of CREATE TABLE entry */ |
| 15550 | 15538 | int regRoot; /* Register holding root page number for new objects */ |
| 15551 | 15539 | int nMaxArg; /* Max args passed to user function by sub-program */ |
| 15552 | 15540 | #if SELECTTRACE_ENABLED |
| 15553 | 15541 | int nSelect; /* Number of SELECT statements seen */ |
| | @@ -15556,21 +15544,38 @@ |
| 15556 | 15544 | #ifndef SQLITE_OMIT_SHARED_CACHE |
| 15557 | 15545 | int nTableLock; /* Number of locks in aTableLock */ |
| 15558 | 15546 | TableLock *aTableLock; /* Required table locks for shared-cache mode */ |
| 15559 | 15547 | #endif |
| 15560 | 15548 | AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */ |
| 15561 | | - |
| 15562 | | - /* Information used while coding trigger programs. */ |
| 15563 | 15549 | Parse *pToplevel; /* Parse structure for main program (or NULL) */ |
| 15564 | 15550 | Table *pTriggerTab; /* Table triggers are being coded for */ |
| 15565 | 15551 | int addrCrTab; /* Address of OP_CreateTable opcode on CREATE TABLE */ |
| 15566 | 15552 | u32 nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */ |
| 15567 | 15553 | u32 oldmask; /* Mask of old.* columns referenced */ |
| 15568 | 15554 | u32 newmask; /* Mask of new.* columns referenced */ |
| 15569 | 15555 | u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */ |
| 15570 | 15556 | u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */ |
| 15571 | 15557 | u8 disableTriggers; /* True to disable triggers */ |
| 15558 | + |
| 15559 | + /************************************************************************** |
| 15560 | + ** Fields above must be initialized to zero. The fields that follow, |
| 15561 | + ** down to the beginning of the recursive section, do not need to be |
| 15562 | + ** initialized as they will be set before being used. The boundary is |
| 15563 | + ** determined by offsetof(Parse,aColCache). |
| 15564 | + **************************************************************************/ |
| 15565 | + |
| 15566 | + struct yColCache { |
| 15567 | + int iTable; /* Table cursor number */ |
| 15568 | + i16 iColumn; /* Table column number */ |
| 15569 | + u8 tempReg; /* iReg is a temp register that needs to be freed */ |
| 15570 | + int iLevel; /* Nesting level */ |
| 15571 | + int iReg; /* Reg with value of this column. 0 means none. */ |
| 15572 | + int lru; /* Least recently used entry has the smallest value */ |
| 15573 | + } aColCache[SQLITE_N_COLCACHE]; /* One for each column cache entry */ |
| 15574 | + int aTempReg[8]; /* Holding area for temporary registers */ |
| 15575 | + Token sNameToken; /* Token with unqualified schema object name */ |
| 15576 | + Token sLastToken; /* The last token parsed */ |
| 15572 | 15577 | |
| 15573 | 15578 | /************************************************************************ |
| 15574 | 15579 | ** Above is constant between recursions. Below is reset before and after |
| 15575 | 15580 | ** each recursion. The boundary between these two regions is determined |
| 15576 | 15581 | ** using offsetof(Parse,nVar) so the nVar field must be the first field |
| | @@ -15583,11 +15588,10 @@ |
| 15583 | 15588 | u8 explain; /* True if the EXPLAIN flag is found on the query */ |
| 15584 | 15589 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 15585 | 15590 | u8 declareVtab; /* True if inside sqlite3_declare_vtab() */ |
| 15586 | 15591 | int nVtabLock; /* Number of virtual tables to lock */ |
| 15587 | 15592 | #endif |
| 15588 | | - int nAlias; /* Number of aliased result set columns */ |
| 15589 | 15593 | int nHeight; /* Expression tree height of current sub-select */ |
| 15590 | 15594 | #ifndef SQLITE_OMIT_EXPLAIN |
| 15591 | 15595 | int iSelectId; /* ID of current select for EXPLAIN output */ |
| 15592 | 15596 | int iNextSelectId; /* Next available select ID for EXPLAIN output */ |
| 15593 | 15597 | #endif |
| | @@ -15595,12 +15599,10 @@ |
| 15595 | 15599 | Vdbe *pReprepare; /* VM being reprepared (sqlite3Reprepare()) */ |
| 15596 | 15600 | const char *zTail; /* All SQL text past the last semicolon parsed */ |
| 15597 | 15601 | Table *pNewTable; /* A table being constructed by CREATE TABLE */ |
| 15598 | 15602 | Trigger *pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */ |
| 15599 | 15603 | const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */ |
| 15600 | | - Token sNameToken; /* Token with unqualified schema object name */ |
| 15601 | | - Token sLastToken; /* The last token parsed */ |
| 15602 | 15604 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 15603 | 15605 | Token sArg; /* Complete text of a module argument */ |
| 15604 | 15606 | Table **apVtabLock; /* Pointer to virtual tables needing locking */ |
| 15605 | 15607 | #endif |
| 15606 | 15608 | Table *pZombieTab; /* List of Table objects to delete after code gen */ |
| | @@ -15607,10 +15609,18 @@ |
| 15607 | 15609 | TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */ |
| 15608 | 15610 | With *pWith; /* Current WITH clause, or NULL */ |
| 15609 | 15611 | With *pWithToFree; /* Free this WITH object at the end of the parse */ |
| 15610 | 15612 | }; |
| 15611 | 15613 | |
| 15614 | +/* |
| 15615 | +** Sizes and pointers of various parts of the Parse object. |
| 15616 | +*/ |
| 15617 | +#define PARSE_HDR_SZ offsetof(Parse,aColCache) /* Recursive part w/o aColCache*/ |
| 15618 | +#define PARSE_RECURSE_SZ offsetof(Parse,nVar) /* Recursive part */ |
| 15619 | +#define PARSE_TAIL_SZ (sizeof(Parse)-PARSE_RECURSE_SZ) /* Non-recursive part */ |
| 15620 | +#define PARSE_TAIL(X) (((char*)(X))+PARSE_RECURSE_SZ) /* Pointer to tail */ |
| 15621 | + |
| 15612 | 15622 | /* |
| 15613 | 15623 | ** Return true if currently inside an sqlite3_declare_vtab() call. |
| 15614 | 15624 | */ |
| 15615 | 15625 | #ifdef SQLITE_OMIT_VIRTUALTABLE |
| 15616 | 15626 | #define IN_DECLARE_VTAB 0 |
| | @@ -16990,20 +17000,17 @@ |
| 16990 | 17000 | ** If x is a lower-case ASCII character, then its upper-case equivalent |
| 16991 | 17001 | ** is (x - 0x20). Therefore toupper() can be implemented as: |
| 16992 | 17002 | ** |
| 16993 | 17003 | ** (x & ~(map[x]&0x20)) |
| 16994 | 17004 | ** |
| 16995 | | -** Standard function tolower() is implemented using the sqlite3UpperToLower[] |
| 17005 | +** The equivalent of tolower() is implemented using the sqlite3UpperToLower[] |
| 16996 | 17006 | ** array. tolower() is used more often than toupper() by SQLite. |
| 16997 | 17007 | ** |
| 16998 | | -** Bit 0x40 is set if the character non-alphanumeric and can be used in an |
| 17008 | +** Bit 0x40 is set if the character is non-alphanumeric and can be used in an |
| 16999 | 17009 | ** SQLite identifier. Identifiers are alphanumerics, "_", "$", and any |
| 17000 | 17010 | ** non-ASCII UTF character. Hence the test for whether or not a character is |
| 17001 | 17011 | ** part of an identifier is 0x46. |
| 17002 | | -** |
| 17003 | | -** SQLite's versions are identical to the standard versions assuming a |
| 17004 | | -** locale of "C". They are implemented as macros in sqliteInt.h. |
| 17005 | 17012 | */ |
| 17006 | 17013 | #ifdef SQLITE_ASCII |
| 17007 | 17014 | SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[256] = { |
| 17008 | 17015 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00..07 ........ */ |
| 17009 | 17016 | 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, /* 08..0f ........ */ |
| | @@ -17072,11 +17079,11 @@ |
| 17072 | 17079 | #ifndef SQLITE_SORTER_PMASZ |
| 17073 | 17080 | # define SQLITE_SORTER_PMASZ 250 |
| 17074 | 17081 | #endif |
| 17075 | 17082 | |
| 17076 | 17083 | /* Statement journals spill to disk when their size exceeds the following |
| 17077 | | -** threashold (in bytes). 0 means that statement journals are created and |
| 17084 | +** threshold (in bytes). 0 means that statement journals are created and |
| 17078 | 17085 | ** written to disk immediately (the default behavior for SQLite versions |
| 17079 | 17086 | ** before 3.12.0). -1 means always keep the entire statement journal in |
| 17080 | 17087 | ** memory. (The statement journal is also always held entirely in memory |
| 17081 | 17088 | ** if journal_mode=MEMORY or if temp_store=MEMORY, regardless of this |
| 17082 | 17089 | ** setting.) |
| | @@ -17160,11 +17167,11 @@ |
| 17160 | 17167 | |
| 17161 | 17168 | /* |
| 17162 | 17169 | ** The value of the "pending" byte must be 0x40000000 (1 byte past the |
| 17163 | 17170 | ** 1-gibabyte boundary) in a compatible database. SQLite never uses |
| 17164 | 17171 | ** the database page that contains the pending byte. It never attempts |
| 17165 | | -** to read or write that page. The pending byte page is set assign |
| 17172 | +** to read or write that page. The pending byte page is set aside |
| 17166 | 17173 | ** for use by the VFS layers as space for managing file locks. |
| 17167 | 17174 | ** |
| 17168 | 17175 | ** During testing, it is often desirable to move the pending byte to |
| 17169 | 17176 | ** a different position in the file. This allows code that has to |
| 17170 | 17177 | ** deal with the pending byte to run on files that are much smaller |
| | @@ -17720,13 +17727,10 @@ |
| 17720 | 17727 | typedef unsigned Bool; |
| 17721 | 17728 | |
| 17722 | 17729 | /* Opaque type used by code in vdbesort.c */ |
| 17723 | 17730 | typedef struct VdbeSorter VdbeSorter; |
| 17724 | 17731 | |
| 17725 | | -/* Opaque type used by the explainer */ |
| 17726 | | -typedef struct Explain Explain; |
| 17727 | | - |
| 17728 | 17732 | /* Elements of the linked list at Vdbe.pAuxData */ |
| 17729 | 17733 | typedef struct AuxData AuxData; |
| 17730 | 17734 | |
| 17731 | 17735 | /* Types of VDBE cursors */ |
| 17732 | 17736 | #define CURTYPE_BTREE 0 |
| | @@ -17797,10 +17801,16 @@ |
| 17797 | 17801 | /* 2*nField extra array elements allocated for aType[], beyond the one |
| 17798 | 17802 | ** static element declared in the structure. nField total array slots for |
| 17799 | 17803 | ** aType[] and nField+1 array slots for aOffset[] */ |
| 17800 | 17804 | }; |
| 17801 | 17805 | |
| 17806 | + |
| 17807 | +/* |
| 17808 | +** A value for VdbeCursor.cacheStatus that means the cache is always invalid. |
| 17809 | +*/ |
| 17810 | +#define CACHE_STALE 0 |
| 17811 | + |
| 17802 | 17812 | /* |
| 17803 | 17813 | ** When a sub-program is executed (OP_Program), a structure of this type |
| 17804 | 17814 | ** is allocated to store the current value of the program counter, as |
| 17805 | 17815 | ** well as the current memory cell array and various other frame specific |
| 17806 | 17816 | ** values stored in the Vdbe struct. When the sub-program is finished, |
| | @@ -17841,15 +17851,10 @@ |
| 17841 | 17851 | int nDbChange; /* Value of db->nChange */ |
| 17842 | 17852 | }; |
| 17843 | 17853 | |
| 17844 | 17854 | #define VdbeFrameMem(p) ((Mem *)&((u8 *)p)[ROUND8(sizeof(VdbeFrame))]) |
| 17845 | 17855 | |
| 17846 | | -/* |
| 17847 | | -** A value for VdbeCursor.cacheValid that means the cache is always invalid. |
| 17848 | | -*/ |
| 17849 | | -#define CACHE_STALE 0 |
| 17850 | | - |
| 17851 | 17856 | /* |
| 17852 | 17857 | ** Internally, the vdbe manipulates nearly all SQL values as Mem |
| 17853 | 17858 | ** structures. Each Mem struct may cache multiple representations (string, |
| 17854 | 17859 | ** integer etc.) of the same value. |
| 17855 | 17860 | */ |
| | @@ -17986,22 +17991,10 @@ |
| 17986 | 17991 | u8 fErrorOrAux; /* isError!=0 or pVdbe->pAuxData modified */ |
| 17987 | 17992 | u8 argc; /* Number of arguments */ |
| 17988 | 17993 | sqlite3_value *argv[1]; /* Argument set */ |
| 17989 | 17994 | }; |
| 17990 | 17995 | |
| 17991 | | -/* |
| 17992 | | -** An Explain object accumulates indented output which is helpful |
| 17993 | | -** in describing recursive data structures. |
| 17994 | | -*/ |
| 17995 | | -struct Explain { |
| 17996 | | - Vdbe *pVdbe; /* Attach the explanation to this Vdbe */ |
| 17997 | | - StrAccum str; /* The string being accumulated */ |
| 17998 | | - int nIndent; /* Number of elements in aIndent */ |
| 17999 | | - u16 aIndent[100]; /* Levels of indentation */ |
| 18000 | | - char zBase[100]; /* Initial space */ |
| 18001 | | -}; |
| 18002 | | - |
| 18003 | 17996 | /* A bitfield type for use inside of structures. Always follow with :N where |
| 18004 | 17997 | ** N is the number of bits. |
| 18005 | 17998 | */ |
| 18006 | 17999 | typedef unsigned bft; /* Bit Field Type */ |
| 18007 | 18000 | |
| | @@ -18022,57 +18015,61 @@ |
| 18022 | 18015 | ** The "sqlite3_stmt" structure pointer that is returned by sqlite3_prepare() |
| 18023 | 18016 | ** is really a pointer to an instance of this structure. |
| 18024 | 18017 | */ |
| 18025 | 18018 | struct Vdbe { |
| 18026 | 18019 | sqlite3 *db; /* The database connection that owns this statement */ |
| 18020 | + Vdbe *pPrev,*pNext; /* Linked list of VDBEs with the same Vdbe.db */ |
| 18021 | + Parse *pParse; /* Parsing context used to create this Vdbe */ |
| 18022 | + ynVar nVar; /* Number of entries in aVar[] */ |
| 18023 | + ynVar nzVar; /* Number of entries in azVar[] */ |
| 18024 | + u32 magic; /* Magic number for sanity checking */ |
| 18025 | + int nMem; /* Number of memory locations currently allocated */ |
| 18026 | + int nCursor; /* Number of slots in apCsr[] */ |
| 18027 | + u32 cacheCtr; /* VdbeCursor row cache generation counter */ |
| 18028 | + int pc; /* The program counter */ |
| 18029 | + int rc; /* Value to return */ |
| 18030 | + int nChange; /* Number of db changes made since last reset */ |
| 18031 | + int iStatement; /* Statement number (or 0 if has not opened stmt) */ |
| 18032 | + i64 iCurrentTime; /* Value of julianday('now') for this statement */ |
| 18033 | + i64 nFkConstraint; /* Number of imm. FK constraints this VM */ |
| 18034 | + i64 nStmtDefCons; /* Number of def. constraints when stmt started */ |
| 18035 | + i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */ |
| 18036 | + |
| 18037 | + /* When allocating a new Vdbe object, all of the fields below should be |
| 18038 | + ** initialized to zero or NULL */ |
| 18039 | + |
| 18027 | 18040 | Op *aOp; /* Space to hold the virtual machine's program */ |
| 18028 | 18041 | Mem *aMem; /* The memory locations */ |
| 18029 | 18042 | Mem **apArg; /* Arguments to currently executing user function */ |
| 18030 | 18043 | Mem *aColName; /* Column names to return */ |
| 18031 | 18044 | Mem *pResultSet; /* Pointer to an array of results */ |
| 18032 | | - Parse *pParse; /* Parsing context used to create this Vdbe */ |
| 18033 | | - int nMem; /* Number of memory locations currently allocated */ |
| 18034 | | - int nOp; /* Number of instructions in the program */ |
| 18035 | | - int nCursor; /* Number of slots in apCsr[] */ |
| 18036 | | - u32 magic; /* Magic number for sanity checking */ |
| 18037 | 18045 | char *zErrMsg; /* Error message written here */ |
| 18038 | | - Vdbe *pPrev,*pNext; /* Linked list of VDBEs with the same Vdbe.db */ |
| 18039 | 18046 | VdbeCursor **apCsr; /* One element of this array for each open cursor */ |
| 18040 | 18047 | Mem *aVar; /* Values for the OP_Variable opcode. */ |
| 18041 | 18048 | char **azVar; /* Name of variables */ |
| 18042 | | - ynVar nVar; /* Number of entries in aVar[] */ |
| 18043 | | - ynVar nzVar; /* Number of entries in azVar[] */ |
| 18044 | | - u32 cacheCtr; /* VdbeCursor row cache generation counter */ |
| 18045 | | - int pc; /* The program counter */ |
| 18046 | | - int rc; /* Value to return */ |
| 18049 | +#ifndef SQLITE_OMIT_TRACE |
| 18050 | + i64 startTime; /* Time when query started - used for profiling */ |
| 18051 | +#endif |
| 18052 | + int nOp; /* Number of instructions in the program */ |
| 18047 | 18053 | #ifdef SQLITE_DEBUG |
| 18048 | 18054 | int rcApp; /* errcode set by sqlite3_result_error_code() */ |
| 18049 | 18055 | #endif |
| 18050 | 18056 | u16 nResColumn; /* Number of columns in one row of the result set */ |
| 18051 | 18057 | u8 errorAction; /* Recovery action to do in case of an error */ |
| 18058 | + u8 minWriteFileFormat; /* Minimum file format for writable database files */ |
| 18052 | 18059 | bft expired:1; /* True if the VM needs to be recompiled */ |
| 18053 | 18060 | bft doingRerun:1; /* True if rerunning after an auto-reprepare */ |
| 18054 | | - u8 minWriteFileFormat; /* Minimum file format for writable database files */ |
| 18055 | 18061 | bft explain:2; /* True if EXPLAIN present on SQL command */ |
| 18056 | 18062 | bft changeCntOn:1; /* True to update the change-counter */ |
| 18057 | 18063 | bft runOnlyOnce:1; /* Automatically expire on reset */ |
| 18058 | 18064 | bft usesStmtJournal:1; /* True if uses a statement journal */ |
| 18059 | 18065 | bft readOnly:1; /* True for statements that do not write */ |
| 18060 | 18066 | bft bIsReader:1; /* True for statements that read */ |
| 18061 | 18067 | bft isPrepareV2:1; /* True if prepared with prepare_v2() */ |
| 18062 | | - int nChange; /* Number of db changes made since last reset */ |
| 18063 | 18068 | yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */ |
| 18064 | 18069 | yDbMask lockMask; /* Subset of btreeMask that requires a lock */ |
| 18065 | | - int iStatement; /* Statement number (or 0 if has not opened stmt) */ |
| 18066 | 18070 | u32 aCounter[5]; /* Counters used by sqlite3_stmt_status() */ |
| 18067 | | -#ifndef SQLITE_OMIT_TRACE |
| 18068 | | - i64 startTime; /* Time when query started - used for profiling */ |
| 18069 | | -#endif |
| 18070 | | - i64 iCurrentTime; /* Value of julianday('now') for this statement */ |
| 18071 | | - i64 nFkConstraint; /* Number of imm. FK constraints this VM */ |
| 18072 | | - i64 nStmtDefCons; /* Number of def. constraints when stmt started */ |
| 18073 | | - i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */ |
| 18074 | 18071 | char *zSql; /* Text of the SQL statement that generated this */ |
| 18075 | 18072 | void *pFree; /* Free this when deleting the vdbe */ |
| 18076 | 18073 | VdbeFrame *pFrame; /* Parent frame */ |
| 18077 | 18074 | VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */ |
| 18078 | 18075 | int nFrame; /* Number of frames in pFrame list */ |
| | @@ -18087,14 +18084,15 @@ |
| 18087 | 18084 | }; |
| 18088 | 18085 | |
| 18089 | 18086 | /* |
| 18090 | 18087 | ** The following are allowed values for Vdbe.magic |
| 18091 | 18088 | */ |
| 18092 | | -#define VDBE_MAGIC_INIT 0x26bceaa5 /* Building a VDBE program */ |
| 18093 | | -#define VDBE_MAGIC_RUN 0xbdf20da3 /* VDBE is ready to execute */ |
| 18094 | | -#define VDBE_MAGIC_HALT 0x519c2973 /* VDBE has completed execution */ |
| 18095 | | -#define VDBE_MAGIC_DEAD 0xb606c3c8 /* The VDBE has been deallocated */ |
| 18089 | +#define VDBE_MAGIC_INIT 0x16bceaa5 /* Building a VDBE program */ |
| 18090 | +#define VDBE_MAGIC_RUN 0x2df20da3 /* VDBE is ready to execute */ |
| 18091 | +#define VDBE_MAGIC_HALT 0x319c2973 /* VDBE has completed execution */ |
| 18092 | +#define VDBE_MAGIC_RESET 0x48fa9f76 /* Reset and ready to run again */ |
| 18093 | +#define VDBE_MAGIC_DEAD 0x5606c3c8 /* The VDBE has been deallocated */ |
| 18096 | 18094 | |
| 18097 | 18095 | /* |
| 18098 | 18096 | ** Structure used to store the context required by the |
| 18099 | 18097 | ** sqlite3_preupdate_*() API functions. |
| 18100 | 18098 | */ |
| | @@ -28776,11 +28774,15 @@ |
| 28776 | 28774 | */ |
| 28777 | 28775 | static unsigned int strHash(const char *z){ |
| 28778 | 28776 | unsigned int h = 0; |
| 28779 | 28777 | unsigned char c; |
| 28780 | 28778 | while( (c = (unsigned char)*z++)!=0 ){ /*OPTIMIZATION-IF-TRUE*/ |
| 28781 | | - h = (h<<3) ^ h ^ sqlite3UpperToLower[c]; |
| 28779 | + /* Knuth multiplicative hashing. (Sorting & Searching, p. 510). |
| 28780 | + ** 0x9e3779b1 is 2654435761 which is the closest prime number to |
| 28781 | + ** (2**32)*golden_ratio, where golden_ratio = (sqrt(5) - 1)/2. */ |
| 28782 | + h += sqlite3UpperToLower[c]; |
| 28783 | + h *= 0x9e3779b1; |
| 28782 | 28784 | } |
| 28783 | 28785 | return h; |
| 28784 | 28786 | } |
| 28785 | 28787 | |
| 28786 | 28788 | |
| | @@ -44019,11 +44021,11 @@ |
| 44019 | 44021 | ){ |
| 44020 | 44022 | PgHdr *pPgHdr; |
| 44021 | 44023 | assert( pPage!=0 ); |
| 44022 | 44024 | pPgHdr = (PgHdr*)pPage->pExtra; |
| 44023 | 44025 | assert( pPgHdr->pPage==0 ); |
| 44024 | | - memset(pPgHdr, 0, sizeof(PgHdr)); |
| 44026 | + memset(&pPgHdr->pDirty, 0, sizeof(PgHdr) - offsetof(PgHdr,pDirty)); |
| 44025 | 44027 | pPgHdr->pPage = pPage; |
| 44026 | 44028 | pPgHdr->pData = pPage->pBuf; |
| 44027 | 44029 | pPgHdr->pExtra = (void *)&pPgHdr[1]; |
| 44028 | 44030 | memset(pPgHdr->pExtra, 0, pCache->szExtra); |
| 44029 | 44031 | pPgHdr->pCache = pCache; |
| | @@ -69042,10 +69044,11 @@ |
| 69042 | 69044 | assert( (pMem->flags&MEM_RowSet)==0 ); |
| 69043 | 69045 | assert( EIGHT_BYTE_ALIGNMENT(pMem) ); |
| 69044 | 69046 | |
| 69045 | 69047 | |
| 69046 | 69048 | if( sqlite3VdbeMemClearAndResize(pMem, nByte) ){ |
| 69049 | + pMem->enc = 0; |
| 69047 | 69050 | return SQLITE_NOMEM_BKPT; |
| 69048 | 69051 | } |
| 69049 | 69052 | |
| 69050 | 69053 | /* For a Real or Integer, use sqlite3_snprintf() to produce the UTF-8 |
| 69051 | 69054 | ** string representation of the value. Then, if the required encoding |
| | @@ -70018,14 +70021,11 @@ |
| 70018 | 70021 | sqlite3_value *pVal = 0; |
| 70019 | 70022 | int negInt = 1; |
| 70020 | 70023 | const char *zNeg = ""; |
| 70021 | 70024 | int rc = SQLITE_OK; |
| 70022 | 70025 | |
| 70023 | | - if( !pExpr ){ |
| 70024 | | - *ppVal = 0; |
| 70025 | | - return SQLITE_OK; |
| 70026 | | - } |
| 70026 | + assert( pExpr!=0 ); |
| 70027 | 70027 | while( (op = pExpr->op)==TK_UPLUS || op==TK_SPAN ) pExpr = pExpr->pLeft; |
| 70028 | 70028 | if( NEVER(op==TK_REGISTER) ) op = pExpr->op2; |
| 70029 | 70029 | |
| 70030 | 70030 | /* Compressed expressions only appear when parsing the DEFAULT clause |
| 70031 | 70031 | ** on a table column definition, and hence only when pCtx==0. This |
| | @@ -70145,11 +70145,11 @@ |
| 70145 | 70145 | Expr *pExpr, /* The expression to evaluate */ |
| 70146 | 70146 | u8 enc, /* Encoding to use */ |
| 70147 | 70147 | u8 affinity, /* Affinity to use */ |
| 70148 | 70148 | sqlite3_value **ppVal /* Write the new value here */ |
| 70149 | 70149 | ){ |
| 70150 | | - return valueFromExpr(db, pExpr, enc, affinity, ppVal, 0); |
| 70150 | + return pExpr ? valueFromExpr(db, pExpr, enc, affinity, ppVal, 0) : 0; |
| 70151 | 70151 | } |
| 70152 | 70152 | |
| 70153 | 70153 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 70154 | 70154 | /* |
| 70155 | 70155 | ** The implementation of the sqlite_record() function. This function accepts |
| | @@ -70488,12 +70488,13 @@ |
| 70488 | 70488 | ** Create a new virtual database engine. |
| 70489 | 70489 | */ |
| 70490 | 70490 | SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse *pParse){ |
| 70491 | 70491 | sqlite3 *db = pParse->db; |
| 70492 | 70492 | Vdbe *p; |
| 70493 | | - p = sqlite3DbMallocZero(db, sizeof(Vdbe) ); |
| 70493 | + p = sqlite3DbMallocRawNN(db, sizeof(Vdbe) ); |
| 70494 | 70494 | if( p==0 ) return 0; |
| 70495 | + memset(&p->aOp, 0, sizeof(Vdbe)-offsetof(Vdbe,aOp)); |
| 70495 | 70496 | p->db = db; |
| 70496 | 70497 | if( db->pVdbe ){ |
| 70497 | 70498 | db->pVdbe->pPrev = p; |
| 70498 | 70499 | } |
| 70499 | 70500 | p->pNext = db->pVdbe; |
| | @@ -70651,13 +70652,12 @@ |
| 70651 | 70652 | #endif |
| 70652 | 70653 | #ifdef SQLITE_DEBUG |
| 70653 | 70654 | if( p->db->flags & SQLITE_VdbeAddopTrace ){ |
| 70654 | 70655 | int jj, kk; |
| 70655 | 70656 | Parse *pParse = p->pParse; |
| 70656 | | - for(jj=kk=0; jj<SQLITE_N_COLCACHE; jj++){ |
| 70657 | + for(jj=kk=0; jj<pParse->nColCache; jj++){ |
| 70657 | 70658 | struct yColCache *x = pParse->aColCache + jj; |
| 70658 | | - if( x->iLevel>pParse->iCacheLevel || x->iReg==0 ) continue; |
| 70659 | 70659 | printf(" r[%d]={%d:%d}", x->iReg, x->iTable, x->iColumn); |
| 70660 | 70660 | kk++; |
| 70661 | 70661 | } |
| 70662 | 70662 | if( kk ) printf("\n"); |
| 70663 | 70663 | sqlite3VdbePrintOp(0, i, &p->aOp[i]); |
| | @@ -70841,11 +70841,10 @@ |
| 70841 | 70841 | assert( j<p->nLabel ); |
| 70842 | 70842 | assert( j>=0 ); |
| 70843 | 70843 | if( p->aLabel ){ |
| 70844 | 70844 | p->aLabel[j] = v->nOp; |
| 70845 | 70845 | } |
| 70846 | | - p->iFixedOp = v->nOp - 1; |
| 70847 | 70846 | } |
| 70848 | 70847 | |
| 70849 | 70848 | /* |
| 70850 | 70849 | ** Mark the VDBE as one that can only be run one time. |
| 70851 | 70850 | */ |
| | @@ -71232,19 +71231,19 @@ |
| 71232 | 71231 | } |
| 71233 | 71232 | SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe *p, u32 addr, int val){ |
| 71234 | 71233 | sqlite3VdbeGetOp(p,addr)->p3 = val; |
| 71235 | 71234 | } |
| 71236 | 71235 | SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe *p, u8 p5){ |
| 71237 | | - if( !p->db->mallocFailed ) p->aOp[p->nOp-1].p5 = p5; |
| 71236 | + assert( p->nOp>0 || p->db->mallocFailed ); |
| 71237 | + if( p->nOp>0 ) p->aOp[p->nOp-1].p5 = p5; |
| 71238 | 71238 | } |
| 71239 | 71239 | |
| 71240 | 71240 | /* |
| 71241 | 71241 | ** Change the P2 operand of instruction addr so that it points to |
| 71242 | 71242 | ** the address of the next instruction to be coded. |
| 71243 | 71243 | */ |
| 71244 | 71244 | SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){ |
| 71245 | | - p->pParse->iFixedOp = p->nOp - 1; |
| 71246 | 71245 | sqlite3VdbeChangeP2(p, addr, p->nOp); |
| 71247 | 71246 | } |
| 71248 | 71247 | |
| 71249 | 71248 | |
| 71250 | 71249 | /* |
| | @@ -71363,11 +71362,11 @@ |
| 71363 | 71362 | /* |
| 71364 | 71363 | ** If the last opcode is "op" and it is not a jump destination, |
| 71365 | 71364 | ** then remove it. Return true if and only if an opcode was removed. |
| 71366 | 71365 | */ |
| 71367 | 71366 | SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe *p, u8 op){ |
| 71368 | | - if( (p->nOp-1)>(p->pParse->iFixedOp) && p->aOp[p->nOp-1].opcode==op ){ |
| 71367 | + if( p->nOp>0 && p->aOp[p->nOp-1].opcode==op ){ |
| 71369 | 71368 | return sqlite3VdbeChangeToNoop(p, p->nOp-1); |
| 71370 | 71369 | }else{ |
| 71371 | 71370 | return 0; |
| 71372 | 71371 | } |
| 71373 | 71372 | } |
| | @@ -71925,10 +71924,25 @@ |
| 71925 | 71924 | zCom |
| 71926 | 71925 | ); |
| 71927 | 71926 | fflush(pOut); |
| 71928 | 71927 | } |
| 71929 | 71928 | #endif |
| 71929 | + |
| 71930 | +/* |
| 71931 | +** Initialize an array of N Mem element. |
| 71932 | +*/ |
| 71933 | +static void initMemArray(Mem *p, int N, sqlite3 *db, u16 flags){ |
| 71934 | + while( (N--)>0 ){ |
| 71935 | + p->db = db; |
| 71936 | + p->flags = flags; |
| 71937 | + p->szMalloc = 0; |
| 71938 | +#ifdef SQLITE_DEBUG |
| 71939 | + p->pScopyFrom = 0; |
| 71940 | +#endif |
| 71941 | + p++; |
| 71942 | + } |
| 71943 | +} |
| 71930 | 71944 | |
| 71931 | 71945 | /* |
| 71932 | 71946 | ** Release an array of N Mem elements |
| 71933 | 71947 | */ |
| 71934 | 71948 | static void releaseMemArray(Mem *p, int N){ |
| | @@ -72137,10 +72151,11 @@ |
| 72137 | 72151 | return SQLITE_ERROR; |
| 72138 | 72152 | } |
| 72139 | 72153 | pMem->flags = MEM_Str|MEM_Term; |
| 72140 | 72154 | zP4 = displayP4(pOp, pMem->z, pMem->szMalloc); |
| 72141 | 72155 | if( zP4!=pMem->z ){ |
| 72156 | + pMem->n = 0; |
| 72142 | 72157 | sqlite3VdbeMemSetStr(pMem, zP4, -1, SQLITE_UTF8, 0); |
| 72143 | 72158 | }else{ |
| 72144 | 72159 | assert( pMem->z!=0 ); |
| 72145 | 72160 | pMem->n = sqlite3Strlen30(pMem->z); |
| 72146 | 72161 | pMem->enc = SQLITE_UTF8; |
| | @@ -72279,11 +72294,11 @@ |
| 72279 | 72294 | SQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe *p){ |
| 72280 | 72295 | #if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE) |
| 72281 | 72296 | int i; |
| 72282 | 72297 | #endif |
| 72283 | 72298 | assert( p!=0 ); |
| 72284 | | - assert( p->magic==VDBE_MAGIC_INIT ); |
| 72299 | + assert( p->magic==VDBE_MAGIC_INIT || p->magic==VDBE_MAGIC_RESET ); |
| 72285 | 72300 | |
| 72286 | 72301 | /* There should be at least one opcode. |
| 72287 | 72302 | */ |
| 72288 | 72303 | assert( p->nOp>0 ); |
| 72289 | 72304 | |
| | @@ -72368,14 +72383,11 @@ |
| 72368 | 72383 | n = ROUND8(sizeof(Op)*p->nOp); /* Bytes of opcode memory used */ |
| 72369 | 72384 | x.pSpace = &((u8*)p->aOp)[n]; /* Unused opcode memory */ |
| 72370 | 72385 | assert( EIGHT_BYTE_ALIGNMENT(x.pSpace) ); |
| 72371 | 72386 | x.nFree = ROUNDDOWN8(pParse->szOpAlloc - n); /* Bytes of unused memory */ |
| 72372 | 72387 | assert( x.nFree>=0 ); |
| 72373 | | - if( x.nFree>0 ){ |
| 72374 | | - memset(x.pSpace, 0, x.nFree); |
| 72375 | | - assert( EIGHT_BYTE_ALIGNMENT(&x.pSpace[x.nFree]) ); |
| 72376 | | - } |
| 72388 | + assert( EIGHT_BYTE_ALIGNMENT(&x.pSpace[x.nFree]) ); |
| 72377 | 72389 | |
| 72378 | 72390 | resolveP2Values(p, &nArg); |
| 72379 | 72391 | p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); |
| 72380 | 72392 | if( pParse->explain && nMem<10 ){ |
| 72381 | 72393 | nMem = 10; |
| | @@ -72400,34 +72412,34 @@ |
| 72400 | 72412 | p->apCsr = allocSpace(&x, p->apCsr, nCursor*sizeof(VdbeCursor*)); |
| 72401 | 72413 | #ifdef SQLITE_ENABLE_STMT_SCANSTATUS |
| 72402 | 72414 | p->anExec = allocSpace(&x, p->anExec, p->nOp*sizeof(i64)); |
| 72403 | 72415 | #endif |
| 72404 | 72416 | if( x.nNeeded==0 ) break; |
| 72405 | | - x.pSpace = p->pFree = sqlite3DbMallocZero(db, x.nNeeded); |
| 72417 | + x.pSpace = p->pFree = sqlite3DbMallocRawNN(db, x.nNeeded); |
| 72406 | 72418 | x.nFree = x.nNeeded; |
| 72407 | 72419 | }while( !db->mallocFailed ); |
| 72408 | 72420 | |
| 72409 | | - p->nCursor = nCursor; |
| 72410 | | - if( p->aVar ){ |
| 72411 | | - p->nVar = (ynVar)nVar; |
| 72412 | | - for(n=0; n<nVar; n++){ |
| 72413 | | - p->aVar[n].flags = MEM_Null; |
| 72414 | | - p->aVar[n].db = db; |
| 72415 | | - } |
| 72416 | | - } |
| 72417 | 72421 | p->nzVar = pParse->nzVar; |
| 72418 | 72422 | p->azVar = pParse->azVar; |
| 72419 | 72423 | pParse->nzVar = 0; |
| 72420 | 72424 | pParse->azVar = 0; |
| 72421 | | - if( p->aMem ){ |
| 72422 | | - p->nMem = nMem; |
| 72423 | | - for(n=0; n<nMem; n++){ |
| 72424 | | - p->aMem[n].flags = MEM_Undefined; |
| 72425 | | - p->aMem[n].db = db; |
| 72426 | | - } |
| 72427 | | - } |
| 72428 | 72425 | p->explain = pParse->explain; |
| 72426 | + if( db->mallocFailed ){ |
| 72427 | + p->nVar = 0; |
| 72428 | + p->nCursor = 0; |
| 72429 | + p->nMem = 0; |
| 72430 | + }else{ |
| 72431 | + p->nCursor = nCursor; |
| 72432 | + p->nVar = (ynVar)nVar; |
| 72433 | + initMemArray(p->aVar, nVar, db, MEM_Null); |
| 72434 | + p->nMem = nMem; |
| 72435 | + initMemArray(p->aMem, nMem, db, MEM_Undefined); |
| 72436 | + memset(p->apCsr, 0, nCursor*sizeof(VdbeCursor*)); |
| 72437 | +#ifdef SQLITE_ENABLE_STMT_SCANSTATUS |
| 72438 | + memset(p->anExec, 0, p->nOp*sizeof(i64)); |
| 72439 | +#endif |
| 72440 | + } |
| 72429 | 72441 | sqlite3VdbeRewind(p); |
| 72430 | 72442 | } |
| 72431 | 72443 | |
| 72432 | 72444 | /* |
| 72433 | 72445 | ** Close a VDBE cursor and release all the resources that cursor |
| | @@ -72575,17 +72587,13 @@ |
| 72575 | 72587 | |
| 72576 | 72588 | releaseMemArray(p->aColName, p->nResColumn*COLNAME_N); |
| 72577 | 72589 | sqlite3DbFree(db, p->aColName); |
| 72578 | 72590 | n = nResColumn*COLNAME_N; |
| 72579 | 72591 | p->nResColumn = (u16)nResColumn; |
| 72580 | | - p->aColName = pColName = (Mem*)sqlite3DbMallocZero(db, sizeof(Mem)*n ); |
| 72592 | + p->aColName = pColName = (Mem*)sqlite3DbMallocRawNN(db, sizeof(Mem)*n ); |
| 72581 | 72593 | if( p->aColName==0 ) return; |
| 72582 | | - while( n-- > 0 ){ |
| 72583 | | - pColName->flags = MEM_Null; |
| 72584 | | - pColName->db = p->db; |
| 72585 | | - pColName++; |
| 72586 | | - } |
| 72594 | + initMemArray(p->aColName, n, p->db, MEM_Null); |
| 72587 | 72595 | } |
| 72588 | 72596 | |
| 72589 | 72597 | /* |
| 72590 | 72598 | ** Set the name of the idx'th column to be returned by the SQL statement. |
| 72591 | 72599 | ** zName must be a pointer to a nul terminated string. |
| | @@ -73343,11 +73351,11 @@ |
| 73343 | 73351 | fclose(out); |
| 73344 | 73352 | } |
| 73345 | 73353 | } |
| 73346 | 73354 | #endif |
| 73347 | 73355 | p->iCurrentTime = 0; |
| 73348 | | - p->magic = VDBE_MAGIC_INIT; |
| 73356 | + p->magic = VDBE_MAGIC_RESET; |
| 73349 | 73357 | return p->rc & db->errMask; |
| 73350 | 73358 | } |
| 73351 | 73359 | |
| 73352 | 73360 | /* |
| 73353 | 73361 | ** Clean up and delete a VDBE after execution. Return an integer which is |
| | @@ -73407,23 +73415,25 @@ |
| 73407 | 73415 | */ |
| 73408 | 73416 | SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){ |
| 73409 | 73417 | SubProgram *pSub, *pNext; |
| 73410 | 73418 | int i; |
| 73411 | 73419 | assert( p->db==0 || p->db==db ); |
| 73412 | | - releaseMemArray(p->aVar, p->nVar); |
| 73413 | 73420 | releaseMemArray(p->aColName, p->nResColumn*COLNAME_N); |
| 73414 | 73421 | for(pSub=p->pProgram; pSub; pSub=pNext){ |
| 73415 | 73422 | pNext = pSub->pNext; |
| 73416 | 73423 | vdbeFreeOpArray(db, pSub->aOp, pSub->nOp); |
| 73417 | 73424 | sqlite3DbFree(db, pSub); |
| 73418 | 73425 | } |
| 73419 | | - for(i=p->nzVar-1; i>=0; i--) sqlite3DbFree(db, p->azVar[i]); |
| 73420 | | - sqlite3DbFree(db, p->azVar); |
| 73426 | + if( p->magic!=VDBE_MAGIC_INIT ){ |
| 73427 | + releaseMemArray(p->aVar, p->nVar); |
| 73428 | + for(i=p->nzVar-1; i>=0; i--) sqlite3DbFree(db, p->azVar[i]); |
| 73429 | + sqlite3DbFree(db, p->azVar); |
| 73430 | + sqlite3DbFree(db, p->pFree); |
| 73431 | + } |
| 73421 | 73432 | vdbeFreeOpArray(db, p->aOp, p->nOp); |
| 73422 | 73433 | sqlite3DbFree(db, p->aColName); |
| 73423 | 73434 | sqlite3DbFree(db, p->zSql); |
| 73424 | | - sqlite3DbFree(db, p->pFree); |
| 73425 | 73435 | #ifdef SQLITE_ENABLE_STMT_SCANSTATUS |
| 73426 | 73436 | for(i=0; i<p->nScan; i++){ |
| 73427 | 73437 | sqlite3DbFree(db, p->aScan[i].zName); |
| 73428 | 73438 | } |
| 73429 | 73439 | sqlite3DbFree(db, p->aScan); |
| | @@ -76665,11 +76675,11 @@ |
| 76665 | 76675 | /* |
| 76666 | 76676 | ** Return true if the prepared statement is in need of being reset. |
| 76667 | 76677 | */ |
| 76668 | 76678 | SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt *pStmt){ |
| 76669 | 76679 | Vdbe *v = (Vdbe*)pStmt; |
| 76670 | | - return v!=0 && v->pc>=0 && v->magic==VDBE_MAGIC_RUN; |
| 76680 | + return v!=0 && v->magic==VDBE_MAGIC_RUN && v->pc>=0; |
| 76671 | 76681 | } |
| 76672 | 76682 | |
| 76673 | 76683 | /* |
| 76674 | 76684 | ** Return a pointer to the next prepared statement after pStmt associated |
| 76675 | 76685 | ** with database connection pDb. If pStmt is NULL, return the first |
| | @@ -78417,15 +78427,17 @@ |
| 78417 | 78427 | u16 nullFlag; |
| 78418 | 78428 | pOut = out2Prerelease(p, pOp); |
| 78419 | 78429 | cnt = pOp->p3-pOp->p2; |
| 78420 | 78430 | assert( pOp->p3<=(p->nMem+1 - p->nCursor) ); |
| 78421 | 78431 | pOut->flags = nullFlag = pOp->p1 ? (MEM_Null|MEM_Cleared) : MEM_Null; |
| 78432 | + pOut->n = 0; |
| 78422 | 78433 | while( cnt>0 ){ |
| 78423 | 78434 | pOut++; |
| 78424 | 78435 | memAboutToChange(p, pOut); |
| 78425 | 78436 | sqlite3VdbeMemSetNull(pOut); |
| 78426 | 78437 | pOut->flags = nullFlag; |
| 78438 | + pOut->n = 0; |
| 78427 | 78439 | cnt--; |
| 78428 | 78440 | } |
| 78429 | 78441 | break; |
| 78430 | 78442 | } |
| 78431 | 78443 | |
| | @@ -92656,36 +92668,23 @@ |
| 92656 | 92668 | #endif |
| 92657 | 92669 | } |
| 92658 | 92670 | } |
| 92659 | 92671 | } |
| 92660 | 92672 | |
| 92661 | | -#if defined(SQLITE_DEBUG) |
| 92662 | | -/* |
| 92663 | | -** Verify the consistency of the column cache |
| 92664 | | -*/ |
| 92665 | | -static int cacheIsValid(Parse *pParse){ |
| 92666 | | - int i, n; |
| 92667 | | - for(i=n=0; i<SQLITE_N_COLCACHE; i++){ |
| 92668 | | - if( pParse->aColCache[i].iReg>0 ) n++; |
| 92669 | | - } |
| 92670 | | - return n==pParse->nColCache; |
| 92671 | | -} |
| 92672 | | -#endif |
| 92673 | | - |
| 92674 | | -/* |
| 92675 | | -** Clear a cache entry. |
| 92676 | | -*/ |
| 92677 | | -static void cacheEntryClear(Parse *pParse, struct yColCache *p){ |
| 92678 | | - if( p->tempReg ){ |
| 92673 | +/* |
| 92674 | +** Erase column-cache entry number i |
| 92675 | +*/ |
| 92676 | +static void cacheEntryClear(Parse *pParse, int i){ |
| 92677 | + if( pParse->aColCache[i].tempReg ){ |
| 92679 | 92678 | if( pParse->nTempReg<ArraySize(pParse->aTempReg) ){ |
| 92680 | | - pParse->aTempReg[pParse->nTempReg++] = p->iReg; |
| 92679 | + pParse->aTempReg[pParse->nTempReg++] = pParse->aColCache[i].iReg; |
| 92681 | 92680 | } |
| 92682 | | - p->tempReg = 0; |
| 92683 | 92681 | } |
| 92684 | | - p->iReg = 0; |
| 92685 | 92682 | pParse->nColCache--; |
| 92686 | | - assert( pParse->db->mallocFailed || cacheIsValid(pParse) ); |
| 92683 | + if( i<pParse->nColCache ){ |
| 92684 | + pParse->aColCache[i] = pParse->aColCache[pParse->nColCache]; |
| 92685 | + } |
| 92687 | 92686 | } |
| 92688 | 92687 | |
| 92689 | 92688 | |
| 92690 | 92689 | /* |
| 92691 | 92690 | ** Record in the column cache that a particular column from a |
| | @@ -92711,64 +92710,52 @@ |
| 92711 | 92710 | ** |
| 92712 | 92711 | ** Actually, the way the column cache is currently used, we are guaranteed |
| 92713 | 92712 | ** that the object will never already be in cache. Verify this guarantee. |
| 92714 | 92713 | */ |
| 92715 | 92714 | #ifndef NDEBUG |
| 92716 | | - for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){ |
| 92717 | | - assert( p->iReg==0 || p->iTable!=iTab || p->iColumn!=iCol ); |
| 92715 | + for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){ |
| 92716 | + assert( p->iTable!=iTab || p->iColumn!=iCol ); |
| 92718 | 92717 | } |
| 92719 | 92718 | #endif |
| 92720 | 92719 | |
| 92721 | | - /* Find an empty slot and replace it */ |
| 92722 | | - for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){ |
| 92723 | | - if( p->iReg==0 ){ |
| 92724 | | - p->iLevel = pParse->iCacheLevel; |
| 92725 | | - p->iTable = iTab; |
| 92726 | | - p->iColumn = iCol; |
| 92727 | | - p->iReg = iReg; |
| 92728 | | - p->tempReg = 0; |
| 92729 | | - p->lru = pParse->iCacheCnt++; |
| 92730 | | - pParse->nColCache++; |
| 92731 | | - assert( pParse->db->mallocFailed || cacheIsValid(pParse) ); |
| 92732 | | - return; |
| 92733 | | - } |
| 92734 | | - } |
| 92735 | | - |
| 92736 | | - /* Replace the last recently used */ |
| 92737 | | - minLru = 0x7fffffff; |
| 92738 | | - idxLru = -1; |
| 92739 | | - for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){ |
| 92740 | | - if( p->lru<minLru ){ |
| 92741 | | - idxLru = i; |
| 92742 | | - minLru = p->lru; |
| 92743 | | - } |
| 92744 | | - } |
| 92745 | | - if( ALWAYS(idxLru>=0) ){ |
| 92720 | + /* If the cache is already full, delete the least recently used entry */ |
| 92721 | + if( pParse->nColCache>=SQLITE_N_COLCACHE ){ |
| 92722 | + minLru = 0x7fffffff; |
| 92723 | + idxLru = -1; |
| 92724 | + for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){ |
| 92725 | + if( p->lru<minLru ){ |
| 92726 | + idxLru = i; |
| 92727 | + minLru = p->lru; |
| 92728 | + } |
| 92729 | + } |
| 92746 | 92730 | p = &pParse->aColCache[idxLru]; |
| 92747 | | - p->iLevel = pParse->iCacheLevel; |
| 92748 | | - p->iTable = iTab; |
| 92749 | | - p->iColumn = iCol; |
| 92750 | | - p->iReg = iReg; |
| 92751 | | - p->tempReg = 0; |
| 92752 | | - p->lru = pParse->iCacheCnt++; |
| 92753 | | - assert( cacheIsValid(pParse) ); |
| 92754 | | - return; |
| 92755 | | - } |
| 92731 | + }else{ |
| 92732 | + p = &pParse->aColCache[pParse->nColCache++]; |
| 92733 | + } |
| 92734 | + |
| 92735 | + /* Add the new entry to the end of the cache */ |
| 92736 | + p->iLevel = pParse->iCacheLevel; |
| 92737 | + p->iTable = iTab; |
| 92738 | + p->iColumn = iCol; |
| 92739 | + p->iReg = iReg; |
| 92740 | + p->tempReg = 0; |
| 92741 | + p->lru = pParse->iCacheCnt++; |
| 92756 | 92742 | } |
| 92757 | 92743 | |
| 92758 | 92744 | /* |
| 92759 | 92745 | ** Indicate that registers between iReg..iReg+nReg-1 are being overwritten. |
| 92760 | 92746 | ** Purge the range of registers from the column cache. |
| 92761 | 92747 | */ |
| 92762 | 92748 | SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse *pParse, int iReg, int nReg){ |
| 92763 | | - struct yColCache *p; |
| 92764 | | - if( iReg<=0 || pParse->nColCache==0 ) return; |
| 92765 | | - p = &pParse->aColCache[SQLITE_N_COLCACHE-1]; |
| 92766 | | - while(1){ |
| 92767 | | - if( p->iReg >= iReg && p->iReg < iReg+nReg ) cacheEntryClear(pParse, p); |
| 92768 | | - if( p==pParse->aColCache ) break; |
| 92769 | | - p--; |
| 92749 | + int i = 0; |
| 92750 | + while( i<pParse->nColCache ){ |
| 92751 | + struct yColCache *p = &pParse->aColCache[i]; |
| 92752 | + if( p->iReg >= iReg && p->iReg < iReg+nReg ){ |
| 92753 | + cacheEntryClear(pParse, i); |
| 92754 | + }else{ |
| 92755 | + i++; |
| 92756 | + } |
| 92770 | 92757 | } |
| 92771 | 92758 | } |
| 92772 | 92759 | |
| 92773 | 92760 | /* |
| 92774 | 92761 | ** Remember the current column cache context. Any new entries added |
| | @@ -92788,22 +92775,23 @@ |
| 92788 | 92775 | ** Remove from the column cache any entries that were added since the |
| 92789 | 92776 | ** the previous sqlite3ExprCachePush operation. In other words, restore |
| 92790 | 92777 | ** the cache to the state it was in prior the most recent Push. |
| 92791 | 92778 | */ |
| 92792 | 92779 | SQLITE_PRIVATE void sqlite3ExprCachePop(Parse *pParse){ |
| 92793 | | - int i; |
| 92794 | | - struct yColCache *p; |
| 92780 | + int i = 0; |
| 92795 | 92781 | assert( pParse->iCacheLevel>=1 ); |
| 92796 | 92782 | pParse->iCacheLevel--; |
| 92797 | 92783 | #ifdef SQLITE_DEBUG |
| 92798 | 92784 | if( pParse->db->flags & SQLITE_VdbeAddopTrace ){ |
| 92799 | 92785 | printf("POP to %d\n", pParse->iCacheLevel); |
| 92800 | 92786 | } |
| 92801 | 92787 | #endif |
| 92802 | | - for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){ |
| 92803 | | - if( p->iReg && p->iLevel>pParse->iCacheLevel ){ |
| 92804 | | - cacheEntryClear(pParse, p); |
| 92788 | + while( i<pParse->nColCache ){ |
| 92789 | + if( pParse->aColCache[i].iLevel>pParse->iCacheLevel ){ |
| 92790 | + cacheEntryClear(pParse, i); |
| 92791 | + }else{ |
| 92792 | + i++; |
| 92805 | 92793 | } |
| 92806 | 92794 | } |
| 92807 | 92795 | } |
| 92808 | 92796 | |
| 92809 | 92797 | /* |
| | @@ -92813,11 +92801,11 @@ |
| 92813 | 92801 | ** get them all. |
| 92814 | 92802 | */ |
| 92815 | 92803 | static void sqlite3ExprCachePinRegister(Parse *pParse, int iReg){ |
| 92816 | 92804 | int i; |
| 92817 | 92805 | struct yColCache *p; |
| 92818 | | - for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){ |
| 92806 | + for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){ |
| 92819 | 92807 | if( p->iReg==iReg ){ |
| 92820 | 92808 | p->tempReg = 0; |
| 92821 | 92809 | } |
| 92822 | 92810 | } |
| 92823 | 92811 | } |
| | @@ -92891,12 +92879,12 @@ |
| 92891 | 92879 | ){ |
| 92892 | 92880 | Vdbe *v = pParse->pVdbe; |
| 92893 | 92881 | int i; |
| 92894 | 92882 | struct yColCache *p; |
| 92895 | 92883 | |
| 92896 | | - for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){ |
| 92897 | | - if( p->iReg>0 && p->iTable==iTable && p->iColumn==iColumn ){ |
| 92884 | + for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){ |
| 92885 | + if( p->iTable==iTable && p->iColumn==iColumn ){ |
| 92898 | 92886 | p->lru = pParse->iCacheCnt++; |
| 92899 | 92887 | sqlite3ExprCachePinRegister(pParse, p->iReg); |
| 92900 | 92888 | return p->iReg; |
| 92901 | 92889 | } |
| 92902 | 92890 | } |
| | @@ -92924,22 +92912,24 @@ |
| 92924 | 92912 | /* |
| 92925 | 92913 | ** Clear all column cache entries. |
| 92926 | 92914 | */ |
| 92927 | 92915 | SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse *pParse){ |
| 92928 | 92916 | int i; |
| 92929 | | - struct yColCache *p; |
| 92930 | 92917 | |
| 92931 | 92918 | #if SQLITE_DEBUG |
| 92932 | 92919 | if( pParse->db->flags & SQLITE_VdbeAddopTrace ){ |
| 92933 | 92920 | printf("CLEAR\n"); |
| 92934 | 92921 | } |
| 92935 | 92922 | #endif |
| 92936 | | - for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){ |
| 92937 | | - if( p->iReg ){ |
| 92938 | | - cacheEntryClear(pParse, p); |
| 92923 | + for(i=0; i<pParse->nColCache; i++){ |
| 92924 | + if( pParse->aColCache[i].tempReg |
| 92925 | + && pParse->nTempReg<ArraySize(pParse->aTempReg) |
| 92926 | + ){ |
| 92927 | + pParse->aTempReg[pParse->nTempReg++] = pParse->aColCache[i].iReg; |
| 92939 | 92928 | } |
| 92940 | 92929 | } |
| 92930 | + pParse->nColCache = 0; |
| 92941 | 92931 | } |
| 92942 | 92932 | |
| 92943 | 92933 | /* |
| 92944 | 92934 | ** Record the fact that an affinity change has occurred on iCount |
| 92945 | 92935 | ** registers starting with iStart. |
| | @@ -92967,11 +92957,11 @@ |
| 92967 | 92957 | ** and does not appear in a normal build. |
| 92968 | 92958 | */ |
| 92969 | 92959 | static int usedAsColumnCache(Parse *pParse, int iFrom, int iTo){ |
| 92970 | 92960 | int i; |
| 92971 | 92961 | struct yColCache *p; |
| 92972 | | - for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){ |
| 92962 | + for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){ |
| 92973 | 92963 | int r = p->iReg; |
| 92974 | 92964 | if( r>=iFrom && r<=iTo ) return 1; /*NO_TEST*/ |
| 92975 | 92965 | } |
| 92976 | 92966 | return 0; |
| 92977 | 92967 | } |
| | @@ -94663,11 +94653,11 @@ |
| 94663 | 94653 | */ |
| 94664 | 94654 | SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse *pParse, int iReg){ |
| 94665 | 94655 | if( iReg && pParse->nTempReg<ArraySize(pParse->aTempReg) ){ |
| 94666 | 94656 | int i; |
| 94667 | 94657 | struct yColCache *p; |
| 94668 | | - for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){ |
| 94658 | + for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){ |
| 94669 | 94659 | if( p->iReg==iReg ){ |
| 94670 | 94660 | p->tempReg = 1; |
| 94671 | 94661 | return; |
| 94672 | 94662 | } |
| 94673 | 94663 | } |
| | @@ -98433,11 +98423,10 @@ |
| 98433 | 98423 | */ |
| 98434 | 98424 | v = sqlite3GetVdbe(pParse); |
| 98435 | 98425 | assert( !pParse->isMultiWrite |
| 98436 | 98426 | || sqlite3VdbeAssertMayAbort(v, pParse->mayAbort)); |
| 98437 | 98427 | if( v ){ |
| 98438 | | - while( sqlite3VdbeDeletePriorOpcode(v, OP_Close) ){} |
| 98439 | 98428 | sqlite3VdbeAddOp0(v, OP_Halt); |
| 98440 | 98429 | |
| 98441 | 98430 | #if SQLITE_USER_AUTHENTICATION |
| 98442 | 98431 | if( pParse->nTableLock>0 && db->init.busy==0 ){ |
| 98443 | 98432 | sqlite3UserAuthInit(db); |
| | @@ -98460,18 +98449,20 @@ |
| 98460 | 98449 | ){ |
| 98461 | 98450 | int iDb, i; |
| 98462 | 98451 | assert( sqlite3VdbeGetOp(v, 0)->opcode==OP_Init ); |
| 98463 | 98452 | sqlite3VdbeJumpHere(v, 0); |
| 98464 | 98453 | for(iDb=0; iDb<db->nDb; iDb++){ |
| 98454 | + Schema *pSchema; |
| 98465 | 98455 | if( DbMaskTest(pParse->cookieMask, iDb)==0 ) continue; |
| 98466 | 98456 | sqlite3VdbeUsesBtree(v, iDb); |
| 98457 | + pSchema = db->aDb[iDb].pSchema; |
| 98467 | 98458 | sqlite3VdbeAddOp4Int(v, |
| 98468 | 98459 | OP_Transaction, /* Opcode */ |
| 98469 | 98460 | iDb, /* P1 */ |
| 98470 | 98461 | DbMaskTest(pParse->writeMask,iDb), /* P2 */ |
| 98471 | | - pParse->cookieValue[iDb], /* P3 */ |
| 98472 | | - db->aDb[iDb].pSchema->iGeneration /* P4 */ |
| 98462 | + pSchema->schema_cookie, /* P3 */ |
| 98463 | + pSchema->iGeneration /* P4 */ |
| 98473 | 98464 | ); |
| 98474 | 98465 | if( db->init.busy==0 ) sqlite3VdbeChangeP5(v, 1); |
| 98475 | 98466 | VdbeComment((v, |
| 98476 | 98467 | "usesStmtJournal=%d", pParse->mayAbort && pParse->isMultiWrite)); |
| 98477 | 98468 | } |
| | @@ -98518,20 +98509,10 @@ |
| 98518 | 98509 | sqlite3VdbeMakeReady(v, pParse); |
| 98519 | 98510 | pParse->rc = SQLITE_DONE; |
| 98520 | 98511 | }else{ |
| 98521 | 98512 | pParse->rc = SQLITE_ERROR; |
| 98522 | 98513 | } |
| 98523 | | - |
| 98524 | | - /* We are done with this Parse object. There is no need to de-initialize it */ |
| 98525 | | -#if 0 |
| 98526 | | - pParse->colNamesSet = 0; |
| 98527 | | - pParse->nTab = 0; |
| 98528 | | - pParse->nMem = 0; |
| 98529 | | - pParse->nSet = 0; |
| 98530 | | - pParse->nVar = 0; |
| 98531 | | - DbMaskZero(pParse->cookieMask); |
| 98532 | | -#endif |
| 98533 | 98514 | } |
| 98534 | 98515 | |
| 98535 | 98516 | /* |
| 98536 | 98517 | ** Run the parser and code generator recursively in order to generate |
| 98537 | 98518 | ** code for the SQL statement given onto the end of the pParse context |
| | @@ -98547,12 +98528,11 @@ |
| 98547 | 98528 | SQLITE_PRIVATE void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){ |
| 98548 | 98529 | va_list ap; |
| 98549 | 98530 | char *zSql; |
| 98550 | 98531 | char *zErrMsg = 0; |
| 98551 | 98532 | sqlite3 *db = pParse->db; |
| 98552 | | -# define SAVE_SZ (sizeof(Parse) - offsetof(Parse,nVar)) |
| 98553 | | - char saveBuf[SAVE_SZ]; |
| 98533 | + char saveBuf[PARSE_TAIL_SZ]; |
| 98554 | 98534 | |
| 98555 | 98535 | if( pParse->nErr ) return; |
| 98556 | 98536 | assert( pParse->nested<10 ); /* Nesting should only be of limited depth */ |
| 98557 | 98537 | va_start(ap, zFormat); |
| 98558 | 98538 | zSql = sqlite3VMPrintf(db, zFormat, ap); |
| | @@ -98559,16 +98539,16 @@ |
| 98559 | 98539 | va_end(ap); |
| 98560 | 98540 | if( zSql==0 ){ |
| 98561 | 98541 | return; /* A malloc must have failed */ |
| 98562 | 98542 | } |
| 98563 | 98543 | pParse->nested++; |
| 98564 | | - memcpy(saveBuf, &pParse->nVar, SAVE_SZ); |
| 98565 | | - memset(&pParse->nVar, 0, SAVE_SZ); |
| 98544 | + memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ); |
| 98545 | + memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ); |
| 98566 | 98546 | sqlite3RunParser(pParse, zSql, &zErrMsg); |
| 98567 | 98547 | sqlite3DbFree(db, zErrMsg); |
| 98568 | 98548 | sqlite3DbFree(db, zSql); |
| 98569 | | - memcpy(&pParse->nVar, saveBuf, SAVE_SZ); |
| 98549 | + memcpy(PARSE_TAIL(pParse), saveBuf, PARSE_TAIL_SZ); |
| 98570 | 98550 | pParse->nested--; |
| 98571 | 98551 | } |
| 98572 | 98552 | |
| 98573 | 98553 | #if SQLITE_USER_AUTHENTICATION |
| 98574 | 98554 | /* |
| | @@ -102331,19 +102311,17 @@ |
| 102331 | 102311 | ** will occur at the end of the top-level VDBE and will be generated |
| 102332 | 102312 | ** later, by sqlite3FinishCoding(). |
| 102333 | 102313 | */ |
| 102334 | 102314 | SQLITE_PRIVATE void sqlite3CodeVerifySchema(Parse *pParse, int iDb){ |
| 102335 | 102315 | Parse *pToplevel = sqlite3ParseToplevel(pParse); |
| 102336 | | - sqlite3 *db = pToplevel->db; |
| 102337 | 102316 | |
| 102338 | | - assert( iDb>=0 && iDb<db->nDb ); |
| 102339 | | - assert( db->aDb[iDb].pBt!=0 || iDb==1 ); |
| 102317 | + assert( iDb>=0 && iDb<pParse->db->nDb ); |
| 102318 | + assert( pParse->db->aDb[iDb].pBt!=0 || iDb==1 ); |
| 102340 | 102319 | assert( iDb<SQLITE_MAX_ATTACHED+2 ); |
| 102341 | | - assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 102320 | + assert( sqlite3SchemaMutexHeld(pParse->db, iDb, 0) ); |
| 102342 | 102321 | if( DbMaskTest(pToplevel->cookieMask, iDb)==0 ){ |
| 102343 | 102322 | DbMaskSet(pToplevel->cookieMask, iDb); |
| 102344 | | - pToplevel->cookieValue[iDb] = db->aDb[iDb].pSchema->schema_cookie; |
| 102345 | 102323 | if( !OMIT_TEMPDB && iDb==1 ){ |
| 102346 | 102324 | sqlite3OpenTempDatabase(pToplevel); |
| 102347 | 102325 | } |
| 102348 | 102326 | } |
| 102349 | 102327 | } |
| | @@ -114053,15 +114031,17 @@ |
| 114053 | 114031 | char *zErrMsg = 0; /* Error message */ |
| 114054 | 114032 | int rc = SQLITE_OK; /* Result code */ |
| 114055 | 114033 | int i; /* Loop counter */ |
| 114056 | 114034 | |
| 114057 | 114035 | /* Allocate the parsing context */ |
| 114058 | | - pParse = sqlite3StackAllocZero(db, sizeof(*pParse)); |
| 114036 | + pParse = sqlite3StackAllocRaw(db, sizeof(*pParse)); |
| 114059 | 114037 | if( pParse==0 ){ |
| 114060 | 114038 | rc = SQLITE_NOMEM_BKPT; |
| 114061 | 114039 | goto end_prepare; |
| 114062 | 114040 | } |
| 114041 | + memset(pParse, 0, PARSE_HDR_SZ); |
| 114042 | + memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ); |
| 114063 | 114043 | pParse->pReprepare = pReprepare; |
| 114064 | 114044 | assert( ppStmt && *ppStmt==0 ); |
| 114065 | 114045 | /* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */ |
| 114066 | 114046 | assert( sqlite3_mutex_held(db->mutex) ); |
| 114067 | 114047 | |
| | @@ -115395,11 +115375,11 @@ |
| 115395 | 115375 | ** Allocate a KeyInfo object sufficient for an index of N key columns and |
| 115396 | 115376 | ** X extra columns. |
| 115397 | 115377 | */ |
| 115398 | 115378 | SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){ |
| 115399 | 115379 | int nExtra = (N+X)*(sizeof(CollSeq*)+1); |
| 115400 | | - KeyInfo *p = sqlite3DbMallocRaw(db, sizeof(KeyInfo) + nExtra); |
| 115380 | + KeyInfo *p = sqlite3DbMallocRawNN(db, sizeof(KeyInfo) + nExtra); |
| 115401 | 115381 | if( p ){ |
| 115402 | 115382 | p->aSortOrder = (u8*)&p->aColl[N+X]; |
| 115403 | 115383 | p->nField = (u16)N; |
| 115404 | 115384 | p->nXField = (u16)X; |
| 115405 | 115385 | p->enc = ENC(db); |
| 115406 | 115386 | |