More improvements to boundary cases in the date/time functions, flowing out

of branch coverage testing.

FossilOrigin-Name: 1218005ab7b52ef45db1354d17fdd8a1a1af9854
This commit is contained in:
drh 2016-11-30 04:07:57 +00:00
parent 64777ba834
commit b5489b88b0
3 changed files with 13 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C Prevent\sa\swarning\sabout\sinteger\soverflow\swhen\susing\sa\svery\slarge\snegative\nLIMIT.
D 2016-11-30T01:05:41.141
C More\simprovements\sto\sboundary\scases\sin\sthe\sdate/time\sfunctions,\sflowing\sout\nof\sbranch\scoverage\stesting.
D 2016-11-30T04:07:57.427
F Makefile.in 6b572807415d3f0a379cebc9461416d8df4a12c8
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc bb4d970894abbbe0e88d00aac29bd52af8bc95f4
@ -337,7 +337,7 @@ F src/build.c 178f16698cbcb43402c343a9413fe22c99ffee21
F src/callback.c 2e76147783386374bf01b227f752c81ec872d730
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
F src/ctime.c a2a52d6e353f459d8ab0f07321f60fafa47d5421
F src/date.c 736c1f36c58bb137f64d8d1f72467dc027832563
F src/date.c 206d0eb85cedec99a9820929579057fb364a72cb
F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d
F src/delete.c cac97d1117a3008934da3a6a587b3608e65e1495
F src/expr.c 8c224aa28278a5c1eed55247b7a571ff388ad5c2
@ -1535,7 +1535,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P dc453b3403450b1d8cc53daf0721fed025b9053c
R dc777d9d449bf1af0c4185b27e450723
P 96106d5620eae51474234f4eec1d2c5bd570d486
R 533c0afd3cc78feab0c7d06b5d67b3a1
U drh
Z 787a300f5849727b901aee7620134dd8
Z 8875af7104f1fa4c1f8084b812f6f104

View File

@ -1 +1 @@
96106d5620eae51474234f4eec1d2c5bd570d486
1218005ab7b52ef45db1354d17fdd8a1a1af9854

View File

@ -65,7 +65,7 @@ struct tm *__cdecl localtime(const time_t *);
*/
typedef struct DateTime DateTime;
struct DateTime {
sqlite3_uint64 iJD; /* The julian day number times 86400000 */
sqlite3_int64 iJD; /* The julian day number times 86400000 */
int Y, M, D; /* Year, month, and day */
int h, m; /* Hour and minutes */
int tz; /* Timezone offset in minutes */
@ -829,7 +829,9 @@ static int isDate(
}
if( (eType = sqlite3_value_type(argv[0]))==SQLITE_FLOAT
|| eType==SQLITE_INTEGER ){
p->iJD = (sqlite3_int64)(sqlite3_value_double(argv[0])*86400000.0 + 0.5);
double r = sqlite3_value_double(argv[0]);
if( r>106751991167.0 || r<-106751991167.0 ) return 1;
p->iJD = (sqlite3_int64)(r*86400000.0 + 0.5);
p->validJD = 1;
}else{
z = sqlite3_value_text(argv[0]);
@ -841,7 +843,8 @@ static int isDate(
z = sqlite3_value_text(argv[i]);
if( z==0 || parseModifier(context, (char*)z, p) ) return 1;
}
if( p->isError || (p->validJD && !validJulianDay(p->iJD)) ) return 1;
computeJD(p);
if( p->isError || !validJulianDay(p->iJD) ) return 1;
return 0;
}