Commit graph

36557 commits

Author SHA1 Message Date
unknown
7e628372e9 Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  vajra.(none):/opt/local/work/mysql-5.0-21483


sql/sp_head.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
2007-05-16 09:52:01 +04:00
unknown
3395c53efc 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.


mysql-test/r/insert.result:
  Update test results.
mysql-test/t/insert.test:
  Add a test case for Bug#21483, Bug#20497, Bug#21714 (INSERT DELAYED
  and stored routines, triggers).
sql/sp_head.cc:
  Upgrade lock type to TL_WRITE when computing the pre-locking set.
sql/sql_base.cc:
  Use a new method.
sql/sql_insert.cc:
  INSERT DELAYED and pre-locking:
  - if  under pre-locking, upgrade the lock type to TL_WRITE
  and proceed as a normal write
  - if DELAYED table has triggers, also request a lock upgrade.
  - make sure errors in the delayed thread are propagated
  correctly
sql/sql_lex.h:
  Add a method to check if a parsed tree refers to stored
  routines.
2007-05-16 09:51:05 +04:00
unknown
1e33cfb36a bug #8663 cant use bigint unsigned as input to cast
in the case of the overflow in the decimal->integer conversion
we didn't return the proper boundary value, but just the result
of the conversion we calculated on the moment of the error


mysql-test/r/bigint.result:
  bug #8663 cant use bigint unsigned as input to cast
  test result fixed
mysql-test/t/bigint.test:
  bug #8663 cant use bigint unsigned as input to cast
  test case
strings/decimal.c:
  bug #8663 cant use bigint unsigned as input to cast
  decimal->int conversion fixed to return proper boundary value
  in the case of overflow
2007-05-16 10:12:49 +05:00
unknown
0e234075e5 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
unknown
9aa67a4096 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.


mysql-test/t/type_datetime.test:
  Added a test case for the bug#28208: Wrong result of a non-const STRING function with a const DATETIME function.
mysql-test/r/type_datetime.result:
  Added a test case for the bug#28208: Wrong result of a non-const STRING function with a const DATETIME function.
sql/item_cmpfunc.cc:
  Bug#28208: Wrong result of a non-const STRING function with a const 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
unknown
dfc85a63b1 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


mysql-test/r/innodb_mysql.result:
  Auto merged
mysql-test/t/innodb_mysql.test:
  Auto merged
sql/sql_select.cc:
  Manual merge
2007-05-15 13:16:10 -07:00
unknown
aeaadfac58 Merge bk-internal.mysql.com:/home/bk/mysql-5.0-maint
into  amd64.(none):/src/bug24732/my50-bug24732


mysql-test/mysql-test-run.pl:
  Auto merged
2007-05-15 15:23:40 -04:00
unknown
09fb739b95 Fix bug#27833 "Bourne shell string comparison issue in scripts/make_win_bin_dist":
Several string comparisons could never yield true because they had an 'x' guard
added to the variable but not to the constant value. Fix that by guarding both sides.


scripts/make_win_bin_dist:
  Fix bug#27833 "Bourne shell string comparison issue in scripts/make_win_bin_dist":
  
  Several string comparisons could never yield true because they had an 'x' guard
  added to the variable but not to the constant value. Fix that by guarding both sides.
  
  Use this occasion to apply some corrections to the comments and the usage text.
  
  Also, ensure the ".pdb" file is always optional.
2007-05-15 18:19:18 +02:00
unknown
e9e6b9e477 Add triggers for detecting bad changesets to mysql-5.0 2007-05-15 17:04:31 +02:00
unknown
7dea4576cb Bug#24732 Executables do not include Vista manifests
- Manifest requires four part application version.
- mysqld does not need requireAdministrator rights 
to run.


sql/CMakeLists.txt:
  Bug#24732 Executables do not include Vista manifests
  - Request less permissive set of privileges.
win/create_manifest.js:
  Bug#24732 Executables do not include Vista manifests
  - Manifest requires four part application version.
2007-05-15 10:30:11 -04:00
unknown
6f2c6b74f9 Bug#27344 Total failure to start the server
- Give some more protection against "too long socket name by setting the max
   length when to use a tmpdir for sockets to 70


mysql-test/mysql-test-run.pl:
  Give some more protection against "too long socket name by setting the max
  ength when to use a tmpdir for sockets to 70
2007-05-15 16:03:38 +02:00
unknown
aaf6acae9b 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.


mysql-test/r/func_group.result:
  Bug #27573: Correct result
mysql-test/t/func_group.test:
  Bug #27573: test case
sql/opt_sum.cc:
  Bug #27573:
  Added code that will try to read the
  first non-null value for a given complete-field prefix, second
  choice is to read the null, and lastly set the error code if no row
  is found.
2007-05-15 15:29:12 +03:00
unknown
ea3569af66 add error code to ndb require 2007-05-15 12:07:09 +02:00
unknown
10e3a96e47 improve error message on corrup schema file 2007-05-15 12:02:58 +02:00
unknown
b763ff9a6b Merge vajra.(none):/opt/local/work/mysql-4.1-runtime
into  vajra.(none):/opt/local/work/mysql-5.0-runtime
2007-05-15 13:57:15 +04:00
unknown
655efae884 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  vajra.(none):/opt/local/work/mysql-5.0-runtime


sql/item.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-05-15 13:56:09 +04:00
unknown
c3c64f1a0a Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into  vajra.(none):/opt/local/work/mysql-4.1-runtime
2007-05-15 13:39:24 +04:00
unknown
bc5ef9ffa1 Bug #26386 ndbd wont start after changing schema
backported error code from 5.1
    split error check when reading schema file


ndb/include/mgmapi/ndbd_exit_codes.h:
  backported error code from 5.1
ndb/src/kernel/blocks/dbdict/Dbdict.cpp:
  backported error code from 5.1
  split error check when reading schema file
ndb/src/kernel/error/ndbd_exit_codes.c:
  backported error code from 5.1
2007-05-15 09:03:00 +02:00
unknown
8762539d47 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.
 


mysql-test/r/innodb_mysql.result:
  Added a test case for bug #28272.
mysql-test/t/innodb_mysql.test:
  Added a test case for bug #28272.
sql/sql_select.cc:
  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.
  Such attempts could be observed only with EXPLAIN commands.
  Now at the optimization phase the WHERE condition is never evaluated if 
  there is no record previously read from the table.
2007-05-14 23:55:18 -07:00
unknown
2695f46b2a #26906 No message slogan found
- added errormessage and code for "declaring node dead"
2007-05-15 08:34:39 +02:00
unknown
963fae4b80 Post-merge fix. 2007-05-14 18:26:00 -07:00
unknown
7a02ef7d92 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


mysql-test/r/ps.result:
  Manual merge
mysql-test/t/ps.test:
  Manual merge
sql/sql_union.cc:
  Manual merge
2007-05-14 17:06:05 -07:00
unknown
fca58c9556 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).



mysql-test/r/ps.result:
  Added a test case for bug #27937.
mysql-test/t/ps.test:
  Added a test case for bug #27937.
sql/sql_union.cc:
  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).
  Added re-initialization of the global order by list in the function
  st_select_lex_unit::init_prepare_fake_select_lex.
2007-05-14 16:41:09 -07:00
unknown
879a0a7467 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
unknown
d8f13c8cd0 Disable im_life_cycle in 5.0. 2007-05-14 19:25:03 +04:00
unknown
db9908fcb9 import of fix for bug#28240 2007-05-14 15:11:29 +02:00
unknown
523078a042 Merge pippilotta.erinye.com:/shared/home/df/mysql/build/mysql-5.0-build-work-28358
into  pippilotta.erinye.com:/shared/home/df/mysql/build/mysql-5.0.42
2007-05-14 15:09:04 +02:00
unknown
373ec1ef11 Raise version number after cloning 5.0.42 2007-05-14 14:59:23 +02:00
unknown
c78f434071 files to check if log bin is turned on
mysql-test/include/have_log_bin.inc:
  New BitKeeper file ``mysql-test/include/have_log_bin.inc''
mysql-test/r/have_log_bin.require:
  New BitKeeper file ``mysql-test/r/have_log_bin.require''
2007-05-14 14:38:50 +02:00
unknown
3425d7d65c Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.0-ndb
into  whalegate.ndb.mysql.com:/home/tomas/mysql-5.0-ndb
2007-05-14 14:08:12 +02:00
unknown
0d6295c088 bug#28358 libmysql.dll cannot be dynamically loaded on Windows
libmysql/CMakeLists.txt:
  bug#28358 USE_TLS was not defined during build of libmysql.dll with target other than Debug. Defining it for RelWithDebInfo appears to fix the bug for win32 and win64 cmake builds.
2007-05-14 13:20:18 +02:00
unknown
5a5aafd307 Bug #28410 ndb: no retry sleep when getting autoincrement
- add retry sleep to allow temprary error to go away
2007-05-14 12:15:27 +02:00
unknown
4ce5e86f6b Merge pippilotta.erinye.com:/shared/home/df/mysql/build/mysql-4.1-build
into  pippilotta.erinye.com:/shared/home/df/mysql/build/mysql-4.1-build-work
2007-05-14 11:45:26 +02:00
unknown
6b67cf2cfa Merge pippilotta.erinye.com:/shared/home/df/mysql/build/mysql-5.0-build
into  pippilotta.erinye.com:/shared/home/df/mysql/build/mysql-5.0-build-work
2007-05-14 11:44:06 +02:00
unknown
2c4c855829 Update description. 2007-05-14 13:20:11 +04:00
unknown
8ebfa0baf4 Disable random-failing IM tests. 2007-05-14 13:02:12 +04:00
unknown
9bcdaea20a Merge mronstrom@bk-internal.mysql.com:/home/bk/mysql-5.0-ndb
into  dator3.(none):/home/mikael/mysql_clones/rt-5.0
2007-05-14 09:08:14 +02:00
unknown
d98a2a87c9 Fix a warning.
sql/sql_insert.cc:
  Fix a compile-time warning (log_on is not used in embedded).
2007-05-14 10:56:23 +04:00
unknown
6e3cff22ca 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
unknown
d886ea8fb6 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.


mysql-test/r/subselect3.result:
  Added a test case for bug #28375.
mysql-test/t/subselect3.test:
  Added a test case for bug #28375.
sql/item_subselect.cc:
  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.
sql/sql_select.h:
  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.
  In the JOIN_TAB structure two fields have been added to save info about
  index methods used to access the subquery rows. The saved info is used
  after a switch back from the alternative full scan access method has 
  occurred. The full scan is used when the left operand of the subquery
  predicate is evaluated to NULL.
2007-05-11 19:37:32 -07:00
unknown
50c5b54931 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-12 00:46:36 +04:00
unknown
f0ddabc518 grant.result, grant.test:
Corrected test case for the bug#27878.


mysql-test/t/grant.test:
  Corrected test case for the bug#27878.
mysql-test/r/grant.result:
  Corrected test case for the bug#27878.
2007-05-12 00:46:07 +04:00
unknown
c9af98c4a4 Added missing DBUG_VOID_RETURN to the sp_head::init_sp_name() method. 2007-05-12 00:03:50 +04:00
unknown
bd311c0c44 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
unknown
86dccd9289 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
unknown
04efdb1526 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.


mysql-test/t/grant.test:
  Added a test case for the bug#27878: Unchecked privileges on a view referring to a table from another database.
mysql-test/r/grant.result:
  Added a test case for the bug#27878: Unchecked privileges on a view referring to a table from another database.
sql/sql_update.cc:
  Bug#27878: Unchecked privileges on a view referring to a table from another 
  database.
  Now the mysql_update() function forces re-checking of access rights after 
  the view is opened.
sql/sql_prepare.cc:
  Bug#27878: Unchecked privileges on a view referring to a table from another 
  database.
  Now the mysql_test_update() function forces re-checking of access rights after
  the view is opened.
2007-05-11 23:19:11 +04:00
unknown
5c5623775c Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  mockturtle.local:/home/dlenev/src/mysql-5.0-cts-3


sql/mysql_priv.h:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-05-11 21:55:55 +04:00
unknown
c5a8245596 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


mysql-test/r/create.result:
  Extended test coverage for CREATE TABLE ... SELECT. In particular added
  tests for bug #24508 "Inconsistent results of CREATE TABLE ... SELECT
  when temporary table exists" and bug #20662 "Infinite loop in CREATE
  TABLE IF NOT EXISTS ... SELECT with locked tables".
mysql-test/r/trigger.result:
  Added test case for bug #20903 "Crash when using CREATE TABLE .. SELECT
  and triggers"
mysql-test/t/create.test:
  Extended test coverage for CREATE TABLE ... SELECT. In particular added
  tests for bug #24508 "Inconsistent results of CREATE TABLE ... SELECT
  when temporary table exists" and bug #20662 "Infinite loop in CREATE
  TABLE IF NOT EXISTS ... SELECT with locked tables".
mysql-test/t/trigger.test:
  Added test case for bug #20903 "Crash when using CREATE TABLE .. SELECT
  and triggers"
sql/lock.cc:
  Now for creation of name-lock placeholder in lock_table_name() we use
  auxiliary function table_cache_insert_placeholder().
sql/mysql_priv.h:
  Made build_table_path() function available outside of sql_table.cc file.
  reopen_name_locked_table() now has 3rd argument which controls linking
  in of table being opened into THD::open_tables (this is useful in
  cases when placeholder used for name-locking is already linked into
  this list).
  Added declaration of auxiliary function table_cache_insert_placeholder()
  which is used for creation of table placeholders for name-locking.
  Added declaration of table_cache_has_open_placeholder() function which
  can be used for checking if table cache contains an open placeholder for
  the table and if this placeholder was created by another thread.
  (This function is needed only in 5.0 where we use it in various versions
   of CREATE TABLE in order to protect it from concurrent CREATE TABLE
   ... SELECT operations for the table. Starting from 5.1 we use different
   approach so it is going to be removed there).
  Made close_old_data_files() static within sql_base.cc file. 
  Added auxiliary drop_open_table() routine.
  Moved declaration of refresh_version to table.h header to make it
  accessible from inline methods of TABLE class.
  MYSQL_OPEN_IGNORE_LOCKED_TABLES flag is no longer used. Instead
  MYSQL_OPEN_TEMPORARY_ONLY option was added.
sql/sql_base.cc:
  Added support for the new approach to the handling of CREATE TABLE
  ... SELECT for base tables.
  
  Now 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.
  
  Note significant distinctions of this placeholder from the placeholder
  used for normal name-lock: 1) It is treated like open table by other
  name-locks so it does not allow name-lock taking operations like DROP
  TABLE or RENAME TABLE to proceed. 2) it is linked into THD::open_tables
  list and automatically removed during close_thread_tables() call.
  
  open_tables():
    Implemented logic described above. To do this added
    auxiliary check_if_table_exists() function.
    Removed support for MYSQL_OPEN_IGNORE_LOCKED_TABLES option
    which is no longer used.
    Added MYSQL_OPEN_TEMPORARY_ONLY which is used to restrict
    search for temporary tables only.
  close_cached_tables()/close_thread_table()/reopen_tables()/
  close_old_data_files()/table_is_used()/remove_table_from_cache():
    Added support for open placeholders (note that we also use them
    when we need to re-open tables during flush).
  Added auxiliary drop_open_table() routine.
  reopen_name_locked_table():
    Now has 3rd argument which controls linking in of table being
    opened into THD::open_tables (this is useful in cases when
    placeholder used for name-locking is already linked into
    this list).
  Added auxiliary table_cache_insert_placeholder() routine which
  simplifies creation of placeholders used for name-locking.
  Added table_cache_has_open_placeholder() function which can be
  used for checking if table cache contains an open placeholder for
  the table and if this placeholder was created by another thread.
  (This function is needed only in 5.0 where we use it in various versions
   of CREATE TABLE in order to protect it from concurrent CREATE TABLE
   ... SELECT operations for the table. Starting from 5.1 we use different
   approach so it is going to be removed there).
sql/sql_handler.cc:
  Adjusted mysql_ha_mark_tables_for_reopen() routine to properly
  handle placeholders which now can be linked into open tables
  list.
sql/sql_insert.cc:
  Introduced new approach to handling of base tables in CREATE TABLE
  ... SELECT statement.
  
  Now 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. By doing this we avoid races which existed with
  previous approach in which we created, opened and locked target in
  separate step without any special protection.
  This also allows properly calculate prelocking set in cases when
  target table already exists and has some on insert triggers.
    
  Note that we don't employ the same approach for temporary tables
  (this is okay as such tables are unaffected by other threads).
  
  Changed create_table_from_items() and select_create methods to
  implement this approach.
sql/sql_parse.cc:
  The new approach to handling of CREATE TABLE ... SELECT for
  base tables assumes that all tables (including table to be
  created) are opened and (or) locked at the same time.
  So in cases when we create base table we have to pass to
  open_and_lock_tables() table list which includes target table.
sql/sql_prepare.cc:
  The new approach to handling of CREATE TABLE ... SELECT for
  base tables assumes that all tables (including table to be
  created) are opened and (or) locked at the same time.
  So in cases when we create base table we have to pass to
  open_and_lock_tables() table list which includes target table.
sql/sql_table.cc:
  Now mysql_create_table_internal(), mysql_create_like_table() and
  mysql_alter_table() not only check that destination table doesn't
  exist on disk but also check that there is no create placeholder
  in table cache for it (i.e. there is no CREATE TABLE ... SELECT
  operation in progress for it). Note that starting from 5.1 we
  use different approach in order to to protect CREATE TABLE ... SELECT
  from concurrent CREATE TABLE (ALTER TABLE ... RENAME) operations,
  the latter simply take name-locks on table before its creation
  (on target table name before renaming).
  
  Also made build_table_path() available from other files and
  asjusted calls to reopen_name_locked_table(), which now takes
  extra argument, which controls linking of open table into
  THD::open_tables list.
sql/sql_trigger.cc:
  reopen_name_locked_tables() now has one more argument which controls
  linking of opened table into the THD::open_tables list.
sql/sql_yacc.yy:
  The new approach to handling of CREATE TABLE ... SELECT statement
  for base tables assumes that all tables including table to be
  created are open and (or) locked at the same time. Therefore
  we need to set correct lock for target table.
sql/table.h:
  Moved declaration of refresh_version variable from mysql_priv.h
  to make it accessible from inline methods of TABLE class. 
  Renamed TABLE::locked_by_flush member to open_placeholder since
  now it is also used for taking exclusive name-lock and not only
  by flush. 
  Introduced TABLE::is_name_opened() helper method which can be used
  to distinguish TABLE instances corresponding to open tables or
  placeholders for them from closed instances (e.g. due to their old
  version). Also introduced TABLE::needs_reopen_or_name_lock() helper
  which allows to check if TABLE instance corresponds to outdated
  version of table or to name-lock placeholder.
  Introduced TABLE_LIST::create member which marks elements of
  table list corresponds to the table to be created.
  Adjusted TABLE_LIST::placeholder() method to take into account 
  name-lock placeholders for tables to be created (this, for example,
  allows to properly handle such placeholders in lock_tables()).
2007-05-11 20:33:13 +04:00
unknown
8bbe6f23db merging fixes
mysql-test/r/type_datetime.result:
  result fixed
mysql-test/t/type_datetime.test:
  testcase fixed
sql/item_func.cc:
  my_decimal_length_to_precision used
sql/my_decimal.h:
  merging fix
2007-05-11 20:56:22 +05:00
unknown
a0567199b1 Cleanup: now that we have Lex_input_stream, finish the transition
by moving yet another relevant flag to it from struct LEX.


mysql-test/r/ps.result:
  Update result.
mysql-test/r/ps_1general.result:
  Update result.
mysql-test/t/ps.test:
  New error code.
mysql-test/t/ps_1general.test:
  New error code.
sql/sql_lex.cc:
  Move stmt_prepare_mode to Lex_input_stream.
sql/sql_lex.h:
  Move stmt_prepare_mode to class Lex_input_stream
sql/sql_prepare.cc:
  Move stmt_prepare_mode to Lex_input_stream
sql/sql_yacc.yy:
  Remove dead code.
2007-05-11 17:26:12 +04:00