Commit graph

1671 commits

Author SHA1 Message Date
unknown
d4bfae38ac Merge siva.hindu.god:/usr/home/tim/m/bk/g50
into  siva.hindu.god:/usr/home/tim/m/bk/50


configure.in:
  Auto merged
mysql-test/r/rename.result:
  Auto merged
mysql-test/r/subselect.result:
  Auto merged
mysql-test/r/view.result:
  Auto merged
mysql-test/t/subselect.test:
  Auto merged
mysql-test/t/view.test:
  Auto merged
mysys/mf_iocache.c:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/opt_range.h:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/table.cc:
  Auto merged
myisam/sort.c:
  Manual merge
mysql-test/r/innodb_mysql.result:
  Manual merge
mysql-test/t/innodb_mysql.test:
  Manual merge
2006-10-24 14:42:08 -06:00
unknown
50fe8e0c2b Merge willster.(none):/home/stewart/Documents/MySQL/4.1/bug19914-mk2
into  willster.(none):/home/stewart/Documents/MySQL/4.1/bug19914-mk2-merge2


sql/sql_select.cc:
  Auto merged
2006-10-23 23:43:48 +10:00
unknown
8cc480915f Merge bk-internal:/home/bk/mysql-5.0
into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt


mysql-test/r/myisam.result:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
2006-10-20 11:02:56 +02:00
unknown
0153d67e59 Merge bk-internal:/home/bk/mysql-4.1
into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-4.1-opt


sql/sql_base.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
2006-10-20 10:57:38 +02:00
unknown
5e1fe0f800 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


sql/sql_select.cc:
  Auto merged
mysql-test/r/olap.result:
  SCCS merged
2006-10-19 15:04:12 +02:00
unknown
d30186772f 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


mysql-test/r/merge.result:
  Auto merged
mysql-test/r/myisam.result:
  Auto merged
mysql-test/r/select.result:
  Auto merged
mysql-test/r/view.result:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_cmpfunc.h:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/opt_range.h:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
sql/table.cc:
  Auto merged
2006-10-19 14:37:49 +02:00
unknown
9bfaab57fa 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


sql/sql_select.cc:
  Auto merged
2006-10-19 14:34:56 +02:00
unknown
68c2a008a1 Merge mysql.com:/usr/home/ram/work/bug20732/my41-bug20732
into  mysql.com:/usr/home/ram/work/bug20732/my50-bug20732


sql/opt_range.cc:
  Auto merged
sql/opt_range.h:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/table.cc:
  Auto merged
mysql-test/r/range.result:
  SCCS merged
mysql-test/t/range.test:
  SCCS merged
2006-10-19 16:15:30 +05:00
unknown
da7af481cd 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.


mysql-test/r/range.result:
  Fix for bug #20732: Partial index and long sjis search with '>' fails sometimes
    - test result.
mysql-test/t/range.test:
  Fix for bug #20732: Partial index and long sjis search with '>' fails sometimes
    - test case.
sql/opt_range.cc:
  Fix for bug #20732: Partial index and long sjis search with '>' fails sometimes
    - check if we have a partial key segment for a Item_func::GT_FUNC;
      if so, don't set NEAR_MIN flag in order to use HA_READ_KEY_OR_NEXT
      instead of HA_READ_AFTER_KEY.
sql/opt_range.h:
  Fix for bug #20732: Partial index and long sjis search with '>' fails sometimes
    - key segment 'flag' slot added.
sql/sql_select.cc:
  Fix for bug #20732: Partial index and long sjis search with '>' fails sometimes
    - test (HA_PART_KEY_SEG | HA_NULL_PART) as we split it in the sql/table.cc
sql/table.cc:
  Fix for bug #20732: Partial index and long sjis search with '>' fails sometimes
    - set HA_NULL_PART flag instead of HA_PART_KEY_SEG in order not to mix them.
2006-10-19 12:52:37 +05:00
unknown
e2698fa753 Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rurik.mysql.com:/home/igor/mysql-5.0-opt


sql/sql_select.cc:
  Auto merged
2006-10-17 12:25:53 -07:00
unknown
711021a464 Merge rurik.mysql.com:/home/igor/mysql-5.0-opt
into  rurik.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug19579


mysql-test/t/select.test:
  Auto merged
sql/sql_select.cc:
  Auto merged
mysql-test/r/select.result:
  SCCS merged
2006-10-17 10:07:29 -07:00
unknown
71b67e4a53 rename of the new members introduced in the fix for bug 21798 2006-10-17 19:22:13 +03:00
unknown
c208f46b66 Merge bk-internal:/home/bk/mysql-5.0-opt
into  macbook.gmz:/Users/kgeorge/mysql/work/B21798-5.0-opt-merge


sql/mysql_priv.h:
  Auto merged
sql/sql_delete.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
mysql-test/r/subselect.result:
  merge fixes for bug 21798
mysql-test/t/subselect.test:
  merge fixes for bug 21798
2006-10-17 16:36:44 +03:00
unknown
841ea461ce 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.


mysql-test/r/subselect.result:
  Bug#21798: memory leak during query execution with subquery in column
              list using a function
   - test case
mysql-test/t/subselect.test:
  Bug#21798: memory leak during query execution with subquery in column
              list using a function
   - test case
sql/mysql_priv.h:
  Bug#21798: memory leak during query execution with subquery in column
              list using a function
   - cache the entities allocated in the threads memory pool by
     JOIN::exec ().
sql/sql_delete.cc:
  Bug#21798: memory leak during query execution with subquery in column
              list using a function
   - cache the SORT_ORDER, TABLE * and JOIN_TAB allocated in the thread's 
     memory pool by JOIN::exec ().
sql/sql_select.cc:
  Bug#21798: memory leak during query execution with subquery in column
              list using a function
   - cache the SORT_ORDER, TABLE * and JOIN_TAB allocated in the thread's 
     memory pool by JOIN::exec ().
sql/sql_select.h:
  Bug#21798: memory leak during query execution with subquery in column
              list using a function
   - cache the SORT_ORDER, TABLE * and JOIN_TAB allocated in the thread's 
     memory pool by JOIN::exec ().
sql/sql_table.cc:
  Bug#21798: memory leak during query execution with subquery in column
              list using a function
   - cache the SORT_ORDER, TABLE * and JOIN_TAB allocated in the thread's 
     memory pool by JOIN::exec ().
sql/sql_update.cc:
  Bug#21798: memory leak during query execution with subquery in column
              list using a function
   - cache the SORT_ORDER, TABLE * and JOIN_TAB allocated in the thread's 
     memory pool by JOIN::exec ().
2006-10-17 16:20:26 +03:00
unknown
7094daee8d Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-4.1-runtime
into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-4.1-bug21726


sql/sql_select.cc:
  Auto merged
2006-10-17 13:41:29 +04:00
unknown
e71520abe3 Merge bk-internal.mysql.com:/home/bk/mysql-4.1-engines
into  chilla.local:/home/mydev/mysql-4.1-bug12240


sql/sql_select.cc:
  Auto merged
2006-10-17 09:33:58 +02:00
unknown
6101fd25d0 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.



mysql-test/r/select.result:
  Added a test case for bug #19579.
mysql-test/t/select.test:
  Added a test case for bug #19579.
sql/item_cmpfunc.cc:
  Fixed bug #19579: at range analysis optimizer did not take into 
  account predicates that become sargable after reading const tables.
  Added a counter of between predicates.
sql/sql_base.cc:
  Fixed bug #19579: at range analysis optimizer did not take into 
  account predicates that become sargable after reading const tables.
  Added a counter of between predicates.
sql/sql_lex.cc:
  Fixed bug #19579: at range analysis optimizer did not take into 
  account predicates that become sargable after reading const tables.
  Added a counter of between predicates.
sql/sql_lex.h:
  Fixed bug #19579: at range analysis optimizer did not take into 
  account predicates that become sargable after reading const tables.
  Added a counter of between predicates.
sql/sql_select.cc:
  Fixed bug #19579: at range analysis optimizer did not take into 
  account predicates that become sargable after reading const tables.
  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
unknown
7fdcb25574 Merge bk-internal.mysql.com:/home/bk/mysql-5.0-engines
into  chilla.local:/home/mydev/mysql-5.0-bug12240


sql/sql_select.cc:
  Auto merged
2006-10-16 17:12:57 +02:00
unknown
2e9103b844 Merge chilla.local:/home/mydev/mysql-4.1-bug12240
into  chilla.local:/home/mydev/mysql-5.0-bug12240


sql/sql_select.cc:
  Bug#12240 - Rows Examined in Slow Log showing incorrect number?
  Manual merge from 4.1.
2006-10-16 13:15:15 +02:00
unknown
62689e18e7 Merge willster.(none):/home/stewart/Documents/MySQL/4.1/bug19914-mk2
into  willster.(none):/home/stewart/Documents/MySQL/5.0/bug19914-mk2-merge


sql/ha_berkeley.cc:
  Auto merged
sql/ha_berkeley.h:
  Auto merged
BitKeeper/deleted/.del-ha_isam.cc~4dce65904db2675e:
  Auto merged
BitKeeper/deleted/.del-ha_isam.h~bf53d533be3d3927:
  Auto merged
BitKeeper/deleted/.del-ha_isammrg.cc~dc682e4755d77a2e:
  Auto merged
BitKeeper/deleted/.del-ha_isammrg.h~66fd2e5bfe7207dc:
  Auto merged
sql/ha_archive.cc:
  Auto merged
sql/ha_archive.h:
  Auto merged
sql/ha_blackhole.cc:
  Auto merged
sql/ha_blackhole.h:
  Auto merged
sql/ha_heap.cc:
  Auto merged
sql/ha_heap.h:
  Auto merged
sql/ha_innodb.cc:
  Auto merged
sql/ha_innodb.h:
  Auto merged
sql/ha_myisam.cc:
  Auto merged
sql/ha_myisam.h:
  Auto merged
sql/ha_myisammrg.cc:
  Auto merged
sql/ha_myisammrg.h:
  Auto merged
sql/item_sum.cc:
  Auto merged
sql/opt_sum.cc:
  Auto merged
sql/sql_delete.cc:
  Auto merged
sql/examples/ha_example.cc:
  Auto merged
sql/examples/ha_example.h:
  Auto merged
sql/examples/ha_tina.cc:
  Auto merged
sql/examples/ha_tina.h:
  Auto merged
sql/sql_union.cc:
  Auto merged
sql/ha_ndbcluster.cc:
  merge
sql/ha_ndbcluster.h:
  merge
sql/handler.h:
  merge
sql/sql_select.cc:
  merge
2006-10-16 17:39:38 +10:00
unknown
ddc5ae3801 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.


sql/sql_select.cc:
  Bug#12240 - Rows Examined in Slow Log showing incorrect number?
  Fixed reseting and accumulation of examined rows counts.
2006-10-11 12:24:59 +02:00
unknown
09dfd9e7e4 Merge bk-internal:/home/bk/mysql-5.0-opt
into  macbook.local:/Users/kgeorge/mysql/work/B22781-5.0-opt


sql/sql_select.cc:
  Auto merged
2006-10-09 19:53:07 +04:00
unknown
45cad70ff4 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.


mysql-test/r/bdb.result:
  Bug #22781: SQL_BIG_RESULT fails to influence sort plan
   - updated sql_big_result testcase
mysql-test/r/group_by.result:
  Bug #22781: SQL_BIG_RESULT fails to influence sort plan
   - test case with MyISAM
mysql-test/r/innodb.result:
  Bug #22781: SQL_BIG_RESULT fails to influence sort plan
   - updated sql_big_result testcase
mysql-test/r/innodb_mysql.result:
  Bug #22781: SQL_BIG_RESULT fails to influence sort plan
   - test case with InnoDB
mysql-test/r/myisam.result:
  Bug #22781: SQL_BIG_RESULT fails to influence sort plan
   - updated sql_big_result testcase
mysql-test/t/group_by.test:
  Bug #22781: SQL_BIG_RESULT fails to influence sort plan
   - test case with MyISAM
mysql-test/t/innodb_mysql.test:
  Bug #22781: SQL_BIG_RESULT fails to influence sort plan
   - test case with InnoDB
sql/sql_select.cc:
  Bug #22781: SQL_BIG_RESULT fails to influence sort plan
   - When SQL_BIG_RESULT is specified, disable the optimization performed
  at execution/explain time that decides to use an index instead
  of filesort.
2006-10-09 19:51:41 +04:00
unknown
f603c1cce8 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.


mysql-test/r/rpl_insert_id.result:
  Add result for bug#21726: Incorrect result with multiple invocations
  of LAST_INSERT_ID.
mysql-test/t/rpl_insert_id.test:
  Add test case for bug#21726: Incorrect result with multiple invocations
  of LAST_INSERT_ID.
sql/item_func.cc:
  Add implementation of Item_func_last_insert_id::fix_fields(), where we
  set THD::last_insert_id_used when statement calls LAST_INSERT_ID().
  In Item_func_last_insert_id::val_int(), return THD::current_insert_id
  if called like LAST_INSERT_ID(), otherwise return value of argument if
  called like LAST_INSERT_ID(expr).
sql/item_func.h:
  Add declaration of Item_func_last_insert_id::fix_fields().
sql/log_event.cc:
  Do not set THD::last_insert_id_used on LAST_INSERT_ID_EVENT.  Though we
  know the statement will call LAST_INSERT_ID(), it wasn't called yet.
sql/set_var.cc:
  In sys_var_last_insert_id::value_ptr(), set THD::last_insert_id_used,
  and return THD::current_insert_id for @@LAST_INSERT_ID.
sql/sql_class.h:
  Update comments.
  Remove THD::insert_id(), as it has lost its purpose now.
sql/sql_insert.cc:
  Now it is OK to read THD::last_insert_id directly.
sql/sql_load.cc:
  Now it is OK to read THD::last_insert_id directly.
sql/sql_parse.cc:
  In mysql_execute_command(), remember THD::last_insert_id (first
  generated value of the previous statement) in THD::current_insert_id,
  which then will be returned for LAST_INSERT_ID() and @@LAST_INSERT_ID.
sql/sql_select.cc:
  If "IS NULL" is replaced with "= <LAST_INSERT_ID>", use right value,
  which is THD::current_insert_id, and also set THD::last_insert_id_used
  to issue binary log LAST_INSERT_ID_EVENT.
sql/sql_update.cc:
  Now it is OK to read THD::last_insert_id directly.
tests/mysql_client_test.c:
  Add test case for bug#21726: Incorrect result with multiple invocations
  of LAST_INSERT_ID.
2006-10-06 13:34:07 +04:00
unknown
48759d7ae9 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-real-bug21726-fix


sql/sql_select.cc:
  Auto merged
2006-10-03 17:21:28 +04:00
unknown
37b5cbdc30 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.


mysql-test/r/rpl_insert_id.result:
  For bug#21726, add result for statement-based replication of function
  calls.
mysql-test/t/rpl_insert_id.test:
  For bug#21726, add test case for statement-based replication of function
  calls.
sql/item_func.cc:
  Set THD::last_insert_id_used_bin_log for issuing of LAST_INSERT_ID_EVENT.
sql/log.cc:
  Issue LAST_INSERT_ID_EVENT if THD::last_insert_id_used_bin_log is set.
sql/set_var.cc:
  Set THD::last_insert_id_used_bin_log for issuing of LAST_INSERT_ID_EVENT.
sql/sql_class.cc:
  Initialize THD::last_insert_id_used_bin_log.
  Fix typo, add whitespace.
sql/sql_class.h:
  Add THD::last_insert_id_used_bin_log.
sql/sql_parse.cc:
  Reset THD::last_insert_id_used_bin_log for upper-level statements.
sql/sql_select.cc:
  Set THD::last_insert_id_used_bin_log for issuing of LAST_INSERT_ID_EVENT.
2006-10-03 13:38:16 +04:00
unknown
69e970a5ea Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into  mockturtle.local:/home/dlenev/src/mysql-4.1-rt-merge


sql/sql_select.cc:
  Auto merged
2006-10-03 08:19:06 +04:00
unknown
2e2198633e Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mockturtle.local:/home/dlenev/src/mysql-5.0-rt-merge


mysql-test/r/ps.result:
  Auto merged
mysql-test/t/ps.test:
  Auto merged
sql/item.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
2006-10-02 22:53:10 +04:00
unknown
be929087ec 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).


mysql-test/r/rpl_insert_id.result:
  Add results for bug#21726: Incorrect result with multiple invocations
  of LAST_INSERT_ID, and bug#20339: stored procedure using LAST_INSERT_ID()
  does not replicate statement-based.
mysql-test/t/rpl_insert_id.test:
  Add test cases for bug#21726: Incorrect result with multiple invocations
  of LAST_INSERT_ID, and bug#20339: stored procedure using LAST_INSERT_ID()
  does not replicate statement-based.
sql/item_func.cc:
  Add implementation of Item_func_last_insert_id::fix_fields(), where we
  remember in THD::current_insert_id the first value generated during
  execution of the previous statement, which is returned then from
  Item_func_last_insert_id::val_int().
sql/item_func.h:
  Add declaration of Item_func_last_insert_id::fix_fields().
sql/log_event.cc:
  Do not set THD::last_insert_id_used on LAST_INSERT_ID_EVENT.  Though we
  know the statement will call LAST_INSERT_ID(), it wasn't called yet.
sql/set_var.cc:
  In sys_var_last_insert_id::value_ptr() remember in
  THD::current_insert_id the first value generated during execution of the
  previous statement, and return this value for @@LAST_INSERT_ID.
sql/sql_class.cc:
  Reset THD::last_insert_id_used after each statement execution.
sql/sql_class.h:
  Rather then remember current insert_id value on first invocation of
  THD::insert_id(), remember it in Item_func_last_insert_id::fix_fields(),
  sys_var_last_insert_id::value_ptr(), or mysql_execute_command().
  Remove THD::insert_id(), as it lost its value now.
sql/sql_insert.cc:
  THD::insert_id() is removed, use THD::last_insert_id directly.
sql/sql_load.cc:
  THD::insert_id() is removed, using THD::last_insert_id directly is OK.
sql/sql_parse.cc:
  Remember in THD::current_insert_id first generated insert id value of
  the previous statement in mysql_execute_command().
  No need to reset THD::last_insert_id_used in
  mysql_reset_thd_for_next_command(), it will be reset after each
  statement.
sql/sql_select.cc:
  If "IS NULL" is replaced with "= <LAST_INSERT_ID>", use right value,
  which is THD::current_insert_id, and also set THD::last_insert_id_used
  to issue binary log LAST_INSERT_ID_EVENT.
sql/sql_update.cc:
  THD::insert_id() is removed, use THD::last_insert_id directly.
tests/mysql_client_test.c:
  Add test case for bug#21726: Incorrect result with multiple invocations
  of LAST_INSERT_ID.
2006-10-02 14:28:23 +04:00
unknown
1643d0c5ed Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  moonbone.local:/work/20503-bug-5.0-mysql


sql/sql_select.cc:
  Auto merged
2006-09-29 21:22:47 +04:00
unknown
da9f990b54 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.


mysql-test/t/olap.test:
  Added the test case for the bug#20825:  rollup puts non-equal values together
mysql-test/r/olap.result:
  Added the test case for the bug#20825:  rollup puts non-equal values together
sql/sql_select.cc:
  Fixed bug#20825: rollup puts non-equal values together
  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
unknown
d4553e3558 Merge mockturtle.local:/home/dlenev/src/mysql-4.1-bg22338-2
into  mockturtle.local:/home/dlenev/src/mysql-5.0-rt-merge


mysql-test/r/temp_table.result:
  Auto merged
mysql-test/t/temp_table.test:
  Auto merged
sql/sql_select.cc:
  Manual merge.
sql/sql_table.cc:
  Manual merge.
2006-09-29 12:36:12 +04:00
unknown
4fd7172391 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.


mysql-test/t/select.test:
  Added the test case for bug#20503: Server crash due to the ORDER clause not taken into account while space allocation
mysql-test/r/select.result:
  Added the test case for bug#20503: Server crash due to the ORDER clause not taken into account while space allocation
sql/sql_select.cc:
  Fixed bug#20503: Server crash due to the ORDER clause not taken into account
  while space allocation
  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
unknown
5d46e29933 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.


sql/sql_select.cc:
  create_tmp_table():
    Moved code which is responsible for determining if optimization
    which pushes down LIMIT clause to temporary table creation is
    applicable out of this function.
    Such move made this function independant of THD::lex::current_select
    value and removed valgrind warnings which occured in cases when this
    member pointed to uninitialized SELECT_LEX object (particularly these
    warnings occured in sp-prelocking.test and information_schema.test
    in 5.0). This seems like a better solution than trying to force this
    pointer always to point to relevant select because:
    - In some cases when we use create_tmp_table() there are no relevant
      SELECT_LEX object (we use it just to create temporary table/object).
    - There is only one place in code where we call this funciton and
      where this optimization can be enabled. And in this place we
      already have some logic which tries to determine if it is applicable.
2006-09-28 23:47:49 +04:00
unknown
44a882f925 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.


sql/ha_blackhole.cc:
  update for handler::info() now returning int
sql/ha_blackhole.h:
  update for handler::info() now returning int
sql/ha_isam.cc:
  update for handler::info() now returning int
sql/ha_isam.h:
  update for handler::info() now returning int
sql/ha_isammrg.cc:
  update for handler::info() now returning int
sql/ha_isammrg.h:
  update for handler::info() now returning int
sql/item_sum.cc:
  update for handler::info() now returning int.
  
  return error to user if info call fails
sql/sql_delete.cc:
  update for handler::info() now returning int.
  
  return error to user if info call fails
sql/sql_select.cc:
  update for handler::info() now returning int.
  
  return error to user if info call fails
sql/sql_union.cc:
  update for handler::info() now returning int.
  
  return error to user if info call fails
2006-09-28 23:41:37 +10:00
unknown
70255e8509 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


mysql-test/r/view.result:
  Auto merged
mysql-test/t/view.test:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2006-09-28 10:36:04 +02:00
unknown
b8fe620615 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


sql/sql_select.cc:
  Auto merged
2006-09-28 10:19:25 +02:00
unknown
ca5e29475c Bug #21174: Index degrades sort performance and optimizer does not honor IGNORE INDEX
- reversed the patch for 5.0 and moved to 5.1


mysql-test/r/group_by.result:
  Bug #21174: Index degrades sort performance and optimizer does not honor IGNORE INDEX
   - reversed the patch for 5.0
mysql-test/t/group_by.test:
  Bug #21174: Index degrades sort performance and optimizer does not honor IGNORE INDEX
   - reversed the patch for 5.0
sql/sql_select.cc:
  Bug #21174: Index degrades sort performance and optimizer does not honor IGNORE INDEX
   - reversed the patch for 5.0
2006-09-27 12:53:53 +03:00
unknown
0f72ee6766 Merge willster.(none):/home/stewart/Documents/MySQL/4.1/main
into  willster.(none):/home/stewart/Documents/MySQL/4.1/bug19914-mk2


sql/opt_sum.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
2006-09-25 14:48:39 +10:00
unknown
5a7c671c1f Merge chilla.local:/home/mydev/mysql-5.0--main
into  chilla.local:/home/mydev/mysql-5.0-toteam


sql/opt_range.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
2006-09-21 10:55:23 +02:00
unknown
d4d3dcacaa Merge willster.(none):/home/stewart/Documents/MySQL/4.1/ndb
into  willster.(none):/home/stewart/Documents/MySQL/4.1/bug19914-mk2


sql/ha_ndbcluster.cc:
  Auto merged
sql/ha_ndbcluster.h:
  Auto merged
sql/sql_select.cc:
  Auto merged
2006-09-20 17:09:53 +10:00
unknown
f6951675f9 Merge bk-internal.mysql.com:/home/bk/mysql-4.1-engines
into  chilla.local:/home/mydev/mysql-4.1-bug14400-monty


BitKeeper/etc/ignore:
  auto-union
mysql-test/r/myisam.result:
  Auto merged
mysql-test/t/myisam.test:
  Auto merged
sql/sql_select.cc:
  Auto merged
2006-09-20 08:33:46 +02:00
unknown
11ba3204e1 After merge fix. 2006-09-19 14:26:18 +02:00
unknown
08f4565e6a Merge chilla.local:/home/mydev/mysql-4.1-bug14400-monty
into  chilla.local:/home/mydev/mysql-5.0-bug14400-monty


BitKeeper/etc/ignore:
  auto-union
include/my_global.h:
  Auto merged
myisam/mi_rkey.c:
  Auto merged
mysql-test/r/myisam.result:
  Auto merged
mysql-test/t/myisam.test:
  Auto merged
myisam/mi_test_all.res:
  Manual merge from 4.1.
sql/sql_select.cc:
  Manual merge from 4.1.
2006-09-19 11:27:00 +02:00
unknown
82a72ee17e Merge bk-internal:/home/bk/mysql-4.0
into  chilla.local:/home/mydev/mysql-4.1-bug14400-monty


BitKeeper/etc/ignore:
  auto-union
include/my_global.h:
  Auto merged
myisam/mi_rkey.c:
  Manual null merge as a better fix is already present.
mysql-test/r/myisam.result:
  Manual null merge as a better fix is already present.
mysql-test/t/myisam.test:
  Manual null merge as a better fix is already present.
sql/sql_select.cc:
  Manual merge of purify improvements.
2006-09-19 10:17:25 +02:00
unknown
db1a94a7ff Merge bk-internal:/home/bk/mysql-5.0-opt
into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt


sql/sql_insert.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_select.cc:
  Auto merged
2006-09-18 12:20:20 +02:00
unknown
c46151d961 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.


mysql-test/r/ps.result:
  Added a test cases for bug #22085.
mysql-test/t/ps.test:
  Added a test cases for bug #22085.
2006-09-16 11:50:00 -07:00
unknown
58e178c5cc 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.)


mysql-test/r/sp.result:
  Added a test case for bug #21493.
mysql-test/t/sp.test:
  Added a test case for bug #21493.
sql/sql_delete.cc:
  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.
sql/sql_insert.cc:
  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.
sql/sql_lex.cc:
  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.
sql/sql_lex.h:
  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.
sql/sql_update.cc:
  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.
2006-09-16 09:50:48 -07:00
unknown
c97cc11392 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


mysql-test/r/query_cache.result:
  Auto merged
mysql-test/r/subselect.result:
  Auto merged
mysql-test/r/type_date.result:
  Auto merged
mysql-test/t/func_time.test:
  Auto merged
mysql-test/t/insert_update.test:
  Auto merged
sql/item.h:
  Auto merged
sql/log.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2006-09-15 14:14:38 +02:00
unknown
e4b044060c 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


sql/item.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/item.h:
  SCCS merged
2006-09-15 11:52:49 +02:00
unknown
8fd0cf5498 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


sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
2006-09-15 11:47:23 +02:00
unknown
5371adca31 Merge rurik.mysql.com:/home/igor/mysql-5.0-opt
into  rurik.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug5500


sql/sql_select.cc:
  Auto merged
2006-09-09 10:23:13 -07:00
unknown
a65342f38d Post-pushbuild corrections for fix of bug #21698. 2006-09-09 09:43:09 -07:00
unknown
21be389b46 Merge rurik.mysql.com:/home/igor/mysql-5.0-opt
into  rurik.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug21698


sql/sql_select.cc:
  Auto merged
2006-09-07 11:10:36 -07:00
unknown
8716670229 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.  


mysql-test/r/func_str.result:
  Added test cases for bug #21698.
mysql-test/r/heap_hash.result:
  Adjusted results after the fix for bug #21198.
mysql-test/t/func_str.test:
  Added test cases for bug #21698.
sql/item.cc:
  Fixed bug #21198.
  Added a method to check whether a field reference can be 
  substituted for a constant equal to the field.
  This substitution is allowed if the field is not of a type string
  or if the field reference serves as an argument of a comparison
  predicate.
sql/item.h:
  Fixed bug #21698.
  Added a new virtual transformation method for a item 'compile'
  with two callback function parameters.
  Added a new virtual method 'subst_argument_checker' to be used
  as an amnalyzer method.
  This method is supposed to set its in/out argument to NULL for
  the nodes where substitution of a string field for a constant
  is not valid.
sql/item_cmpfunc.cc:
  Fixed bug #21698.
  Added an implementation of the compile method for class Item_cond.
  First it processes the Item_cond node with a callback function and if
  the latter returns TRUE it proceeds with a transformation performed by
  another callback function.
sql/item_cmpfunc.h:
  Fixed bug #21698.
  Added the implementations of 'subst_argument_checker'
  for the Item_func and Item_cond classes.
  This method is supposed to set its in/out argument to NULL for
  the nodes where substitution of a string field for a constant
  is not valid.
  Added the declaration of an implementation of the compile method for 
  class Item_cond.
  First it processes the Item_cond node with a callback function and if
  the latter returns TRUE it proceeds with a transformation performed by
  another callback function.
sql/item_func.cc:
  Fixed bug #21698.
  Added an implementation of the compile method for class Item_func.
  First it processes the Item_func node with a callback function and if
  the latter returns TRUE it proceeds with a transformation performed by
  another callback function.
sql/item_func.h:
  Fixed bug #21698.
  Added the declaration of the implementation of the compile method for
  class Item_func.
  First it processes the Item_func node with a callback function and if
  the latter returns TRUE it proceeds with a transformation performed by
  another callback function.
sql/sql_select.cc:
  Fixed bug #21698.
  Limited the conditions at which a field can be substituted 
  a for an equal constant in a formula. 
  This substitution is 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
unknown
22c3e7b4e1 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.
 


mysql-test/r/group_by.result:
  Adjusted results after the fix for bug #5500.
mysql-test/r/information_schema.result:
  Adjusted results after the fix for bug #5500.
mysql-test/r/olap.result:
  Adjusted results after the fix for bug #5500.
mysql-test/r/range.result:
  Adjusted results after the fix for bug #5500.
mysql-test/r/view.result:
  Added a test case for bug #5500.
  Adjusted other results.
mysql-test/r/view_grant.result:
  Adjusted results after the fix for bug #5500.
mysql-test/t/view.test:
  Added a test case for bug #5500.
2006-09-06 08:21:43 -07:00
unknown
b527a75e01 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-4.1-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B16792-4.1-opt


mysql-test/r/subselect.result:
  Auto merged
sql/sql_select.cc:
  Auto merged
2006-09-05 19:22:55 +03:00
unknown
2aeec864e2 Merge macbook.gmz:/Users/kgeorge/mysql/work/B16792-4.1-opt
into  macbook.gmz:/Users/kgeorge/mysql/work/B16792-5.0-opt


mysql-test/r/func_gconcat.result:
  Auto merged
mysql-test/r/subselect.result:
  Auto merged
sql/opt_sum.cc:
  Auto merged
mysql-test/r/func_group.result:
  merge 4.1->5.0 for bug #16792
mysql-test/t/func_group.test:
  merge 4.1->5.0 for bug #16792
sql/sql_select.cc:
  merge 4.1->5.0 for bug #16792
2006-09-05 17:09:12 +03:00
unknown
1039540807 BUG#21787: COUNT(*) + ORDER BY + LIMIT returns wrong result
Fix an error in the bug fix.


sql/sql_select.cc:
  Use a local variable to iterate over group items, since
  'group' is used later in a condition.
2006-09-04 16:53:03 +03:00
unknown
eb0cc3bf87 Merge dl145s:/data/tkatchaounov/5.0-bug-21787
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0


sql/sql_select.cc:
  Auto merged
2006-09-04 11:45:43 +02:00
unknown
b133be170a Merge lamia.home:/home/timka/mysql/src/4.1-virgin
into  lamia.home:/home/timka/mysql/src/4.1-bug-21787


sql/sql_select.cc:
  Auto merged
2006-09-01 17:21:49 +03:00
unknown
495edb59bd Merge timka@10.100.64.80:/home/timka/mysql/src/4.1-bug-21787
into  dl145s.mysql.com:/data/tkatchaounov/5.0-bug-21787


mysql-test/r/limit.result:
  Auto merged
mysql-test/t/limit.test:
  Auto merged
sql/sql_select.cc:
  Adjust the fix for BUG#21787 for 5.0
2006-09-01 14:29:27 +02:00
unknown
b017caefbd 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.


mysql-test/r/limit.result:
  Test case for BUG#21787
mysql-test/t/limit.test:
  Test case for BUG#21787
sql/sql_select.cc:
  If there is an aggregate function in a non-group query,
  materialize all rows in the temporary table no matter if
  there is a LIMIT clause. This is necessary, since the
  aggregate functions must be computed over all result rows,
  not just the first LIMIT rows.
2006-09-01 15:07:04 +03:00
unknown
a53f3d0f1a 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.


mysql-test/r/join_outer.result:
  Adjusted results after fix for bug #16081.
mysql-test/r/row.result:
  Added a test cases for bug #16081.
mysql-test/t/row.test:
  Added a test cases for bug #16081.
sql/sql_list.h:
  Corrected the copy constructor for the class base_list.
  The previous implementation resulted in creation of an
  inconsistent base_list if the source list was empty.
2006-09-01 04:23:04 -07:00
unknown
5bd9bf5572 Merge maint2.mysql.com:/data/localhome/tsmith/bk/41
into  maint2.mysql.com:/data/localhome/tsmith/bk/50


mysql-test/r/ctype_utf8.result:
  Auto merged
mysql-test/t/ctype_utf8.test:
  Auto merged
sql/net_serv.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
vio/viosocket.c:
  Auto merged
client/mysql.cc:
  Manual merge.
mysql-test/t/ctype_recoding.test:
  Manual merge.
sql/sql_lex.h:
  SCCS merged
sql/sql_table.cc:
  Manual merge.
mysql-test/r/ctype_recoding.result:
  Manual merge
2006-09-01 08:53:56 +02:00
unknown
01ec88dcd8 Merge tkatchaounov@bk-internal.mysql.com:/home/bk/mysql-5.0
into  dl145s.mysql.com:/data/tkatchaounov/autopush/5.0-bug-21456


sql/sql_select.cc:
  Auto merged
2006-08-28 16:08:48 +02:00
unknown
f121994de8 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).



mysql-test/r/select.result:
  Added a test case for bug #21390: wrong estimate of rows
  after elimination of const tables.
  Includded a test case that checks the code added by the patch
  that handles outer joins with no matches after substitution of
  a const table in an efficient way.
mysql-test/t/select.test:
  Added a test case for bug #21390: wrong estimate of rows
  after elimination of const tables.
  Included a test case that checks the code added by the patch
  that handles outer joins with no matches after substitution of
  a const table in an efficient way.
sql/sql_select.cc:
  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).
  Also added the code to handle outer joins with no matches after
  substitution of a const table in an efficient way. 
  Corrected calculation of the null rejecting key conditions.
2006-08-25 02:17:41 -07:00
unknown
e989c51d0d Merge lamia.home:/home/timka/mysql/src/4.1-virgin
into  lamia.home:/home/timka/mysql/src/4.1-bug-21456


sql/sql_select.cc:
  Auto merged
2006-08-23 18:30:21 +03:00
unknown
e3181c59e7 Merge lamia.home:/home/timka/mysql/src/4.1-bug-21456
into  lamia.home:/home/timka/mysql/src/5.0-bug-21456


mysql-test/r/distinct.result:
  Merge the fix for BUG#21456
mysql-test/t/distinct.test:
  Merge the fix for BUG#21456
sql/sql_select.cc:
  Merge the fix for BUG#21456
2006-08-23 18:22:53 +03:00
unknown
2baf2fdf13 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.


mysql-test/r/distinct.result:
  Test for BUG#21456.
mysql-test/t/distinct.test:
  Test for BUG#21456.
sql/sql_select.cc:
  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.
2006-08-23 16:46:57 +03:00
unknown
3a23139aa4 Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  sunlight.local:/local_work/16861-bug-5.0-mysql


sql/sql_select.cc:
  Auto merged
2006-08-22 17:39:18 +04:00
unknown
c623e54fb8 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.


mysql-test/r/user_var.result:
  Added a test case for bug#16861: User defined variable can have a wrong value if a tmp table was used.
mysql-test/t/user_var.test:
  Added a test case for bug#16861: User defined variable can have a wrong value if a tmp table was used.
sql/item_func.cc:
  Fixed bug#16861: User defined variable can have a wrong value if a tmp table was used.
  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.
sql/item_func.h:
  Fixed bug#16861: User defined variable can have a wrong value if a tmp table was used.
  Added a new SUSERVAR_FUNC function type.
  Updated the Item_func_set_user_var::check() function declaration.
  Added the Item_func_set_user_var::send() member function.
sql/set_var.cc:
  Fixed bug#16861: User defined variable can have a wrong value if a tmp table was used.
  Modified to use updated Item_func_set_user_var::check() function.
sql/sql_class.cc:
  Fixed bug#16861: User defined variable can have a wrong value if a tmp table was used.
  Modified to use updated Item_func_set_user_var::check() function.
sql/sql_select.cc:
  Fixed bug#16861: User defined variable can have a wrong value if a tmp table was used.
  Now an Item_func_set_user_var object isn't substituted for an Item_field object after filling a temporary table.
2006-08-22 17:37:41 +04:00
unknown
7a11df8c93 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.


mysql-test/t/type_datetime.test:
  Added a test case for bug#21475: Wrongly applied constant propagation leads to a false comparison.
mysql-test/r/type_datetime.result:
  Added a test case for bug#21475: Wrongly applied constant propagation leads to a false comparison.
sql/sql_select.cc:
  Fixed bug#21475: Wrongly applied constant propagation leads to a false comparison.
  The constant propagation mechanism now doesn't mix items used in different
  comparison contexts. The check is done in the change_cond_ref_to_const() function.
sql/item_cmpfunc.cc:
  Fixed bug#21475: Wrongly applied constant propagation leads to a false comparison.
  Now the Item_bool_func2::fix_length_and_dec() function sets the comparison
  context for items being compared.
sql/item.h:
  Fixed bug#21475: Wrongly applied constant propagation leads to a false comparison.
  To the Item class a new field called cmp_context is added.
  It represents the comparison context of an item.
sql/item.cc:
  Fixed bug#21475: Wrongly applied constant propagation leads to a false comparison.
  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() function.
2006-08-21 00:23:57 +04:00
unknown
5a76d76007 Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rurik.mysql.com:/home/igor/mysql-5.0-opt


sql/sql_select.cc:
  Auto merged
2006-08-16 10:21:23 -07:00
unknown
c8cafde703 Fixed bug #18165.
Made [NOT]BETWEEN predicates SARGable in respect to the second and 
the third arguments.


mysql-test/r/range.result:
  Added a test case to bug #18165.
mysql-test/t/range.test:
  Added a test case to bug #18165.
sql/opt_range.cc:
  Fixed bug #18165.
  Made [NOT]BETWEEN predicates SARGable in respect to the second and 
  the third arguments.
  Put in a separate function called get_full_func_mm_tree the functionality
  that builds a conjunction of all SEL_TREEs for a simple predicate of the
  form (f op c), where f was a field and c was a constant, applying different
  equalities f=f' with f' being another field.
2006-08-16 09:37:19 -07:00
unknown
c234aaa0ed Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  sunlight.local:/local_work/21261-bug-5.0-mysql


sql/sql_select.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
mysql-test/r/view.result:
  SCCS merged
mysql-test/t/view.test:
  SCCS merged
2006-08-16 18:17:58 +04:00
unknown
c55b9f5069 Merge mysql.com:/usr/home/bar/mysql-4.1
into  mysql.com:/usr/home/bar/mysql-4.1.b9509


mysql-test/r/ctype_utf8.result:
  Auto merged
mysql-test/t/ctype_utf8.test:
  Auto merged
sql/sql_select.cc:
  Auto merged
2006-08-16 09:31:24 +05:00
unknown
a23d1792bc 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.


mysql-test/t/view.test:
  Added a test case for bug#21261: Wrong access rights was required for an insert into a view
mysql-test/r/view.result:
  Added a test case for bug#21261: Wrong access rights was required for an insert into a view
sql/sql_update.cc:
  Fixed bug#21261: Wrong access rights was required for an insert into a view
  Modified to use updated setup_tables_and_check_access() function.
sql/sql_select.cc:
  Fixed bug#21261: Wrong access rights was required for an insert into a view
  Modified to use updated setup_tables_and_check_access() function.
sql/sql_load.cc:
  Fixed bug#21261: Wrong access rights was required for an insert into a view
  Modified to use updated setup_tables_and_check_access() function.
sql/sql_insert.cc:
  Fixed bug#21261: Wrong access rights was required for an insert into a view
  Modified to use updated setup_tables_and_check_access() function.
sql/sql_delete.cc:
  Fixed bug#21261: Wrong access rights was required for an insert into a view
  Modified to use updated setup_tables_and_check_access() function.
sql/sql_base.cc:
  Fixed bug#21261: Wrong access rights was required 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.
sql/mysql_priv.h:
  Fixed bug#21261: Wrong access rights was required for an insert into a view
  The setup_tables_and_check_access() function now accepts two want_access
  parameters.
2006-08-15 21:45:24 +04:00
unknown
5bf943a95d Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B21159-5.0-opt


sql/sql_select.cc:
  Auto merged
2006-08-15 12:54:02 +03:00
unknown
fd65e53a8a Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B21174-5.0-opt


sql/sql_select.cc:
  Auto merged
2006-08-15 10:31:34 +03:00
unknown
a0474a811c Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B21159-5.0-opt


sql/sql_select.cc:
  Auto merged
2006-08-15 10:25:56 +03:00
unknown
3915c3d94c 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.


mysql-test/r/compare.result:
  Bug #21159: Optimizer: wrong result after AND with different data types
   - test case
mysql-test/t/compare.test:
  Bug #21159: Optimizer: wrong result after AND with different data types
   - test case
sql/sql_select.cc:
  Bug #21159: Optimizer: wrong result after AND with different data types
   - disable const propagation for Item_hex_string.
2006-08-15 10:13:17 +03:00
unknown
6675c2c2d3 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.


mysql-test/r/group_by.result:
  Bug #21174: Index degrades sort performance and 
               optimizer does not honor IGNORE INDEX
   - test case
mysql-test/t/group_by.test:
  Bug #21174: Index degrades sort performance and 
               optimizer does not honor IGNORE INDEX
   - test case
2006-08-14 18:19:29 +03:00
unknown
06a302eff2 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;


mysql-test/r/join_outer.result:
  Bug #21302: Result not properly sorted when using an ORDER BY on a second 
              table in a join
   - don't remove columns of const tables in ORDER BY if the const table 
     is an outer table.
mysql-test/r/order_by.result:
  Bug #21302: Result not properly sorted when using an ORDER BY on a second 
              table in a join
   - test case
mysql-test/t/order_by.test:
  Bug #21302: Result not properly sorted when using an ORDER BY on a second 
              table in a join
   - test case
sql/sql_select.cc:
  Bug #21302: Result not properly sorted when using an ORDER BY on a second 
              table in a join
   - don't remove columns of const tables in ORDER BY if the const table 
     is an outer table.
2006-08-14 15:45:48 +03:00
unknown
dcb6659001 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


BitKeeper/etc/ignore:
  Added */.libs/*
include/my_global.h:
  Don't use GNUC min/max operations are they are depricated
myisam/mi_rkey.c:
  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.
myisam/mi_test_all.res:
  Updated results to match mi_test_all.sh
myisam/mi_test_all.sh:
  Removed confusing warning
mysql-test/r/myisam.result:
  Added test case for #14400
mysql-test/t/myisam.test:
  Added test case for #14400
sql/sql_select.cc:
  Fixed valgrind warning (in field_string::val_int())
2006-08-10 22:41:19 +03:00
unknown
e34496e5d8 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)


sql/ha_berkeley.cc:
  update handler::info interface to return int
sql/ha_berkeley.h:
  update handler::info interface to return int
sql/ha_heap.cc:
  update handler::info interface to return int
sql/ha_heap.h:
  update handler::info interface to return int
sql/ha_innodb.cc:
  update handler::info interface to return int
sql/ha_innodb.h:
  update handler::info interface to return int
sql/ha_myisam.cc:
  update handler::info interface to return int
sql/examples/ha_archive.cc:
  update handler::info interface to return int
sql/examples/ha_archive.h:
  update handler::info interface to return int
sql/examples/ha_example.cc:
  update handler::info interface to return int
sql/examples/ha_example.h:
  update handler::info interface to return int
sql/examples/ha_tina.cc:
  update handler::info interface to return int
sql/examples/ha_tina.h:
  update handler::info interface to return int
sql/ha_myisam.h:
  update handler::info interface to return int
sql/ha_myisammrg.cc:
  update handler::info interface to return int
sql/ha_myisammrg.h:
  update handler::info interface to return int
sql/ha_ndbcluster.cc:
  update handler::info interface to return int
sql/ha_ndbcluster.h:
  update handler::info interface to return int
sql/handler.h:
  update handler::info interface to return int
sql/opt_sum.cc:
  If we get an error when using handler::info to get count(*),
  print and return the error.
sql/sql_select.cc:
  if error, set fatal error.
2006-08-10 22:55:20 +08:00
unknown
d3dd6fa008 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.


mysql-test/r/func_gconcat.result:
  Bug #16792 query with subselect, join, and group not returning proper values
   - test case. Note how it improves the support for DUAL.
mysql-test/r/func_group.result:
  Bug #16792 query with subselect, join, and group not returning proper values
   - test case. Note how it improves the support for DUAL.
mysql-test/r/subselect.result:
  Bug #16792 query with subselect, join, and group not returning proper values
   - consequence of (SELECT MAX(<const>)) now returning <const> instead of 0
mysql-test/t/func_group.test:
  Bug #16792 query with subselect, join, and group not returning proper values
   - test case.
sql/opt_sum.cc:
  Bug #16792 query with subselect, join, and group not returning proper values
   - cannot do the optimization if the index is already opened by (say) UPDATE
     as it invloves opening reading and closing the index.
sql/sql_select.cc:
  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.
2006-08-10 16:45:02 +03:00
unknown
c102fe94ad Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0
into  moonbone.local:/work/tmp_merge-5.0-opt-mysql


client/mysql.cc:
  Auto merged
mysql-test/r/date_formats.result:
  Auto merged
mysql-test/r/func_str.result:
  Auto merged
mysql-test/t/date_formats.test:
  Auto merged
mysql-test/t/func_str.test:
  Auto merged
mysql-test/t/udf.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/field.h:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/time.cc:
  Auto merged
mysql-test/r/sp.result:
  Manual merge
mysql-test/t/sp.test:
  Manual merge
2006-08-02 16:44:56 +04:00
unknown
84ece59cef Merge moonbone.local:/work/tmp_merge-4.1
into  moonbone.local:/work/tmp_merge-4.1-opt-mysql


sql/item_strfunc.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
2006-08-02 16:10:52 +04:00
unknown
45871dbfd9 select.result, func_group.result, sql_select.cc:
After merge fix


mysql-test/r/select.result:
  After merge fix
mysql-test/r/func_group.result:
  After merge fix
sql/sql_select.cc:
  After merge fix
2006-07-31 23:05:54 +04:00
unknown
08be4e96a9 Merge sunlight.local:/local_work/tmp_merge-4.1-opt-mysql
into  sunlight.local:/local_work/tmp_merge-5.0-opt-mysql


mysql-test/t/select.test:
  Auto merged
sql/sql_select.cc:
  Auto merged
mysql-test/r/func_group.result:
  Manual merge
mysql-test/r/select.result:
  Manual merge
mysql-test/r/subselect.result:
  Manual merge
2006-07-29 23:59:53 +04:00
unknown
74214b8635 Merge moonlight.intranet:/home/tomash/src/mysql_ab/tmp_merge
into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-merge


configure.in:
  Auto merged
man/Makefile.am:
  Auto merged
mysys/my_bitmap.c:
  Auto merged
scripts/make_binary_distribution.sh:
  Auto merged
sql/field.cc:
  Auto merged
sql/sql_locale.cc:
  Auto merged
support-files/mysql.spec.sh:
  Auto merged
mysql-test/t/mysqlbinlog.test:
  Manual merge.
sql/sql_select.cc:
  Manual merge.
2006-07-29 13:43:34 +04:00
unknown
8d73c0b392 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


sql/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)
extra/yassl/taocrypt/src/asn.cpp:
  Avoid name clash with NAME_MAX
extra/yassl/taocrypt/include/asn.hpp:
  Avoid name clash with NAME_MAX
2006-07-28 21:26:46 +02:00
unknown
667c73be65 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B21019-5.0-opt


sql/sql_select.cc:
  Auto merged
2006-07-27 10:11:13 +03:00
unknown
9c7a329eba Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-4.1-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B20792-4.1-opt


sql/sql_select.cc:
  Auto merged
2006-07-27 10:06:37 +03:00
unknown
d81d6e7430 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B20792-5.0-opt


sql/sql_select.cc:
  Auto merged
2006-07-27 10:05:03 +03:00
unknown
1150869c4a item_func.h, item_func.cc, sql_select.cc, item.h:
Post review changes for bug#19862.


sql/sql_select.cc:
  Post review changes for bug#19862.
sql/item_func.h:
  Post review changes for bug#19862.
sql/item_func.cc:
  Post review changes for bug#19862.
sql/item.h:
  Post review changes for bug#19862.
2006-07-26 21:36:03 +04:00
unknown
bb81f6ac2d Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-4.1-opt
into  rakia.(none):/home/kgeorge/mysql/autopush/B20792-4.1-opt


sql/sql_select.cc:
  Auto merged
2006-07-26 19:55:33 +03:00
unknown
c7c8c33c5b Merge macbook.gmz:/Users/kgeorge/mysql/work/B20792-4.1-opt
into  macbook.gmz:/Users/kgeorge/mysql/work/B20792-5.0-opt


mysql-test/r/subselect2.result:
  Auto merged
sql/sql_select.cc:
  Auto merged
2006-07-26 19:23:44 +03:00
unknown
6b75e24b73 * 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.


mysql-test/r/subselect2.result:
  * Bug #20792: Incorrect results from aggregate subquery
   - test suite for the bug. This is dependent on InnoDB despite
     the fact that the bug and the fix are not InnoDB specific.
     This is because of the table flag HA_NOT_EXACT_COUNT.
     When this flag is off (as in MyISAM) both t2 and t3 become of
     join type 'system' as they are estimated to have 1 record and
     and this statistics can be trusted (according to the absence of
     HA_NOT_EXACT_COUNT).
mysql-test/t/subselect2.test:
  * Bug #20792: Incorrect results from aggregate subquery
   - test suite for the bug
sql/sql_select.cc:
  * Bug #20792: Incorrect results from aggregate subquery
   - when clearing results if there are not rows found for group
     the const tables must not be reset as they are not recalculated
     for each group.
2006-07-26 19:19:30 +03:00