From: drh <> Date: Wed, 8 Feb 2023 12:01:48 +0000 (+0000) Subject: Revert the behavior of date/time functions with no arguments so that they X-Git-Tag: version-3.41.0~34^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ed092fc3684dbc2b2d8642cd05241391e279fe8e;p=thirdparty%2Fsqlite.git Revert the behavior of date/time functions with no arguments so that they once again work like 'now', even while CURRENT_TIMESTAMP and similar work like 'txn'. FossilOrigin-Name: 06180caff0f5d8aba83b9f7be682ccdd6cb2ffc228b557ee6c1fd00fe5c23e92 --- diff --git a/manifest b/manifest index e5694c8f1a..b98697019e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sbehavior\sof\sdate-time\sfunctions\swithout\sany\sarguments\s(and\sthus\nthe\sCURRENT_TIME,\sCURRENT_DATE,\sand\sCURRENT_TIMESTAMP\svariables)\sso\sthat\sthey\nwork\slike\s'txn'\sinstead\sof\slike\s'now'.\s\sThis\sis\san\sincompatibility\swith\slegacy,\nbut\sbrings\sSQLite\sinto\sconformance\swith\sall\sother\sSQL\ssystems. -D 2023-02-08T11:34:05.173 +C Revert\sthe\sbehavior\sof\sdate/time\sfunctions\swith\sno\sarguments\sso\sthat\sthey\nonce\sagain\swork\slike\s'now',\seven\swhile\sCURRENT_TIMESTAMP\sand\ssimilar\swork\nlike\s'txn'. +D 2023-02-08T12:01:48.294 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -567,7 +567,7 @@ F src/build.c c55ab6d1b089ceef57160e840f05f692955ac90944c3d04fcf01d97fd7bfd08d F src/callback.c 4cd7225b26a97f7de5fee5ae10464bed5a78f2adefe19534cc2095b3a8ca484a F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 20507cc0b0a6c19cd882fcd0eaeda32ae6a4229fb4b024cfdf3183043d9b703d -F src/date.c 7bbe94be3ceb349faaf922ed6fb2429c1745bf0c4440c77bfc9ce5b93fcc9fde +F src/date.c 37ca5e3cb34d666fae892156c9317d8bf756ae8a281504040dd3a02813ce5e9e F src/dbpage.c d47549716549311f79dc39fe5c8fb19390a6eb2c960f8e37c89a9c4de0c1052e F src/dbstat.c ec92074baa61d883de58c945162d9e666c13cd7cf3a23bc38b4d1c4d0b2c2bef F src/delete.c 86573edae75e3d3e9a8b590d87db8e47222103029df4f3e11fa56044459b514e @@ -2045,8 +2045,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d3bed4caff561e71c396cc869c5b4d9bf216ba203485e738c12ec62741f1aba5 -R 306a6107a9a25e9636c592ddc5563a3a +P 1ac78be54502779236645eac35b962797f2fb98307d059d2aa19658c4fa74cb7 +R 21bc10e166e48f106bd855a3f05d7452 U drh -Z 577c1f61a5429561225ed1087c13c668 +Z 81861e88fff679ab1e007b3943020398 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e3acf22720..0086c81715 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1ac78be54502779236645eac35b962797f2fb98307d059d2aa19658c4fa74cb7 \ No newline at end of file +06180caff0f5d8aba83b9f7be682ccdd6cb2ffc228b557ee6c1fd00fe5c23e92 \ No newline at end of file diff --git a/src/date.c b/src/date.c index 43334f15c1..8546b5dc89 100644 --- a/src/date.c +++ b/src/date.c @@ -937,8 +937,11 @@ static int parseModifier( ** the resulting time into the DateTime structure p. Return 0 ** on success and 1 if there are any errors. ** -** If there are zero parameters (if even argv[0] is undefined) -** then assume a default value of "now" for argv[0]. +** If there are zero parameters (if argc<=0) then assume a default +** value of "now" for argv[0] if argc==0 and "txn" if argc<0. SQL +** functions will always have argc>=0, but the special implementations +** of CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP set argc to -1 +** in order to force the use of 'txn' semantics. */ static int isDate( sqlite3_context *context, @@ -950,9 +953,9 @@ static int isDate( const unsigned char *z; int eType; memset(p, 0, sizeof(*p)); - if( argc==0 ){ + if( argc<=0 ){ if( !sqlite3NotPureFunc(context) ) return 1; - return setCurrentStmtTime(context, p, 1); + return setCurrentStmtTime(context, p, argc<0); } if( (eType = sqlite3_value_type(argv[0]))==SQLITE_FLOAT || eType==SQLITE_INTEGER ){ @@ -1259,7 +1262,7 @@ static void ctimeFunc( sqlite3_value **NotUsed2 ){ UNUSED_PARAMETER2(NotUsed, NotUsed2); - timeFunc(context, 0, 0); + timeFunc(context, -1, 0); } /* @@ -1273,7 +1276,7 @@ static void cdateFunc( sqlite3_value **NotUsed2 ){ UNUSED_PARAMETER2(NotUsed, NotUsed2); - dateFunc(context, 0, 0); + dateFunc(context, -1, 0); } /* @@ -1287,7 +1290,7 @@ static void ctimestampFunc( sqlite3_value **NotUsed2 ){ UNUSED_PARAMETER2(NotUsed, NotUsed2); - datetimeFunc(context, 0, 0); + datetimeFunc(context, -1, 0); } #endif /* !defined(SQLITE_OMIT_DATETIME_FUNCS) */