Fossil SCM
Update the build-in SQLite to the lastest 3.7.7 release candidate.
Commit
4722e1ab770c0381e3dd429640886b608df2ea95
Parent
b72eb4d4b204480…
2 files changed
+134
-72
+3
-2
+134
-72
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -650,11 +650,11 @@ | ||
| 650 | 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | 652 | */ |
| 653 | 653 | #define SQLITE_VERSION "3.7.7" |
| 654 | 654 | #define SQLITE_VERSION_NUMBER 3007007 |
| 655 | -#define SQLITE_SOURCE_ID "2011-06-20 23:51:33 e60eefc76fa5066720d76858f6cfca56365330ee" | |
| 655 | +#define SQLITE_SOURCE_ID "2011-06-23 17:29:33 b61a76a53af04f731fe7617f7b6b4fb2aef6587b" | |
| 656 | 656 | |
| 657 | 657 | /* |
| 658 | 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | 660 | ** |
| @@ -6119,11 +6119,12 @@ | ||
| 6119 | 6119 | #define SQLITE_TESTCTRL_RESERVE 14 |
| 6120 | 6120 | #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 |
| 6121 | 6121 | #define SQLITE_TESTCTRL_ISKEYWORD 16 |
| 6122 | 6122 | #define SQLITE_TESTCTRL_PGHDRSZ 17 |
| 6123 | 6123 | #define SQLITE_TESTCTRL_SCRATCHMALLOC 18 |
| 6124 | -#define SQLITE_TESTCTRL_LAST 18 | |
| 6124 | +#define SQLITE_TESTCTRL_LOCALTIME_FAULT 19 | |
| 6125 | +#define SQLITE_TESTCTRL_LAST 19 | |
| 6125 | 6126 | |
| 6126 | 6127 | /* |
| 6127 | 6128 | ** CAPI3REF: SQLite Runtime Status |
| 6128 | 6129 | ** |
| 6129 | 6130 | ** ^This interface is used to retrieve runtime status information |
| @@ -9556,10 +9557,11 @@ | ||
| 9556 | 9557 | #define SQLITE_IndexSort 0x04 /* Disable indexes for sorting */ |
| 9557 | 9558 | #define SQLITE_IndexSearch 0x08 /* Disable indexes for searching */ |
| 9558 | 9559 | #define SQLITE_IndexCover 0x10 /* Disable index covering table */ |
| 9559 | 9560 | #define SQLITE_GroupByOrder 0x20 /* Disable GROUPBY cover of ORDERBY */ |
| 9560 | 9561 | #define SQLITE_FactorOutConst 0x40 /* Disable factoring out constants */ |
| 9562 | +#define SQLITE_IdxRealAsInt 0x80 /* Store REAL as INT in indices */ | |
| 9561 | 9563 | #define SQLITE_OptMask 0xff /* Mask of all disablable opts */ |
| 9562 | 9564 | |
| 9563 | 9565 | /* |
| 9564 | 9566 | ** Possible values for the sqlite.magic field. |
| 9565 | 9567 | ** The numbers are obtained at random and have no special meaning, other |
| @@ -11053,10 +11055,11 @@ | ||
| 11053 | 11055 | int isPCacheInit; /* True after malloc is initialized */ |
| 11054 | 11056 | sqlite3_mutex *pInitMutex; /* Mutex used by sqlite3_initialize() */ |
| 11055 | 11057 | int nRefInitMutex; /* Number of users of pInitMutex */ |
| 11056 | 11058 | void (*xLog)(void*,int,const char*); /* Function for logging */ |
| 11057 | 11059 | void *pLogArg; /* First argument to xLog() */ |
| 11060 | + int bLocaltimeFault; /* True to fail localtime() calls */ | |
| 11058 | 11061 | }; |
| 11059 | 11062 | |
| 11060 | 11063 | /* |
| 11061 | 11064 | ** Context pointer passed down through the tree-walk. |
| 11062 | 11065 | */ |
| @@ -12013,10 +12016,11 @@ | ||
| 12013 | 12016 | 0, /* isPCacheInit */ |
| 12014 | 12017 | 0, /* pInitMutex */ |
| 12015 | 12018 | 0, /* nRefInitMutex */ |
| 12016 | 12019 | 0, /* xLog */ |
| 12017 | 12020 | 0, /* pLogArg */ |
| 12021 | + 0, /* bLocaltimeFault */ | |
| 12018 | 12022 | }; |
| 12019 | 12023 | |
| 12020 | 12024 | |
| 12021 | 12025 | /* |
| 12022 | 12026 | ** Hash table for global functions - functions common to all |
| @@ -13163,26 +13167,10 @@ | ||
| 13163 | 13167 | */ |
| 13164 | 13168 | #include <time.h> |
| 13165 | 13169 | |
| 13166 | 13170 | #ifndef SQLITE_OMIT_DATETIME_FUNCS |
| 13167 | 13171 | |
| 13168 | -/* | |
| 13169 | -** On recent Windows platforms, the localtime_s() function is available | |
| 13170 | -** as part of the "Secure CRT". It is essentially equivalent to | |
| 13171 | -** localtime_r() available under most POSIX platforms, except that the | |
| 13172 | -** order of the parameters is reversed. | |
| 13173 | -** | |
| 13174 | -** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx. | |
| 13175 | -** | |
| 13176 | -** If the user has not indicated to use localtime_r() or localtime_s() | |
| 13177 | -** already, check for an MSVC build environment that provides | |
| 13178 | -** localtime_s(). | |
| 13179 | -*/ | |
| 13180 | -#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \ | |
| 13181 | - defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE) | |
| 13182 | -#define HAVE_LOCALTIME_S 1 | |
| 13183 | -#endif | |
| 13184 | 13172 | |
| 13185 | 13173 | /* |
| 13186 | 13174 | ** A structure for holding a single date and time. |
| 13187 | 13175 | */ |
| 13188 | 13176 | typedef struct DateTime DateTime; |
| @@ -13523,20 +13511,88 @@ | ||
| 13523 | 13511 | static void clearYMD_HMS_TZ(DateTime *p){ |
| 13524 | 13512 | p->validYMD = 0; |
| 13525 | 13513 | p->validHMS = 0; |
| 13526 | 13514 | p->validTZ = 0; |
| 13527 | 13515 | } |
| 13516 | + | |
| 13517 | +/* | |
| 13518 | +** On recent Windows platforms, the localtime_s() function is available | |
| 13519 | +** as part of the "Secure CRT". It is essentially equivalent to | |
| 13520 | +** localtime_r() available under most POSIX platforms, except that the | |
| 13521 | +** order of the parameters is reversed. | |
| 13522 | +** | |
| 13523 | +** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx. | |
| 13524 | +** | |
| 13525 | +** If the user has not indicated to use localtime_r() or localtime_s() | |
| 13526 | +** already, check for an MSVC build environment that provides | |
| 13527 | +** localtime_s(). | |
| 13528 | +*/ | |
| 13529 | +#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \ | |
| 13530 | + defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE) | |
| 13531 | +#define HAVE_LOCALTIME_S 1 | |
| 13532 | +#endif | |
| 13533 | + | |
| 13534 | +#ifndef SQLITE_OMIT_LOCALTIME | |
| 13535 | +/* | |
| 13536 | +** The following routine implements the rough equivalent of localtime_r() | |
| 13537 | +** using whatever operating-system specific localtime facility that | |
| 13538 | +** is available. This routine returns 0 on success and | |
| 13539 | +** non-zero on any kind of error. | |
| 13540 | +** | |
| 13541 | +** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this | |
| 13542 | +** routine will always fail. | |
| 13543 | +*/ | |
| 13544 | +static int osLocaltime(time_t *t, struct tm *pTm){ | |
| 13545 | + int rc; | |
| 13546 | +#if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \ | |
| 13547 | + && (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S) | |
| 13548 | + struct tm *pX; | |
| 13549 | + sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); | |
| 13550 | + sqlite3_mutex_enter(mutex); | |
| 13551 | + pX = localtime(t); | |
| 13552 | +#ifndef SQLITE_OMIT_BUILTIN_TEST | |
| 13553 | + if( sqlite3GlobalConfig.bLocaltimeFault ) pX = 0; | |
| 13554 | +#endif | |
| 13555 | + if( pX ) *pTm = *pX; | |
| 13556 | + sqlite3_mutex_leave(mutex); | |
| 13557 | + rc = pX==0; | |
| 13558 | +#else | |
| 13559 | +#ifndef SQLITE_OMIT_BUILTIN_TEST | |
| 13560 | + if( sqlite3GlobalConfig.bLocaltimeFault ) return 1; | |
| 13561 | +#endif | |
| 13562 | +#if defined(HAVE_LOCALTIME_R) && HAVE_LOCALTIME_R | |
| 13563 | + rc = localtime_r(t, pTm)==0; | |
| 13564 | +#else | |
| 13565 | + rc = localtime_s(pTm, t); | |
| 13566 | +#endif /* HAVE_LOCALTIME_R */ | |
| 13567 | +#endif /* HAVE_LOCALTIME_R || HAVE_LOCALTIME_S */ | |
| 13568 | + return rc; | |
| 13569 | +} | |
| 13570 | +#endif /* SQLITE_OMIT_LOCALTIME */ | |
| 13571 | + | |
| 13528 | 13572 | |
| 13529 | 13573 | #ifndef SQLITE_OMIT_LOCALTIME |
| 13530 | 13574 | /* |
| 13531 | -** Compute the difference (in milliseconds) | |
| 13532 | -** between localtime and UTC (a.k.a. GMT) | |
| 13533 | -** for the time value p where p is in UTC. | |
| 13575 | +** Compute the difference (in milliseconds) between localtime and UTC | |
| 13576 | +** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs, | |
| 13577 | +** return this value and set *pRc to SQLITE_OK. | |
| 13578 | +** | |
| 13579 | +** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value | |
| 13580 | +** is undefined in this case. | |
| 13534 | 13581 | */ |
| 13535 | -static sqlite3_int64 localtimeOffset(DateTime *p){ | |
| 13582 | +static sqlite3_int64 localtimeOffset( | |
| 13583 | + DateTime *p, /* Date at which to calculate offset */ | |
| 13584 | + sqlite3_context *pCtx, /* Write error here if one occurs */ | |
| 13585 | + int *pRc /* OUT: Error code. SQLITE_OK or ERROR */ | |
| 13586 | +){ | |
| 13536 | 13587 | DateTime x, y; |
| 13537 | 13588 | time_t t; |
| 13589 | + struct tm sLocal; | |
| 13590 | + | |
| 13591 | + /* Initialize the contents of sLocal to avoid a compiler warning. */ | |
| 13592 | + memset(&sLocal, 0, sizeof(sLocal)); | |
| 13593 | + | |
| 13538 | 13594 | x = *p; |
| 13539 | 13595 | computeYMD_HMS(&x); |
| 13540 | 13596 | if( x.Y<1971 || x.Y>=2038 ){ |
| 13541 | 13597 | x.Y = 2000; |
| 13542 | 13598 | x.M = 1; |
| @@ -13550,51 +13606,27 @@ | ||
| 13550 | 13606 | } |
| 13551 | 13607 | x.tz = 0; |
| 13552 | 13608 | x.validJD = 0; |
| 13553 | 13609 | computeJD(&x); |
| 13554 | 13610 | t = (time_t)(x.iJD/1000 - 21086676*(i64)10000); |
| 13555 | -#ifdef HAVE_LOCALTIME_R | |
| 13556 | - { | |
| 13557 | - struct tm sLocal; | |
| 13558 | - localtime_r(&t, &sLocal); | |
| 13559 | - y.Y = sLocal.tm_year + 1900; | |
| 13560 | - y.M = sLocal.tm_mon + 1; | |
| 13561 | - y.D = sLocal.tm_mday; | |
| 13562 | - y.h = sLocal.tm_hour; | |
| 13563 | - y.m = sLocal.tm_min; | |
| 13564 | - y.s = sLocal.tm_sec; | |
| 13565 | - } | |
| 13566 | -#elif defined(HAVE_LOCALTIME_S) && HAVE_LOCALTIME_S | |
| 13567 | - { | |
| 13568 | - struct tm sLocal; | |
| 13569 | - localtime_s(&sLocal, &t); | |
| 13570 | - y.Y = sLocal.tm_year + 1900; | |
| 13571 | - y.M = sLocal.tm_mon + 1; | |
| 13572 | - y.D = sLocal.tm_mday; | |
| 13573 | - y.h = sLocal.tm_hour; | |
| 13574 | - y.m = sLocal.tm_min; | |
| 13575 | - y.s = sLocal.tm_sec; | |
| 13576 | - } | |
| 13577 | -#else | |
| 13578 | - { | |
| 13579 | - struct tm *pTm; | |
| 13580 | - sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); | |
| 13581 | - pTm = localtime(&t); | |
| 13582 | - y.Y = pTm->tm_year + 1900; | |
| 13583 | - y.M = pTm->tm_mon + 1; | |
| 13584 | - y.D = pTm->tm_mday; | |
| 13585 | - y.h = pTm->tm_hour; | |
| 13586 | - y.m = pTm->tm_min; | |
| 13587 | - y.s = pTm->tm_sec; | |
| 13588 | - sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); | |
| 13589 | - } | |
| 13590 | -#endif | |
| 13611 | + if( osLocaltime(&t, &sLocal) ){ | |
| 13612 | + sqlite3_result_error(pCtx, "local time unavailable", -1); | |
| 13613 | + *pRc = SQLITE_ERROR; | |
| 13614 | + return 0; | |
| 13615 | + } | |
| 13616 | + y.Y = sLocal.tm_year + 1900; | |
| 13617 | + y.M = sLocal.tm_mon + 1; | |
| 13618 | + y.D = sLocal.tm_mday; | |
| 13619 | + y.h = sLocal.tm_hour; | |
| 13620 | + y.m = sLocal.tm_min; | |
| 13621 | + y.s = sLocal.tm_sec; | |
| 13591 | 13622 | y.validYMD = 1; |
| 13592 | 13623 | y.validHMS = 1; |
| 13593 | 13624 | y.validJD = 0; |
| 13594 | 13625 | y.validTZ = 0; |
| 13595 | 13626 | computeJD(&y); |
| 13627 | + *pRc = SQLITE_OK; | |
| 13596 | 13628 | return y.iJD - x.iJD; |
| 13597 | 13629 | } |
| 13598 | 13630 | #endif /* SQLITE_OMIT_LOCALTIME */ |
| 13599 | 13631 | |
| 13600 | 13632 | /* |
| @@ -13614,13 +13646,16 @@ | ||
| 13614 | 13646 | ** weekday N |
| 13615 | 13647 | ** unixepoch |
| 13616 | 13648 | ** localtime |
| 13617 | 13649 | ** utc |
| 13618 | 13650 | ** |
| 13619 | -** Return 0 on success and 1 if there is any kind of error. | |
| 13651 | +** Return 0 on success and 1 if there is any kind of error. If the error | |
| 13652 | +** is in a system call (i.e. localtime()), then an error message is written | |
| 13653 | +** to context pCtx. If the error is an unrecognized modifier, no error is | |
| 13654 | +** written to pCtx. | |
| 13620 | 13655 | */ |
| 13621 | -static int parseModifier(const char *zMod, DateTime *p){ | |
| 13656 | +static int parseModifier(sqlite3_context *pCtx, const char *zMod, DateTime *p){ | |
| 13622 | 13657 | int rc = 1; |
| 13623 | 13658 | int n; |
| 13624 | 13659 | double r; |
| 13625 | 13660 | char *z, zBuf[30]; |
| 13626 | 13661 | z = zBuf; |
| @@ -13636,13 +13671,12 @@ | ||
| 13636 | 13671 | ** Assuming the current time value is UTC (a.k.a. GMT), shift it to |
| 13637 | 13672 | ** show local time. |
| 13638 | 13673 | */ |
| 13639 | 13674 | if( strcmp(z, "localtime")==0 ){ |
| 13640 | 13675 | computeJD(p); |
| 13641 | - p->iJD += localtimeOffset(p); | |
| 13676 | + p->iJD += localtimeOffset(p, pCtx, &rc); | |
| 13642 | 13677 | clearYMD_HMS_TZ(p); |
| 13643 | - rc = 0; | |
| 13644 | 13678 | } |
| 13645 | 13679 | break; |
| 13646 | 13680 | } |
| 13647 | 13681 | #endif |
| 13648 | 13682 | case 'u': { |
| @@ -13659,15 +13693,16 @@ | ||
| 13659 | 13693 | } |
| 13660 | 13694 | #ifndef SQLITE_OMIT_LOCALTIME |
| 13661 | 13695 | else if( strcmp(z, "utc")==0 ){ |
| 13662 | 13696 | sqlite3_int64 c1; |
| 13663 | 13697 | computeJD(p); |
| 13664 | - c1 = localtimeOffset(p); | |
| 13665 | - p->iJD -= c1; | |
| 13666 | - clearYMD_HMS_TZ(p); | |
| 13667 | - p->iJD += c1 - localtimeOffset(p); | |
| 13668 | - rc = 0; | |
| 13698 | + c1 = localtimeOffset(p, pCtx, &rc); | |
| 13699 | + if( rc==SQLITE_OK ){ | |
| 13700 | + p->iJD -= c1; | |
| 13701 | + clearYMD_HMS_TZ(p); | |
| 13702 | + p->iJD += c1 - localtimeOffset(p, pCtx, &rc); | |
| 13703 | + } | |
| 13669 | 13704 | } |
| 13670 | 13705 | #endif |
| 13671 | 13706 | break; |
| 13672 | 13707 | } |
| 13673 | 13708 | case 'w': { |
| @@ -13844,13 +13879,12 @@ | ||
| 13844 | 13879 | if( !z || parseDateOrTime(context, (char*)z, p) ){ |
| 13845 | 13880 | return 1; |
| 13846 | 13881 | } |
| 13847 | 13882 | } |
| 13848 | 13883 | for(i=1; i<argc; i++){ |
| 13849 | - if( (z = sqlite3_value_text(argv[i]))==0 || parseModifier((char*)z, p) ){ | |
| 13850 | - return 1; | |
| 13851 | - } | |
| 13884 | + z = sqlite3_value_text(argv[i]); | |
| 13885 | + if( z==0 || parseModifier(context, (char*)z, p) ) return 1; | |
| 13852 | 13886 | } |
| 13853 | 13887 | return 0; |
| 13854 | 13888 | } |
| 13855 | 13889 | |
| 13856 | 13890 | |
| @@ -61212,10 +61246,18 @@ | ||
| 61212 | 61246 | rc = db->errCode = p->rc; |
| 61213 | 61247 | } |
| 61214 | 61248 | return (rc&db->errMask); |
| 61215 | 61249 | } |
| 61216 | 61250 | |
| 61251 | +/* | |
| 61252 | +** The maximum number of times that a statement will try to reparse | |
| 61253 | +** itself before giving up and returning SQLITE_SCHEMA. | |
| 61254 | +*/ | |
| 61255 | +#ifndef SQLITE_MAX_SCHEMA_RETRY | |
| 61256 | +# define SQLITE_MAX_SCHEMA_RETRY 5 | |
| 61257 | +#endif | |
| 61258 | + | |
| 61217 | 61259 | /* |
| 61218 | 61260 | ** This is the top-level implementation of sqlite3_step(). Call |
| 61219 | 61261 | ** sqlite3Step() to do most of the work. If a schema error occurs, |
| 61220 | 61262 | ** call sqlite3Reprepare() and try again. |
| 61221 | 61263 | */ |
| @@ -61230,11 +61272,11 @@ | ||
| 61230 | 61272 | return SQLITE_MISUSE_BKPT; |
| 61231 | 61273 | } |
| 61232 | 61274 | db = v->db; |
| 61233 | 61275 | sqlite3_mutex_enter(db->mutex); |
| 61234 | 61276 | while( (rc = sqlite3Step(v))==SQLITE_SCHEMA |
| 61235 | - && cnt++ < 5 | |
| 61277 | + && cnt++ < SQLITE_MAX_SCHEMA_RETRY | |
| 61236 | 61278 | && (rc2 = rc = sqlite3Reprepare(v))==SQLITE_OK ){ |
| 61237 | 61279 | sqlite3_reset(pStmt); |
| 61238 | 61280 | v->expired = 0; |
| 61239 | 61281 | } |
| 61240 | 61282 | if( rc2!=SQLITE_OK && ALWAYS(v->isPrepareV2) && ALWAYS(db->pErr) ){ |
| @@ -82142,12 +82184,18 @@ | ||
| 82142 | 82184 | sqlite3VdbeAddOp3(v, OP_Column, iCur, idx, regBase+j); |
| 82143 | 82185 | sqlite3ColumnDefault(v, pTab, idx, -1); |
| 82144 | 82186 | } |
| 82145 | 82187 | } |
| 82146 | 82188 | if( doMakeRec ){ |
| 82189 | + const char *zAff; | |
| 82190 | + if( pTab->pSelect || (pParse->db->flags & SQLITE_IdxRealAsInt)!=0 ){ | |
| 82191 | + zAff = 0; | |
| 82192 | + }else{ | |
| 82193 | + zAff = sqlite3IndexAffinityStr(v, pIdx); | |
| 82194 | + } | |
| 82147 | 82195 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol+1, regOut); |
| 82148 | - sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), P4_TRANSIENT); | |
| 82196 | + sqlite3VdbeChangeP4(v, -1, zAff, P4_TRANSIENT); | |
| 82149 | 82197 | } |
| 82150 | 82198 | sqlite3ReleaseTempRange(pParse, regBase, nCol+1); |
| 82151 | 82199 | return regBase; |
| 82152 | 82200 | } |
| 82153 | 82201 | |
| @@ -110770,10 +110818,21 @@ | ||
| 110770 | 110818 | if( sz ) *ppNew = sqlite3ScratchMalloc(sz); |
| 110771 | 110819 | sqlite3ScratchFree(pFree); |
| 110772 | 110820 | break; |
| 110773 | 110821 | } |
| 110774 | 110822 | |
| 110823 | + /* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff); | |
| 110824 | + ** | |
| 110825 | + ** If parameter onoff is non-zero, configure the wrappers so that all | |
| 110826 | + ** subsequent calls to localtime() and variants fail. If onoff is zero, | |
| 110827 | + ** undo this setting. | |
| 110828 | + */ | |
| 110829 | + case SQLITE_TESTCTRL_LOCALTIME_FAULT: { | |
| 110830 | + sqlite3GlobalConfig.bLocaltimeFault = va_arg(ap, int); | |
| 110831 | + break; | |
| 110832 | + } | |
| 110833 | + | |
| 110775 | 110834 | } |
| 110776 | 110835 | va_end(ap); |
| 110777 | 110836 | #endif /* SQLITE_OMIT_BUILTIN_TEST */ |
| 110778 | 110837 | return rc; |
| 110779 | 110838 | } |
| @@ -112562,10 +112621,13 @@ | ||
| 112562 | 112621 | rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0); |
| 112563 | 112622 | if( rc==SQLITE_OK ){ |
| 112564 | 112623 | sqlite3_step(pStmt); |
| 112565 | 112624 | p->nPgsz = sqlite3_column_int(pStmt, 0); |
| 112566 | 112625 | rc = sqlite3_finalize(pStmt); |
| 112626 | + }else if( rc==SQLITE_AUTH ){ | |
| 112627 | + p->nPgsz = 1024; | |
| 112628 | + rc = SQLITE_OK; | |
| 112567 | 112629 | } |
| 112568 | 112630 | } |
| 112569 | 112631 | assert( p->nPgsz>0 || rc!=SQLITE_OK ); |
| 112570 | 112632 | sqlite3_free(zSql); |
| 112571 | 112633 | *pRc = rc; |
| 112572 | 112634 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -650,11 +650,11 @@ | |
| 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | */ |
| 653 | #define SQLITE_VERSION "3.7.7" |
| 654 | #define SQLITE_VERSION_NUMBER 3007007 |
| 655 | #define SQLITE_SOURCE_ID "2011-06-20 23:51:33 e60eefc76fa5066720d76858f6cfca56365330ee" |
| 656 | |
| 657 | /* |
| 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | ** |
| @@ -6119,11 +6119,12 @@ | |
| 6119 | #define SQLITE_TESTCTRL_RESERVE 14 |
| 6120 | #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 |
| 6121 | #define SQLITE_TESTCTRL_ISKEYWORD 16 |
| 6122 | #define SQLITE_TESTCTRL_PGHDRSZ 17 |
| 6123 | #define SQLITE_TESTCTRL_SCRATCHMALLOC 18 |
| 6124 | #define SQLITE_TESTCTRL_LAST 18 |
| 6125 | |
| 6126 | /* |
| 6127 | ** CAPI3REF: SQLite Runtime Status |
| 6128 | ** |
| 6129 | ** ^This interface is used to retrieve runtime status information |
| @@ -9556,10 +9557,11 @@ | |
| 9556 | #define SQLITE_IndexSort 0x04 /* Disable indexes for sorting */ |
| 9557 | #define SQLITE_IndexSearch 0x08 /* Disable indexes for searching */ |
| 9558 | #define SQLITE_IndexCover 0x10 /* Disable index covering table */ |
| 9559 | #define SQLITE_GroupByOrder 0x20 /* Disable GROUPBY cover of ORDERBY */ |
| 9560 | #define SQLITE_FactorOutConst 0x40 /* Disable factoring out constants */ |
| 9561 | #define SQLITE_OptMask 0xff /* Mask of all disablable opts */ |
| 9562 | |
| 9563 | /* |
| 9564 | ** Possible values for the sqlite.magic field. |
| 9565 | ** The numbers are obtained at random and have no special meaning, other |
| @@ -11053,10 +11055,11 @@ | |
| 11053 | int isPCacheInit; /* True after malloc is initialized */ |
| 11054 | sqlite3_mutex *pInitMutex; /* Mutex used by sqlite3_initialize() */ |
| 11055 | int nRefInitMutex; /* Number of users of pInitMutex */ |
| 11056 | void (*xLog)(void*,int,const char*); /* Function for logging */ |
| 11057 | void *pLogArg; /* First argument to xLog() */ |
| 11058 | }; |
| 11059 | |
| 11060 | /* |
| 11061 | ** Context pointer passed down through the tree-walk. |
| 11062 | */ |
| @@ -12013,10 +12016,11 @@ | |
| 12013 | 0, /* isPCacheInit */ |
| 12014 | 0, /* pInitMutex */ |
| 12015 | 0, /* nRefInitMutex */ |
| 12016 | 0, /* xLog */ |
| 12017 | 0, /* pLogArg */ |
| 12018 | }; |
| 12019 | |
| 12020 | |
| 12021 | /* |
| 12022 | ** Hash table for global functions - functions common to all |
| @@ -13163,26 +13167,10 @@ | |
| 13163 | */ |
| 13164 | #include <time.h> |
| 13165 | |
| 13166 | #ifndef SQLITE_OMIT_DATETIME_FUNCS |
| 13167 | |
| 13168 | /* |
| 13169 | ** On recent Windows platforms, the localtime_s() function is available |
| 13170 | ** as part of the "Secure CRT". It is essentially equivalent to |
| 13171 | ** localtime_r() available under most POSIX platforms, except that the |
| 13172 | ** order of the parameters is reversed. |
| 13173 | ** |
| 13174 | ** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx. |
| 13175 | ** |
| 13176 | ** If the user has not indicated to use localtime_r() or localtime_s() |
| 13177 | ** already, check for an MSVC build environment that provides |
| 13178 | ** localtime_s(). |
| 13179 | */ |
| 13180 | #if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \ |
| 13181 | defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE) |
| 13182 | #define HAVE_LOCALTIME_S 1 |
| 13183 | #endif |
| 13184 | |
| 13185 | /* |
| 13186 | ** A structure for holding a single date and time. |
| 13187 | */ |
| 13188 | typedef struct DateTime DateTime; |
| @@ -13523,20 +13511,88 @@ | |
| 13523 | static void clearYMD_HMS_TZ(DateTime *p){ |
| 13524 | p->validYMD = 0; |
| 13525 | p->validHMS = 0; |
| 13526 | p->validTZ = 0; |
| 13527 | } |
| 13528 | |
| 13529 | #ifndef SQLITE_OMIT_LOCALTIME |
| 13530 | /* |
| 13531 | ** Compute the difference (in milliseconds) |
| 13532 | ** between localtime and UTC (a.k.a. GMT) |
| 13533 | ** for the time value p where p is in UTC. |
| 13534 | */ |
| 13535 | static sqlite3_int64 localtimeOffset(DateTime *p){ |
| 13536 | DateTime x, y; |
| 13537 | time_t t; |
| 13538 | x = *p; |
| 13539 | computeYMD_HMS(&x); |
| 13540 | if( x.Y<1971 || x.Y>=2038 ){ |
| 13541 | x.Y = 2000; |
| 13542 | x.M = 1; |
| @@ -13550,51 +13606,27 @@ | |
| 13550 | } |
| 13551 | x.tz = 0; |
| 13552 | x.validJD = 0; |
| 13553 | computeJD(&x); |
| 13554 | t = (time_t)(x.iJD/1000 - 21086676*(i64)10000); |
| 13555 | #ifdef HAVE_LOCALTIME_R |
| 13556 | { |
| 13557 | struct tm sLocal; |
| 13558 | localtime_r(&t, &sLocal); |
| 13559 | y.Y = sLocal.tm_year + 1900; |
| 13560 | y.M = sLocal.tm_mon + 1; |
| 13561 | y.D = sLocal.tm_mday; |
| 13562 | y.h = sLocal.tm_hour; |
| 13563 | y.m = sLocal.tm_min; |
| 13564 | y.s = sLocal.tm_sec; |
| 13565 | } |
| 13566 | #elif defined(HAVE_LOCALTIME_S) && HAVE_LOCALTIME_S |
| 13567 | { |
| 13568 | struct tm sLocal; |
| 13569 | localtime_s(&sLocal, &t); |
| 13570 | y.Y = sLocal.tm_year + 1900; |
| 13571 | y.M = sLocal.tm_mon + 1; |
| 13572 | y.D = sLocal.tm_mday; |
| 13573 | y.h = sLocal.tm_hour; |
| 13574 | y.m = sLocal.tm_min; |
| 13575 | y.s = sLocal.tm_sec; |
| 13576 | } |
| 13577 | #else |
| 13578 | { |
| 13579 | struct tm *pTm; |
| 13580 | sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); |
| 13581 | pTm = localtime(&t); |
| 13582 | y.Y = pTm->tm_year + 1900; |
| 13583 | y.M = pTm->tm_mon + 1; |
| 13584 | y.D = pTm->tm_mday; |
| 13585 | y.h = pTm->tm_hour; |
| 13586 | y.m = pTm->tm_min; |
| 13587 | y.s = pTm->tm_sec; |
| 13588 | sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); |
| 13589 | } |
| 13590 | #endif |
| 13591 | y.validYMD = 1; |
| 13592 | y.validHMS = 1; |
| 13593 | y.validJD = 0; |
| 13594 | y.validTZ = 0; |
| 13595 | computeJD(&y); |
| 13596 | return y.iJD - x.iJD; |
| 13597 | } |
| 13598 | #endif /* SQLITE_OMIT_LOCALTIME */ |
| 13599 | |
| 13600 | /* |
| @@ -13614,13 +13646,16 @@ | |
| 13614 | ** weekday N |
| 13615 | ** unixepoch |
| 13616 | ** localtime |
| 13617 | ** utc |
| 13618 | ** |
| 13619 | ** Return 0 on success and 1 if there is any kind of error. |
| 13620 | */ |
| 13621 | static int parseModifier(const char *zMod, DateTime *p){ |
| 13622 | int rc = 1; |
| 13623 | int n; |
| 13624 | double r; |
| 13625 | char *z, zBuf[30]; |
| 13626 | z = zBuf; |
| @@ -13636,13 +13671,12 @@ | |
| 13636 | ** Assuming the current time value is UTC (a.k.a. GMT), shift it to |
| 13637 | ** show local time. |
| 13638 | */ |
| 13639 | if( strcmp(z, "localtime")==0 ){ |
| 13640 | computeJD(p); |
| 13641 | p->iJD += localtimeOffset(p); |
| 13642 | clearYMD_HMS_TZ(p); |
| 13643 | rc = 0; |
| 13644 | } |
| 13645 | break; |
| 13646 | } |
| 13647 | #endif |
| 13648 | case 'u': { |
| @@ -13659,15 +13693,16 @@ | |
| 13659 | } |
| 13660 | #ifndef SQLITE_OMIT_LOCALTIME |
| 13661 | else if( strcmp(z, "utc")==0 ){ |
| 13662 | sqlite3_int64 c1; |
| 13663 | computeJD(p); |
| 13664 | c1 = localtimeOffset(p); |
| 13665 | p->iJD -= c1; |
| 13666 | clearYMD_HMS_TZ(p); |
| 13667 | p->iJD += c1 - localtimeOffset(p); |
| 13668 | rc = 0; |
| 13669 | } |
| 13670 | #endif |
| 13671 | break; |
| 13672 | } |
| 13673 | case 'w': { |
| @@ -13844,13 +13879,12 @@ | |
| 13844 | if( !z || parseDateOrTime(context, (char*)z, p) ){ |
| 13845 | return 1; |
| 13846 | } |
| 13847 | } |
| 13848 | for(i=1; i<argc; i++){ |
| 13849 | if( (z = sqlite3_value_text(argv[i]))==0 || parseModifier((char*)z, p) ){ |
| 13850 | return 1; |
| 13851 | } |
| 13852 | } |
| 13853 | return 0; |
| 13854 | } |
| 13855 | |
| 13856 | |
| @@ -61212,10 +61246,18 @@ | |
| 61212 | rc = db->errCode = p->rc; |
| 61213 | } |
| 61214 | return (rc&db->errMask); |
| 61215 | } |
| 61216 | |
| 61217 | /* |
| 61218 | ** This is the top-level implementation of sqlite3_step(). Call |
| 61219 | ** sqlite3Step() to do most of the work. If a schema error occurs, |
| 61220 | ** call sqlite3Reprepare() and try again. |
| 61221 | */ |
| @@ -61230,11 +61272,11 @@ | |
| 61230 | return SQLITE_MISUSE_BKPT; |
| 61231 | } |
| 61232 | db = v->db; |
| 61233 | sqlite3_mutex_enter(db->mutex); |
| 61234 | while( (rc = sqlite3Step(v))==SQLITE_SCHEMA |
| 61235 | && cnt++ < 5 |
| 61236 | && (rc2 = rc = sqlite3Reprepare(v))==SQLITE_OK ){ |
| 61237 | sqlite3_reset(pStmt); |
| 61238 | v->expired = 0; |
| 61239 | } |
| 61240 | if( rc2!=SQLITE_OK && ALWAYS(v->isPrepareV2) && ALWAYS(db->pErr) ){ |
| @@ -82142,12 +82184,18 @@ | |
| 82142 | sqlite3VdbeAddOp3(v, OP_Column, iCur, idx, regBase+j); |
| 82143 | sqlite3ColumnDefault(v, pTab, idx, -1); |
| 82144 | } |
| 82145 | } |
| 82146 | if( doMakeRec ){ |
| 82147 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol+1, regOut); |
| 82148 | sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), P4_TRANSIENT); |
| 82149 | } |
| 82150 | sqlite3ReleaseTempRange(pParse, regBase, nCol+1); |
| 82151 | return regBase; |
| 82152 | } |
| 82153 | |
| @@ -110770,10 +110818,21 @@ | |
| 110770 | if( sz ) *ppNew = sqlite3ScratchMalloc(sz); |
| 110771 | sqlite3ScratchFree(pFree); |
| 110772 | break; |
| 110773 | } |
| 110774 | |
| 110775 | } |
| 110776 | va_end(ap); |
| 110777 | #endif /* SQLITE_OMIT_BUILTIN_TEST */ |
| 110778 | return rc; |
| 110779 | } |
| @@ -112562,10 +112621,13 @@ | |
| 112562 | rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0); |
| 112563 | if( rc==SQLITE_OK ){ |
| 112564 | sqlite3_step(pStmt); |
| 112565 | p->nPgsz = sqlite3_column_int(pStmt, 0); |
| 112566 | rc = sqlite3_finalize(pStmt); |
| 112567 | } |
| 112568 | } |
| 112569 | assert( p->nPgsz>0 || rc!=SQLITE_OK ); |
| 112570 | sqlite3_free(zSql); |
| 112571 | *pRc = rc; |
| 112572 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -650,11 +650,11 @@ | |
| 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | */ |
| 653 | #define SQLITE_VERSION "3.7.7" |
| 654 | #define SQLITE_VERSION_NUMBER 3007007 |
| 655 | #define SQLITE_SOURCE_ID "2011-06-23 17:29:33 b61a76a53af04f731fe7617f7b6b4fb2aef6587b" |
| 656 | |
| 657 | /* |
| 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | ** |
| @@ -6119,11 +6119,12 @@ | |
| 6119 | #define SQLITE_TESTCTRL_RESERVE 14 |
| 6120 | #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 |
| 6121 | #define SQLITE_TESTCTRL_ISKEYWORD 16 |
| 6122 | #define SQLITE_TESTCTRL_PGHDRSZ 17 |
| 6123 | #define SQLITE_TESTCTRL_SCRATCHMALLOC 18 |
| 6124 | #define SQLITE_TESTCTRL_LOCALTIME_FAULT 19 |
| 6125 | #define SQLITE_TESTCTRL_LAST 19 |
| 6126 | |
| 6127 | /* |
| 6128 | ** CAPI3REF: SQLite Runtime Status |
| 6129 | ** |
| 6130 | ** ^This interface is used to retrieve runtime status information |
| @@ -9556,10 +9557,11 @@ | |
| 9557 | #define SQLITE_IndexSort 0x04 /* Disable indexes for sorting */ |
| 9558 | #define SQLITE_IndexSearch 0x08 /* Disable indexes for searching */ |
| 9559 | #define SQLITE_IndexCover 0x10 /* Disable index covering table */ |
| 9560 | #define SQLITE_GroupByOrder 0x20 /* Disable GROUPBY cover of ORDERBY */ |
| 9561 | #define SQLITE_FactorOutConst 0x40 /* Disable factoring out constants */ |
| 9562 | #define SQLITE_IdxRealAsInt 0x80 /* Store REAL as INT in indices */ |
| 9563 | #define SQLITE_OptMask 0xff /* Mask of all disablable opts */ |
| 9564 | |
| 9565 | /* |
| 9566 | ** Possible values for the sqlite.magic field. |
| 9567 | ** The numbers are obtained at random and have no special meaning, other |
| @@ -11053,10 +11055,11 @@ | |
| 11055 | int isPCacheInit; /* True after malloc is initialized */ |
| 11056 | sqlite3_mutex *pInitMutex; /* Mutex used by sqlite3_initialize() */ |
| 11057 | int nRefInitMutex; /* Number of users of pInitMutex */ |
| 11058 | void (*xLog)(void*,int,const char*); /* Function for logging */ |
| 11059 | void *pLogArg; /* First argument to xLog() */ |
| 11060 | int bLocaltimeFault; /* True to fail localtime() calls */ |
| 11061 | }; |
| 11062 | |
| 11063 | /* |
| 11064 | ** Context pointer passed down through the tree-walk. |
| 11065 | */ |
| @@ -12013,10 +12016,11 @@ | |
| 12016 | 0, /* isPCacheInit */ |
| 12017 | 0, /* pInitMutex */ |
| 12018 | 0, /* nRefInitMutex */ |
| 12019 | 0, /* xLog */ |
| 12020 | 0, /* pLogArg */ |
| 12021 | 0, /* bLocaltimeFault */ |
| 12022 | }; |
| 12023 | |
| 12024 | |
| 12025 | /* |
| 12026 | ** Hash table for global functions - functions common to all |
| @@ -13163,26 +13167,10 @@ | |
| 13167 | */ |
| 13168 | #include <time.h> |
| 13169 | |
| 13170 | #ifndef SQLITE_OMIT_DATETIME_FUNCS |
| 13171 | |
| 13172 | |
| 13173 | /* |
| 13174 | ** A structure for holding a single date and time. |
| 13175 | */ |
| 13176 | typedef struct DateTime DateTime; |
| @@ -13523,20 +13511,88 @@ | |
| 13511 | static void clearYMD_HMS_TZ(DateTime *p){ |
| 13512 | p->validYMD = 0; |
| 13513 | p->validHMS = 0; |
| 13514 | p->validTZ = 0; |
| 13515 | } |
| 13516 | |
| 13517 | /* |
| 13518 | ** On recent Windows platforms, the localtime_s() function is available |
| 13519 | ** as part of the "Secure CRT". It is essentially equivalent to |
| 13520 | ** localtime_r() available under most POSIX platforms, except that the |
| 13521 | ** order of the parameters is reversed. |
| 13522 | ** |
| 13523 | ** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx. |
| 13524 | ** |
| 13525 | ** If the user has not indicated to use localtime_r() or localtime_s() |
| 13526 | ** already, check for an MSVC build environment that provides |
| 13527 | ** localtime_s(). |
| 13528 | */ |
| 13529 | #if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \ |
| 13530 | defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE) |
| 13531 | #define HAVE_LOCALTIME_S 1 |
| 13532 | #endif |
| 13533 | |
| 13534 | #ifndef SQLITE_OMIT_LOCALTIME |
| 13535 | /* |
| 13536 | ** The following routine implements the rough equivalent of localtime_r() |
| 13537 | ** using whatever operating-system specific localtime facility that |
| 13538 | ** is available. This routine returns 0 on success and |
| 13539 | ** non-zero on any kind of error. |
| 13540 | ** |
| 13541 | ** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this |
| 13542 | ** routine will always fail. |
| 13543 | */ |
| 13544 | static int osLocaltime(time_t *t, struct tm *pTm){ |
| 13545 | int rc; |
| 13546 | #if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \ |
| 13547 | && (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S) |
| 13548 | struct tm *pX; |
| 13549 | sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); |
| 13550 | sqlite3_mutex_enter(mutex); |
| 13551 | pX = localtime(t); |
| 13552 | #ifndef SQLITE_OMIT_BUILTIN_TEST |
| 13553 | if( sqlite3GlobalConfig.bLocaltimeFault ) pX = 0; |
| 13554 | #endif |
| 13555 | if( pX ) *pTm = *pX; |
| 13556 | sqlite3_mutex_leave(mutex); |
| 13557 | rc = pX==0; |
| 13558 | #else |
| 13559 | #ifndef SQLITE_OMIT_BUILTIN_TEST |
| 13560 | if( sqlite3GlobalConfig.bLocaltimeFault ) return 1; |
| 13561 | #endif |
| 13562 | #if defined(HAVE_LOCALTIME_R) && HAVE_LOCALTIME_R |
| 13563 | rc = localtime_r(t, pTm)==0; |
| 13564 | #else |
| 13565 | rc = localtime_s(pTm, t); |
| 13566 | #endif /* HAVE_LOCALTIME_R */ |
| 13567 | #endif /* HAVE_LOCALTIME_R || HAVE_LOCALTIME_S */ |
| 13568 | return rc; |
| 13569 | } |
| 13570 | #endif /* SQLITE_OMIT_LOCALTIME */ |
| 13571 | |
| 13572 | |
| 13573 | #ifndef SQLITE_OMIT_LOCALTIME |
| 13574 | /* |
| 13575 | ** Compute the difference (in milliseconds) between localtime and UTC |
| 13576 | ** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs, |
| 13577 | ** return this value and set *pRc to SQLITE_OK. |
| 13578 | ** |
| 13579 | ** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value |
| 13580 | ** is undefined in this case. |
| 13581 | */ |
| 13582 | static sqlite3_int64 localtimeOffset( |
| 13583 | DateTime *p, /* Date at which to calculate offset */ |
| 13584 | sqlite3_context *pCtx, /* Write error here if one occurs */ |
| 13585 | int *pRc /* OUT: Error code. SQLITE_OK or ERROR */ |
| 13586 | ){ |
| 13587 | DateTime x, y; |
| 13588 | time_t t; |
| 13589 | struct tm sLocal; |
| 13590 | |
| 13591 | /* Initialize the contents of sLocal to avoid a compiler warning. */ |
| 13592 | memset(&sLocal, 0, sizeof(sLocal)); |
| 13593 | |
| 13594 | x = *p; |
| 13595 | computeYMD_HMS(&x); |
| 13596 | if( x.Y<1971 || x.Y>=2038 ){ |
| 13597 | x.Y = 2000; |
| 13598 | x.M = 1; |
| @@ -13550,51 +13606,27 @@ | |
| 13606 | } |
| 13607 | x.tz = 0; |
| 13608 | x.validJD = 0; |
| 13609 | computeJD(&x); |
| 13610 | t = (time_t)(x.iJD/1000 - 21086676*(i64)10000); |
| 13611 | if( osLocaltime(&t, &sLocal) ){ |
| 13612 | sqlite3_result_error(pCtx, "local time unavailable", -1); |
| 13613 | *pRc = SQLITE_ERROR; |
| 13614 | return 0; |
| 13615 | } |
| 13616 | y.Y = sLocal.tm_year + 1900; |
| 13617 | y.M = sLocal.tm_mon + 1; |
| 13618 | y.D = sLocal.tm_mday; |
| 13619 | y.h = sLocal.tm_hour; |
| 13620 | y.m = sLocal.tm_min; |
| 13621 | y.s = sLocal.tm_sec; |
| 13622 | y.validYMD = 1; |
| 13623 | y.validHMS = 1; |
| 13624 | y.validJD = 0; |
| 13625 | y.validTZ = 0; |
| 13626 | computeJD(&y); |
| 13627 | *pRc = SQLITE_OK; |
| 13628 | return y.iJD - x.iJD; |
| 13629 | } |
| 13630 | #endif /* SQLITE_OMIT_LOCALTIME */ |
| 13631 | |
| 13632 | /* |
| @@ -13614,13 +13646,16 @@ | |
| 13646 | ** weekday N |
| 13647 | ** unixepoch |
| 13648 | ** localtime |
| 13649 | ** utc |
| 13650 | ** |
| 13651 | ** Return 0 on success and 1 if there is any kind of error. If the error |
| 13652 | ** is in a system call (i.e. localtime()), then an error message is written |
| 13653 | ** to context pCtx. If the error is an unrecognized modifier, no error is |
| 13654 | ** written to pCtx. |
| 13655 | */ |
| 13656 | static int parseModifier(sqlite3_context *pCtx, const char *zMod, DateTime *p){ |
| 13657 | int rc = 1; |
| 13658 | int n; |
| 13659 | double r; |
| 13660 | char *z, zBuf[30]; |
| 13661 | z = zBuf; |
| @@ -13636,13 +13671,12 @@ | |
| 13671 | ** Assuming the current time value is UTC (a.k.a. GMT), shift it to |
| 13672 | ** show local time. |
| 13673 | */ |
| 13674 | if( strcmp(z, "localtime")==0 ){ |
| 13675 | computeJD(p); |
| 13676 | p->iJD += localtimeOffset(p, pCtx, &rc); |
| 13677 | clearYMD_HMS_TZ(p); |
| 13678 | } |
| 13679 | break; |
| 13680 | } |
| 13681 | #endif |
| 13682 | case 'u': { |
| @@ -13659,15 +13693,16 @@ | |
| 13693 | } |
| 13694 | #ifndef SQLITE_OMIT_LOCALTIME |
| 13695 | else if( strcmp(z, "utc")==0 ){ |
| 13696 | sqlite3_int64 c1; |
| 13697 | computeJD(p); |
| 13698 | c1 = localtimeOffset(p, pCtx, &rc); |
| 13699 | if( rc==SQLITE_OK ){ |
| 13700 | p->iJD -= c1; |
| 13701 | clearYMD_HMS_TZ(p); |
| 13702 | p->iJD += c1 - localtimeOffset(p, pCtx, &rc); |
| 13703 | } |
| 13704 | } |
| 13705 | #endif |
| 13706 | break; |
| 13707 | } |
| 13708 | case 'w': { |
| @@ -13844,13 +13879,12 @@ | |
| 13879 | if( !z || parseDateOrTime(context, (char*)z, p) ){ |
| 13880 | return 1; |
| 13881 | } |
| 13882 | } |
| 13883 | for(i=1; i<argc; i++){ |
| 13884 | z = sqlite3_value_text(argv[i]); |
| 13885 | if( z==0 || parseModifier(context, (char*)z, p) ) return 1; |
| 13886 | } |
| 13887 | return 0; |
| 13888 | } |
| 13889 | |
| 13890 | |
| @@ -61212,10 +61246,18 @@ | |
| 61246 | rc = db->errCode = p->rc; |
| 61247 | } |
| 61248 | return (rc&db->errMask); |
| 61249 | } |
| 61250 | |
| 61251 | /* |
| 61252 | ** The maximum number of times that a statement will try to reparse |
| 61253 | ** itself before giving up and returning SQLITE_SCHEMA. |
| 61254 | */ |
| 61255 | #ifndef SQLITE_MAX_SCHEMA_RETRY |
| 61256 | # define SQLITE_MAX_SCHEMA_RETRY 5 |
| 61257 | #endif |
| 61258 | |
| 61259 | /* |
| 61260 | ** This is the top-level implementation of sqlite3_step(). Call |
| 61261 | ** sqlite3Step() to do most of the work. If a schema error occurs, |
| 61262 | ** call sqlite3Reprepare() and try again. |
| 61263 | */ |
| @@ -61230,11 +61272,11 @@ | |
| 61272 | return SQLITE_MISUSE_BKPT; |
| 61273 | } |
| 61274 | db = v->db; |
| 61275 | sqlite3_mutex_enter(db->mutex); |
| 61276 | while( (rc = sqlite3Step(v))==SQLITE_SCHEMA |
| 61277 | && cnt++ < SQLITE_MAX_SCHEMA_RETRY |
| 61278 | && (rc2 = rc = sqlite3Reprepare(v))==SQLITE_OK ){ |
| 61279 | sqlite3_reset(pStmt); |
| 61280 | v->expired = 0; |
| 61281 | } |
| 61282 | if( rc2!=SQLITE_OK && ALWAYS(v->isPrepareV2) && ALWAYS(db->pErr) ){ |
| @@ -82142,12 +82184,18 @@ | |
| 82184 | sqlite3VdbeAddOp3(v, OP_Column, iCur, idx, regBase+j); |
| 82185 | sqlite3ColumnDefault(v, pTab, idx, -1); |
| 82186 | } |
| 82187 | } |
| 82188 | if( doMakeRec ){ |
| 82189 | const char *zAff; |
| 82190 | if( pTab->pSelect || (pParse->db->flags & SQLITE_IdxRealAsInt)!=0 ){ |
| 82191 | zAff = 0; |
| 82192 | }else{ |
| 82193 | zAff = sqlite3IndexAffinityStr(v, pIdx); |
| 82194 | } |
| 82195 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol+1, regOut); |
| 82196 | sqlite3VdbeChangeP4(v, -1, zAff, P4_TRANSIENT); |
| 82197 | } |
| 82198 | sqlite3ReleaseTempRange(pParse, regBase, nCol+1); |
| 82199 | return regBase; |
| 82200 | } |
| 82201 | |
| @@ -110770,10 +110818,21 @@ | |
| 110818 | if( sz ) *ppNew = sqlite3ScratchMalloc(sz); |
| 110819 | sqlite3ScratchFree(pFree); |
| 110820 | break; |
| 110821 | } |
| 110822 | |
| 110823 | /* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff); |
| 110824 | ** |
| 110825 | ** If parameter onoff is non-zero, configure the wrappers so that all |
| 110826 | ** subsequent calls to localtime() and variants fail. If onoff is zero, |
| 110827 | ** undo this setting. |
| 110828 | */ |
| 110829 | case SQLITE_TESTCTRL_LOCALTIME_FAULT: { |
| 110830 | sqlite3GlobalConfig.bLocaltimeFault = va_arg(ap, int); |
| 110831 | break; |
| 110832 | } |
| 110833 | |
| 110834 | } |
| 110835 | va_end(ap); |
| 110836 | #endif /* SQLITE_OMIT_BUILTIN_TEST */ |
| 110837 | return rc; |
| 110838 | } |
| @@ -112562,10 +112621,13 @@ | |
| 112621 | rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0); |
| 112622 | if( rc==SQLITE_OK ){ |
| 112623 | sqlite3_step(pStmt); |
| 112624 | p->nPgsz = sqlite3_column_int(pStmt, 0); |
| 112625 | rc = sqlite3_finalize(pStmt); |
| 112626 | }else if( rc==SQLITE_AUTH ){ |
| 112627 | p->nPgsz = 1024; |
| 112628 | rc = SQLITE_OK; |
| 112629 | } |
| 112630 | } |
| 112631 | assert( p->nPgsz>0 || rc!=SQLITE_OK ); |
| 112632 | sqlite3_free(zSql); |
| 112633 | *pRc = rc; |
| 112634 |
+3
-2
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -107,11 +107,11 @@ | ||
| 107 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | 109 | */ |
| 110 | 110 | #define SQLITE_VERSION "3.7.7" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3007007 |
| 112 | -#define SQLITE_SOURCE_ID "2011-06-20 23:51:33 e60eefc76fa5066720d76858f6cfca56365330ee" | |
| 112 | +#define SQLITE_SOURCE_ID "2011-06-23 17:29:33 b61a76a53af04f731fe7617f7b6b4fb2aef6587b" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| @@ -5576,11 +5576,12 @@ | ||
| 5576 | 5576 | #define SQLITE_TESTCTRL_RESERVE 14 |
| 5577 | 5577 | #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 |
| 5578 | 5578 | #define SQLITE_TESTCTRL_ISKEYWORD 16 |
| 5579 | 5579 | #define SQLITE_TESTCTRL_PGHDRSZ 17 |
| 5580 | 5580 | #define SQLITE_TESTCTRL_SCRATCHMALLOC 18 |
| 5581 | -#define SQLITE_TESTCTRL_LAST 18 | |
| 5581 | +#define SQLITE_TESTCTRL_LOCALTIME_FAULT 19 | |
| 5582 | +#define SQLITE_TESTCTRL_LAST 19 | |
| 5582 | 5583 | |
| 5583 | 5584 | /* |
| 5584 | 5585 | ** CAPI3REF: SQLite Runtime Status |
| 5585 | 5586 | ** |
| 5586 | 5587 | ** ^This interface is used to retrieve runtime status information |
| 5587 | 5588 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.7" |
| 111 | #define SQLITE_VERSION_NUMBER 3007007 |
| 112 | #define SQLITE_SOURCE_ID "2011-06-20 23:51:33 e60eefc76fa5066720d76858f6cfca56365330ee" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -5576,11 +5576,12 @@ | |
| 5576 | #define SQLITE_TESTCTRL_RESERVE 14 |
| 5577 | #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 |
| 5578 | #define SQLITE_TESTCTRL_ISKEYWORD 16 |
| 5579 | #define SQLITE_TESTCTRL_PGHDRSZ 17 |
| 5580 | #define SQLITE_TESTCTRL_SCRATCHMALLOC 18 |
| 5581 | #define SQLITE_TESTCTRL_LAST 18 |
| 5582 | |
| 5583 | /* |
| 5584 | ** CAPI3REF: SQLite Runtime Status |
| 5585 | ** |
| 5586 | ** ^This interface is used to retrieve runtime status information |
| 5587 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.7" |
| 111 | #define SQLITE_VERSION_NUMBER 3007007 |
| 112 | #define SQLITE_SOURCE_ID "2011-06-23 17:29:33 b61a76a53af04f731fe7617f7b6b4fb2aef6587b" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -5576,11 +5576,12 @@ | |
| 5576 | #define SQLITE_TESTCTRL_RESERVE 14 |
| 5577 | #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 |
| 5578 | #define SQLITE_TESTCTRL_ISKEYWORD 16 |
| 5579 | #define SQLITE_TESTCTRL_PGHDRSZ 17 |
| 5580 | #define SQLITE_TESTCTRL_SCRATCHMALLOC 18 |
| 5581 | #define SQLITE_TESTCTRL_LOCALTIME_FAULT 19 |
| 5582 | #define SQLITE_TESTCTRL_LAST 19 |
| 5583 | |
| 5584 | /* |
| 5585 | ** CAPI3REF: SQLite Runtime Status |
| 5586 | ** |
| 5587 | ** ^This interface is used to retrieve runtime status information |
| 5588 |