mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Add a new interface, sqlite3_context_db_handle(), that returns the database
connection pointer for an application-defined function. (CVS 4889) FossilOrigin-Name: 54c55cae556af5a16c0ce8be1a96d2932db80ad8
This commit is contained in:
13
src/date.c
13
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.77 2008/03/19 20:18:28 drh Exp $
|
||||
** $Id: date.c,v 1.78 2008/03/19 21:45:51 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
|
||||
@@ -324,7 +324,8 @@ static int parseDateOrTime(
|
||||
return 0;
|
||||
}else if( sqlite3StrICmp(zDate,"now")==0){
|
||||
double r;
|
||||
sqlite3OsCurrentTime((sqlite3_vfs *)sqlite3_user_data(context), &r);
|
||||
sqlite3 *db = sqlite3_context_db_handle(context);
|
||||
sqlite3OsCurrentTime(db->pVfs, &r);
|
||||
p->rJD = r;
|
||||
p->validJD = 1;
|
||||
return 0;
|
||||
@@ -970,12 +971,12 @@ static void currentTimeFunc(
|
||||
){
|
||||
time_t t;
|
||||
char *zFormat = (char *)sqlite3_user_data(context);
|
||||
sqlite3_vfs *pVfs;
|
||||
sqlite3 *db;
|
||||
double rT;
|
||||
char zBuf[20];
|
||||
|
||||
pVfs = sqlite3_vfs_find(0);
|
||||
sqlite3OsCurrentTime(pVfs, &rT);
|
||||
db = sqlite3_context_db_handle(context);
|
||||
sqlite3OsCurrentTime(db->pVfs, &rT);
|
||||
t = 86400.0*(rT - 2440587.5) + 0.5;
|
||||
#ifdef HAVE_GMTIME_R
|
||||
{
|
||||
@@ -1022,7 +1023,7 @@ void sqlite3RegisterDateTimeFunctions(sqlite3 *db){
|
||||
|
||||
for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){
|
||||
sqlite3CreateFunc(db, aFuncs[i].zName, aFuncs[i].nArg,
|
||||
SQLITE_UTF8, (void *)(db->pVfs), aFuncs[i].xFunc, 0, 0);
|
||||
SQLITE_UTF8, 0, aFuncs[i].xFunc, 0, 0);
|
||||
}
|
||||
#else
|
||||
static const struct {
|
||||
|
Reference in New Issue
Block a user