Commit graph

27624 commits

Author SHA1 Message Date
unknown
7999f40a99 Fix LP BUG#613029
Analysis:
There are two code paths through which JOIN::exec may produce
an all-NULL row for an empty result set. One goes via the
function return_zero_rows(), when query processing detectes
early that the where clause is false, the other one is via
do_select() in the case of join execution.

In the case of do_select(), the problem was that the executioner
didn't set TABLE::null_row to 1. As result when sending the only
result row, the evaluation of each field didn't detect that all
non-aggregated fields are NULL, because Field::is_null returned
true, after checking that field->table->null_row was false.

Given that the each non-aggregated field was not considered NULL,
select_result::send_data sent whatever was in the buffer of each
field. However, since there was no actual data in the field buffer,
send_data() accessed and sent whatever junk was in the field's
data buffer.

Solution:
Similar to the analogous case in return_zero_rows() mark all
tables that their current row is NULL before sending the
artificailly created NULL row.
2011-03-28 12:55:36 +03:00
Michael Widenius
b20efbb119 Fixed test failures with embedded server
mysql-test/mysql-test-run.pl:
  Don't set --log-error when running embedded server as we don't want the mysqltest output into mysqld.1.err
sql/mysqld.cc:
  Allow one to disable --log-error
2011-03-28 12:49:20 +03:00
Vladislav Vaintroub
9762b236d4 merge 2011-03-28 02:04:43 +02:00
Vladislav Vaintroub
6058b9ea0a Fix build error (wrong printf-like format) 2011-03-28 02:02:24 +02:00
Vladislav Vaintroub
493a9108ae merge 2011-03-26 00:15:33 +01:00
Sergey Petrunya
201fb06db9 Merge in fix for BUG#727667 2011-03-25 12:47:44 +03:00
Sergey Petrunya
0fe8c972c6 BUG#727667 Wrong result with OR + NOT NULL in maria-5.3
- Address review feedback: introduce NO_REF_PART symbolic name, better comments
2011-03-25 12:43:32 +03:00
unknown
ec23949158 Fix LP BUG#715738
Analysis:
A query with implicit grouping is one with aggregate functions and
no GROUP BY clause. MariaDB inherits from MySQL an SQL extenstion
that allows mixing aggregate functions with non-aggregate fields.
If a query with such mixed select clause produces an empty result
set, the meaning of aggregate functions is well defined - either
NULL (MIN, MAX, etc.), or 0 (count(*)). However the non-aggregated
fields must also have some value, and the only reasonable value in
the case of empty result is NULL.

The cause of the many wrong results was that if a field is declared
as non-nullable (e.g. because it is a PK or NOT NULL), the semantic
analysis and the optimization phases treat this field as non-nullable,
and generate all related query plan elements based on this assumption.

Later during execution, these incorrectly configured/generated query
plan elements result in a wrong result because the selected fields
are not null due to the not-null assumption during optimization.

Solution:
Detect before the context analysys phase that a query uses implicit
grouping with mixed aggregates/non-aggregates, and set all fields
as nullable. The parser already walks the SELECT clause, and
already sets Item::with_sum_func for Items that reference aggreagate
functions. The patch adds a symmetric Item::with_field so that all
Items that reference an Item_field are marked during their
construction at parse time in the same way as with aggregate function
use.
2011-03-24 16:34:06 +02:00
Michael Widenius
eaed26053d Merge with base 5.2 2011-03-23 19:22:38 +02:00
Michael Widenius
7de98f2ffb Added --log-basename to mysqld to allow one to set the prefix for all logs with one command
Changed test suite to use --log-basename (to get the code tested)
Added --sync-sys=1 to test suite to speed it up.
Better error messages if something goes wrong with mysql_install_db


mysql-test/Makefile.am:
  Removed not existing directory
mysql-test/lib/My/ConfigFactory.pm:
  Use log-basename
  We had to also set 'log_error' as some test was explicitely using the old name
  Added 'sync-sys=1' to speed up test suite
mysql-test/r/variables-notembedded.result:
  Updated test results (variable relay_log is now set)
mysql-test/suite/binlog/t/binlog_delete_and_flush_index-master.opt:
  Force specific names for some log files.
mysql-test/suite/binlog/t/binlog_index-master.opt:
  Force specific names for some log files.
mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt:
  Force specific names for some log files.
mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test:
  Better error message if something goes wrong
mysql-test/suite/rpl/r/rpl_flushlog_loop.result:
  Updated results
mysql-test/suite/rpl/rpl_1slave_base.cnf:
  Use --log-basename
scripts/mysql_install_db.sh:
  More information to --help
  Write url to knowledge base if something goes wrong
  Fail at once if we can't create a database directory (no reason to continue and write a screenful of not related text)
scripts/mysqld_safe.sh:
  Also allow one to use --data for --datadir (common shortening)
  Added support for --log-basename
  Fail at once if we can't create a log directory
  Fixed bug where we used a pid file name without '.pid' extension
sql/log.cc:
  Create a log file name trough my_once_alloc()  (To get it automaticly freed at exit)
sql/mysql_priv.h:
  Added new prototype
sql/mysqld.cc:
  Added support for --log-basename
  Better help for a lot of log-filename related variables.
sql/rpl_rli.cc:
  Write information that one can use --log-basename
sql/set_var.cc:
  Add log_basename as a readonly variable
2011-03-23 17:59:41 +02:00
unknown
ca5ca4b968 MWL#116: group commit
Implement binlog_optimize_thread_scheduling option to allow benchmarking the
effect of running commit_ordered() for multiple transactions all in one
thread.
2011-03-23 15:29:20 +01:00
Igor Babaev
8aaf9197d0 Merge. 2011-03-15 12:30:48 -07:00
unknown
3f944c43e9 Merge in the fix for LPBUG#730604, and a corrected fix for LP BUG#719198,
after Monty's review.
2011-03-13 16:57:05 +00:00
unknown
428b52f503 Fix LP BUG#719198, LP BUG#730604
Analysis (BUG#719198):
The assert failed because the execution code for
partial matching is designed with the assumption that
NULLs on the left side are detected as early as possible,
and a NULL result is returned before any lookups are
performed at all.

However, in the case of an Item_cache object on the left
side, null was not detected properly, because detection
was done via Item::is_null(), which is not implemented at
all for Item_cache, and resolved to the default Item::is_null()
which always returns FALSE.

Solution:
Imlpement Item::is_null().

******

Analysis (BUG#730604):
The method Item_field::is_null() determines if an item is NULL from its
Item_field::field object. However, for Item_fields that represent internal
temporary tables, Item_field::field represents the field of the original
table that was the source for the temporary table (in this case t1.f3).
Both in the committed test case, and in the original bug report the current
value of t1.f3 is not NULL. This results in an incorrect count of NULLs
for this column. As a consequence, all related Ordered_key buffers are
allocated with incorrect sizes. Depending on the exact query and data,
these incorrect sizes result in various crashes or failed asserts.

Solution:
The correct value of the current field of the internal temp table is
in Item_field::result_field. This value is determined by
Item::is_null_result().
2011-03-13 15:03:26 +00:00
Igor Babaev
edc69e3227 Merge 2011-03-13 03:50:14 -07:00
Igor Babaev
f1cc6dd401 Merge. 2011-03-12 05:14:10 -08:00
Igor Babaev
81316aac3a Fixed LP bugs BUG#729067/730466.
Do not reset the value of the item_equal field in the Item_field object
once it has been set.
2011-03-12 00:49:03 -08:00
Vladislav Vaintroub
75625f5652 merge mwl#55 2011-03-11 15:20:24 +01:00
Vladislav Vaintroub
41d432462b merge 5.2 2011-03-10 09:39:14 +01:00
Vladislav Vaintroub
d4a3a7b90e mwl#59 - windows installer.
Address Monty's review comments
2011-03-09 20:21:03 +01:00
Michael Widenius
2f9579151b Added item.real_type() for easy access to the underlaying types for Item_ref and Item_cache_wrapper()
This allows us to simplify and speed up some tests and also remove get_cached_item()

sql/item.h:
  Added item.real_type()
  Removed get_cached_item()
sql/opt_range.cc:
  Simplify test
sql/sql_select.cc:
  Simplify test
sql/sql_show.cc:
  Simplify test
2011-03-09 17:55:00 +02:00
Michael Widenius
139a2b64bf Merge with 5.2 2011-03-09 15:47:59 +02:00
Michael Widenius
b3f7eac530 Added define to get rid of compiler warnings on system without DLOPEN 2011-03-09 00:51:22 +02:00
unknown
546a166b4e Fix LP BUG#719198
Analysis:
The assert failed because the execution code for
partial matching is designed with the assumption that
NULLs on the left side are detected as early as possible,
and a NULL result is returned before any lookups are
performed at all.

However, in the case of an Item_cache object on the left
side, null was not detected properly, because detection
was done via Item::is_null(), which is not implemented at
all for Item_cache, and resolved to the default Item::is_null()
which always returns FALSE.

Solution:
Use the property Item::null_value instead of is_null(), which
is properly updated for Item_cache objects as well.
2011-03-08 23:23:44 +02:00
Igor Babaev
3d3d5f1d43 Fixed LP bug #729039.
If join condition is of the form <t2.key>=<t1.no_key> then the server
performs no index look-ups when looking for matching rows of t2 for
the rows from t1 with t1.no_key=NULL. It happens because the function
add_not_null_conds() injects an additional condition of the form 
IS NOT NULL(<t1.no_key>) into the WHERE condition.
However if the join condition was of the form <t.key>=<outer_ref> no
additional null rejecting predicate was generated. This could lead
to extra records in the result set if the value of <outer_ref> happened
to be NULL.
The new code injects null rejecting predicates of the form 
IS NOT NULL(<outer_ref>) and evaluates them before the first row
the subquery is constructed.
2011-03-07 22:09:21 -08:00
Sergey Petrunya
76165dc760 BUG#727667 Wrong result with OR + NOT NULL in maria-5.3
- put the code that sets HA_NULL_PART bit back
- Fix test_if_ref/part_of_refkey() so that 
  = NULL-ability of lookup columns does not prevent the equality 
    from being removed (we now have early/late NULLs filtering which 
    will filter out NULL values)
  = equality is not removed if it is ref_or_null access, and the value 
    of the lookup column can alternate between the lookup value and NULL.
2011-03-05 12:56:22 +03:00
Michael Widenius
e1bb14ea6b Automatic merge with 5.2 to fix compiler failure on FreeBSD 2011-03-04 12:39:27 +02:00
Michael Widenius
fa4eb9931b Removed wrong #ifdef that caused compile failure on Freebsd. 2011-03-04 12:37:48 +02:00
Sergey Petrunya
e6bd643c75 MRR interface: change range_info's type from char* to range_id_t typedef. The goals are:
- cleaner code
- ability to change from using pointers to offsets at some point
2011-03-04 12:06:03 +03:00
Igor Babaev
633dbc3b68 Fixed LP bug #702322.
The bug was a result of the fix for bug 668644 that turned out to be
not quite correct. A problem appeared with HAVING conditions containing
more than one predicate. If a query with an ORDER BY clause uses
such HAVING condition and the required order can be obtained with
a range/index scan then the HAVING condition has to be pushed into
two different formulas (items). To be able to do it we have to create
a copy of the ANDOR structure of the pushed condition.
2011-03-03 18:24:41 -08:00
Sergey Petrunya
cdd214de1c Merge fix for BUG#693747 2011-03-04 01:30:25 +03:00
Sergey Petrunya
0e090eaa51 Merge BUG#707925. 2011-03-04 01:28:02 +03:00
Sergey Petrunya
8ef094fe4f BUG#707925: Wrong result with join_cache_level=6 optimizer_use_mrr = force (incremental, BKA join)
- The problem was that Mrr_ordered_index_reader's interrupt_read() and resume_read() would 
  save and restore 1) index tuple  2) the rowid (as bytes returned by handler->position()).  Clustered 
  primary key columns were not saved/restored. 
  They are not explicitly present in the index tuple (i.e. table->key_info[secondary_key].key_parts 
  doesn't list them), but they are actually there, in particular 
  table->field[clustered_primary_key_member].part_of_key(secondary_key) == 1. Index condition pushdown
  code [correctly] uses the latter as inidication that pushed index condition can refer to clustered PK
  members. 

  The fix was to make interrupt_read()/resume_read() to save/restore clustered primary key members as well,
  so that we get correct values for them when evaluating pushed index condition.
[3rd attempt: remove the debugging aids, fix comments in testcase]
2011-03-04 00:54:10 +03:00
unknown
adce16f96f Fix LP BUG#718763
Analysis:
The reason for the crash was that the inner subquery was executed
via a scan on a final temporary table applied after all other
operations. This final operation is implemented by changing the
contents of the JOIN object of the subquery to represent a table
scan over the temp table. At the same time query optimization of
the outer subquery required evaluation of the inner subquery, which
happened before the actual EXPLAIN. The evaluation left the JOIN
object of the inner subquery in the changed state, where it represented
a table scan over a temp table, and EXPLAIN crashed because the temp
table is not associated with any table reference (TABLE_LIST object).
The reason the JOIN was not restored was because its saving/restoration
was controlled by the join->select_lex->uncacheable flag, which was
not set in the case of materialization.

Solution:
In the methods Item_in_subselect::[single | row]_value_transformer() set:
    select_lex->uncacheable|= UNCACHEABLE_EXPLAIN;
In addition, for symmetry, change:
    master_unit->uncacheable|= UNCACHEABLE_EXPLAIN;
instead of UNCACHEABLE_DEPENDENT because if a subquery was not
dependent initially, the changed methods do not change this
fact. The subquery may later become correlated if it is transformed
to an EXISTS query, but it may stay uncorrelated if executed via
materialization.
2011-03-03 23:48:31 +02:00
Sergey Petrunya
9faf5452a1 BUG#693747: Assertion multi_range_read.cc:908: int DsMrr_impl::dsmrr_init
- Make DsMrr_impl::dsmrr_init() handle the case of 
   1. 1st MRR scan using DS-MRR strategy (i.e. doing key sorting and rowid sorting)
   2. 2nd MRR scan getting a buffer that's too small to fit one key element 
      and one rowid element, and so falling back to default MRR implementation
  In this case, dsmrr_init() is invoked with {primary_handler, secondary_handler}
  initialized for DS-MRR scan and have to reset them to be initialized for the
  default MRR scan.
(attempt 2, with simplified testcase)
2011-03-02 23:08:13 +03:00
unknown
0737fb479f MWL#89
Added comment.
2011-03-02 08:10:38 +02:00
Michael Widenius
9aa44bb4b3 Fixed wrong alias usage 2011-03-01 23:24:17 +02:00
unknown
71e9d94895 MWL#89
Merge 5.3 into 5.3-mwl89.
2011-03-01 15:54:21 +02:00
unknown
7895c35874 MWL#89
Merge MWL#89 with 5.3.
2011-03-01 14:16:28 +02:00
Sergey Petrunya
c6ba959802 Merge fix for BUG#725275 2011-03-01 10:22:22 +03:00
Sergey Petrunya
10b8119ad3 BUG#724275: Crash in JOIN::optimize in maria-5.3
- Make equality-substitution-for-ref-access code in JOIN::optimize() treat join_tab->ref.key_copy correctly
  (in the way create_ref_for_key() has filled it).
2011-03-01 00:29:59 +03:00
Michael Widenius
3358cdd504 Merge with 5.1 to get in changes from MySQL 5.1.55 2011-02-28 19:39:30 +02:00
Michael Widenius
869f5d0e81 Merge with alias as String 2011-02-28 13:16:17 +02:00
Michael Widenius
ff3da0f963 Change TABLE->alias to String for less memory reallocation
Changed some String.ptr() -> String.c_ptr() for String that are not guaranteed to end with \0
Removed some c_ptr() usage from parameters to functions that takes ptr & length
Use preallocate buffers to avoid calling malloc() for most operations. 


sql/event_db_repository.cc:
  alias is now a String
sql/event_scheduler.cc:
  c_ptr -> c_ptr_safe() to avoid warnings from valgrind.
sql/events.cc:
  c_ptr -> c_ptr_safe() to avoid warnings from valgrind.
  c_ptr -> ptr() as function takes ptr & length
sql/field.cc:
  alias is now a String
sql/field.h:
  alias is now a String
sql/ha_partition.cc:
  alias is now a String
sql/handler.cc:
  alias is now a String
  ptr() -> c_ptr() as string is not guaranteed to be \0 terminated
sql/item.cc:
  Store error parameter in separarte buffer to ensure correct error message
sql/item_func.cc:
  ptr() -> c_ptr_safe() as string is not guaranteed to be \0 terminated
sql/item_sum.h:
  Use my_strtod() instead of my_atof() to not have to make string \0 terminated
sql/lock.cc:
  alias is now a String
sql/log.cc:
  c_ptr() -> ptr() as function takes ptr & length
sql/log_event.cc:
  c_ptr_quick() -> ptr() as we only want to get the pointer to String buffer
sql/opt_range.cc:
  ptr() -> c_ptr() as string is not guaranteed to be \0 terminated
sql/opt_table_elimination.cc:
  alias is now a String
sql/set_var.cc:
  ptr() -> c_ptr() as string is not guaranteed to be \0 terminated
  c_ptr() -> c_ptr_safe() to avoid warnings from valgrind.
  c_ptr() -> ptr() as function takes ptr & length
  Simplify some code.
sql/sp.cc:
  c_ptr() -> ptr() as function takes ptr & length
sql/sp_rcontext.cc:
  alias is now a String
sql/sql_base.cc:
  alias is now a String.
  Here we win a realloc() for most alias usage.
sql/sql_class.cc:
  Use size descriptor for printf() to avoid accessing bytes outside of buffer
sql/sql_insert.cc:
  Change allocation of TABLE as it's now contains a String
  _ptr() -> ptr() as function takes ptr & length
sql/sql_load.cc:
  Use preallocate buffers to avoid calling malloc() for most operations.
sql/sql_parse.cc:
  Use c_ptr_safe() to ensure string is \0 terminated.
sql/sql_plugin.cc:
  c_ptr_quick() -> ptr() as function takes ptr & length
sql/sql_select.cc:
  alias is now a String
sql/sql_show.cc:
  alias is now a String
sql/sql_string.h:
  Added move() function to change who owns the string (owner does the free)
sql/sql_table.cc:
  alias is now a String
  c_ptr() -> c_ptr_safe() to avoid warnings from valgrind.
sql/sql_test.cc:
  c_ptr() -> c_ptr_safe() to avoid warnings from valgrind.
  alias is now a String
sql/sql_trigger.cc:
  c_ptr() -> c_ptr_safe() to avoid warnings from valgrind.
  Use field->init() to setup pointers to alias.
sql/sql_update.cc:
  alias is now a String
sql/sql_view.cc:
  ptr() -> c_ptr_safe() as string is not guaranteed to be \0 terminated
sql/sql_yacc.yy:
  r() -> c_ptr() as string is not guaranteed to be \0 terminated
sql/table.cc:
  alias is now a String
sql/table.h:
  alias is now a String
storage/federatedx/ha_federatedx.cc:
  Remove extra 1 byte alloc that is automaticly done by strmake()
  Ensure that error message ends with \0
storage/maria/ha_maria.cc:
  alias is now a String
storage/myisam/ha_myisam.cc:
  alias is now a String
2011-02-28 12:48:50 +02:00
Igor Babaev
0f0360e21f Fixed LP bug #725050.
The bug in the function print_keyuse() caused crashes if
hash join could be used. It happened because the function
ignored the fact that KEYUSE structures could be created
for hash joins as well.
2011-02-27 22:37:46 -08:00
Igor Babaev
1b03a028fc Merge. 2011-02-27 10:14:11 -08:00
Igor Babaev
ed3524c212 Minor corrections.
sql/mysqld.cc:
  Fixed: optimize_join_buffer_size was missing in the description of possible
  options for the optimizer switch.
sql/sql_select.cc:
  Fixed: initialization for the field ref_table_rows of the KEYUSE structure was 
  missing (as a result of a lame merge).
2011-02-27 09:35:14 -08:00
Igor Babaev
d57b1be961 Merge 2011-02-27 00:21:45 -08:00
Sergey Petrunya
db984067eb Fix buildbot failure in fix of BUG#723822 2011-02-26 23:09:58 +03:00
Sergey Petrunya
71371a9d5e Merge of fix for BUG#723822 2011-02-25 21:45:21 +03:00
Sergey Petrunya
0f265b8251 BUG#723822: Crash in get_constant_key_infix with EXISTS ( SELECT .. DISTINCT )
- Make get_constant_key_infix() take into account that there may be SEL_TREEs with
  type=SEL_ARG::MAYBE_KEY, which it cannot process, because they are not real ranges
  but rather indications that we might have been able to construct a range if we had
  values for some other tables' fields. 
  (check_quick_select() already has such check)
2011-02-25 21:43:57 +03:00
Michael Widenius
52b64be318 Fixed compiler warnings
client/readline.cc:
  Initialize not used variable (to kill wrong compiler warning)
mysql-test/suite/handler/aria.result:
  Updated test result
mysql-test/suite/handler/handler.inc:
  Changed index to ensure rows are in a fixed order
mysql-test/suite/handler/heap.result:
  Updated test result
mysql-test/suite/handler/innodb.result:
  Updated test result
mysql-test/suite/handler/myisam.result:
  Updated test result
plugin/handler_socket/handlersocket/Makefile.am:
  Use CXX flags to compile
sql/filesort.cc:
  Initialize variable that may be used
sql/log.cc:
  Initialize not used variable (to kill wrong compiler warning)
sql/opt_range_mrr.cc:
  Fixed cast to avoid compiler warning
storage/xtradb/fil/fil0fil.c:
  Added cast to avoid compiler warning
2011-02-25 20:15:27 +02:00
Michael Widenius
d46aee702e Fixed compiler and build error:
- Fixed main.mysqlcheck error on windows
- Fixed 'can't drop database pbxt' failure when running pbxt.mysqlslap


sql/table.cc:
  When using not legal file names for checking a non existing table, one got a warning in the log file which caused mysql.mysqlcheck to fail
storage/innodb_plugin/row/row0upd.c:
  Fixed compiler warning
storage/pbxt/src/table_xt.cc:
  Remove table that is dropped from 'repair-pending'.
  Fixed 'can't drop database pbxt' failure when running pbxt.mysqlslap
2011-02-25 17:45:53 +02:00
Igor Babaev
272e5e6212 BNLH algorithm always used a full table scan over the joined table
even in the cases when there existed range/index-merge scans that
were cheaper than the full table scan.
This was a defect/bug of the implementation of mwl #128. 
Now hash join can work not only with full table scan of the joined
table, but also with full index scan, range and index-merge scans.
Accordingly, in the cases when hash join is used the column 'type'
in the EXPLAINs can contain now 'hash_ALL', 'hash_index', 'hash_range'
and 'hash_index_merge'. If hash join is coupled with a range/index_merge
scan then the columns 'key' and 'key_len' contain info not only on
the used hash index, but also on the indexes used for the scan.
2011-02-23 22:23:12 -08:00
Michael Widenius
1c23091c4e Fixed build failures
- Removed references to deleted files
- If we link staticly, check for static zlib
  - This should fix the problem with 'no -lz found' link error
- Fixed build failure on window (Patch from Wlad)
- Fixed build problem with federatedx when using -Werror

BUILD/Makefile.am:
  Remove removed file
config/ac-macros/zlib.m4:
  If we compile with --all-static, test that we have a static libz
libmysqld/CMakeLists.txt:
  Fix for build error on windows
mysql-test/suite/pbxt/r/key_cache.result:
  Updated result
mysql-test/suite/pbxt/t/key_cache.test:
  Fixed not updated test case
sql/CMakeLists.txt:
  Fix for build error on windows
storage/federatedx/Makefile.am:
  Don't use CFLAGS to compile C++ programs
storage/pbxt/src/lock_xt.cc:
  Fixed compiler warning about using uninitialized b2
storage/xtradb/buf/buf0buf.c:
  Fixed wrong printf
storage/xtradb/srv/srv0srv.c:
  Fixed assignment of different width and test with different sign/unsigned
2011-02-23 11:22:56 +02:00
Michael Widenius
988d263e25 Merge with main 2011-02-22 20:28:01 +02:00
Michael Widenius
ab6d450639 Merge with main 2011-02-22 11:30:51 +02:00
Michael Widenius
4ad6d6b6c9 Merge in new handler and handlersocket code into 5.3 main 2011-02-22 11:15:47 +02:00
Vladislav Vaintroub
ab136fc6be Bug#53240 :Fixed dependency to prevent occasional situations
where bison runs in parallel with the same input and output files
2011-02-21 20:17:26 +01:00
Michael Widenius
58bb0769bd Merge with MySQL 5.1.55
- Fixed some issues with partitions and connection_string, which also fixed lp:716890 "Pre- and post-recovery crash in Aria"
- Fixed wrong assert in Aria

Now need to merge with latest xtradb before pushing 

sql/ha_partition.cc:
  Ensure that m_ordered_rec_buffer is not freed before close.
sql/mysqld.cc:
  Changed to use opt_stack_trace instead of opt_pstack.
  Removed references to pstack
sql/partition_element.h:
  Ensure that connect_string is initialized
storage/maria/ma_key_recover.c:
  Fixed wrong assert
2011-02-20 18:51:43 +02:00
Vladislav Vaintroub
38e3787af4 add newline at the end of file 2011-02-19 15:21:50 +01:00
Vladislav Vaintroub
99320324b2 Fix remaining windows (32 bit) warnings. 2011-02-19 15:16:31 +01:00
Vladislav Vaintroub
70a7e97e3c Fixed high-impact Windows 64bit warnings (at least 4000 of them) 2011-02-19 13:43:01 +01:00
Vladislav Vaintroub
28cb3b85b9 Fixed DBUG_PRINT formatting (compile error on Linux with -Werror) 2011-02-19 02:42:08 +01:00
Vladislav Vaintroub
019256c9fc Fix numerous warnings introduced in the last pushes on Windows 2011-02-18 23:31:01 +01:00
Michael Widenius
2813f568b7 Merge with bugfix
sql/multi_range_read.cc:
  Added printing of error if something goes wrong in get_next()
  (Not critical for this bug fix, but this was something that I noticed while testing and found missing)
storage/myisam/mi_rkey.c:
  Fixed wrong error number in mi_yield_and_check_if_killed()
2011-02-18 21:45:32 +02:00
Michael Widenius
b12e3796dc Fix for lp:711565 "Index Condition Pushdown can make a thread hold MyISAM locks as well as be unKILLable for long time"
- In Maria/MyISAM: Release/re-acquire locks to give queries that wait on them a chance to make progress
- In Maria/MyISAM: Change from numeric constants to ICP_RES values.
- In Maria: Do check index condition in maria_rprev() (was lost in the merge/backport?)
- In Maria/MyISAM/XtraDB: Check if the query was killed, and return immediately if it was.

Added new storage engine error: HA_ERR_ABORTED_BY_USER, for handler to signal that it detected a kill of the query and aborted

Authors: Sergey Petrunia & Monty

include/my_base.h:
  Added HA_ERR_ABORTED_BY_USER, for handler to signal that it detected a kill of the query and aborted
include/my_handler.h:
  Added comment
mysql-test/r/myisam_icp.result:
  Updated test
mysql-test/t/myisam_icp.test:
  Drop used tables at start of test
  Added test case that can help with manual testing of killing index condition pushdown query.
mysys/my_handler_errors.h:
  Text for new storage engine error
sql/handler.cc:
  If engine got HA_ERR_ABORTED_BY_USER, send kill message.
sql/multi_range_read.cc:
  Return error code
storage/maria/ha_maria.cc:
  Added ma_killed_in_mariadb() to detect kill.
  Ensure that file->external_ref points to TABLE object.
storage/maria/ma_extra.c:
  Dummy test-if-killed for standalone
storage/maria/ma_key.c:
  If ma_check_index_cond() fails, set my_errno and info->cur_row.lastpos
storage/maria/ma_rkey.c:
  Release/re-acquire locks to give queries that wait on them a chance to make progress
  Check if the query was killed, and return immediately if it was
storage/maria/ma_rnext.c:
  Check if the query was killed, and return immediately if it was
  Added missing fast_ma_writeinfo(info)
storage/maria/ma_rnext_same.c:
  Check if the query was killed, and return immediately if it was
  Added missing fast_ma_writeinfo(info)
storage/maria/ma_rprev.c:
  Check if the query was killed, and return immediately if it was
  Added missing fast_ma_writeinfo(info) and ma_check_index_cond()
storage/maria/ma_search.c:
  Give error message if we find a wrong key
storage/maria/ma_static.c:
  Added pointer to test-if-killed function
storage/maria/maria_def.h:
  New prototypes
storage/myisam/ha_myisam.cc:
  Added mi_killed_in_mariadb()
  Ensure that file->external_ref points to TABLE object.
storage/myisam/mi_extra.c:
  Dummy test-if-killed for standalone
storage/myisam/mi_key.c:
  If ma_check_index_cond() fails, set my_errno and info->lastpos
storage/myisam/mi_rkey.c:
  Ensure that info->lastpos= HA_OFFSET_ERROR in case of error
  Release/re-acquire locks to give queries that wait on them a chance to make progress
  Check if the query was killed, and return immediately if it was
  Reorder code to do less things in case of error.
  Added missing fast_mi_writeinfo()
storage/myisam/mi_rnext.c:
  Check if the query was killed, and return immediately if it was
  Simplify old ICP code
  Added missing fast_ma_writeinfo(info)
storage/myisam/mi_rnext_same.c:
  Check if the query was killed, and return immediately if it was
  Added missing fast_mi_writeinfo(info)
storage/myisam/mi_rprev.c:
  Check if the query was killed, and return immediately if it was
  Simplify error handling of ICP
  Added missing fast_mi_writeinfo(info)
storage/myisam/mi_search.c:
  Give error message if we find a wrong key
storage/myisam/mi_static.c:
  Added pointer to test-if-killed function
storage/myisam/myisamdef.h:
  New prototypes
storage/xtradb/handler/ha_innodb.cc:
  Added DB_SEARCH_ABORTED_BY_USER and ha_innobase::is_thd_killed()
  Check if the query was killed, and return immediately if it was
storage/xtradb/handler/ha_innodb.h:
  Added prototype
storage/xtradb/include/db0err.h:
  Added DB_SEARCH_ABORTED_BY_USER
storage/xtradb/include/row0mysql.h:
  Added possible ICP errors
storage/xtradb/row/row0sel.c:
  Use ICP errors instead of constants.
  Detect if killed and return B_SEARCH_ABORTED_BY_USER
2011-02-18 17:43:59 +02:00
unknown
96efe1cab3 Fix for LP BUG#714808 and LP BUG#719280.
The patch also adjusts several instable test results
to order the result.

Analysis:

The function prev_record_reads() may skip (jump over)
some query plan nodes where record_count < 1. At the
same time, even though get_partial_join_cost() uses
all first N plan nodes after the last constant table,
it may produce a smaller record_count than
prev_record_reads(), because the record count for
some plan nodes may be < 1, and these nodes may not
participate in prev_record_reads.

Solution:
The current solution is to treat the result of
get_partial_join_cost() as the upper bound for the
total number of unique lookup keys.
2011-02-15 22:17:18 +02:00
Vladislav Vaintroub
7ac23980b8 MWL#55 : Philip's review:
Take into account that mysql services start even with 
invalid defaults files (using data file relative to mysqld.exe location).
Handle this case in upgrade scenarios, as if there was no  
--defaults-file in service definition.
2011-02-15 13:04:55 +01:00
unknown
6c45d903f0 Fix LP BUG#718578
This bug extends the fix for LP BUG#715027 to cover one
more case of an Item being transformed, and its property
Item::with_subselect not being updated because
quick_fix_fields doesn't recalculate any properties.
2011-02-14 16:50:10 +02:00
unknown
2aeb4170a0 Fix LP BUG#715027
Analysis:
Before calling:
  write_record= (select->skip_record(thd) > 0);
the function find_all_keys needs to restore the original read/write
sets of the table that is sorted if the condition select->cond
contains a subquery.

This didn't happen in this test case because the flag "with_subselect"
was not set properly for select->cond.

The reason for the flag not being set properly, was that this condition
was rewritten by add_cond_and_fix() inside make_join_select() by:

      /* Add conditions added by add_not_null_conds(). */
      if (tab->select_cond)
        add_cond_and_fix(thd, &tmp, tab->select_cond);

However, the function add_cond_and_fix() called the shortcut method
Item::quick_fix_field() that didn't update the "with_subselect"
property.

Solution:
Call the complete Item::fix_fields() to update all Item properties,
including "with_subselect".
2011-02-14 00:11:46 +02:00
Vladislav Vaintroub
fb47a163d4 Fix MYSQL Bug#60057 : sel_arg_range_seq_next loops in optimized compilation/VS2010
When mariadb 5.3 is compiler with VS2010, several tests would enter infinite loop in 
sel_arg_range_seq_next(). The reason is compiler backend bug. This bug is not
present in either VS2008  or VS2010 SP1 RC.

Workaround is to compile this function without most aggresive optimization flag
 (-Og )  using #pragma optimize ("g", {on|off}) for this version of MSVC compiler.
2011-02-12 17:17:19 +01:00
unknown
cd34946657 Fix LP BUG#715034
Analysis:
The failed assert is a result of calling Item_sum_distinct::clear()
on an incomplete object for which Item_sum_distinct::setup() was
not yet called.

The reason is that JOIN::exec for the outer query calls JOIN::reinit()
for all its subqueries, which in turn calls clear() for all aggregate
functions of the subqueries. The call stack is:
mysql_explain_union -> mysql_select -> JOIN::exec -> select_desribe ->
mysql_explain_union -> mysql_select -> JOIN::reinit

This assert doesn't fail in the main 5.3 because constant subqueries
are being executed during the optimize phase of the outer query,
thus the Unique object is created before calling JOIN::exec for the
outer query, and Item_sum_distinct::clear() actually cleans the
Unique object.

Solution:
The best solution is the obvious one - substitute the assert with
a test whether Item_sum_distinct::tree is NULL.
2011-02-11 18:46:31 +02:00
Sergey Petrunya
21fdc91091 Merge: BUG#716293: "Range checked for each record" is not used if condition refers to outside of subquery 2011-02-11 13:27:35 +03:00
Michael Widenius
55c55d85bd Fixed bug in federatedx patch that caused partition tests to fail.
Fixed that connection string is returned for partitioned federated tables.

mysql-test/r/partition_federated.result:
  Fixed error message
mysql-test/suite/federated/federated_partition.result:
  Added test to show that connection string is returned in 'show create'.
sql/ha_partition.cc:
  Fixed a set of bugs introduced by the last federated patch:
  - We can't allocate m_ordered_rec_buffer in memroot as it has to survive call to clear_handler_file()
sql/partition_element.h:
  Ensure that connect_string is properly initialized.
  (This caused crashed in partition tests)
sql/sql_partition.cc:
  Print CONNECTION option for federated partitioned tables
2011-02-11 04:28:22 +02:00
unknown
ac6653aacc Fix LP BUG#714999
Analysis:
The crash in EXPLAIN resulted from an attempt to print the
name of the internal temporary table created to compute
distinct for the innermost subquery of the test case.
Such tables do not have a corresponding TABLE_LIST (table
reference), hence the crash. The reason for this was that
the subquery was executed as part of constant condition
evaluation before EXPLAIN attempts to print the table name.
During the subquery execution, the subquery JOIN_TAB and
its table are substituted by a temporary table in
make_simple_join.

Solution:
Similar to the analogous case for other Items than the
IS NULL function, do not evaluate expensive constant
conditions.
2011-02-10 22:53:30 +02:00
Michael Widenius
f2ca9c8784 Applied patch for lp:585688 "maridb crashes in federatedx code" from lp:~atcurtis/maria/federatedx:
- Fixed Partition engine to store CONNECTION string for partitions.
  Removed HA_NO_PARTITION flag from FederatedX.
  Added test 'federated_partition' to suite.
- lp:#585688 - maridb crashes in federatedx code
  FederatedX handler instances, created on one thread and used on
  another thread (via table cache) when "show table status" is executed
  crashed because txn member was not initialized for current thread.
  Added test 'federated_bug_585688' to suite.

Author for the patch is Antony Curtis

mysql-test/suite/federated/federated_bug_585688.result:
  Test for lp:585688
mysql-test/suite/federated/federated_bug_585688.test:
  Test for lp:585688
mysql-test/suite/federated/federated_partition-slave.opt:
  Test for partition support in federatedx
mysql-test/suite/federated/federated_partition.result:
  Test for partition support in federatedx
mysql-test/suite/federated/federated_partition.test:
  Test for partition support in federatedx
mysql-test/t/partition_federated.test:
  Updated error message
sql/ha_partition.cc:
  Added support for connection strings to partitions for federatedx
sql/ha_partition.h:
  Added support for connection strings to partitions for federatedx
sql/partition_element.h:
  Added support for connection strings to partitions for federatedx
sql/sql_yacc.yy:
  Added support for connection strings to partitions for federatedx
storage/federatedx/ha_federatedx.cc:
  Added support for partitions.
  FederatedX handler instances, created on one thread and used on another thread (via table cache) when "show table status"
  is executed crashed because txn member was not initialized for current thread.
2011-02-10 22:40:59 +02:00
unknown
6a66bf3182 MWL#89
Fixed LP BUG#714808 Assertion `outer_lookup_keys <= outer_record_count'

Analysis:

The function best_access_path() computes the number or records as
follows:

...
      if (rec < MATCHING_ROWS_IN_OTHER_TABLE)
        rec= MATCHING_ROWS_IN_OTHER_TABLE; // Fix for small tables
...
              if (table->quick_keys.is_set(key))
                records= (double) table->quick_rows[key];
              else
              {
                /* quick_range couldn't use key! */
                records= (double) s->records/rec;
              }

Above MATCHING_ROWS_IN_OTHER_TABLE == 10, and s->records == 1,
thus we get an estimated 0.1 records. As a result JOIN::get_partial_join_cost()
for the outer query computes outer_record_count == 0.1 records, which is
meaningless in this context.

Solution:
Round row count estimates that are < 1 to 1.
2011-02-10 16:23:59 +02:00
unknown
ca37339585 MWL#89
Fixed a memory leak found by valgrind. The memory leak was
a result of JOINs corresponding to subselects in a global
ORDER BY of a UNION not being cleaned up because the
fake_select of the UNION didn't point down to the subquery
select.
2011-02-10 16:16:06 +02:00
Sergey Petrunya
e431f106b9 BUG#716293: "Range checked for each record" is not used if condition refers to outside of subquery
- Assume that outside subquery references are known when doing "Range-checked-for-each-record" check.
2011-02-10 11:36:43 +03:00
Igor Babaev
38bc3bba43 Merge 2011-02-09 11:22:26 -08:00
Vladislav Vaintroub
577d02b17d MWL#55: look for my.cnf in addition to my.ini trying to figure out defaults file for the service 2011-02-08 13:07:31 +01:00
Vladislav Vaintroub
47c776bc4c MWL#55: mysql_upgrade_service.exe will now ensure that datadir is always written to my.ini file 2011-02-08 12:05:16 +01:00
Igor Babaev
6c7360b540 Merge 2011-02-07 15:19:03 -08:00
Igor Babaev
cbeab25085 Fixed LP bug #702403 that caused a crash on the tree for mwl#128
with the test case added by this patch.
The bug cannot be reproduced with the same test case for the main
5.3 tree because the backported fix for bug 59696 masks the 
problem that causes the crash in the mentioned test case. It's not
clear weather this fix masks this problem in all possible cases. 

Anyway the patch for bug 698882 introduced some inconsistent data
structures that could contain indirect references to deleted object.
It happened when two Item_equal objects were merged and the Item_field
list of the second object was joined to such list of the first object.
This operation required adjustment of the backward pointers in 
Item fields from the joined list. However the adjustment was missing 
and this caused crashes in the tree for mwl#128.

Now the backward pointers are set only when Item_equal items are
completely built and are not changed anymore.
2011-02-05 20:57:03 -08:00
Igor Babaev
4b24105df8 Introduced optimizer switch flag 'optimize_join_buffer_size'.
When this flag is 'off' the size of the used join buffer 
is taken directly from the system variable 'join_buffer_size'.
When this flag is 'on' then the size of the buffer depends
on the estimated number of rows in the partial join whose
records are to be stored in the buffer.
By default this flag is set 'on'.
2011-02-04 19:06:35 -08:00
Vladislav Vaintroub
0e3921a8fe Remove --loose-skip-pbxt kludge from mysql_install_db
and mysql_upgrade_service, after LPBUG#688404 was 
fixed.
2011-02-04 19:51:23 +01:00
Vladislav Vaintroub
614a6dfcd4 MWL#55: Handle cases where service was installed with
mysqld --install without any parameters.

In such case, service name is always MYSQL, as service
binary path is "path\to\mysqld.exe" "MySQL". Guess data
directory it is either from my.ini (which  is assumed to
be in the installation root), or just data directory 
under install root.
2011-02-04 12:20:41 +01:00
Vladislav Vaintroub
d99fbf4867 MWL#55 : Add banner text to command line utilities
(Philip's review)
2011-02-03 18:56:30 +01:00
Vladislav Vaintroub
3cb88652dd MWL#55: correct mysqld.exe file path, to extract version from it.
Take into account that services registered by  MySQL do not have
 .exe extension  in service binary path.
2011-02-03 17:51:03 +01:00
unknown
648e604615 MWL#89
Adjusted test cases in accordance with the implementation.
2011-02-03 17:00:28 +02:00
Michael Widenius
cfa0c6ff1d Increased precision for status variables Rows_sent and Rows_read from long to longlong
Fixed that status variables 'empty_queries', 'access_denied_errors' and 'lost_connections' are propageted to global status.
This should also remove some warnings with VC++



sql/mysqld.cc:
  Increased precision for status variables Rows_sent and Rows_read from long to longlong
sql/sql_class.cc:
  Increased precision for status variables Rows_sent and Rows_read from long to longlong
sql/sql_class.h:
  Increased precision for status variables Rows_sent and Rows_read from long to longlong
  Fixed that status variables 'empty_queries', 'access_denied_errors' and 'lost_connections' are propageted to global status.
2011-02-03 16:45:29 +02:00
Vladislav Vaintroub
1cb5bc32b6 Fix service user name and directory ACL setting on localized Windows
* Spell username correctly as "NT AUTHORITY\NetworkService"
* Also, use well-known SIDs for predefined user when assigning directory
ACLs (the names differ in localized Windows)
2011-02-02 01:30:24 +01:00
Vladislav Vaintroub
7e20687212 Fix compile errors:
* declaration in the middle of the block in C file.
* round() is only available in C99.
2011-02-01 14:19:58 +01:00
Igor Babaev
8041013fb1 Back-ported the patch for bug #59696 from mysql-5.6 code line.
The patch fixed the following optimizer defect: when performing
substitution for best equal fields into where conditions to be
able to do their evaluations as soon as possible the optimizer 
skipped conditions over views. That could lead to suboptimal 
execution of queries that used views.  
Slightly changed the test case to demonstrate the performance
improvements if this fix.
2011-01-31 19:33:32 -08:00
Vladislav Vaintroub
b2a15f73ce remove an extra LocalFree() call for pOldDacls, it is not allocated on heap 2011-02-01 01:57:23 +01:00
Vladislav Vaintroub
1b28a0883d split long lines, use get_mysql_service_properties() 2011-01-30 22:42:02 +01:00
Vladislav Vaintroub
366ee3c791 Move common functionality (analyze service configuration) into winservice library 2011-01-30 22:27:59 +01:00
Vladislav Vaintroub
2bc6032c99 MWL#55 - mysql_upgrade_service.exe
New utility to upgrade Windows service to higher MariaDB version.
Its functionality includes changing service definition as well as
running mysql_upgrade.
2011-01-29 19:00:05 +01:00
Vladislav Vaintroub
1a3115dbb2 MWL#55 : mysql_install_db.exe - command line utilityto install new database
on Windows.

Some parameters not present in traditional mysql_install_db are present
e.g --port, --default-user (whether to create a new users) or 
--service (windows service name)
2011-01-29 18:55:48 +01:00