Commit graph

27223 commits

Author SHA1 Message Date
Sergey Glukhov
47885f552b Bug#11766087 59125: VALGRIND UNINITIALISED VALUE WARNING IN ULL2DEC, LONGLONG2DECIMAL
Valgrind warning happens due to missing NULL value check in
Item_func::val_decimal. The fix is to add this check.


mysql-test/r/func_time.result:
  test case
mysql-test/t/func_time.test:
  test case
sql/item_func.cc:
  added check for NULL value
2011-03-28 17:27:44 +04:00
Sergey Glukhov
d6125b27b3 Bug#11765216 58154: UNINITIALIZED VARIABLE FORMAT IN STR_TO_DATE FUNCTION
Valgrind warning happens due to uninitialized cached_format_type field
which is used later in Item_func_str_to_date::val_str method.
The fix is to init cached_format_type field.


mysql-test/r/func_time.result:
  test case
mysql-test/t/func_time.test:
  test case
sql/item_timefunc.cc:
  init cached_format_type field
2011-03-28 17:24:25 +04:00
Michael Widenius
b20efbb119 Fixed test failures with embedded server
mysql-test/mysql-test-run.pl:
  Don't set --log-error when running embedded server as we don't want the mysqltest output into mysqld.1.err
sql/mysqld.cc:
  Allow one to disable --log-error
2011-03-28 12:49:20 +03:00
Sergey Glukhov
2901548911 automerge 2011-03-28 13:09:02 +04:00
Magne Mahre
9ff72a1acf Bug#11900714 REMOVE LGPL LICENSED FILES IN MYSQL 5.1
The LGPL license is used in some legacy code, and to
adhere to current licensing polity, we remove those
files that are no longer used, and reorganize the
remaining LGPL code so it will be GPL licensed from
now on.
      
Note:  This patch only removed LGPL licensed files
       in MySQL 5.1, and is the second of a set of
       patches to remove LGPL from all trees.
       (See Bug# 11840513 for details)
2011-03-28 10:47:30 +02:00
Sergey Glukhov
a88faf2a4a Bug#11764994 57900: CREATE TABLE .. SELECT ASSERTS SCALE >= 0 && PRECISION > 0 && SCALE <= PR
Assert fails due to overflow which happens in
Item_func_int_val::fix_num_length_and_dec() as
geometry functions have max_length value equal to
max_field_size(4294967295U). The fix is to skip
max_length calculation for some boundary cases.


mysql-test/r/func_math.result:
  test case
mysql-test/t/func_math.test:
  test case
sql/item_func.cc:
  skip max_length calculation
  if argument max_length is near max_field_size.
2011-03-28 12:35:50 +04:00
Sergey Glukhov
ff23f5360e Bug#11766424 59527: DECIMAL_BIN_SIZE: ASSERTION `SCALE >= 0 && PRECISION > 0 && SCALE <= PRE
Assertion happens due to missing initialization of unsigned_flag
for Item_func_set_user_var object. It leads to incorrect
calculation of decimal field size.
The fix is to add initialization of unsigned_flag.


mysql-test/r/variables.result:
  test case
mysql-test/t/variables.test:
  test case
sql/item_func.cc:
  add initialization of unsigned_flag.
2011-03-28 12:28:30 +04:00
Sergey Glukhov
d499851be0 Bug#11766112 59151:UNINITIALIZED VALUES IN EXTRACT_DATE_TIME WITH STR_TO_DATE(SPACE(..) ...
Valgrind warining happens due to missing
'end of the string' check. The fix is to
check if we reached the end of the string.


mysql-test/r/func_time.result:
  test case
mysql-test/t/func_time.test:
  test case
sql/item_timefunc.cc:
  check if we reached the end of
  the string after leading spaces skipping.
2011-03-28 11:53:18 +04:00
Vladislav Vaintroub
6058b9ea0a Fix build error (wrong printf-like format) 2011-03-28 02:02:24 +02: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
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
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
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
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
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
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
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
Michael Widenius
9aa44bb4b3 Fixed wrong alias usage 2011-03-01 23:24:17 +02: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
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
Michael Widenius
1c23091c4e Fixed build failures
- Removed references to deleted files
- If we link staticly, check for static zlib
  - This should fix the problem with 'no -lz found' link error
- Fixed build failure on window (Patch from Wlad)
- Fixed build problem with federatedx when using -Werror

BUILD/Makefile.am:
  Remove removed file
config/ac-macros/zlib.m4:
  If we compile with --all-static, test that we have a static libz
libmysqld/CMakeLists.txt:
  Fix for build error on windows
mysql-test/suite/pbxt/r/key_cache.result:
  Updated result
mysql-test/suite/pbxt/t/key_cache.test:
  Fixed not updated test case
sql/CMakeLists.txt:
  Fix for build error on windows
storage/federatedx/Makefile.am:
  Don't use CFLAGS to compile C++ programs
storage/pbxt/src/lock_xt.cc:
  Fixed compiler warning about using uninitialized b2
storage/xtradb/buf/buf0buf.c:
  Fixed wrong printf
storage/xtradb/srv/srv0srv.c:
  Fixed assignment of different width and test with different sign/unsigned
2011-02-23 11:22:56 +02:00
Michael Widenius
988d263e25 Merge with main 2011-02-22 20:28:01 +02:00
Michael Widenius
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Mattias Jonsson
ec5e43da33 merge 2011-01-26 16:50:21 +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
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
49b7a1f48d Postfix BUG#58546
Updated Copyright.
2011-01-24 11:48:54 +08: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
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
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
Igor Babaev
c8e56e3713 Fixed LP bug #702310 / bug #59493.
An assertion failure was triggered for a 6-way join query that uses two
join buffers.
The failure happened because every call of the function flush_cached_records()
saved and restored status of all tables before the table join_tab. It
must do it only for those of them that follow the last table that uses
a join buffer.
2011-01-14 02:05:10 -08:00
Martin Hansson
716b64cdb0 Bug#58165: "my_empty_string" gets modified and causes LOAD DATA to fail and
other crashes

Some string manipulating SQL functions use a shared string object intended to
contain an immutable empty string. This object was used by the SQL function
SUBSTRING_INDEX() to return an empty string when one argument was of the wrong
datatype. If the string object was then modified by the sql function INSERT(),
undefined behavior ensued.

Fixed by instead modifying the string object representing the function's
result value whenever string manipulating SQL functions return an empty
string.

Relevant code has also been documented.
2011-01-13 08:57:15 +01:00
Georgi Kodinov
7f9ce73d49 merge 2011-01-12 17:08:52 +02:00
Michael Widenius
d0e8dbc4a3 Merge with 5.1 2011-01-12 16:32:52 +02:00
Michael Widenius
213321206e Fix for LP#697610 ha_index_prev(uchar*): Assertion `inited==INDEX' failed with HANDLER + InnoDB in maria-5.3
mysql-test/suite/handler/innodb.result:
  Added test case
mysql-test/suite/handler/innodb.test:
  Added test case
sql/handler.h:
  Move setting/resetting of active_index to ha_index_init()/ha_index_end() to simplify handler functions index_init()/index_end()
  Fixed that get_index() returns MAX_KEY if index is not inited (this fixed LP#697610)
storage/federated/ha_federated.cc:
  Settting of active_index is not needed anymore
storage/maria/ma_pagecache.c:
  Added error message if we have too little memory for Maria page cache
2011-01-12 15:41:39 +02:00
Alexey Botchkov
33c78e328f Bug #57321 crashes and valgrind errors from spatial types
Item_func_spatial_collection::fix_length_and_dec didn't call parent's method, so
        the maybe_null was set to '0' after it. But in this case the result was
        just NULL, that caused wrong behaviour.

per-file comments:
  mysql-test/r/gis.result
Bug #57321 crashes and valgrind errors from spatial types 
        test result updated.

  mysql-test/t/gis.test
Bug #57321 crashes and valgrind errors from spatial types 
        test case added.
  sql/item_geofunc.h
Bug #57321 crashes and valgrind errors from spatial types 
        Item_func_geometry::fix_length_and_dec() called in
        Item_func_spatial_collection::fix_length_and_dec().
2011-01-12 17:02:41 +04:00
Dmitry Lenev
599457ae2c Fix for bug #58499 "DEFINER-security view selecting from
INVOKER-security view access check wrong".

When privilege checks were done for tables used from an 
INVOKER-security view which in its turn was used from 
a DEFINER-security view connection's active security
context was incorrectly used instead of security context
with privileges of the second view's creator.

This meant that users which had enough rights to access
the DEFINER-security view and as result were supposed to 
be able successfully access it were unable to do so in 
cases when they didn't have privileges on underlying tables 
of the INVOKER-security view.

This problem was caused by the fact that for INVOKER-security
views TABLE_LIST::security_ctx member for underlying tables
were set to 0 even in cases when particular view was used from 
another DEFINER-security view. This meant that when checks of
privileges on these underlying tables was done in
setup_tables_and_check_access() active connection security 
context was used instead of context corresponding to the 
creator of caller view.

This fix addresses the problem by ensuring that underlying
tables of an INVOKER-security view inherit security context
from the view and thus correct security context is used for
privilege checks on underlying tables in cases when such view 
is used from another view with DEFINER-security.

mysql-test/r/view_grant.result:
  Added coverage for various combinations of DEFINER and
  INVOKER-security views, including test for bug #58499
  "DEFINER-security view selecting from INVOKER-security
  view access check wrong".
mysql-test/t/view_grant.test:
  Added coverage for various combinations of DEFINER and
  INVOKER-security views, including test for bug #58499
  "DEFINER-security view selecting from INVOKER-security
  view access check wrong".
sql/sql_view.cc:
  When opening a non-suid view ensure that its underlying 
  tables will get the same security context as use for
  checking privileges on the view, i.e. security context
  of view invoker. This context can be different from the
  security context which is currently active for connection 
  in cases when this non-suid view is used from a view with
  suid security. Inheriting security context in such situation
  allows correctly apply privileges of creator of suid view
  in checks for tables of non-suid view (since in this 
  situation creator/definer of suid view serves as invoker
  for non-suid view).
2011-01-12 16:08:30 +03:00
Michael Widenius
d52a41d26a Merge with 5.1 2011-01-14 16:49:27 +02:00
Michael Widenius
4c576fd492 Merge with 5.1 2011-01-12 17:38:13 +02:00