Commit graph

27223 commits

Author SHA1 Message Date
Michael Widenius
c9a0d7338c Ensure we don't read a MariaDB 5.3 errmsg.sys file or new errmsg.sys file with holes for not used error messages
sql/derror.cc:
  Ensure we don't read a MariaDB 5.3 errmsg.sys file with moved error messages or a new errmsg.sys file with holes for not used error messages
  If error message file didn't exist and we have not read one in the past, don't continue.
  Give better error message if the errmsg.sys header has changed.
2011-05-20 14:36:13 +03:00
Vladislav Vaintroub
f4ae8b7691 - Properly terminate options array with all-zero entry.
- Fix CRLF end of lines, use LF instead
2011-05-20 01:38:42 +02:00
Vladislav Vaintroub
b898022a6d Fix compile error on Unixes
my_rwlock_destroy=>rwlock_destroy
2011-05-14 18:59:06 +02:00
Vladislav Vaintroub
8a376ae237 LPBUG#782223 : Memory released by Query_cache::resize() or Query_cache::free() contains active rwlocks.
The bug was found by application verifier. 
Fixed by destroying locks prior to free(),
2011-05-14 18:37:20 +02:00
Vladislav Vaintroub
1779c2adbf merge 2011-05-12 16:31:54 +02:00
Vladislav Vaintroub
984fa23b45 merge 2011-05-12 15:39:54 +02:00
Vladislav Vaintroub
1c95254523 Fix check_table_file_presence:
On Windows, do not attempt access() for special device names like
CON, PRN etc. access() would return 0, this does not mean that fiile
with this name exists.
2011-05-12 15:31:11 +02:00
Oleksandr Byelkin
84505e6e3a db_name can change case, so we need copy of it for case insensitive FS. 2011-05-12 14:56:08 +03:00
unknown
520927a7df Bugfix: New table creation/renaming block added if old encoded table present.
mysql-test/r/create.result:
  test of renaming
mysql-test/r/upgrade.result:
  Now such behaviour prohibited to avoid problems.
mysql-test/t/create.test:
  test of renaming
mysql-test/t/upgrade.test:
  Now such behaviour prohibited to avoid problems.
sql/mysql_priv.h:
  Function to test table name presence added.
sql/sql_rename.cc:
  Rename fixed.
sql/sql_table.cc:
  Function to test table name presence added.
  Create fixed.
2011-05-11 14:09:48 +03:00
Sergei Golubchik
e343a2c134 small enhancement of the create table options feature:
no unnecessary casting from void*, more type safety.
typos fixed.
2011-05-10 18:19:11 +02:00
unknown
e1ceb8048c Automatic merge Mariadb 5.1->5.2. 2011-05-09 15:09:40 +02:00
unknown
e2ff288531 Fix buildbot failure in rpl_stop_slave.test.
Problem was setting DEBUG_SYNC twice in a row too fast in the test case; this
could cause the second setting to override the first before the code had time
to react to the first, causing the signal to get lost.

Fixed by waiting for the code to receive the first signal before overwriting
it in the test case.
2011-05-09 15:06:16 +02:00
Michael Widenius
8882d71f3f Make event stop code even more robust.
(Test failed if we added my_sleep(200000) in event_queue::cond_wait() just before pthread_cond_wait();  Not likely scenario but better to get that fixed too)
2011-05-09 15:14:04 +03:00
Michael Widenius
4cb68c0e89 mysqltest: Write command to be executed to the log BEFORE executing the command.
Fixed race condition in event that could cause hang when stopping event scheduler with SET GLOBAL event_scheduler=OFF 

client/mysqltest.cc:
  Write command to be executed to the log BEFORE executing the command.
  This makes it easier to debug crashes as the log will contain the fatal command.
mysql-test/r/mysqltest.result:
  Updated results (we now get more things logged)
sql/event_queue.cc:
  Fixed race condition in event that could cause hang when stopping event scheduler with SET GLOBAL event_scheduler=OFF.
  The reason was that a kill signal could be sent between last check of thd->killed and before thd->enter_cond() in which case the signal
  would be missed and we would be stuck in Event_scheduler::stop() forever.
2011-05-09 14:38:49 +03:00
Vladislav Vaintroub
ba87d4810a Fix effect of recent mismerge (it made default pid file name ".pid" instead of "hostname.pid") 2011-05-07 19:27:07 +02:00
Michael Widenius
4249382a65 Automatic merge 2011-05-04 22:33:18 +03:00
Michael Widenius
718ddbb2ca Automatic merge with 5.1 2011-05-04 22:25:56 +03:00
Michael Widenius
3c9ae014ca Fixed build errors on centos5-amd64-minimal, where we compile with very few character sets
Fixed compiler warnings

client/readline.cc:
  Fixed compiler warning
mysql-test/t/mysqldump.test:
  Only run test if utf8 is used
sql/log.cc:
  Fixed compiler warning
sql/mysql_priv.h:
  Fixed compiler warnings
tests/mysql_client_test.c:
  Don't abort test if ucs2 is not in use.
2011-05-04 21:28:02 +03:00
Vladislav Vaintroub
e4732a765e fix noisy warnings in header files 2011-05-04 14:47:27 +02:00
Michael Widenius
1be5462d59 Merge with MariaDB 5.1 2011-05-03 19:10:10 +03:00
Michael Widenius
e415ba0fb2 Merge with MySQL 5.1.57/58
Moved some BSD string functions from Unireg
2011-05-02 20:58:45 +03:00
Michael Widenius
046418ad95 Added calls to cleanup_mutexes() for embedded library. 2011-04-28 23:58:00 +03:00
Sergey Glukhov
a60c39a2ff Bug#11889186 60503: CRASH IN MAKE_DATE_TIME WITH DATE_FORMAT / STR_TO_DATE COMBINATION
calc_daynr() function returns negative result
if malformed date with zero year and month is used.
Attempt to calculate week day on negative value
leads to crash. The fix is return NULL for
'W', 'a', 'w' specifiers if zero year and month is used.
Additional fix for calc_daynr():
--added assertion that result can not be negative
--return 0 if zero year and month is used


mysql-test/r/func_time.result:
  test case
mysql-test/t/func_time.test:
  test case
sql-common/my_time.c:
  --added assertion that result can not be negative
  --return 0 if zero year and month is used
sql/item_timefunc.cc:
  eturn NULL for 'W', 'a', 'w' specifiers
  if zero year and month is used.
2011-04-27 11:35:57 +04:00
Guilhem Bichot
c575254f9d merge from 5.1 2011-04-26 13:06:44 +02:00
Mattias Jonsson
bdaaee5d04 post fix for werror build for bug#11766249. 2011-04-26 10:21:09 +02:00
Mattias Jonsson
bd707d128a merge 2011-04-23 16:57:24 +02:00
Sergey Glukhov
a5e8d9029b Bug#11756928 48916: SERVER INCORRECTLY PROCESSING HAVING CLAUSES WITH AN ORDER BY CLAUSE
Before sorting HAVING condition is split into two parts,
first part is a table related condition and the rest of is
HAVING part. Extraction of HAVING part does not take into account
the fact that some of conditions might be non-const but
have 'used_tables' == 0 (independent subqueries)
and because of that these conditions are cut off by
make_cond_for_table() function.
The fix is to use (table_map) 0 instead of used_tables in
third argument for make_cond_for_table() function.
It allows to extract elements which belong to sorted
table and in addition elements which are independend
subqueries.


mysql-test/r/having.result:
  test case
mysql-test/t/having.test:
  test case
sql/sql_select.cc:
  The fix is to use (table_map) 0 instead of used_tables in
  third argument for make_cond_for_table() function.
  It allows to extract elements which belong to sorted
  table and in addition elements which are independend
  subqueries.
2011-04-22 11:20:55 +04:00
Mattias Jonsson
b3d86f12eb merge 2011-04-20 18:10:15 +02:00
Mattias Jonsson
046b57450d merge 2011-04-20 18:00:50 +02:00
Mattias Jonsson
bd92ea4311 Bug#11766249 bug#59316: PARTITIONING AND INDEX_MERGE MEMORY LEAK
Update for previous patch according to reviewers comments.

Updated the constructors for ha_partitions to use the common
init_handler_variables functions

Added use of defines for size and offset to get better readability for the code that reads
and writes the .par file. Also refactored the get_from_handler_file function.
2011-04-20 17:52:33 +02:00
Jon Olav Hauglid
f3b024cafa BUG#12377872 ASSERTION FAILED: !_ENTERED WHEN GETHOSTBYADDR_R
FAILS ON SOLARIS

This assertion was triggered if gethostbyaddr_r cannot do a
reverse lookup on an ip address. The reason was a missing
DBUG_RETURN macro. The problem affected only debug versions of
the server.

This patch fixes the problem by replacing return with DBUG_RETURN.
No test case added.
2011-04-20 11:32:28 +02:00
Sergey Glukhov
90bbf9d615 Bug#11765923 58937: MANY VALGRIND ERRORS AFTER GROUPING BY RESULT OF DECIMAL COLUMN FUNCTION
Bug#11764671  57533: UNINITIALISED VALUES IN COPY_AND_CONVERT (SQL_STRING.CC) WITH CERTAIN CHA
When ROUND evaluates decimal result it uses Item::decimal
value as fraction value for the result. In some cases
Item::decimal is greater than real result fraction value
and uninitialised memory of result(decimal) buffer can be
used in further calculations. Issue is introduced by
Bug33143 fix. The fix is to remove erroneous assignment.


mysql-test/r/func_math.result:
  test case
mysql-test/t/func_math.test:
  test case
sql/item_func.cc:
  remove erroneous assignment
2011-04-20 11:39:20 +04:00
Sergey Glukhov
bba7b9ca0c Bug#11765139 58069: LOAD DATA INFILE: VALGRIND REPORTS INVALID MEMORY READS AND WRITES WITH U
Some multibyte sequences could be considered by my_mbcharlen() functions
as multibyte character but more exact my_ismbchar() does not think so.
In such a case this multibyte sequences is pushed into 'stack' buffer which
is too small to accommodate the sequence.
The fix is to allocate stack buffer in
compliance with max character length.


mysql-test/r/loaddata.result:
  test case
mysql-test/t/loaddata.test:
  test case
sql/sql_load.cc:
  allocate stack buffer in compliance with max character length.
2011-04-15 12:51:34 +04:00
Tor Didriksen
dd3d9477b2 Bug#11765713 58705: OPTIMIZER LET ENGINE DEPEND ON UNINITIALIZED VALUES CREATED BY OPT_SUM_QU
Valgrind warnings were caused by comparing index values to an un-initialized field.


mysql-test/r/subselect.result:
  New test cases.
mysql-test/t/subselect.test:
  New test cases.
sql/opt_sum.cc:
  Add thd to opt_sum_query enabling it to test for errors.
  If we have a non-nullable index, we cannot use it to match null values,
  since set_null() will be ignored, and we might compare uninitialized data.
sql/sql_select.cc:
  Add thd to opt_sum_query, enabling it to test for errors.
sql/sql_select.h:
  Add thd to opt_sum_query, enabling it to test for errors.
2011-04-14 16:35:24 +02:00
Sergey Glukhov
3abe56f31d Bug#11756242 48137: PROCEDURE ANALYSE() LEAKS MEMORY WHEN RETURNING NULL
There are two problems with ANALYSE():

1. Memory leak 
   it happens because do_select() can overwrite
   JOIN::procedure field(with zero value in our case) and
   JOIN destructor don't free the memory allocated for
   JOIN::procedure. The fix is to save original JOIN::procedure
   before do_select() call and restore it after do_select
   execution.

2. Wrong result
   If ANALYSE() procedure is used for the statement with LIMIT clause
   it could retrun empty result set. It happens because of missing 
   analyse::end_of_records() call. First end_send() function call
   returns NESTED_LOOP_QUERY_LIMIT and second call of end_send() with
   end_of_records flag enabled does not happen. The fix is to return
   NESTED_LOOP_OK from end_send() if procedure is active.


mysql-test/r/analyse.result:
  test case
mysql-test/t/analyse.test:
  test case
sql/sql_select.cc:
  --save original JOIN::procedure before do_select() call and
    restore it after do_select execution.
  --return NESTED_LOOP_OK from end_send() if procedure is active
2011-04-14 12:11:57 +04:00
unknown
ce55d37929 Merge Mariadb 5.1->5.2 2011-04-12 14:26:06 +02:00
Sergey Glukhov
7fa7a0cad9 Bug#11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION
When we create temporary result table for UNION
incorrect max_length for YEAR field is used and
it leads to incorrect field value and incorrect
result string length as YEAR field value calculation
depends on field length.
The fix is to use underlying item max_length for
Item_sum_hybrid::max_length intialization.


mysql-test/r/func_group.result:
  test case
mysql-test/t/func_group.test:
  test case
sql/field.cc:
  added assert
sql/item_sum.cc:
  init Item_sum_hybrid::max_length with 
  use underlying item max_length for
  INT result type.
2011-04-12 14:01:33 +04:00
Sergey Glukhov
33c2a5e7e3 Bug#11766212 59270: NOT IN (YEAR( ... ), ... ) PRODUCES MANY VALGRIND WARNINGS
Valgrind warning happens due to early null values check
in Item_func_in::fix_length_and_dec(before item evaluation).
As result null value items with uninitialized values are
placed into array and it leads to valgrind warnings during
value array sorting.
The fix is to check null value after item evaluation, item
is evaluated in in_array::set() method.


mysql-test/r/func_in.result:
  test case
mysql-test/t/func_in.test:
  test case
sql/item_cmpfunc.cc:
  The fix is to check null value after item evaluation.
2011-04-12 13:51:36 +04:00
Gleb Shchepa
a77bc59896 Bug #11829681 - 60295: ERROR 1356 ON VIEW THAT EXECUTES FINE AS A QUERY
Select from a view with the underlying HAVING clause failed with a
message: "1356: View '...' references invalid table(s) or column(s)
or function(s) or definer/invoker of view lack rights to use them"

The bug is a regression of the fix for bug 11750328 - 40825 (similar
case, but the HAVING cause references an aliased field).
In the old fix for bug 40825 the Item_field::name_length value has
been used in place of the real length of Item_field::name. However,
in some cases Item_field::name_length is not in sync with the
actual name length (TODO: combine name and name_length into a
solid String field).

The Item_ref::print() method has been modified to calculate actual
name length every time.


mysql-test/r/view.result:
  Test case for bug #11829681
mysql-test/t/view.test:
  Test case for bug #11829681
sql/item.cc:
  Bug #11829681 - 60295: ERROR 1356 ON VIEW THAT EXECUTES FINE AS A QUERY
  
  The Item_ref::print() method has been modified to calculate actual
  name length every time.
sql/item.h:
  Minor commentary.
2011-04-08 12:05:20 +04:00
Vladislav Vaintroub
ad7b636d72 fix CRLF line endings to LF 2011-04-08 01:42:47 +02:00
Vladislav Vaintroub
3fdd009990 Fix SQL syntax error when running mysql --bootstrap. 2011-04-08 01:41:07 +02:00
Guilhem Bichot
dc65d9217c Fix for Bug#11765141 - "58072: LOAD DATA INFILE: LEAKS IO CACHE MEMORY WHEN ERROR OCCURS"
mysql-test/t/loaddata.test:
  test for bug; without fix, running the test with --valgrind would show the leak
  and make the test fail.
sql/sql_load.cc:
  * In READ_INFO class, 'need_end_io_cache' is true as long as init_io_cache() was called,
  so if it's true, we need to call end_io_cache(), to free memory allocated
  by init_io_cache(). No matter the value of 'error'. In the bug's scenario,
  'error' was set to true in read_sep_field() because
  '1' (read from file) isn't suitable to load into a geometric column. Because of
  'error', end_io_cache() was not called.
  Note: end_io_cache() calls my_b_flush_io_cache(), which will do nothing wrong given
  that the file is opened for reads only; see the init_io_cache() call which uses
  only those read-only types:
  (get_it_from_net) ? READ_NET : (is_fifo ? READ_FIFO : READ_CACHE).
  IF the cache were rather used to write to the file, my_b_flush_io_cache() may
  write to it, and it may be questionable to write to the file
  if 'error' is true. But here there's no problem.
  * Now that 'need_end_io_cache' is checked even if 'error' is true, it needs
  to be initialized in all cases.
  * Bonus: move some variables to the initialization list.
2011-04-07 15:09:19 +02:00
Georgi Kodinov
5321b3a57a Bug #11758687: 50924: object names not resolved correctly
on lctn2 systems

There was a local variable in get_all_tables() to store the 
"original" value of the database name as it can get lowercased
depending on the lower_case_table_name value.
get_all_tables() iterates over database names and for each 
database iterates over the tables in it.
The "original" db name was assigned in the table names loop.
Thus the first table is ok, but the second and subsequent tables
get the lowercased name from processing the first table.
Fixed by moving the assignment of the original database name
from the inner (table name) to the outer (database name) loop.
Test suite added.
2011-04-04 16:04:15 +03:00
Vladislav Vaintroub
aa2b482ec4 Fix error in "make dist" (sql/CMakeLists.txt is not delivered in source distribution) 2011-04-03 20:56:47 +02:00
Gleb Shchepa
7aa81e2a02 Bug #11766094 - 59132: MIN() AND MAX() REMOVE UNSIGNEDNESS
In the string context the MIN() and MAX() functions don't take
into account the unsignedness of the UNSIGNED BIGINT argument
column.

I.e.:
        CREATE TABLE t1 (a BIGINT UNSIGNED);
        INSERT INTO t1 VALUES (18446668621106209655);
        SELECT CONCAT(MAX(a)) FROM t1;

returns -75452603341961.


mysql-test/r/func_group.result:
  Test case for bug #11766094.
mysql-test/t/func_group.test:
  Test case for bug #11766094.
sql/item.cc:
  Bug #11766094 - 59132: MIN() AND MAX() REMOVE UNSIGNEDNESS
  
  The Item_cache_int::val_str() method has been modified to
  take into account the unsigned_flag value when converting
  data to string.
2011-03-31 22:59:11 +04:00
Michael Widenius
6f20e3a385 Fixed problem that fill_record() allocated memory for every call. This could be a problem when doing big unions as memory could be filled up.
sql/sql_base.cc:
  Don't allocate memory in fill_record().
  Fix was to remove the list of tables. This was not necessary as this call is only used with one table.
2011-03-30 19:20:22 +03:00
Sergey Glukhov
a7d383cbb8 Bug#11766124 59164: VALGRIND: UNINITIALIZED VALUE IN NUMBER_TO_DATETIME
Valgrind warning happens due to missing NULL value check in
Item::get_date. 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.cc:
  added check for NULL value
2011-03-30 11:08:35 +04:00
Sergey Glukhov
3b7f044534 Bug#11766126 59166: ANOTHER DATETIME VALGRIND UNINITIALIZED WARNING
Valgrind warning happens because null values check happens too late
in Item_func_month::val_str(after result string calculation).The fix
is to check null value before result string calculation.


mysql-test/r/func_time.result:
  test case
mysql-test/t/func_time.test:
  test case
sql/item_timefunc.h:
  check null value before result string calculation.
2011-03-30 11:00:41 +04:00
Jon Olav Hauglid
4e26a41f3e Bug# 11763784 (former 56541)
ASSERTION TABLE->DB_STAT FAILED IN
SQL_BASE.CC::OPEN_TABLE() DURING I_S Q

This assert could be triggered if a statement requiring a name
lock on a table (e.g. DROP TRIGGER) executed concurrently
with an I_S query which also used the table.

One connection first started an I_S query that opened a given table.
Then another connection started a statement requiring a name lock
on the same table. This statement was blocked since the table was
in use by the I_S query. When the I_S query resumed and tried to
open the table again as part of get_all_tables(), it would encounter
a table instance with an old version number representing the pending
name lock. Since I_S queries ignore version checks and thus pending
name locks, it would try to continue. This caused it to encounter
the assert. The assert checked that the TABLE instance found with a
different version, was a real, open table. However, since this TABLE
instance instead represented a pending name lock, the check would
fail and trigger the assert.

This patch fixes the problem by removing the assert. It is ok for
TABLE::db_stat to be 0 in this case since the TABLE instance can
represent a pending name lock.

Test case added to lock_sync.test.
2011-03-29 10:09:05 +02:00
Sergei Golubchik
0741f1a902 lp:702084 - myisam_block_size is not reported in SHOW GLOBAL VARIABLES
add a read-only server variable @@myisam_block_size
2011-03-28 16:53:46 +02:00