Commit graph

1660 commits

Author SHA1 Message Date
dlenev@mockturtle.local
8e8f4c05cc 5.1 version of fix for:
Bug #23667 "CREATE TABLE LIKE is not isolated from alteration
              by other connections"
  Bug #18950 "CREATE TABLE LIKE does not obtain LOCK_open"
As well as:
  Bug #25578 "CREATE TABLE LIKE does not require any privileges
              on source table".

The first and the second bugs resulted in various errors and wrong
binary log order when one tried to execute concurrently CREATE TABLE LIKE
statement and DDL statements on source table or DML/DDL statements on its
target table.

The problem was caused by incomplete protection/table-locking against
concurrent statements implemented in mysql_create_like_table() routine.
We solve it by simply implementing such protection in proper way.
Most of actual work for 5.1 was already done by fix for bug 20662 and
preliminary patch changing locking in ALTER TABLE.

The third bug allowed user who didn't have any privileges on table create
its copy and therefore circumvent privilege check for SHOW CREATE TABLE.

This patch solves this problem by adding privilege check, which was missing.

Finally it also removes some duplicated code from mysql_create_like_table()
and thus fixes bug #26869 "TABLE_LIST::table_name_length inconsistent with
TABLE_LIST::table_name".
2007-05-23 15:26:16 +04:00
dlenev@mockturtle.local
b0dfdc2b83 Patch changing how ALTER TABLE implementation handles table locking
and invalidation in the most general case (non-temporary table and
not simple RENAME or ENABLE/DISABLE KEYS or partitioning command).

See comment for sql/sql_table.cc for more information.

These changes are prerequisite for 5.1 version of fix for bug #23667
"CREATE TABLE LIKE is not isolated from alteration by other connections"
2007-05-19 10:49:56 +04:00
kostja@vajra.(none)
0a061c902b Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  vajra.(none):/opt/local/work/mysql-5.1-runtime
2007-05-15 17:54:11 +04:00
dlenev@mockturtle.local
4cafc8eeec 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.

Note that we have separate fix for 5.0 since there we use slightly
different less intrusive approach.
2007-05-11 21:51:03 +04:00
thek@adventure.(none)
770219c15a Merge adventure.(none):/home/thek/Development/cpp/bug27792/my51-bug27792
into  adventure.(none):/home/thek/Development/cpp/mysql-5.1-runtime
2007-05-08 12:02:38 +02:00
thek@adventure.(none)
6927ddd85a Merge adventure.(none):/home/thek/Development/cpp/bug27792/my50-bug27792
into  adventure.(none):/home/thek/Development/cpp/bug27792/my51-bug27792
2007-05-08 11:29:07 +02:00
thek@adventure.(none)
5e774747bc 4.1 -> 5.0 Manual merge for Bug #27792 2007-05-08 11:24:07 +02:00
thek@adventure.(none)
4744b0b91e Merge adventure.(none):/home/thek/Development/cpp/bug27792/my41-bug27792
into  adventure.(none):/home/thek/Development/cpp/bug27792/my50-bug27792
2007-05-08 09:36:21 +02:00
thek@adventure.(none)
4ea05eae31 Bug #27792 query cache returns wrong result, with certain system variables
- Queries in the query cache are identified by the individual 
   characters in the query statement, the current database and 
   the current environment expressed as a set of system variable
   flags.
 - Since the set of environment flags didn't properly describe the
   current environment unexpected results were returned from the 
   query cache.
 - Query cache is now cleared when the variable ft_boolean_syntax is 
   updated.
 - An identification flag for the variable default_week_format is 
   added to the query cache record.
 
Thanks to Martin Friebe who has supplied significant parts of this patch.
2007-05-08 09:09:25 +02:00
acurtis/antony@ltamd64.xiphis.org
b8301263f3 Merge xiphis.org:/home/antony/work2/mysql-5.1-engines
into  xiphis.org:/home/antony/work2/mysql-5.1-merge
2007-05-07 12:32:09 -07:00
holyfoot/hf@hfmain.(none)
763d4bf22e Merge mysql.com:/d2/hf/mrg/mysql-5.0-opt
into  mysql.com:/d2/hf/mrg/mysql-5.1-opt
2007-05-07 16:12:42 +05:00
holyfoot/hf@mysql.com/hfmain.(none)
37a9575b2e Merge bk@192.168.21.1:mysql-5.0
into  mysql.com:/d2/hf/mrg/mysql-5.0-opt
2007-05-07 16:08:29 +05:00
acurtis/antony@ltamd64.xiphis.org
a4dbc0990c Merge xiphis.org:/home/antony/work2/mysql-5.1-engines
into  xiphis.org:/home/antony/work2/mysql-5.1-engines.merge
2007-05-04 23:35:14 -07:00
evgen@moonbone.local
239f727b7e Bug#27759: Wrong DATE/DATETIME comparison in LEAST()/GREATEST() functions.
The LEAST/GREATEST functions compared DATE/DATETIME values as
strings which in some cases could lead to a wrong result.

A new member function called cmp_datetimes() is added to the
Item_func_min_max class. It compares arguments in DATETIME context
and returns index of the least/greatest argument.
The Item_func_min_max::fix_length_and_dec() function now detects when
arguments should be compared in DATETIME context and sets the newly
added flag compare_as_dates. It indicates that the cmp_datetimes() function
should be called to get a correct result.
Item_func_min_max::val_xxx() methods are corrected to call the
cmp_datetimes() function when needed.
Objects of the Item_splocal class now stores and reports correct original
field type.
2007-05-04 18:57:10 +04:00
malff/marcsql@weblab.(none)
e22cbec571 Merge weblab.(none):/home/marcsql/TREE/mysql-5.1-base
into  weblab.(none):/home/marcsql/TREE/mysql-5.1-rt-merge
2007-05-02 12:11:25 -06:00
serg@sergbook.mysql.com
1bd2953c02 compilation/test fixes 2007-04-29 17:46:18 -07:00
kaa@polly.local
561bd78654 Merge polly.local:/home/kaa/src/maint/bug24912/my50-bug24912
into  polly.local:/home/kaa/src/maint/mysql-5.0-maint
2007-04-28 20:26:14 +04:00
kaa@polly.local
83e8b70983 Merge polly.local:/home/kaa/src/maint/bug24912/my51-bug24912
into  polly.local:/home/kaa/src/maint/mysql-5.1-maint
2007-04-28 20:08:58 +04:00
kaa@polly.local
a45b654ed7 Merge polly.local:/home/kaa/src/maint/bug24912/my50-bug24912
into  polly.local:/home/kaa/src/maint/bug24912/my51-bug24912
2007-04-28 20:04:03 +04:00
kaa@polly.local
050c6723e8 Fix for bug #24912 "problems with bigint in abs() ceiling() round() truncate() mod()" and a number of related problems:
- unsigned flag was not handled correctly for a number of mathematical funcions, which led to incorrect results
- passing large values as the number of decimals to ROUND() resulted in incorrect results and even server crashes in some cases
- reverted the fix and the testcase for bug #10083 as it violates the manual
- fixed some testcases which relied on broken ROUND() behavior
2007-04-28 20:01:01 +04:00
istruewing@chilla.local
e327818c28 Merge bk-internal.mysql.com:/home/bk/mysql-5.1-engines
into  chilla.local:/home/mydev/mysql-5.1-wl2936-two
2007-04-27 19:09:39 +02:00
malff/marcsql@weblab.(none)
62fd6aa696 manual merge 5.0-runtime -> 5.1->runtime, with 25411 part I 2007-04-25 21:38:12 -06:00
malff/marcsql@weblab.(none)
575eeda804 Merge malff@bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  weblab.(none):/home/marcsql/TREE/mysql-5.0-25411_d
2007-04-24 09:25:54 -06:00
malff/marcsql@weblab.(none)
fc809c70cc Bug#25411 (trigger code truncated), PART I
The issue found with bug 25411 is due to the function skip_rear_comments()
which damages the source code while implementing a work around.
The root cause of the problem is in the lexical analyser, which does not
process special comments properly.
For special comments like :
[1] aaa /*!50000 bbb */ ccc
since 5.0 is a version older that the current code, the parser is in lining
the content of the special comment, so that the query to process is
[2] aaa bbb ccc
However, the text of the query captured when processing a stored procedure,
stored function or trigger (or event in 5.1), can be after rebuilding it:
[3] aaa bbb */ ccc
which is wrong.

To fix bug 25411 properly, the lexical analyser needs to return [2] when
in lining special comments.
In order to implement this, some preliminary cleanup is required in the code,
which is implemented by this patch.

Before this change, the structure named LEX (or st_lex) contains attributes
that belong to lexical analysis, as well as attributes that represents the
abstract syntax tree (AST) of a statement.
Creating a new LEX structure for each statements (which makes sense for the
AST part) also re-initialized the lexical analysis phase each time, which
is conceptually wrong.

With this patch, the previous st_lex structure has been split in two:
- st_lex represents the Abstract Syntax Tree for a statement. The name "lex"
has not been changed to avoid a bigger impact in the code base.
- class lex_input_stream represents the internal state of the lexical
  analyser, which by definition should *not* be reinitialized when parsing
  multiple statements from the same input stream.

This change is a pre-requisite for bug 25411, since the implementation of
lex_input_stream will later improve to deal properly with special comments,
and this processing can not be done with the current implementation of
sp_head::reset_lex and sp_head::restore_lex, which interfere with the lexer.

This change set alone does not fix bug 25411.
2007-04-24 09:24:21 -06:00
msvensson@pilot.blaudden
2ac94c30f4 Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.1
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.1-maint
2007-04-23 17:01:02 +02:00
msvensson@pilot.blaudden
dcd914e24e Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
2007-04-23 16:22:01 +02:00
msvensson@pilot.blaudden
d1de41c59a Merge bk-internal:/home/bk/mysql-5.0-maint
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
2007-04-23 12:05:00 +02:00
mats@romeo.(none)
875de0e571 Merge romeo.(none):/home/bkroot/mysql-5.1-rpl
into  romeo.(none):/home/bk/merge-mysql-5.1
2007-04-20 10:46:58 +02:00
mats@romeo.(none)
f1caa9559c Merge romeo.(none):/home/bkroot/mysql-5.0-rpl
into  romeo.(none):/home/bk/merge-mysql-5.0
2007-04-20 10:35:27 +02:00
tsmith@siva.hindu.god
9232def96b Merge siva.hindu.god:/home/tsmith/m/bk/51
into  siva.hindu.god:/home/tsmith/m/bk/maint/51
2007-04-18 14:55:42 -06:00
msvensson@pilot.blaudden
01133f8e6f Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.1-maint
2007-04-18 14:18:55 +02:00
msvensson@pilot.blaudden
dd0d2146c3 Merge pilot.blaudden:/home/msvensson/mysql/my50-m-mysql_upgrade
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
2007-04-18 13:22:32 +02:00
msvensson@pilot.blaudden
20e622dcf3 Bug#25452 mysql_upgrade access denied
- Improve mysql_upgrade and add comments describing it's logic
 - Don't look for mysql and mysqlcheck randomly, use dir where mysql_upgrade
  was started from
 - Don't look for mysql_fix_privilege_tables.sql randomly, compile
  in the mysql_fix_privilege_tables.sql file and use that to upgrade
  the system tables of MySQL
 - Check for any unexpected error returned from runnning the mysql_fix_privilege_tables SQL
 - Fix bug#26639, bug#24248 and bug#25405
2007-04-18 13:21:39 +02:00
serg@sergbook.mysql.com
6bc9bc92df Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  sergbook.mysql.com:/usr/home/serg/Abk/mysql-5.1-wl2936
2007-04-16 10:37:50 +02:00
jani@a88-113-38-195.elisa-laajakaista.fi
52196018ce Merge a88-113-38-195.elisa-laajakaista.fi:/home/my/new/mysql-5.0-marvel
into  a88-113-38-195.elisa-laajakaista.fi:/home/my/new/mysql-5.1-marvel
2007-04-13 10:25:33 +03:00
jani@ua141d10.elisa.omakaista.fi
335153121b Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.0
into  ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-5.0-marvel
2007-04-12 12:50:02 +03:00
lars/lthalmann@dl145h.mysql.com
1e5d279451 Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.1-new-rpl
into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.1-merge
2007-04-10 18:26:14 +02:00
lars/lthalmann@mysql.com/dl145h.mysql.com
904c75ede5 Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.0-rpl
into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.0-merge
2007-04-10 18:25:27 +02:00
jani@ua141d10.elisa.omakaista.fi
b4ba815967 Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.1
into  ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-5.1-marvel
2007-04-10 16:28:47 +03:00
bar@mysql.com
220c453194 Merge mysql.com:/home/bar/mysql-5.0-rpl
into  mysql.com:/home/bar/mysql-5.1-new-rpl
2007-04-09 18:06:27 +05:00
bar@mysql.com
4341df8cf6 Bug#22648 LC_TIME_NAMES: Setting GLOBAL has no effect
Problem: setting/displaying @@LC_TIME_NAMES didn't distinguish between
GLOBAL and SESSION variable types - always SESSION variable
was set/shonw.
Fix: set either global or session value.
Also, "mysqld --lc-time-names" was added to set "global default" value.
2007-04-09 17:58:56 +05:00
holyfoot/hf@hfmain.(none)
ce426dd622 Merge bk@192.168.21.1:mysql-5.1-opt
into  mysql.com:/d2/hf/mrg/mysql-5.1-opt
2007-04-07 14:59:53 +05:00
mskold/marty@mysql.com/linux.site
3e8cf5958b Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.0
into  mysql.com:/windows/Linux_space/MySQL/mysql-5.0-ndb
2007-04-05 08:39:12 +02:00
tomas@whalegate.ndb.mysql.com
343bfb779d Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.1
into  whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-single-user
2007-04-04 23:03:27 +02:00
jani@ua141d10.elisa.omakaista.fi
e40d3631a3 Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.1
into  ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-5.1-marvel
2007-04-04 21:25:39 +03:00
mskold/marty@linux.site
552d1086ec Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.1
into  mysql.com:/windows/Linux_space/MySQL/mysql-5.1-new-ndb
2007-04-04 17:03:31 +02:00
mskold/marty@mysql.com/linux.site
6c8f5c5859 Merge from 5.0 2007-04-04 16:58:25 +02:00
mskold/marty@linux.site
7e33b92279 Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.0
into  mysql.com:/windows/Linux_space/MySQL/mysql-5.1
2007-04-04 13:21:49 +02:00
mskold/marty@mysql.com/linux.site
625a2629f0 Bug #26242 UPDATE with subquery and triggers failing with cluster tables
In certain cases AFTER UPDATE/DELETE triggers on NDB tables that referenced
subject table didn't see the results of operation which caused invocation
of those triggers. In other words AFTER trigger invoked as result of update
(or deletion) of particular row saw version of this row before update (or
deletion).

The problem occured because NDB handler in those cases postponed actual
update/delete operations to be able to perform them later as one batch.

This fix solves the problem by disabling this optimization for particular
operation if subject table has AFTER trigger for this operation defined.
To achieve this we introduce two new flags for handler::extra() method:
HA_EXTRA_DELETE_CANNOT_BATCH and HA_EXTRA_UPDATE_CANNOT_BATCH.
These are called if there exists AFTER DELETE/UPDATE triggers during a
statement that potentially can generate calls to delete_row()/update_row().
This includes multi_delete/multi_update statements as well as insert statements
that do delete/update as part of an ON DUPLICATE statement.
2007-04-04 12:50:39 +02:00
holyfoot/hf@hfmain.(none)
f65b42dc6e Merge mysql.com:/home/hf/work/23675/my51-23675
into  mysql.com:/home/hf/work/my_mrg/my51-my_mrg
2007-04-04 14:04:05 +05:00