Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | min() ignores NULL values. Ticket #800. (CVS 1802) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
166234a2b61e1d6a501e48dde1caec0a |
User & Date: | drh 2004-07-18 20:52:32.000 |
Context
2004-07-18
| ||
21:33 | An improved fix for the min() problem of ticket #800. (CVS 1804) (check-in: b6e8b7a13c user: drh tags: trunk) | |
20:52 | min() ignores NULL values. Ticket #800. (CVS 1802) (check-in: 166234a2b6 user: drh tags: trunk) | |
2004-07-17
| ||
21:56 | mprintf() correctly handles "%s","". Fix for ticket #812. (CVS 1800) (check-in: 4f56db1149 user: drh tags: trunk) | |
Changes
Changes to src/func.c.
︙ | |||
12 13 14 15 16 17 18 | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | - + | ** This file contains the C functions that implement various SQL ** functions of SQLite. ** ** There is only one exported symbol in this file - the function ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** |
︙ | |||
975 976 977 978 979 980 981 | 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 | - - + + + - + + + | char zBuf[28]; /* Space that can be used for storage */ }; /* ** Routines to implement min() and max() aggregate functions. */ static void minmaxStep(sqlite3_context *context, int argc, sqlite3_value **argv){ |
︙ |
Changes to src/select.c.
︙ | |||
8 9 10 11 12 13 14 | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | - + | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** |
︙ | |||
2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 | 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 | + + + + + + + + | if( pIdx==0 ){ sqlite3VdbeAddOp(v, seekOp, base, 0); }else{ sqlite3VdbeAddOp(v, OP_Integer, pIdx->iDb, 0); sqlite3VdbeOp3(v, OP_OpenRead, base+1, pIdx->tnum, (char*)&pIdx->keyInfo, P3_KEYINFO); sqlite3VdbeAddOp(v, seekOp, base+1, 0); if( seekOp==OP_Rewind ){ int addr; sqlite3VdbeAddOp(v, OP_SetNumColumns, base+1, pIdx->nColumn+1); sqlite3VdbeAddOp(v, OP_KeyAsData, base+1, 1); addr = sqlite3VdbeAddOp(v, OP_IdxColumn, base+1, 0); sqlite3VdbeAddOp(v, OP_NotNull, 1, addr+3); sqlite3VdbeAddOp(v, OP_Next, 1, addr); } sqlite3VdbeAddOp(v, OP_IdxRecno, base+1, 0); sqlite3VdbeAddOp(v, OP_Close, base+1, 0); sqlite3VdbeAddOp(v, OP_MoveGe, base, 0); } eList.nExpr = 1; memset(&eListItem, 0, sizeof(eListItem)); eList.a = &eListItem; |
︙ |
Changes to test/func.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | - + | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing built-in functions. # |
︙ | |||
247 248 249 250 251 252 253 | 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | - + - + | # Tests for aggregate functions and how they handle NULLs. # do_test func-8.1 { execsql { SELECT sum(a), count(a), round(avg(a),2), min(a), max(a), count(*) FROM t2; } |
︙ |
Changes to test/minmax.test.
︙ | |||
9 10 11 12 13 14 15 | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | - + | # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing SELECT statements that contain # aggregate min() and max() functions and which are handled as # as a special case. # |
︙ | |||
123 124 125 126 127 128 129 | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | - + | } {0} do_test minmax-4.1 { execsql { SELECT coalesce(min(x+0),-1), coalesce(max(x+0),-1) FROM (SELECT * FROM t1 UNION SELECT NULL as 'x', NULL as 'y') } |
︙ | |||
272 273 274 275 276 277 278 | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | - - + + - - + - + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | execsql { SELECT max(rowid) FROM ( SELECT max(rowid) FROM t4 EXCEPT SELECT max(rowid) FROM t5 ) } } {{}} |
Changes to test/null.test.
︙ | |||
96 97 98 99 100 101 102 | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | - + | # Check to see that NULL values are ignored in aggregate functions. # do_test null-3.1 { execsql { select count(*), count(b), count(c), sum(b), sum(c), avg(b), avg(c), min(b), max(b) from t1; } |
︙ |
Changes to test/select1.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | - + | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the SELECT statement. # |
︙ | |||
155 156 157 158 159 160 161 | 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | - + | } {0 11} do_test select1-2.8 { set v [catch {execsql {SELECT MIN(f1,f2) FROM test1}} msg] lappend v [lsort $msg] } {0 {11 33}} do_test select1-2.8.1 { execsql {SELECT coalesce(min(a),'xyzzy') FROM t3} |
︙ |
Changes to www/lang.tcl.
1 2 3 | 1 2 3 4 5 6 7 8 9 10 11 | - + | # # Run this Tcl script to generate the sqlite.html file. # |
︙ | |||
1088 1089 1090 1091 1092 1093 1094 | 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 | - - + + + | <td valign="top" align="right">max(<i>X</i>)</td> <td valign="top">Return the maximum value of all values in the group. The usual sort order is used to determine the maximum.</td> </tr> <tr> <td valign="top" align="right">min(<i>X</i>)</td> |
︙ |