Commit graph

888 commits

Author SHA1 Message Date
unknown
1b84c0cfee Fix for LP bug#1007622
TABLE_LIST::check_single_table made aware about fact that now if table attached to a merged view it can be (unopened) temporary table
(in 5.2 it was always leaf table or non (in case of several tables)).
2012-06-26 21:43:34 +03:00
Igor Babaev
20f3f4a273 Merge 5.2->5.3 2012-06-23 15:00:05 -07:00
Igor Babaev
0c69f22032 Fixed bug mdev-354.
Virtual columns of ENUM and SET data types were not supported properly
in the original patch that introduced virtual columns into MariaDB 5.2.
The problem was that for any  virtual column the patch used the 
interval_id field of the definition of the column in the frm file as
a reference to the virtual column expression.
The fix stores the optional interval_id of the virtual column in the
extended header of the virtual column expression.
2012-06-18 22:32:17 -07:00
unknown
9997b78ae4 LP BUG#978847 fixed.
Fixed incorrect type casting which made all fields (except very first) changes to materialized table incorrect.
Saved list of view/derived table used items after expanding '*'.
2012-04-19 09:16:30 +03:00
unknown
1a48919036 Fix of LP bug#968720.
When a view/derived table is converted from merged to materialized the
items from the used_item lists are substituted for items referring to
the fields of the result of the materialization. The problem appeared
with queries employing natural joins. Since the resolution of a natural
join was performed only once the used_item list formed at the second
execution of the query lacked the references to the fields that were
used only in the equality predicates generated for the natural join.
2012-04-05 23:32:57 +03:00
Michael Widenius
bb6cc52528 Automatic merge 2012-03-28 13:58:14 +03:00
Michael Widenius
3bc932ec17 Merge with 5.1 2012-03-28 13:49:07 +03:00
Michael Widenius
74b0649332 Fixed lp:944422 "mysql_upgrade destroys Maria tables?"
The issue was that check/optimize/anaylze did not zerofill the table before they started to work on it.
Added one more element to not often used function handler::auto_repair() to allow handler to decide when to auto repair.


mysql-test/suite/maria/r/maria-autozerofill.result:
  Test case for lp:944422
mysql-test/suite/maria/t/maria-autozerofill.test:
  Test case for lp:944422
sql/ha_partition.cc:
  Added argument to auto_repair()
sql/ha_partition.h:
  Added argument to auto_repair()
sql/handler.h:
  Added argument to auto_repair()
sql/table.cc:
  Let auto_repair() decide which errors to trigger auto-repair
storage/archive/ha_archive.h:
  Added argument to auto_repair()
storage/csv/ha_tina.h:
  Added argument to auto_repair()
storage/maria/ha_maria.cc:
  Give better error & warning messages for auto-repaired tables.
storage/maria/ha_maria.h:
  Added argument to auto_repair()
  Always auto-repair in case of moved table.
storage/maria/ma_open.c:
  Remove special handling of HA_ERR_OLD_FILE (this is now handled in auto_repair())
storage/myisam/ha_myisam.h:
  Added argument to auto_repair()
2012-03-28 13:22:21 +03:00
Michael Widenius
c36bdf1c88 Speedup:
- Don't call update_virtual_fields() if table->vfield is not set
- Don't prealloc memory for in open_tables() as this is very seldom used.


sql/records.cc:
  Don't call update_virtual_fields() if table->vfield is not set
sql/sql_base.cc:
  Don't prealloc memory for in open_tables() as this is very seldom used.
  Don't call update_virtual_fields() if table->vfield is not set
sql/sql_delete.cc:
  Don't call update_virtual_fields() if table->vfield is not set
sql/sql_handler.cc:
  Don't call update_virtual_fields() if table->vfield is not set
sql/sql_join_cache.cc:
  Don't call update_virtual_fields() if table->vfield is not set
  Move some frequent values to local variables
sql/sql_table.cc:
  Don't call update_virtual_fields() if table->vfield is not set
sql/sql_update.cc:
  Don't call update_virtual_fields() if table->vfield is not set
sql/table.cc:
  Assert if update_virtual_fields is called with wrong parameters
2012-03-23 18:22:39 +02:00
unknown
8e0afbd8af Backport some simple performance patches from 5.5. 2012-03-22 13:21:15 +01:00
unknown
5338a28912 Merge 5.2->5.3 2012-03-14 13:58:18 +02:00
Igor Babaev
8c08349882 Fixed LP bug #930814.
This bug was introduced into mariadb 5.2 in the December 2010 with
the patch that added a new engine property: the ability to support
virtual columns.    
As a result of this bug the information from frm files for tables 
that contained virtual columns did not appear in the information schema
tables.
2012-03-09 15:37:16 -08:00
unknown
764eeeee74 Fix for LP BUG#910123 MariaDB 5.3.3 causes 1093 error on Drupal
Problem was that now we can merge derived table (subquery in the FROM clause).
Fix: in case of detected conflict and presence of derived table "over" the table which cased the conflict - try materialization strategy.
2012-02-14 16:52:56 +02:00
unknown
79a04a2c9c Moving LP BUG#794005 to 5.3 + fixing INSERT of multi-table view. 2012-02-03 13:01:05 +02:00
unknown
d6e1377ac2 Fix check of view updatability in case of underlying view changes its updatability.
For single table update/insert added deep check of single tables (single_table_updatable()).
For multi-table view insert added additional check of target table (check_view_single_update).
Multi-update was correct.

Test suite for all cases added.
2012-02-03 10:28:23 +02:00
Igor Babaev
7b79d8a33f Merge 5.2->5.3 in preparation for the release of mariadb-5.3.4-rc. 2012-02-01 15:48:02 -08:00
Igor Babaev
6dfe0956d6 Back-ported the test cases for bug #12763207 from mysql-5.6 code line into 5.2
Completed the fix for this bug.
Note: in 5.3 the affected 'if' statement in Item_in_subselect::single_value_transformer()
starting with the  condition (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY)
should be removed altogether. The change from table.cc is not needed either.
This is because in 5.3
 - min/max transformation for subqueries are done at the optimization phase
 - evaluation of the expensive subqueries is done at the execution phase.

Added an EXPLAIN EXTENDED to the test case for bug #12329653.
2012-01-13 12:23:19 -08:00
Igor Babaev
27380e4fb5 Fixed LP bug #794005.
The function st_table::mark_virtual_columns_for_write() did not take into
account the fact that for any table the value of st_table::vfield is 0
when there are no virtual columns in the table definition.
2011-12-20 01:56:41 -08:00
Michael Widenius
24e452a208 Merge with 5.1 & fixes to IGNORE handling 2011-12-11 19:28:05 +02:00
Michael Widenius
6d4224a31c Merge with 5.2.
no_error handling for select (used by INSERT ... SELECT) still needs to be fixed, but I will do that in a separate commit
2011-12-11 11:34:44 +02:00
Sergey Petrunya
a1b4eadf89 BUG#868908: Crash in check_simple_equality() with semijoin + materialization + prepared statement
- Part2: safety and code cleanup
2011-12-07 19:21:51 +04:00
Sergey Petrunya
8e25dcfcd7 BUG#868908: Crash in check_simple_equality() with semijoin + materialization + prepared statement
- Part 1 of the fix: for semi-join merged subqueries, calling child_join->optimize() until we're done with all
  PS-lifetime optimizations in the parent.
2011-12-07 01:03:00 +04:00
Michael Widenius
a293d0788c Automatic merge 2011-11-24 22:48:35 +02:00
Michael Widenius
6920457142 Merge with MariaDB 5.1 2011-11-24 18:48:58 +02:00
Michael Widenius
a8d03ab235 Initail merge with MySQL 5.1 (XtraDB still needs to be merged)
Fixed up copyright messages.
2011-11-21 19:13:14 +02:00
unknown
26387734fd Fix gcc 4.6 warning after merge with 5.1 2011-10-27 19:18:25 +03:00
unknown
4720b6f68b merge 2011-10-18 14:04:10 +03:00
unknown
255c04aed8 Compiler warning about assigned but not used variables fixed. 2011-10-18 13:44:12 +03:00
Igor Babaev
cc80671202 Fixed a compiler warning. 2011-10-17 03:42:56 -07:00
Igor Babaev
f5955f87c6 Fixed LP bug #874006.
This bug manifested itself with queries containing non-correlated
IN subqueries over materialized views/derived tables.  
The bug happened because the code of the function generate_derived_keys did
not take into account that the function could be called twice when the
optimizer was deciding whether in-exist transformation should be applied.
2011-10-16 13:23:57 -07:00
unknown
b152c4c71d Merge 5.2->5.3 2011-09-02 15:10:10 +03:00
Michael Widenius
4692537f60 Fixed non critical buffer overflow bug in open_binary_frm() that could cause ASSERT
Added more printing of errors to myisamchk.

mysys/mf_iocache.c:
  Write error message if failed seek.
sql/table.cc:
  Fixed buffer overflow bug:
  - It's not enough to check for mysql_version to to detect partion indicator as the version may have been updated by mysql_upgrade.
storage/myisam/ha_myisam.cc:
  Don't log same error twice.
  Don't reset log_all_errors if it's set
storage/myisam/mi_check.c:
  Fixed bug that caused repair() to not report error if called twice (as when doing retry)
  More printing of errors.
storage/myisam/sort.c:
  Set my_errno in case of out of memory errors.
2011-09-01 21:18:29 +03:00
Kent Boortz
027b5f1ed4 Updated/added copyright headers 2011-07-03 17:47:37 +02:00
Sergey Petrunya
1ecfc9551c Merge first chunk of OJ+SJ fixes into 5.3 2011-07-01 12:45:45 +04:00
Igor Babaev
584954ab6e Fixed LP bug #803851.
The function generate_derived_keys_for_table should set the value of
the number of keys for the derived table to 0 before it starts 
generating key definitions for the table. It's important as the
function can be called twice by the optimizer for a derived table
if the query contains a subquery to which the IN-EXIST transformation
is applicable.

Fixed a valgrind complain.
2011-06-30 19:32:19 -07:00
Kent Boortz
68f00a5686 Updated/added copyright headers 2011-06-30 17:37:13 +02:00
Kent Boortz
44135d4725 Updated/added copyright headers 2011-06-30 17:31:31 +02:00
Sergey Petrunya
1aede4d1c8 Merge 2011-06-29 11:52:26 +04:00
Igor Babaev
5ce5e8db92 Merge 2011-06-27 23:36:20 -07:00
Igor Babaev
9c4a3ced11 Fixed LP bug #800535.
The function create_view_field in some cases incorrectly set the maybe_null
flag for the returned items.
2011-06-27 23:07:46 -07:00
Sergey Petrunya
a28c8a3cf7 Merge semi-join+outer-join fixes into 5.3 2011-06-27 23:40:58 +04: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
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
Sergey Petrunya
6adddca80e Make semi-joins work with outer joins part #1:
- Make make_outerjoin_info() correctly process semi-join nests
- Make make_join_select() attach conditions to the right places.
2011-06-22 01:57:28 +04: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
unknown
55d26463ad Fixed typo (exlude -> exclude). 2011-05-30 21:40:46 +03:00
Sergey Petrunya
5cd18326c2 Merge 5.3->main -> 5.3-mwl90 2011-05-29 12:58:44 +04:00
Igor Babaev
8ce2e1bcbe Fixed the abort failure of a test case from vcol.vcol_misc.
The fix blocks execution of any constant sub-expressions of
the defining expressions for virtual columns when context
analysis if these expressions is performed.

Fixed a compiler warning.
2011-05-28 22:07:56 -07: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