Commit graph

27917 commits

Author SHA1 Message Date
Sergey Petrunya
73510c289a MWL#90: Switch update_depend_map() back to single loop (so that diff is smaller) 2011-03-27 04:02:27 +04:00
Sergey Petrunya
924bdf3e1c Remove comments 2011-03-27 03:55:38 +04:00
Sergey Petrunya
4e5199912b Rename JOIN::top_jtrange_tables to top_join_tab_count 2011-03-27 03:54:15 +04:00
Sergey Petrunya
5de770f317 MWL#90: Address review feedback part #14 2011-03-27 03:45:16 +04:00
Sergey Petrunya
290a72d50b Check the theory that optimize_wo_join_buffering() doesn't need to save/restore join->cur_sj_inner_tables. 2011-03-26 17:39:34 +03:00
Sergei Golubchik
e016a2f5f0 lp:705210 Compiling with BUILD/compile-pentium64-debug fails 2011-03-26 11:59:34 +01:00
Sergey Petrunya
2071ac10fd MWL#90: Address review feedback part #12
- Address review feedback in select_describe().
2011-03-26 12:46:00 +03:00
Vladislav Vaintroub
493a9108ae merge 2011-03-26 00:15:33 +01:00
Sergey Petrunya
bf894470de MWL#90: Address review feedback part #11. 2011-03-25 18:42:47 +03:00
Sergey Petrunya
5ae088f8c1 Fix a problem introduced in previous cset 2011-03-25 17:10:16 +03:00
Georgi Kodinov
5af973582d merge 2011-03-25 14:57:25 +02:00
Mattias Jonsson
e0887df8e1 Bug#11766249 bug#59316: PARTITIONING AND INDEX_MERGE MEMORY LEAK
When executing row-ordered-retrieval index merge,
the handler was cloned, but it used the wrong
memory root, so instead of allocating memory
on the thread/query's mem_root, it used the table's
mem_root, resulting in non released memory in the
table object, and was not freed until the table was
closed.

Solution was to ensure that memory used during cloning
of a handler was allocated from the correct memory root.

This was implemented by fixing handler::clone() to also
take a name argument, so it can be used with partitioning.
And in ha_partition only allocate the ha_partition's ref, and
call the original ha_partition partitions clone() and set at cloned
partitions.

Fix of .bzrignore on Windows with VS 2010
2011-03-25 12:36:02 +01:00
Sergey Petrunya
5a07fcc6c4 MWL#90: Address review feedback part #10. 2011-03-25 14:24:58 +03:00
Georgi Kodinov
dcf6b68d08 Bug #11766769: 59959: SMALL VALUES OF --MAX-ALLOWED-PACKET
ARE NOT BEING HONORED

max_allowed_packet works in conjunction with net_buffer_length.
max_allowed_packet is an upper bound of net_buffer_length.
So it doesn't make sense to set the upper limit lower than the value.
Added a warning (using ER_UNKNOWN_ERRROR and a specific message)
when this is done (in the log at startup and when setting either 
max_allowed_packet or the net_buffer_length variables)
Added a test case.
Fixed several tests that broke the above rule.
2011-03-25 12:57:27 +02:00
Sergey Petrunya
253087815a Make first_linear_tab()/next_linear_tab() use named constants instead of TRUE/FALSE flags, for better readability. 2011-03-25 12:58:27 +03: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
Sergey Petrunya
432a058723 - Fix valgrind failure introduced in previous push 2011-03-25 12:14:02 +03:00
Sergey Petrunya
daf4acc18a MWL#90: Address review feedback: fix a problem introduced a few csets earlier: Do perform tab->cleanup()
for const tables in JOIN::cleanup().
2011-03-24 22:46:10 +03:00
Sergei Golubchik
c41b66c07f fixes for funcs_1 suite 2011-03-24 15:55:52 +01: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
Vladislav Vaintroub
e06f8fbbae merge 2011-03-24 12:35:44 +01:00
Vladislav Vaintroub
8250ceced6 Fix compilation on Windows:
- Fixes for type-conversion
  (time_t   is not interchangeable  with  my_time_t on Windows as time_t s 64 bit while my_time_t is long)
- BIGENDIAN-> ARCH_BIGENDIAN . 
  BIGENDIAN constant  is defined in winsock2.h (as 0)
- added explicit cast for longlong->double conversion in sql/item.h  (fixed many warnings) 

Also, HAVE_SNPRINTF is now defined and snprintf is defined to _snprintf in config-win.h
2011-03-24 12:30:03 +01:00
Luis Soares
f24b6702e9 Automerging bzr bundle attached to bug report into latest mysql-5.1. 2011-03-24 10:58:48 +00:00
Luis Soares
b489c89f73 BUG#11766865: 60091: RBR + NO PK + UPDATE NULL VALUE --> SLAVE BREAK WITH ERROR HA_ERR_END_OF_
The slave was not able to find the correct row in the innodb
table, because the row fetched from the innodb table would not
match the before image. This happened because the (don't care)
bytes in the NULLed fields would change once the row was stored
in the storage engine (from zero to the default value). This
would make bulk memory comparison (using memcmp) to fail.
  
We fix this by taking a preventing measure and avoiding memcmp
for tables that contain nullable fields. Therefore, we protect
the slave search routine from engines that return arbitrary
values for don't care bytes (in the nulled fields). Instead, the
slave thread will only check null_bits and those fields that are
not set to NULL when comparing the before image against the
storage engine row.

mysql-test/extra/rpl_tests/rpl_record_compare.test:
  Added test case to the include file so that this is tested 
  with more than one engine.
mysql-test/suite/rpl/r/rpl_row_rec_comp_innodb.result:
  Result update.
mysql-test/suite/rpl/r/rpl_row_rec_comp_myisam.result:
  Result update.
mysql-test/suite/rpl/t/rpl_row_rec_comp_myisam.test:
  Moved the include file last, so that the result from
  BUG#11766865 is not intermixed with the result for
  BUG#11760454.
sql/log_event.cc:
  Skips memory comparison if the table has nullable 
  columns and compares only non-nulled fields in the
  field comparison loop.
2011-03-24 10:52:40 +00: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
Sergei Golubchik
7cd29fe917 lp:740958 5.1-micro can not handle prepared statements with timestamps involving nanoseconds
fix a typo in the boundary test.
simplify make_truncated_value_warning call.
2011-03-23 16:14:34 +01: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
Sergei Golubchik
a85ccfedcf lp:740958 5.1-micro can not handle prepared statements with timestamps involving nanoseconds
fix a typo in the boundary test.
simplify make_truncated_value_warning call.
2011-03-23 14:10:11 +01:00
Sergei Golubchik
8d2738367e lp:740173 5.1-micro reports incorrect Length metadata for TIME expressions 2011-03-23 13:31:06 +01:00
Sergey Petrunya
f064087ed0 MWL#90: Address review feedback part #9:
- among everything else, switch to using first/next_linear_tab() in make_outerjoin_info().
2011-03-22 19:42:36 +03:00
Sergey Petrunya
739e6c99a2 MWL#90: Address review feedback part #8 2011-03-22 19:23:12 +03:00
Sergey Petrunya
39fe368d68 MWL#90: Address review feedback part #7 2011-03-22 16:46:39 +03:00
Sergey Petrunya
b9d4c69135 MWL#90: Address review feedback part #6: more clearer code in next_linear_tab() function 2011-03-22 13:17:14 +03:00
Sergey Petrunya
b77e3dc9f4 MWL#90: Address review feedback part #5 2011-03-22 13:09:55 +03:00
Sergey Petrunya
809a805251 MWL#90: Address review feedback part #4 2011-03-22 00:39:27 +03:00
Sergey Petrunya
4e5dbab5a6 MWL#90: Address review feedback part #3 2011-03-21 23:25:09 +03:00
Sergey Petrunya
d56e74eb9b MWL#90: Address review feedback part #2 2011-03-21 23:06:16 +03:00
Mayank Prasad
c8b724b2aa Bug #11751148 : show events shows events in other schema
Issue:
------
Due to prefix match, database like 'k' was matching with 'ka' and events of 'ka' we getting displayed for 'show event' of 'k'.

Resolution:
-----------
Scan for listing of events in a schema is made to be done on exact match of database (schema) name instead of just prefix.

mysql-test/r/events_bugs.result:
  modified expected file with the expected results.
mysql-test/t/events_bugs.test:
  added a test case to reproduce the scenario.
sql/event_db_repository.cc:
  Scan for schema name is made to be done on exact db name match.
2011-03-21 21:32:47 +05:30
Sergei Golubchik
299b29b273 lp:738091 cast(timestamp() AS time returns NULL for 0000-00-00 00:00:00 in 5.1-micro 2011-03-19 15:19:05 +01:00
Sergei Golubchik
a67bf98f02 lp:738067 Crash in get_datetime_value() in 5.1-micro 2011-03-19 14:54:46 +01:00
Sergey Petrunya
792c67ff61 MWL#90: Address review feedback part #1 2011-03-19 12:27:08 +03:00
Sergei Golubchik
e79a72a410 lp:737496 Assertion `(was_cut & 1) == 0' failed in Field_temporal::store_TIME_with_warning() in 5.1-micro
fix incorrect assert
2011-03-18 19:45:00 +01:00
Sergei Golubchik
c629477981 lp:737474 Wrong result with DAY(COALESCE(NULL)) in 5.1-micro
fix the return value of Item_func_coalesce::get_date()
2011-03-18 19:29:52 +01:00
Sergei Golubchik
5122e43a93 lp:737450 Second Assertion `item->null_value' failed in 5.1-micro
implement Item_func_min_max::get_date()
2011-03-18 19:23:32 +01:00
Sergei Golubchik
6998bacfb3 lp:737458 Casting dates and times into integers works differently in 5.1-micro
better default for Field::cast_to_int_type()
2011-03-18 14:52:20 +01:00
Sergei Golubchik
db9c46de40 number to time comparison 2011-03-18 13:50:39 +01:00
Sergei Golubchik
5ff5c4b8a3 lp:737111 Different behavior for TIMESTAMPADD with 0000-00-00 argument in 5.1-micro
respect fuzzydate flags in Item_*::get_date() methods
2011-03-18 13:43:33 +01:00
Sergei Golubchik
1a963822c8 lp:737104 Crash in DTCollation::set in 5.1-micro
and a different fix for lp:736370

cache temporal expression in Item_cache_int, not in Item_string.
invoke get_datetime_value() to create a correct Item_cache_int.
Implement Item_cache_int::clone, as it's a proper constant
2011-03-17 22:38:34 +01:00
Sergei Golubchik
684405e741 lp:737092 Assertion `item->null_value' failed in get_datetime_value in 5.1-micro
Implement Item_func_coalesce::get_date()
2011-03-17 22:04:45 +01:00
Sergei Golubchik
256185c50d lp:736370 Datetime functions in subquery context cause wrong result and bogus warnings in mysql-5.1-micro
Don't cache temporal value in an Item_string, it is compared differently.
2011-03-17 18:19:47 +01:00
Sergei Golubchik
d72f05fc5b lp:736791 Crash in make_truncated_value_warningwith LEAST()/GREATEST/COALESCE
and a test case for lp:736370 Datetime functions in subquery context cause wrong result
2011-03-17 15:57:04 +01:00
Sergei Golubchik
1cda265457 * fix for ALTER TABLE ... MODIFY timestamp->timestamp.
Use dedicated  do_field_temporal() for Copy_field.
* check_time_range() needs to know TIME's precision to use the
  correct max value.
2011-03-17 14:13:03 +01:00
Sergei Golubchik
a169ede155 lp:736358 Unexpected increased timestamp resolution with UNION
partial fix
2011-03-17 11:54:36 +01:00
Igor Babaev
8aaf9197d0 Merge. 2011-03-15 12:30:48 -07:00
Dmitry Shulga
9320dca994 Fixed Bug#11764168 "56976: SEVERE DENIAL OF SERVICE IN PREPARED STATEMENTS".
The problem was that server didn't check resulting size of prepared
statement argument which was set using mysql_send_long_data() API.
By calling mysql_send_long_data() several times it was possible
to create overly big string and thus force server to allocate
memory for it. There was no way to limit this allocation.

The solution is to add check for size of result string against
value of max_long_data_size start-up parameter. When intermediate
string exceeds max_long_data_size value an appropriate error message
is emitted.

We can't use existing max_allowed_packet parameter for this purpose
since its value is limited by 1GB and therefore using it as a limit
for data set through mysql_send_long_data() API would have been an
incompatible change. Newly introduced max_long_data_size parameter
gets value from max_allowed_packet parameter unless its value is
specified explicitly. This new parameter is marked as deprecated
and will be eventually replaced by max_allowed_packet parameter.
Value of max_long_data_size parameter can be set only at server
startup.


mysql-test/t/variables.test:
  Added checking for new start-up parameter max_long_data_size.
sql/item.cc:
  Added call to my_message() when accumulated string exceeds
  max_long_data_size value. my_message() calls error handler
  that was installed in mysql_stmt_get_longdata before call
  to Item_param::set_longdata.
  
  The error handler then sets state, last_error and last_errno
  fields for current statement to values which correspond to
  error which was caught.
sql/mysql_priv.h:
  Added max_long_data_size variable declaration.
sql/mysqld.cc:
  Added support for start-up parameter 'max_long_data_size'.
  This parameter limits size of data which can be sent from
  client to server using mysql_send_long_data() API.
sql/set_var.cc:
  Added variable 'max_long_data_size' into list of variables
  displayed by command 'show variables'.
sql/sql_prepare.cc:
  Added error handler class Set_longdata_error_handler.
  This handler is used to catch any errors that can be
  generated during execution of Item_param::set_longdata().
  
  Source code snippet that makes checking for statement's state 
  during statement execution is moved from Prepared_statement::execute()
  to Prepared_statement::execute_loop() in order not to call
  set_parameters() when statement has failed during
  set_long_data() execution. If this hadn't been done
  the call to set_parameters() would have failed.
tests/mysql_client_test.c:
  A testcase for the bug #56976 was added.
2011-03-15 17:36:12 +06:00
Davi Arnaut
07106d4ad9 Bug#11765202: Dbug_violation_helper::~Dbug_violation_helper(): Assertion `!_entered' failed.
Add a missing DBUG_RETURN function test_if_number().
2011-03-14 15:03:22 -03: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
e6b0be38f9 Bug fix for lp:732124 union + limit returns wrong result
mysql-test/r/union.result:
  Added test for lp:732124
mysql-test/t/union.test:
  Added test for lp:732124
sql/sp_rcontext.cc:
  Updated function definition for ::send_data()
sql/sp_rcontext.h:
  Updated function definition for ::send_data()
sql/sql_analyse.cc:
  Test if send_data() returned an error
sql/sql_class.cc:
  Updated function definition for ::send_data()
sql/sql_class.h:
  Changed select_result::send_data(List<Item> &items) to return -1 in case of duplicate row that should not be counted as part of LIMIT
sql/sql_cursor.cc:
  Check if send_data returned error
sql/sql_delete.cc:
  Updated function definition for ::send_data()
sql/sql_insert.cc:
  Updated function definition for ::send_data()
sql/sql_select.cc:
  Don't count rows which send_data() tells you to ignore
sql/sql_union.cc:
  Inform caller that the row should be ignored. This is the real bug fix for lp:732124
sql/sql_update.cc:
  Updated function definition for ::send_data()
2011-03-09 19:45:48 +02:00
Mattias Jonsson
ba85e3cf54 Merge of Bug#11766232 - bug#59297 2011-03-09 18:12:23 +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
Sergei Golubchik
3c6ff364ca lp:731815 Crash/valgrind warning Item::send with 5.1-micro
Two problems:
* Item_func_convert_tz() did not tell args[0] that it needs
  TIME_NO_ZERO_IN_DATE result
* Item_func_timediff did not respect fuzzy_date limitations,
  truncated seconds when casting to signed long, resulting in
  invalid time value (hours, seconds = (uint)-1).
2011-03-09 11:59:47 +01:00
Sergei Golubchik
eeb7f5129b lp:731089 Crash in Field_time_hires::pack_length on CREATE TABLE TIME(3)
add missing size_of() methods to new Field* classes
2011-03-09 09:20:23 +01: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
Sergei Golubchik
743b6f866b lp:731229 Different results depending on table access method with TIME column and CURDATE()
issue a warning when a datetime is truncated for storing in a TIME column.
this automatically prevents optimizer from using indexes when comparing time column to a datetime
2011-03-08 22:01:40 +01:00
Sergei Golubchik
8b7fd8f577 lp:731124 Loss of precision on DISTINCT
many changes:
* NOT_FIXED_DEC now create hires fields, not old ones.
  As a result, temp tables preserve microseconds (on DISTINCT, GROUP BY)
* I_S tables force decimals=0 on temporal types (backward compatibility)
* Item_func_coalesce calculates decimals for temporal types
* no precision for TIME/DATETIME in CAST means 0, not NOT_FIXED_DEC
* addtime/timediff calculate decimals from arguments (not NOT_FIXED_DEC)

sql/field.h:
  NOT_FIXED_DEC now create hires fields, not old ones
sql/item.h:
  force decimals=0 for I_S tables
sql/item_cmpfunc.cc:
  Item_func_coalesce calculates decimals for temporal types
sql/item_create.cc:
  no precision for TIME/DATETIME in CAST means 0, not NOT_FIXED_DEC
sql/item_timefunc.cc:
  addtime calculates decimals from arguments (not NOT_FIXED_DEC)
sql/item_timefunc.h:
  timediff calculates decimals from arguments (not NOT_FIXED_DEC)
2011-03-08 19:41:58 +01:00
Sergei Golubchik
2c80662d23 lp:731103 Assertion `maybe_null && item->null_value' failed with ORDER BY LAST_DAY()
Item_func_last_day did not set mayby_null=1
2011-03-08 10:14:43 +01: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
Sergei Golubchik
30e5b4d719 lp:730637 - Valgrind warnings in 5.1-micro
sql/field.cc:
  initialize ltime completely
sql/filesort.cc:
  don't pack MYSQL_TIME if it's not initialized
  (safe here, but valgrind complains)
sql/item_cmpfunc.cc:
  don't pack MYSQL_TIME if it's not initialized
  (safe here, but valgrind complains)
sql/item_timefunc.cc:
  don't check MYSQL_TIME members if it's uninitialized
  (safe here, but valgrind complains)
sql/time.cc:
  use c_ptr_safe() instead of c_ptr()
  (make valgrind happy)
2011-03-07 21:57:17 +01:00
Sergei Golubchik
19a3c29d64 lp:730627 TIME_to_ulonglong: Assertion `0' failed in 5.1-micro on wrong argument to MAKETIME
correct the return value of Item_func_maketime::get_date()
2011-03-07 16:27:49 +01: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
unknown
d2ac3542f2 Merge from mysql-5.1.56-release 2011-03-03 21:11:47 +01:00
Alexander Barkov
a1e9be8e8b Bug 11766519 - 59648: MY_STRTOLL10_MB2: ASSERTION `(*ENDPTR - S) % 2 == 0' FAILED.
Part 2. Function QUOTE() was not multi-byte safe.

  @ mysql-test/r/ctype_ucs.result
  @ mysql-test/t/ctype_ucs.test
  Adding tests

  @ sql/item_strfunc.cc
  Fixing Item_func_quote::val_str to be multi-byte safe.

  @ sql/item_strfunc.h
  Multiple size needed for quote characters to mbmaxlen
2011-03-03 18:39:26 +03:00
Alexander Barkov
1bc5e76efb BUG#11766519 (bug#59648): MY_STRTOLL10_MB2: ASSERTION `(*ENDPTR - S) % 2 == 0' FAILED
Problem: wrong character set pointer was passed to my_strtoll10_mb2,
which led to DBUG_ASSERT failure in some cases.

  @ mysql-test/r/func_encrypt_ucs2.result
  @ mysql-test/t/func_encrypt_ucs2.test
  @ mysql-test/r/ctype_ucs.result
  @ mysql-test/t/ctype_ucs.test
  Adding tests

  @ sql/item_func.cc
  "cs" initialization was wrong (res does not necessarily point to &str_value)

  @ sql/item_strfunc.cc
  Item_func_dec_encrypt::val_str() and Item_func_des_descrypt::val_str()
  did not set character set for tmp_value (the returned value),
  so the old value, which was previously copied from args[1]->val_str(),
  was incorrectly returned with tmp_value.
2011-03-03 15:04:04 +03:00
Alexander Barkov
165660fd29 An after-fix for
Bug#11765108 - Bug#58036: CLIENT UTF32, UTF16, UCS2 SHOULD BE DISALLOWED, THEY CRASH SERVER 

Fixing wrong usage of DBUG_ASSERT.
In non-debug version thd_init_client_charset
was not executed at all.
2011-03-03 11:25:37 +03: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
Sergei Golubchik
a8a757c6bb wl#173 - temporal types with sub-second resolution
and collateral changes.

* introduce my_hrtime_t, my_timediff_t, and conversion macros
* inroduce TIME_RESULT, but it can only be returned from Item::cmp_type(),
  never from Item::result_type()
* pack_time/unpack_time function for "packed" representation of
  MYSQL_TIME in a longlong that can be compared
* ADDTIME()/SUBTIME()/+- INTERVAL now work with TIME values
* numbers aren't quoted in EXPLAIN EXTENDED
* new column I_S.COLUMNS.DATETIME_PRECISION
* date/time values are compares to anything as date/time, not as strings or numbers.
* old timestamp(X) is no longer supported
* MYSQL_TIME to string conversion functions take precision as an argument
* unified the warnings from Field_timestamp/datetime/time/date/newdate store methods
* Field_timestamp_hires, Field_datetime_hires, Field_time_hires
* Field_temporal
* Lazy_string class to pass a value (string, number, time) polymorphically down the stack
* make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants
* removed Field::can_be_compared_as_longlong(). Use Field::cmp_type() == INT_RESULT instead
* introduced Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
* in many cases date/time types are treated like other types, not as special cases
* greatly simplified Arg_comparator (regarding date/time/year code)
* SEC_TO_TIME is real function, not integer.
* microsecond precision in NOW, CURTIME, etc
* Item_temporal. All items derived from it only provide get_date, but no val* methods
* replication of NOW(6)
* Protocol::store(time) now takes the precision as an argument
* @@TIMESTAMP is a double

client/mysqlbinlog.cc:
  remove unneded casts
include/my_sys.h:
  introduce my_hrtime_t, my_timediff_t, and conversion macros
include/my_time.h:
  pack_time/unpack_time, etc.
  convenience functions to work with MYSQL_TIME::second_part
libmysql/libmysql.c:
  str_to_time() is gone. str_to_datetime() does it now.
  my_TIME_to_str() takes the precision as an argument
mysql-test/include/ps_conv.inc:
  time is not equal to datetime anymore
mysql-test/r/distinct.result:
  a test for an old MySQL bug
mysql-test/r/explain.result:
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/func_default.result:
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/func_sapdb.result:
  when decimals=NOT_FIXED_DEC it means "not fixed" indeed
mysql-test/r/func_test.result:
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/func_time.result:
  ADDTIME()/SUBTIME()/+- INTERVAL now work with TIME values
mysql-test/r/having.result:
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/information_schema.result:
  new column I_S.COLUMNS.DATETIME_PRECISION
mysql-test/r/join_outer.result:
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/metadata.result:
  TIMESTAMP no longer has zerofill flag
mysql-test/r/range.result:
  invalid datetime is not compared with as a string
mysql-test/r/select.result:
  NO_ZERO_IN_DATE, etc only affect storage - according to the manual
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/subselect.result:
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/sysdate_is_now.result:
  when decimals=NOT_FIXED_DEC it means "not fixed" indeed
mysql-test/r/type_blob.result:
  TIMESTAMP(N) is not deprecated
mysql-test/r/type_timestamp.result:
  old TIMESTAMP(X) semantics is not supported anymore
mysql-test/r/union.result:
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/varbinary.result:
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/t/distinct.test:
  test for an old MySQL bug
mysql-test/t/func_time.test:
  +- INTERVAL now works with TIME values
mysql-test/t/select.test:
  typo
mysql-test/t/subselect.test:
  only one error per statement, please
mysql-test/t/system_mysql_db_fix40123.test:
  old timestamp(X) is no longer supported
mysql-test/t/system_mysql_db_fix50030.test:
  old timestamp(X) is no longer supported
mysql-test/t/system_mysql_db_fix50117.test:
  old timestamp(X) is no longer supported
mysql-test/t/type_blob.test:
  old timestamp(X) is no longer supported
mysql-test/t/type_timestamp.test:
  old timestamp(X) is no longer supported
mysys/my_getsystime.c:
  functions to get the time with microsecond precision
mysys/my_init.c:
  move the my_getsystime.c initialization code to my_getsystime.c
mysys/my_static.c:
  no need to make these variables extern
mysys/my_static.h:
  no need to make these variables extern
scripts/mysql_system_tables.sql:
  old timestamp(X) is no longer supported
scripts/mysql_system_tables_fix.sql:
  old timestamp(X) is no longer supported
scripts/mysqlhotcopy.sh:
  old timestamp(X) is no longer supported
sql-common/my_time.c:
  * call str_to_time from str_to_datetime, as appropriate
  * date/time to string conversions take precision as an argument
  * number_to_time()
  * TIME_to_double()
  * pack_time() and unpack_time()
sql/event_data_objects.cc:
  cast is not needed
  my_datetime_to_str() takes precision as an argument
sql/event_db_repository.cc:
  avoid dangerous downcast (because the pointer is
  not always Field_timestamp, see events_1.test)
sql/event_queue.cc:
  avoid silly double-work for cond_wait
  (having an endpoint of wait, subtract the current time to get the timeout,
  and use set_timespec() macro to fill in struct timespec, by adding the current
  time to the timeout)
sql/field.cc:
  * remove virtual Field::get_time(), everyone should use only Field::get_date()
  * remove lots of #ifdef WORDS_BIGENDIAN
  * unified the warnings from Field_timestamp/datetime/time/date/newdate store methods
  * Field_timestamp_hires, Field_datetime_hires, Field_time_hires
  * Field_temporal
  * make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants
sql/field.h:
  * remove virtual Field::get_time(), everyone should use only Field::get_date()
  * remove lots of #ifdef WORDS_BIGENDIAN
  * unified the warnings from Field_timestamp/datetime/time/date/newdate store methods
  * Field_timestamp_hires, Field_datetime_hires, Field_time_hires
  * Field_temporal
  * make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants
  * removed Field::can_be_compared_as_longlong(). Use Field::cmp_type() == INT_RESULT instead
sql/filesort.cc:
  TIME_RESULT, cmp_time()
sql/item.cc:
  * numbers aren't quoted in EXPLAIN EXTENDED
  * Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
  * virtual Item::get_time() is gone
  * Item_param::field_type() is set correctly
  * Item_datetime, for a datetime constant
  * time to anything is compared as a time
  * Item_cache::print() prints the value is available
  * bug fixed in Item_cache_int::val_str()
sql/item.h:
  * Item::print_value(), to be used from Item_xxx::print() when needed
  * Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
  * virtual Item::get_time() is gone
  * Item_datetime, for a datetime constant
  * better default for cast_to_int_type()
  * Item_cache objects now *always* have the field_type() set
sql/item_cmpfunc.cc:
  * get_year_value, get_time_value are gone. get_datetime_value does it all
  * get_value_a_func, get_value_b_func are gone
  * can_compare_as_dates() is gone too, TIME_RESULT is used instead
  * cmp_type() instead or result_type() when doing a comparison
  * compare_datetime and compate_e_datetime in the comparator_matrix, is_nulls_eq is gone
  * Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
sql/item_cmpfunc.h:
  greatly simplified Arg_comparator
sql/item_create.cc:
  * fix a bug in error messages in CAST
sql/item_func.cc:
  Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
  mention all possibitiles in switch over Item_result values, or use default:
sql/item_row.h:
  overwrite the default cmp_type() for Item_row,
  as no MYSQL_TYPE_xxx value corresponds to ROW_RESULT
sql/item_timefunc.cc:
  rewrite make_datetime to support precision argument
  SEC_TO_TIME is real function, not integer.
  many functions that returned temporal values had duplicate code in val_* methods,
  some of them did not have get_date() which resulted in unnecessary date->str->date conversions. 
  Now they all are derived from Item_temporal_func and *only* provide get_date, not val* methods.
  many fixes to set decimals (datetime precision) correctly.
sql/item_timefunc.h:
  SEC_TO_TIME is real function, not integer.
  many functions that returned temporal values had duplicate code in val_* methods,
  some of them did not have get_date() which resulted in unnecessary date->str->date conversions. 
  Now they all are derived from Item_temporal_func and *only* provide get_date, not val* methods.
  many fixes to set decimals (datetime precision) correctly.
sql/log_event.cc:
  replication of NOW(6)
sql/log_event.h:
  replication of NOW(6)
sql/mysql_priv.h:
  Lazy_string class to pass a value (string, number, time) polymorphically down the stack.
  make_truncated_value_warning() that uses it.
sql/mysqld.cc:
  datetime in Arg_comparator::comparator_matrix
sql/opt_range.cc:
  cleanup: don't disable warnings before calling save_in_field_no_warnings()
sql/protocol.cc:
  Protocol::store(time) now takes the precision as an argument
sql/protocol.h:
  Protocol::store(time) now takes the precision as an argument
sql/rpl_rli.cc:
  small cleanup
sql/set_var.cc:
  SET TIMESTAMP=double
sql/set_var.h:
  @@TIMESTAMP is a double
sql/share/errmsg.txt:
  precision and scale are unsigned
sql/slave.cc:
  replication of NOW(6)
sql/sp_head.cc:
  cleanup
sql/sql_class.cc:
  support for NOW(6)
sql/sql_class.h:
  support for NOW(6)
sql/sql_insert.cc:
  support for NOW(6)
sql/sql_select.cc:
  use item->cmp_type().
  move a comment where it belongs
sql/sql_show.cc:
  new column I_S.COLUMNS.DATETIME_PRECISION
sql/sql_yacc.yy:
  TIME(X), DATETIME(X), cast, NOW(X), CURTIME(X), etc
sql/time.cc:
  fix date_add_interval() to support MYSQL_TIMESTAMP_TIME argument
storage/myisam/ha_myisam.cc:
  TIMESTAMP no longer carries ZEROFIELD flag, still we keep MYI file compatible.
strings/my_vsnprintf.c:
  warnings
tests/mysql_client_test.c:
  old timestamp(X) does not work anymore
  datetime is no longer equal to time
2011-03-01 13:24:36 +01:00
unknown
7895c35874 MWL#89
Merge MWL#89 with 5.3.
2011-03-01 14:16:28 +02:00
Sergey Petrunya
125bfa2ce7 Fix error code handling in fix for BUG#724228 2011-03-01 13:33:23 +03:00
Sergey Petrunya
cb147b3965 Merge 5.3 -> 5.3-subqueries-mwl90 2011-03-01 13:21:48 +03:00
Sergey Petrunya
b8f00542e2 BUG#724228: Wrong result with materialization=on and three aggregates in maria-5.3-mwl90
- In join buffering code, call join_tab_execution_startup() (#1) before we call join_tab_scan->open() (#2).
  This is important with SJ-Materialization because #1 fills the materialized table, while
  #2 will actually try to read the first row. Attempt to read the first row before we have
  populated the materialized table would cause zero rows to be returned when actually there were matches.
2011-03-01 12:01:10 +03: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
Sergey Petrunya
862135a18a Code cleanup (remove garbage comments and #if 0-s) 2011-02-22 17:19:03 +03: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
Sergey Petrunya
9ccce9f100 Fix valgrind warnings 2011-02-20 11:35:26 +03: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
Sergey Petrunya
e7aa18fb9c Code cleanup (1) 2011-02-19 00:22:38 +03: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
Alexander Barkov
5f55c23208 Bug#11765108 (Bug#58036) client utf32, utf16, ucs2 should be disallowed, they crash server
A separate fix for 5.1 (as 5.1 and 5.5 have seriously
differged in the related pieces of the code).
A patch for 5.5 was approved earlier.

Problem: ucs2 was correctly disallowed in "SET NAMES" only,
while mysql_real_connect() and mysql_change_user() still allowed
to use ucs2, which made server crash.

Fix: disallow ucs2 in mysql_real_connect() and mysql_change_user().

  @ sql/sql_priv.h
    - changing return type for thd_init_client_charset() to bool,
      to return errors to the caller

  @ sql/sql_var.cc
    - using new function

  @ sql/sql_connect.cc
    - thd_client_charset_init:
      in case of unsupported client character set send error and return true;
      in case of success return false
    - check_connection:
      Return error if character set initialization failed

  @ sql/sql_parse.cc
    - check charset in the very beginnig of the CMD_CHANGE_USER handling code

  @ tests/mysql_client_test.c
    - adding tests
2011-02-18 16:12:36 +03:00
Sergey Petrunya
2c7c230a59 Fix typo 2011-02-18 15:11:16 +03:00
Sergey Petrunya
e7605349d6 Fix compiler warning 2011-02-18 14:35:41 +03:00
Sergey Petrunya
f93b0bbebb MWL#90: subquery optimizations
- Remove redundant changes againist 5.3-main
2011-02-18 14:17:28 +03:00
Martin Hansson
61b256177b Bug#11766675 - 59839: Aggregation followed by subquery yields wrong result
The loop that was looping over subqueries' references to outer field used a
local boolean variable to tell whether the field was grouped or not. But the
implementor failed to reset the variable after each iteration. Thus a field
that was not directly aggregated appeared to be.

Fixed by resetting the variable upon each new iteration.
2011-02-18 11:50:06 +01:00
Sergey Petrunya
9482a2cf09 Fix valgrind failure: don't look at join->join_tab[-1] 2011-02-17 15:37:38 +03:00
Magne Mahre
6503226743 Bug#48053 String::c_ptr has a race and/or does an invalid
memory reference

There are two issues present here.
  1) There is a possibility that we test a byte beyond the
     allocated buffer

  2) We compare a byte that might never have been
     initalized to see if it's 0.

The first issue is not triggered by existing code, but an
ASSERT has been added to safe-guard against introducing
new code that triggers it.

The second issue is what triggers the Valgrind warnings
reported in the bug report. A buffer is allocated in
class String to hold the value. This buffer is populated
by the character data constituting the string, but is not
zero-terminated in most cases.  Testing if it is indeed
zero-terminated means that we check a byte that has never
been explicitly set, thus causing Valgrind to trigger.

Note that issue 2 is not a serious problem.  The variable
is read, and if it's not zero, we will set it to zero.
There are no further consequences.

Note that this patch does not fix the underlying problems
with issue 1, as it is deemed too risky to fix at this
point (as noted in the bug report).  As discussed in
the report, the c_ptr() method should probably be
replaced, but this requires a thorough analysis of the
~200 calls to the method.


sql/set_var.cc:
  These two cases have been reported to fail
  with Valgrind.
2011-02-17 12:43:53 +01:00
Sergey Petrunya
0d26e2cdf5 Fix compiler warnings: add LINT_INIT() 2011-02-16 14:16:09 +03:00
Sergey Petrunya
e69c642920 Post-merge fixes part 5 2011-02-16 13:59:14 +03:00
Sergey Petrunya
716091e2a0 Post-merge fixes part 4 2011-02-16 13:26:27 +03:00
Sergey Petrunya
db7461783e Post-merge fixes part 3 2011-02-16 01:13:48 +03:00
Sergey Petrunya
089d2e2ea3 Post-merge fixes part 2 2011-02-16 00:59:02 +03:00
Sergey Petrunya
7e5795fe04 Post-merge fixes 2011-02-15 23:42:57 +03: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
Sergey Petrunya
cdccdea951 MWL#90: Merge (4) 2011-02-15 22:25:10 +03:00
Sergey Petrunya
e4325ff60b MWL#90: Subqueries: Inside-out execution for materialized non-sj subqueries
- Merge with 5.3 (3)
2011-02-15 20:29:57 +03: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
Georgi Kodinov
6b1b898ef6 weave merge mysql-5.1->mysql-5.1-security 2011-02-09 10:30:44 +02: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
unknown
17fe23e46c Merge from mysql-5.1.55-release 2011-02-08 12:52:33 +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
Dmitry Lenev
f74fd118cf Merged fix for bug #36544 "DROP USER does not remove stored
function privileges" into 5.5 tree. Did after-merge fixes.
2011-02-07 15:06:22 +03:00
Dmitry Lenev
b169b8d853 Fix for bug#36544 "DROP USER does not remove stored function
privileges".

The first problem was that DROP USER didn't properly remove privileges 
on stored functions from in-memory structures. So the dropped user
could have called stored functions on which he had privileges before
being dropped while his connection was still around.
Even worse if a new user with the same name was created he would
inherit privileges on stored functions from the dropped user.
Similar thing happened with old user name and function privileges
during RENAME USER.

This problem stemmed from the fact that the handle_grant_data() function
which handled DROP/RENAME USER didn't take any measures to update
in-memory hash with information about function privileges after
updating them on disk.

This patch solves this problem by adding code doing just that.

The second problem was that RENAME USER didn't properly update in-memory
structures describing table-level privileges and privileges on stored 
procedures. As result such privileges could have been lost after a rename
(i.e. not associated with the new name of user) and inherited by a new
user with the same name as the old name of the original user.

This problem was caused by code handling RENAME USER in
handle_grant_struct() which [sic!]:
a) tried to update wrong (tables) hash when updating stored procedure
   privileges for new user name.
b) passed wrong arguments to function performing the hash update and
   didn't take into account the way in which such update could have
   changed the order of the hash elements.

This patch solves this problem by ensuring that a) the correct hash
is updated, b) correct arguments are used for the hash_update()
function and c) we take into account possible changes in the order
of hash elements.

mysql-test/r/grant.result:
  Added test coverage for bug#36544 "DROP USER does not remove stored
  function privileges".
mysql-test/suite/funcs_1/r/innodb_storedproc_06.result:
  Since after fixing bug#36544 "DROP USER does not remove stored function
  privileges" in-memory structures are correctly updated by DROP USER,
  DROP FUNCTION performed after DROP USER for its definer no longer
  produces unwarranted warning/error messages.
mysql-test/suite/funcs_1/r/memory_storedproc_06.result:
  Since after fixing bug#36544 "DROP USER does not remove stored function
  privileges" in-memory structures are correctly updated by DROP USER,
  DROP FUNCTION performed after DROP USER for its definer no longer
  produces unwarranted warning/error messages.
mysql-test/suite/funcs_1/r/myisam_storedproc_06.result:
  Since after fixing bug#36544 "DROP USER does not remove stored function
  privileges" in-memory structures are correctly updated by DROP USER,
  DROP FUNCTION performed after DROP USER for its definer no longer
  produces unwarranted warning/error messages.
mysql-test/t/grant.test:
  Added test coverage for bug#36544 "DROP USER does not remove stored
  function privileges".
sql/sql_acl.cc:
  Changed handle_grant_data() to also update hash with function 
  privileges. This allows DROP/RENAME USER correctly keep this 
  in-memory structure up-to-date.
  
  To do this extended handle_grant_struct() to support updating of this
  hash. In addition fixed code in this function which is responsible for 
  handling of column and routine hashes during RENAME USER, ensured that
  we correctly update these hashes after changing user name and that we
  don't skip elements while iterating through the hash and doing updates.
2011-02-07 14:01:19 +03:00
Ole John Aske
221ce9223d Fix for bug#59308: Incorrect result for SELECT DISTINCT <col>... ORDER BY <col> DESC.
Also fix bug#59110: Memory leak of QUICK_SELECT_I allocated memory.
Includes Jørgen Lølands review comments.
      
Root cause of these bugs are that test_if_skip_sort_order() decided to
revert the 'skip_sort_order' descision (and use filesort) after the
query plan has been updated to reflect a 'skip' of the sort order.
      
This might happen in 'check_reverse_order:' if we have a 
select->quick which could not be made descending by appending 
a QUICK_SELECT_DESC. ().
      
The original 'save_quick' was then restored after the QEP has been modified,
which caused:
      
  - An incorrect 'precomputed_group_by= TRUE' may have been set, 
    and not reverted, as part of the already modifified QEP (Bug#59308)
  - A 'select->quick' might have been created which we fail to delete (bug#59110).
      
This fix is a refactorication of test_if_skip_sort_order() where all logic
related to modification of QEP (controlled by argument 'bool no_changes'), is
moved to the end of test_if_skip_sort_order(), and done after *all* 'test_if_skip'
checks has been performed - including the 'check_reverse_order:' checks.
      
The refactorication above contains now intentional changes to the logic which 
has been moved to the end of the function.
      
Furthermore, a smaller part of the fix address the handling of the 
select->quick objects which may already exists when we call 
'test_if_skip_sort_order()' (save_quick) -and
new select->quick's created during test_if_skip_sort_order():
      
  - Before new select->quick may be created by calling ::test_quick_select(), we
    set 'select->quick= 0' to avoid that ::test_quick_select() prematurely
    delete the save_quick's. (After this call we may have both a 'save_quick' 
    and 'select->quick')
      
  - All returns from ::test_if_skip_sort_order() where we may have both a
    'save_quick' and a 'select->quick' has been changed to goto's to the
    exit points 'skiped_sort_order:' or 'need_filesort:' where we
    decide which of the QUICK_SELECT's to keep, and delete the other.
2011-02-07 10:36:21 +01: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
Dmitry Shulga
378091e434 Fixed bug#58026 - massive recursion and crash in regular expression
handling.

The problem was that parsing of nested regular expression involved
recursive calls. Such recursion didn't take into account the amount of
available stack space, which ended up leading to stack overflow crashes.

mysql-test/t/not_embedded_server.test:
  Added test for bug#58026.
regex/my_regex.h:
  added pointer to function as last argument of my_regex_init() for check
  enough memory in stack.
regex/regcomp.c:
  p_ere() was modified: added call to function for check enough memory
  in stack. Function for check available stack space specified by
  global variable my_regex_enough_mem_in_stack. This variable set to
  NULL for embedded mysqld and to a pointer to function
  check_enough_stack_size otherwise.
regex/reginit.c:
  my_regex_init was modified: pass a pointer to a function for check
  enough memory in stack space. Reset this pointer to NULL in my_regex_end.
sql/mysqld.cc:
  Added function check_enough_stack_size() for check enough memory in stack.
  Passed this function as second argument to my_regex_init. For embedded 
  mysqld passed NULL as second argument.
2011-02-04 10:47:46 +06: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
Georgi Kodinov
72ae1d65dd merge to 5.1. 2011-02-02 19:05:28 +02:00
Georgi Kodinov
a70c34bf0f Fixes for Bug #55755 and Bug #52315 part 2
Bug #55755 : Date STD variable signness breaks server on FreeBSD and OpenBSD

* Added a check to configure on the size of time_t
* Created a macro to check for a valid time_t that is safe to use with datetime 
  functions and store in TIMESTAMP columns.
* Used the macro consistently instead of the ad-hoc checks introduced by 52315
* Fixed compliation warnings on platforms where the size of time_t is smaller than
  the size of a long (e.g. OpenBSD 4.8 64 amd64).

Bug #52315: utc_date() crashes when system time > year 2037

* Added a correct check for the timestamp range instead of just variable size check to
SET TIMESTAMP.
* Added overflow checking before converting to time_t. 
* Using a correct localized error message in this case instead of the generic error.
* Added a test suite.
* fixed the checks so that they check for unsigned time_t as well. Used the checks 
  consistently across the source code.
* fixed the original test case to expect the new error code.
2011-02-02 18:51:35 +02:00
Dmitry Lenev
e805a0fd9d Fix for bug #58650 "Failing assertion: primary_key_no == -1 ||
primary_key_no == 0".

Attempt to create InnoDB table with non-nullable column of
geometry type having an unique key with length 12 on it and
with some other candidate key led to server crash due to
assertion failure in both non-debug and debug builds.

The problem was that such a non-candidate key could have
been sorted as the first key in table/.FRM, before any legit
candidate keys. This resulted in assertion failure in InnoDB
engine which assumes that primary key should either be the
first key in table/.FRM or should not exist at all.

The reason behind such an incorrect sorting was an wrong
value of Create_field::key_length member for geometry field
(which was set to its pack_length == 12) which confused code
in mysql_prepare_create_table(), so it would skip marking
such key as a key with partial segments.

This patch fixes the problem by ensuring that this member
gets the same value of Create_field::key_length member as 
for other blob fields (from which geometry field class is
inherited), and as result unique keys on geometry fields
are correctly marked as having partial segments.


mysql-test/include/gis_keys.inc:
  Added test case for bug #58650 "Failing assertion:
  primary_key_no == -1 || primary_key_no == 0".
mysql-test/r/gis.result:
  Added test case for bug #58650 "Failing assertion:
  primary_key_no == -1 || primary_key_no == 0".
mysql-test/suite/innodb/r/innodb_gis.result:
  Added test case for bug #58650 "Failing assertion:
  primary_key_no == -1 || primary_key_no == 0".
mysql-test/suite/innodb_plugin/r/innodb_gis.result:
  Added test case for bug #58650 "Failing assertion:
  primary_key_no == -1 || primary_key_no == 0".
sql/field.cc:
  Changed Create_field::create_length_to_internal_length() to
  correctly set Create_field::key_length member for geometry
  fields. Similar to the blob types key_length for such fields
  should be the same as length and not field's packed length
  (which is always 12 for geometry).
  
  As result of this change code handling table creation now
  always correctly identifies btree/unique keys on geometry
  fields as partial keys, so such keys can't be erroneously
  treated as candidate keys and sorted in keys array in .FRM
  before legit candidate keys.
  
  This fixes bug #58650 "Failing assertion: primary_key_no ==
  -1 || primary_key_no == 0" in which incorrect candidate key
  sorting led to assertion failure in InnoDB code.
2011-02-02 16:17:48 +03: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
Ole John Aske
59269b1da1 Fix for bug#57030: ('BETWEEN' evaluation is incorrect')
Root cause for this bug is that the optimizer try to detect&
optimize the special case:
      
'<field>  BETWEEN c1 AND c1' and handle this as the condition '<field>  = c1'
            
This was implemented inside add_key_field(.. *field, *value[]...)
which assumed field to refer key Field, and value[] to refer a [low...high]
constant pair. value[0] and value[1] was then compared for equality.
            
In a 'normal' BETWEEN condition of the form '<field>  BETWEEN val1 and val2' the
BETWEEN operation is represented with an argementlist containing the
values [<field>, val1, val2] - add_key_field() is then called with
parameters field=<field>, *value=val1.
            
However, if the BETWEEN predicate specified:
            
 1)  '<const1>  BETWEEN<const2>  AND<field>
            
the 'field' and 'value' arguments to add_key_field() had to be swapped.
This was implemented by trying to cheat add_key_field() to handle it like:
            
 2) '<const1>  GE<const2>  AND<const1>  LE<field>'
            
As we didn't really replace the BETWEEN operation with 'ge' and 'le',
add_key_field() still handled it as a 'BETWEEN' and compared the (swapped)
arguments<const1>  and<const2>  for equality. If they was equal, the
condition 1) was incorrectly 'optimized' to:
            
 3) '<field>  EQ <const1>'
            
This fix moves this optimization of '<field>  BETWEEN c1 AND c1' into
add_key_fields() which then calls add_key_equal_fields() to collect 
key equality / comparison for the key fields in the BETWEEN condition.
2011-02-01 13:20:16 +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
Alfranio Correia
54c58cea3b merge mysql-5.1 (local) --> mysql-5.1 2011-01-31 10:11:01 +00:00
Alfranio Correia
ee36bd7f46 merge mysql-5.1 (local) --> mysql-5.1 2011-01-31 10:08:58 +00: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
Vladislav Vaintroub
b19e99865c MWL#55 : cherrypick MySQL 5.5 CMake/build improvements in order
to be able to build MSI based installer
2011-01-29 18:51:12 +01:00
Igor Babaev
9ea80ac481 Merge 2011-01-28 18:54:30 -08:00
Mattias Jonsson
d83706bc74 minor fix of copyright header 2011-01-28 13:37:39 +01:00
Alfranio Correia
8ce9b99246 BUG#59338 Inconsistency in binlog for statements that don't change any rows STATEMENT SBR
In SBR, if a statement does not fail, it is always written to the binary
log, regardless if rows are changed or not. If there is a failure, a
statement is only written to the binary log if a non-transactional (.e.g.
MyIsam) engine is updated.

INSERT ON DUPLICATE KEY UPDATE and INSERT IGNORE were not following the
rule above and were not written to the binary log, if then engine was
Innodb.

mysql-test/extra/rpl_tests/rpl_insert_duplicate.test:
  Added test case.
mysql-test/extra/rpl_tests/rpl_insert_ignore.test:
  Updated test case.
mysql-test/include/commit.inc:
  Updated test case as the calls to the binary log have changed
  for INSERT ON DUPLICATE and INSERT IGNORE.
mysql-test/r/commit_1innodb.result:
  Updated result file.
mysql-test/suite/rpl/r/rpl_insert_duplicate.result:
  Added test case.
mysql-test/suite/rpl/r/rpl_insert_ignore.result:
  Updated result file.
mysql-test/suite/rpl/t/rpl_insert_duplicate.test:
  Added test case.
mysql-test/suite/rpl/t/rpl_insert_ignore.test:
  Improved test case.
2011-01-28 12:09:15 +00:00
Sergey Vojtovich
7a3d113d9d Merge. 2011-01-28 14:51:28 +03:00
Sergey Vojtovich
e8ffaf4ae7 Merge. 2011-01-28 14:46:10 +03:00
Igor Babaev
d492903502 Fixed LP bug #707827.
This bug could manifest itself when hash join over a varchar column
with NULL values in some rows was used. It happened because the
function key_buf_cmp erroneously returned FALSE when one of the joined
key fields was null while the second was not.
Also fixed two other bugs in the functions key_hashnr and key_buf_cmp 
that could possibly lead to wrong results for some queries that
used hash join over several columns with nulls.
Also reverted the latest addition of the test case for bug #45092. It
had been already backported earlier.
2011-01-27 21:23:02 -08:00
Alfranio Correia
235e10d987 BUG#55675 rpl.rpl_log_pos fails sporadically with error binlog truncated in the middle
There are two calls to read_log_event() on master in mysql_binlog_send().
Each call reads 19 bytes in this test case and the error of the second
read_log_event() is reported to the slave.

The second read_log_event() starts from position 94 (75 + 19) to 113
(75 + 19 + 19). Usually, there are two events in the binary log:

    . 0   - 3   - Header
    . 4   - 105 - Format Descriptor Event
    . 106 - 304 - Query Event

and both reads fail because operations are reading from invalid positions
as expected.

However, mysql_binlog_send() does not use the same IO_CACHE that is used to
write into binary log (i.e. mysql_bin_log.log_file) for the hot binary log.
It opens the binary log file directly by calling open_binlog() and creates a
separated IO_CACHE. So there is a possibly that after a master has flushed
the binary log file, the content has been cached by the filesystem, and has
not updated the disk file. If this happens, then a slave will only see part
of the file, and thus the second read_log_event() will report event truncated
error.

To fix the problem, if the first read_log_event() has failed, we ensure that
the second one will try to read from the same position.
2011-01-28 01:25:26 +00:00
Mattias Jonsson
62ab200343 Update of copyright headers for files I changed this year. 2011-01-27 23:47:24 +01:00
unknown
49dd89fcc9 Merge fix for lp:697174 2011-01-27 16:54:49 +01:00
unknown
cf2a7c5b5e lp:697174: Do not put absolute path in status variable binlog_snapshot_file.
Omit the directory part to make the output the same as SHOW MASTER STATUS.
2011-01-27 16:51:11 +01:00
unknown
2b5a9147c8 automerge 2011-01-27 15:56:00 +01:00
unknown
fea75f404a MWL#136: Fix typo (wrong type) breaking compile. 2011-01-27 15:32:39 +01:00
Igor Babaev
3e868cd3cb Fixed LP bug #707848.
This was another bug in the patch for bug 698882. The new
code from this patch did not ensured that substitutions
of fields for best equal fields were performed on all
AND-OR levels. As a result substitutions for best fields
in some predicates that had been used by the range optimizer
were not actually performed while range plans could employ
these substitutions. This could lead to inconsistent data
structures and ultimately to a crash.
2011-01-26 20:45:23 -08:00
Igor Babaev
a624f99e98 Fixed LP bug #707555.
The bug was in the code of the patch fixing bug 698882.
With improper casting the method store_key_field::change_source_field
was called for the elements of the array TABLE_REF::key_copy that
were either of a different type or not allocated at all. This caused
crashes in some queries.
2011-01-26 11:30:29 -08:00
Mattias Jonsson
ec5e43da33 merge 2011-01-26 16:50:21 +01:00
unknown
6dbd796074 Merge three Percona patches into mariadb-5.2-rpl:
- MWL#47, allowing to annotate row-based binlog events with the SQL test of
   the originating query (eg. in mysqlbinlog output).

 - row_based_replication_without_primary_key.patch, providing more intelligent
   selection of index to use on slave when applying row-based binlog events
   for tables with no primary key.

 - Make mysqlbinlog omit redundant `use` around BEGIN/SAVEPOINT/COMMIT/
   ROLLBACK in 5.0 binlogs.
2011-01-26 15:35:03 +01:00
unknown
79a8e5f61b Fix incorrect DBUG_ASSERT(). 2011-01-26 14:25:34 +01:00
Michael Widenius
69fe020f01 Fixed bugs found by buildbot:
- Use -Wno-uninitialized if -DFORCE_INIT_OF_VARS is not used, to avoid warnings about not initialized variables.
- Fixed compiler warnings
- Added a name for each thr_lock to get better error messages (This is needed to find out why 'archive.test' sometimes fails)


BUILD/SETUP.sh:
  Use -Wno-uninitialized if -DFORCE_INIT_OF_VARS is not used, to avoid warnings about not initialized variables.
BUILD/build_mccge.sh:
  Use -Wno-uninitialized if -DFORCE_INIT_OF_VARS is not used, to avoid warnings about not initialized variables.
client/mysqltest.cc:
  Fixed bug in remove_files_wildcards (the orignal code never removed anything)
extra/libevent/devpoll.c:
  Fixed compiler warning
include/thr_lock.h:
  Added a name for each thr_lock to get better error messages.
mysql-test/suite/maria/t/maria3.test:
  Speed up test.
mysys/thr_lock.c:
  Added a name for each thr_lock to get better error messages.
  Added a second 'check_locks' to find if something goes wrong in 'wake_up_waiters'.
sql/lock.cc:
  Added a name for each thr_lock to get better error messages.
storage/xtradb/fil/fil0fil.c:
  Fixed compiler warning
2011-01-26 15:17:46 +02:00
Libing Song
8ec9bbaf59 Postfix bug#49124
Updated the copyright.
2011-01-26 15:30:06 +08:00
Karen Langford
de3c4428b8 Updating header copyright/README in source for 2011 2011-01-25 15:42:40 +01:00
Igor Babaev
edeeb023bc Post-second-review fixes for the patch that added the code allowing to use
hash join over equi-join conditions without supporting indexes.
2011-01-24 14:54:50 -08:00
unknown
fd6a079993 MWL#89
- fixed incorrect query plans that resulted from emptying the
  keyuse array with the access methods of the non-modified query
  plan.
- fixed compiler warning.
2011-01-24 23:38:39 +02:00
unknown
e2bd1ee9df Fix of LP bug#706884: fill_record should be used for only one table (no need list).
sql/sql_base.cc:
  fill_record should be used for only one table (no need list).
2011-01-24 15:47:28 +02:00
Mattias Jonsson
e24398ee42 Bug#59297: Can't find record in 'tablename' on update inner join
Regression introduced in bug#52455. Problem was that the
fixed function did not set the last used partition variable, resulting
in wrong partition used when storing the position of the newly
retrieved row.

Fixed by setting the last used partition in ha_partition::index_read_idx_map.
2011-01-24 13:41:44 +01:00
unknown
481cd2dbf1 Fix of problem with WHERE/HAVING consist of alone outer reference field by wrapping it.
sql/item.cc:
  Wrapper added.
sql/item.h:
  Wrapper added.
sql/mysql_priv.h:
  Wrap function added.
sql/sql_base.cc:
  Wrap function added.
  Fix of problem with WHERE consist of alone outer reference field by wrapping it.
sql/sql_select.cc:
  Fix of problem with HAVING consist of alone outer reference field by wrapping it.
2011-01-24 13:31:17 +02:00
unknown
49b7a1f48d Postfix BUG#58546
Updated Copyright.
2011-01-24 11:48:54 +08:00
Igor Babaev
b251d8a4c8 Merge 2011-01-23 10:39:53 -08:00
Igor Babaev
1f970d41e8 Fixed typo that caused printing 'range' instead of 'index_merge' as the type
of sort_intersect scans.
2011-01-22 23:45:52 -08:00
Igor Babaev
ec368ab9fa Merge 2011-01-21 22:48:28 -08:00
Igor Babaev
5cbb50eafd Fixed compiler warning 2011-01-21 21:31:53 -08:00
Igor Babaev
0f46efcba6 Post-review fixes for the patch that added the code allowing to use
hash join over equi-join conditions without supporting indexes.
2011-01-21 18:21:55 -08:00
unknown
902a307df1 Fix of reverting changes in depend_on list. 2011-01-21 09:56:55 +02:00
Michael Widenius
7057545699 Fixed some mysql-test-run failures and compile warnings/errors
Added logging of all possible fatal table errors if --log-warnings set to > 1


mysql-test/extra/rpl_tests/rpl_EE_err.test:
  Safety fix
mysql-test/extra/rpl_tests/rpl_row_basic.test:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/r/archive.result:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/r/csv.result:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/suite/maria/r/maria-autozerofill.result:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/suite/maria/t/maria-autozerofill.test:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/suite/maria/t/maria-recover.test:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/suite/parts/t/partition_recover_myisam.test:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/suite/rpl/r/rpl_bug38694.result:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/suite/rpl/r/rpl_idempotency.result:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/suite/rpl/r/rpl_ignore_table.result:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/suite/rpl/r/rpl_row_conflicts.result:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/suite/rpl/r/rpl_temporary_errors.result:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/suite/rpl/t/rpl_bug38694.test:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/suite/rpl/t/rpl_idempotency.test:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/suite/rpl/t/rpl_ignore_table.test:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/suite/rpl/t/rpl_row_basic_11bugs.test:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/suite/rpl/t/rpl_row_conflicts.test:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/suite/rpl/t/rpl_temporary_errors.test:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/t/archive.test:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
mysql-test/t/csv.test:
  Added suppression of possible error message (so that one can run test with --log-warnings=2)
sql/handler.cc:
  If running with --assert-of-crashed-table or --log-warnings > 1 then print engine error to log
sql/sql_select.cc:
  Disable not initialized warning from gcc
strings/Makefile.am:
  Fixed compiler error on Solaris 10 (duplicate strmov() function)
2011-01-20 19:08:12 +02:00
Sergei Golubchik
7effc175ce lp:705210 - Compiling with BUILD/compile-pentium64-debug fails
support building with -all-static (no dlopen and dlclose make few
related declarations unused or "statement have no effect") and -Werror
2011-01-20 13:00:46 +01:00
Martin Hansson
03db0de64f Bug#59173: Failure to handle DATE(TIME) values where Year, Month or Day is
ZERO
      
When dates are represented internally as strings, i.e. when a string constant
is compared to a date value, both values are converted to long integers,
ostensibly for fast comparisons. DATE typed integer values are converted to
DATETIME by multiplying by 1,000,000 (each digit pair representing hour,
minute and second, respectively). But the mechanism did not distuinguish
cached INTEGER values, already in correct format, from newly converted
strings.

Fixed by marking the INTEGER cache as being of DATETIME format.
2011-01-19 15:09:32 +01:00
Libing Song
77bc81b89c Bug#58546 test rpl_packet timeout failure sporadically on PB
rpl_packet got a timeout failure sporadically on PB when stopping
slave. The real reason of this bug is that STOP SLAVE stopped
IO thread first and then stopped SQL thread. It was
possible that IO thread stopped after replicating part of a
transaction which SQL thread was executing. SQL thread would
be hung if the transaction could not be rolled back safely.
            
After this patch, STOP SLAVE will stop SQL thread first and then stop IO
thread, which guarantees that IO thread will fetch the reset of the
events of the transaction that SQL thread is executing, so that SQL
thread can finish the transaction if it cannot be rolled back safely.
            
Added below auxiliary files to make the test code neater.
restart_slave_sql.inc
rpl_connection_master.inc
rpl_connection_slave.inc
rpl_connection_slave1.inc
2011-01-19 01:23:49 +08:00
unknown
2038256bed Fix LP BUG#704337
Analysis:
The cause for the failing assert was that between preparation
and execution of a DELETE prepared statement, the server reverted
back all changes of the item tree. Since the substitution of
Item_in_subselect by an Item_in_optimizer was recorded via
change_item_tree, thus the rollback of the item tree affected
the substitution as well. As a result the execution of the PS
called Item_in_subselect::val_int(), which was never supposed
to be called.

Solution:
Replace change_item_tree with assignment. This is OK because
the Item objects used for substitution are created in PS memory.
2011-01-18 19:15:55 +02:00
unknown
5c4e64a574 MWL#89
Fixed query plans with loose index scan degraded into index scan.

Analysis:
With MWL#89 subqueries are no longer executed and substituted during
the optimization of the outer query. As a result subquery predicates
that were previously executed and substituted by a constant before
the range optimizer were present as regular subquery predicates during
range optimization. The procedure check_group_min_max_predicates()
had a naive test that ruled out all queries with subqueries in the
WHERE clause. This resulted in worse plans with MWL#89.

Solution:
The solution is to refine the test in check_group_min_max_predicates()
to check if each MIN/MAX argument is referred to by a subquery predicate.
2011-01-18 00:53:41 +02:00
Alexander Barkov
6665ca25af Bug#58371 Assertion failed: !s.uses_buffer_owned_by(this) with format string function
Introduced by the fix for bug#44766.

Problem: it's not correct to use args[0]->str_value as a buffer,
because args[0] may need this buffer for its own purposes.

Fix: adding a new class member tmp_value to use as return value.

  @ mysql-test/r/ctype_many.result
  @ mysql-test/t/ctype_many.test
  Adding tests

  @ sql/item_strfunc.cc
  Changing code into traditional style:
  use "str" as a buffer for the argument and tmp_value for the result value.

  @ sql/item_strfunc.h
  Adding tmp_value
2011-01-17 15:11:33 +03:00
unknown
b1a6ecd64c Fix LP BUG#702345
Analysis:
Close to its end JOIN::optimize() assigns having to tmp_having, and
sets the having clause to NULL:

  tmp_having= having;
  if (select_options & SELECT_DESCRIBE)
  {
    error= 0;
    DBUG_RETURN(0);
  }
  having= 0;

At the same time, this query detects an empty result set, and calls
return_zero_rows(), which checks the HAVING clause as follows:

    if (having && having->val_int() == 0)
      send_row=0;

However having has been already set to NULL, so return_zero_rows
doesn't check the having clause, hence the wrong result.

Solution:
Check join->tmp_having in addition to join->having.

There is no additional test case, because the failure was in
the current regression test.
2011-01-17 13:48:14 +02:00
Alexander Barkov
a2850a2f53 Bug#59149 valgrind warnings with "like .. escape .." function
Problem: when processing a query like:
  SELECT '' LIKE '1' ESCAPE COUNT(1);
escape_item->val_str() was never executed and the "escape" class member
stayed initialized, which led to valgrind uninitialized memory error.
      
Note, a query with some tables in "FROM" clause
returns ER_WRONG_ARGUMENTS in the same situation:

   SELECT '' LIKE '1' ESCAPE COUNT(1) FROM t1;
   ERROR 1210 (HY000): Incorrect arguments to ESCAPE

Fix: disallowing using aggregate functions in ESCAPE clause,
even if there are no tables used. There is no much use of that anyway.
2011-01-17 12:30:22 +03:00
unknown
12c6d1f355 BUG#49124 Security issue with /*!-versioned */ SQL statements on Slave
Backport to 5.0.

/*![:version:] Query Code */, where [:version:] is a sequence of 5 
digits representing the mysql server version(e.g /*!50200 ... */),
is a special comment that the query in it can be executed on those 
servers whose versions are larger than the version appearing in the 
comment. It leads to a security issue when slave's version is larger 
than master's. A malicious user can improve his privileges on slaves. 
Because slave SQL thread is running with SUPER privileges, so it can
execute queries that he/she does not have privileges on master.
      
This bug is fixed with the logic below: 
- To replace '!' with ' ' in the magic comments which are not applied on
  master. So they become common comments and will not be applied on slave.
      
- Example:
  'INSERT INTO t1 VALUES (1) /*!10000, (2)*/ /*!99999 ,(3)*/
   will be binlogged as
  'INSERT INTO t1 VALUES (1) /*!10000, (2)*/ /* 99999 ,(3)*/
2011-01-15 13:48:16 +08:00
Igor Babaev
56f4e6b460 Merge 2011-01-14 11:16:01 -08:00
Michael Widenius
3c0a37fd18 Call always ha_index_init(), not index_init(), to ensure that active_index is set correctly.
Fixes failures in merge.test
2011-01-14 16:45:14 +02:00
Sergei Golubchik
418df96d51 use bulk insert and repair by sort for unique keys in
Aria and MyISAM in create_internal_tmp_table_from_heap()
(safe, as duplicates are impossible).
This gives a HUGE speed boost!

sql/opt_subselect.cc:
  Fixed problem with wrong recinfo in create_duplicate_weedout_tmp_tabl()
  Tagged the table with 'no_rows' so that when we create the table on disk,
  we only store the index data. This gave us a major speedup!
sql/sql_select.cc:
  create_tmp_table_from_heap() now uses bulk_insert + repair_by_sort
  when creating Aria/MyISAM tables from HEAP tables.
  This gives a HUGE speed boost!
storage/maria/ha_maria.cc:
  Extended bulk_insert() to recreate UNIQUE keys for
  internal temporary tables
storage/maria/ma_open.c:
  Initialize m_info->lock.type properly for temporarly tables
  (needed for start_bulk_insert())
storage/maria/ma_write.c:
  Don't check uniques that are disabled
storage/myisam/ha_myisam.cc:
  Extended bulk_insert() to recreate UNIQUE keys for
  internal temporary tables.
2011-01-14 12:03:41 +01:00
Sergei Golubchik
6554977fe5 Added ha_write_tmp_row() for slightly faster write_row for internal temp tables.
This will also enable us in the future to collect statistics for
writes to internal tmp tables.

sql/handler.h:
  Added ha_write_tmp_row()
sql/opt_subselect.cc:
  ha_write_row -> ha_write_tmp_row
sql/sql_class.h:
  Added ha_write_tmp_row()
sql/sql_select.cc:
  ha_write_row -> ha_write_tmp_row
2011-01-14 11:58:45 +01:00
Sergei Golubchik
f5ea301acc Added support for NO_RECORD record format (don't store any row data) for Aria.
This makes the keys smaller (no row pointer) and gives us proper errors if we
use the table wrongly.

sql/sql_select.cc:
  Use NO_RECORD for tables that doesn't need row data.
storage/maria/Makefile.am:
  Added ma_norec.c
storage/maria/ma_check.c:
  Added support for NO_RECORD record format (don't store any row data)
storage/maria/ma_norec.c:
  Added support for NO_RECORD record format
storage/maria/ma_open.c:
  Added support for NO_RECORD record format
storage/maria/ma_search.c:
  Added support for 0 size row pointers (used with NO_RECORD)
storage/maria/ma_test1.c:
  Added testing of NO_RECORD record format.
storage/maria/maria_chk.c:
  Added support for NO_RECORD
storage/maria/maria_def.h:
  Added support for NO_RECORD
storage/maria/unittest/ma_test_all-t:
  Added testing of NO_RECORD record format
2011-01-14 11:54:39 +01:00
Sergei Golubchik
17c188779b use normal unique (HA_NOSAME) keys for expression cache
temptables, not "uniques", that are hash-based keys.

sql/sql_expression_cache.cc:
  Don't set uniques (we don't want or need an unique
  constraint on this table)
2011-01-14 11:43:42 +01:00
Sergei Golubchik
3d5868c682 compare "Copying to tmp table" proc_info as a pointer, not as a string 2011-01-14 11:34:41 +01:00
Michael Widenius
26aa83bfc0 Fix for LP#702786 "Two handler read f1 next gives different errors"
mysql-test/suite/handler/heap.result:
  New test case
mysql-test/suite/handler/heap.test:
  New test case
sql/sql_handler.cc:
  If we get a fatal error in handler read, end table/index scan as it's likely it was wrongly used (for example not supported feature for index)
2011-01-14 12:32:23 +02:00
Sergei Golubchik
563da78d57 Removed some old comments.
mysys/my_handler.c:
  Fixed typo
2011-01-14 11:31:09 +01:00
Sergey Petrunya
ff7f5879b5 Merge 5.3-subquery-bugfixing -> 5.3 2011-01-18 00:26:04 +03:00
Igor Babaev
e32efc013a Merge 2011-01-15 12:42:32 -08:00
Igor Babaev
84a0c9b2a2 Fixed LP bug #698882.
Made sure that the optimal fields are used by TABLE_REF objects
when building index access keys to joined tables.
Fixed a bug in the template function that sorts the elements of
a list using the bubble sort algorithm. The bug caused poor
performance of the function. Also added an optimization that
skips comparison with the most heavy elements that has been 
already properly placed in the list.
Made the comparison of the fields belonging to the same Item_equal
more granular: fields belonging to the same table are also ordered
according to some rules.
2011-01-15 11:14:36 -08:00
Igor Babaev
92f2392eb5 Merge 2011-01-14 23:53:27 -08:00
Igor Babaev
0aebdc115f Ported the fix for LP bug #702310 / bug #59493.
An assertion failure was triggered for a 6-way join query that used two
join buffers.
The failure happened because every call of JOIN_CACHE::join_matching_records
saved and restored status of all tables that were accessed before the table
join_tab. It must do it only for those of them that follow the last table 
using a join buffer.
2011-01-14 22:55:56 -08:00