]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Change the ROUND() function to return a REAL value instead of TEXT.
authordrh <drh@noemail.net>
Thu, 2 Mar 2006 03:02:48 +0000 (03:02 +0000)
committerdrh <drh@noemail.net>
Thu, 2 Mar 2006 03:02:48 +0000 (03:02 +0000)
Ticket #1699. (CVS 3116)

FossilOrigin-Name: 9dbadfb2111f7d7f971e1832db3992ed5851d8b1

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

index aeef69914aa803ce22386a14a1f315584bb554d9..09aff746abf7fea26020dd39dc4efcbaa82fdc5c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Reduce\sthe\ssize\sof\sa\smemory\sallocation\sin\sthe\swindows\sdriver\sto\sthe\nminimum\sneeded.\s\sTicket\s#1690.\s(CVS\s3115)
-D 2006-02-27T23:44:36
+C Change\sthe\sROUND()\sfunction\sto\sreturn\sa\sREAL\svalue\sinstead\sof\sTEXT.\nTicket\s#1699.\s(CVS\s3116)
+D 2006-03-02T03:02:48
 F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b
 F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -43,7 +43,7 @@ F src/date.c cd2bd5d1ebc6fa12d6312f69789ae5b0a2766f2e
 F src/delete.c 2dea1a83e6ef534346e74fd03114d3a7b16f08fc
 F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
 F src/expr.c 9c957fabf95ef62288151eecd5c490a629470666
-F src/func.c 402b305b0f0d8709cce343e74312bcc38ed61f06
+F src/func.c ea1a4480bacfb17f8e08d675313f024fe7136c00
 F src/hash.c 449f3d6620193aa557f5d86cbc5cc6b87702b185
 F src/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564
 F src/insert.c ae51e360d1e710870471fb72d00f84c3d98292a0
@@ -165,7 +165,7 @@ F test/enc3.test 890508efff6677345e93bf2a8adb0489b30df030
 F test/expr.test 4e65cade931e14a0194eee41e33707e7af5f397a
 F test/fkey1.test 153004438d51e6769fb1ce165f6313972d6263ce
 F test/format4.test 9f31d41d4f926cab97b2ebe6be00a6ab12dece87
-F test/func.test 9fdc0a5ba9435dc7700cb81dbc46ee2459fb21e4
+F test/func.test 0996e47cb5bb24007cec76f1a4cac9f4417360be
 F test/hook.test 7e7645fd9a033f79cce8fdff151e32715e7ec50a
 F test/in.test 40feeebc7e38576255051aad428322be1545e0f1
 F test/index.test c478459611ded74745fee57f99f424da8a5f5fbd
@@ -355,7 +355,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 201ab3b5238c4afeb9a9f254f9ed3632b106066d
-R 9dca04ddafe342429b84cfc45a77a9a4
+P 1fe9ca078b77b79ac738a095d8d4c82ae0926286
+R b3fdad5802e6bee698b446a91a4e2c53
 U drh
-Z 4896a5f6cfb8b9ec7a034a281b292e51
+Z 321fd91bd847dc54e0ab9246b1daf202
index dbc809335beb7ab6b08001c5ed76f68394914979..d461fc9e8f61a6c57dbe6961c565484f97384105 100644 (file)
@@ -1 +1 @@
-1fe9ca078b77b79ac738a095d8d4c82ae0926286
\ No newline at end of file
+9dbadfb2111f7d7f971e1832db3992ed5851d8b1
\ No newline at end of file
index e365cc435c55fb5977dcead1960d925c7c8c9673..951365115c137632ee788fee5bb69fb7c4a153d8 100644 (file)
@@ -16,7 +16,7 @@
 ** sqliteRegisterBuildinFunctions() found at the bottom of the file.
 ** All other code has file scope.
 **
-** $Id: func.c,v 1.124 2006/02/23 21:51:13 drh Exp $
+** $Id: func.c,v 1.125 2006/03/02 03:02:48 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -201,10 +201,10 @@ static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
     if( n>30 ) n = 30;
     if( n<0 ) n = 0;
   }
-  if( SQLITE_NULL==sqlite3_value_type(argv[0]) ) return;
+  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
   r = sqlite3_value_double(argv[0]);
   sqlite3_snprintf(sizeof(zBuf),zBuf,"%.*f",n,r);
-  sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
+  sqlite3_result_double(context, atof(zBuf));
 }
 
 /*
index 79e6e430673b358b442ea15fbeb56401c027992c..5038a2a1ca2bcfd4df91dd35d6673988df3d5498 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing built-in functions.
 #
-# $Id: func.test,v 1.49 2006/02/23 21:43:56 drh Exp $
+# $Id: func.test,v 1.50 2006/03/02 03:02:48 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -179,28 +179,35 @@ do_test func-4.5 {
 } {1 {wrong number of arguments to function round()}}
 do_test func-4.6 {
   catchsql {SELECT round(b,2) FROM t1 ORDER BY b}
-} {0 {-2.00 1.23 2.00}}
+} {0 {-2.0 1.23 2.0}}
 do_test func-4.7 {
   catchsql {SELECT round(b,0) FROM t1 ORDER BY a}
-} {0 {2 1 -2}}
+} {0 {2.0 1.0 -2.0}}
 do_test func-4.8 {
   catchsql {SELECT round(c) FROM t1 ORDER BY a}
-} {0 {3 -12346 -5}}
+} {0 {3.0 -12346.0 -5.0}}
 do_test func-4.9 {
   catchsql {SELECT round(c,a) FROM t1 ORDER BY a}
-} {0 {3.0 -12345.68 -5.000}}
+} {0 {3.0 -12345.68 -5.0}}
 do_test func-4.10 {
   catchsql {SELECT 'x' || round(c,a) || 'y' FROM t1 ORDER BY a}
-} {0 {x3.0y x-12345.68y x-5.000y}}
+} {0 {x3.0y x-12345.68y x-5.0y}}
 do_test func-4.11 {
   catchsql {SELECT round() FROM t1 ORDER BY a}
 } {1 {wrong number of arguments to function round()}}
 do_test func-4.12 {
   execsql {SELECT coalesce(round(a,2),'nil') FROM t2}
-} {1.00 nil 345.00 nil 67890.00}
+} {1.0 nil 345.0 nil 67890.0}
 do_test func-4.13 {
   execsql {SELECT round(t1,2) FROM tbl1}
-} {0.00 0.00 0.00 0.00 0.00}
+} {0.0 0.0 0.0 0.0 0.0}
+do_test func-4.14 {
+  execsql {SELECT typeof(round(5.1,1));}
+} {real}
+do_test func-4.15 {
+  execsql {SELECT typeof(round(5.1));}
+} {real}
+
 
 # Test the upper() and lower() functions
 #