Commit graph

2979 commits

Author SHA1 Message Date
Michael Widenius
c752596183 Automatic merge 2011-06-28 00:13:22 +03:00
Michael Widenius
ba9a890f0c New status variables: Rows_tmp_read, Handler_tmp_update and Handler_tmp_write
Split status variable Rows_read to Rows_read and Rows_tmp_read so that one can see how much real data is read.
Same was done with with Handler_update and Handler_write.
Fixed bug in MEMORY tables where some variables was counted twice.
Added new internal handler call 'ha_close()' to have one place to gather statistics.
Fixed bug where thd->open_options was set to wrong value when doing admin_recreate_table()


mysql-test/r/status.result:
  Updated test results and added new tests
mysql-test/r/status_user.result:
  Udated test results
mysql-test/t/status.test:
  Added new test for temporary table status variables
sql/ha_partition.cc:
  Changed to call ha_close() instead of close()
sql/handler.cc:
  Added internal_tmp_table variable for easy checking of temporary tables.
  Added new internal handler call 'ha_close()' to have one place to gather statistics.
  Gather statistics for internal temporary tables.
sql/handler.h:
  Added handler variables internal_tmp_table, rows_tmp_read.
  Split function update_index_statistics() to two.
  Added ha_update_tmp_row() for faster tmp table handling with more statistics.
sql/item_sum.cc:
  ha_write_row() -> ha_write_tmp_row()
sql/multi_range_read.cc:
  close() -> ha_close()
sql/mysqld.cc:
  New status variables: Rows_tmp_read, Handler_tmp_update and Handler_tmp_write
sql/opt_range.cc:
  close() -> ha_close()
sql/sql_base.cc:
  close() -> ha_close()
sql/sql_class.cc:
  Added handling of rows_tmp_read
sql/sql_class.h:
  Added new satistics variables.
  rows_read++  ->  update_rows_read() to be able to correctly count reads to internal temp tables.
  Added handler::ha_update_tmp_row()
sql/sql_connect.cc:
  Added comment
sql/sql_expression_cache.cc:
  ha_write_row() -> ha_write_tmp_row()
sql/sql_select.cc:
  close() -> ha_close()
  ha_update_row() -> ha_update_tmp_row()
sql/sql_show.cc:
  ha_write_row() -> ha_write_tmp_row()
sql/sql_table.cc:
  Fixed bug where thd->open_options was set to wrong value when doing admin_recreate_table()
sql/sql_union.cc:
  ha_write_row() -> ha_write_tmp_row()
sql/sql_update.cc:
  ha_write_row() -> ha_write_tmp_row()
sql/table.cc:
  close() -> ha_close()
storage/heap/ha_heap.cc:
  Removed double counting of statistic variables.
  close -> ha_close() to get tmp table statistics.
storage/maria/ha_maria.cc:
  close -> ha_close() to get tmp table statistics.
2011-06-27 19:07:24 +03:00
Igor Babaev
cb164640be Fixed LP bug #801536.
Ensured valid calculations of the estimates stored in JOIN_TAB::used_fieldlength.
2011-06-26 21:55:32 -07:00
Igor Babaev
37bac085da Fixed LP bug #799499.
The following were missing in the patch for mwl106:
- KEY_PART_INFO::fieldnr were not set for generated keys to access
  tmp tables storing the rows of materialized derived tables/views
- TABLE_SHARE::column_bitmap_size was not set for tmp tables storing
  the rows of materialized derived tables/views.
These could cause crashes or memory overwrite.
2011-06-24 18:42:14 -07:00
Igor Babaev
fb22eb1391 Fixed LP bug #798576.
If a view/derived table is non-mergeable then the definition of the tmp table
to store the rows for it is created at the prepare stage. In this case if the
view definition uses outer joins and a view column belongs to an inner table
of one of them then the column should be considered as nullable independently
on nullability of the underlying column. If the underlying column happens to be
defined as non-nullable then the function create_tmp_field_from_item rather 
than the function create_tmp_field_from_field should be employed to create
the definition of the interesting column in the tmp table.
2011-06-24 14:38:53 -07:00
Sergey Petrunya
7880039fc0 Merge 5.2 -> 5.3
(testcase for #798597 now crashes)
2011-06-24 21:43:31 +04:00
Michael Widenius
66b3e82953 Merge with 5.1 2011-06-24 12:13:03 +03:00
Michael Widenius
6f5f5b9491 Fixed typo. (Old code worked as both tested parts where 'bool', but not nice code..) 2011-06-24 10:56:29 +03:00
Michael Widenius
6a9ac86cd3 Fix for bug lp:798597 Incorrect "Duplicate entry" error with views and GROUP BY
mysql-test/r/join.result:
  Test case for LP:798597
mysql-test/t/join.test:
  Test case for LP:798597
sql/sql_select.cc:
  In simplify_joins we reset table->maybe_null for outer join tables that can't ever be NULL.
  This caused a conflict between the previously calculated items and the group_buffer against the fields
  in the temporary table that are created as not null thanks to the optimization.
  The fix is to correct the group by items to also be not_null so that they match the used fields and keys.
2011-06-24 10:08:09 +03:00
Igor Babaev
d6b0767c8c Fixed a valgrind problem.
The function setup_tables should handle table_list elements for
semijoin materialized tables in a special way when executing
a prepared statement for the second time.
2011-06-23 22:12:22 -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
Igor Babaev
078b59f5bc Merge of mwl #106 into 5.3. 2011-06-15 21:48:38 -07: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
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
9b98cae4cc merge with 5.1-micro 2011-06-07 18:13:02 +02: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
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
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
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
Sergey Petrunya
037e16583e Remove garbage comments 2011-05-29 13:22:38 +04:00
Sergey Petrunya
5cd18326c2 Merge 5.3->main -> 5.3-mwl90 2011-05-29 12:58:44 +04:00
Sergey Petrunya
ded7342daa - Update test results (trivial)
- Code cleanup: remove garbage comments
2011-05-29 01:47:24 +04:00
Sergey Petrunya
6f17421c27 Buildbot fixes:
- Don't call table_list->process_index_hints() for JTBM pseudo-tables
- Update test results
2011-05-29 01:24:36 +04:00
Sergey Petrunya
0b69585dec Buildbot fixes
- Update test results (checked)
- Fix compiler warning
2011-05-29 00:41:41 +04:00
Sergey Petrunya
77c4c4d8ea post-merge fixes: get MWL#90 code to work with MWL#89's
way of processing prepared statements:
- conversion subquery_predicate -> TABLE_LIST is once per-statement
- However, the code must take into account that materialized temptable
  is dropped and re-created on each execution (the tricky part is that 
  at start of n-th EXECUTE we have TABLE_LIST object but not its TABLE object)
- IN-equality is injected into WHERE on every execution.
2011-05-28 20:34:04 +04:00
Michael Widenius
2894d50e3e automatic merge with 5.3 2011-05-28 05:58:16 +03:00
Michael Widenius
f197991f41 Merge with 5.1-microseconds
A lot of small fixes and new test cases.

client/mysqlbinlog.cc:
  Cast removed
client/mysqltest.cc:
  Added missing DBUG_RETURN
include/my_pthread.h:
  set_timespec_time_nsec() now only takes one argument
mysql-test/t/date_formats.test:
  Remove --disable_ps_protocl as now also ps supports microseconds
mysys/my_uuid.c:
  Changed to use my_interval_timer() instead of my_getsystime()
mysys/waiting_threads.c:
  Changed to use my_hrtime()
sql/field.h:
  Added bool special_const_compare() for fields that may convert values before compare (like year)
sql/field_conv.cc:
  Added test to get optimal copying of identical temporal values.
sql/item.cc:
  Return that item_int is equal if it's positive, even if unsigned flag is different.
  Fixed Item_cache_str::save_in_field() to have identical null check as other similar functions
  Added proper NULL check to Item_cache_int::save_in_field()
sql/item_cmpfunc.cc:
  Don't call convert_constant_item() if there is nothing that is worth converting.
  Simplified test when years should be converted
sql/item_sum.cc:
  Mark cache values in Item_sum_hybrid as not constants to ensure they are not replaced by other cache values in compare_datetime()
sql/item_timefunc.cc:
  Changed sec_to_time() to take a my_decimal argument to ensure we don't loose any sub seconds.
  Added Item_temporal_func::get_time() (This simplifies some things)
sql/mysql_priv.h:
  Added Lazy_string_decimal()
sql/mysqld.cc:
  Added my_decimal constants max_seconds_for_time_type, time_second_part_factor
sql/table.cc:
  Changed expr_arena to be of type CONVENTIONAL_EXECUTION to ensure that we don't loose any items that are created by fix_fields()
sql/tztime.cc:
  TIME_to_gmt_sec() now sets *in_dst_time_gap in case of errors
  This is needed to be able to detect if timestamp is 0
storage/maria/lockman.c:
  Changed from my_getsystime() to set_timespec_time_nsec()
storage/maria/ma_loghandler.c:
  Changed from my_getsystime() to my_hrtime()
storage/maria/ma_recovery.c:
  Changed from my_getsystime() to mmicrosecond_interval_timer()
storage/maria/unittest/trnman-t.c:
  Changed from my_getsystime() to mmicrosecond_interval_timer()
storage/xtradb/handler/ha_innodb.cc:
  Added support for new time,datetime and timestamp
unittest/mysys/thr_template.c:
  my_getsystime() -> my_interval_timer()
unittest/mysys/waiting_threads-t.c:
  my_getsystime() -> my_interval_timer()
2011-05-28 05:11:32 +03:00
Sergey Petrunya
aa551f1b9e Post-merge fixes part#2 2011-05-26 15:01:26 +04:00
Sergey Petrunya
f0038da8f6 Post-merge fixes part #1. 2011-05-26 11:30:14 +04:00
Sergey Petrunya
77b3b960b1 Merge MWL#90 with 5.3-main 2011-05-25 19:31:13 +04:00
unknown
8a314700f9 MWL#89 automatic merge with 5.3 2011-05-23 11:54:26 +03:00
unknown
742dfc92a2 MWL#89: Address review feedback (by Sergey Petrunia)
mysql-test/r/subselect4.result:
  Moved test case for LP BUG#718593 into the correct test file subselect_mat_cost_bugs.test.
mysql-test/t/subselect4.test:
  Moved test case for LP BUG#718593 into the correct test file subselect_mat_cost_bugs.test.
2011-05-23 10:56:05 +03:00
Igor Babaev
63d6dbc4ab Fixed 3 valgrind bugs.
Two of them (in the function make_join_statistics and in the function
sort_and_filter_keyuse) were due to bad merges while the third bug was
triggered by uninitialized values of the field JOIN_TAB::preread_init_done.

Fixed a compiler warning in mysql_priv.h.

Commented out some queries from the funcs_1 suite returning wrong
errors due to bugs concerning updatable views (see bugs 784297 and
784303).

Adjusted some results for the test cases with derived tables from
different suites.
2011-05-21 13:12:21 -07:00
Sergei Golubchik
dda9577d55 comments 2011-05-21 18:41:56 +02:00
Sergei Golubchik
7c459960ec db_low_byte_first is gone 2011-05-20 23:56:13 +02:00
Igor Babaev
89cf840cd9 Merge 2011-05-20 12:47:39 -07:00
Sergey Petrunya
be6d6e1b3e Fix a comment (unmatched '{' and '}' screw up jumping in advanced editors) 2011-05-20 19:52:24 +04:00
Igor Babaev
d015b8fa0a Fixed a compiler warning. 2011-05-20 00:06:27 -07:00