diff --git a/manifest b/manifest index bc1563c28f..b43603693f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Port\sthe\s"DEFAULT\sCURRENT_TIME"\setc.\sfunctionality\sfrom\san\searlier\sfork\sof\ssqlite.\s(CVS\s2082) -D 2004-11-09T12:44:38 +C Have\s"DEFAULT\sCURRENT_TIME"\s&\sco.\swork\seven\sif\sSQLITE_OMIT_DATETIME_FUNCS\sis\sdefined.\s(CVS\s2083) +D 2004-11-09T16:13:33 F Makefile.in c4d2416860f472a1e3393714d0372074197565df F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1 @@ -32,7 +32,7 @@ F src/auth.c 3b81f2a42f48a62c2c9c9b0eda31a157c681edea F src/btree.c 63a84350a18f6ca68f16e2a12018b5041444a2df F src/btree.h 861e40b759a195ba63819740e484390012cf81ab F src/build.c d623d84fd7f4e9cc0c5e8d1b96aab7886cf0f84d -F src/date.c dbf15c130ba2c0231c642b65a361d41dbc02db95 +F src/date.c fcbade133371925ac28fe3f926031d60b07e2474 F src/delete.c f0af21a1ede15524a5edd59fe10ef486283a1ee9 F src/expr.c 5f9afecf27e048b8f3627b5a9be3136bc1d9bdf1 F src/func.c 600e506bccf7648df8ad03efb417560d0f7ad4c1 @@ -54,7 +54,7 @@ F src/os_win.c 9482dfc92f289b68205bb2c9315757c7e3946bfb F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b F src/pager.c 2653787b86267c079283b8128541095f0febac4f F src/pager.h 9eba8c53dd91eae7f3f90743b2ee242da02a9862 -F src/parse.y 0af8d009cab3a30b967ab75dc260967d87b20496 +F src/parse.y 02e0d88a6d465f6fd5ea79a200a8c23c92a877dc F src/pragma.c 44074b93216516b01cafacd85cb10621088693dd F src/printf.c 3d20b21cfecadacecac3fb7274e746cb81d3d357 F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3 @@ -173,7 +173,7 @@ F test/select6.test 4ce9fa563662d5b2f5a8ff57e4d8b2f5cd186d38 F test/select7.test c71c822a82c80bbd55558b4b69d35442dfe22ffd F test/sort.test c97c1a3289337b1dc349ac8a59e0780d2dcfd90b F test/subselect.test 50f98723f00e97b1839d36410ee63597ca82d775 -F test/table.test 54081854744733598af2122451b97b59d64ae894 +F test/table.test 0d7659fa9ffd5946c7d2f006b4c8608d7e9cc518 F test/tableapi.test b21ab097e87a5484bb61029e69e1a4e5c5e65ede F test/tclsqlite.test 5e262df81a638a058536fb6d6666f316843ac7b2 F test/temptable.test 63a16e3ad19adf073cfbcdf7624c92ac5236522c @@ -254,7 +254,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c -P 63f2ee22e20ed7e520fd9230acc5c6db43b69d13 -R c7c1616611e1356d29290318a6cf79f2 +P 0d27c8ff48f327ad82dd5b5b3b47b8d221f119b7 +R 50983ef3488aaf796e19a0b73688d49a U danielk1977 -Z ee44e58703e5c1b5ed5b43c2151ec560 +Z a02b42aae687ca01ff2682d8d73ff8dd diff --git a/manifest.uuid b/manifest.uuid index b5f66e1a38..a6f27409bc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0d27c8ff48f327ad82dd5b5b3b47b8d221f119b7 \ No newline at end of file +f81b9c1c022772378aad32ec45d0027beeb36574 \ No newline at end of file diff --git a/src/date.c b/src/date.c index f085ed56fb..3dff942af0 100644 --- a/src/date.c +++ b/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.38 2004/11/09 12:44:38 danielk1977 Exp $ +** $Id: date.c,v 1.39 2004/11/09 16:13:33 danielk1977 Exp $ ** ** NOTES: ** @@ -917,6 +917,45 @@ static void ctimestampFunc( } #endif /* !defined(SQLITE_OMIT_DATETIME_FUNCS) */ +#ifdef SQLITE_OMIT_DATETIME_FUNCS +/* +** If the library is compiled to omit the full-scale date and time +** handling (to get a smaller binary), the following minimal version +** of the functions current_time(), current_date() and current_timestamp() +** are included instead. This is to support column declarations that +** include "DEFAULT CURRENT_TIME" etc. +** +** This function uses the C-library functions time(), localtime_r() +** and strftime(). The format string to pass to strftime() is supplied +** as the user-data for the function. +*/ + +static void currentTimeFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + time_t t; + char *zFormat = (char *)sqlite3_user_data(context); + char zBuf[20]; + struct tm now; + +#ifdef SQLITE_TEST + /* This test variable is located in os_XXX.c */ +extern int sqlite3_current_time; +#endif + time(&t); +#ifdef SQLITE_TEST + if( sqlite3_current_time ){ + t = sqlite3_current_time; + } +#endif + localtime_r(&t, &now); + strftime(zBuf, 20, zFormat, &now); + sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT); +} +#endif + /* ** This function registered all of the above C functions as SQL ** functions. This should be the only routine in this file with @@ -944,6 +983,21 @@ void sqlite3RegisterDateTimeFunctions(sqlite3 *db){ sqlite3_create_function(db, aFuncs[i].zName, aFuncs[i].nArg, SQLITE_UTF8, 0, aFuncs[i].xFunc, 0, 0); } +#else + static const struct { + char *zName; + char *zFormat; + } aFuncs[] = { + { "current_time", "%H:%M:%S" }, + { "current_date", "%Y-%m-%d" }, + { "current_timestamp", "%Y-%m-%d %H:%M:%S" } + }; + int i; + + for(i=0; i