Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix the round() SQL function so that it handles infinities correctly. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
db9acef14d49212108c8082cc15a9b9b |
User & Date: | drh 2019-05-10 12:06:47 |
References
2019-05-10
| ||
12:14 | Fix the previous check-in [db9acef14d492121] so that the amalgamation build works for systems for which lack HAVE_ISNAN. (check-in: 3cc55e09 user: drh tags: trunk) | |
Context
2019-05-10
| ||
12:14 | Fix the previous check-in [db9acef14d492121] so that the amalgamation build works for systems for which lack HAVE_ISNAN. (check-in: 3cc55e09 user: drh tags: trunk) | |
12:06 | Fix the round() SQL function so that it handles infinities correctly. (check-in: db9acef1 user: drh tags: trunk) | |
2019-05-09
| ||
18:37 | Fix another small buffer overread in sqlite_dbdata triggered by a corrupt database page. (check-in: 1dfc95b8 user: dan tags: trunk) | |
Changes
Changes to src/func.c.
︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ** This file contains the C-language implementations for many of the SQL ** functions of SQLite. (Some function, and in particular the date and ** time functions, are implemented separately.) */ #include "sqliteInt.h" #include <stdlib.h> #include <assert.h> #include "vdbeInt.h" /* ** Return the collating function associated with a function. */ static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){ VdbeOp *pOp; | > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ** This file contains the C-language implementations for many of the SQL ** functions of SQLite. (Some function, and in particular the date and ** time functions, are implemented separately.) */ #include "sqliteInt.h" #include <stdlib.h> #include <assert.h> #include <math.h> #include "vdbeInt.h" /* ** Return the collating function associated with a function. */ static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){ VdbeOp *pOp; |
︙ | ︙ | |||
392 393 394 395 396 397 398 | r = -(double)((sqlite_int64)((-r)+0.5)); }else{ zBuf = sqlite3_mprintf("%.*f",n,r); if( zBuf==0 ){ sqlite3_result_error_nomem(context); return; } | | > > > | 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | r = -(double)((sqlite_int64)((-r)+0.5)); }else{ zBuf = sqlite3_mprintf("%.*f",n,r); if( zBuf==0 ){ sqlite3_result_error_nomem(context); return; } if( !sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8) ){ assert( sqlite3_strglob("*Inf", zBuf)==0 ); r = zBuf[0]=='-' ? -HUGE_VAL : +HUGE_VAL; } sqlite3_free(zBuf); } sqlite3_result_double(context, r); } #endif /* |
︙ | ︙ |
Changes to test/func.test.
︙ | ︙ | |||
311 312 313 314 315 316 317 318 319 320 321 322 323 324 | } {99999999999995.0} do_test func-4.37 { execsql {SELECT round(9999999999999.55,1);} } {9999999999999.6} do_test func-4.38 { execsql {SELECT round(9999999999999.556,2);} } {9999999999999.56} } # Test the upper() and lower() functions # do_test func-5.1 { execsql {SELECT upper(t1) FROM tbl1} } {THIS PROGRAM IS FREE SOFTWARE} | > > > | 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | } {99999999999995.0} do_test func-4.37 { execsql {SELECT round(9999999999999.55,1);} } {9999999999999.6} do_test func-4.38 { execsql {SELECT round(9999999999999.556,2);} } {9999999999999.56} do_execsql_test func-4.39 { SELECT round(1e500), round(-1e500); } {Inf -Inf} } # Test the upper() and lower() functions # do_test func-5.1 { execsql {SELECT upper(t1) FROM tbl1} } {THIS PROGRAM IS FREE SOFTWARE} |
︙ | ︙ |