Commit graph

16766 commits

Author SHA1 Message Date
msvensson@pilot.blaudden
e50116e99e Bug#26664 test suite times out on OS X 64bit
- Add checks to make sure net has a vio assigned
 - For example bootstrap will create a fake "net" with vio
   set to 0
2007-05-25 16:47:43 +02:00
ramil/ram@ramil.myoffice.izhnet.ru
b49abf428c Merge mysql.com:/home/ram/work/mysql-5.0-maint
into  mysql.com:/home/ram/work/b26842/b26842.5.0
2007-05-25 11:13:32 +05:00
msvensson@pilot.blaudden
3545f28c91 Merge bk-internal:/home/bk/mysql-5.0-maint
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
2007-05-24 22:26:49 +02:00
msvensson@pilot.blaudden
374de2c7cb Merge pilot.blaudden:/home/msvensson/mysql/bug26664/my50-bug26664
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
2007-05-24 20:51:37 +02:00
ramil/ram@ramil.myoffice.izhnet.ru
6369ff54b7 Merge mysql.com:/home/ram/work/mysql-5.0-maint
into  mysql.com:/home/ram/work/b28464.new/b28464.new.5.0
2007-05-24 20:21:04 +05:00
ramil/ram@mysql.com/ramil.myoffice.izhnet.ru
2c759bd45f Fix for
bug #26842: master binary log contains invalid queries - replication fails
bug #12826: Possible to get inconsistent slave using SQL syntax Prepared Statements

Problem:  
binlogging PS' we may produce syntacticly incorrect queries in the binlog replacing 
some parameters with variable names (instead of variable values).
E.g. in the reported case of "limit ?" clause: replacing "?" with "@var"
produces "limit @var" which is not a correct SQL syntax. 
Also it may lead to different query execution on slave if we
set and use a variable in the same statement, e.g.
"insert into t1 values (@x:=@x+1, ?)"

Fix: make the stored statement string created upon its execution use variable values
(instead of names) to fill placeholders.
2007-05-24 15:35:43 +05:00
msvensson@pilot.blaudden
93b1fe65d8 Bug#26664 test suite times out on OS X 64bit
- The "mysql client in mysqld"(which is used by
   replication and federated) should use alarms instead of setting
   socket timeout value if the rest of the server uses alarm. By
   always calling 'my_net_set_write_timeout'
   or 'my_net_set_read_timeout' when changing the timeout value(s), the
   selection whether to use alarms or timeouts will be handled by
   ifdef's in those two functions. 
 - Move declaration of 'vio_timeout' into "vio_priv.h"
2007-05-24 11:21:27 +02:00
ramil/ram@ramil.myoffice.izhnet.ru
1f9b403b45 Merge mysql.com:/home/ram/work/mysql-5.0-maint
into  mysql.com:/home/ram/work/b28509/b28509.5.0
2007-05-23 13:48:31 +05:00
ramil/ram@mysql.com/ramil.myoffice.izhnet.ru
f1ae9793a7 Fix for bug #21476: stack overflow crashes server; error-message stack reservation too small
Increase STACK_BUFF_ALLOC to avoid execution_constants test failure on the hpita2.
2007-05-22 11:16:29 +05:00
tsmith@quadxeon.mysql.com
99488b31b9 Merge quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/50
into  quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/50
2007-05-21 20:50:08 +02:00
holyfoot/hf@mysql.com/hfmain.(none)
8b21517de4 Merge bk@192.168.21.1:mysql-5.0
into  mysql.com:/d2/hf/mrg/mysql-5.0-opt
2007-05-18 20:02:27 +05:00
ramil/ram@mysql.com/ramil.myoffice.izhnet.ru
11a2fd422b Fox for bug #28509: strange behaviour: passing a decimal value to PS
Set parameter's type to Item::DECIMAL_ITEM assigning a decimal value.
2007-05-18 18:16:51 +05:00
evgen@moonbone.local
835189cb85 Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  moonbone.local:/mnt/gentoo64/work/28261-bug-5.0-opt-mysql
2007-05-18 13:39:34 +04:00
ramil/ram@mysql.com/ramil.myoffice.izhnet.ru
63b2e8d9df Fix for bug #28464: a string argument to 'limit ?' PS - replication fails
Problem: we may get syntactically incorrect queries in the binary log 
if we use a string value user variable executing a PS which 
contains '... limit ?' clause, e.g.
prepare s from "select 1 limit ?"; 
set @a='qwe'; execute s using @a;
  
Fix: raise an error in such cases.
2007-05-18 12:08:07 +05:00
dkatz@damien-katzs-computer.local
89e28d00b0 Bug #27119 server crash with integer division by zero during filesort on huge result
Fixed a problem and compiler warning on 64bit platforms so that they only allocated UINT_MAX number of BUFFPEKS.
2007-05-17 20:45:33 -04:00
dkatz@damien-katzs-computer.local
155a098be6 Merge damien-katzs-computer.local:/Users/dkatz/mysql50
into  damien-katzs-computer.local:/Users/dkatz/50_div_zero
2007-05-17 18:02:03 -04:00
dkatz@damien-katzs-computer.local
971d8d0077 Bug #27119 server crash with integer division by zero during filesort on huge result
Fixed a compiler warning on platforms where uint != ulong from the first pushed fix.
2007-05-17 17:54:31 -04:00
tsmith@siva.hindu.god
07c7a25e30 Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-5.0-maint
into  siva.hindu.god:/home/tsmith/m/bk/maint/50
2007-05-17 14:24:52 -06:00
tsmith@siva.hindu.god
30bc713c77 Merge siva.hindu.god:/home/tsmith/m/bk/50
into  siva.hindu.god:/home/tsmith/m/bk/maint/50
2007-05-17 14:17:50 -06:00
evgen@moonbone.local
0e3c4f6729 Bug#28261: Wrong DATETIME comparison result when the GET_USER_VAR function
is involved.

The Arg_comparator::compare_datetime() comparator caches its arguments if
they are constants i.e. const_item() returns true. The
Item_func_get_user_var::const_item() returns true or false based on
the current query_id and the query_id where the variable was created.
Thus even if a query can change its value its const_item() still will return
true. All this leads to a wrong comparison result when an object of the
Item_func_get_user_var class is involved.

Now the Arg_comparator::can_compare_as_dates() and the
get_datetime_value() functions never cache result of the GET_USER_VAR()
function (the Item_func_get_user_var class).
2007-05-17 23:09:45 +04:00
igor@olga.mysql.com
8c34ae268c Fixed bug #28337: wrong results for grouping queries with correlated
subqueries in WHERE conditions.
This bug was introduced by the patch for bug 27321.
2007-05-16 23:42:10 -07:00
dkatz@damien-katzs-computer.local
41dac22271 Bug #27119 server crash with integer division by zero during filesort on huge result
Added checks to detect integer overflow and fixed other bugs on the error path.
2007-05-16 16:14:13 -04:00
mhansson/martin@linux-st28.site
364014e455 Merge mhansson@bk-internal:/home/bk/mysql-5.0-opt
into  linux-st28.site:/home/martin/mysql/src/5.0o-bug27573
2007-05-16 12:22:20 +03:00
msvensson@pilot.blaudden
a65d12a830 Backport of TIME->MYSQL_TIME / Y2K fixset
Made year 2000 handling more uniform
Removed year 2000 handling out from calc_days()
The above removes some bugs in date/datetimes with year between 0 and 200
Now we get a note when we insert a datetime value into a date column
For default values to CREATE, don't give errors for warning level NOTE
Fixed some compiler failures
Added library ws2_32 for windows compilation (needed if we want to compile with IOCP support)
Removed duplicate typedef TIME and replaced it with MYSQL_TIME

Better (more complete) fix for: Bug#21103 "DATE column not compared as DATE"
Fixed properly Bug#18997 "DATE_ADD and DATE_SUB perform year2K autoconversion magic on 4-digit year value"
Fixed Bug#23093 "Implicit conversion of 9912101 to date does not match cast(9912101 as date)"
2007-05-16 10:44:59 +02:00
msvensson@pilot.blaudden
19618b5375 Merge bk-internal:/home/bk/mysql-5.0-maint
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
2007-05-16 10:15:21 +02:00
msvensson@pilot.blaudden
47d3829f0b Fix for bug #28240: "isinf()" cannot be used in C++ for lack of prototype
- Since isinf() portability across various platforms and
  compilers is a complicated question, we should not use
  it directly. Instead, the my_isinf() macro should be used,
  which is defined as an alias to the system-defined isinf()
  if it is safe to use, or a workaround implementation otherwise
2007-05-16 10:10:02 +02:00
kostja@vajra.(none)
bb2a43dd19 Fix a failing assert. 2007-05-16 11:49:15 +04:00
kostja@vajra.(none)
f10effe402 Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  vajra.(none):/opt/local/work/mysql-5.0-21483
2007-05-16 09:52:01 +04:00
kostja@vajra.(none)
747842e10b A fix and a test case for
Bug#21483 "Server abort or deadlock on INSERT DELAYED with another
implicit insert"
Also fixes and adds test cases for bugs:
20497 "Trigger with INSERT DELAYED causes Error 1165"
21714 "Wrong NEW.value and server abort on INSERT DELAYED to a
table with a trigger".
Post-review fixes.

Problem:
In MySQL INSERT DELAYED is a way to pipe all inserts into a
given table through a dedicated thread. This is necessary for
simplistic storage engines like MyISAM, which do not have internal
concurrency control or threading and thus can not
achieve efficient INSERT throughput without support from SQL layer.
DELAYED INSERT works as follows:
For every distinct table, which can accept DELAYED inserts and has
pending data to insert, a dedicated thread is created to write data
to disk. All user connection threads that attempt to
delayed-insert into this table interact with the dedicated thread in
producer/consumer fashion: all records to-be inserted are pushed
into a queue of the dedicated thread, which fetches the records and 
writes them.
In this design, client connection threads never open or lock
the delayed insert table.
This functionality was introduced in version 3.23 and does not take 
into account existence of triggers, views, or pre-locking.
E.g. if INSERT DELAYED is called from a stored function, which,
in turn, is called from another stored function that uses the delayed
table, a deadlock can occur, because delayed locking by-passes
pre-locking. Besides:
 * the delayed thread works directly with the subject table through
   the storage engine API and does not invoke triggers
 * even if it was patched to invoke triggers, if triggers,
   in turn, used other tables, the delayed thread would
   have to open and lock involved tables (use pre-locking).
 * even if it was patched to use pre-locking, without deadlock
   detection the delayed thread could easily lock out user 
   connection threads in case when the same table is used both
   in a trigger and on the right side of the insert query: 
   the delayed thread would not release locks until all inserts 
   are complete, and user connection can not complete inserts 
   without having locks on the tables used on the right side of the
   query.

Solution:

These considerations suggest two general alternatives for the
future of INSERT DELAYED:
 * it is considered a full-fledged alternative to normal INSERT
 * it is regarded as an optimisation that is only relevant 
   for simplistic engines.
Since we missed our chance to provide complete support of new
features when 5.0 was in development, the first alternative
currently renders infeasible.
However, even the second alternative, which is to detect
new features and convert DELAYED insert into a normal insert, 
is not easy to implement.
The catch-22 is that we don't know if the subject table has triggers
or is a view before we open it, and we only open it in the
delayed thread. We don't know if the query involves pre-locking
until we have opened all tables, and we always first create
the delayed thread, and only then open the remaining tables.
This patch detects the problematic scenarios and converts
DELAYED INSERT to a normal INSERT using the following approach:
 * if the statement is executed under pre-locking (e.g. from
   within a stored function or trigger) or the right
   side may require pre-locking, we detect the situation
   before creating a delayed insert thread and convert the statement
   to a conventional INSERT.
  * if the subject table is a view or has triggers, we shutdown
   the delayed thread and convert the statement to a conventional
   INSERT.
2007-05-16 09:51:05 +04:00
igor@olga.mysql.com
8b829fb1ae Merge olga.mysql.com:/home/igor/mysql-5.0-opt
into  olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug28272
2007-05-15 14:14:52 -07:00
evgen@moonbone.local
fbb2332628 Bug#28208: Wrong result of a non-const STRING function with a const DATETIME
function.

A wrong  condition was used to check that the
Arg_comparator::can_compare_as_dates() function calculated the value of the
string constant. When comparing a non-const STRING function with a constant
DATETIME function it leads to saving an arbitrary value as a cached value of
the DATETIME function.

Now the Arg_comparator::set_cmp_func() function initializes the const_value
variable to the impossible DATETIME value (-1) and this const_value is
cached only if it was changed by the Arg_comparator::can_compare_as_dates()
function.
2007-05-16 00:30:12 +04:00
igor@olga.mysql.com
fea67e6868 Merge olga.mysql.com:/home/igor/dev-opt/mysql-4.1-opt-bug28272
into  olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug28272
2007-05-15 13:16:10 -07:00
iggy@amd64.(none)
3f4138a519 Bug#24732 Executables do not include Vista manifests
- Manifest requires four part application version.
- mysqld does not need requireAdministrator rights 
to run.
2007-05-15 10:30:11 -04:00
mhansson/martin@linux-st28.site
5bc137ff17 Bug#27573: MIN() on an indexed column which is always NULL sets _other_ results
to NULL

For queries of the form SELECT MIN(key_part_k) FROM t1 
WHERE key_part_1 = const and ... and key_part_k-1 = const,
the opt_sum_query optimization tries to
use an index to substitute MIN/MAX functions with their values according
to the following rules:
1) Insert the minimum non-null values where the WHERE clause still matches, or
3) A row of nulls

However, the correct semantics requires that there is a third case 2)
such that a NULL value is substituted if there are only NULL values for 
key_part_k.

The patch modifies opt_sum_query() to handle this missing case.
2007-05-15 15:29:12 +03:00
kostja@vajra.(none)
7ff604eb76 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  vajra.(none):/opt/local/work/mysql-5.0-runtime
2007-05-15 13:56:09 +04:00
igor@olga.mysql.com
268be06874 Fixed bug #28272: crash that occurs when running an EXPLAIN command
for a query over an empty table right after its creation. 
The crash is the result of an attempt made by JOIN::optimize to evaluate
the WHERE condition when no records have been actually read.
The added test case can reproduce the crash only with InnoDB tables and
only with 5.0.x.
2007-05-14 23:55:18 -07:00
igor@olga.mysql.com
25f5e7d999 Merge olga.mysql.com:/home/igor/dev-opt/mysql-4.1-opt-bug27937
into  olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug27937
2007-05-14 17:06:05 -07:00
igor@olga.mysql.com
d71043b889 Fixed bug #27937: crash for the the second execution of a prepared
statement from a UNION query with ORDER BY an expression containing
RAND().
The crash happened because the global order by list in the union query
was not re-initialized for execution.
(Local order by lists were re-initialized though).
2007-05-14 16:41:09 -07:00
mhansson@dl145s.mysql.com
10ab91447d Merge mhansson@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  dl145s.mysql.com:/users/mhansson/mysql/autopush/5.0o-5.0o-bug28273
2007-05-14 17:28:10 +02:00
kostja@vajra.(none)
162e9b9866 Fix a warning. 2007-05-14 10:56:23 +04:00
ibabaev@bk-internal.mysql.com
7d006ee538 Merge bk-internal.mysql.com:/data0/bk/mysql-5.0
into  bk-internal.mysql.com:/data0/bk/mysql-5.0-opt
2007-05-12 23:42:36 +02:00
igor@olga.mysql.com
11d5f7ee1c Fixed bug #28375: a query with an NOT IN subquery predicate may cause
a crash when the left operand of the predicate is evaluated to NULL.
It happens when the rows from the inner tables (tables from the subquery)
are accessed by index methods with key values obtained by evaluation of
the left operand of the subquery predicate. When this predicate is
evaluated to NULL an alternative access with full table scan is used
to check whether the result set returned by the subquery is empty or not.
The crash was due to the fact the info about the access methods used for
regular key values was not properly restored after a switch back from the
full scan access method had occurred.
The patch restores this info properly.
The same problem existed for queries with IN subquery predicates if they
were used not at the top level of the queries.
2007-05-11 19:37:32 -07:00
dlenev@mockturtle.local
25114c7d09 Added missing DBUG_VOID_RETURN to the sp_head::init_sp_name() method. 2007-05-12 00:03:50 +04:00
holyfoot/hf@mysql.com/hfmain.(none)
6fe0f52de1 Merge bk@192.168.21.1:mysql-5.0-opt
into  mysql.com:/home/hf/work/27957/my50-27957
2007-05-12 00:22:14 +05:00
evgen@moonbone.local
9a427d8dd8 Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  moonbone.local:/mnt/gentoo64/work/27878-bug-5.0-opt-mysql
2007-05-11 23:22:13 +04:00
evgen@moonbone.local
34f478121f Bug#27878: Unchecked privileges on a view referring to a table from another
database.

If a user has a right to update anything in the current database then the 
access was granted and further checks of access rights for underlying tables
wasn't done correctly. The check is done before a view is opened and thus no
check of access rights for underlying tables can be carried out.
This allows a user to update through a view a table from another database for
which he hasn't enough rights.

Now the mysql_update() and the mysql_test_update() functions are forces
re-checking of access rights after a view is opened.
2007-05-11 23:19:11 +04:00
dlenev@mockturtle.local
d5dbdd9866 Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  mockturtle.local:/home/dlenev/src/mysql-5.0-cts-3
2007-05-11 21:55:55 +04:00
dlenev@mockturtle.local
8b93e52e92 Fix for:
Bug #20662 "Infinite loop in CREATE TABLE IF NOT EXISTS ... SELECT
              with locked tables"
  Bug #20903 "Crash when using CREATE TABLE .. SELECT and triggers"
  Bug #24738 "CREATE TABLE ... SELECT is not isolated properly"
  Bug #24508 "Inconsistent results of CREATE TABLE ... SELECT when
              temporary table exists"
 
Deadlock occured when one tried to execute CREATE TABLE IF NOT
EXISTS ... SELECT statement under LOCK TABLES which held
read lock on target table.
Attempt to execute the same statement for already existing
target table with triggers caused server crashes.
Also concurrent execution of CREATE TABLE ... SELECT statement
and other statements involving target table suffered from
various races (some of which might've led to deadlocks).
Finally, attempt to execute CREATE TABLE ... SELECT in case
when a temporary table with same name was already present
led to the insertion of data into this temporary table and
creation of empty non-temporary table.
 
All above problems stemmed from the old implementation of CREATE
TABLE ... SELECT in which we created, opened and locked target
table without any special protection in a separate step and not
with the rest of tables used by this statement.
This underminded deadlock-avoidance approach used in server
and created window for races. It also excluded target table
from prelocking causing problems with trigger execution.
  
The patch solves these problems by implementing new approach to
handling of CREATE TABLE ... SELECT for base tables.
We try to open and lock table to be created at the same time as
the rest of tables used by this statement. If such table does not
exist at this moment we create and place in the table cache special
placeholder for it which prevents its creation or any other usage
by other threads.

We still use old approach for creation of temporary tables.

Also note that we decided to postpone introduction of some tests
for concurrent behaviour of CREATE TABLE ... SELECT till 5.1.
The main reason for this is absence in 5.0 ability to set @@debug
variable at runtime, which can be circumvented only by using several
test files with individual .opt files. Since the latter is likely
to slowdown test-suite unnecessary we chose not to push this tests
into 5.0, but run them manually for this version and later push
their optimized version into 5.1
2007-05-11 20:33:13 +04:00
holyfoot/hf@mysql.com/hfmain.(none)
17265468ac merging fixes 2007-05-11 20:56:22 +05:00
kostja@vajra.(none)
ad609d6e80 Cleanup: now that we have Lex_input_stream, finish the transition
by moving yet another relevant flag to it from struct LEX.
2007-05-11 17:26:12 +04:00