1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Allow indexes to be created on date/time functions as long as the 'now'

date and the 'localtime' and 'utc' modifiers are not used.

FossilOrigin-Name: 0a5e1c04d9d07bb7fd6546a9ddac1bf42b19ea19c2b79570aea6cd4226887a27
This commit is contained in:
drh
2017-07-19 19:48:40 +00:00
parent 885f410472
commit 3e34eabcdf
11 changed files with 189 additions and 145 deletions

View File

@@ -386,7 +386,8 @@ static int parseDateOrTime(
return 0;
}else if( parseHhMmSs(zDate, p)==0 ){
return 0;
}else if( sqlite3StrICmp(zDate,"now")==0){
}else if( sqlite3StrICmp(zDate,"now")==0 ){
sqlite3VdbePureFuncOnly(context);
return setDateTimeToCurrent(context, p);
}else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8) ){
setRawDateNumber(p, r);
@@ -670,6 +671,7 @@ static int parseModifier(
** show local time.
*/
if( sqlite3_stricmp(z, "localtime")==0 ){
sqlite3VdbePureFuncOnly(pCtx);
computeJD(p);
p->iJD += localtimeOffset(p, pCtx, &rc);
clearYMD_HMS_TZ(p);
@@ -696,6 +698,7 @@ static int parseModifier(
}
#ifndef SQLITE_OMIT_LOCALTIME
else if( sqlite3_stricmp(z, "utc")==0 ){
sqlite3VdbePureFuncOnly(pCtx);
if( p->tzSet==0 ){
sqlite3_int64 c1;
computeJD(p);
@@ -1231,11 +1234,11 @@ static void currentTimeFunc(
void sqlite3RegisterDateTimeFunctions(void){
static FuncDef aDateTimeFuncs[] = {
#ifndef SQLITE_OMIT_DATETIME_FUNCS
DFUNCTION(julianday, -1, 0, 0, juliandayFunc ),
DFUNCTION(date, -1, 0, 0, dateFunc ),
DFUNCTION(time, -1, 0, 0, timeFunc ),
DFUNCTION(datetime, -1, 0, 0, datetimeFunc ),
DFUNCTION(strftime, -1, 0, 0, strftimeFunc ),
PURE_DATE(julianday, -1, 0, 0, juliandayFunc ),
PURE_DATE(date, -1, 0, 0, dateFunc ),
PURE_DATE(time, -1, 0, 0, timeFunc ),
PURE_DATE(datetime, -1, 0, 0, datetimeFunc ),
PURE_DATE(strftime, -1, 0, 0, strftimeFunc ),
DFUNCTION(current_time, 0, 0, 0, ctimeFunc ),
DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc),
DFUNCTION(current_date, 0, 0, 0, cdateFunc ),