Commit graph

116 commits

Author SHA1 Message Date
mhansson/martin@linux-st28.site
364014e455 Merge mhansson@bk-internal:/home/bk/mysql-5.0-opt
into  linux-st28.site:/home/martin/mysql/src/5.0o-bug27573
2007-05-16 12:22:20 +03:00
mhansson/martin@linux-st28.site
5bc137ff17 Bug#27573: MIN() on an indexed column which is always NULL sets _other_ results
to NULL

For queries of the form SELECT MIN(key_part_k) FROM t1 
WHERE key_part_1 = const and ... and key_part_k-1 = const,
the opt_sum_query optimization tries to
use an index to substitute MIN/MAX functions with their values according
to the following rules:
1) Insert the minimum non-null values where the WHERE clause still matches, or
3) A row of nulls

However, the correct semantics requires that there is a third case 2)
such that a NULL value is substituted if there are only NULL values for 
key_part_k.

The patch modifies opt_sum_query() to handle this missing case.
2007-05-15 15:29:12 +03:00
ramil/ram@mysql.com/ramil.myoffice.izhnet.ru
c132038451 Merge mysql.com:/home/ram/work/mysql-5.0-maint
into  mysql.com:/home/ram/work/b21976/my50-b21976
2007-03-29 13:37:07 +05:00
ramil/ram@mysql.com/ramil.myoffice.izhnet.ru
fe8b1495f3 Fix for bug #25834: Test failure in "func_group"
Round the results of std() for some calls with double arguments
to avoid double math precision problems.
2007-02-27 11:01:58 +04:00
tsmith/tim@siva.hindu.god
828121bd6d In func_group.test, round the results of std() for some calls, because Windows' sqrt() function appears to return fewer "significant" digits than the Unix implementations.
This is for bug #22555.
2006-12-26 12:42:54 -07:00
cmiller@zippy.cornsilk.net
8ffe6fb522 Merge zippy.cornsilk.net:/home/cmiller/work/mysql/bug22555/my50-bug22555
into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-maint
2006-12-22 16:02:54 -05:00
cmiller@zippy.cornsilk.net
50726b2322 Bug#22555: STDDEV yields positive result for groups with only one row
When only one row was present, the subtraction of nearly the same number 
resulted in catastropic cancellation, introducing an error in the 
VARIANCE calculation near 1e-15.  That was sqrt()ed to get STDDEV, the 
error was escallated to near 1e-8.  

The simple fix of testing for a row count of 1 and forcing that to yield 
0.0 is insufficient, as two rows of the same value should also have a
variance of 0.0, yet the error would be about the same.

So, this patch changes the formula that computes the VARIANCE to be one
that is not subject to catastrophic cancellation.

In addition, it now uses only (faster-than-decimal) floating point numbers
to calculate, and renders that to other types on demand.
2006-12-22 15:37:37 -05:00
ramil/ram@mysql.com/ramil.myoffice.izhnet.ru
294ae90d9c Fix for bug #21976: Unnecessary warning with count(decimal)
We use val_int() calls (followed by null_value check) to determine 
nullness in some Item_sum_count' and Item_sum_count_distinct' methods, 
as a side effect we get extra warnings raised in the val_int().
Fix: use is_null() instead.
2006-12-22 09:29:28 +04:00
gkodinov/kgeorge@macbook.gmz
6cd1f7b2e5 Bug #23184: SELECT causes server crash
Item::val_xxx() may be called by the server several times at execute time 
 for a single query. Calls to val_xxx() may be very expensive and sometimes
 (count(distinct), sum(distinct), avg(distinct)) not possible.
 To avoid that problem the results of calculation for these aggregate 
 functions are cached so that val_xxx() methods just return the calculated 
 value for the second and subsequent calls.
2006-10-31 11:01:27 +02:00
gkodinov/kgeorge@rakia.(none)
8577d7913e fixed merge 2006-09-20 12:02:58 +03:00
gkodinov/kgeorge@rakia.(none)
2da037c7d5 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B21540-5.0-opt
2006-09-19 19:18:52 +03:00
gkodinov/kgeorge@macbook.gmz
5bc16fd954 Bug #21540: Subqueries with no from and aggregate functions return
wrong results
 Mark the containing Item(s) (Item_subselect descendant usually) of 
 a subselect as containing aggregate functions if it has references
 to aggregates functions that are calculated outside its context.
 This tels end_send_group() not to make an Item_subselect descendant in
 select list a copy and causes the correct value being returned.
2006-09-08 19:04:46 +03:00
gkodinov/kgeorge@macbook.gmz
7eaa08e092 Merge bug #16792 4.1->5.0 2006-09-05 19:07:55 +03:00
gkodinov/kgeorge@macbook.gmz
91e93eb7d0 Merge macbook.gmz:/Users/kgeorge/mysql/work/B16792-4.1-opt
into  macbook.gmz:/Users/kgeorge/mysql/work/B16792-5.0-opt
2006-09-05 17:09:12 +03:00
gkodinov/kgeorge@macbook.gmz
9ff33b5d93 Bug #16792 query with subselect, join, and group not returning proper values
Treat queries with no FROM and aggregate functions as normal queries,
so the aggregate function get correctly calculated as if there is 1 row. 
This means that they will be considered to have one row, so COUNT(*) will return
1 instead of 0. Other aggregates will behave in compatible manner.
2006-08-10 16:45:02 +03:00
msvensson@neptunus.(none)
7280f63100 Merge neptunus.(none):/home/msvensson/mysql/mysql-5.0
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0-maint
2006-08-03 09:32:58 +02:00
evgen@moonbone.local
b43b2a2fe0 select.result, func_group.result, sql_select.cc:
After merge fix
2006-07-31 23:05:54 +04:00
evgen@sunlight.local
3ca575dc89 Merge sunlight.local:/local_work/tmp_merge-4.1-opt-mysql
into  sunlight.local:/local_work/tmp_merge-5.0-opt-mysql
2006-07-29 23:59:53 +04:00
timour/timka@lamia.home
86ae2f3b06 Fix for BUG#20954: avg(keyval) retuns 0.38 but max(keyval) returns an empty set
The problem was in that opt_sum_query() replaced MIN/MAX functions
with the corresponding constant found in a key, but due to imprecise
representation of float numbers, when evaluating the where clause,
this comparison failed.

When MIN/MAX optimization detects that all tables can be removed,
also remove all conjuncts in a where clause that refer to these
tables. As a result of this fix, these conditions are not evaluated
twice, and in the case of float number comparisons we do not discard
result rows due to imprecise float representation.

As a side-effect this fix also corrects an unnoticed problem in
bug 12882.
2006-07-26 01:11:19 +03:00
ramil/ram@mysql.com/myoffice.izhnet.ru
a810a2a437 Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-5.0-maint
into  mysql.com:/usr/home/ram/work/5.0.b10966
2006-07-23 12:58:26 +05:00
gkodinov/kgeorge@macbook.gmz
3ef086d263 Bug #20868: Client connection is broken on SQL query error
An aggregate function reference was resolved incorrectly and
caused a crash in count_field_types.
 Must use real_item() to get to the real Item instance through
the reference
2006-07-21 17:59:52 +03:00
igor@rurik.mysql.com
ee2e2d0c6d Post_merges fixes. 2006-06-15 20:29:05 -07:00
igor@rurik.mysql.com
1241d86787 Merge rurik.mysql.com:/home/igor/mysql-4.1-opt
into  rurik.mysql.com:/home/igor/mysql-5.0-opt
2006-06-15 18:40:18 -07:00
igor@rurik.mysql.com
5cdd1eb62d Post-review corrections of the fix for bug #18206. 2006-06-13 22:38:00 -07:00
igor@rurik.mysql.com
5ade9e75dc Merge rurik.mysql.com:/home/igor/mysql-4.1-opt
into  rurik.mysql.com:/home/igor/mysql-5.0-opt
2006-06-02 17:06:10 -07:00
igor@rurik.mysql.com
37e049db01 Fixed bug #18206.
The bug report revealed two problems related to min/max optimization:
1. If the length of a constant key used in a SARGable condition for
for the MIN/MAX fields is greater than the length of the field an 
unwanted warning on key truncation is issued;
2. If MIN/MAX optimization is applied to a partial index, like INDEX(b(4))
than can lead to returning a wrong result set.
2006-06-02 14:14:57 -07:00
gkodinov@mysql.com
b357c232fc Bug#18745: Test case 'func_group' fails if "classic" 5.0 configuration
Moved the InnoDB related test from func_group.test to innodb_mysql.test
2006-05-22 16:10:53 +03:00
evgen@moonbone.local
605f62fce8 Fixed bug #15633: Evaluation of Item_equal for non-const table caused wrong
select result

Item equal objects are employed only at the optimize phase. Usually they are not
supposed to be evaluated.  Yet in some cases we call the method val_int() for
them. Here we have to take care of restricting the predicate such an object
represents f1=f2= ...=fn to the projection of known fields fi1=...=fik.

Added a check for field's table being const in Item_equal::val_int().
If the field's table is not const val_int() just skips that field when
evaluating Item_equal.
2006-01-11 22:49:43 +03:00
ramil@mysql.com
ca345dede4 Fix for bug #10966: Variance functions return wrong data type. 2005-11-22 18:29:46 +04:00
msvensson@neptunus.(none)
02c7645cc1 Merge neptunus.(none):/home/msvensson/mysql/mysql-4.1
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0
2005-09-23 09:18:56 +02:00
timour@mysql.com
633d118d01 Fix for BUG#12882 - min/max inconsistent on empty table.
The problem was in that the MIN/MAX optimization in opt_sum_query was
replacing MIN/MAX functions with their constant argument without
taking into account that a query has no result rows.
2005-09-21 09:49:19 +03:00
monty@mysql.com
ef1de7da1d After merge fixes 2005-07-28 21:39:24 +03:00
holyfoot@hf-ibm.(none)
8f3647005c Tests and results fixed with last precision/decimal related modifications 2005-05-06 01:01:39 +05:00
bell@sanja.is.com.ua
05d4ed14e4 merge 4.1->5.0 2005-03-31 10:39:48 +03:00
bell@sanja.is.com.ua
4554b1f263 fixed union types merging and table related metadata (BUG#8824) 2005-03-23 08:36:48 +02:00
igor@rurik.mysql.com
df12e29955 func_group.test, func_group.result:
Added a test case for bug #9210.
sql_select.cc:
  Fixed bug #9210.
  The function calc_group_buffer did not cover the case
  when the GROUP BY expression was decimal.
  Slightly optimized the other code.
2005-03-19 23:12:50 -08:00
konstantin@mysql.com
6a2ef5577c WL#926 "AVG(DISTINCT) and other distincts", part 2 (out of 3): clean up
Item_sum_count_distinct, and
deploy Unique for use with COUNT(DISTINCT) if there is no blob
column in the list of DISTINCT arguments.
2005-03-15 03:46:19 +03:00
hf@deer.(none)
fbbb58c6ae Fix for bug #8935 CAST(time AS DECIMAL) crashes 2005-03-07 20:53:51 +04:00
hf@deer.(none)
e5a2d03743 Merging 2005-03-07 17:45:39 +04:00
hf@deer.(none)
cef95249bd Fix for bug #8465 (MIN, MAX return incorrect result) 2005-03-07 16:38:05 +04:00
hf@deer.(none)
b8e5df4b7d Fix for bug #8464 (AVG returns incorrect result)
Actually problem was not in AVG function, but in SUM before the AVG in the
query.
2005-03-07 16:08:06 +04:00
bar@deer.(none)
42e5de1bee func_group.test, func_str.result, func_group.result:
after merge fixes
2005-03-05 20:44:22 +04:00
bar@mysql.com
d50d213162 Merge 2005-03-05 18:20:35 +04:00
igor@linux.local
6d7862aeaf logging_ok:
Logging to logging@openlogging.org accepted
func_group.result, func_group.test:
  Added a test case for bug #8893.
opt_sum.cc:
  A misplaced initialization for the returned parameter
  prefix_len in the function find_key_for_maxmin caused
  usage of a wrong key prefix by the min/max optimization
  in cases when the matching index was not the first index
  that contained the min/max field.
2005-03-04 20:24:13 -08:00
jani@ua141d10.elisa.omakaista.fi
111e1cb29d Fix for Bug#5615 and merge from 4.1 2005-03-01 22:19:19 +02:00
jani@ua141d10.elisa.omakaista.fi
62b9fc5da6 Merge 2005-03-01 14:50:59 +02:00
ramil@mysql.com
883ff0cc81 merging 2005-02-28 18:11:18 +04:00
svoj@mysql.com
800aaae1fb BUG#3190 fix (request for STDDEV_SAMP, VAR_SAMP).
This bug is also known as WL#1639.
2005-02-25 22:19:04 +04:00
hf@deer.(none)
803ed1a116 Tests modified to coved decimal-related code 2005-02-21 19:20:05 +04:00
monty@mysql.com
218e00ac68 Fixed BUILD script to use --with-berkeley-db instead of --with-bdb
Lots of small fixes to multi-precision-math path
Give Note for '123.4e'
Added helper functions type 'val_string_from_real()
Don't give warnings for end space for string2decimal()
Changed storage of values for SP so that we can detect length of argument without strlen()
Changed interface for str2dec() so that we must supple the pointer to the last character in the buffer
2005-02-19 18:58:27 +02:00