Commit graph

390 commits

Author SHA1 Message Date
lars/lthalmann@dl145j.mysql.com
6f6492b715 Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.0-rpl
into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.0-merge
2007-07-02 13:22:23 +02:00
gkodinov/kgeorge@magare.gmz
38172240e3 Bug#27333: subquery grouped for aggregate of outer
query / no aggregate of subquery
 The optimizer counts the aggregate functions that 
 appear as top level expressions (in all_fields) in 
 the current subquery. Later it makes a list of these
 that it uses to actually execute the aggregates in
 end_send_group().
 That count is used in several places as a flag whether
 there are aggregates functions.
 While collecting the above info it must not consider
 aggregates that are not aggregated in the current 
 context. It must treat them as normal expressions 
 instead. Not doing that leads to incorrect data about
 the query, e.g. running a query that actually has no
 aggregate functions as if it has some (and hence is
 expected to return only one row).
 Fixed by ignoring the aggregates that are not aggregated
 in the current context. 
 One other smaller omission discovered and fixed in the 
 process : the place of aggregation was not calculated for
 user defined functions. Fixed by calling 
 Item_sum::init_sum_func_check() and 
 Item_sum::check_sum_func() as it's done for the rest of 
 the aggregate functions.
2007-06-29 10:39:17 +03:00
bar@mysql.com/bar.myoffice.izhnet.ru
aa0f7eec11 Bug#28925 GROUP_CONCAT inserts wrong separators for a ucs2 column
Problem: separator was not converted to the result character set,
so the result was a mixture of two different character sets,
which was especially bad for UCS2.
Fix: convert separator to the result character set.
2007-06-22 17:18:40 +05:00
mhansson@dl145s.mysql.com
d6cf093408 Merge dl145s.mysql.com:/users/mhansson/mysql/push/bug23856/my50-bug23856
into  dl145s.mysql.com:/users/mhansson/mysql/push/bug23856/mysql-5.0o-pushee
2007-05-22 14:48:49 +02:00
mhansson@dl145s.mysql.com
6530f6806a bug#23856 2007-05-21 10:27:33 +02:00
mhansson/martin@linux-st28.site
b1375104b3 bug#28273: GROUP_CONCAT and ORDER BY: No warning when result gets truncated.
When using GROUP_CONCAT with ORDER BY, a tree is used for the sorting, as 
opposed to normal nested loops join used when there is no ORDER BY. 

The tree traversal that generates the result counts the lines that have been 
cut down. (as they get cut down to the field's max_size)
But the check of that count was before the tree traversal, so no 
warning was generated if the output is truncated.

Fixed by moving the check to after the tree traversal.
2007-05-11 16:05:20 +03:00
gkodinov/kgeorge@magare.gmz
f4ec0f1cbe Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/autopush/B27363-5.0-opt
2007-04-26 11:16:01 +03:00
gkodinov/kgeorge@magare.gmz
bfa29e175e Bug #27363:
Validity checks for nested set functions
were not taking into account that the enclosed
set function may be on a nest level that is
lower than the nest level of the enclosing set
function.
Fixed by :
 - propagating max_sum_func_level
up the enclosing set functions chain.
 - updating the max_sum_func_level of the 
   enclosing set function when the enclosed set
   function is aggregated above or on the same
   nest level of as the level of the enclosing 
   set function.
 - updating the max_arg_level of the enclosing
   set function on a reference that refers to
   an item above or on the same nest level
   as the level of the enclosing set function.
 - Treating both Item_field and Item_ref as possibly
   referencing items from outer nest levels.
2007-04-26 11:12:17 +03:00
msvensson@pilot.blaudden
bb9a601829 Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
2007-04-02 10:50:39 +02:00
gkodinov/kgeorge@magare.gmz
fca2a0c4ac Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/autopush/B26815-5.0-opt
2007-03-29 19:20:33 +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
igor@olga.mysql.com
adc07255ee Fixed bug #27348.
If a set function with a outer reference s(outer_ref) cannot be aggregated 
the outer query against which the reference has been resolved then MySQL
interpretes s(outer_ref) in the same way as it would interpret s(const).
Hovever the standard requires throwing an error in this situation.
Added some code to support this requirement in ansi mode.
Corrected another minor bug in Item_sum::check_sum_func.
2007-03-27 09:48:10 -07:00
gkodinov/kgeorge@magare.gmz
4f2ec8f3de Bug #26815:
When creating a temporary table the concise column type
 of a string expression is decided based on its length:
 - if its length is under 512 it is stored as either 
   varchar or char.
 - otherwise it is stored as a BLOB.
 
 There is a flag (convert_blob_length) to create_tmp_field 
 that, when >0 allows to force creation of a varchar if the
 max blob length is under convert_blob_length.
 However it must be verified that convert_blob_length 
 (settable through a SQL option in some cases) is 
 under the maximum that can be stored in a varchar column.
 While performing that check for expressions in 
 create_tmp_field_from_item the max length of the blob was
 used instead. This causes blob columns to be created in the
 heap temp table used by GROUP_CONCAT (where blobs must not
 be created in the temp table because of the constant 
 convert_blob_length that is passed to create_tmp_field() ).
 And since these blob columns are not expected in that place
 we get wrong results.
 Fixed by checking that the value of the flag variable is 
 in the limits that fit into VARCHAR instead of the max length
 of the blob column.
2007-03-27 19:28:04 +03:00
igor@olga.mysql.com
18ea806864 This is a fix for the memory corruption occurred in one of test cases
from func_group.test after the patch for bug #27229 had been applied.
The memory corruption happened because in some rare cases the function
count_field_types underestimated the number of elements in
in the array param->items_to_copy.
2007-03-25 23:44:06 -07:00
igor@olga.mysql.com
92d1d74037 Merge olga.mysql.com:/home/igor/mysql-5.0-opt
into  olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug27229
2007-03-22 14:51:20 -07:00
igor@olga.mysql.com
8f9178e857 Fixed bug #27229: crash when a set function aggregated in outer
context was used as an argument of GROUP_CONCAT.
Ensured correct setting of the depended_from field in references
generated for set functions aggregated in outer selects.
A wrong value of this field resulted in wrong maps returned by 
used_tables() for these references.
Made sure that a temporary table field is added for any set function
aggregated in outer context when creation of a temporary table is 
needed to execute the inner subquery.
2007-03-22 14:48:03 -07:00
mhansson/martin@linux-st28.site
749976ee5e Merge mhansson@bk-internal:/home/bk/mysql-5.0-opt
into  linux-st28.site:/home/martin/mysql/src/5.0o-bug24791
2007-03-22 10:58:16 +01:00
mhansson/martin@linux-st28.site
50077b6db9 Bug #24791: Union with AVG-groups generates wrong results
The problem in this bug is when we create temporary tables. When
temporary tables are created for unions, there is some 
inferrence being carried out regarding the type of the column.
Whenever this column type is inferred to be REAL (i.e. FLOAT or
DOUBLE), MySQL will always try to maintain exact precision, and
if that is not possible (there are hardware limits, since FLOAT
and DOUBLE are stored as approximate values) will switch to
using approximate values. The problem here is that at this point
the information about number of significant digits is not 
available. Furthermore, the number of significant digits should
be increased for the AVG function, however, this was not properly 
handled. There are 4 parts to the problem:

#1: DOUBLE and FLOAT fields don't display their proper display 
lengths in max_display_length(). This is hard-coded as 53 for 
DOUBLE and 24 for FLOAT. Now changed to instead return the 
field_length.

#2: Type holders for temporary tables do not preserve the 
max_length of the Item's from which they are created, and is 
instead reverted to the 53 and 24 from above. This causes 
*all* fields to get non-fixed significant digits.

#3: AVG function does not update max_length (display length)
when updating number of decimals.

#4: The function that switches to non-fixed number of 
significant digits should use DBL_DIG + 2 or FLT_DIG + 2 as 
cut-off values (Since fixed precision does not use the 'e' 
notation)

Of these points, #1 is the controversial one, but this 
change is preferred and has been cleared with Monty. The 
function causes quite a few unit tests to blow up and they had
to b changed, but each one is annotated and motivated. We 
frequently see the magical 53 and 24 give way to more relevant
numbers.
2007-03-22 10:56:47 +01:00
igor@olga.mysql.com
facd57e5fd Merge olga.mysql.com:/home/igor/mysql-5.0-opt
into  olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug27257
2007-03-20 12:20:18 -07:00
igor@olga.mysql.com
19da4d3972 Fixed bug #27257: queries containing subqueries with COUNT(*)
aggregated in outer context returned wrong results.
This happened only if the subquery did not contain any references
to outer fields.
As there were no references to outer fields the subquery erroneously
was taken for non-correlated one.
Now any set function aggregated in outer context makes the subquery
correlated.
2007-03-20 11:51:09 -07:00
gkodinov/kgeorge@magare.gmz
354c364ad4 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/autopush/B24484-5.0
2007-03-20 19:49:38 +02:00
gkodinov/kgeorge@macbook.local
28962a76a3 Bug #24484:
To correctly decide which predicates can be evaluated with a given table
the optimizer must know the exact set of tables that a predicate depends 
on. If that mask is too wide (refer to non-existing tables) the optimizer
can erroneously skip a predicate.
One such case of wrong table usage mask were the aggregate functions.
The have a all-1 mask (meaning depend on all tables, including non-existent
ones).
Fixed by making a real used_tables mask for the aggregates. The mask is
constructed in the following way :
1. OR the table dependency masks of all the arguments of the aggregate.
2. If all the arguments of the function are from the local name resolution 
  context and it is evaluated in the same name resolution
  context where it is referenced all the tables from that name resolution 
  context are OR-ed to the dependency mask. This is to denote that an
  aggregate function depends on the number of rows it processes.
3. Handle correctly the case of an aggregate function optimization (such that
  the aggregate function can be pre-calculated and made a constant).

Made sure that an aggregate function is never a constant (unless subject of a 
specific optimization and pre-calculation).  

One other flaw was revealed and fixed in the process : references were 
not calling the recalculation method for used_tables of their targets.
2007-03-20 19:46:02 +02:00
monty@mysql.com/narttu.mysql.fi
26aa385bc5 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/my/mysql-5.0
2007-02-21 14:07:08 +02:00
ramil/ram@mysql.com/ramil.myoffice.izhnet.ru
0bd1c03e7e after-merge fix. 2007-01-31 11:14:32 +04:00
monty@mysql.com/narttu.mysql.fi
a04157fbb3 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/my/mysql-5.0
2007-01-22 14:04:40 +02:00
tsmith/tim@siva.hindu.god
682596d7ce Merge siva.hindu.god:/usr/home/tim/m/bk/g50
into  siva.hindu.god:/usr/home/tim/m/bk/50
2006-12-26 22:28:28 -07:00
kent@mysql.com/kent-amd64.(none)
226a5c833f Many files:
Changed header to GPL version 2 only
2006-12-23 20:17:15 +01: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
monty@mysql.com/narttu.mysql.fi
a6481aa4c7 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/my/mysql-5.0
2006-12-15 01:01:52 +02:00
monty@mysql.com/narttu.mysql.fi
88dd873de0 Fixed compiler warnings detected by option -Wshadow and -Wunused:
- Removed not used variables and functions
- Added #ifdef around code that is not used
- Renamed variables and functions to avoid conflicts
- Removed some not used arguments

Fixed some class/struct warnings in ndb
Added define IS_LONGDATA() to simplify code in libmysql.c

I did run gcov on the changes and added 'purecov' comments on almost all lines that was not just variable name changes
2006-12-15 00:51:37 +02:00
df@kahlann.erinye.com
da7820c37d Merge dfischer@bk-internal.mysql.com:/home/bk/mysql-5.0-marvel
into  kahlann.erinye.com:/home/df/mysql/build/mysql-5.0-build
2006-12-01 13:02:54 +01:00
gkodinov@dl145s.mysql.com
03431eb78a Merge dl145s.mysql.com:/data0/bk/team_tree_merge/mysql-5.0
into  dl145s.mysql.com:/data0/bk/team_tree_merge/MERGE/mysql-5.0-opt
2006-11-30 12:22:32 +01:00
monty@mysql.com/narttu.mysql.fi
8aec636ba8 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/my/mysql-5.0
2006-11-29 17:25:23 +02:00
kostja@bodhi.local
5fea0724bc Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  bodhi.local:/opt/local/work/mysql-5.0-runtime
2006-11-29 02:44:12 +03:00
gkodinov/kgeorge@rakia.gmz
fb41ec6f22 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rakia.gmz:/home/kgeorge/mysql/autopush/B11927-5.0-opt
2006-11-28 15:47:53 +02:00
gkodinov/kgeorge@macbook.gmz
42cd956752 BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0)
When implicitly converting string fields to numbers the 
 string-to-number conversion error was not sent to the client.
 Added code to send the conversion error as warning.
 
 We also need to prevent generation of warnings from the places
 where val_xxx() methods are called for the sole purpose of updating
 the Item::null_value flag.
 To achieve that a special function is added (and called) : 
 update_null_value(). This function will set the no_errors flag and
 will call val_xxx(). The warning generation in Field_string::val_xxx()
 will use the flag when generating the conversion warnings.
2006-11-28 15:44:11 +02:00
monty@mysql.com/nosik.monty.fi
9c3a2a0d8e Increased heap max length to > 4G for 64 bit machines
Initialize key_part->type on open. This caused key_copy() to fail for bit_fields. (key_copy is used in HANDLER and opt_range)
2006-11-28 00:47:21 +02:00
kroki/tomash@moonlight.intranet
003cd7b78f Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-4.1-bug21635
into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-bug21635
2006-11-22 14:05:26 +03:00
kroki/tomash@moonlight.intranet
ec7a6d15fc BUG#21635: MYSQL_FIELD struct's member strings seem to misbehave for
expression cols.

The problem was that MYSQL_FIELD::org_name was set for MIN() and MAX()
functions (COUNT() is also mentioned in the bug report but was already
fixed).

After this patch for expressions MYSQL_FIELD::name is set to either
expression itself or its alias, and other data origin fields of
MYSQL_FILED (db, org_table, table, org_name) are empty strings.
2006-11-22 13:58:00 +03:00
holyfoot/hf@mysql.com/deer.(none)
e95e23b0f3 Merge bk@192.168.21.1:mysql-5.0-opt
into  mysql.com:/home/hf/work/mysql-5.0-0mrg
2006-11-17 10:30:16 +04:00
bar@mysql.com/bar.intranet.mysql.r18.ru
9870d87f25 after merge fix for bug 23451. 2006-11-08 22:08:50 +04:00
bar@mysql.com/bar.intranet.mysql.r18.ru
ac3ce653b4 Merge mysql.com:/usr/home/bar/mysql-4.1.b23451v2
into  mysql.com:/usr/home/bar/mysql-5.0.b23451
2006-11-08 17:03:37 +04:00
bar@mysql.com/bar.intranet.mysql.r18.ru
599b731660 Bug#23451 GROUP_CONCAT truncates a multibyte utf8 character
Problem: GROUP_CONCAT on a multi-byte column can truncate
  in the middle of a multibyte character when applying
  group_concat_max_len limit. It produces an invalid
  multi-byte character in the result string.
  
The second, easier version - reusing old "warning_for_row" flag,
instead of introducing of "result_is_full" - which was
added in the previous commit.
2006-11-07 12:45:48 +04:00
kostja@bodhi.local
b471ea50f7 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  bodhi.local:/opt/local/work/mysql-5.0-runtime-merge
2006-11-02 01:21:37 +03:00
kostja@bodhi.local
6a28c436f7 Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into  bodhi.local:/opt/local/work/mysql-4.1-runtime
2006-11-02 01:08:39 +03: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
kroki/tomash@moonlight.intranet
9fd2c86103 Fix for valgrind warning introduced by the fix for bug#21354:
(COUNT(*) = 1) not working in SELECT inside prepared statement.
Note: the warning was introduced in 5.0 and 5.1, 4.1 is OK with the
original fix.

The problem was that in 5.0 and 5.1 clear() for group functions may
access hybrid_type member, and this member is initialized in
fix_fields().

So we should not call clear() from item cleanup() methods, as cleanup()
may be called for unfixed items.
2006-10-18 15:20:34 +04:00
stewart@willster.(none)
c1903d967a Merge willster.(none):/home/stewart/Documents/MySQL/4.1/bug19914-mk2
into  willster.(none):/home/stewart/Documents/MySQL/5.0/bug19914-mk2-merge
2006-10-16 17:39:38 +10:00