Avoid unnecessary float->text->float conversions in date/time processing.
This change necessary to reproduce the problem reported by BareFoot. (CVS 5213) FossilOrigin-Name: 6ec4d7653b1e67ba0951e909ee23fe774762d646
This commit is contained in:
parent
66147c9715
commit
3af5d685d7
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Add\sthe\sability\sto\sdisable\sthe\s"localtime"\smodifier\sin\sthe\sdate/time\nfunctions.\s\sThis\smight\sbe\snecessary\sfor\ssystems\sthat\sdo\snot\ssupport\nlocaltime_r()\sor\slocaltime_s().\s(CVS\s5212)
|
||||
D 2008-06-12T12:51:37
|
||||
C Avoid\sunnecessary\sfloat->text->float\sconversions\sin\sdate/time\sprocessing.\nThis\schange\snecessary\sto\sreproduce\sthe\sproblem\sreported\sby\sBareFoot.\s(CVS\s5213)
|
||||
D 2008-06-12T13:50:00
|
||||
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
|
||||
F Makefile.in ce92ea8dc7adfb743757794f51c10d1b0d9c55e4
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -102,7 +102,7 @@ F src/btreeInt.h dc04ee33d8eb84714b2acdf81336fbbf6e764530
|
||||
F src/build.c a52d9d51341444a2131e3431608f245db80d9591
|
||||
F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0
|
||||
F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
|
||||
F src/date.c fd34fd6b95ba197a7edcf03f2d29bbad12627747
|
||||
F src/date.c 95d742c3fbbcccb3bf89e1acfaf90c9626e37592
|
||||
F src/delete.c d3fc5987f2eb88f7b9549d58a5dfea079a83fe8b
|
||||
F src/expr.c ecb3b23d3543427cba3e2ac12a6c6ae4bb20d39b
|
||||
F src/fault.c 1f6177188edb00641673e462f3fab8cba9f7422b
|
||||
@ -593,7 +593,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
P 699cec66cdae6818844612d69eb89aa8b93c3f1a
|
||||
R 6631b4e8e1eef0d904b1e969cd29169e
|
||||
P 12f3ba11e72b2310abf51d040d5344c81fe5ebd3
|
||||
R bb5746ef6e6bfc89c8a8599c4be75f8d
|
||||
U drh
|
||||
Z c094251ed94ff85de9ce9595187c60d8
|
||||
Z 2295630320c454b579b6d344ea7e8948
|
||||
|
@ -1 +1 @@
|
||||
12f3ba11e72b2310abf51d040d5344c81fe5ebd3
|
||||
6ec4d7653b1e67ba0951e909ee23fe774762d646
|
29
src/date.c
29
src/date.c
@ -16,7 +16,7 @@
|
||||
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
|
||||
** All other code has file scope.
|
||||
**
|
||||
** $Id: date.c,v 1.81 2008/06/12 12:51:37 drh Exp $
|
||||
** $Id: date.c,v 1.82 2008/06/12 13:50:00 drh Exp $
|
||||
**
|
||||
** SQLite processes all times and dates as Julian Day numbers. The
|
||||
** dates and times are stored as the number of days since noon
|
||||
@ -313,6 +313,17 @@ static int parseYyyyMmDd(const char *zDate, DateTime *p){
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Set the time to the current time reported by the VFS
|
||||
*/
|
||||
static void setDateTimeToCurrent(sqlite3_context *context, DateTime *p){
|
||||
double r;
|
||||
sqlite3 *db = sqlite3_context_db_handle(context);
|
||||
sqlite3OsCurrentTime(db->pVfs, &r);
|
||||
p->rJD = r;
|
||||
p->validJD = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
** Attempt to parse the given string into a Julian Day Number. Return
|
||||
** the number of errors.
|
||||
@ -340,11 +351,7 @@ static int parseDateOrTime(
|
||||
}else if( parseHhMmSs(zDate, p)==0 ){
|
||||
return 0;
|
||||
}else if( sqlite3StrICmp(zDate,"now")==0){
|
||||
double r;
|
||||
sqlite3 *db = sqlite3_context_db_handle(context);
|
||||
sqlite3OsCurrentTime(db->pVfs, &r);
|
||||
p->rJD = r;
|
||||
p->validJD = 1;
|
||||
setDateTimeToCurrent(context, p);
|
||||
return 0;
|
||||
}else if( sqlite3IsNumber(zDate, 0, SQLITE_UTF8) ){
|
||||
getValue(zDate, &p->rJD);
|
||||
@ -708,15 +715,19 @@ static int isDate(
|
||||
){
|
||||
int i;
|
||||
const unsigned char *z;
|
||||
static const unsigned char zDflt[] = "now";
|
||||
memset(p, 0, sizeof(*p));
|
||||
if( argc==0 ){
|
||||
z = zDflt;
|
||||
setDateTimeToCurrent(context, p);
|
||||
}else if( sqlite3_value_type(argv[0])==SQLITE_FLOAT ){
|
||||
memset(p, 0, sizeof(*p));
|
||||
p->rJD = sqlite3_value_double(argv[0]);
|
||||
p->validJD = 1;
|
||||
}else{
|
||||
z = sqlite3_value_text(argv[0]);
|
||||
}
|
||||
if( !z || parseDateOrTime(context, (char*)z, p) ){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
for(i=1; i<argc; i++){
|
||||
if( (z = sqlite3_value_text(argv[i]))==0 || parseModifier((char*)z, p) ){
|
||||
return 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user