Commit graph

10563 commits

Author SHA1 Message Date
unknown
eb056fb82b Merge lthalmann@bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  mysql.com:/nfsdisk1/lars/bk/mysql-5.0-rpl


mysql-test/t/disabled.def:
  Auto merged
2007-05-31 10:20:58 +02:00
unknown
dd190b0e6b bug#22725
refining the test because of Bug #28786 'reset master' does not reset binlogging on embeded server


mysql-test/t/binlog_killed.test:
  the test can not pass on embedded server. Setting the include-guard.
2007-05-30 22:29:15 +03:00
unknown
e5c4d97c9e bug#22725
test comments correction


mysql-test/r/binlog_killed.result:
  changed
mysql-test/t/binlog_killed.test:
  wrong comments (but important ones) left;
  little refinement in result calc
2007-05-30 10:56:18 +03:00
unknown
9f15fe64bd Disable IM-tests. 2007-05-30 11:53:50 +04:00
unknown
9a1e9de91f bug#22725
combining the final result variable in such way that either option of the test execution
will yield zero.


mysql-test/r/binlog_killed.result:
  results changed
mysql-test/t/binlog_killed.test:
  there are two options for the test passing:
  1. no rows inserted and the INSERT gets killed, then there is no INSERT query in binlog
  2. all rows inserted, then INSERT gets to binlog and error_code is zero
2007-05-30 00:22:24 +03:00
unknown
54e1f2f0ce bug#22725
tests refining, see binlog_killed.test file for details


mysql-test/r/binlog_killed.result:
  results changed
mysql-test/t/binlog_killed.test:
  killer conn waits for the first row to appear;
  log-disabling kill query since prey's id is not deterministic;
  correcting pattern to search in binlog for insert query;
2007-05-29 23:16:50 +03:00
unknown
70a530e401 bug#22725
refining the test.


mysql-test/t/binlog_killed.test:
  due to killing reap may catch an error though it's indeterministic.
2007-05-29 21:05:08 +03:00
unknown
00710d17bb Bug#22725 Replication outages from ER_SERVER_SHUTDOWN (1053) set in replication events
Refining the tests since pb revealed the older version's fragality - the error from SF() due to killed
may be different on different env:s.
DBUG_ASSERT instead of assert.


mysql-test/r/binlog_killed.result:
  new result file
mysql-test/t/binlog_killed.test:
  regression for bug#22725 simplified. tests for bug27563, BUG#27565 made inactive.
sql/sql_insert.cc:
  DBUG_ASSERT
2007-05-29 16:27:55 +03:00
unknown
f27bf2b463 Bug#22725 Replication outages from ER_SERVER_SHUTDOWN (1053) set in replication events
The reason for the bug was that replaying of a query on slave could not be possible since its event
was recorded with the killed error. Due to the specific of handling INSERT, which per-row-while-loop is 
unbreakable to killing, the query on transactional table should have not appeared in binlog unless
there was  a call to a stored routine that got interrupted with killing (and then there must be an error
returned out of the loop).
   
The offered solution added the following rule for binlogging of INSERT that accounts the above
specifics:
For INSERT on transactional-table if the error was not set the only raised flag
is harmless and is ignored via masking out on time of creation of binlog event.
   
For both table types the combination of raised error and KILLED flag indicates that there
was potentially partial execution on master and consistency is under the question.
In that case the code continues to binlog an event with an appropriate killed error.
 
The fix relies on the specified behaviour of stored routine that must propagate the error 
to the top level query handling if the thd->killed flag was raised in the routine execution.
   
The patch adds an arg with the default killed-status-unset value to Query_log_event::Query_log_event.


sql/log_event.cc:
  killed_status as the value of thd->killed can be passed as an arg to the constructor.
  if the value is different from the default the arg is set to the current thd->killed value.
  A caller might need to masquerade thd->killed with THD::NOT_KILLED.
  So far only mysql_insert() uses such explicit way to tell the constructor about killing status.
sql/log_event.h:
  default arg to the constructor with meaning of killed status of the query. 
  if the arg is not explicitly provided the status of thd->killed will be snapshot 
  inside of the constuctor, which is potentially incorrect (see bug#27571)
sql/sql_class.h:
  extending killed_state with no-state member.
sql/sql_insert.cc:
  ignore the KILLED flag incl KILL_BAD_DATA when the INSERT query event 
  is created without an `error';
sql/sql_update.cc:
  Suggestion how to fix bug#27571 as comments.
mysql-test/r/binlog_killed.result:
  new result file
mysql-test/t/binlog_killed.test:
  regression tests also apply for bug27563, BUG#27565
2007-05-28 22:20:22 +03:00
unknown
9f757559ee Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.0-rpl
into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.0-merge


mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/t/disabled.def:
  Auto merged
sql/sql_load.cc:
  Auto merged
2007-05-28 09:21:42 +02:00
unknown
c8236f564c Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  vajra.(none):/opt/local/work/mysql-5.0-runtime


sql/mysql_priv.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
2007-05-24 19:23:52 +04:00
unknown
f9d7642e7b 5.0 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 (see
comment for sql_table.cc for details).

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().

Note that, altough tests covering concurrency-related aspects of CREATE TABLE
LIKE behaviour will only be introduced in 5.1, they were run manually for
this patch as well.


mysql-test/r/grant2.result:
  Added test for bug#25578 "CREATE TABLE LIKE does not require any privileges
  on source table".
mysql-test/t/grant2.test:
  Added test for bug#25578 "CREATE TABLE LIKE does not require any privileges
  on source table".
sql/handler.h:
  Introduced new flag for HA_CREATE_INFO::options in order to be able to
  distinguish CREATE TABLE ... LIKE from other types of CREATE TABLE.
sql/mysql_priv.h:
  mysql_create_like_table() now takes source table name not as a
  Table_ident object but as regular table list element.
sql/sql_parse.cc:
  CREATE TABLE ... LIKE implementation now uses statement's table list
  for storing information about the source table. We also use flag
  in LEX::create_info.options for distinguishing it from other types
  of CREATE TABLE.
  Finally CREATE TABLE ... LIKE now requires the same privileges on
  the source tables as SHOW CREATE TABLE. Moved this privilege check
  to check_show_create_table_access() function.
sql/sql_table.cc:
  mysql_create_like_table():
   - Provided proper protection from concurrent statements.
     This is achieved by keeping name-lock on the source table and holding
     LOCK_open mutex during whole operation. This gives protection against
     concurrent DDL on source table. Also holding this mutex makes copying
     of .frm file, call to ha_create_table() and binlogging atomic against
     concurrent DML and DDL operations on target table.
   - Get rid of duplicated code related to source database/table name
     handling. All these operations are already done in
     st_select_lex::add_table_to_list(), so we achieve the same effect
     by including source table into the statement's table list.
sql/sql_yacc.yy:
  Now we use special flag in LEX::create_info::options for distinguishing
  CREATE TABLE ... LIKE from other types of CREATE TABLE and store name
  of source table as regular element in statement's table list.
2007-05-23 15:22:13 +04:00
unknown
adef673652 Merge mysql.com:/home/svoj/devel/bk/mysql-5.0
into  mysql.com:/home/svoj/devel/mysql/merge/mysql-5.0-engines
2007-05-23 12:39:33 +05:00
unknown
221e23ad72 Merge quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/50
into  quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/50


configure.in:
  Auto merged
mysql-test/r/strict.result:
  Auto merged
mysql-test/r/type_datetime.result:
  Auto merged
mysql-test/t/type_datetime.test:
  Auto merged
sql/item.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
2007-05-21 20:50:08 +02:00
unknown
f40047df9c Merge pilot.blaudden:/home/msvensson/mysql/bug28401/my50-bug28401
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
2007-05-19 18:22:08 +02:00
unknown
f52f931f4b Bug #28401 mysql_upgrade Failed with STRICT_ALL_TABLES, ANSI_QUOTES and NO_ZERO_DATE
- The SQL commands used by mysql_upgrade are written to be run
    with sql_mode set to '' - thus the scripts should change sql_mode
    for the session to make sure the SQL is legal.


mysql-test/r/mysql_upgrade.result:
  Update test result
mysql-test/t/mysql_upgrade.test:
  The SQL commands used by mysql_upgrade are written to be run
  with sql_mode set to '' - thus the scripts should change sql_mode
  for the session to make sure the SQL is legal.
scripts/mysql_system_tables_fix.sql:
  Set sql_mode to '' before running the SQL commands
  to fix system tables - backport from 5.1
2007-05-19 18:15:08 +02:00
unknown
8933c18cca Merge bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  sergbook.mysql.com:/usr/home/serg/Abk/mysql-5.0


mysql-test/r/ps.result:
  Auto merged
mysql-test/t/ps.test:
  Auto merged
sql/item.cc:
  Auto merged
2007-05-18 18:22:38 +02:00
unknown
f7434c4f93 added cleanup to some tests
mysql-test/r/sp_trans.result:
  added cleanup
mysql-test/r/strict.result:
  added cleanup
mysql-test/t/sp_trans.test:
  added cleanup
mysql-test/t/strict.test:
  added cleanup
2007-05-18 17:48:44 +02:00
unknown
ca633f5f56 Merge bk-internal:/home/bk/mysql-5.0-maint
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
2007-05-18 12:58:28 +02:00
unknown
f35dd61497 Merge pilot.blaudden:/home/msvensson/mysql/mysql-4.1-maint
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint


client/mysqltest.c:
  Auto merged
mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/r/mysqltest.result:
  Auto merged
mysql-test/t/mysqltest.test:
  SCCS merged
2007-05-18 12:56:52 +02:00
unknown
421d8ca972 WL#2247 mysqltest: add option for sorting results
- Final touchups


client/mysqltest.c:
  Final touch ups, rename sorted_results to sorted_result
mysql-test/r/mysqltest.result:
  Update test result
mysql-test/t/mysqltest.test:
  Update results with additional subtests for empty result set,
  NULL values and 1024 rows
2007-05-18 12:50:23 +02:00
unknown
507ad360d7 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
unknown
fda27597ee Bug #27907 "Misleading error message when opening/locking tables"
Adjust the check that defines the error message to be returned.


mysql-test/r/sp-error.result:
  Update results (more accurate error code)
mysql-test/r/sp-prelocking.result:
  Update results (more accurate error code)
mysql-test/r/trigger.result:
  Update results (more accurate error code)
mysql-test/t/sp-error.test:
  ER_NOT_LOCKED -> ER_NO_SUCH_TABLE
mysql-test/t/sp-prelocking.test:
  Add a test case for Bug#27907
mysql-test/t/trigger.test:
  ER_NOT_LOCKED -> ER_NO_SUCH_TABLE
sql/sql_base.cc:
  Adjust the check for where-we-are for a better error message.
2007-05-18 12:29:06 +04:00
unknown
042b1717c4 Merge olga.mysql.com:/home/igor/mysql-5.0-opt
into  olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug28337
2007-05-17 16:06:57 -07:00
unknown
ce5f0d1bc3 Merge siva.hindu.god:/home/tsmith/m/bk/50
into  siva.hindu.god:/home/tsmith/m/bk/maint/50


mysql-test/r/type_datetime.result:
  Auto merged
mysql-test/t/outfile.test:
  Auto merged
mysql-test/t/type_datetime.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/my_decimal.h:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
2007-05-17 14:17:50 -06:00
unknown
c4a4df5aa4 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).


mysql-test/t/type_datetime.test:
  A test case is added for the bug#28261: Wrong DATETIME comparison result when the GET_USER_VAR function
  is involved.
mysql-test/r/type_datetime.result:
  A test case is added for the bug#28261: Wrong DATETIME comparison result when the GET_USER_VAR function
  is involved.
sql/item_cmpfunc.cc:
  Bug#28261: Wrong DATETIME comparison result when the GET_USER_VAR function
  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
unknown
dd1a118000 Fixed bug #28337: wrong results for grouping queries with correlated
subqueries in WHERE conditions.
This bug was introduced by the patch for bug 27321.


mysql-test/r/subselect.result:
  Added a test case for bug #28337.
mysql-test/t/subselect.test:
  Added a test case for bug #28337.
sql/item.cc:
  Fixed bug #28337: wrong results for grouping queries with correlated
  subqueries in WHERE conditions.
  This bug was introduced by the patch for bug 27321.
  
  Now in the Item_field::fix_outer_field function we create an Item_outer_ref
  object for an outer reference only if it is used in the SELECT list or
  in the HAVING clause of the subquery against which the reference is resolved.
2007-05-16 23:42:10 -07:00
unknown
b015146e41 Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  mysql.com:/home/hf/work/8663/my50-8663
2007-05-17 00:10:39 +05:00
unknown
5e00d4b7f6 Merge bk@192.168.21.1:mysql-5.0-opt
into  mysql.com:/home/hf/work/8663/my50-8663
2007-05-17 00:09:43 +05:00
unknown
614135222f WL#2247 mysqltest: add option for sorting results
- Change from "query_sorted <query>" to "sorted_results"


client/mysqltest.c:
  Replace "query_sorted <query>" with the ability to turn
  on "one shot result sorting" with the command "sorted_results"
mysql-test/r/mysqltest.result:
  Update test and result
mysql-test/t/mysqltest.test:
  Update test and result
2007-05-16 17:19:36 +02:00
unknown
7c70011e21 Merge kpettersson@bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  adventure.(none):/home/thek/Development/cpp/mysql-5.0-runtime
2007-05-16 14:54:47 +02:00
unknown
d9ce3033f5 Bug#27415 Text Variables in stored procedures
- Problem was reported as a SP variable using itself as 
   right value inside SUBSTR caused corruption of data. 
 - This bug could not be verified in either 5.0bk or 5.1bk
 - Added test case to prevent future regressions.


mysql-test/r/sp-vars.result:
  Added test case for a reported regression which couldn't be
  verified.
mysql-test/t/sp-vars.test:
  Added test case for a reported regression which couldn't be
  verified.
2007-05-16 14:25:38 +02:00
unknown
418a2983c0 Merge mhansson@bk-internal:/home/bk/mysql-5.0-opt
into  linux-st28.site:/home/martin/mysql/src/5.0o-bug27573


mysql-test/r/func_group.result:
  Auto merged
mysql-test/t/func_group.test:
  bug#27573: hand merged test case
2007-05-16 12:22:20 +03:00
unknown
b5e4f54a53 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)"
 


include/my_time.h:
  Removed not used define YY_MAGIC_BELOW
  Added prototype for year_2000_handling()
mysql-test/r/date_formats.result:
  Updated results (fixed bug in date_format() with year < 99
mysql-test/r/func_sapdb.result:
  Added more testing of make_date()
mysql-test/r/ps_2myisam.result:
  Now we get a note when we insert a datetime value into a date column
mysql-test/r/ps_3innodb.result:
  Now we get a note when we insert a datetime value into a date column
mysql-test/r/ps_4heap.result:
  Now we get a note when we insert a datetime value into a date column
mysql-test/r/ps_5merge.result:
  Now we get a note when we insert a datetime value into a date column
mysql-test/r/ps_7ndb.result:
  Now we get a note when we insert a datetime value into a date column
mysql-test/r/strict.result:
  zero-year in str_to_date() throws warning in strict
mysql-test/r/type_date.result:
  Added test for date conversions
mysql-test/r/type_datetime.result:
  Added testcase for datetime to date conversion.
mysql-test/t/date_formats.test:
  Added testing of dates < 200
mysql-test/t/func_sapdb.test:
  More testing of makedate()
mysql-test/t/type_date.test:
  Added test for date conversions
mysql-test/t/type_datetime.test:
  Added testcase for datetime to date conversion
sql/field.cc:
  Give note if we insert a datetime value in a date field
  Don't give notes if we are doing internal test conversions (like from convert_constant_item())
  More documentation (store functions can now return '3' to inform that the function did return a NOTE (not warning or error))
  Revert some changes in Field_newdate::store() to get more optimal code
  Field::set_warning() will now ignore notes if CHECK_FIELD_IGNORE is set.
  New parameters to make_truncated_value_warning()
sql/field.h:
  Give note if we insert a datetime value in a date field
  Don't give notes if we are doing internal test conversions (like from convert_constant_item())
  More documentation (store functions can now return '3' to inform that the function did return a NOTE (not warning or error))
  Revert some changes in Field_newdate::store() to get more optimal code
  Field::set_warning() will now ignore notes if CHECK_FIELD_IGNORE is set.
  New parameters to make_truncated_value_warning()
sql/item.cc:
  Give note if we insert a datetime value in a date field
  Don't give notes if we are doing internal test conversions (like from convert_constant_item())
  More documentation (store functions can now return '3' to inform that the function did return a NOTE (not warning or error))
  Revert some changes in Field_newdate::store() to get more optimal code
  Field::set_warning() will now ignore notes if CHECK_FIELD_IGNORE is set.
  New parameters to make_truncated_value_warning()
sql/item.h:
  TIME -> MYSQL_TIME
sql/item_cmpfunc.cc:
  Don't print notes in convert_constant_item()
sql/item_func.h:
  TIME -> MYSQL_TIME
sql/item_timefunc.cc:
  New parameters to make_truncated_value_warning()
  Moved year 2000 handling out from calc_days()
sql/item_timefunc.h:
  TIME -> MYSQL_TIME
sql/my_decimal.cc:
  TIME -> MYSQL_TIME
sql/my_decimal.h:
  TIME -> MYSQL_TIME
sql/mysql_priv.h:
  Added error level to make_truncated_value_warning()
sql/protocol.cc:
  TIME -> MYSQL_TIME
sql/protocol.h:
  TIME -> MYSQL_TIME
sql/sp.cc:
  TIME -> MYSQL_TIME
sql/sql_base.cc:
  Make testing of result value of save_in_field() uniform
sql/sql_class.h:
  TIME -> MYSQL_TIME
sql/sql_show.cc:
  TIME -> MYSQL_TIME
sql/structs.h:
  TIME -> MYSQL_TIME
sql/time.cc:
  Added error level to make_truncated_value_warning()
sql/tztime.cc:
  TIME -> MYSQL_TIME
sql/tztime.h:
  TIME -> MYSQL_TIME
sql/unireg.cc:
  For default values to CREATE, don't give errors for warning level NOTE
  (Fixed failed CREATE when we give a datetime value to a date field)
sql-common/my_time.c:
  Added year_2000_handling()
  Removed year 2000 handling from calc_daynr()
2007-05-16 10:44:59 +02:00
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
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
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
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
963fae4b80 Post-merge fix. 2007-05-14 18:26:00 -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
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
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