Commit graph

27980 commits

Author SHA1 Message Date
Igor Babaev
3cf0d6f446 Fixed LP bug #800518.
The function simple_pred did not take into account that a multiple equality
could include ref items (more exactly items of the class Item_direct_view_ref).
It caused crashes for queries over derived tables or views if the
min/max optimization could be applied to these queries.
2011-06-23 14:48:45 -07:00
Igor Babaev
e7578ac612 Fixed LP bug #798621.
The patch for bugs 717577 and 724942 has missed to make adjustments for the
call item_equal->add_const(const_item, orig_field_item) in the function
check_simple_equality that builds multiple equality for a field and a constant.
As a result, when this field happens to be a view field and the corresponding
Item_field object F is wrapped in an Item_direct_view_ref object R the object
F is placed in the multiple equality instead of the object R.
A substitution of an equal item for F potentially can cause very serious
problems and in some cases can lead to crashes of the server.
2011-06-21 18:00:58 -07:00
unknown
44570d2b12 MWL#89
Automerged with 5.3.
2011-06-21 16:00:41 +03:00
unknown
a02682abcc MWL#89
- Added regression test with queries over the WORLD database.
- Discovered and fixed several bugs in the related cost calculation
  functionality both in the semijoin and non-semijon subquery code.
- Added DBUG printing of the cost variables used to decide between
  IN-EXISTS and MATERIALIZATION.
2011-06-21 15:50:07 +03:00
Sergey Petrunya
a0973ba22e Merge fix for BUG#778406. 2011-06-17 17:45:41 +04:00
Igor Babaev
078b59f5bc Merge of mwl #106 into 5.3. 2011-06-15 21:48:38 -07:00
Sergey Petrunya
bce51cebcb BUG#778406: Crash in hp_movelink with Aria engine and subqueries
-In  do_sj_dups_weedout(), set nulls_ptr to point to NULL bytes (and not to length bytes) of the DuplicateWeedout column.
2011-06-15 18:37:01 +04:00
Sergei Golubchik
54d0ec5732 fix for cast of negative numbers to datetime 2011-06-14 18:45:14 +02:00
Sergey Petrunya
b8fdbf8874 Remove redundant code that is a result of a wrong merge.
(Changeset sp1r-igor@olga.mysql.com-20070526173301-38848 moved this loop from one place 
to another, then the merge of sp1r-gshchepa/uchum@gleb.loc-20070527192244-26330  have 
kept both copies).
2011-06-13 12:41:19 +04:00
Sergey Petrunya
0f22ba3cfe In make_join_select():
- move attempt to evaluate join->exec_const_cond() out of the "Extract constant part of each ON expression" loop
  (it got there by mistake when merging).
2011-06-12 00:35:53 +04:00
Michael Widenius
9f6f04360a Merge with Sergei's tree to get in latest microsecond patches and also fixes to innodb_plugin. 2011-06-11 12:04:42 +03:00
Michael Widenius
6d8d6afb64 Merge with main 5.3 2011-06-11 11:09:17 +03:00
Sergei Golubchik
49874ff827 more buildbot fixes 2011-06-10 21:15:13 +02:00
Sergei Golubchik
f1a5c49c4e various fixes for buildbot failures 2011-06-10 15:42:55 +02:00
Michael Widenius
3516b4b5d1 Merge with 5.2 2011-06-10 12:09:21 +03:00
Sergey Petrunya
9c11646fcd [No BUG#] end_tab_idx==-1 passed as parameter to JOIN::get_partial_cost_and_fanout()
- Handle the case when the subquery's join is degenerate and so has zero tables.
2011-06-10 12:36:06 +04:00
Sergei Golubchik
10fedf675a change test_if_equality_guarantees_uniqueness()
from an ad hoc set of limitations
to a correct rule
2011-06-10 10:14:20 +02:00
Michael Widenius
13f55aac67 A bit better fix for tmp-table problem
Fixed reference to not initialized memory detected by valgrind

sql/sql_select.cc:
  A bit better fix for tmp-table problem:
  Use only dynamic_record format for group by and distinct.
storage/maria/ma_create.c:
  DYNAMIC_RECORD format doesn't pack VARCHAR fields.
  This change fixes a non-fatal uninitialized memory copy.
2011-06-10 02:02:58 +03:00
Igor Babaev
ab411f8f1c Fixed LP bug #794909.
The function generate_derived_keys did not take into account the fact
that the last element in the array of keyuses could be just a barrier
element. In some cases it could lead to a crash of the server.

Also fixed a couple of other bugs in generate_derived_keys: the inner 
loop in the body of if this function did not change the cycle variables
properly.
2011-06-09 12:43:28 -07:00
Michael Widenius
97e834e151 Use dynamic row format when creating temporary tables without sumary fields.
The reason for this is that BLOCK_RECORD format is not good when there is a lot of duplicated keys as it first writes the data (to get the row position) and
then writes the key (and thus checks for duplicates).
2011-06-09 20:22:03 +03:00
Sergei Golubchik
fdfeb4bea3 small optimization in Field_time_hires.
Fix Field_time_hires::reset()
2011-06-09 18:06:29 +02:00
Sergei Golubchik
c3f665dc66 bugfixes:
microsecond(TIME)
  alter table datetime<->datetime(6)
  max(TIME), mix(TIME) 

mysql-test/t/func_if.test:
  fix the test case of avoid overflow
sql/field.cc:
  don't use make_date() and make_time()
sql/field.h:
  correct eq_def() for temporal fields
sql/item.cc:
  move datetime caching from Item_cache_int
  to Item_cache_temporal
sql/item.h:
  move datetime caching from Item_cache_int
  to Item_cache_temporal
sql/item_func.cc:
  use existing helper methods, don't duplicate
sql/item_sum.cc:
  argument cache must use argument's cmp_type, not result_type.
sql/item_timefunc.cc:
  use existing methods, don't tuplicate.
  remove unused function.
  fix micorseconds() to support TIME argument
sql/mysql_priv.h:
  dead code
sql/time.cc:
  dead code
2011-06-09 17:23:39 +02:00
Michael Widenius
3600e6b81c Fixed problem that global status variables 'bytes_recieved' and 'binlog_bytes_written' where not correctly updated 2011-06-09 16:17:45 +03:00
Michael Widenius
60bd2133d7 Fixed compile failure when we don't use system zlib
Fixed crash when setting query_cache_type to 0.

client/Makefile.am:
  Added zlib include (needed by checksum.c)
sql/set_var.cc:
  Updated call to disable_query_cache()
sql/sql_cache.cc:
  Don't give warning if we start mysqld with --query_cache_type=0 --query_cache-size=0
  Fixed crash when setting query_cache_type to 0 (we shouldn't call query_cache.disable_query_cache() when there is no current_thd)
sql/sql_cache.h:
  Added THD to disable_query_cache()
2011-06-09 13:35:01 +03:00
Igor Babaev
7f345153f9 Fixed LP bug #794038.
INSERT/UPDATE/DELETE statement that used a temptable view v1 could lead to
a crash if v1 was defined as a select from a mergeable view v2 that selected
rows from a temptable view v3. 
 
When INSERT/UPDATE/DELETE uses a view that is not updatable then field
translation for the view should be created before the prepare phase.
2011-06-09 00:13:00 -07:00
Sergei Golubchik
9b98cae4cc merge with 5.1-micro 2011-06-07 18:13:02 +02:00
Michael Widenius
8d7f810894 Upgraded to latest handlersocket code. This fixed LP:766870 "Assertion `next_insert_id == 0' failed with handlersocket"
sql/handler.cc:
  Added DBUG_ code
2011-06-07 14:19:49 +03:00
Michael Widenius
2740edcf56 Fixed that mysqld --no-defaults --help --verbose doesn't give a lot of irrelevant error messages.
sql/mysql_priv.h:
  Make opt_help global
sql/mysqld.cc:
  Don't give (double) warnings about lower case file systems if --help is given.
  Don't give warning about non existing data directory if --help is given.
sql/sql_plugin.cc:
  Give a better warning if --help is used and plugin table doesn't exists
2011-06-07 10:54:37 +03:00
Michael Widenius
370f79e389 Fixed strict alias problem by replacing = with memcpy() 2011-06-07 10:29:08 +03:00
Igor Babaev
059aff15cd Fixed LP bug #784441.
The code that added semi-join transformations missed checking
the state of the fixed flag for the items built with the
and_items function before calls of the fix_fields method.
This could lead to an abort failure when the first argument
of and_items() happened to be NULL.
2011-06-06 15:50:46 -07:00
Igor Babaev
db0c340601 Fixed LP bug #793436.
When looking for the execution plan of a derived table to be materialized
JOIN::optimize finds  out that all joined tables of the derived table
contain not more than one row then the derived table should be maretialized
at the optimization stage.
Added a test case for the bug.
Adjusted results in other test cases.
2011-06-06 12:19:35 -07:00
Sergei Golubchik
4d128777dd revert a suggested "optimization" that introduced a bug
compilation error in mysys/my_getsystime.c fixed
some redundant code removed
sec_to_time, time_to_sec, from_unixtime, unix_timestamp, @@timestamp now
  use decimal, not double for numbers with a fractional part.
purge_master_logs_before_date() fixed
many bugs in corner cases fixed

mysys/my_getsystime.c:
  compilation failure fixed
sql/sql_parse.cc:
  don't cut corners. it backfires.
2011-06-06 20:28:15 +02:00
Michael Widenius
7e04f7c8fb Fixed that SHOW COLUMNS for a virtual persistent column shows 'PERSISTENT' instead of 'VIRTUAL'
Strict mode now gives error if one tries to update a virtual column.

mysql-test/suite/vcol/r/vcol_column_def_options_innodb.result:
  Updated test results
mysql-test/suite/vcol/r/vcol_column_def_options_myisam.result:
  Updated test results
mysql-test/suite/vcol/r/vcol_keys_innodb.result:
  Updated test results
mysql-test/suite/vcol/r/vcol_keys_myisam.result:
  Updated test results
mysql-test/suite/vcol/r/vcol_misc.result:
  Added new test for 'show columns' and error handling when trying to update a virtual column.
mysql-test/suite/vcol/t/vcol_misc.test:
  Added new test for 'show columns' and error handling when trying to update a virtual column.
sql/sql_base.cc:
  Strict mode now gives error if one tries to update a virtual column.
sql/sql_show.cc:
  Show PERSISTENT instead of VIRTUAL for persistent columns.
2011-06-06 17:25:01 +03:00
Michael Widenius
6ae42b75b8 Fixed lock sorting and lock check issues with thr_lock that caused warnings when running test suite.
Safety check that could cause core dump when doing create table with virtual column.

mysql-test/mysql-test-run.pl:
  Show also warnings from thr_lock (which starts with just Warning, not Warning:)
mysql-test/r/lock.result:
  Added test that showed not relevant warning when using table locks.
mysql-test/t/lock.test:
  Added test that showed not relevant warning when using table locks.
mysys/thr_lock.c:
  Fixed sorting of locks.
  (Old sort code didn't handle case where TL_WRITE_CONCURRENT_INSERT must be sorted before TL_WRITE)
  Added more information to check_locks warning output.
  Fixed wrong testing of multiple different write locks for same table.
sql/item_cmpfunc.cc:
  Safety check that could cause core dump when doing create table with virtual column.
2011-06-06 16:39:06 +03:00
Igor Babaev
3bf08e549a Added two new flags for the optimizer switch:
'derived_merge':
  - if the flag is off then all derived tables are materialized
  - if the flag is on then mergeable derived tables are merged
'derived_with_keys':
  - if the flag is off then no keys are created for derived tables
  - if the flag is on then for any derived table a key to access 
    the derived table may be created.

Now by default both flags are on.
Later the default values for the flags will be off to comply with
the current behaviour of mysql-5.1. 

Uncommented previously commented out test case from parts.partition_repair_myisam
after having added an explicit requirement to materialize the derived
table used in the test case.
2011-06-05 21:54:25 -07:00
Igor Babaev
f03a3ee54f Merged the code of mwl 106 into the latest 5.3 with mwl 90 pushed.
Resolved all conflicts and failures.
2011-06-04 19:56:06 -07:00
Igor Babaev
35c35858f8 Fixed bugs causing failures fot the funcs_1 test suite.
Uncommented the failing test cases.

Commented out the failing test case from parts.partition_repair_myisam.test.
The test case has to be changed to bear the same semantics as before mwl106.
2011-06-03 21:44:37 -07:00
Sergey Petrunya
f0f2ec3086 Buildbot fixes:
- make sp.test work both with and without query_cache (attempt 2)
- fix compile warning in make_sort_key(), as directed by SergeiG
2011-06-03 21:45:24 +04:00
Vladislav Vaintroub
668d79e87c Fixed compiler warning in central header file mysql_priv.h. 2011-06-03 15:06:13 +02:00
Sergey Petrunya
3fa0c9f468 Merge 2011-06-03 09:38:59 +04:00
Igor Babaev
33c8796beb Merge 2011-06-02 17:33:08 -07:00
Sergey Petrunya
9482e387e6 Change optimizer_use_mrr=auto|disable|force
to be optimizer_switch flags mrr=on|off and mrr_cost_based=on|off.
2011-06-03 00:25:58 +04:00
Sergey Petrunya
ebb130b189 BUG#787299: Valgrind complains on a join query with two IN subqueries
- Don't attempt to construct FirstMatch access method if we've 
  just figured three lines above that it can't be used (because join
  prefix doesn't have the needed tables), and so have set 
    pos->first_firstmatch_table= MAX_TABLES 
  Attempts to analyze join->positions[MAX_TABLES] caused valgrind warnings
2011-06-02 23:48:33 +04:00
Oleksandr Byelkin
dd3b27834c Fix of privilege problem in views and PS
sql/sql_base.cc:
  Column for views should be looked in views (not in underlying table)
sql/sql_parse.cc:
  if we reread grants for single table we should read both database and tables grants for views (not only database grants).
2011-06-02 10:30:05 +03:00
Igor Babaev
8bf69ab7bf Corrected the previous patch concerning elimination of SQL_SELECT::original_cond.
Corrected the code from the patch for  LP bug 702322.
2011-05-31 09:39:35 -07:00
unknown
55d26463ad Fixed typo (exlude -> exclude). 2011-05-30 21:40:46 +03:00
unknown
cd6fc3876b Fixed valgrind problem in expression cache (double opening the table).
sql/sql_expression_cache.cc:
  The call should not open the temporary table. It will be done later after its index creation.
2011-05-30 21:35:32 +03:00
Sergey Petrunya
0cf912c23f - Remove compiler warning
- Remove garbage comments
2011-05-30 11:19:40 +04:00
Sergey Petrunya
922830830a Merge 5.3-main -> MWL#90 2011-05-30 10:51:41 +04:00
Igor Babaev
5dc9a53d19 Eliminated the member original_cond from the class SQL_SELECT
introduced at the latest merge 5.1->5.2->5.3.
It is basically not needed since if SQL_SELECT::pre_idx_push_select_cond 
is not NULL then SQL_SELECT::original_cond would point to the same condition
as SQL_SELECT::pre_idx_push_select_cond. Otherwise SQL_SELECT::original_cond
would be equal to SQL_SELECT::cond.
2011-05-29 20:48:14 -07:00