Commit graph

27627 commits

Author SHA1 Message Date
Sergey Petrunya
0a5026b057 Merge fix for BUG#779885 2011-05-11 08:52:16 +01:00
Sergey Petrunya
30575353b6 BUG#779885: Crash in eliminate_item_equal with materialization=on in maria-5.3
- In eliminate_item_equal(), we could end up in a situation where:
  = The multiple equality has a constant C1 (and so it is the "head item")
  = The join order was such that we've generated "sj_inner_table1=C1" equality,
    and now are looking to generate "sj_inner_table2_=..." equality. 
  When looking for what should be the other member of equality, we run

      Item *head_item= current_sjm? current_sjm_head: head;
  
  which sees current_sjm!=NULL, and takes current_sjm_head (which is NULL because 
  the constant C1 is the head for all cases).

- Fixed in a trivial way: take current_sjm_head if we don't have constant.
2011-05-10 21:59:51 +01:00
unknown
a55b1165d2 MWL#89 - Automatic merge with 5.3 2011-05-10 18:28:05 +03:00
Michael Widenius
e843297d12 Fixed compiler warnings 2011-05-08 13:26:07 +03:00
unknown
183d6b7025 Merge MWL#180 into main MariaDB 5.3. 2011-05-07 15:48:45 +02:00
unknown
9789c94349 MWL#180: Merge bugfix from 5.2 to 5.3 codebase + really fix version from which mariadb supports binlog checksums. 2011-05-05 16:35:02 +02:00
unknown
4337aa74e3 MWL#180: Fix bug where setting @@global.binlog_checksum did not actually change the value. 2011-05-05 16:32:20 +02:00
unknown
ee3b7b56e4 Fix LP BUG#772309
Analysis:
The method st_select_lex::optimize_unflattened_subqueries()
incorrectly propagated to each subquery the complete
select_options flag set for the whole query. Among other
flags in select_options, this propagated incorrectly the
STRAIGHT_JOIN flag from the upper query to the subquery.

Solution:
During EXPLAIN set only the SELECT_DESCRIBE bit in the
select_options of the subquery.
2011-05-05 15:24:28 +03:00
Igor Babaev
20c9084deb Fixed LP bug #776295.
If the value of the flag cond_false of an Item_equal object is
true then the print method must return the string '0'.
2011-05-04 18:08:44 -07:00
unknown
879f25dc64 MWL#89
Merge with main 5.3
2011-05-05 00:35:21 +03:00
Igor Babaev
e3e2358fd2 Fixed LP bug #751350.
The third parameter in the call of make_cond_for_table() that
built the pushed condition containing only outer references
was incorrect. This condition appeared for the first time in
the patch fixing bug 729039.
2011-05-04 11:23:29 -07:00
unknown
c7f0fd6592 Automatic merge with 5.3 2011-05-04 12:00:18 +03:00
Igor Babaev
aaf9fb0de7 Fixed LP bug #776274,
The bug was introduced by the patch that fixed bug 717577.
2011-05-03 17:11:45 -07:00
unknown
284f52476c Merge MWL#180, binlog checksum backport, into MariaDB 5.3-based tree. 2011-05-03 14:44:25 +02:00
unknown
014b8e7f43 Backport MySQL WL#2540 into MariaDB.
Patch backported:

bzr diff
'-rrevid:alfranio.correia@oracle.com-20101121143257-se3vpqus73l4mum0
..revid:luis.soares@oracle.com-20101124111752-9b8260bd1qak87hr'
--old=lp:mysql-server --new=lp:mysql-server
2011-05-03 14:01:11 +02:00
unknown
5dc11616b2 MWL#89
Merge with 5.3
2011-05-02 21:59:16 +03:00
Igor Babaev
80b0b300f6 Merge 2011-04-29 19:20:46 -07:00
Michael Widenius
2721e912ba Added ALTER ONLINE TABLE, which will give an error if the change can't be done 'instantly' (without a table copy)
mysql-test/r/alter_table_online.result:
  Test new feature
mysql-test/t/alter_table_online.test:
  Test new feature
sql/handler.cc:
  Added comment
sql/lex.h:
  Added ONLINE keyword
sql/mysql_priv.h:
  Added option to alter table to require online operation
sql/share/errmsg.txt:
  Added error message if ONLINE can't be done
sql/sql_lex.h:
  Added online option
sql/sql_parse.cc:
  Added online option to mysql_alter_table()
sql/sql_table.cc:
  Added test that gives error if table can't be done instantly when requsted to be online.
  Fixed wrong test if table includes a VARCHAR
  Fixed wrong (but unlikely) handling of error conditions in ALTER table
sql/sql_yacc.yy:
  Added ALTER ONLINE TABLE syntax
storage/maria/ha_maria.cc:
  Fixed bug where 'start_bulk_insert' used too small buffer if used with unknown number of rows
2011-04-28 19:56:10 +03:00
Michael Widenius
6da8ac5f71 Added option "AND DISABLE CHECKPOINT" to "FLUSH TABLES WITH READ LOCK"
This makes it possible to do safe multi volume snapshots as long as one snapshots the volume with the transaction logs last.


include/mysql_com.h:
  Added REFRESH_CHECKPOINT
mysql-test/r/flush.result:
  Added test of new FLUSH TABLES syntax + calls to checkpoint_status handler calls
mysql-test/t/flush.test:
  Added test of new FLUSH TABLES syntax + calls to checkpoint_status handler calls
sql/handler.cc:
  Added code to call checkpoint_state for all handlertons that supports it
sql/handler.h:
  Added new checkpoint_state() handlerton call to temporarly disable checkpoints.
sql/lex.h:
  Added CHECKPOINT keyword
sql/sql_yacc.yy:
  Added support for FLUSH TABLES WITH READ LOCK AND DISABLE CHECKPOINT
storage/maria/ha_maria.cc:
  Added handlerton call to disable checkpoints.
storage/maria/ma_checkpoint.c:
  Don't do checkpoint if checkpoints are disabled.
storage/maria/ma_static.c:
  Added maria_checkpoint_disabled
storage/maria/maria_def.h:
  Added maria_checkpoint_disabled
storage/xtradb/handler/ha_innodb.cc:
  Added handlerton call to disable checkpoints.
storage/xtradb/include/log0log.h:
  Added option to log_checkpoint() to allow one to ignore not critical checkpoints during the time checkpoints are disabled.
storage/xtradb/log/log0log.c:
  Added code to allow one to disable checkpoints during a FLUSH TABLES ... DISABLE CHECKPOINT
  This was done by adding a new argument to log_checkpoint() which tells us when the checkpoint is called by srv_master_thread (which are safe to ignore)
storage/xtradb/srv/srv0srv.c:
  Tell log_checkpoint() that checkpoints from srv_master_thread() are safe to ignore (will just delay recovery time a bit).
2011-04-28 18:02:26 +03:00
unknown
0f4236659c Fix LP BUG#718593
Analysis:
Build_equal_items_for_cond() rewrites the WHERE clause in such a way,
that it may merge the list join->cond_equal->current_level with the
list of child Items in an AND condition of the WHERE clause.

The place where this is done is:
static COND *build_equal_items_for_cond(THD *thd, COND *cond,
                                        COND_EQUAL *inherited)
{
  ...
      if (and_level)
    {
      args->concat(&eq_list);
      args->concat((List<Item> *)&cond_equal.current_level);
    }
  ...
}

As a result, later transformations on the WHERE clause may change the
structure of the list join->cond_equal->current_level without knowing this.

Specifically in this bug, Item_in_subselect::inject_in_to_exists_cond
creates a new AND of the old WHERE clause and the IN->EXISTS conditions.
It then calls fix_fields() for the new AND. Among other things, fix_fields
flattens all nested ANDs into one by merging the AND argument lists.

When there is a cond_equal for the JOIN, its list of Item_equal objects
is attached to the end of the original AND. When a lower-level AND is
merged into the top-level one, the argument list of the lower-level AND
is concatenated to the list of multiple equalities in the upper-level AND.

As a result, when substitute_for_best_equal_field processes the 
multiple equalities, it turns out that the multiple equality list contains
the Items from the lower-level AND which were concatenated to the end of
the join->cond_equal->current_level list. This results in a crash because
this list must not contain any other Items except for the previously found
Item_equal ones.

Solution:
When performing IN->EXIST predicate injection, and the where clause is an
AND, detach the list of Item_equal objects before calling fix_fields on
the injected where clause.

After fix_fields is done, reattach back the multiple equalities list to
the end of the argument list of the new AND.
2011-04-28 17:15:05 +03:00
Igor Babaev
1556a136ac Fixed LP bug #754521.
The function test_quick_select by mistake did not update the value
of table->quick_condition_rows for index intersection scans though
the specification explicitly required to do so from any table access
plan once the plan provided a better upper bound for the number of
rows selected from the table. It resulted in a bogus, usually very
big number saved as the cost of the table access. This, in its turn,
in many cases forced the optimizer to make a bad choice of the
execution plan for join queries.
2011-04-27 15:29:46 -07:00
Igor Babaev
24edac2211 Merge 2011-04-26 21:11:06 -07:00
Igor Babaev
8d9dd21d85 Fixed LP bugs #717577, #724942.
Both these two bugs happened due to the following problem.
When a view column is referenced in the query an Item_direct_view_ref
object is created that is refers to the Item_field for the column.
All references to the same view column refer to the same Item_field.
Different references can belong to different AND/OR levels and,
as a result, can be included in different Item_equal object.
These Item_equal objects may include different constant objects.
If these constant objects are substituted for the Item_field created
for a view column we have a conflict situation when the second
substitution annuls the first substitution. This leads to
wrong result sets returned by the query. Bug #724942 demonstrates
such an erroneous behaviour.
Test case of the bug #717577 produces wrong result sets because best
equal fields of the multiple equalities built for different OR levels
of the WHERE condition differs. The subsitution for the best equal field
in the second OR branch overwrites the the substitution made for the
first branch.

To avoid such conflicts we have to substitute for the references
to the view columns rather than for the underlying field items.
To make such substitutions possible we have to include into
multiple equalities references to view columns rather than 
field items created for such columns.

This patch modifies the Item_equal class to include references
to view columns into multiple equality objects. It also performs
a clean up of the class methods and adds more comments. The methods
of the Item_direct_view_ref class that assist substitutions for
references to view columns has been also added by this patch.
2011-04-26 19:58:41 -07:00
Igor Babaev
79439d9a74 Fixed LP bug #752353.
In some cases the field max_part_no of the SEL_ARG structure
was not initialized. That triggered a Valgrind complain.
2011-04-20 15:30:21 -07:00
unknown
43acceeb47 Fix LP BUG#715069
Analysis:
The wrong result is a consquence of sorting the subquery
result and then selecting only the first row due to the
artificial LIMIT 1 introduced by the fix_fields phase.
Normally, if there is an ORDER BY in a subquery, the ORDER
is removed (Item_in_subselect::select_in_like_transformer),
however if a GROUP BY is transformed into ORDER, this happens
later, after the removal of the ORDER clause of subqueries, so
we end up with a subquery with an ORDER clause, and an artificially
added LIMIT 1.

The reason why the same works in the main 5.3 without MWL#89, is
that the 5.3 performs all subquery transformations, including
IN->EXISTS before JOIN::optimize(). The beginning of JOIN::optimize
does:
  if (having || (select_options & OPTION_FOUND_ROWS))
    select_limit= HA_POS_ERROR;
which sets the limit back to infinity, thus 5.3 sorts the whole
subquery result, and IN performs the lookup into all subquery result
rows.

Solution:
Sorting of subqueries without LIMIT is meaningless. Since LIMIT in
subqueries is not supported, the patch removes sorting by setting
  join->skip_sort_order= true
for each subquery JOIN object. This improves a number of execution
plans to not perform unnecessary sorting at all.
2011-04-20 18:36:55 +03:00
unknown
64e43e1cc8 Merge various replication-related patches into MariaDB 5.3:
- MWL#116 Group commit
 - MWL#136 Enhancements for START TRANSACTION WITH CONSISTENT SNAPSHOT
 - MWL#47 Annotate_rows_log_event
 - MWL#163 innodb_release_locks_early
 - Percona patch enhancing row-based replication for tables with no primary key
2011-04-08 09:39:33 +02:00
Vladislav Vaintroub
8b427b7d55 merge 2011-04-08 02:54:01 +02:00
Vladislav Vaintroub
ad7b636d72 fix CRLF line endings to LF 2011-04-08 01:42:47 +02:00
Vladislav Vaintroub
3fdd009990 Fix SQL syntax error when running mysql --bootstrap. 2011-04-08 01:41:07 +02:00
Sergey Petrunya
acc161d363 BUG#752992: Wrong results for a subquery with 'semijoin=on'
- Let advance_sj_state() save the value of JOIN::cur_dups_producing_tables
  in POSITION::prefix_dups_producing_tables, and restore_sj_state() restore
  it.
2011-04-08 02:12:03 +04:00
unknown
86008e0ca2 Fix merge error. 2011-04-07 17:21:22 +02:00
unknown
c359daaa17 Merge --binlog_optimize_thread_scheduling into mariadb-5.2-rpl. 2011-04-04 15:18:43 +02:00
Sergey Petrunya
2a498b393a Merge: Make EXPLAIN better at displaying MRR/BKA 2011-04-04 12:38:08 +04:00
Sergey Petrunya
d4ce827226 Amend the previous cset:
Make EXPLAIN better at displaying MRR/BKA:
- Update all .result files
- Extra comments
2011-04-04 12:32:52 +04:00
Vladislav Vaintroub
aa2b482ec4 Fix error in "make dist" (sql/CMakeLists.txt is not delivered in source distribution) 2011-04-03 20:56:47 +02:00
Sergey Petrunya
997445bc8e Make EXPLAIN better at displaying MRR/BKA:
- "Using MRR" is no longer shown with range access.
- Instead, both range and BKA accesses will show one of the following:
  = "Rowid-ordered scan"
  = "Key-ordered scan"
  = "Key-ordered Rowid-ordered scan"
depending on whether DS-MRR implementation will do scan keys in order, rowids in order,
or both.
- The patch also introduces a way for other storage engines/MRR implementations to
  pass information to EXPLAIN output about the properties of employed MRR scans.
2011-04-02 14:04:45 +04:00
unknown
c677fea7d0 Merge MariaDB 5.2.5 release into MariaDB-5.2-rpl. 2011-04-01 15:07:10 +02:00
unknown
619a16bffc MWL#89
- Auto-merge with 5.3 main.
- Changed the test for LP BUG#719198 so that
  an two more queries were added, and removed a
  query that produces a wrong result due to an
  unrelated problem. The wrong result is submitted
  as a separate bug.
2011-04-01 15:42:59 +03:00
Michael Widenius
d5adc29d1c Fixed compiler warnings
sql/key.cc:
  Fixed compiler warnings about not initialized variables
2011-04-01 12:04:59 +03:00
unknown
09bd289497 Merge MWL#136 after-review fixes into mariadb-5.2-rpl 2011-04-01 10:25:45 +02:00
unknown
6c8a23c8d7 MWL#136 after-review fixes. 2011-04-01 10:12:59 +02:00
Michael Widenius
ff650ab048 Automatic merge 2011-03-31 18:35:57 +03:00
Michael Widenius
fc5953250b Fixed unlikely reference to freed memory in item->print().
sql/item.cc:
  If a item_ref is referenced by name, we have to reset it's ref in item_ref::cleanup() as the reference may be to a memory that is freed.
  This happens at least when you have 'HAVING MAX()' in a sub query and you execute 'cond_having->print()' which tries to access items before fix fields.
sql/item.h:
  Added 'reference_trough_name' as a marker for Item_ref that needs to have ref reset during cleanup
2011-03-31 18:30:05 +03:00
unknown
92dfbd4242 Merge MWL#116 after-review fixes. 2011-03-31 15:32:04 +02:00
Michael Widenius
1ee94dc2f7 Fixed all BUILD scripts to use g++ instead of gcc for linking
Fixed memory leak from HEAP tables that was not deleted properly


BUILD/compile-alpha-ccc:
  Use g++ instead of gcc for linking
BUILD/compile-alpha-debug:
  Use g++ instead of gcc for linking
BUILD/compile-pentium-pgcc:
  Use g++ instead of gcc for linking
BUILD/compile-solaris-sparc:
  Use g++ instead of gcc for linking
BUILD/compile-solaris-sparc-debug:
  Use g++ instead of gcc for linking
BUILD/compile-solaris-sparc-purify:
  Use g++ instead of gcc for linking
sql/item.cc:
  Safety fixes for expr_cache
  Call Item_result:field::cleanup() in Item_cache_wrapper::cleanup()
  More DBUG_PRINT
sql/sql_base.cc:
  Simple optimization for setup_wild
  More DBUG_PRINT
sql/sql_expression_cache.cc:
  Added header
  Removed not needed initialization
sql/sql_lex.cc:
  More DBUG_PRINT
sql/sql_select.cc:
  More DBUG_PRINT
  Fixed memory leak from HEAP tables that was not deleted properly
storage/heap/hp_create.c:
  More DBUG_PRINT
2011-03-31 16:26:51 +03:00
unknown
bc9f6021ff MWL#116: After-review fixes. 2011-03-31 14:29:23 +02:00
Vladislav Vaintroub
f2f5fd36c0 merge LP BUG#68606 2011-03-30 23:34:48 +02:00
Michael Widenius
6f20e3a385 Fixed problem that fill_record() allocated memory for every call. This could be a problem when doing big unions as memory could be filled up.
sql/sql_base.cc:
  Don't allocate memory in fill_record().
  Fix was to remove the list of tables. This was not necessary as this call is only used with one table.
2011-03-30 19:20:22 +03:00
Michael Widenius
309e016eec Fixes to get more information about random bind failure in pushbuild for windows hosts.
mysql-test/mysql-test-run.pl:
  Set port-open-timeout to 10 to retry binds
sql/mysqld.cc:
  Write error number for bind failure. (perror can't do that on windows as errno dosn't contain error code)
2011-03-30 12:15:58 +03:00
unknown
3d8aa98c71 MWL#89
Merge 5.3 with 5.3-mwl89.
2011-03-30 11:38:57 +03:00