]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
The coalesce(), ifnull(), and iif() functions pass through subtype values
authordrh <>
Fri, 3 May 2024 19:35:43 +0000 (19:35 +0000)
committerdrh <>
Fri, 3 May 2024 19:35:43 +0000 (19:35 +0000)
from their arguments, and hence need to have the SQLITE_RESULT_SUBTYPE flag
set.  This fixes an corner-case for the patch at [ba789a7804ab96d8].

FossilOrigin-Name: cdd1610c44876623e629bb8e5779ea689e6d23c545552b088eca63ad2d1cf8da

manifest
manifest.uuid
src/func.c
test/indexexpr1.test

index a0040a7b296a36654c6971c43086b9677e58f787..1ed79f3c8994d571adb0c56f44ff9d04fbfbb7e2 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sproblem\swith\squeries\sthat\suse\s"IN(...)\sORDER\sBY\s...\sNULLS\sLAST"\sor\ssimilar\sintroduced\sby\s[d7648e21605a0b38].
-D 2024-05-02T19:22:23.368
+C The\scoalesce(),\sifnull(),\sand\siif()\sfunctions\spass\sthrough\ssubtype\svalues\nfrom\stheir\sarguments,\sand\shence\sneed\sto\shave\sthe\sSQLITE_RESULT_SUBTYPE\sflag\nset.\s\sThis\sfixes\san\scorner-case\sfor\sthe\spatch\sat\s[ba789a7804ab96d8].
+D 2024-05-03T19:35:43.156
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -705,7 +705,7 @@ F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500
 F src/expr.c 005bf7a088a2fb12a50752a2a1d40d423b8942e1920e93c3a1ba76da0bfbe52b
 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
 F src/fkey.c a47610f0a5c6cb0ad79f8fcef039c01833dec0c751bb695f28dc0ec6a4c3ba00
-F src/func.c 283d4f3b2751a1d9339fd93a8a013d1948fd5f4474a3cab0955eb4fafd445d0f
+F src/func.c ac6e03e7f39feced49681a1a67c50a82b43e8573dd7a9278ca4ff291317f2b0d
 F src/global.c 61a419dd9e993b9be0f91de4c4ccf322b053eb829868e089f0321dd669be3b90
 F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220
 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
@@ -1302,7 +1302,7 @@ F test/index8.test caa097735c91dbc23d8a402f5e63a2a03c83840ba3928733ed7f9a03f8a91
 F test/index9.test 2ac891806a4136ef3e91280477e23114e67575207dc331e6797fa0ed9379f997
 F test/indexA.test 11d84f6995e6e5b9d8315953fb1b6d29772ee7c7803ee9112715e7e4dd3e4974
 F test/indexedby.test f21eca4f7a6ffe14c8500a7ad6cd53166666c99e5ccd311842a28bc94a195fe0
-F test/indexexpr1.test 833f511213a5e26549186813f0566bd72f978177a7e6e98a2d2dd695de3c670d
+F test/indexexpr1.test 870ffcf3911ef447e7714d49c4504a92580410ecb0d6d76499493f9a5591efb1
 F test/indexexpr2.test 1c382e81ef996d8ae8b834a74f2a9013dddf59214c32201d7c8a656d739f999a
 F test/indexfault.test 98d78a8ff1f5335628b62f886a1cb7c7dac1ef6d48fa39c51ec871c87dce9811
 F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7
@@ -2188,8 +2188,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 fbc446daac761dd1b66a85c9b61e1d5af194a8fd665600c43a874da38cc6ec10
-R 36f998b45a8aa5d9ecb00ca50d9b4f7d
-U dan
-Z b095a9ec23cb25cb4e9e06b89cd38b3b
+P 26b2d9390f1273ee0e3f3c96f6bc5bf0e9c1dcfd0d9ecd993dba487ef5a07f7e
+R 0268c566eccde5bd7b524cfab1a24524
+U drh
+Z ad416147806e454b3211249b5d00a37b
 # Remove this line to create a well-formed Fossil manifest.
index 91bc583d15c3da8e13f74e3f28aea3d7ce570a0f..b99a890c23aa4e7e707393a52b22a8a3df11b333 100644 (file)
@@ -1 +1 @@
-26b2d9390f1273ee0e3f3c96f6bc5bf0e9c1dcfd0d9ecd993dba487ef5a07f7e
\ No newline at end of file
+cdd1610c44876623e629bb8e5779ea689e6d23c545552b088eca63ad2d1cf8da
\ No newline at end of file
index 18004984d983d07b3fc6ac986dc03bf89c1e8634..472efa211052a58321f757f7bf58bd1f8b9e610d 100644 (file)
@@ -2643,7 +2643,7 @@ void sqlite3RegisterBuiltinFunctions(void){
     FUNCTION(concat_ws,         -1, 0, 0, concatwsFunc     ),
     FUNCTION(concat_ws,          0, 0, 0, 0                ),
     FUNCTION(concat_ws,          1, 0, 0, 0                ),
-    INLINE_FUNC(ifnull,          2, INLINEFUNC_coalesce, ),
+    INLINE_FUNC(ifnull,          2, INLINEFUNC_coalesce, SQLITE_RESULT_SUBTYPE),
     VFUNCTION(random,            0, 0, 0, randomFunc       ),
     VFUNCTION(randomblob,        1, 0, 0, randomBlob       ),
     FUNCTION(nullif,             2, 0, 1, nullifFunc       ),
@@ -2725,8 +2725,8 @@ void sqlite3RegisterBuiltinFunctions(void){
     FUNCTION(pi,                 0, 0, 0,      piFunc      ),
 #endif /* SQLITE_ENABLE_MATH_FUNCTIONS */
     FUNCTION(sign,               1, 0, 0,      signFunc    ),
-    INLINE_FUNC(coalesce,       -1, INLINEFUNC_coalesce, ),
-    INLINE_FUNC(iif,             3, INLINEFUNC_iif,      ),
+    INLINE_FUNC(coalesce,       -1, INLINEFUNC_coalesce, SQLITE_RESULT_SUBTYPE),
+    INLINE_FUNC(iif,             3, INLINEFUNC_iif,      SQLITE_RESULT_SUBTYPE),
   };
 #ifndef SQLITE_OMIT_ALTERTABLE
   sqlite3AlterFunctions();
index 0316ee9d421bdb758878d7c9a1a18758c06b62f1..e6b3fb6333acdf260ca397b774df16a8c4e02371 100644 (file)
@@ -615,6 +615,34 @@ do_execsql_test indexexpr1-2200 {
            GROUP BY t2.type, t1.tag
          ) v ON v.type = 0 AND v.tag = u.tag;
 } {7 100 8 101}
+do_execsql_test indexexpr1-2210 {
+  DROP TABLE t1;
+  CREATE TABLE t1(x INT, y TEXT);
+  INSERT INTO t1(x,y) VALUES(1,'{b:5}');
+  SELECT json_insert('{}', '$.a', coalesce(null,json(y)))->>'$.a.b' FROM t1;
+} {5}
+db null NULL
+do_execsql_test indexexpr1-2211 {
+  CREATE INDEX t1j ON t1(coalesce(null,json(y)));
+  SELECT json_insert('{}', '$.a', coalesce(null,json(y)))->>'$.a.b' FROM t1;
+} {5}
+do_execsql_test indexexpr1-2220 {
+  DROP INDEX t1j;
+  SELECT json_insert('{}', '$.a', iif(1,json(y),123))->>'$.a.b' FROM t1;
+} {5}
+do_execsql_test indexexpr1-2221 {
+  CREATE INDEX t1j ON t1(iif(1,json(y),123));
+  SELECT json_insert('{}', '$.a', iif(1,json(y),123))->>'$.a.b' FROM t1;
+} {5}
+do_execsql_test indexexpr1-2230 {
+  DROP INDEX t1j;
+  SELECT json_insert('{}', '$.a', ifnull(NULL,json(y)))->>'$.a.b' FROM t1;
+} {5}
+do_execsql_test indexexpr1-2231 {
+  CREATE INDEX t1j ON t1(ifnull(NULL,json(y)));
+  SELECT json_insert('{}', '$.a', ifnull(NULL,json(y)))->>'$.a.b' FROM t1;
+} {5}
+
 
 # 2023-11-08 Forum post https://sqlite.org/forum/forumpost/68d284c86b082c3e
 #