Commit graph

40343 commits

Author SHA1 Message Date
Georgi Kodinov
ac37324843 Bug #42116 : Mysql crash on specific query
Queries with nested outer joins may lead to crashes or 
bad results because an internal data structure is not handled
correctly.
The optimizer uses bitmaps of nested JOINs to determine
if certain table can be placed at a certain place in the
JOIN order.
It does maintain a bitmap describing in which JOINs 
last placed table is nested.
When it puts a table it makes sure the bit of every JOIN that
contains the table in question is set (because JOINs can be nested).
It does that by recursively setting the bit for the next enclosing
JOIN when this is the first table in the JOIN and recursively 
resetting the bit if it's the last table in the JOIN.
When it removes a table from the join order it should do the
opposite : recursively unset the bit if it's the only remaining 
table in this join and and recursively set the bit if it's removing
the last table of a JOIN.
There was an error in how the bits was set for the upper levels :
when removing a table it was setting the bit for all the enclosing 
nested JOINs even if there were more tables left in the current JOIN
(which practically means that the upper nested JOINs were not affected).
Fixed by stopping the recursion at the relevant level.

mysql-test/r/join.result:
  Bug #42116: test case
mysql-test/t/join.test:
  Bug #42116: test case
sql/sql_select.cc:
  Bug #41116: don't go up and set the bits if more tables in
  at the current JOIN level
2009-10-29 17:24:29 +02:00
Sergey Glukhov
0b10509e3b Bug#41049 does syntax "grant" case insensitive?
test result fix

mysql-test/suite/funcs_1/r/is_columns_mysql.result:
  test result fix
mysql-test/suite/funcs_1/r/is_statistics.result:
  test result fix
2009-10-28 13:15:33 +04:00
Georgi Kodinov
a7d26e109c merge from 4.1 2009-10-27 15:11:06 +02:00
Sergey Glukhov
f4d01357d6 automerge 2009-10-27 15:02:58 +04:00
Sergey Vojtovich
eeee91173e An addition to fix for
BUG#41597 - After rename of user, there are additional grants
            when grants are reapplied.

Fixed build failure on Windows. Added missing cast.

sql/sql_acl.cc:
  Fixed build failure on Windows. Added missing cast.
2009-10-27 12:37:57 +04:00
Sergey Glukhov
f0a7ff8419 Bug#41049 does syntax "grant" case insensitive?
Problem 1:
column_priv_hash uses utf8_general_ci collation
for the key comparison. The key consists of user name,
db name and table name. Thus user with privileges on table t1
is able to perform the same operation on T1
(the similar situation with user name & db name, see acl_cache).
So collation which is used for column_priv_hash and acl_cache
should be case sensitive.
The fix:
replace system_charset_info with my_charset_utf8_bin for
column_priv_hash and acl_cache
Problem 2:
The same situation with proc_priv_hash, func_priv_hash,
the only difference is that Routine name is case insensitive.
So the fix is to use my_charset_utf8_bin for
proc_priv_hash & func_priv_hash and convert routine name into lower
case before writing the element into the hash and
before looking up the key.
Additional fix: mysql.procs_priv Routine_name field collation
is changed to utf8_general_ci.
It's necessary for REVOKE command
(to find a field by routine hash element values).
Note: 
It's safe for lower-case-table-names mode too because
db name & table name are converted into lower case
(see GRANT_NAME::GRANT_NAME).


mysql-test/include/have_case_insensitive_fs.inc:
  test case
mysql-test/r/case_insensitive_fs.require:
  test case
mysql-test/r/grant_lowercase_fs.result:
  test result
mysql-test/r/lowercase_fs_off.result:
  test result
mysql-test/r/ps_grant.result:
  test result
mysql-test/r/system_mysql_db.result:
  changed Routine_name field collation to case insensitive
mysql-test/t/grant_lowercase_fs.test:
  test case
mysql-test/t/lowercase_fs_off.test:
  test case
scripts/mysql_system_tables.sql:
  changed Routine_name field collation to case insensitive
scripts/mysql_system_tables_fix.sql:
  changed Routine_name field collation to case insensitive
sql/sql_acl.cc:
  Problem 1:
  column_priv_hash uses utf8_general_ci collation
  for the key comparison. The key consists of user name,
  db name and table name. Thus user with privileges on table t1
  is able to perform the same operation on T1
  (the similar situation with user name & db name, see acl_cache).
  So collation which is used for column_priv_hash and acl_cache
  should be case sensitive.
  The fix:
  replace system_charset_info with my_charset_utf8_bin for
  column_priv_hash and acl_cache
  Problem 2:
  The same situation with proc_priv_hash, func_priv_hash,
  the only difference is that Routine name is case insensitive.
  So the fix is to use my_charset_utf8_bin for
  proc_priv_hash & func_priv_hash and convert routine name into lower
  case before writing the element into the hash and
  before looking up the key.
  Additional fix: mysql.procs_priv Routine_name field collation
  is changed to utf8_general_ci.
  It's necessary for REVOKE command
  (to find a field by routine hash element values).
  Note: 
  It's safe for lower-case-table-names mode too because
  db name & table name are converted into lower case
  (see GRANT_NAME::GRANT_NAME).
2009-10-27 12:09:19 +04:00
unknown
37743aedda Merge from mysql-5.0.87-release 2009-10-26 19:20:02 +01:00
Georgi Kodinov
19ffe23085 Bug #47780: crash when comparing GIS items from subquery
If the first argument to GeomFromWKB function is a geometry
field then the function just returns its value.
However in doing so it's not preserving first argument's 
null_value flag and this causes unexpected null value to
be returned to the calling function.
      
Fixed by updating the null_value of the GeomFromWKB function
in such cases (and all other cases that return a NULL e.g.
because of not enough memory for the return buffer).
2009-10-21 11:43:45 +03:00
Ramil Kalimullin
b7ce2a01bc Fix for bug#48258: Assertion failed when using a spatial index
Problem: involving a spatial index for "non-spatial" queries
(that don't containt MBRXXX() functions) may lead to failed assert.

Fix: don't use spatial indexes in such cases.


mysql-test/r/gis-rtree.result:
  Fix for bug#48258: Assertion failed when using a spatial index
    - test result.
mysql-test/t/gis-rtree.test:
  Fix for bug#48258: Assertion failed when using a spatial index
    - test case.
sql/opt_range.cc:
  Fix for bug#48258: Assertion failed when using a spatial index
    - allow only spatial functions (MBRXXX) for itMBR keyparts.
2009-10-23 16:26:48 +05:00
Ramil Kalimullin
17ed6b9abd Fix for bug#47019: Assertion failed: 0, file .\rt_mbr.c,
line 138 when forcing a spatial index

Problem: "Spatial indexes can be involved in the search 
for queries that use a function such as MBRContains() 
or MBRWithin() in the WHERE clause".
Using spatial indexes for JOINs with =, <=> etc.
predicates is incorrect.

Fix: disable spatial indexes for such queries.


mysql-test/r/select.result:
  Fix for bug#47019: Assertion failed: 0, file .\rt_mbr.c, 
  line 138 when forcing a spatial index
    - test result.
mysql-test/t/select.test:
  Fix for bug#47019: Assertion failed: 0, file .\rt_mbr.c, 
  line 138 when forcing a spatial index
    - test case.
sql/sql_select.cc:
  Fix for bug#47019: Assertion failed: 0, file .\rt_mbr.c, 
  line 138 when forcing a spatial index
    - disable spatial indexes for queries which use 
  non-spatial conditions (e.g. NATURAL JOINs).
2009-10-21 14:04:08 +05:00
Tatiana A. Nurnberg
b25cc8f23f auto-merge 2009-10-20 20:38:56 -07:00
Georgi Kodinov
7fa2f921c2 Bug #47320: OpenSSL client does not check YaSSL server certificate
Removed the verify callback, as it's not needed to verify even self
signed certificates and is a security problem.
2009-10-20 13:09:16 +03:00
Satya B
034627aeec merge to mysql-5.0-bugteam 2009-10-20 12:21:58 +05:30
Satya B
882535423d Fix for Bug #41597 - After rename of user, there are additional grants when
grants are reapplied.


After renaming a user and trying to re-apply grants results in additional
grants.

This is because we use username as part of the key for GRANT_TABLE structure.
When the user is renamed, we only change the username stored and the hash key
still contains the old user name and this results in the extra privileges

Fixed by rebuilding the hash key and updating the column_priv_hash structure
when the user is renamed

mysql-test/r/grant3.result:
  Bug #41597 - After rename of user, there are additional grants when 
               grants are reapplied.
  
  Testcase for BUG#41597
mysql-test/t/grant3.test:
  Bug #41597 - After rename of user, there are additional grants when 
               grants are reapplied.
  
  Testcase for BUG#41597
sql/sql_acl.cc:
  Bug #41597 - After rename of user, there are additional grants when 
               grants are reapplied.
  
  Fixed handle_grant_struct() to update the hash key when the user is renamed.
  Added to set_user_details() method to GRANT_NAME class
2009-10-20 11:47:57 +05:30
Tatiana A. Nurnberg
5ef63a4f1c Bug#28141: Control C on query waiting on lock causes ERROR 1053 (server shutdown)
If a thread is killed in the server, we throw "shutdown" only if one is actually in
progress; otherwise, we throw "query interrupted".

Control-C in the mysql command-line client is "incremental" now.
First Control-C sends KILL QUERY (when connected to 5.0+ server, otherwise, see next)
Next  Control-C sends KILL CONNECTION
Next  Control-C aborts client.

As the first two steps only pertain to an existing query,
Control-C will abort the client right away if no query is running.

client will give more detailed/consistent feedback on Control-C now.


client/mysql.cc:
  Extends Control-C handling; enhances up feedback to user.
  
  On 5.0+ servers, we try to be nice and send KILL QUERY first
  if Control-C is pressed in the command-line client, but if
  that doesn't work, we now give the user the opportunity to
  send KILL CONNECTION with another Control-C (and to kill the
  client with another Control-C if that somehow doesn't work
  either).
mysql-test/t/flush_read_lock_kill.test:
  we're getting correct "thread killed" rather than
  "in shutdown" error now
mysql-test/t/kill.test:
  we're getting correct "thread killed" rather than
  "in shutdown" error now
mysql-test/t/rpl000001.test:
  we're getting correct "thread killed" rather than
  "in shutdown" error now
mysql-test/t/rpl_error_ignored_table.test:
  we're getting correct "thread killed" rather than
  "in shutdown" error now
sql/records.cc:
  make error messages on KILL uniform for rr_*()
  by folding that handling into rr_handle_error()
sql/sql_class.h:
  Only throw "shutdown" when we have one flagged as being in progress;
  otherwise, throw "query interrupted" as it's likely to be "KILL CONNECTION"
  or related.
2009-10-19 21:42:10 -07:00
Joerg Bruehe
ce0a06935b Merge 5.0-bugteam (compile fix) into main 5.0 2009-10-16 14:29:41 +02:00
Joerg Bruehe
0888592457 Merge the Windows compile fix into the push tree. 2009-10-16 14:09:31 +02:00
Joerg Bruehe
4bebf04354 Compile fix for Windows:
Use "#ifdef", not plain "#if".
2009-10-16 14:06:33 +02:00
Joerg Bruehe
74f4e39490 Merge bug fix into push tree. 2009-10-15 20:14:07 +02:00
Hery Ramilison
7df70d09a9 Added make targets 'test-bt-fast' and 'test-bt-debug-fast'
Put variable declaration at the beginning of a block
2009-10-15 00:40:40 +02:00
Georgi Kodinov
903d21287c version change 2009-10-14 18:44:22 +03:00
Georgi Kodinov
3eb048ab87 merged main to mysql-5.0-bugteam 2009-10-14 17:33:20 +03:00
unknown
ecb9119beb Null-merge from mysql-5.0.84sp1-release 2009-10-14 10:16:04 +02:00
unknown
7b32690cf9 Raise version number after cloning 5.0.87 2009-10-13 20:50:37 +02:00
Kent Boortz
128e676c0d "MySQL Network" => "MySQL Enterprise" 2009-10-08 22:55:28 +02:00
Joerg Bruehe
33b4ba9950 Fix bug#47923 New "mf_keycache.c" requires thread support
The bug is a compilation issue:
Function "find_key_block()" had thread operations
which were not guarded by "#if THREAD", add that now.

mysys/mf_keycache.c:
  Without thread-support, we are in a single-threaded world,
  so there is no parallelism, and the keycache cannot be
  within a resize operation while this request is being processed.
2009-10-08 21:58:17 +02:00
Frazer Clement
fd04391340 Fix compile break from bug#39663 fix 2009-10-08 16:23:15 +01:00
Ramil Kalimullin
3185118e1a Fix for bug #42803: Field_bit does not have unsigned_flag field,
can lead to bad memory access

Problem: Field_bit is the only field which returns INT_RESULT
and doesn't have unsigned flag. As it's not a descendant of the 
Field_num, so using ((Field_num *) field_bit)->unsigned_flag may lead
to unpredictable results.

Fix: check the field type before casting.


mysql-test/r/type_bit.result:
  Fix for bug #42803: Field_bit does not have unsigned_flag field,
  can lead to bad memory access
    - test result.
mysql-test/t/type_bit.test:
  Fix for bug #42803: Field_bit does not have unsigned_flag field,
  can lead to bad memory access
    - test case.
sql/opt_range.cc:
  Fix for bug #42803: Field_bit does not have unsigned_flag field,
  can lead to bad memory access
    - don't cast to (Field_num *) Field_bit, as it's not a Field_num
  descendant and is always unsigned by nature.
2009-10-08 16:56:31 +05:00
Kristofer Pettersson
6edfba9562 Automerge 2009-10-06 10:02:58 +02:00
Kristofer Pettersson
9098e2997b Bug#47768 pthread_cond_timedwait() is broken on windows
The pthread_cond_wait implementations for windows might
dead lock in some rare circumstances.

1) One thread (I) enter a timed wait and at a point in
   time ends up after mutex unlock and before
   WaitForMultipleObjects(...)
2) Another thread (II) enters pthread_cond_broadcast.
   Grabs the mutex and discovers one waiter. It set
   the broadcast event and closes the broadcast gate
   then unlocks the mutex.
3) A third thread (III) issues a pthread_cond_signal.
   It grabs the mutex, discovers one waiter, sets the
   signal event then unlock the mutex.
4) The first threads (I) enters WaitForMultipleObjects
   and finds out that the signal object is in a
   signalled state and exits the wait.
5) Thread (I) grabs the mutex and checks result status.
   The number of waiters is decreased and becomes equal
   to 0. The event returned was a signal event so the
   broadcast gate isn't opened. The mutex is released.
6) Thread (II) issues a new broadcast. The mutex is
   acquired but the number of waiters are 0 hence
   the broadcast gate remains closed.
7) Thread (I) enters the wait again but is blocked by
   the broadcast gate.

      This fix resolves the above issue by always resetting
      broadcast gate when there are no more waiters in th queue.


mysys/my_wincond.c:
  * Always reset the broadcast gate if there are no more waiters left.
2009-10-06 09:38:44 +02:00
Georgi Kodinov
3d35e53c85 version update 2009-10-06 10:32:02 +03:00
Frazer Clement
379d1f19ce Bug#39663 mysqltest: --enable_info, affected_rows and ps-protocol broken 2009-10-05 13:57:00 +01:00
Georgi Kodinov
9fbc5728ae automerge 2009-10-04 12:00:27 +03:00
Jonathan Perkin
79b438cb98 Merge to mysql-5.0-bugteam 2009-10-02 13:54:38 +01:00
Davi Arnaut
3c5d9f4272 Post-merge cleanup: Reorganize code for better comprehensibility.
Removes the need of a hack (the jump to label).
2009-09-30 19:59:30 -03:00
Davi Arnaut
e218ac06ed Post-merge fix: DBUG macros are wrapped inside a loop.
sql/sql_parse.cc:
  DBUG macros are wrapped inside a loop. Allow to break
  the command switch from within a DBUG macro.
2009-09-30 19:14:55 -03:00
Davi Arnaut
565f1bc4a1 Bug#47525: MySQL crashed (Federated)
On Mac OS X or Windows, sending a SIGHUP to the server or a
asynchronous flush (triggered by flush_time), would cause the
server to crash.

The problem was that a hook used to detach client API handles
wasn't prepared to handle cases where the thread does not have
a associated session.

The solution is to verify whether the thread has a associated
session before trying to detach a handle.

mysql-test/r/federated_debug.result:
  Add test case result for Bug#47525
mysql-test/t/federated_debug-master.opt:
  Debug point.
mysql-test/t/federated_debug.test:
  Add test case for Bug#47525
sql/slave.cc:
  Check whether a the thread has a associated session.
sql/sql_parse.cc:
  Add debug code to simulate a reload without thread session.
2009-09-30 18:38:02 -03:00
Jonathan Perkin
16b41f1056 bug#27693: Windows compilation from bk fails using WITH_BERKELEY_STORAGE_ENGINE
Make configure.js bail with an error if trying to build bdb from a bzr
tree.
2009-09-30 15:46:51 +01:00
Kristofer Pettersson
df2122a262 Bug#34895 'show procedure status' or 'show function status' +
'flush tables' crashes

The server crashes when 'show procedure status' and 'flush tables' are
run concurrently.

This is caused by the way mysql.proc table is added twice to the list
of table to lock although the requirements on the current locking API
assumes differently.

No test case is submitted because of the nature of the crash which is 
currently difficult to reproduce in a deterministic way.

This is a backport from 5.1

myisam/mi_dbug.c:
  * check_table_is_closed is only used in EXTRA_DEBUG mode but since it is
  iterating over myisam shared data it still needs to be protected by an
  appropriate mutex.
sql/sql_yacc.yy:
  * Since the I_S mechanism is already handling the open and close of 
  mysql.proc there is no need for the method sp_add_to_query_tables.
2009-09-30 14:50:25 +02:00
MySQL Build Team
4ecbf3a7b4 Backport into build-200909301147-5.0.84sp1
> ------------------------------------------------------------
> revno: 2802.1.1
> tags: mysql-5.0.86
> revision-id: hery.ramilison@sun.com-20090909185217-mooeczu391ztp2fz
> parent: joro@sun.com-20090902123318-8qe40pr91xmui5ue
> committer: hery <hery.ramilison@sun.com>
> branch nick: mysql-5.0.86-release
> timestamp: Wed 2009-09-09 20:52:17 +0200
> message:
>   change c++ comment to c comment
2009-09-30 14:26:15 +02:00
MySQL Build Team
31c0647f98 Backport into build-200909301147-5.0.84sp1
> ------------------------------------------------------------
> revno: 2796
> revision-id: sergey.glukhov@sun.com-20090827102219-sgjz0v5t1rfccs14
> parent: joro@sun.com-20090824122803-1d5jlaysjc7a7j6q
> committer: Sergey Glukhov <Sergey.Glukhov@sun.com>
> branch nick: mysql-5.0-bugteam
> timestamp: Thu 2009-08-27 15:22:19 +0500
> message:
>   Bug#46184 Crash, SELECT ... FROM derived table procedure analyze
>   The crash happens because select_union object is used as result set
>   for queries which have derived tables.
>   select_union use temporary table as data storage and if
>   fields count exceeds 10(count of values for procedure ANALYSE())
>   then we get a crash on fill_record() function.
2009-09-30 14:24:59 +02:00
MySQL Build Team
dc7c927787 Backport into build-200909301147-5.0.84sp1
> ------------------------------------------------------------
> revno: 2791.2.3
> revision-id: joro@sun.com-20090827114042-h55n7qp9990bl6ge
> parent: anurag.shekhar@sun.com-20090831073231-e55y1hsck6n08ux8
> committer: Georgi Kodinov <joro@sun.com>
> branch nick: B46749-5.0-bugteam
> timestamp: Thu 2009-08-27 14:40:42 +0300
> message:
>   Bug #46749: Segfault in add_key_fields() with outer subquery level 
>     field references
>   
>   This error requires a combination of factors : 
>   1. An "impossible where" in the outermost SELECT
>   2. An aggregate in the outermost SELECT
>   3. A correlated subquery with a WHERE clause that includes an outer 
>   field reference as a top level WHERE sargable predicate
>   
>   When JOIN::optimize detects an "impossible WHERE" it will bail out
>   without doing the rest of the work and initializations. It will not
>   call make_join_statistics() as well.  And make_join_statistics fills 
>   in various structures for each table referenced.
>   When processing the result of the "impossible WHERE" the query must
>   send a single row of data if there are aggregate functions in it.
>   In this case the server marks all the aggregates as having received 
>   no rows and calls the relevant Item::val_xxx() method on the SELECT
>   list. However if this SELECT list happens to contain a correlated 
>   subquery this subquery is evaluated in a normal evaluation mode.
>   And if this correlated subquery has a reference to a field from the 
>   outermost "impossible where" SELECT the add_key_fields will mistakenly
>   consider the outer field reference as a "local" field reference when 
>   looking for sargable predicates.
>   But since the SELECT where the outer field reference refers to is not
>   completely initialized due to the "impossible WHERE" in this level
>   we'll get a NULL pointer reference.
>   Fixed by making a better condition for discovering if a field is "local"
>   to the SELECT level being processed. 
>   It's not enough to look for OUTER_REF_TABLE_BIT in this case since 
>   for outer references to constant tables the Item_field::used_tables() 
>   will return 0 regardless of whether the field reference is from the 
>   local SELECT or not.
2009-09-30 14:22:38 +02:00
unknown
bbaae7ecd4 Set version number for mysql-5.0.84sp1 release 2009-09-30 13:53:41 +02:00
unknown
de04eb6c37 Bug #46998 mysqlbinlog can't output BEGIN even if the database is included in a transaction
The 'BEGIN/COMMIT/ROLLBACK' log event could be filtered out if the
database is not selected by --database option of mysqlbinlog command.
This can result in problem if there are some statements in the
transaction are not filtered out.

To fix the problem, mysqlbinlog will output 'BEGIN/ROLLBACK/COMMIT' 
in regardless of the database filtering rules.

client/mysqlbinlog.cc:
  Skip the database check for BEGIN/COMMIT/ROLLBACK log events.
mysql-test/r/mysqlbinlog.result:
  Test result for bug#46998
mysql-test/t/mysqlbinlog.test:
  Added test to verify if the 'BEGIN', 'COMMIT' and 'ROLLBACK' are output
  in regardless of database filtering
2009-09-30 10:01:52 +08:00
Kristofer Pettersson
0fb0b2b1b8 autocommit 2009-09-29 17:18:55 +02:00
Kristofer Pettersson
da9a5ef622 Bug#42108 Wrong locking for UPDATE with subqueries leads to broken statement
replication
              
MySQL server uses wrong lock type (always TL_READ instead of
TL_READ_NO_INSERT when appropriate) for tables used in
subqueries of UPDATE statement. This leads in some cases to
a broken replication as statements are written in the wrong
order to the binlog.

sql/sql_yacc.yy:
  * Set lock_option to either TL_READ_NO_INSERT or
    TL_READ for any sub-SELECT following UPDATE.
  * Changed line adjusted for parser identation
    rules; code begins at column 13.
2009-09-29 17:06:51 +02:00
Davi Arnaut
aca9b35ffe Bug#41728: Dropped symbol but no soname change
Restore a stub of the removed mysql_odbc_escape_string function
to fix a ABI breakage. The function was intended to be private
and used only by Connector/ODBC, but, unfortunately, it was exported
as part of the ABI. Nonetheless, only a stub is restored as the
original function is inherently broken and shouldn't be used.

This restoration only applies to MySQL 5.0. This will be addressed
differently in later versions -- reworked library versioning.

include/mysql.h:
  Restore mysql_odbc_escape_string prototype.
include/mysql_h.ic:
  Update ABI check.
libmysql/libmysql.c:
  Restore a mysql_odbc_escape_string stub.
libmysql/libmysql.def:
  Restore mysql_odbc_escape_string.
libmysqld/libmysqld.def:
  Restore mysql_odbc_escape_string.
2009-09-29 09:55:53 -03:00
Jonathan Perkin
f4d20df9dc Merge to mysql-5.0-bugteam 2009-09-28 15:24:52 +01:00
Jonathan Perkin
ea295c233b bug#30954: "configure" script in binary distributions considered harmfull
Add --help option.
2009-09-28 15:14:33 +01:00
Joerg Bruehe
b80e34fe00 Merge the fix for bug#47137 into 5.0-build
Solaris binary packages should be compiled with '-g0', not '-g'
2009-09-28 10:43:26 +02:00