Sync w/trunk, allow build-time override of auto-column decorating character

FossilOrigin-Name: caaef4c592c980889efb349fa73b61303ec493172d90cd67d54ffde0855e4138
This commit is contained in:
larrybr 2022-02-12 02:15:37 +00:00
commit 78138397b5
16 changed files with 356 additions and 250 deletions

View File

@ -1,5 +1,5 @@
C Upon\s.import\scolumn\srenaming,\sissue\smessage\ssaying\sso.\sTest\sthis.
D 2022-02-11T13:40:25.959
C Sync\sw/trunk,\sallow\sbuild-time\soverride\sof\sauto-column\sdecorating\scharacter
D 2022-02-12T02:15:37.064
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -499,7 +499,7 @@ F src/build.c b59ff41525c10b429adc277d3bca6e433b09d055b0df8c1529385763cea8bb04
F src/callback.c 4c19af69835787bfe790ac560f3071a824eb629f34e41f97b52ce5235c77de1c
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
F src/ctime.c 2cce39df1a13e05b7633e6d21b651f21492471f991dd7b323a4ee4e7b7f0b7f1
F src/date.c 41627dec396f3d33e2c317a065f9d59bb535982b2ea3a561c96e4d4cf1137b65
F src/date.c 1fcc64294b0e81cc9fa05cf8f773e862dd004f74d023544d43edeeacbcfde7e5
F src/dbpage.c 8a01e865bf8bc6d7b1844b4314443a6436c07c3efe1d488ed89e81719047833a
F src/dbstat.c 861e08690fcb0f2ee1165eff0060ea8d4f3e2ea10f80dab7d32ad70443a6ff2d
F src/delete.c b5f1716b4d723db48254ee0f896e362cd029e865e05414139ea7f539f3884e1d
@ -507,7 +507,7 @@ F src/expr.c b90a029105a93a93a0ed5e5f8c5eaed8f19043a3b62e4c4d235a4611d9ada178
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c 06e4ac33031b02dde7130c12e79cddf4dc5cfa72b23d8e63a3c26878fc9c1d3c
F src/func.c 5a0379450bd19ca5cb2d65327b0df6466a14fa0f06f9355329c3e0eec483519a
F src/global.c 1f56aead86e8a18c4415638f5e6c4d0a0550427f4b3f5d065ba5164cc09c22e8
F src/global.c a3daa18a1696aadd94f18d37cbbdebf0bbdb827b8397a534f021cd56c15cd0f9
F src/hash.c 8d7dda241d0ebdafb6ffdeda3149a412d7df75102cecfc1021c98d6219823b19
F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
F src/hwtime.h cb1d7e3e1ed94b7aa6fde95ae2c2daccc3df826be26fc9ed7fd90d1750ae6144
@ -516,7 +516,7 @@ F src/insert.c 1eea44389de3768ac98588c1410171cd53e7c6ad1af74049983dcbac82093de0
F src/json.c 225b00422112ecd7094a555f3ace16b25d7d5894062b823269ed03899907c2a2
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
F src/loadext.c aa919a6a7884f8b34d7b791841b24d14b1b0ab43f45b3940f4851043b2855c0c
F src/main.c 2b6b0dbfeb14d4bb57e368604b0736b2aa42b51b00339d399b01d6b1fc9b4960
F src/main.c 0840cee6984034c7e73cc747a1562c7eaed4673694bf20b00980aaa0672c0405
F src/malloc.c fec841aa0a0400a6f7d20706178a5d8e8219a6bf562b6fe712c17f6c26813266
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de
@ -539,7 +539,7 @@ F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
F src/os_unix.c f5ad51cfd024116db8531feab9efd831c2621436dca1464e4ff1e8af9bf3252e
F src/os_win.c 77d39873836f1831a9b0b91894fec45ab0e9ca8e067dc8c549e1d1eca1566fe9
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
F src/pager.c 0c028c10e73b496ed9f5ecda50e814e99999e97c9e483b3d6d5be54cc39ddffc
F src/pager.c 66bc54c37448c562950e28783e49c7697ea79d1e85136d0e4a915d3a7f9feb5b
F src/pager.h 4bf9b3213a4b2bebbced5eaa8b219cf25d4a82f385d093cd64b7e93e5285f66f
F src/parse.y b34d4eb8105271ea0d577ef165bb7b2a2b70e03b2e694e68e2e43b76389bf660
F src/pcache.c 084e638432c610f95aea72b8509f0845d2791293f39d1b82f0c0a7e089c3bb6b
@ -553,16 +553,16 @@ F src/random.c 097dc8b31b8fba5a9aca1697aeb9fd82078ec91be734c16bffda620ced7ab83c
F src/resolve.c ea935b87d6fb36c78b70cdc7b28561dc8f33f2ef37048389549c7b5ef9b0ba5e
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
F src/select.c 3baa9dd8cf240654773c7974e2bcce398ac9dd24419c36684156963defe43b35
F src/shell.c.in 4368f3d2a0e7866ed86c2877a4d839b8eb9b855142677b26356bb0003b656ef8
F src/shell.c.in 910aa363580f8e75c9d62c03baef2dcec25d077b9f04dacfe61df33f85b0107d
F src/sqlite.h.in 7047c4b60fa550264d6363bb1d983540e7828fb19d2d1e5aa43b52ca13144807
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h a95cb9ed106e3d39e2118e4dcc15a14faec3fa50d0093425083d340d9dfd96e6
F src/sqliteInt.h b6619030ed13b2a8d49c0b5cb0525db1f727966b65ab1ec40b5f11102af7254d
F src/sqliteInt.h f8814239fb1f95056555e2d7fa475750e64681cac4221fb03610d1fde0b79d53
F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a31657
F src/status.c 4b8bc2a6905163a38b739854a35b826c737333fab5b1f8e03fa7eb9a4799c4c1
F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
F src/tclsqlite.c 48f291e1a7e672a7204884d4c164a8ed3a522ff087c361ada2991f5d54e987f6
F src/test1.c ac0e7eeea18230c9c315abedd5a91db7bea91743880d9371b60d3bf2b40c9796
F src/test1.c 87fda59eea3ac1eba1baef37c1967565cb1b8d6d264649f2e57f252ca5989914
F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5
F src/test3.c 61798bb0d38b915067a8c8e03f5a534b431181f802659a6616f9b4ff7d872644
F src/test4.c 7c4420e01c577b5c4add2cb03119743b1a357543d347773b9e717195ea967159
@ -627,7 +627,7 @@ F src/vacuum.c 6c38ddc52f0619865c91dae9c441d4d48bf3040d7dc1bc5b22da1e45547ed0b3
F src/vdbe.c 13a4de20ee07bdfb3dc74ab49b7912208e309caf762a8d1678fb111e2223af35
F src/vdbe.h 25dabb25c7e157b84e59260cfb5b466c3ac103ede9f36f4db371332c47601abe
F src/vdbeInt.h b45599a2b59f1ce042512ab6786b0b82a8cf3002f6b0fa60b4834e2cd3ac61d8
F src/vdbeapi.c c38f1642bb2e31a3e2f1bbd185984455e277022bdd618698a036557686721e8a
F src/vdbeapi.c 8863ffb5a7bac42fe9a68aaa3526ee29fc18fb02a9b27188b756de41e33856e9
F src/vdbeaux.c 0d7659fe8cb38ce86092b9bc5131c99a834a04eb78745e54acb77d79d7af2fb5
F src/vdbeblob.c 5e61ce31aca17db8fb60395407457a8c1c7fb471dde405e0cd675974611dcfcd
F src/vdbemem.c eb6042667c02c3ef1f968235b4a170e31b23a4b6a57f65a8454eab4d36f14b7f
@ -664,8 +664,8 @@ F test/alterdropcol2.test 527fce683b200d620f560f666c44ae33e22728e990a10a48a54328
F test/alterfault.test 289067108947bedca27534edd4ff251bcd298cf84402d7b24eaa3749305418c6
F test/alterlegacy.test f38c6d06cda39e1f7b955bbce57f2e3ef5b7cb566d3d1234502093e228c15811
F test/altermalloc.test 167a47de41b5c638f5f5c6efb59784002b196fff70f98d9b4ed3cd74a3fb80c9
F test/altermalloc2.test ca3ebc01670d9313953a2b7628d8cc00dc5ea9988f229b3cbbbe1cca506dae45
F test/altermalloc3.test 4660ac6240a8c82ba3947b927612dcc7c05a8eec3fe3c9f38e047ca69a789a33
F test/altermalloc2.test 17fb3724c4b004c469c27dc4ef181608aa644555fbd3f3236767584f73747c81
F test/altermalloc3.test 55e606edf4b0acfbbd851ddfe93cfdddfae43d103644dcfd6008ae4ab3c44adf
F test/alterqf.test 3008318ba9e16b4ac0b5f83cf7683caa4b0a3154aafe3b4099838a250d4ba74a
F test/altertab.test 7273b8506eab46342be016af78028df49f3bd99037412f997a8f1011b37a6912
F test/altertab2.test 62597b6fd08feaba1b6bfe7d31dac6117c67e06dc9ce9c478a3abe75b5926de0
@ -739,7 +739,7 @@ F test/bigmmap.test b820c234daa56d24bc3bf006e3ac7aa9d9623c8ac656a38f59063b444a2d
F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747
F test/bigsort.test 8299fa9298f4f1e02fc7d2712e8b77d6cd60e5a2
F test/bind.test 1e136709b306f7ed3192d349c2930d89df6ab621654ad6f1a72381d3fe76f483
F test/bind2.test ce26f19475c933e59e80028fc44073b84c2aba8650dadfdfbd057a4c5adbeb3a
F test/bind2.test 918bc35135f4141809ead7585909cde57d44db90a7a62aef540127148f91aab7
F test/bindxfer.test efecd12c580c14df5f4ad3b3e83c667744a4f7e0
F test/bitvec.test 75894a880520164d73b1305c1c3f96882615e142
F test/blob.test e7ac6c7d3a985cc4678c64f325292529a69ae252
@ -837,7 +837,7 @@ F test/ctime.test 340f362f41f92972bbd71f44e10569a5cc694062b692231bd08aa6fe6c1c47
F test/cursorhint.test 0175e4404181ace3ceca8b114eb0a98eae600d565aa4e2705abbe6614c7fe201
F test/cursorhint2.test 6f3aa9cb19e7418967a10ec6905209bcbb5968054da855fc36c8beee9ae9c42f
F test/dataversion1.test 6e5e86ac681f0782e766ebcb56c019ae001522d114e0e111e5ebf68ccf2a7bb8
F test/date.test 9b73bbeb1b82d9c1f44dec5cf563bf7da58d2373
F test/date.test 50d5b1eeec57041c000d2be5e9ab995026ded4255507f0206c81c1ca3b34b840
F test/date2.test 7e12ec14aaf4d5e6294b4ba140445b0eca06ea50062a9c3a69c4ee13d0b6f8b1
F test/date3.test a1b77abf05c6772fe5ca2337cac1398892f2a41e62bce7e6be0f4a08a0e64ae5
F test/dbdata.test 042f49acff3438f940eeba5868d3af080ae64ddf26ae78f80c92bec3ca7d8603
@ -1072,7 +1072,7 @@ F test/fuzzdata4.db b502c7d5498261715812dd8b3c2005bad08b3a26e6489414bd13926cd3e4
F test/fuzzdata5.db e35f64af17ec48926481cfaf3b3855e436bd40d1cfe2d59a9474cb4b748a52a5
F test/fuzzdata6.db 92a80e4afc172c24f662a10a612d188fb272de4a9bd19e017927c95f737de6d7
F test/fuzzdata7.db 0166b56fd7a6b9636a1d60ef0a060f86ddaecf99400a666bb6e5bbd7199ad1f2
F test/fuzzdata8.db 738ed275638f2423cdef240a44eba3b9bc272eec619e68b00429d4575a15e50b
F test/fuzzdata8.db ca9a97f401b06b0d5376139ec7e1f9e773e13345a9a2d9ccc0032cdbfedea230
F test/fuzzer1.test 3d4c4b7e547aba5e5511a2991e3e3d07166cfbb8
F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14
F test/fuzzerfault.test f64c4aef4c9e9edf1d6dc0d3f1e65dcc81e67c996403c88d14f09b74807a42bc
@ -1826,7 +1826,7 @@ F test/with4.test 257be66c0c67fee1defbbac0f685c3465e2cad037f21ce65f23f86084f1982
F test/with5.test 6248213c41fab36290b5b73aa3f937309dfba337004d9d8434c3fabc8c7d4be8
F test/with6.test 661d7e416bef6c0a2556b2c9f0c8178a5b15932bed65246abed99723a8d4e7c0
F test/withM.test 693b61765f2b387b5e3e24a4536e2e82de15ff64
F test/without_rowid1.test 78fd9b437f4cdb46f76e6a510d545334e4f58e3e4ce37aaf19384eda5b27de8c
F test/without_rowid1.test a5210b8770dc4736bca4e74bc96588f43025ad03ad6a80f885afd36d9890e217
F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99
F test/without_rowid3.test 39ab0dd773eaa62e59b17093f875327630f54c4145458f6d2b053d68d4b2f67b
F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a
@ -1944,8 +1944,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 2da1f8e45eb0cb1ead6049df6a31a903bfad5a7abd27e92cd3dac25fe355aec3
R 3c587522ab1009a0f304c6f4fc9291c2
P 8b6ca9304bff9a5b2897a6517ce77e4cd32f337b6c849b73ead5f757228d8ac8 ca22a64e6f05a6688974f4cff1a0ff2c873aad1947f3cf6ffaeee8bb074b2627
R f2657b8c4f3b23824e6168670f3c28c6
U larrybr
Z 6eda7b7abac4cc7637f7063a4d303de3
Z 72b6123e2f6f8261fe59a92cab260c52
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
8b6ca9304bff9a5b2897a6517ce77e4cd32f337b6c849b73ead5f757228d8ac8
caaef4c592c980889efb349fa73b61303ec493172d90cd67d54ffde0855e4138

View File

@ -503,8 +503,10 @@ static void clearYMD_HMS_TZ(DateTime *p){
** is available. This routine returns 0 on success and
** non-zero on any kind of error.
**
** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this
** routine will always fail.
** If the sqlite3GlobalConfig.bLocaltimeFault variable is non-zero then this
** routine will always fail. If bLocaltimeFault is nonzero and
** sqlite3GlobalConfig.xAltLocaltime is not NULL, then xAltLocaltime() is
** invoked in place of the OS-defined localtime() function.
**
** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C
** library function localtime_r() is used to assist in the calculation of
@ -520,7 +522,15 @@ static int osLocaltime(time_t *t, struct tm *pTm){
sqlite3_mutex_enter(mutex);
pX = localtime(t);
#ifndef SQLITE_UNTESTABLE
if( sqlite3GlobalConfig.bLocaltimeFault ) pX = 0;
if( sqlite3GlobalConfig.bLocaltimeFault ){
if( sqlite3GlobalConfig.xAltLocaltime!=0
&& 0==sqlite3GlobalConfig.xAltLocaltime((const void*)t,(void*)pTm)
){
pX = pTm;
}else{
pX = 0;
}
}
#endif
if( pX ) *pTm = *pX;
#if SQLITE_THREADSAFE>0
@ -529,7 +539,13 @@ static int osLocaltime(time_t *t, struct tm *pTm){
rc = pX==0;
#else
#ifndef SQLITE_UNTESTABLE
if( sqlite3GlobalConfig.bLocaltimeFault ) return 1;
if( sqlite3GlobalConfig.bLocaltimeFault ){
if( sqlite3GlobalConfig.xAltLocaltime!=0 ){
return sqlite3GlobalConfig.xAltLocaltime((const void*)t,(void*)pTm);
}else{
return 1;
}
}
#endif
#if HAVE_LOCALTIME_R
rc = localtime_r(t, pTm)==0;
@ -544,67 +560,56 @@ static int osLocaltime(time_t *t, struct tm *pTm){
#ifndef SQLITE_OMIT_LOCALTIME
/*
** Compute the difference (in milliseconds) between localtime and UTC
** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs,
** return this value and set *pRc to SQLITE_OK.
**
** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value
** is undefined in this case.
** Assuming the input DateTime is UTC, move it to its localtime equivalent.
*/
static sqlite3_int64 localtimeOffset(
DateTime *p, /* Date at which to calculate offset */
sqlite3_context *pCtx, /* Write error here if one occurs */
int *pRc /* OUT: Error code. SQLITE_OK or ERROR */
static int toLocaltime(
DateTime *p, /* Date at which to calculate offset */
sqlite3_context *pCtx /* Write error here if one occurs */
){
DateTime x, y;
time_t t;
struct tm sLocal;
int iYearDiff;
/* Initialize the contents of sLocal to avoid a compiler warning. */
memset(&sLocal, 0, sizeof(sLocal));
x = *p;
computeYMD_HMS(&x);
if( x.Y<1971 || x.Y>=2038 ){
computeJD(p);
if( p->iJD<21086676000*(i64)10000 /* 1970-01-01 */
|| p->iJD>21301414560*(i64)10000 /* 2038-01-18 */
){
/* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only
** works for years between 1970 and 2037. For dates outside this range,
** SQLite attempts to map the year into an equivalent year within this
** range, do the calculation, then map the year back.
*/
x.Y = 2000;
x.M = 1;
x.D = 1;
x.h = 0;
x.m = 0;
x.s = 0.0;
} else {
int s = (int)(x.s + 0.5);
x.s = s;
DateTime x = *p;
computeYMD_HMS(&x);
iYearDiff = (2000 + x.Y%4) - x.Y;
x.Y += iYearDiff;
x.validJD = 0;
computeJD(&x);
t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);
}else{
iYearDiff = 0;
t = (time_t)(p->iJD/1000 - 21086676*(i64)10000);
}
x.tz = 0;
x.validJD = 0;
computeJD(&x);
t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);
if( osLocaltime(&t, &sLocal) ){
sqlite3_result_error(pCtx, "local time unavailable", -1);
*pRc = SQLITE_ERROR;
return 0;
return SQLITE_ERROR;
}
y.Y = sLocal.tm_year + 1900;
y.M = sLocal.tm_mon + 1;
y.D = sLocal.tm_mday;
y.h = sLocal.tm_hour;
y.m = sLocal.tm_min;
y.s = sLocal.tm_sec;
y.validYMD = 1;
y.validHMS = 1;
y.validJD = 0;
y.rawS = 0;
y.validTZ = 0;
y.isError = 0;
computeJD(&y);
*pRc = SQLITE_OK;
return y.iJD - x.iJD;
p->Y = sLocal.tm_year + 1900 - iYearDiff;
p->M = sLocal.tm_mon + 1;
p->D = sLocal.tm_mday;
p->h = sLocal.tm_hour;
p->m = sLocal.tm_min;
p->s = sLocal.tm_sec;
p->validYMD = 1;
p->validHMS = 1;
p->validJD = 0;
p->rawS = 0;
p->validTZ = 0;
p->isError = 0;
return SQLITE_OK;
}
#endif /* SQLITE_OMIT_LOCALTIME */
@ -713,9 +718,7 @@ static int parseModifier(
** show local time.
*/
if( sqlite3_stricmp(z, "localtime")==0 && sqlite3NotPureFunc(pCtx) ){
computeJD(p);
p->iJD += localtimeOffset(p, pCtx, &rc);
clearYMD_HMS_TZ(p);
rc = toLocaltime(p, pCtx);
}
break;
}
@ -741,18 +744,31 @@ static int parseModifier(
#ifndef SQLITE_OMIT_LOCALTIME
else if( sqlite3_stricmp(z, "utc")==0 && sqlite3NotPureFunc(pCtx) ){
if( p->tzSet==0 ){
sqlite3_int64 c1;
i64 iOrigJD; /* Original localtime */
i64 iGuess; /* Guess at the corresponding utc time */
int cnt = 0; /* Safety to prevent infinite loop */
int iErr; /* Guess is off by this much */
computeJD(p);
c1 = localtimeOffset(p, pCtx, &rc);
if( rc==SQLITE_OK ){
p->iJD -= c1;
clearYMD_HMS_TZ(p);
p->iJD += c1 - localtimeOffset(p, pCtx, &rc);
}
iGuess = iOrigJD = p->iJD;
iErr = 0;
do{
DateTime new;
memset(&new, 0, sizeof(new));
iGuess -= iErr;
new.iJD = iGuess;
new.validJD = 1;
rc = toLocaltime(&new, pCtx);
if( rc ) return rc;
computeJD(&new);
iErr = new.iJD - iOrigJD;
}while( iErr && cnt++<3 );
memset(p, 0, sizeof(*p));
p->iJD = iGuess;
p->validJD = 1;
p->tzSet = 1;
}else{
rc = SQLITE_OK;
}
rc = SQLITE_OK;
}
#endif
break;
@ -1002,11 +1018,38 @@ static void datetimeFunc(
){
DateTime x;
if( isDate(context, argc, argv, &x)==0 ){
char zBuf[100];
int Y, s;
char zBuf[24];
computeYMD_HMS(&x);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%04d-%02d-%02d %02d:%02d:%02d",
x.Y, x.M, x.D, x.h, x.m, (int)(x.s));
sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
Y = x.Y;
if( Y<0 ) Y = -Y;
zBuf[1] = '0' + (Y/1000)%10;
zBuf[2] = '0' + (Y/100)%10;
zBuf[3] = '0' + (Y/10)%10;
zBuf[4] = '0' + (Y)%10;
zBuf[5] = '-';
zBuf[6] = '0' + (x.M/10)%10;
zBuf[7] = '0' + (x.M)%10;
zBuf[8] = '-';
zBuf[9] = '0' + (x.D/10)%10;
zBuf[10] = '0' + (x.D)%10;
zBuf[11] = ' ';
zBuf[12] = '0' + (x.h/10)%10;
zBuf[13] = '0' + (x.h)%10;
zBuf[14] = ':';
zBuf[15] = '0' + (x.m/10)%10;
zBuf[16] = '0' + (x.m)%10;
zBuf[17] = ':';
s = (int)x.s;
zBuf[18] = '0' + (s/10)%10;
zBuf[19] = '0' + (s)%10;
zBuf[20] = 0;
if( x.Y<0 ){
zBuf[0] = '-';
sqlite3_result_text(context, zBuf, 20, SQLITE_TRANSIENT);
}else{
sqlite3_result_text(context, &zBuf[1], 19, SQLITE_TRANSIENT);
}
}
}
@ -1022,10 +1065,20 @@ static void timeFunc(
){
DateTime x;
if( isDate(context, argc, argv, &x)==0 ){
char zBuf[100];
int s;
char zBuf[16];
computeHMS(&x);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%02d:%02d:%02d", x.h, x.m, (int)x.s);
sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
zBuf[0] = '0' + (x.h/10)%10;
zBuf[1] = '0' + (x.h)%10;
zBuf[2] = ':';
zBuf[3] = '0' + (x.m/10)%10;
zBuf[4] = '0' + (x.m)%10;
zBuf[5] = ':';
s = (int)x.s;
zBuf[6] = '0' + (s/10)%10;
zBuf[7] = '0' + (s)%10;
zBuf[8] = 0;
sqlite3_result_text(context, zBuf, 8, SQLITE_TRANSIENT);
}
}
@ -1041,10 +1094,28 @@ static void dateFunc(
){
DateTime x;
if( isDate(context, argc, argv, &x)==0 ){
char zBuf[100];
int Y;
char zBuf[16];
computeYMD(&x);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%04d-%02d-%02d", x.Y, x.M, x.D);
sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
Y = x.Y;
if( Y<0 ) Y = -Y;
zBuf[1] = '0' + (Y/1000)%10;
zBuf[2] = '0' + (Y/100)%10;
zBuf[3] = '0' + (Y/10)%10;
zBuf[4] = '0' + (Y)%10;
zBuf[5] = '-';
zBuf[6] = '0' + (x.M/10)%10;
zBuf[7] = '0' + (x.M)%10;
zBuf[8] = '-';
zBuf[9] = '0' + (x.D/10)%10;
zBuf[10] = '0' + (x.D)%10;
zBuf[11] = 0;
if( x.Y<0 ){
zBuf[0] = '-';
sqlite3_result_text(context, zBuf, 11, SQLITE_TRANSIENT);
}else{
sqlite3_result_text(context, &zBuf[1], 10, SQLITE_TRANSIENT);
}
}
}

View File

@ -286,6 +286,7 @@ SQLITE_WSD struct Sqlite3Config sqlite3Config = {
0, /* xTestCallback */
#endif
0, /* bLocaltimeFault */
0, /* xAltLocaltime */
0x7ffffffe, /* iOnceResetThreshold */
SQLITE_DEFAULT_SORTERREF_SIZE, /* szSorterRef */
0, /* iPrngSeed */

View File

@ -4029,12 +4029,16 @@ int sqlite3_test_control(int op, ...){
** sqlite3_test_control().
*/
case SQLITE_TESTCTRL_FAULT_INSTALL: {
/* MSVC is picky about pulling func ptrs from va lists.
** http://support.microsoft.com/kb/47961
/* A bug in MSVC prevents it from understanding pointers to functions
** types in the second argument to va_arg(). Work around the problem
** using a typedef.
** http://support.microsoft.com/kb/47961 <-- dead hyperlink
** Search at http://web.archive.org/ to find the 2015-03-16 archive
** of the link above to see the original text.
** sqlite3GlobalConfig.xTestCallback = va_arg(ap, int(*)(int));
*/
typedef int(*TESTCALLBACKFUNC_t)(int);
sqlite3GlobalConfig.xTestCallback = va_arg(ap, TESTCALLBACKFUNC_t);
typedef int(*sqlite3FaultFuncType)(int);
sqlite3GlobalConfig.xTestCallback = va_arg(ap, sqlite3FaultFuncType);
rc = sqlite3FaultSim(0);
break;
}
@ -4161,13 +4165,27 @@ int sqlite3_test_control(int op, ...){
break;
}
/* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff);
/* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, onoff, xAlt);
**
** If parameter onoff is non-zero, subsequent calls to localtime()
** and its variants fail. If onoff is zero, undo this setting.
** If parameter onoff is 1, subsequent calls to localtime() fail.
** If 2, then invoke xAlt() instead of localtime(). If 0, normal
** processing.
**
** xAlt arguments are void pointers, but they really want to be:
**
** int xAlt(const time_t*, struct tm*);
**
** xAlt should write results in to struct tm object of its 2nd argument
** and return zero on success, or return non-zero on failure.
*/
case SQLITE_TESTCTRL_LOCALTIME_FAULT: {
sqlite3GlobalConfig.bLocaltimeFault = va_arg(ap, int);
if( sqlite3GlobalConfig.bLocaltimeFault==2 ){
typedef int(*sqlite3LocaltimeType)(const void*,void*);
sqlite3GlobalConfig.xAltLocaltime = va_arg(ap, sqlite3LocaltimeType);
}else{
sqlite3GlobalConfig.xAltLocaltime = 0;
}
break;
}

View File

@ -3945,7 +3945,7 @@ static void assertTruncateConstraint(Pager *pPager){
** then continue writing to the database.
*/
void sqlite3PagerTruncateImage(Pager *pPager, Pgno nPage){
assert( pPager->dbSize>=nPage );
assert( pPager->dbSize>=nPage || CORRUPT_DB );
assert( pPager->eState>=PAGER_WRITER_CACHEMOD );
pPager->dbSize = nPage;

View File

@ -23,10 +23,10 @@
** If SQLITE_CUSTOM_INCLUDE=? is defined, its value names the #include
** file. Note that this macro has a like effect on sqlite3.c compilation.
*/
# define SHELL_STRINGIFY_(f) #f
# define SHELL_STRINGIFY(f) SHELL_STRINGIFY_(f)
#ifdef SQLITE_CUSTOM_INCLUDE
# define INC_STRINGIFY_(f) #f
# define INC_STRINGIFY(f) INC_STRINGIFY_(f)
# include INC_STRINGIFY(SQLITE_CUSTOM_INCLUDE)
# include SHELL_STRINGIFY(SQLITE_CUSTOM_INCLUDE)
#endif
/*
@ -7254,6 +7254,17 @@ static char zCOL_DB[] = SHELL_COLFIX_DB;
static const char *zCOL_DB = ":memory:";
#endif
/* Define character (as C string) to separate generated column ordinal
* from protected part of incoming column names. This defaults to "_"
* so that incoming column identifiers that did not need not be quoted
* remain usable without being quoted. It must be one character.
*/
#ifndef SHELL_AUTOCOLUMN_SEP
# define AUTOCOLUMN_SEP "_"
#else
# define AUTOCOLUMN_SEP SHELL_STRINGIFY(SHELL_AUTOCOLUMN_SEP)
#endif
static char *zAutoColumn(const char *zColNew, sqlite3 **pDb, int *pRenamed){
/* Queries and D{D,M}L used here */
static const char const *zTabMake = "\
@ -7282,12 +7293,14 @@ WITH chopped AS ( \
FROM choppable \
WHERE substring(name, nc, 1) BETWEEN '0' AND '9'\
) SELECT cpos /*name*/ FROM choppable \
WHERE nc<length(name) and substring(name, nc, 1)='_'\
WHERE nc<length(name) and \
substring(name, nc, 1)='"AUTOCOLUMN_SEP"'\
)\
UNION ALL\
SELECT cpos, name, chop+1 AS chop, nlen \
FROM chopping \
WHERE instr('_0123456789', substring(name, nlen-chop, 1))>0 \
WHERE \
instr('"AUTOCOLUMN_SEP"0123456789', substring(name, nlen-chop, 1))>0 \
)\
SELECT cpos, name, max(chop) AS chop FROM chopping s \
GROUP BY cpos \
@ -7306,7 +7319,8 @@ SELECT CAST(ceil(log(count(*)+0.5)) AS INT) FROM ColNames \
";
#endif
static const char const *zRenameRank = "\
UPDATE ColNames AS t SET suff=iif(reps>1, printf('_%0*d', $1, cpos), '')\
UPDATE ColNames AS t SET \
suff=iif(reps>1, printf('"AUTOCOLUMN_SEP"%0*d', $1, cpos), '')\
";
static const char const *zCollectVar = "\
SELECT\

View File

@ -3936,6 +3936,7 @@ struct Sqlite3Config {
int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */
#endif
int bLocaltimeFault; /* True to fail localtime() calls */
int (*xAltLocaltime)(const void*,void*); /* Alternative localtime() routine */
int iOnceResetThreshold; /* When to reset OP_Once counters */
u32 szSorterRef; /* Min size in bytes to use sorter-refs */
unsigned int iPrngSeed; /* Alternative fixed seed for the PRNG */

View File

@ -4009,6 +4009,7 @@ static int SQLITE_TCLAPI test_bind_value_from_preupdate(
if( Tcl_GetIntFromObj(interp, objv[4], &bidx) ) return TCL_ERROR;
db = sqlite3_db_handle(pStmt);
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
if( z3[0]=='n' ){
sqlite3_preupdate_new(db, bidx, &pVal);
}else if( z3[0]=='o' ){
@ -4018,6 +4019,7 @@ static int SQLITE_TCLAPI test_bind_value_from_preupdate(
return TCL_ERROR;
}
sqlite3_bind_value(pStmt, idx, pVal);
#endif
return TCL_OK;
}
@ -7205,6 +7207,55 @@ static int SQLITE_TCLAPI test_print_eqp(
}
#endif /* SQLITE_OMIT_EXPLAIN */
#include <time.h>
/*
** This is an alternative localtime_r() implementation used for testing
** the 'localtime' and 'utc' modifiers of date-time functions. Because
** the OS-supplied localtime_r() is locale-dependent, this alternative is
** provided as a stable test platform.
**
** Operation:
**
** (1) Localtime is 30 minutes earlier than (west of) UTC on
** even days (counting from 1970-01-01)
**
** (2) Localtime is 30 minutes later than (east of) UTC on odd days.
**
** (3) The function fails for the specific date/time value
** of 2000-05-29 14:16:00 in order to test the ability of
** SQLite to deal with localtime_r() failures.
*/
static int testLocaltime(const void *aliasT, void *aliasTM){
const time_t t = *(const time_t*)aliasT;
struct tm *pTm = (struct tm *)aliasTM;
time_t altT;
sqlite3_int64 iJD;
int Z, A, B, C, D, E, X1, S;
if( (t/86400) & 1 ){
altT = t + 1800; /* 30 minutes later on odd days */
}else{
altT = t - 1800; /* 30 minutes earlier on even days */
}
iJD = (sqlite3_int64)(altT + 210866760000);
Z = (int)((iJD + 43200)/86400);
A = (int)((Z - 1867216.25)/36524.25);
A = Z + 1 + A - (A/4);
B = A + 1524;
C = (int)((B - 122.1)/365.25);
D = (36525*(C&32767))/100;
E = (int)((B-D)/30.6001);
X1 = (int)(30.6001*E);
pTm->tm_mday = B - D - X1;
pTm->tm_mon = E<14 ? E-2 : E-14;
pTm->tm_year = (pTm->tm_mon>1 ? C - 4716 : C - 4715) - 1900;
S = (int)((iJD + 43200)%86400);
pTm->tm_hour = S/3600;
pTm->tm_min = (S/60)%60;
pTm->tm_sec = S % 60;
return t==959609760; /* Special case: 2000-05-29 14:16:00 fails */
}
/*
** sqlite3_test_control VERB ARGS...
*/
@ -7252,11 +7303,11 @@ static int SQLITE_TCLAPI test_test_control(
case SQLITE_TESTCTRL_LOCALTIME_FAULT: {
int val;
if( objc!=3 ){
Tcl_WrongNumArgs(interp, 2, objv, "ONOFF");
Tcl_WrongNumArgs(interp, 2, objv, "0|1|2");
return TCL_ERROR;
}
if( Tcl_GetBooleanFromObj(interp, objv[2], &val) ) return TCL_ERROR;
sqlite3_test_control(iFlag, val);
if( Tcl_GetIntFromObj(interp, objv[2], &val) ) return TCL_ERROR;
sqlite3_test_control(iFlag, val, testLocaltime);
break;
}

View File

@ -1594,7 +1594,10 @@ int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){
break;
}
case SQLITE_FLOAT: {
rc = sqlite3_bind_double(pStmt, i, sqlite3VdbeRealValue((Mem*)pValue));
assert( pValue->flags & (MEM_Real|MEM_IntReal) );
rc = sqlite3_bind_double(pStmt, i,
(pValue->flags & MEM_Real) ? pValue->u.r : (double)pValue->u.i
);
break;
}
case SQLITE_BLOB: {

View File

@ -26,6 +26,11 @@ do_execsql_test 1.0 {
}
faultsim_save_and_close
set ::TMPDBERROR [list 1 \
{unable to open a temporary database file for storing temporary tables}
]
do_faultsim_test 1 -prep {
faultsim_restore_and_reopen
} -body {
@ -33,7 +38,7 @@ do_faultsim_test 1 -prep {
ALTER TABLE t1 RENAME abcd TO dcba
}
} -test {
faultsim_test_result {0 {}}
faultsim_test_result {0 {}} $::TMPDBERROR
}
catch {db close}
@ -52,7 +57,7 @@ do_faultsim_test 2 -prep {
ALTER TABLE t1 RENAME abcd TO dcba
}
} -test {
faultsim_test_result {0 {}}
faultsim_test_result {0 {}} $::TMPDBERROR
}
@ -70,7 +75,7 @@ do_faultsim_test 3 -prep {
ALTER TABLE t1 RENAME abcd TO dcba
}
} -test {
faultsim_test_result {0 {}}
faultsim_test_result {0 {}} $::TMPDBERROR
}
reset_db
@ -95,7 +100,7 @@ do_faultsim_test 4 -faults oom-* -prep {
ALTER TABLE rr RENAME a TO c;
}
} -test {
faultsim_test_result {0 {}}
faultsim_test_result {0 {}} $::TMPDBERROR
}
reset_db
@ -116,7 +121,7 @@ do_faultsim_test 5 -faults oom-* -prep {
ALTER TABLE rr RENAME TO c;
}
} -test {
faultsim_test_result {0 {}}
faultsim_test_result {0 {}} $::TMPDBERROR
}
finish_test

View File

@ -21,6 +21,10 @@ ifcapable !altertable {
return
}
set ::TMPDBERROR [list 1 \
{unable to open a temporary database file for storing temporary tables}
]
do_execsql_test 1.0 {
CREATE TABLE x1(
one, two, three, PRIMARY KEY(one),
@ -40,7 +44,7 @@ do_faultsim_test 1 -prep {
} -body {
execsql { ALTER TABLE t1 DROP COLUMN c }
} -test {
faultsim_test_result {0 {}}
faultsim_test_result {0 {}} $::TMPDBERROR
}
#-------------------------------------------------------------------------
@ -72,7 +76,7 @@ do_faultsim_test 2.2 -prep {
ALTER TABLE t2 RENAME TO t2x;
}
} -test {
faultsim_test_result {0 {}}
faultsim_test_result {0 {}} $::TMPDBERROR
}
finish_test

View File

@ -36,6 +36,11 @@ do_test 1.1 {
} {42.0}
sqlite3_finalize $stmt
ifcapable !preupdate {
finish_test
return
}
proc preup {args} {
set stmt [sqlite3_prepare db "SELECT ?" -1 tail]
sqlite3_bind_value_from_preupdate $stmt 1 old 0

View File

@ -239,138 +239,70 @@ datetest 5.13 {datetime('1994-04-16 14:00:00Zulu')} NULL
datetest 5.14 {datetime('1994-04-16 14:00:00Z +05:00')} NULL
datetest 5.15 {datetime('1994-04-16 14:00:00 +05:00 Z')} NULL
# localtime->utc and utc->localtime conversions. These tests only work
# if the localtime is in the US Eastern Time (the time in Charlotte, NC
# and in New York.)
# localtime->utc and utc->localtime conversions.
#
# On non-Vista Windows platform, '2006-03-31' is treated incorrectly as being
# in DST giving a 4 hour offset instead of 5. In 2007, DST was extended to
# start three weeks earlier (second Sunday in March) and end one week
# later (first Sunday in November). Older Windows systems apply this
# new rule incorrectly to dates prior to 2007.
# Use SQLITE_TESTCTRL_LOCALTIME_FAULT=2 to set an alternative localtime_r()
# implementation that is not locale-dependent. This testing localtime_r()
# operates as follows:
#
# It might be argued that this is masking a problem on non-Vista Windows
# platform. A ticket has already been opened for this issue
# (http://www.sqlite.org/cvstrac/tktview?tn=2322). This is just to prevent
# more confusion/reports of the issue.
# (1) Localtime is 30 minutes earlier than (west of) UTC on
# even days (counting from 1970-01-01)
#
# $tzoffset_old should be 5 if DST is working correctly.
set tzoffset_old [db one {
SELECT CAST(24*(julianday('2006-03-31') -
julianday('2006-03-31','localtime'))+0.5
AS INT)
}]
# $tzoffset_new should be 4 if DST is working correctly.
set tzoffset_new [db one {
SELECT CAST(24*(julianday('2007-03-31') -
julianday('2007-03-31','localtime'))+0.5
AS INT)
}]
# Warn about possibly broken Windows DST implementations.
if {$::tcl_platform(platform)=="windows" && $tzoffset_new==4 && $tzoffset_old==4} {
puts "******************************************************************"
puts "N.B.: The DST support provided by your current O/S seems to be"
puts "suspect in that it is reporting incorrect DST values for dates"
puts "prior to 2007. This is the known case for most (all?) non-Vista"
puts "Windows versions. Please see ticket #2322 for more information."
puts "******************************************************************"
# (2) Localtime is 30 minutes later than (east of) UTC on odd days.
#
# (3) The function fails for the specific date/time value
# of 2000-05-29 14:16:00 in order to test the ability of
# SQLite to deal with localtime_r() failures.
#
proc local_to_utc {tn utc local} {
do_execsql_test date-$tn "SELECT datetime('$utc','localtime')" [list $local]
}
proc utc_to_local {tn local utc} {
do_execsql_test date-$tn "SELECT datetime('$local','utc')" [list $utc]
}
if {$tzoffset_new==4} {
datetest 6.1 {datetime('2000-10-29 05:59:00','localtime')}\
{2000-10-29 01:59:00}
datetest 6.1.1 {datetime('2006-10-29 05:59:00','localtime')}\
{2006-10-29 01:59:00}
datetest 6.1.2 {datetime('2007-11-04 05:59:00','localtime')}\
{2007-11-04 01:59:00}
sqlite3_test_control SQLITE_TESTCTRL_LOCALTIME_FAULT 2
local_to_utc 6.1 {2000-10-29 12:00:00} {2000-10-29 12:30:00}
utc_to_local 6.2 {2000-10-29 12:30:00} {2000-10-29 12:00:00}
local_to_utc 6.3 {2000-10-30 12:00:00} {2000-10-30 11:30:00}
utc_to_local 6.4 {2000-10-30 11:30:00} {2000-10-30 12:00:00}
# If the new and old DST rules seem to be working correctly...
if {$tzoffset_new==4 && $tzoffset_old==5} {
datetest 6.2 {datetime('2000-10-29 06:00:00','localtime')}\
{2000-10-29 01:00:00}
datetest 6.2.1 {datetime('2006-10-29 06:00:00','localtime')}\
{2006-10-29 01:00:00}
}
datetest 6.2.2 {datetime('2007-11-04 06:00:00','localtime')}\
{2007-11-04 01:00:00}
local_to_utc 6.5 {2000-10-28 23:59:59} {2000-10-28 23:29:59}
local_to_utc 6.6 {2000-10-29 00:00:00} {2000-10-29 00:30:00}
# If the new and old DST rules seem to be working correctly...
if {$tzoffset_new==4 && $tzoffset_old==5} {
datetest 6.3 {datetime('2000-04-02 06:59:00','localtime')}\
{2000-04-02 01:59:00}
datetest 6.3.1 {datetime('2006-04-02 06:59:00','localtime')}\
{2006-04-02 01:59:00}
}
datetest 6.3.2 {datetime('2007-03-11 07:00:00','localtime')}\
{2007-03-11 03:00:00}
datetest 6.4 {datetime('2000-04-02 07:00:00','localtime')}\
{2000-04-02 03:00:00}
datetest 6.4.1 {datetime('2006-04-02 07:00:00','localtime')}\
{2006-04-02 03:00:00}
datetest 6.4.2 {datetime('2007-03-11 07:00:00','localtime')}\
{2007-03-11 03:00:00}
datetest 6.5 {datetime('2000-10-29 01:59:00','utc')} {2000-10-29 05:59:00}
datetest 6.5.1 {datetime('2006-10-29 01:59:00','utc')} {2006-10-29 05:59:00}
datetest 6.5.2 {datetime('2007-11-04 01:59:00','utc')} {2007-11-04 05:59:00}
# If the new and old DST rules seem to be working correctly...
if {$tzoffset_new==4 && $tzoffset_old==5} {
datetest 6.6 {datetime('2000-10-29 02:00:00','utc')} {2000-10-29 07:00:00}
datetest 6.6.1 {datetime('2006-10-29 02:00:00','utc')} {2006-10-29 07:00:00}
}
datetest 6.6.2 {datetime('2007-11-04 02:00:00','utc')} {2007-11-04 07:00:00}
# If the new and old DST rules seem to be working correctly...
if {$tzoffset_new==4 && $tzoffset_old==5} {
datetest 6.7 {datetime('2000-04-02 01:59:00','utc')} {2000-04-02 06:59:00}
datetest 6.7.1 {datetime('2006-04-02 01:59:00','utc')} {2006-04-02 06:59:00}
}
datetest 6.7.2 {datetime('2007-03-11 01:59:00','utc')} {2007-03-11 06:59:00}
datetest 6.8 {datetime('2000-04-02 02:00:00','utc')} {2000-04-02 06:00:00}
datetest 6.8.1 {datetime('2006-04-02 02:00:00','utc')} {2006-04-02 06:00:00}
datetest 6.8.2 {datetime('2007-03-11 02:00:00','utc')} {2007-03-11 06:00:00}
# The 'utc' modifier is a no-op if the LHS is known to already be in UTC
datetest 6.9.1 {datetime('2015-12-23 12:00:00','utc')} {2015-12-23 17:00:00}
datetest 6.9.2 {datetime('2015-12-23 12:00:00z','utc')} {2015-12-23 12:00:00}
datetest 6.9.3 {datetime('2015-12-23 12:00:00-03:00','utc')} \
{2015-12-23 15:00:00}
datetest 6.9.4 {datetime('2015-12-23 12:00:00','utc','utc','utc')} \
{2015-12-23 17:00:00}
datetest 6.10 {datetime('2000-01-01 12:00:00','localtime')} \
{2000-01-01 07:00:00}
datetest 6.11 {datetime('1969-01-01 12:00:00','localtime')} \
{1969-01-01 07:00:00}
datetest 6.12 {datetime('2039-01-01 12:00:00','localtime')} \
{2039-01-01 07:00:00}
datetest 6.13 {datetime('2000-07-01 12:00:00','localtime')} \
{2000-07-01 08:00:00}
datetest 6.14 {datetime('1969-07-01 12:00:00','localtime')} \
{1969-07-01 07:00:00}
datetest 6.15 {datetime('2039-07-01 12:00:00','localtime')} \
{2039-07-01 07:00:00}
set sqlite_current_time \
[db eval {SELECT strftime('%s','2000-07-01 12:34:56')}]
datetest 6.16 {datetime('now','localtime')} {2000-07-01 08:34:56}
datetest 6.17 {datetime('now','localtimex')} NULL
datetest 6.18 {datetime('now','localtim')} NULL
set sqlite_current_time 0
}
# These two are a bit of a scam. They are added to ensure that 100% of
# the date.c file is covered by testing, even when the time-zone
# is not -0400 (the condition for running of the block of tests above).
# The previous two cases establish that no such localtime as
# 2000-10-29 00:10:00 exists. Verify that we get a reasonable
# answer if we try to convert this non-existant localtime to utc?
#
datetest 6.19 {datetime('2039-07-01 12:00:00','localtime',null)} NULL
datetest 6.20 {datetime('2039-07-01 12:00:00','utc',null)} NULL
utc_to_local 6.7 {2000-10-29 00:10:00} {2000-10-28 23:40:00}
local_to_utc 6.8 {2022-02-10 23:59:59} {2022-02-11 00:29:59}
local_to_utc 6.9 {2022-02-11 00:00:00} {2022-02-10 23:30:00}
local_to_utc 6.10 {2022-02-10 23:45:00} {2022-02-11 00:15:00}
local_to_utc 6.11 {2022-02-11 00:45:00} {2022-02-11 00:15:00}
# The previous two cases show that two different UTC values give
# the same localtime of 2022-02-11 00:15:00. When converting from
# that localtime back to UTC, we should get one or the other of
# the two UTC values.
#
utc_to_local 6.12 {2022-02-11 00:15:00} {2022-02-11 00:45:00}
# If localtime_r() fails, the datetime() SQL function should raise an error
#
do_catchsql_test date-6.20 {
SELECT datetime('2000-05-29 14:16:00','localtime');
} {1 {local time unavailable}}
# Modifiers work for dates that are way out of band for localtime_r()
#
local_to_utc 6.21 {1800-10-29 12:00:00} {1800-10-29 12:30:00}
utc_to_local 6.22 {1800-10-29 12:30:00} {1800-10-29 12:00:00}
local_to_utc 6.23 {3000-10-30 12:00:00} {3000-10-30 11:30:00}
utc_to_local 6.24 {3000-10-30 11:30:00} {3000-10-30 12:00:00}
# Restore the use of the OS localtime_r() before going on...
sqlite3_test_control SQLITE_TESTCTRL_LOCALTIME_FAULT 0
# Date-time functions that contain NULL arguments return a NULL
# result.

Binary file not shown.

View File

@ -475,15 +475,16 @@ ifcapable altertable {
# Omit an assert() from 2013 that no longer serves any purpose and
# is no longer always true.
#
reset_db
do_execsql_test 15.1 {
PRAGMA writable_schema=ON;
CREATE TABLE sqlite_sequence (name PRIMARY KEY) WITHOUT ROWID;
PRAGMA writable_schema=OFF;
CREATE TABLE c1(x);
INSERT INTO sqlite_sequence(name) VALUES('c0'),('c1'),('c2');
ALTER TABLE c1 RENAME TO a;
SELECT name FROM sqlite_sequence ORDER BY +name;
} {a c0 c2}
ifcapable altertable {
reset_db
do_execsql_test 15.1 {
PRAGMA writable_schema=ON;
CREATE TABLE sqlite_sequence (name PRIMARY KEY) WITHOUT ROWID;
PRAGMA writable_schema=OFF;
CREATE TABLE c1(x);
INSERT INTO sqlite_sequence(name) VALUES('c0'),('c1'),('c2');
ALTER TABLE c1 RENAME TO a;
SELECT name FROM sqlite_sequence ORDER BY +name;
} {a c0 c2}
}
finish_test