| | @@ -1150,11 +1150,11 @@ |
| 1150 | 1150 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1151 | 1151 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1152 | 1152 | */ |
| 1153 | 1153 | #define SQLITE_VERSION "3.24.0" |
| 1154 | 1154 | #define SQLITE_VERSION_NUMBER 3024000 |
| 1155 | | -#define SQLITE_SOURCE_ID "2018-04-25 13:27:07 3bcdbccf530e2a5aab7b91f4b9e5535cced91f242c49ff69b05a75d643b8b4a3" |
| 1155 | +#define SQLITE_SOURCE_ID "2018-04-26 18:34:26 9fd0faf517993587d2f54212638545fc85fbbc84a031bcfae8c1e5894825d83b" |
| 1156 | 1156 | |
| 1157 | 1157 | /* |
| 1158 | 1158 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1159 | 1159 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1160 | 1160 | ** |
| | @@ -8041,11 +8041,11 @@ |
| 8041 | 8041 | #define SQLITE_TESTCTRL_PENDING_BYTE 11 |
| 8042 | 8042 | #define SQLITE_TESTCTRL_ASSERT 12 |
| 8043 | 8043 | #define SQLITE_TESTCTRL_ALWAYS 13 |
| 8044 | 8044 | #define SQLITE_TESTCTRL_RESERVE 14 |
| 8045 | 8045 | #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 |
| 8046 | | -#define SQLITE_TESTCTRL_ISKEYWORD 16 |
| 8046 | +#define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */ |
| 8047 | 8047 | #define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */ |
| 8048 | 8048 | #define SQLITE_TESTCTRL_LOCALTIME_FAULT 18 |
| 8049 | 8049 | #define SQLITE_TESTCTRL_EXPLAIN_STMT 19 /* NOT USED */ |
| 8050 | 8050 | #define SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD 19 |
| 8051 | 8051 | #define SQLITE_TESTCTRL_NEVER_CORRUPT 20 |
| | @@ -8055,10 +8055,61 @@ |
| 8055 | 8055 | #define SQLITE_TESTCTRL_SORTER_MMAP 24 |
| 8056 | 8056 | #define SQLITE_TESTCTRL_IMPOSTER 25 |
| 8057 | 8057 | #define SQLITE_TESTCTRL_PARSER_COVERAGE 26 |
| 8058 | 8058 | #define SQLITE_TESTCTRL_LAST 26 /* Largest TESTCTRL */ |
| 8059 | 8059 | |
| 8060 | +/* |
| 8061 | +** CAPI3REF: SQL Keyword Checking |
| 8062 | +** |
| 8063 | +** These routines provide access to the set of SQL language keywords |
| 8064 | +** recognized by SQLite. Applications can uses these routines to determine |
| 8065 | +** whether or not a specific identifier needs to be escaped (for example, |
| 8066 | +** by enclosing in double-quotes) so as not to confuse the parser. |
| 8067 | +** |
| 8068 | +** The sqlite3_keyword_count() interface returns the number of distinct |
| 8069 | +** keywords understood by SQLite. |
| 8070 | +** |
| 8071 | +** The sqlite3_keyword_name(N,Z,L) interface finds the N-th keyword and |
| 8072 | +** makes *Z point to that keyword expressed as UTF8 and writes the number |
| 8073 | +** of bytes in the keyword into *L. The string that *Z points to is not |
| 8074 | +** zero-terminated. The sqlite3_keyword_name(N,Z,L) routine returns |
| 8075 | +** SQLITE_OK if N is within bounds and SQLITE_ERROR if not. If either Z |
| 8076 | +** or L are NULL or invalid pointers then calls to |
| 8077 | +** sqlite3_keyword_name(N,Z,L) result in undefined behavior. |
| 8078 | +** |
| 8079 | +** The sqlite3_keyword_check(Z,L) interface checks to see whether or not |
| 8080 | +** the L-byte UTF8 identifier that Z points to is a keyword, returning non-zero |
| 8081 | +** if it is and zero if not. |
| 8082 | +** |
| 8083 | +** The parser used by SQLite is forgiving. It is often possible to use |
| 8084 | +** a keyword as an identifier as long as such use does not result in a |
| 8085 | +** parsing ambiguity. For example, the statement |
| 8086 | +** "CREATE TABLE BEGIN(REPLACE,PRAGMA,END);" is accepted by SQLite, and |
| 8087 | +** creates a new table named "BEGIN" with three columns named |
| 8088 | +** "REPLACE", "PRAGMA", and "END". Nevertheless, best practice is to avoid |
| 8089 | +** using keywords as identifiers. Common techniques used to avoid keyword |
| 8090 | +** name collisions include: |
| 8091 | +** <ul> |
| 8092 | +** <li> Put all indentifier names inside double-quotes. This is the official |
| 8093 | +** SQL way to escape identifier names. |
| 8094 | +** <li> Put identifier names inside [...]. This is not standard SQL, |
| 8095 | +** but it is what SQL Server does and so lots of programmers use this |
| 8096 | +** technique. |
| 8097 | +** <li> Begin every identifier with the letter "Z" as no SQL keywords start |
| 8098 | +** with "Z". |
| 8099 | +** <li> Include a digit somewhere in every identifier name. |
| 8100 | +** </ul> |
| 8101 | +** |
| 8102 | +** Note that the number of keywords understood by SQLite can depend on |
| 8103 | +** compile-time options. For example, "VACUUM" is not a keyword if |
| 8104 | +** SQLite is compiled with the [-DSQLITE_OMIT_VACUUM] option. Also, |
| 8105 | +** new keywords may be added to future releases of SQLite. |
| 8106 | +*/ |
| 8107 | +SQLITE_API int sqlite3_keyword_count(void); |
| 8108 | +SQLITE_API int sqlite3_keyword_name(int,const char**,int*); |
| 8109 | +SQLITE_API int sqlite3_keyword_check(const char*,int); |
| 8110 | + |
| 8060 | 8111 | /* |
| 8061 | 8112 | ** CAPI3REF: SQLite Runtime Status |
| 8062 | 8113 | ** |
| 8063 | 8114 | ** ^These interfaces are used to retrieve runtime status information |
| 8064 | 8115 | ** about the performance of SQLite, and optionally to reset various |
| | @@ -98210,14 +98261,13 @@ |
| 98210 | 98261 | assert( pExpr->iColumn>=-1 && pExpr->iColumn<pTab->nCol ); |
| 98211 | 98262 | assert( pTab->iPKey<0 || pExpr->iColumn!=pTab->iPKey ); |
| 98212 | 98263 | assert( p1>=0 && p1<(pTab->nCol*2+2) ); |
| 98213 | 98264 | |
| 98214 | 98265 | sqlite3VdbeAddOp2(v, OP_Param, p1, target); |
| 98215 | | - VdbeComment((v, "%s.%s -> $%d", |
| 98266 | + VdbeComment((v, "r[%d]=%s.%s", target, |
| 98216 | 98267 | (pExpr->iTable ? "new" : "old"), |
| 98217 | | - (pExpr->iColumn<0 ? "rowid" : pExpr->pTab->aCol[pExpr->iColumn].zName), |
| 98218 | | - target |
| 98268 | + (pExpr->iColumn<0 ? "rowid" : pExpr->pTab->aCol[pExpr->iColumn].zName) |
| 98219 | 98269 | )); |
| 98220 | 98270 | |
| 98221 | 98271 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 98222 | 98272 | /* If the column has REAL affinity, it may currently be stored as an |
| 98223 | 98273 | ** integer. Use OP_RealAffinity to make sure it is really real. |
| | @@ -121222,19 +121272,19 @@ |
| 121222 | 121272 | sqlite3VdbeAddOp2(v, OP_Sequence, pSort->iECursor, regBase+nExpr); |
| 121223 | 121273 | } |
| 121224 | 121274 | if( nPrefixReg==0 && nData>0 ){ |
| 121225 | 121275 | sqlite3ExprCodeMove(pParse, regData, regBase+nExpr+bSeq, nData); |
| 121226 | 121276 | } |
| 121227 | | - sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase+nOBSat, nBase-nOBSat, regRecord); |
| 121228 | 121277 | if( nOBSat>0 ){ |
| 121229 | 121278 | int regPrevKey; /* The first nOBSat columns of the previous row */ |
| 121230 | 121279 | int addrFirst; /* Address of the OP_IfNot opcode */ |
| 121231 | 121280 | int addrJmp; /* Address of the OP_Jump opcode */ |
| 121232 | 121281 | VdbeOp *pOp; /* Opcode that opens the sorter */ |
| 121233 | 121282 | int nKey; /* Number of sorting key columns, including OP_Sequence */ |
| 121234 | 121283 | KeyInfo *pKI; /* Original KeyInfo on the sorter table */ |
| 121235 | 121284 | |
| 121285 | + sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase+nOBSat, nBase-nOBSat,regRecord); |
| 121236 | 121286 | regPrevKey = pParse->nMem+1; |
| 121237 | 121287 | pParse->nMem += pSort->nOBSat; |
| 121238 | 121288 | nKey = nExpr - pSort->nOBSat + bSeq; |
| 121239 | 121289 | if( bSeq ){ |
| 121240 | 121290 | addrFirst = sqlite3VdbeAddOp1(v, OP_IfNot, regBase+nExpr); |
| | @@ -121264,45 +121314,46 @@ |
| 121264 | 121314 | } |
| 121265 | 121315 | sqlite3VdbeJumpHere(v, addrFirst); |
| 121266 | 121316 | sqlite3ExprCodeMove(pParse, regBase, regPrevKey, pSort->nOBSat); |
| 121267 | 121317 | sqlite3VdbeJumpHere(v, addrJmp); |
| 121268 | 121318 | } |
| 121319 | + if( iLimit ){ |
| 121320 | + /* At this point the values for the new sorter entry are stored |
| 121321 | + ** in an array of registers. They need to be composed into a record |
| 121322 | + ** and inserted into the sorter if either (a) there are currently |
| 121323 | + ** less than LIMIT+OFFSET items or (b) the new record is smaller than |
| 121324 | + ** the largest record currently in the sorter. If (b) is true and there |
| 121325 | + ** are already LIMIT+OFFSET items in the sorter, delete the largest |
| 121326 | + ** entry before inserting the new one. This way there are never more |
| 121327 | + ** than LIMIT+OFFSET items in the sorter. |
| 121328 | + ** |
| 121329 | + ** If the new record does not need to be inserted into the sorter, |
| 121330 | + ** jump to the next iteration of the loop. Or, if the |
| 121331 | + ** pSort->bOrderedInnerLoop flag is set to indicate that the inner |
| 121332 | + ** loop delivers items in sorted order, jump to the next iteration |
| 121333 | + ** of the outer loop. |
| 121334 | + */ |
| 121335 | + int iCsr = pSort->iECursor; |
| 121336 | + int iJmp = sqlite3VdbeCurrentAddr(v)+5+(nOBSat<=0)+pSort->bOrderedInnerLoop; |
| 121337 | + assert( pSort->bOrderedInnerLoop==0 || pSort->bOrderedInnerLoop==1 ); |
| 121338 | + sqlite3VdbeAddOp2(v, OP_IfNotZero, iLimit, sqlite3VdbeCurrentAddr(v)+4); |
| 121339 | + VdbeCoverage(v); |
| 121340 | + sqlite3VdbeAddOp2(v, OP_Last, iCsr, 0); |
| 121341 | + sqlite3VdbeAddOp4Int(v, OP_IdxLE, iCsr, iJmp, regBase+nOBSat, nExpr-nOBSat); |
| 121342 | + VdbeCoverage(v); |
| 121343 | + sqlite3VdbeAddOp1(v, OP_Delete, iCsr); |
| 121344 | + } |
| 121345 | + if( nOBSat<=0 ){ |
| 121346 | + sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase+nOBSat, nBase-nOBSat,regRecord); |
| 121347 | + } |
| 121269 | 121348 | if( pSort->sortFlags & SORTFLAG_UseSorter ){ |
| 121270 | 121349 | op = OP_SorterInsert; |
| 121271 | 121350 | }else{ |
| 121272 | 121351 | op = OP_IdxInsert; |
| 121273 | 121352 | } |
| 121274 | 121353 | sqlite3VdbeAddOp4Int(v, op, pSort->iECursor, regRecord, |
| 121275 | 121354 | regBase+nOBSat, nBase-nOBSat); |
| 121276 | | - if( iLimit ){ |
| 121277 | | - int addr; |
| 121278 | | - int r1 = 0; |
| 121279 | | - /* Fill the sorter until it contains LIMIT+OFFSET entries. (The iLimit |
| 121280 | | - ** register is initialized with value of LIMIT+OFFSET.) After the sorter |
| 121281 | | - ** fills up, delete the least entry in the sorter after each insert. |
| 121282 | | - ** Thus we never hold more than the LIMIT+OFFSET rows in memory at once */ |
| 121283 | | - addr = sqlite3VdbeAddOp1(v, OP_IfNotZero, iLimit); VdbeCoverage(v); |
| 121284 | | - sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor); |
| 121285 | | - if( pSort->bOrderedInnerLoop ){ |
| 121286 | | - r1 = ++pParse->nMem; |
| 121287 | | - sqlite3VdbeAddOp3(v, OP_Column, pSort->iECursor, nExpr, r1); |
| 121288 | | - VdbeComment((v, "seq")); |
| 121289 | | - } |
| 121290 | | - sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor); |
| 121291 | | - if( pSort->bOrderedInnerLoop ){ |
| 121292 | | - /* If the inner loop is driven by an index such that values from |
| 121293 | | - ** the same iteration of the inner loop are in sorted order, then |
| 121294 | | - ** immediately jump to the next iteration of an inner loop if the |
| 121295 | | - ** entry from the current iteration does not fit into the top |
| 121296 | | - ** LIMIT+OFFSET entries of the sorter. */ |
| 121297 | | - int iBrk = sqlite3VdbeCurrentAddr(v) + 2; |
| 121298 | | - sqlite3VdbeAddOp3(v, OP_Eq, regBase+nExpr, iBrk, r1); |
| 121299 | | - sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); |
| 121300 | | - VdbeCoverage(v); |
| 121301 | | - } |
| 121302 | | - sqlite3VdbeJumpHere(v, addr); |
| 121303 | | - } |
| 121304 | 121355 | } |
| 121305 | 121356 | |
| 121306 | 121357 | /* |
| 121307 | 121358 | ** Add code to implement the OFFSET |
| 121308 | 121359 | */ |
| | @@ -128898,10 +128949,16 @@ |
| 128898 | 128949 | ** a new.* reference in a trigger program. |
| 128899 | 128950 | */ |
| 128900 | 128951 | testcase( i==31 ); |
| 128901 | 128952 | testcase( i==32 ); |
| 128902 | 128953 | sqlite3ExprCodeGetColumnToReg(pParse, pTab, i, iDataCur, regNew+i); |
| 128954 | + if( tmask & TRIGGER_BEFORE ){ |
| 128955 | + /* This value will be recomputed in After-BEFORE-trigger-reload-loop |
| 128956 | + ** below, so make sure that it is not cached and reused. |
| 128957 | + ** Ticket d85fffd6ffe856092ed8daefa811b1e399706b28. */ |
| 128958 | + sqlite3ExprCacheRemove(pParse, regNew+i, 1); |
| 128959 | + } |
| 128903 | 128960 | }else{ |
| 128904 | 128961 | sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i); |
| 128905 | 128962 | } |
| 128906 | 128963 | } |
| 128907 | 128964 | } |
| | @@ -128926,14 +128983,18 @@ |
| 128926 | 128983 | }else{ |
| 128927 | 128984 | sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid); |
| 128928 | 128985 | VdbeCoverage(v); |
| 128929 | 128986 | } |
| 128930 | 128987 | |
| 128931 | | - /* If it did not delete it, the row-trigger may still have modified |
| 128988 | + /* After-BEFORE-trigger-reload-loop: |
| 128989 | + ** If it did not delete it, the BEFORE trigger may still have modified |
| 128932 | 128990 | ** some of the columns of the row being updated. Load the values for |
| 128933 | | - ** all columns not modified by the update statement into their |
| 128934 | | - ** registers in case this has happened. |
| 128991 | + ** all columns not modified by the update statement into their registers |
| 128992 | + ** in case this has happened. Only unmodified columns are reloaded. |
| 128993 | + ** The values computed for modified columns use the values before the |
| 128994 | + ** BEFORE trigger runs. See test case trigger1-18.0 (added 2018-04-26) |
| 128995 | + ** for an example. |
| 128935 | 128996 | */ |
| 128936 | 128997 | for(i=0; i<pTab->nCol; i++){ |
| 128937 | 128998 | if( aXRef[i]<0 && i!=pTab->iPKey ){ |
| 128938 | 128999 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regNew+i); |
| 128939 | 129000 | } |
| | @@ -145167,10 +145228,20 @@ |
| 145167 | 145228 | int id = TK_ID; |
| 145168 | 145229 | keywordCode((char*)z, n, &id); |
| 145169 | 145230 | return id; |
| 145170 | 145231 | } |
| 145171 | 145232 | #define SQLITE_N_KEYWORD 126 |
| 145233 | +SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){ |
| 145234 | + if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR; |
| 145235 | + *pzName = zKWText + aKWOffset[i]; |
| 145236 | + *pnName = aKWLen[i]; |
| 145237 | + return SQLITE_OK; |
| 145238 | +} |
| 145239 | +SQLITE_API int sqlite3_keyword_count(void){ return SQLITE_N_KEYWORD; } |
| 145240 | +SQLITE_API int sqlite3_keyword_check(const char *zName, int nName){ |
| 145241 | + return TK_ID!=sqlite3KeywordCode((const u8*)zName, nName); |
| 145242 | +} |
| 145172 | 145243 | |
| 145173 | 145244 | /************** End of keywordhash.h *****************************************/ |
| 145174 | 145245 | /************** Continuing where we left off in tokenize.c *******************/ |
| 145175 | 145246 | |
| 145176 | 145247 | |
| | @@ -149895,28 +149966,10 @@ |
| 149895 | 149966 | sqlite3 *db = va_arg(ap, sqlite3*); |
| 149896 | 149967 | db->dbOptFlags = (u16)(va_arg(ap, int) & 0xffff); |
| 149897 | 149968 | break; |
| 149898 | 149969 | } |
| 149899 | 149970 | |
| 149900 | | -#ifdef SQLITE_N_KEYWORD |
| 149901 | | - /* sqlite3_test_control(SQLITE_TESTCTRL_ISKEYWORD, const char *zWord) |
| 149902 | | - ** |
| 149903 | | - ** If zWord is a keyword recognized by the parser, then return the |
| 149904 | | - ** number of keywords. Or if zWord is not a keyword, return 0. |
| 149905 | | - ** |
| 149906 | | - ** This test feature is only available in the amalgamation since |
| 149907 | | - ** the SQLITE_N_KEYWORD macro is not defined in this file if SQLite |
| 149908 | | - ** is built using separate source files. |
| 149909 | | - */ |
| 149910 | | - case SQLITE_TESTCTRL_ISKEYWORD: { |
| 149911 | | - const char *zWord = va_arg(ap, const char*); |
| 149912 | | - int n = sqlite3Strlen30(zWord); |
| 149913 | | - rc = (sqlite3KeywordCode((u8*)zWord, n)!=TK_ID) ? SQLITE_N_KEYWORD : 0; |
| 149914 | | - break; |
| 149915 | | - } |
| 149916 | | -#endif |
| 149917 | | - |
| 149918 | 149971 | /* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff); |
| 149919 | 149972 | ** |
| 149920 | 149973 | ** If parameter onoff is non-zero, configure the wrappers so that all |
| 149921 | 149974 | ** subsequent calls to localtime() and variants fail. If onoff is zero, |
| 149922 | 149975 | ** undo this setting. |
| | @@ -206672,11 +206725,11 @@ |
| 206672 | 206725 | int nArg, /* Number of args */ |
| 206673 | 206726 | sqlite3_value **apUnused /* Function arguments */ |
| 206674 | 206727 | ){ |
| 206675 | 206728 | assert( nArg==0 ); |
| 206676 | 206729 | UNUSED_PARAM2(nArg, apUnused); |
| 206677 | | - sqlite3_result_text(pCtx, "fts5: 2018-04-25 13:27:07 3bcdbccf530e2a5aab7b91f4b9e5535cced91f242c49ff69b05a75d643b8b4a3", -1, SQLITE_TRANSIENT); |
| 206730 | + sqlite3_result_text(pCtx, "fts5: 2018-04-26 12:27:03 368c14da868a843767344f6cc17c499fddd83244c0510337ed9a918e64ee2413", -1, SQLITE_TRANSIENT); |
| 206678 | 206731 | } |
| 206679 | 206732 | |
| 206680 | 206733 | static int fts5Init(sqlite3 *db){ |
| 206681 | 206734 | static const sqlite3_module fts5Mod = { |
| 206682 | 206735 | /* iVersion */ 2, |
| | @@ -210942,12 +210995,12 @@ |
| 210942 | 210995 | } |
| 210943 | 210996 | #endif /* SQLITE_CORE */ |
| 210944 | 210997 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 210945 | 210998 | |
| 210946 | 210999 | /************** End of stmt.c ************************************************/ |
| 210947 | | -#if __LINE__!=210947 |
| 211000 | +#if __LINE__!=211000 |
| 210948 | 211001 | #undef SQLITE_SOURCE_ID |
| 210949 | | -#define SQLITE_SOURCE_ID "2018-04-25 13:27:07 3bcdbccf530e2a5aab7b91f4b9e5535cced91f242c49ff69b05a75d643b8alt2" |
| 211002 | +#define SQLITE_SOURCE_ID "2018-04-26 18:34:26 9fd0faf517993587d2f54212638545fc85fbbc84a031bcfae8c1e5894825alt2" |
| 210950 | 211003 | #endif |
| 210951 | 211004 | /* Return the source-id for this library */ |
| 210952 | 211005 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 210953 | 211006 | /************************** End of sqlite3.c ******************************/ |
| 210954 | 211007 | |