Commit graph

1847 commits

Author SHA1 Message Date
evgen@moonbone.local
35e5925673 sql_select.cc:
Postfix for bug#22331.
2007-03-08 19:38:21 +03:00
kroki/tomash@moonlight.home
1792908381 Merge moonlight.home:/home/tomash/src/mysql_ab/mysql-5.0
into  moonlight.home:/home/tomash/src/mysql_ab/mysql-5.0-bug20492
2007-03-08 15:16:21 +03:00
evgen@moonbone.local
999c1cdcc1 sql_select.cc:
Postfix for bug#22331 for windows platform.
explain.test, explain.result:
  Cleanup after bugfix#22331.
2007-03-08 00:27:42 +03:00
evgen@moonbone.local
8936e53fca Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  moonbone.local:/mnt/gentoo64/work/25373-bug-5.0-opt-mysql
2007-03-07 22:23:08 +03:00
evgen@moonbone.local
c4fc9c5ef9 Merge moonbone.local:/mnt/gentoo64/work/22331-bug-5.0-opt-mysql
into  moonbone.local:/mnt/gentoo64/work/25373-bug-5.0-opt-mysql
2007-03-07 22:22:19 +03:00
evgen@moonbone.local
7afa5f1c5a Bug#22331: Wrong WHERE in EXPLAIN EXTENDED when all expressions were optimized
away.

During optimization stage the WHERE conditions can be changed or even
be removed at all if they know for sure to be true of false. Thus they aren't
showed in the EXPLAIN EXTENDED which prints conditions after optimization.

Now if all elements of an Item_cond were removed this Item_cond is substituted
for an Item_int with the int value of the Item_cond.
If there were conditions that were totally optimized away then values of the
saved cond_value and having_value will be printed instead.
2007-03-07 21:44:58 +03:00
igor@olga.mysql.com
34a643b692 Merge olga.mysql.com:/home/igor/mysql-5.0-opt
into  olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug26560
2007-03-07 07:58:34 -08:00
evgen@moonbone.local
7b77956f58 Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  moonbone.local:/mnt/gentoo64/work/25376-bug-5.0-opt-mysql
2007-03-07 12:10:59 +03:00
evgen@moonbone.local
6552d3064d Bug#25376: Incomplete setup of ORDER BY clause results in a wrong result.
Functions over sum functions wasn't set up correctly for the ORDER BY clause
which leads to a wrong order of the result set.

The split_sum_func() function is called now for each ORDER BY item that
contains a sum function to set it up correctly.
2007-03-06 23:58:10 +03:00
evgen@moonbone.local
f482379296 Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-4.1-opt
into  moonbone.local:/mnt/gentoo64/work/clean-5.0-opt-mysql
2007-03-05 23:33:57 +03:00
igor@olga.mysql.com
08efa4e0ea Fixed bug #26560.
The flag alias_name_used was not set on for the outer references
in subqueries. It resulted in replacement of any outer reference
resolved against an alias for a full field name when the frm 
representation of a view with a subquery was generated. 
If the subquery and the outer query referenced the same table in
their from lists this replacement effectively changed the meaning
of the view and led to wrong results for selects from this view. 

Modified several functions to ensure setting the right value of
the alias_name_used flag for outer references resolved against
aliases.
2007-03-04 19:54:35 -08:00
evgen@sunlight.local
629c12316d Bug#25126: Wrongly resolved field leads to a crash.
When the ORDER BY clause gets fixed it's allowed to search in the current
item_list in order to find aliased fields and expressions. This is ok for a
SELECT but wrong for an UPDATE statement. If the ORDER BY clause will
contain a non-existing field which is mentioned in the UPDATE set list
then the server will crash due to using of non-existing (0x0) field.

When an Item_field is getting fixed it's allowed to search item list for
aliased expressions and fields only for selects.
2007-03-04 00:47:42 +03:00
gluh@mysql.com/eagle.(none)
b3cb846680 removed unused variable 2007-02-27 12:37:17 +04:00
gluh@mysql.com/eagle.(none)
e8635ad3cb Merge mysql.com:/home/gluh/MySQL/Merge/5.0
into  mysql.com:/home/gluh/MySQL/Merge/5.0-opt
2007-02-26 16:57:45 +04:00
monty@mysql.com/narttu.mysql.fi
e5cc397f33 Fixed compiler warnings (for linux and win32 and win64)
Fixed a couple of usage of not initialized warnings (unlikely cases)
2007-02-22 16:59:57 +02:00
evgen@moonbone.local
76461a4442 Merge moonbone.local:/mnt/gentoo64/work/bk-trees/mysql-5.0-opt
into  moonbone.local:/mnt/gentoo64/work/23800-bug1-5.0-opt-mysql
2007-02-21 23:18:17 +03:00
evgen@moonbone.local
9a233742b8 Bug#23800: Outer fields in correlated subqueries is used in a temporary table
created for sorting.

Any outer reference in a subquery was represented by an Item_field object.
If the outer select employs a temporary table all such fields should be
replaced with fields from that temporary table in order to point to the 
actual data. This replacement wasn't done and that resulted in a wrong
subquery evaluation and a wrong result of the whole query.

Now any outer field is represented by two objects - Item_field placed in the
outer select and Item_outer_ref in the subquery. Item_field object is
processed as a normal field and the reference to it is saved in the
ref_pointer_array. Thus the Item_outer_ref is always references the correct
field. The original field is substituted for a reference in the
Item_field::fix_outer_field() function.

New function called fix_inner_refs() is added to fix fields referenced from
inner selects and to fix references (Item_ref objects) to these fields.

The new Item_outer_ref class is a descendant of the Item_direct_ref class.
It additionally stores a reference to the original field and designed to
behave more like a field.
2007-02-21 23:00:32 +03: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
igor@olga.mysql.com
f5888a8d10 Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  olga.mysql.com:/home/igor/mysql-5.0-opt
2007-02-16 09:39:08 -08:00
evgen@moonbone.local
31d63b7971 Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  moonbone.local:/mnt/gentoo64/work/16630-bug-5.0-opt-mysql
2007-02-16 19:44:54 +03:00
evgen@moonbone.local
7916d9e965 Bug#16630: The update fields of the INSERT .. SELECT .. ON DUPLICATE KEY
UPDATE contains wrong data if the SELECT employs a temporary table.

If the UPDATE values of the INSERT .. SELECT .. ON DUPLICATE KEY UPDATE
statement contains fields from the SELECT part and the select employs a
temporary table then those fields will contain wrong values because they
aren't corrected to get data from the temporary table.

The solution is to add these fields to the selects all_fields list,
to store pointers to those fields in the selects ref_pointer_array and
to access them via Item_ref objects.

The substitution for Item_ref objects is done in the new function called 
Item_field::update_value_transformer(). It is called through the
item->transform() mechanism at the end of the select_insert::prepare()
function.
2007-02-16 19:39:28 +03:00
igor@olga.mysql.com
a2d4a042d0 Fixed bug #25971: indexes on text columns were ignored when ref accesses
were evaluated.
According to the new rules for string comparison partial indexes on text
columns can be used in the same cases when partial indexes on varchar
columns can be used.
2007-02-14 22:06:41 -08:00
ibabaev@bk-internal.mysql.com
266300142e Merge bk-internal.mysql.com:/data0/bk/mysql-5.0
into  bk-internal.mysql.com:/data0/bk/mysql-5.0-opt
2007-02-13 23:35:06 +01:00
cmiller@zippy.cornsilk.net
11e8f48734 Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-4.1-maint
2007-02-13 10:54:04 -05:00
igor@olga.mysql.com
0461228a70 Merge olga.mysql.com:/home/igor/mysql-5.0-opt
into  olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug26209
2007-02-12 23:10:33 -08:00
gluh@mysql.com/eagle.(none)
47e537b47c Bug#24630 Subselect query crashes mysqld
The crash happens because second filling of the same I_S table happens in
case of subselect with order by. table->sort.io_cache previously allocated
in create_sort_index() is deleted during second filling
(function get_schema_tables_result). There are two places where
I_S table can be filled: JOIN::exec and create_sort_index().
To fix the bug we should check if the table was already filled
in one of these places and skip processing of the table in second.
2007-02-12 16:06:14 +04:00
igor@olga.mysql.com
4b1a1d9eb7 Fixed bug #26209.
The function make_unireg_sortorder ignored the fact that any
view field is represented by a 'ref' object.
This could lead to wrong results for the queries containing
both GROUP BY and ORDER BY clauses.
2007-02-11 19:36:46 -08:00
msvensson@neptunus.(none)
ede3afe470 Merge neptunus.(none):/home/msvensson/mysql/mysql-5.0
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0-maint
2007-02-06 14:45:08 +01:00
gkodinov/kgeorge@rakia.gmz
0d40608fff Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rakia.gmz:/home/kgeorge/mysql/autopush/B25551-5.0-opt
2007-02-01 10:50:41 +02:00
cmiller@zippy.cornsilk.net
ad66e7a0dd Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-maint
2007-01-31 16:23:05 -05:00
gkodinov/kgeorge@macbook.gmz
2ba683f2ee Bug #25551: inconsistent behaviour in grouping NULL, depending on index type
The optimizer takes away columns from GROUP BY/DISTINCT if they constitute
 all the parts of an unique index.
 However if some of the columns can contain NULLs this cannot be done 
(because an UNIQUE index can have multiple rows with NULL values).
 Fixed by not using UNIQUE indexes with nullable columns to remove
 grouping columns from GROUP BY/DISTINCT.
2007-01-31 10:18:26 +02:00
ramil/ram@mysql.com/ramil.myoffice.izhnet.ru
f0f83a36bc Merge mysql.com:/home/ram/work/b19690/b19690.4.1
into  mysql.com:/home/ram/work/b19690/b19690.5.0
2007-01-31 10:07:56 +04:00
ramil/ram@mysql.com/ramil.myoffice.izhnet.ru
eb415e4920 fix for bug #19690: ORDER BY eliminates rows from the result
Depending on the queries we use different data processing methods
and can lose some data in case of double (and decimal in 4.1) fields.

The fix consists of two parts:
1. double comparison changed, now double a is equal to double b 
if (a-b) is less than 5*0.1^(1 + max(a->decimals, b->decimals)). 
For example, if a->decimals==1, b->decimals==2, a==b if (a-b)<0.005
2. if we use a temporary table, store double values there as is 
to avoid any data conversion (rounding).
2007-01-31 09:51:05 +04:00
igor@olga.mysql.com
3eff8907e2 Merge olga.mysql.com:/home/igor/dev-opt/mysql-4.1-opt-bug24987
into  olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug24987
2007-01-30 13:14:52 -08:00
igor@olga.mysql.com
60ac1f1b78 Fixed bug #24987.
Made the function opt_sum_query to return HA_ERR_KEY_NOT_FOUND when
no matches were found (instead of -1 it returned prior this patch).
This changes allow us to avoid possible conflicts with return values
from user-defined handler methods which also may return -1. 
No particular test cases are provided with this fix.
2007-01-30 13:06:36 -08:00
igor@olga.mysql.com
19f4fb2b4f Merge olga.mysql.com:/home/igor/dev-opt/mysql-4.1-opt-bug24653
into  olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug24653
2007-01-25 21:01:28 -08:00
igor@olga.mysql.com
36df33d80a Fixed bug #24653.
The bug report has demonstrated the following two problems.
1. If an ORDER/GROUP BY list includes a constant expression being 
optimized away and, at the same time, containing single-row
subselects that return more that one row, no error is reported.
Strictly speaking the standard allows to ignore error in this case.
Yet, now a corresponding fatal error is reported in this case.
2. If a query requires sorting by expressions containing single-row
subselects that, however, return more than one row, then the execution
of the query may cause a server crash. 
To fix this some code has been added that blocks execution of a subselect
item in case of a fatal error in the method Item_subselect::exec.
2007-01-25 18:44:35 -08:00
sergefp@mysql.com
39e6de4359 BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...):
Fixed typo problem that surfaced after the merge
2007-01-25 02:27:28 +03:00
sergefp@mysql.com
e2f0f4dbd3 Merge spetrunia@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  mysql.com:/home/psergey/mysql-5.0-bug8804-r12
2007-01-24 19:13:28 +03:00
gluh@mysql.com/eagle.(none)
e34b0056f2 Merge mysql.com:/home/gluh/MySQL/Merge/5.0
into  mysql.com:/home/gluh/MySQL/Merge/5.0-opt
2007-01-23 14:08:58 +04:00
evgen@moonbone.local
884713fb08 sql_select.cc:
Code cleanup after fix for bug#23417.
2007-01-22 23:04:14 +03: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
evgen@moonbone.local
d7d5db64ec Bug#25172: Not checked buffer size leads to a server crash.
After fix for bug#21798 JOIN stores the pointer to the buffer for sorting
fields. It is used while sorting for grouping and for ordering. If ORDER BY
clause has more elements then the GROUP BY clause then a memory overrun occurs.

Now the length of the ORDER BY list is always passed to the 
make_unireg_sortorder() function and it allocates buffer big enough to be
used for bigger list.
2007-01-19 18:34:09 +03:00
evgen@moonbone.local
53a4949d3b sql_select.cc:
Fix for crashes on 64bit platforms after fixing bug#23417.
2007-01-15 22:40:39 +03:00
dlenev@mockturtle.local
af838b4c55 Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  mockturtle.local:/home/dlenev/src/mysql-5.0-bg20390-2
2007-01-15 13:48:07 +03:00
dlenev@mockturtle.local
ab98cbc88a Fix for bug#20390 "SELECT FOR UPDATE does not release locks
of untouched rows in full table scans".

SELECT ... FOR UPDATE/LOCK IN SHARE MODE statements as well as
UPDATE/DELETE statements which were executed using full table
scan were not releasing locks on rows which didn't satisfy
WHERE condition.
This bug surfaced in 5.0 and affected NDB tables. (InnoDB tables
intentionally don't support such unlocking in default mode).

This problem occured because code implementing join didn't call
handler::unlock_row() for rows which didn't satisfy part of condition
attached to this particular table/level of nested loop. So we solve
the problem adding this call.
Note that we already had this call in place in 4.1 but it was lost
(actually not quite correctly placed) when we have introduced nested 
joins.

Also note that additional QA should be requested once this patch is
pushed as interaction between handler::unlock_row() and many recent
MySQL features such as subqueries, unions, views is not tested enough.
2007-01-15 12:32:38 +03:00
sergefp@mysql.com
c3f46e1f26 BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs:
- Make the code produce correct result: use an array of triggers to turn on/off equalities for each
  compared column. Also turn on/off optimizations based on those equalities.
- Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between
  ref/unique_subquery/index_subquery and ALL access.
- index_subquery engine now has HAVING clause when it is needed, and it is
  displayed in EXPLAIN EXTENDED
- Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930)
// bk trigger note: this commit refers to BUG#24127
2007-01-12 23:22:41 +03:00
evgen@moonbone.local
19ee0a94fe Bug#23417: Too strict checks against GROUP BY in the ONLY_FULL_GROUP_BY mode.
Currently in the ONLY_FULL_GROUP_BY mode no hidden fields are allowed in the
select list. To ensure this each expression in the select list is checked
to be a constant, an aggregate function or to occur in the GROUP BY list.
The last two requirements are wrong and doesn't allow valid expressions like
"MAX(b) - MIN(b)" or "a + 1" in a query with grouping by a.

The correct check implemented by the patch will ensure that:
any field reference in the [sub]expressions of the select list 
  is under an aggregate function or
  is mentioned as member of the group list or
  is an outer reference or
  is part of the select list element that coincide with a grouping element.

The Item_field objects now can contain the position of the select list
expression which they belong to. The position is saved during the
field's Item_field::fix_fields() call.

The non_agg_fields list for non-aggregated fields is added to the SELECT_LEX
class. The SELECT_LEX::cur_pos_in_select_list now contains the position in the
select list of the expression being currently fixed.
2007-01-11 23:18:01 +03:00
igor@olga.mysql.com
ae6bee30fc Merge olga.mysql.com:/home/igor/mysql-5.0-opt
into  olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug24345
2007-01-09 00:17:48 -08:00
gkodinov/kgeorge@macbook.gmz
a63df24a68 Bug #15881: cast problems
The optimizer removes expressions from GROUP BY/DISTINCT
  if they happen to participate in a <expression> = <const>
  predicates of the WHERE clause (the idea being that if
  it's always equal to a constant it can't have multiple 
  values).
  However for predicates where the expression and the 
  constant item are of different result type this is not
  valid (e.g. a string column compared to 0).
  Fixed by additional check of the result types of the 
  expression and the constant and if they differ the 
  expression don't get removed from the group by list.
2007-01-05 14:02:50 +02:00
igor@olga.mysql.com
08369f4bce Fixed bug #24345.
This bug appeared after the patch for bug 21390 that had added some code
to handle outer joins with no matches after substitution of a const
table in an efficient way. That code as it is cannot be applied to the case
of nested outer join operations. Being applied to the queries with
nested outer joins the code can cause crashes or wrong result sets.
The fix blocks row substitution for const inner tables of an outer join
if the inner operand is not a single table.
2007-01-03 12:16:03 -08:00
kent@mysql.com/kent-amd64.(none)
6523aca729 my_strtoll10-x86.s:
Corrected spelling in copyright text
Makefile.am:
  Don't update the files from BitKeeper
Many files:
  Removed "MySQL Finland AB & TCX DataKonsult AB" from copyright header
  Adjusted year(s) in copyright header 
Many files:
  Added GPL copyright text
Removed files:
  Docs/Support/colspec-fix.pl
  Docs/Support/docbook-fixup.pl
  Docs/Support/docbook-prefix.pl
  Docs/Support/docbook-split
  Docs/Support/make-docbook
  Docs/Support/make-makefile
  Docs/Support/test-make-manual
  Docs/Support/test-make-manual-de
  Docs/Support/xwf
2006-12-31 01:02:27 +01: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
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
monty@mysql.com/narttu.mysql.fi
3d40956039 Fixed portability issue in my_thr_init.c (was added in my last push)
Fixed compiler warnings (detected by VC++):
- Removed not used variables
- Added casts
- Fixed wrong assignments to bool
- Fixed wrong calls with bool arguments
- Added missing argument to store(longlong), which caused wrong store method to be called.
2006-11-30 18:25:05 +02: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
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
gkodinov@dl145s.mysql.com
e74c9add47 Merge bk-internal:/home/bk/mysql-5.0
into  dl145s.mysql.com:/data0/bk/team_tree_merge/MERGE/mysql-5.0-opt
2006-11-27 16:25:52 +01:00
gluh@mysql.com/gluh.(none)
ff38409128 Bug#22413 EXPLAIN SELECT FROM view with ORDER BY yield server crash
disable filling of I_S tables for EXPLAIN
2006-11-21 13:45:01 +04:00
monty@mysql.com/nosik.monty.fi
306b871d52 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/my/mysql-5.0
2006-11-20 22:46:52 +02:00
monty@mysql.com/nosik.monty.fi
e825879800 Remove compiler warnings
(Mostly in DBUG_PRINT() and unused arguments)
Fixed bug in query cache when used with traceing (--with-debug)
Fixed memory leak in mysqldump
Removed warnings from mysqltest scripts (replaced -- with #)
2006-11-20 22:42:06 +02: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
gkodinov/kgeorge@rakia.gmz
0be7e70399 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rakia.gmz:/home/kgeorge/mysql/autopush/B20191-5.0-opt
2006-11-09 18:03:49 +02:00
gkodinov/kgeorge@macbook.gmz
e7ff881c6b Bug #20191: getTableName gives wrong or inconsistent result when using VIEWs
When compiling GROUP BY Item_ref instances are dereferenced in 
setup_copy_fields(), i.e. replaced with the corresponding Item_field 
(if they point to one) or Item_copy_string for the other cases.
Since the Item_ref (in the Item_field case) is no longer used the information
about the aliases stored in it is lost.   
Fixed by preserving the column, table and DB alias on dereferencing Item_ref
2006-11-09 16:55:42 +02:00
bar@mysql.com/bar.intranet.mysql.r18.ru
aa1c8a5826 Bug#21505 Create view - illegal mix of collation for operation 'UNION'
The problem was that any VIEW columns had always implicit derivation.
  Fix: derivation is now copied from the original expression
  given in VIEW definition.
  For example:
  - a VIEW column which comes from a string constant
    in CREATE VIEW definition have now coercible derivation.
  - a VIEW column having COLLATE clause
    in CREATE VIEW definition have now explicit derivation.
2006-11-09 14:41:34 +04:00
sergefp@mysql.com
26c30f2f7d BUG#24056: Crash in subquery:
Don't assume that condition that was pushed down into subquery has 
produced exactly one KEY_FIELD element - it could produce several or
none at all, handle all of those cases.
2006-11-08 02:26:50 +03:00
cmiller@zippy.cornsilk.net
af5acac047 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-maint
2006-11-02 17:39:52 -05:00
cmiller@zippy.cornsilk.net
c34f3219b3 Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-4.1-maint
2006-11-02 17:27:42 -05:00
igor@rurik.mysql.com
79abdb38f8 Merge rurik.mysql.com:/home/igor/mysql-5.0-opt
into  rurik.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug21727
2006-11-01 14:50:14 -08: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
igor@rurik.mysql.com
2a7acba7e1 Fixed bug #21727.
This is a performance issue for queries with subqueries evaluation
of which requires filesort.
Allocation of memory for the sort buffer at each evaluation of a
subquery may take a significant amount of time if the buffer is rather big.
With the fix we allocate the buffer at the first evaluation of the
subquery and reuse it at each subsequent evaluation.
2006-10-31 17:31:56 -08:00
sergefp@mysql.com
54a713aac5 BUG#8804: wrong results for NULL IN (SELECT ...)
Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down 
conditions and their "consequences": 
 = Do full table scans instead of unique_[index_subquery] lookups.
 = Change appropriate "ref_or_null" accesses to full table scans in
   subquery's joins.
Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated 
wrt any upper select.
2006-10-31 20:51:09 +03:00
jonas@perch.ndb.mysql.com
b67e5b1131 Merge perch.ndb.mysql.com:/home/jonas/src/mysql-5.0
into  perch.ndb.mysql.com:/home/jonas/src/mysql-5.0-ndb
2006-10-27 23:59:04 +02:00
jonas@perch.ndb.mysql.com
dc2ca8ca10 Merge perch.ndb.mysql.com:/home/jonas/src/mysql-4.1
into  perch.ndb.mysql.com:/home/jonas/src/mysql-4.1-ndb
2006-10-27 23:56:51 +02:00
stewart@willster.(none)
a4faddc64f Merge bk-internal.mysql.com:/home/bk/mysql-4.1-ndb
into  willster.(none):/home/stewart/Documents/MySQL/4.1/bug19914-mk2-merge2
2006-10-25 17:24:20 +10:00
tsmith/tim@siva.hindu.god
3af2089b13 Merge siva.hindu.god:/usr/home/tim/m/bk/g50
into  siva.hindu.god:/usr/home/tim/m/bk/50
2006-10-24 14:42:08 -06:00
stewart@willster.(none)
fc776db8e7 Merge willster.(none):/home/stewart/Documents/MySQL/4.1/bug19914-mk2
into  willster.(none):/home/stewart/Documents/MySQL/4.1/bug19914-mk2-merge2
2006-10-23 23:43:48 +10:00
gkodinov@dl145s.mysql.com
a93cc1b70b Merge bk-internal:/home/bk/mysql-5.0
into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt
2006-10-20 11:02:56 +02:00
gkodinov@dl145s.mysql.com
0612a212d1 Merge bk-internal:/home/bk/mysql-4.1
into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-4.1-opt
2006-10-20 10:57:38 +02:00
gkodinov@dl145s.mysql.com
c77fae407b Merge dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-4.1-opt
into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt
2006-10-19 15:04:12 +02:00
gkodinov@dl145s.mysql.com
892495acaf Merge dl145s.mysql.com:/data/bk/team_tree_merge/mysql-5.0
into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt
2006-10-19 14:37:49 +02:00
gkodinov@dl145s.mysql.com
1dacdd4c85 Merge dl145s.mysql.com:/data/bk/team_tree_merge/mysql-4.1
into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-4.1-opt
2006-10-19 14:34:56 +02:00
ramil/ram@mysql.com/myoffice.izhnet.ru
f6ea36c3a5 Merge mysql.com:/usr/home/ram/work/bug20732/my41-bug20732
into  mysql.com:/usr/home/ram/work/bug20732/my50-bug20732
2006-10-19 16:15:30 +05:00
ramil/ram@mysql.com/myoffice.izhnet.ru
0027b6e4b7 Fix for bug #20732: Partial index and long sjis search with '>' fails sometimes
We miss some records sometimes using RANGE method if we have
partial key segments.
Example:
  Create table t1(a char(2), key(a(1)));
  insert into t1 values ('a'), ('xx');
  select a from t1 where a > 'x';
We call index_read() passing 'x' key and HA_READ_AFTER_KEY flag
in the handler::read_range_first() wich is wrong because we have
a partial key segment for the field and might miss records like 'xx'.

Fix: don't use open segments in such a case.
2006-10-19 12:52:37 +05:00
igor@rurik.mysql.com
17eb0b353e Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rurik.mysql.com:/home/igor/mysql-5.0-opt
2006-10-17 12:25:53 -07:00
igor@rurik.mysql.com
c4c9fe63db Merge rurik.mysql.com:/home/igor/mysql-5.0-opt
into  rurik.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug19579
2006-10-17 10:07:29 -07:00
gkodinov/kgeorge@macbook.gmz
8e7f0fe785 rename of the new members introduced in the fix for bug 21798 2006-10-17 19:22:13 +03:00
gkodinov/kgeorge@macbook.gmz
a64ae1844d Merge bk-internal:/home/bk/mysql-5.0-opt
into  macbook.gmz:/Users/kgeorge/mysql/work/B21798-5.0-opt-merge
2006-10-17 16:36:44 +03:00
gkodinov/kgeorge@macbook.gmz
f7b8937661 Bug#21798: memory leak during query execution with subquery in column
list using a function
When executing dependent subqueries they are re-inited and re-exec() for 
each row of the outer context.
The cause for the bug is that during subquery reinitialization/re-execution,
the optimizer reallocates JOIN::join_tab, JOIN::table in make_simple_join()
and the local variable in 'sortorder' in create_sort_index(), which is
allocated by make_unireg_sortorder().
Care must be taken not to allocate anything into the thread's memory pool
while re-initializing query plan structures between subquery re-executions.
All such items mush be cached and reused because the thread's memory pool
is freed at the end of the whole query.
Note that they must be cached and reused even for queries that are not 
otherwise cacheable because otherwise it will grow the thread's memory 
pool every time a cacheable query is re-executed. 
We provide additional members to the JOIN structure to store references 
to the items that need to be cached.
2006-10-17 16:20:26 +03:00
kroki/tomash@moonlight.intranet
656b643276 Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-4.1-runtime
into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-4.1-bug21726
2006-10-17 13:41:29 +04:00
istruewing@chilla.local
647dee0316 Merge bk-internal.mysql.com:/home/bk/mysql-4.1-engines
into  chilla.local:/home/mydev/mysql-4.1-bug12240
2006-10-17 09:33:58 +02:00
igor@rurik.mysql.com
c467be8d6e Fixed bug #19579: at range analysis optimizer did not take into
account predicates that become sargable after reading const tables.
In some cases this resulted in choosing non-optimal execution plans.
Now info of such potentially saragable predicates is saved in
an array and after reading const tables we check whether this
predicates has become saragable.
2006-10-16 14:25:28 -07:00
istruewing@chilla.local
b14e9a7ad5 Merge bk-internal.mysql.com:/home/bk/mysql-5.0-engines
into  chilla.local:/home/mydev/mysql-5.0-bug12240
2006-10-16 17:12:57 +02:00
istruewing@chilla.local
9f4d8208da Merge chilla.local:/home/mydev/mysql-4.1-bug12240
into  chilla.local:/home/mydev/mysql-5.0-bug12240
2006-10-16 13:15:15 +02: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
istruewing@chilla.local
296d64dbc3 Bug#12240 - Rows Examined in Slow Log showing incorrect number?
Examined rows are counted for every join part. The per-join-part
counter was incremented over all iterations. The result variable
was replaced at the end of every iteration. The final result was
the number of examined rows by the join part that ended its
execution as the last one. The numbers of other join parts was
lost.

Now we reset the per-join-part counter before every iteration and
add it to the result variable at the end of the iteration. That
way we get the sum of all iterations of all join parts.

No test case. Testing this needs a look into the slow query log.
I don't know of a way to do this portably with the test suite.
2006-10-11 12:24:59 +02:00
gkodinov/kgeorge@macbook.local
5367793e8b Merge bk-internal:/home/bk/mysql-5.0-opt
into  macbook.local:/Users/kgeorge/mysql/work/B22781-5.0-opt
2006-10-09 19:53:07 +04:00
gkodinov/kgeorge@macbook.local
13633864bb Bug #22781: SQL_BIG_RESULT fails to influence sort plan
Currently SQL_BIG_RESULT is checked only at compile time.
 However, additional optimizations may take place after
 this check that change the sort method from 'filesort'
 to sorting via index. As a result the actual plan
 executed is not the one specified by the SQL_BIG_RESULT
 hint. Similarly, there is no such test when executing
 EXPLAIN, resulting in incorrect output.
 The patch corrects the problem by testing for
 SQL_BIG_RESULT both during the explain and execution
 phases.
2006-10-09 19:51:41 +04:00
kroki/tomash@moonlight.intranet
ee0cebf9a7 BUG#21726: Incorrect result with multiple invocations of LAST_INSERT_ID.
Note: bug#21726 does not directly apply to 4.1, as it doesn't have stored
procedures.  However, 4.1 had some bugs that were fixed in 5.0 by the
patch for bug#21726, and this patch is a backport of those fixes.
Namely, in 4.1 it fixes:

  - LAST_INSERT_ID(expr) didn't return value of expr (4.1 specific).

  - LAST_INSERT_ID() could return the value generated by current
    statement if the call happens after the generation, like in

      CREATE TABLE t1 (i INT AUTO_INCREMENT PRIMARY KEY, j INT);
      INSERT INTO t1 VALUES (NULL, 0), (NULL, LAST_INSERT_ID());

  - Redundant binary log LAST_INSERT_ID_EVENTs could be generated.
2006-10-06 13:34:07 +04:00
kroki/tomash@moonlight.intranet
995ac34a24 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-real-bug21726-fix
2006-10-03 17:21:28 +04:00
kroki/tomash@moonlight.intranet
8798b462b5 Fix for the patch for bug#21726: Incorrect result with multiple
invocations of LAST_INSERT_ID.

Reding of LAST_INSERT_ID inside stored function wasn't noted by caller,
and no LAST_INSERT_ID_EVENT was issued for binary log.

The solution is to add THD::last_insert_id_used_bin_log, which is much
like THD::last_insert_id_used, but is reset only for upper-level
statements.  This new variable is used to issue LAST_INSERT_ID_EVENT.
2006-10-03 13:38:16 +04:00
dlenev@mockturtle.local
c30b6eafac Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into  mockturtle.local:/home/dlenev/src/mysql-4.1-rt-merge
2006-10-03 08:19:06 +04:00
dlenev@mockturtle.local
8eb4401c59 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mockturtle.local:/home/dlenev/src/mysql-5.0-rt-merge
2006-10-02 22:53:10 +04:00
kroki/tomash@moonlight.intranet
5ea8adfae7 BUG#21726: Incorrect result with multiple invocations of LAST_INSERT_ID
Non-upper-level INSERTs (the ones in the body of stored procedure,
stored function, or trigger) into a table that have AUTO_INCREMENT
column didn't affected the result of LAST_INSERT_ID() on this level.

The problem was introduced with the fix of bug 6880, which in turn was
introduced with the fix of bug 3117, where current insert_id value was
remembered on the first call to LAST_INSERT_ID() (bug 3117) and was
returned from that function until it was reset before the next
_upper-level_ statement (bug 6880).

The fix for bug#21726 brings back the behaviour of version 4.0, and
implements the following: remember insert_id value at the beginning
of the statement or expression (which at that point equals to
the first insert_id value generated by the previous statement), and
return that remembered value from LAST_INSERT_ID() or @@LAST_INSERT_ID.

Thus, the value returned by LAST_INSERT_ID() is not affected by values
generated by current statement, nor by LAST_INSERT_ID(expr) calls in
this statement.

Version 5.1 does not have this bug (it was fixed by WL 3146).
2006-10-02 14:28:23 +04:00
evgen@moonbone.local
299d243fcb Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  moonbone.local:/work/20503-bug-5.0-mysql
2006-09-29 21:22:47 +04:00
evgen@moonbone.local
0c9f941bb2 Fixed bug#20825: rollup puts non-equal values together
Fix for bug 7894 replaces a field(s) in a non-aggregate function with a item
reference if such a field was specified in the GROUP BY clause in order to
get a correct result.
When ROLLUP is involved this lead to a wrong result due to value of a such
field is got through a copy function and copying happens after the function
evaluation.
Such replacement isn't needed if grouping is also done by such a function.

The change_group_ref() function now isn't called for a function present in
the group list.
2006-09-29 20:02:53 +04:00
dlenev@mockturtle.local
76c5979f9e Merge mockturtle.local:/home/dlenev/src/mysql-4.1-bg22338-2
into  mockturtle.local:/home/dlenev/src/mysql-5.0-rt-merge
2006-09-29 12:36:12 +04:00
evgen@moonbone.local
e0461067b8 Fixed bug#20503: Server crash due to the ORDER clause not taken into account
while space allocation

Under some circumstances DISTINCT clause can be converted to grouping.
In such cases grouping is performed by all items in the select list.
If an ORDER clause is present then items from it is prepended to group list.
But the case with ORDER wasn't taken into account when allocating the
array for sum functions. This leads to memory corruption and crash.

The JOIN::alloc_func_list() function now allocates additional space if there
is an ORDER by clause is specified and DISTINCT -> GROUP BY optimization is
possible.
2006-09-29 00:50:00 +04:00
dlenev@mockturtle.local
acaa584c55 Fix for bug#22338 "Valgrind warning: uninitialized variable in
create_tmp_table()".

The fix for bug 21787 "COUNT(*) + ORDER BY + LIMIT returns wrong
result" introduced valgrind warnings which occured during execution
of information_schema.test and sp-prelocking.test in version 5.0.
There were no user visible effects.

The latter fix made create_tmp_table() dependant on
THD::lex::current_select value. Valgrind warnings occured when this
function was executed and THD::lex::current_select member pointed
to uninitialized SELECT_LEX instance.

This fix tries to remove this dependancy by moving some logic
outside of create_tmp_table() function.
2006-09-28 23:47:49 +04:00
stewart@willster.(none)
57a97f53bc BUG#19914 SELECT COUNT(*) sometimes returns MAX_INT on cluster tables
post-review fixes as indicated by Serg.

manual testing of error cases done in 5.0 due to support for DBUG_EXECUTE_IF
to insert errors.
Unable to write test case for mysql-test until 5.1 due to support for setting
debug options at runtime.
2006-09-28 23:41:37 +10:00
gkodinov@dl145s.mysql.com
b0167d265f Merge dl145s.mysql.com:/data/bk/team_tree_merge/mysql-5.0
into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt
2006-09-28 10:36:04 +02:00
gkodinov@dl145s.mysql.com
55cc4fd5c6 Merge dl145s.mysql.com:/data/bk/team_tree_merge/mysql-4.1
into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-4.1-opt
2006-09-28 10:19:25 +02:00
gkodinov/kgeorge@macbook.gmz
903387afc0 Bug #21174: Index degrades sort performance and optimizer does not honor IGNORE INDEX
- reversed the patch for 5.0 and moved to 5.1
2006-09-27 12:53:53 +03:00
stewart@willster.(none)
3ecc09e0e4 Merge willster.(none):/home/stewart/Documents/MySQL/4.1/main
into  willster.(none):/home/stewart/Documents/MySQL/4.1/bug19914-mk2
2006-09-25 14:48:39 +10:00
istruewing@chilla.local
f083782c42 Merge chilla.local:/home/mydev/mysql-5.0--main
into  chilla.local:/home/mydev/mysql-5.0-toteam
2006-09-21 10:55:23 +02:00
stewart@willster.(none)
0f3874dffa Merge willster.(none):/home/stewart/Documents/MySQL/4.1/ndb
into  willster.(none):/home/stewart/Documents/MySQL/4.1/bug19914-mk2
2006-09-20 17:09:53 +10:00
istruewing@chilla.local
1782889d35 Merge bk-internal.mysql.com:/home/bk/mysql-4.1-engines
into  chilla.local:/home/mydev/mysql-4.1-bug14400-monty
2006-09-20 08:33:46 +02:00
istruewing@chilla.local
7419f50245 After merge fix. 2006-09-19 14:26:18 +02:00
istruewing@chilla.local
5d509b32d4 Merge chilla.local:/home/mydev/mysql-4.1-bug14400-monty
into  chilla.local:/home/mydev/mysql-5.0-bug14400-monty
2006-09-19 11:27:00 +02:00
istruewing@chilla.local
47dc3fbe8a Merge bk-internal:/home/bk/mysql-4.0
into  chilla.local:/home/mydev/mysql-4.1-bug14400-monty
2006-09-19 10:17:25 +02:00
gkodinov@dl145s.mysql.com
2ec485f06e Merge bk-internal:/home/bk/mysql-5.0-opt
into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt
2006-09-18 12:20:20 +02:00
igor@rurik.mysql.com
dd3b8e4f9a Fixed bug #22085: Crash on the execution of a prepared
statement that uses an aggregating IN subquery with 
HAVING clause.
A wrong order of the call of split_sum_func2 for the HAVING
clause of the subquery and the transformation for the 
subquery resulted in the creation of a andor structure
that could not be restored at an execution of the prepared
statement.
2006-09-16 11:50:00 -07:00
igor@rurik.mysql.com
d3d3cef88c Fixed bug #21493: crash for the second execution of a function
containing a select statement that uses an aggregating IN subquery.
Added a parameter to the function fix_prepare_information 
to restore correctly the having clause for the second execution.
Saved andor structure of the having conditions at the proper moment
before any calls of split_sum_func2 that could modify the having structure
adding new Item_ref objects. (These additions, are produced not with 
the statement mem_root, but rather with the execution mem_root.)
2006-09-16 09:50:48 -07:00
gkodinov@dl145s.mysql.com
a9b3bd0eec Merge dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-4.1-opt
into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt
2006-09-15 14:14:38 +02:00
gkodinov@dl145s.mysql.com
b1e087a717 Merge dl145s.mysql.com:/data/bk/team_tree_merge/CLEAN/mysql-5.0
into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt
2006-09-15 11:52:49 +02:00
gkodinov@dl145s.mysql.com
148cb4e98a Merge dl145s.mysql.com:/data/bk/team_tree_merge/CLEAN/mysql-5.0
into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt
2006-09-15 11:47:23 +02:00
igor@rurik.mysql.com
ecf03182d9 Merge rurik.mysql.com:/home/igor/mysql-5.0-opt
into  rurik.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug5500
2006-09-09 10:23:13 -07:00
igor@rurik.mysql.com
9c15b7e0e8 Post-pushbuild corrections for fix of bug #21698. 2006-09-09 09:43:09 -07:00
igor@rurik.mysql.com
00a2f232c9 Merge rurik.mysql.com:/home/igor/mysql-5.0-opt
into  rurik.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug21698
2006-09-07 11:10:36 -07:00
igor@rurik.mysql.com
34206c6f80 Fixed bug #21698: erroneously a field could be replaced by an
equal constant under any circumstances.
In fact this substitution can be allowed if the field is
not of a type string or if the field reference serves as 
an argument of a comparison predicate.
2006-09-07 11:06:37 -07:00
kroki/tomash@moonlight.intranet
7abe938dfa BUG#20492: Subsequent calls to stored procedure yield incorrect result
if join is used

For procedures with selects that use complicated joins with ON expression
re-execution could erroneously ignore this ON expression, giving
incorrect result.

The problem was that optimized ON expression wasn't saved for
re-execution.  The solution is to properly save it.
2006-09-07 18:51:00 +04:00
igor@rurik.mysql.com
b7ded1e34f Fixed bug #5500: EXPLAIN returned a wrong select_type for queries using views.
Select_type in the EXPLAIN output for the query SELECT * FROM t1 was
'SIMPLE', while for the query SELECT * FROM v1, where the view v1
was defined as SELECT * FROM t1, the EXPLAIN output contained 'PRIMARY'
for the select_type column.
2006-09-06 08:21:43 -07:00
gkodinov/kgeorge@rakia.(none)
580d4a0df4 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-4.1-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B16792-4.1-opt
2006-09-05 19:22: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
timour/timka@lamia.home
cf3bed86b5 BUG#21787: COUNT(*) + ORDER BY + LIMIT returns wrong result
Fix an error in the bug fix.
2006-09-04 16:53:03 +03:00
msvensson@neptunus.(none)
4d0430c8fd Merge dl145s:/data/tkatchaounov/5.0-bug-21787
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0
2006-09-04 11:45:43 +02:00
timour/timka@lamia.home
5a0d5670b8 Merge lamia.home:/home/timka/mysql/src/4.1-virgin
into  lamia.home:/home/timka/mysql/src/4.1-bug-21787
2006-09-01 17:21:49 +03:00
timour/tkatchaounov@dl145s.mysql.com
462c22c1ae Merge timka@10.100.64.80:/home/timka/mysql/src/4.1-bug-21787
into  dl145s.mysql.com:/data/tkatchaounov/5.0-bug-21787
2006-09-01 14:29:27 +02:00
timour/timka@lamia.home
02e194cea2 Fix for BUG#21787: COUNT(*) + ORDER BY + LIMIT returns wrong result
The problem was due to a prior fix for BUG 9676, which limited
the rows stored in a temporary table to the LIMIT clause. This
optimization is not applicable to non-group queries with aggregate
functions. The fix disables the optimization in this case.
2006-09-01 15:07:04 +03:00
igor@rurik.mysql.com
0e96978cf6 Fixed bug #16081: row equalities were not taken into
account by the optimizer.
Now all row equalities are converted into conjunctions of
equalities between row elements. They are taken into account
by the optimizer together with the original regular equality
predicates.
2006-09-01 04:23:04 -07:00
tsmith@maint2.mysql.com
e2f40aa6d0 Merge maint2.mysql.com:/data/localhome/tsmith/bk/41
into  maint2.mysql.com:/data/localhome/tsmith/bk/50
2006-09-01 08:53:56 +02:00
timour/tkatchaounov@dl145s.mysql.com
4761ea5c82 Merge tkatchaounov@bk-internal.mysql.com:/home/bk/mysql-5.0
into  dl145s.mysql.com:/data/tkatchaounov/autopush/5.0-bug-21456
2006-08-28 16:08:48 +02:00
igor@rurik.mysql.com
218a96d2c6 Fixed bug #21390: wrong estimate of rows after elimination of
const tables. This resulted in choosing extremely inefficient
execution plans in same cases when distribution of data in
joined were skewed (see the customer test case for the bug).
2006-08-25 02:17:41 -07:00
timour/timka@lamia.home
31373e000b Merge lamia.home:/home/timka/mysql/src/4.1-virgin
into  lamia.home:/home/timka/mysql/src/4.1-bug-21456
2006-08-23 18:30:21 +03:00
timour/timka@lamia.home
70f76e457f Merge lamia.home:/home/timka/mysql/src/4.1-bug-21456
into  lamia.home:/home/timka/mysql/src/5.0-bug-21456
2006-08-23 18:22:53 +03:00
timour/timka@lamia.home
de723f2998 Bug #21456: SELECT DISTINCT(x) produces incorrect results when using order by
GROUP BY/DISTINCT pruning optimization must be done before ORDER BY 
optimization because ORDER BY may be removed when GROUP BY/DISTINCT
sorts as a side effect, e.g. in 
  SELECT DISTINCT <non-key-col>,<pk> FROM t1
  ORDER BY <non-key-col> DISTINCT
must be removed before ORDER BY as if done the other way around
it will remove both.
2006-08-23 16:46:57 +03:00
evgen@sunlight.local
f0edc9084d Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  sunlight.local:/local_work/16861-bug-5.0-mysql
2006-08-22 17:39:18 +04:00
evgen@sunlight.local
f17a536e09 Fixed bug#16861: User defined variable can have a wrong value if a tmp table was
used.

Sorting by RAND() uses a temporary table in order to get a correct results.
User defined variable was set during filling the temporary table and later
on it is substituted for its value from the temporary table. Due to this
it contains the last value stored in the temporary table.

Now if the result_field is set for the Item_func_set_user_var object it 
updates variable from the result_field value when being sent to a client.

The Item_func_set_user_var::check() now accepts a use_result_field
parameter. Depending on its value the result_field or the args[0] is used
to get current value.
2006-08-22 17:37:41 +04:00
evgen@moonbone.local
b4c2f3f8e5 Fixed bug#21475: Wrongly applied constant propagation leads to a false comparison.
A date can be represented as an int (like 20060101) and as a string (like
"2006.01.01"). When a DATE/TIME field is compared in one SELECT against both
representations the constant propagation mechanism leads to comparison
of DATE as a string and DATE as an int. In this example it compares 2006 and
20060101 integers. Obviously it fails comparison although they represents the
same date.


Now the Item_bool_func2::fix_length_and_dec() function sets the comparison
context for items being compared. I.e. if items compared as strings the
comparison context is STRING.
The constant propagation mechanism now doesn't mix items used in different
comparison contexts. The context check is done in the
Item_field::equal_fields_propagator() and in the change_cond_ref_to_const() 
functions.

Also the better fix for bug 21159 is introduced.
2006-08-21 00:23:57 +04:00
igor@rurik.mysql.com
cabb55a64f Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rurik.mysql.com:/home/igor/mysql-5.0-opt
2006-08-16 10:21:23 -07:00
igor@rurik.mysql.com
067d6fdfca Fixed bug #18165.
Made [NOT]BETWEEN predicates SARGable in respect to the second and 
the third arguments.
2006-08-16 09:37:19 -07:00
evgen@sunlight.local
db17048cac Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  sunlight.local:/local_work/21261-bug-5.0-mysql
2006-08-16 18:17:58 +04:00
bar@mysql.com/bar.intranet.mysql.r18.ru
b1f9b63a54 Merge mysql.com:/usr/home/bar/mysql-4.1
into  mysql.com:/usr/home/bar/mysql-4.1.b9509
2006-08-16 09:31:24 +05:00
evgen@sunlight.local
dd9a07706b Fixed bug#21261: Wrong access rights was required for an insert into a view
SELECT right instead of INSERT right was required for an insert into to a view.
This wrong behaviour appeared after the fix for bug #20989. Its intention was
to ask only SELECT right for all tables except the very first for a complex
INSERT query. But that patch has done it in a wrong way and lead to asking 
a wrong access right for an insert into a view.

The setup_tables_and_check_access() function now accepts two want_access
parameters. One will be used for the first table and the second for other
tables.
2006-08-15 21:45:24 +04:00
gkodinov/kgeorge@rakia.(none)
e024d63342 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B21159-5.0-opt
2006-08-15 12:54:02 +03:00
gkodinov/kgeorge@rakia.(none)
18c52dc2c1 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B21174-5.0-opt
2006-08-15 10:31:34 +03:00
gkodinov/kgeorge@rakia.(none)
5f242d0823 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B21159-5.0-opt
2006-08-15 10:25:56 +03:00
gkodinov/kgeorge@macbook.gmz
c606c63f0e Bug #21159: Optimizer: wrong result after AND with different data types
Disable const propagation for Item_hex_string.
This must be done because Item_hex_string->val_int() is not
the same as (Item_hex_string->val_str() in BINARY column)->val_int().
We cannot simply disable the replacement in a particular context (
e.g. <bin_col> = <int_col> AND <bin_col> = <hex_string>) since
Items don't know the context they are in and there are functions like 
IF (<hex_string>, 'yes', 'no').
Note that this will disable some valid cases as well 
(e.g. : <bin_col> = <hex_string> AND <bin_col2> = <bin_col>) but 
there's no way to distinguish the valid cases without having the
Item's parent say something like : Item->set_context(Item::STRING_RESULT)
and have all the Items that contain other Items do that consistently.
2006-08-15 10:13:17 +03:00
gkodinov/kgeorge@macbook.gmz
25eaa521bf Bug #21174: Index degrades sort performance and
optimizer does not honor IGNORE INDEX
 - Allow an index to be used for sorting the table 
   instead of filesort only if it is not disabled by
   IGNORE INDEX.
2006-08-14 18:19:29 +03:00
gkodinov/kgeorge@macbook.gmz
2d9aa1e61e Bug #21302: Result not properly sorted when using an ORDER BY on a second
table in a join
 The optimizer removes redundant columns in ORDER BY. It is considering 
redundant every reference to const table column, e.g b in :
create table t1 (a int, b int, primary key(a)); 
select 1 from t1 order by b where a = 1

But it must not remove references to const table columns if the 
const table is an outer table because there still can be 2 values :
the const value and NULL. e.g.:
create table t1 (a int, b int, primary key(a));
select t2.b c from t1 left join t1 t2 on (t1.a = t2.a and t2.a = 5) 
  order by c;
2006-08-14 15:45:48 +03:00
monty@mysql.com/narttu.mysql.fi
7d0b042ec5 Better bug fix for #14400 "Query joins wrong rows from table which is subject of "concurrent insert""
The previous bug fix didn't work when using partial keys.
Don't use GNUC min/max operations are they are depricated.
Fixed valgrind warning
2006-08-10 22:41:19 +03:00
stewart@willster.(none)
9d2e6b8d23 BUG#19914 SELECT COUNT(*) sometimes returns MAX_INT on cluster tables
allow handler::info to return an error code (that will be returned to the user)
2006-08-10 22:55:20 +08: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
evgen@moonbone.local
67c85a170a Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0
into  moonbone.local:/work/tmp_merge-5.0-opt-mysql
2006-08-02 16:44:56 +04:00
evgen@moonbone.local
40a1fbdffb Merge moonbone.local:/work/tmp_merge-4.1
into  moonbone.local:/work/tmp_merge-4.1-opt-mysql
2006-08-02 16:10:52 +04: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
kroki/tomash@moonlight.intranet
5c90b6f810 Merge moonlight.intranet:/home/tomash/src/mysql_ab/tmp_merge
into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-merge
2006-07-29 13:43:34 +04:00
kent@mysql.com/c-4b4072d5.010-2112-6f72651.cust.bredbandsbolaget.se
345945165a sql_select.cc:
Renamed variable, to avoid name clash with macro "rem_size"
  on AIX 5.3 and "/usr/include/sys/xmem.h" (bug#17648)
asn.cpp, asn.hpp:
  Avoid name clash with NAME_MAX
2006-07-28 21:26:46 +02:00
gkodinov/kgeorge@rakia.(none)
21e6d13147 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B21019-5.0-opt
2006-07-27 10:11:13 +03:00
gkodinov/kgeorge@rakia.(none)
351554e121 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-4.1-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B20792-4.1-opt
2006-07-27 10:06:37 +03:00
gkodinov/kgeorge@rakia.(none)
778dd354e3 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B20792-5.0-opt
2006-07-27 10:05:03 +03:00
evgen@moonbone.local
b7ade8e408 item_func.h, item_func.cc, sql_select.cc, item.h:
Post review changes for bug#19862.
2006-07-26 21:36:03 +04:00
gkodinov/kgeorge@rakia.(none)
e2a082aa32 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-4.1-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B20792-4.1-opt
2006-07-26 19:55:33 +03:00
gkodinov/kgeorge@macbook.gmz
609befda87 Merge macbook.gmz:/Users/kgeorge/mysql/work/B20792-4.1-opt
into  macbook.gmz:/Users/kgeorge/mysql/work/B20792-5.0-opt
2006-07-26 19:23:44 +03:00
gkodinov/kgeorge@macbook.gmz
565d495997 * Bug #20792: Incorrect results from aggregate subquery
When processing aggregate functions all tables values are reset
to NULLs at the end of each group. 
When doing that if there are no rows found for a group
the const tables must not be reset as they are not recalculated 
by do_select()/sub_select() for each group.
2006-07-26 19:19:30 +03:00
gkodinov/kgeorge@rakia.(none)
49f8ec4c99 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-4.1-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B21019-4.1-opt
2006-07-26 18:49:26 +03:00
gkodinov/kgeorge@macbook.gmz
66e65eff14 Merge macbook.gmz:/Users/kgeorge/mysql/work/B21019-4.1-opt
into  macbook.gmz:/Users/kgeorge/mysql/work/B21019-5.0-opt
2006-07-26 17:31:34 +03:00
kroki/tomash@moonlight.intranet
4e845cccc4 BUG#21206: memory corruption when too many cursors are opened at once
Too many cursors (more than 1024) could lead to memory corruption.
This affects both, stored routines and C API cursors, and the
threshold is per-server, not per-connection.  Similarly, the
corruption could happen when the server was under heavy load
(executing more than 1024 simultaneous complex queries), and this is
the reason why this bug is fixed in 4.1, which doesn't support
cursors.

The corruption was caused by a bug in the temporary tables code, when
an attempt to create a table could lead to a write beyond allocated
space.  Note, that only internal tables were affected (the tables
created internally by the server to resolve the query), not tables
created with CREATE TEMPORARY TABLE.  Another pre-condition for the
bug is TRUE value of --temp-pool startup option, which, however, is a
default.

The cause of a bug was that random memory was overwritten in
bitmap_set_next() due to out-of-bound memory access.
2006-07-26 16:23:07 +04:00
gkodinov/kgeorge@macbook.gmz
6766cfcdf9 Bug #21019: First result of SELECT COUNT(*) different than consecutive runs
When optimizing conditions like 'a = <some_val> OR a IS NULL' so that they're
 united into a single condition on the key and checked together the server must 
 check which value is the NULL value in a correct way : not only using ->is_null 
 but also check if the expression doesn't depend on any tables referenced in the 
 current statement. 
 This additional check must be performed because that optimization takes place 
 before the actual execution of the statement, so if the field was initialized 
 to NULL from a previous statement the optimization would be applied incorrectly.
2006-07-26 13:32:28 +03: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
evgen@moonbone.local
0a84eb5ff2 Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  moonbone.local:/work/19862-bug-5.0-opt-mysql
2006-07-26 00:37:35 +04:00
evgen@moonbone.local
4ee2e07cc0 Fixed bug#19862: Sort with filesort by function evaluates function twice
When there is no index defined filesort is used to sort the result of a
query. If there is a function in the select list and the result set should be
ordered by it's value then this function will be evaluated twice. First time to
get the value of the sort key and second time to send its value to a user.
This happens because filesort when sorts a table remembers only values of its
fields but not values of functions.
All functions are affected. But taking into account that SP and UDF functions
can be both expensive and non-deterministic a temporary table should be used 
to store their results and then sort it to avoid twice SP evaluation and to 
get a correct result.

If an expression referenced in an ORDER clause contains a SP or UDF 
function, force the use of a temporary table.

A new Item_processor function called func_type_checker_processor is added
to check whether the expression contains a function of a particular type.
2006-07-26 00:31:29 +04:00
gkodinov/kgeorge@rakia.(none)
9e9fb3e4e4 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B16712-5.0-opt
2006-07-25 11:56:22 +03:00
gkodinov/kgeorge@macbook.gmz
9380bb837f Bug#16712: group_concat returns odd srting insead of intended result
when calculating GROUP_CONCAT all blob fields are transformed
  to varchar when making the temp table.
  However a varchar has at max 2 bytes for length. 
  This fix makes the conversion only for blobs whose max length 
  is below that limit. 
  Otherwise blob field is created by make_string_field() call.
2006-07-25 11:45:10 +03:00
gkodinov/kgeorge@macbook.mshome.net
3cd6780241 Merge office:mysql/autopush/B20466-5.0-opt
into  macbook.mshome.net:/Users/kgeorge/mysql/work/B20466-5.0-opt
2006-07-22 15:18:30 +03:00
gkodinov/kgeorge@macbook.mshome.net
0282028292 Bug #20466: a view is mixing data when there's a trigger on the table
When making a place to store field values at the start of each group
  the real item (not the reference) must be used when deciding which column
  to copy.
2006-07-21 20:44:35 +03: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@olga.mysql.com
4de3186ae1 Fixed bug #20519.
The bug was due to a loss happened during a refactoring made
on May 30 2005 that modified the function JOIN::reinit.
As a result of it for any subquery the value of offset_limit_cnt
was not restored for the following executions. Yet the first 
execution of the subquery made it equal to 0.
The fix restores this value in the function JOIN::reinit.
2006-07-14 19:28:58 -07:00
gkodinov/kgeorge@macbook.gmz
a64f67bc4a Merge macbook.gmz:/Users/kgeorge/mysql/work/B17212-4.1-opt
into  macbook.gmz:/Users/kgeorge/mysql/work/B17212-5.0-opt
2006-07-14 11:20:52 +03:00
igor@olga.mysql.com
f608064083 Fixed bug #19714.
DESCRIBE returned the type BIGINT for a column of a view if the column
was specified by an expression over values of the type INT.
    
E.g. for the view defined as follows:
  CREATE VIEW v1 SELECT COALESCE(f1,f2) FROM t1
DESCRIBE returned type BIGINT for the only column of the view if f1,f2 are
columns of the INT type.
At the same time DESCRIBE returned type INT for the only column of the table
defined by the statement:
  CREATE TABLE t2 SELECT COALESCE(f1,f2) FROM t1.
    
This inconsistency was removed by the patch.

Now the code chooses between INT/BIGINT depending on the
precision of the aggregated column type.
 
Thus both DESCRIBE commands above returns type INT for v1 and t2.
2006-07-13 20:48:26 -07:00
evgen@moonbone.local
4b1730241d Merge moonbone.local:/work/16302-bug-4.1-opt-mysql
into  moonbone.local:/work/tmp_merge-5.0-opt-mysql
2006-07-13 18:18:20 +04:00
evgen@moonbone.local
8394aec4e6 Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0
into  moonbone.local:/work/tmp_merge-5.0-opt-mysql
2006-07-13 18:16:16 +04:00
gkodinov/kgeorge@macbook.gmz
5079d5cf6a Bug #17212 results not sorted correctly by ORDER BY when using index
* don't use join cache when the incoming data set is already ordered
    for ORDER BY
    This choice must be made because join cache will effectively
    reverse the join order and the results will be sorted by the index
    of the table that uses join cache.
2006-07-12 10:57:38 +03:00
evgen@moonbone.local
5d4881b864 Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-4.1-opt
into  moonbone.local:/work/18503-bug-4.1-mysql
2006-07-12 02:52:29 +04:00
evgen@moonbone.local
8ffda481c9 Fixed bug#18503: Queries with a quantified subquery returning empty set
may return a wrong result.

An Item_sum_hybrid object has the was_values flag which indicates whether any
values were added to the sum function. By default it is set to true and reset
to false on any no_rows_in_result() call. This method is called only in
return_zero_rows() function. An ALL/ANY subquery can be optimized by MIN/MAX
optimization. The was_values flag is used to indicate whether the subquery
has returned at least one row. This bug occurs because return_zero_rows() is
called only when we know that the select will return zero rows before
starting any scans but often such information is not known.
In the reported case the return_zero_rows() function is not called and
the was_values flag is not reset to false and yet the subquery return no rows
Item_func_not_all and Item_func_nop_all functions return a wrong
comparison result.

The end_send_group() function now calls no_rows_in_result() for each item
in the fields_list if there is no rows were found for the (sub)query.
2006-07-12 01:52:18 +04:00
gkodinov/kgeorge@macbook.gmz
8f71e47a0d Merge macbook.gmz:/Users/kgeorge/mysql/work/B14553-4.1-opt
into  macbook.gmz:/Users/kgeorge/mysql/work/B14553-5.0-opt
2006-07-10 16:44:05 +03:00
gkodinov/kgeorge@macbook.gmz
893e92761f Merge rakia:mysql/4.1/B14553
into  macbook.gmz:/Users/kgeorge/mysql/work/B14553-4.1-opt
2006-07-10 16:27:04 +03:00
gkodinov/kgeorge@mysql.com/rakia.(none)
2c9f5cc706 BUG#14553: NULL in WHERE resets LAST_INSERT_ID
To make MySQL compatible with some ODBC applications, you can find
the AUTO_INCREMENT value for the last inserted row with the following query:
 SELECT * FROM tbl_name WHERE auto_col IS NULL.
This is done with a special code that replaces 'auto_col IS NULL' with
'auto_col = LAST_INSERT_ID'.
However this also resets the LAST_INSERT_ID to 0 as it uses it for a flag
so as to ensure that only the first SELECT ... WHERE auto_col IS NULL
after an INSERT has this special behaviour.
In order to avoid resetting the LAST_INSERT_ID a special flag is introduced
in the THD class. This flag is used to restrict the second and subsequent
SELECTs instead of LAST_INSERT_ID.
2006-07-10 16:27:03 +03:00
ingo@chilla.local
591d461d95 Merge chilla.local:/home/mydev/mysql-5.0
into  chilla.local:/home/mydev/mysql-5.0-bug16218
2006-07-06 19:36:07 +02:00