#At file:///media/sdb2/hezx/work/mysql/bzrwork/b37148/next-mr-bugfixing/ based on revid:zhenxing.he@stripped21042801-p3yv6rd8sn6atdu1
2957 He Zhenxing 2009-11-21 [merge]
Auto merge
A mysql-test/r/partition_sync.result
A mysql-test/r/rpl_mysqldump_slave.result
A mysql-test/t/partition_sync.test
A mysql-test/t/rpl_mysqldump_slave.test
M client/client_priv.h
M client/mysql.cc
M client/mysqladmin.cc
M client/mysqlcheck.c
M client/mysqldump.c
M client/mysqltest.cc
M client/sql_string.cc
M client/sql_string.h
M config/ac-macros/misc.m4
M include/m_string.h
M include/mysql_com.h
M include/violite.h
M libmysql/libmysql.c
M libmysqld/lib_sql.cc
M mysql-test/r/alias.result
M mysql-test/r/delete.result
M mysql-test/r/derived.result
M mysql-test/r/dirty_close.result
M mysql-test/r/func_sapdb.result
M mysql-test/r/func_time.result
M mysql-test/r/mysql.result
M mysql-test/r/sp-error.result
M mysql-test/r/sp.result
M mysql-test/r/subselect.result
M mysql-test/r/trigger.result
M mysql-test/r/type_time.result
M mysql-test/r/union.result
M mysql-test/suite/rpl/r/rpl_multi_delete2.result
M mysql-test/suite/rpl/t/rpl_multi_delete2.test
M mysql-test/suite/sys_vars/r/group_concat_max_len_func.result
M mysql-test/t/alias.test
M mysql-test/t/delete.test
M mysql-test/t/derived.test
M mysql-test/t/dirty_close.test
M mysql-test/t/func_sapdb.test
M mysql-test/t/func_time.test
M mysql-test/t/lock_multi.test
M mysql-test/t/mysql.test
M mysql-test/t/shm.test
M mysql-test/t/sp-error.test
M mysql-test/t/sp.test
M mysql-test/t/subselect.test
M mysql-test/t/trigger.test
M mysql-test/t/type_time.test
M mysql-test/t/union.test
M mysys/my_alloc.c
M mysys/my_getopt.c
M sql/event_data_objects.cc
M sql/event_scheduler.cc
M sql/events.cc
M sql/field.cc
M sql/field.h
M sql/ha_ndbcluster.cc
M sql/ha_ndbcluster_binlog.cc
M sql/ha_partition.cc
M sql/item_cmpfunc.cc
M sql/item_func.cc
M sql/item_subselect.cc
M sql/item_timefunc.cc
M sql/mysql_priv.h
M sql/opt_sum.cc
M sql/share/errmsg.txt
M sql/slave.cc
M sql/sp.cc
M sql/sp_head.cc
M sql/sql_acl.cc
M sql/sql_base.cc
M sql/sql_cache.cc
M sql/sql_class.cc
M sql/sql_class.h
M sql/sql_insert.cc
M sql/sql_list.h
M sql/sql_parse.cc
M sql/sql_partition.cc
M sql/sql_plugin.cc
M sql/sql_select.cc
M sql/sql_servers.cc
M sql/sql_show.cc
M sql/sql_string.cc
M sql/sql_string.h
M sql/sql_trigger.cc
M sql/sql_udf.cc
M sql/sql_update.cc
M sql/sql_yacc.yy
M sql/table.cc
M sql/table.h
M sql/tztime.cc
M storage/ndb/include/kernel/signaldata/DictTabInfo.hpp
M strings/ctype-bin.c
M strings/ctype-latin1.c
M strings/ctype-mb.c
M strings/ctype-simple.c
M vio/vio.c
M vio/vio_priv.h
M vio/viosocket.c
2944.1.3 Konstantin Osipov 2009-11-20 [merge]
Merge with next-mr
A mysql-test/r/partition_sync.result
A mysql-test/r/rpl_mysqldump_slave.result
A mysql-test/t/partition_sync.test
A mysql-test/t/rpl_mysqldump_slave.test
M client/client_priv.h
M client/mysql.cc
M client/mysqladmin.cc
M client/mysqlcheck.c
M client/mysqldump.c
M client/mysqltest.cc
M client/sql_string.cc
M client/sql_string.h
M config/ac-macros/misc.m4
M include/m_string.h
M include/mysql_com.h
M include/violite.h
M libmysql/libmysql.c
M libmysqld/lib_sql.cc
M mysql-test/r/alias.result
M mysql-test/r/delete.result
M mysql-test/r/derived.result
M mysql-test/r/dirty_close.result
M mysql-test/r/func_sapdb.result
M mysql-test/r/func_time.result
M mysql-test/r/mysql.result
M mysql-test/r/sp-error.result
M mysql-test/r/sp.result
M mysql-test/r/trigger.result
M mysql-test/r/type_time.result
M mysql-test/suite/rpl/r/rpl_multi_delete2.result
M mysql-test/suite/rpl/t/rpl_multi_delete2.test
M mysql-test/suite/sys_vars/r/group_concat_max_len_func.result
M mysql-test/t/alias.test
M mysql-test/t/delete.test
M mysql-test/t/derived.test
M mysql-test/t/dirty_close.test
M mysql-test/t/func_sapdb.test
M mysql-test/t/func_time.test
M mysql-test/t/lock_multi.test
M mysql-test/t/mysql.test
M mysql-test/t/shm.test
M mysql-test/t/sp-error.test
M mysql-test/t/sp.test
M mysql-test/t/trigger.test
M mysql-test/t/type_time.test
M mysys/my_alloc.c
M mysys/my_getopt.c
M sql/event_data_objects.cc
M sql/field.cc
M sql/field.h
M sql/ha_partition.cc
M sql/item_cmpfunc.cc
M sql/item_func.cc
M sql/item_subselect.cc
M sql/item_timefunc.cc
M sql/mysql_priv.h
M sql/opt_sum.cc
M sql/share/errmsg.txt
M sql/sp.cc
M sql/sp_head.cc
M sql/sql_cache.cc
M sql/sql_class.h
M sql/sql_insert.cc
M sql/sql_list.h
M sql/sql_parse.cc
M sql/sql_partition.cc
M sql/sql_select.cc
M sql/sql_servers.cc
M sql/sql_show.cc
M sql/sql_string.cc
M sql/sql_string.h
M sql/sql_trigger.cc
M sql/sql_update.cc
M sql/sql_yacc.yy
M sql/table.h
M sql/tztime.cc
M storage/ndb/include/kernel/signaldata/DictTabInfo.hpp
M strings/ctype-bin.c
M strings/ctype-latin1.c
M strings/ctype-mb.c
M strings/ctype-simple.c
M vio/vio.c
M vio/vio_priv.h
M vio/viosocket.c
2876.23.15 Davi Arnaut 2009-11-19 [merge]
Manual merge of mysql-next-mr-runtime upstream.
A mysql-test/r/partition_sync.result
A mysql-test/r/rpl_mysqldump_slave.result
A mysql-test/t/partition_sync.test
A mysql-test/t/rpl_mysqldump_slave.test
M client/client_priv.h
M client/mysql.cc
M client/mysqladmin.cc
M client/mysqlcheck.c
M client/mysqldump.c
M client/mysqltest.cc
M client/sql_string.cc
M client/sql_string.h
M config/ac-macros/misc.m4
M include/m_string.h
M include/mysql_com.h
M include/violite.h
M libmysql/libmysql.c
M libmysqld/lib_sql.cc
M mysql-test/r/alias.result
M mysql-test/r/delete.result
M mysql-test/r/derived.result
M mysql-test/r/dirty_close.result
M mysql-test/r/func_sapdb.result
M mysql-test/r/func_time.result
M mysql-test/r/mysql.result
M mysql-test/r/sp-error.result
M mysql-test/r/sp.result
M mysql-test/r/trigger.result
M mysql-test/r/type_time.result
M mysql-test/suite/rpl/r/rpl_multi_delete2.result
M mysql-test/suite/rpl/t/rpl_multi_delete2.test
M mysql-test/suite/sys_vars/r/group_concat_max_len_func.result
M mysql-test/t/alias.test
M mysql-test/t/delete.test
M mysql-test/t/derived.test
M mysql-test/t/dirty_close.test
M mysql-test/t/func_sapdb.test
M mysql-test/t/func_time.test
M mysql-test/t/lock_multi.test
M mysql-test/t/mysql.test
M mysql-test/t/shm.test
M mysql-test/t/sp-error.test
M mysql-test/t/sp.test
M mysql-test/t/trigger.test
M mysql-test/t/type_time.test
M mysys/my_alloc.c
M mysys/my_getopt.c
M sql/event_data_objects.cc
M sql/field.cc
M sql/field.h
M sql/ha_partition.cc
M sql/item_cmpfunc.cc
M sql/item_func.cc
M sql/item_subselect.cc
M sql/item_timefunc.cc
M sql/mysql_priv.h
M sql/opt_sum.cc
M sql/share/errmsg.txt
M sql/sp.cc
M sql/sp_head.cc
M sql/sql_cache.cc
M sql/sql_class.h
M sql/sql_insert.cc
M sql/sql_list.h
M sql/sql_parse.cc
M sql/sql_partition.cc
M sql/sql_select.cc
M sql/sql_servers.cc
M sql/sql_show.cc
M sql/sql_string.cc
M sql/sql_string.h
M sql/sql_trigger.cc
M sql/sql_update.cc
M sql/sql_yacc.yy
M sql/table.h
M sql/tztime.cc
M storage/ndb/include/kernel/signaldata/DictTabInfo.hpp
M strings/ctype-bin.c
M strings/ctype-latin1.c
M strings/ctype-mb.c
M strings/ctype-simple.c
M vio/vio.c
M vio/vio_priv.h
M vio/viosocket.c
2876.27.30 Davi Arnaut 2009-11-13
Post-merge fixes for backports.
@ mysql-test/r/sp-error.result
Update test case result.
@ mysql-test/t/dirty_close.test
Dirty close does not work under embedded.
@ mysql-test/t/sp-error.test
Use the specific error number so it won't catch
other non-fatal errors.
M mysql-test/r/sp-error.result
M mysql-test/t/dirty_close.test
M mysql-test/t/sp-error.test
2876.27.29 Magne Mahre 2009-11-11
Bug#40700: aclocal warnings for missing cache-id's
Just change mysql_foo to mysql_cv_foo for one cache-id variable name. There
was only one bad variable name, present in 5.0 and 5.1, but not in the -pe
branch.
Backported to 5.6.0 (mysql-next-mr-runtime)
M config/ac-macros/misc.m4
2876.27.28 Magne Mahre 2009-11-11 [merge]
Bug #33544 UDF_INIT member decimals initialized wrong with
STRING_RESULT argument
There is a "magic" number for precision : NOT_FIXED_DEC.
This means that the precision is not a fixed number.
But this constant was re-defined in several files and
was not available to the UDF developers.
Moved the NOT_FIXED_DEC definition to the correct header
and removed the redundant definitions.
Backported to 5.6.0 (mysql-next-mr-runtime)
@ client/sql_string.h
moved NOT_FIXED_DEC to the correct header
@ include/mysql_com.h
moved NOT_FIXED_DEC to the correct header
@ libmysql/libmysql.c
moved NOT_FIXED_DEC to the correct header
@ sql/field.h
moved NOT_FIXED_DEC to the correct header
@ sql/sql_string.h
moved NOT_FIXED_DEC to the correct header
@ storage/ndb/include/kernel/signaldata/DictTabInfo.hpp
moved NOT_FIXED_DEC to the correct header
M client/sql_string.cc
M client/sql_string.h
M include/mysql_com.h
M libmysql/libmysql.c
M sql/field.h
M sql/sql_string.cc
M sql/sql_string.h
M storage/ndb/include/kernel/signaldata/DictTabInfo.hpp
2512.71.1 gkodinov/ 2008-03-05
Bug #33544: UDF_INIT member decimals initialized wrong with
STRING_RESULT argument
There is a "magic" number for precision : NOT_FIXED_DEC.
This means that the precision is not a fixed number.
But this constant was re-defined in several files and
was not available to the UDF developers.
Moved the NOT_FIXED_DEC definition to the correct header
and removed the redundant definitions.
@ client/sql_string.cc
Bug #33544: moved NOT_FIXED_DEC to the correct header
@ client/sql_string.h
Bug #33544: moved NOT_FIXED_DEC to the correct header
@ include/mysql_com.h
Bug #33544: moved NOT_FIXED_DEC to the correct header
@ libmysql/libmysql.c
Bug #33544: moved NOT_FIXED_DEC to the correct header
@ sql/field.h
Bug #33544: moved NOT_FIXED_DEC to the correct header
@ sql/sql_string.cc
Bug #33544: moved NOT_FIXED_DEC to the correct header
@ sql/sql_string.h
Bug #33544: moved NOT_FIXED_DEC to the correct header
@ storage/ndb/include/kernel/signaldata/DictTabInfo.hpp
Bug #33544: moved NOT_FIXED_DEC to the correct header
M client/sql_string.cc
M client/sql_string.h
M include/mysql_com.h
M libmysql/libmysql.c
M sql/field.h
M sql/sql_string.cc
M sql/sql_string.h
M storage/ndb/include/kernel/signaldata/DictTabInfo.hpp
2876.27.27 Magne Mahre 2009-11-11
Bug #37097 mysqltest add result file format version 2
Add result file format v2
Backport to 5.6.0
M client/mysqltest.cc
2876.27.26 Magne Mahre 2009-11-11
Fix of incorrect casting for large sizes
M include/m_string.h
2876.27.25 Magne Mahre 2009-11-11
Return type fix (strlen returns size_t)
M client/mysqladmin.cc
2876.27.24 Magne Mahre 2009-11-11
Bug #5724 'mysqladmin password' should be allowed to prompt for password
Add support for being prompted for new passwords by mysqladmin instead of
specifying them on the command line. (Bug #5724, patch by Harrison Fisk)
M client/mysqladmin.cc
2876.27.23 Magne Mahre 2009-11-11
Bug #14637: trim trailing spaces processes data only byte wise
(From: gkodinov)
Use and int * where possible to scan for trailing space in a
string instead of always iterating char-by-char.
Using the attached benchmark file on a 32 bit Intel Core 2
Duo CPU I've got 43485 ms run with the fix compared to 44373
without it.
Backported to 5.6.0 (next-mr-runtime)
6.0-codebase revid: 2476.1362.1
@ include/m_string.h
scan for space through ints
@ strings/ctype-bin.c
scan for space through ints
@ strings/ctype-latin1.c
scan for space through ints
@ strings/ctype-mb.c
scan for space through ints
@ strings/ctype-simple.c
scan for space through ints
M include/m_string.h
M strings/ctype-bin.c
M strings/ctype-latin1.c
M strings/ctype-mb.c
M strings/ctype-simple.c
2876.27.22 Davi Arnaut 2009-11-10
The FIONREAD macro could expand to a expression which
is invalid to preporcessor conditionals. Instead use
the autoconf generated macro to test the presence.
M vio/viosocket.c
2876.27.21 Davi Arnaut 2009-11-10
Backport of Bug#45767 to mysql-next-mr
------------------------------------------------------------
revno: 3405
revision-id: davi.arnaut@strippedo5193j4cu7
parent: luis.soares@strippedm-20090626113019-1j4mn1jos480u9f3
committer: Davi Arnaut <Davi.Arnaut@stripped>
branch nick: mysql-pe
timestamp: Fri 2009-06-26 09:46:24 -0300
message:
Bug#45767: deprecate/remove Field::pack_key, Field::unpack_key, Field::pack_cmp
Remove unused and dead code.
Parts of the patch contributed by Zardosht Kasheff
M sql/field.cc
M sql/field.h
M sql/sql_parse.cc
M sql/sql_string.cc
2876.27.20 Davi Arnaut 2009-11-10
Backport of Bug#27249 to mysql-next-mr
------------------------------------------------------------
revno: 2476.784.4
revision-id: sp1r-davi@stripped751-46069
parent: sp1r-davi@strippedcal-20071003002731-48537
committer: davi@stripped
timestamp: Mon 2007-10-08 08:47:51 -0300
message:
Bug#27249 table_wild with alias: select t1.* as something
Aliases to table wildcards are silently ignored, but they should
not be allowed as it is non-standard and currently useless. There
is not point in having a alias to a wildcard of column names.
The solution is to rewrite the select_item rule so that aliases
for table wildcards are not accepted.
Contribution by Martin Friebe
@ mysql-test/r/alias.result
Add test case result for Bug#27249
@ mysql-test/t/alias.test
Add test case for Bug#27249
@ sql/sql_yacc.yy
Split up select_item rule so that aliases for table wildcards
are not accepted by the parser.
M mysql-test/r/alias.result
M mysql-test/t/alias.test
M sql/sql_yacc.yy
2876.27.19 Davi Arnaut 2009-11-10
Backport of Bug#15192 to mysql-next-mr
------------------------------------------------------------
revno: 2597.4.17
revision-id: sp1r-davi@stripped/endora.local-20080328174753-24337
parent: sp1r-anozdrin/alik@stripped
committer: davi@stripped/endora.local
timestamp: Fri 2008-03-28 14:47:53 -0300
message:
Bug#15192 "fatal errors" are caught by handlers in stored procedures
The problem is that fatal errors (e.g.: out of memory) were being
caught by stored procedure exception handlers which could cause
the execution to not be stopped due to a continue handler.
The solution is to not call any exception handler if the error is
fatal and send the fatal error to the client.
@ mysql-test/r/sp-error.result
Add test case result for Bug#15192
@ mysql-test/t/sp-error.test
Add test case for Bug#15192
@ mysys/my_alloc.c
Pass flag to signal fatal error in memory root allocations.
@ sql/event_data_objects.cc
Use init_sql_alloc to initialize memory roots, which uses
the sql error handler to push errors.
@ sql/ha_partition.cc
Pass flag to signal fatal error instead of calling fatal_error.
@ sql/item_func.cc
Pass flag to signal fatal error instead of calling fatal_error.
@ sql/item_subselect.cc
Remove redundant fatal error, memory root already pushes error.
@ sql/opt_sum.cc
Pass flag to signal fatal error instead of calling fatal_error.
@ sql/sp_head.cc
Allocator already sets fatal error.
@ sql/sql_class.h
A error must exist for it to be fatal. Pass flag to signal fatal
error instead of calling fatal_error.
@ sql/sql_insert.cc
Pass flag to signal fatal error instead of calling fatal_error.
@ sql/sql_list.h
Pass flag to signal fatal error instead of calling fatal_error.
@ sql/sql_parse.cc
Pass flag to signal fatal error instead of calling fatal_error.
@ sql/sql_partition.cc
Pass flag to signal fatal error instead of calling fatal_error.
@ sql/sql_select.cc
Pass flag to signal fatal error instead of calling fatal_error.
@ sql/sql_servers.cc
Use init_sql_alloc to initialize memory roots, which uses
the sql error handler to push errors.
@ sql/sql_show.cc
Pass flag to signal fatal error instead of calling fatal_error.
@ sql/sql_trigger.cc
Use init_sql_alloc to initialize memory roots, which uses
the sql error handler to push errors.
@ sql/sql_update.cc
Pass flag to signal fatal error instead of calling fatal_error.
@ sql/tztime.cc
Use init_sql_alloc to initialize memory roots, which uses
the sql error handler to push errors.
M mysql-test/r/sp-error.result
M mysql-test/t/sp-error.test
M mysys/my_alloc.c
M sql/event_data_objects.cc
M sql/ha_partition.cc
M sql/item_func.cc
M sql/item_subselect.cc
M sql/opt_sum.cc
M sql/sp_head.cc
M sql/sql_class.h
M sql/sql_insert.cc
M sql/sql_list.h
M sql/sql_parse.cc
M sql/sql_partition.cc
M sql/sql_select.cc
M sql/sql_servers.cc
M sql/sql_show.cc
M sql/sql_trigger.cc
M sql/sql_update.cc
M sql/tztime.cc
2876.27.18 Davi Arnaut 2009-11-10
Backport of Bug#41860 to mysql-next-mr
------------------------------------------------------------
revno: 3317
revision-id: davi.arnaut@stripped
parent: patrick.crews@stripped933-ole8s3suy4zqyvku
committer: Davi Arnaut <Davi.Arnaut@stripped>
branch nick: 41860-6.0
timestamp: Fri 2009-05-22 14:09:16 -0300
message:
Bug#41860: Without Windows named pipe
The problem was that the patch for Bug#10374 broke named pipe
and shared memory transports on Windows due to a failure to
implement a dummy poll method for transports other than BSD
sockets. Another problem was that mysqltest lacked support
for named pipe and shared memory connections, which lead to
misleading test cases that were supposed run common queries
over both transports.
The solution is to properly implement, at the VIO layer, the
poll and is_connected methods. The is_connected method is
implemented for every suppported transport and the poll one
only where it makes sense. Furthermore, support for named pipe
and shared memory connections is added to mysqltest as to
enable testing of both transports using the test suite.
@ client/mysqltest.cc
Add support for named pipe and shared memory connections.
@ include/violite.h
Move private functions to vio/vio_priv.h
Add poll_read and is_connected methods.
@ mysql-test/t/named_pipe.test
Run tests over a named pipe connection.
@ mysql-test/t/shm.test
Run tests over a shared memory connection.
@ sql/item_func.cc
Rename method.
@ sql/sql_class.cc
Remove higher-level vio_is_connected implementation.
@ sql/sql_class.h
Rename vio_is_connected to not conflict with the vio one.
Verify that there is a valid vio.
@ vio/vio.c
Add poll_read and is_connected methods.
@ vio/vio_priv.h
Add private functions.
@ vio/viosocket.c
Implement the is_connected method for the various transports.
M client/mysqltest.cc
M include/violite.h
M mysql-test/t/named_pipe.test
M mysql-test/t/shm.test
M sql/item_func.cc
M sql/sql_class.cc
M sql/sql_class.h
M vio/vio.c
M vio/vio_priv.h
M vio/viosocket.c
2876.27.17 Davi Arnaut 2009-11-10
Backport of Bug#10374 to mysql-next-mr
------------------------------------------------------------
revno: 2597.37.3
revision-id: sp1r-davi@stripped/endora.local-20080328123626-16430
parent: sp1r-anozdrin/alik@stripped7125300-11290
committer: davi@strippedom/endora.local
timestamp: Fri 2008-03-28 09:36:26 -0300
message:
Bug#10374 GET_LOCK does not let connection to close on the server side if it's aborted
The problem is that the server doesn't detect aborted connections which
are waiting on a lock or sleeping (user sleep), wasting system resources
for a connection that is already dead.
The solution is to peek at the connection every five seconds to verify if
the connection is not aborted. A aborted connection is detect by polling
the connection socket for available data to be read or end of file and in
case of eof, the wait is aborted and the connection killed.
@ include/violite.h
Export vio_peek_read function.
@ mysql-test/r/dirty_close.result
Add test case result for Bug#10374
@ mysql-test/t/dirty_close.test
Add test case for Bug#10374
@ sql/item_func.cc
While waiting for a condition to be signaled, check if the connection
is not broken every INTERRUPT_INTERVAL seconds.
@ sql/sql_class.cc
Add function which checks if the client connection was aborted.
@ sql/sql_class.h
Add function prototype.
@ vio/viosocket.c
Add poll and peek functions for Windows and Unix.
M include/violite.h
M mysql-test/r/dirty_close.result
M mysql-test/t/dirty_close.test
M sql/item_func.cc
M sql/sql_class.cc
M sql/sql_class.h
M vio/viosocket.c
2876.27.16 Davi Arnaut 2009-11-10
Backport of Bug#27525 to mysql-next-mr
------------------------------------------------------------
revno: 2572.2.1
revision-id: sp1r-davi@stripped/endora.local-20080227225948-16317
parent: sp1r-anozdrin/alik@stripped6165712-10409
committer: davi@strippedom/endora.local
timestamp: Wed 2008-02-27 19:59:48 -0300
message:
Bug#27525 table not found when using multi-table-deletes with aliases over several databas
Bug#30234 Unexpected behavior using DELETE with AS and USING
The multi-delete statement has a documented limitation that
cross-database multiple-table deletes using aliases are not
supported because it fails to find the tables by alias if it
belongs to a different database. The problem is that when
building the list of tables to delete from, if a database
name is not specified (maybe an alias) it defaults to the
name of the current selected database, making impossible to
to properly resolve tables by alias later. Another problem
is a inconsistency of the multiple table delete syntax that
permits ambiguities in a delete statement (aliases that refer
to multiple different tables or vice-versa).
The first step for a solution and proper implementation of
the cross-databse multiple table delete is to get rid of any
ambiguities in a multiple table statement. Currently, the parser
is accepting multiple table delete statements that have no obvious
meaning, such as:
DELETE a1 FROM db1.t1 AS a1, db2.t2 AS a1;
DELETE a1 AS a1 FROM db1.t1 AS a1, db2.t2 AS a1;
The solution is to resolve the left part of a delete statement
using the right part, if the a table on right has an alias,
it must be referenced in the left using the given alias. Also,
each table on the left side must match unambiguously only one
table in the right side.
@ mysql-test/r/delete.result
Add test case result for Bug#27525 and Bug#21148
@ mysql-test/r/derived.result
Update error.
@ mysql-test/suite/rpl/r/rpl_multi_delete2.result
Update syntax.
@ mysql-test/suite/rpl/t/rpl_multi_delete2.test
Update syntax.
@ mysql-test/t/delete.test
Add test case for Bug#27525 and Bug#21148
@ mysql-test/t/derived.test
Update statement error, alias is properly resolved now.
@ sql/sql_parse.cc
Implement new algorithm for the resolution of alias in
a multiple table delete statement.
@ sql/sql_yacc.yy
Rework multi-delete parser rules to not accept table alias
for the table source list.
@ sql/table.h
Add flag to signal that the table has a alias set or
that fully qualified table name was given.
M mysql-test/r/delete.result
M mysql-test/r/derived.result
M mysql-test/suite/rpl/r/rpl_multi_delete2.result
M mysql-test/suite/rpl/t/rpl_multi_delete2.test
M mysql-test/t/delete.test
M mysql-test/t/derived.test
M sql/sql_parse.cc
M sql/sql_yacc.yy
M sql/table.h
2876.27.15 Davi Arnaut 2009-11-10
Backport of Bug#37843 to mysql-next-mr
@ sql/sql_cache.cc
Swap return value description.
M sql/sql_cache.cc
2876.27.14 Davi Arnaut 2009-11-10
Backport of Bug#36785 to mysql-next-mr
------------------------------------------------------------
revno: 2630.2.13
revision-id: davi@stripped
parent: davi@strippedrxfdga9upho
committer: Davi Arnaut <davi@stripped>
branch nick: 36785-6.0
timestamp: Thu 2008-06-12 16:04:52 -0300
message:
Bug#36785: Wrong error message when group_concat() exceeds max length
The problem is that when ER_CUT_VALUE_GROUP_CONCAT is elevated
to a error, the message does not get updated with the number of
cut lines when group_concat() exceeds max length.
The solution is to modify the warning message to be more meaningful
by giving the number of the line that was cut and to issue the warning
for each line that is cut. This approach is inline with how other
per-row truncated data warnings are issued avoids violating the warning
internal interface.
@ mysql-test/suite/sys_vars/r/group_concat_max_len_func.result
Update result to reflect the new warning message
@ sql/share/errmsg.txt
Update warning message ER_CUT_VALUE_GROUP_CONCAT.
M mysql-test/suite/sys_vars/r/group_concat_max_len_func.result
M sql/share/errmsg.txt
2876.27.13 Davi Arnaut 2009-11-10
Backport of Bug#32140 to mysql-next-mr
------------------------------------------------------------
revno: 2618
revision-id: sp1r-davi@stripped/endora.local-20080418131946-26951
parent: sp1r-davi@stripped/endora.local-20080417190810-26185
committer: davi@mysql.com/endora.local
timestamp: Fri 2008-04-18 10:19:46 -0300
message:
Bug#32140: wrong error code caught when an SF() call is interruped with KILL query
The problem is that killing a query which calls a stored function
could return a wrong error (table corrupt) instead of the query
interrupted error message.
The solution is to not set the table corrupt error if the query
is killed, the query interrupted error message will be set later
when the query is finished.
@ sql/sp.cc
Don't set a error if the thread was killed, the query
interrupted error will be set later.
M sql/sp.cc
2876.27.12 Davi Arnaut 2009-11-10
Backport of Bug#36649 to mysql-next-mr
------------------------------------------------------------
revno: 2630.39.3
revision-id: davi.arnaut@stripped
parent: kostja@stripped71ht
committer: Davi Arnaut <Davi.Arnaut@stripped>
branch nick: 36649-6.0
timestamp: Wed 2008-12-10 19:53:59 -0200
message:
Bug#36649: Condition area is not properly cleaned up after stored routine invocation
The problem is that the diagnostics area of a trigger is not
isolated from the area of the statement that caused the trigger
invocation. In MySQL terms, it means that warnings generated
during the execution of the trigger are not removed from the
"warning area" at the end of the execution.
Before this fix, the rules for MySQL message list life cycle (see
manual entry for SHOW WARNINGS) did not apply to statements
inside stored programs:
- The manual says that the list of messages is cleared by a
statement that uses a table (any table). However, such
statement, if run inside a stored program did not clear the
message list.
- The manual says that the list is cleared by a statement that
generates a new error or a warning, but this was not the case
with stored program statements either and is changed to be the
case as well.
In other words, after this fix, a statement has the same effect
on the message list regardless of whether it's executed inside a
stored program/sub-statement or not.
This introduces an incompatible change:
- before this fix, a, e.g. statement inside a trigger could
never clear the global warning list
- after this fix, a trigger that generates a warning or uses a
table, clears the global warning list
- however, when we leave a trigger or a function, the caller's
warning information is restored (see more on this below).
This change is not backward compatible as it is intended to make
MySQL behavior similar to the SQL standard behavior:
A stored function or trigger will get its own "warning area" (or,
in standard terminology, diagnostics area). At the beginning of
the stored function or trigger, all messages from the caller area
will be copied to the area of the trigger. During execution, the
message list will be cleared according to the MySQL rules
described on the manual (SHOW WARNINGS entry). At the end of the
function/trigger, the "warning area" will be destroyed along with
all warnings it contains, except that if the last statement of
the function/trigger generated messages, these are copied into
the "warning area" of the caller.
Consequently, statements that use a table or generate a warning
*will* clear warnings inside the trigger, but that will have no
effect to the warning list of the calling (outer) statement.
@ mysql-test/r/sp.result
Fix test case results.
@ mysql-test/r/trigger.result
Fix test case results.
@ mysql-test/t/sp.test
Add test case for Bug#36649
@ mysql-test/t/trigger.test
Add test case for Bug#36649
@ sql/sp_head.cc
Emulate multiple warning areas -- one per stored program instance.
@ sql/sql_parse.cc
Message list reset rules are the same for statements inside
or outside compound statements.
M mysql-test/r/sp.result
M mysql-test/r/trigger.result
M mysql-test/t/sp.test
M mysql-test/t/trigger.test
M sql/sp_head.cc
M sql/sql_parse.cc
2876.27.11 Kristofer Pettersson 2009-11-10 [merge]
automerge
M libmysqld/lib_sql.cc
M mysql-test/t/lock_multi.test
M sql/sql_show.cc
2876.28.2 Davi Arnaut 2009-11-10
Backport of Bug#47304 to mysql-next-mr
------------------------------------------------------------
revno: 3624
revision-id: jon.hauglid@stripped
parent: alik@stripped1q7oe
committer: Jon Olav Hauglid <jon.hauglid@stripped>
branch nick: mysql-6.0-codebase-bugfixing-bug47304
timestamp: Mon 2009-09-28 18:34:26 +0200
message:
Bug #47304 Test main.mdl_sync fails on embedded server
The problem was that SHOW PROCESSLIST was trying to access
a thread that was not properly running and therefore had an
uninitialized mutex.
This patch explicitly resets thd->mysys_var after each embedded
server command to prevent the mutex from being accessed in an
illegal state.
The patch also re-enables lock_multi.test and mdl_sync.test for
embedded server as they had been disabled because of this bug.
M libmysqld/lib_sql.cc
M mysql-test/t/lock_multi.test
2876.28.1 Davi Arnaut 2009-11-10
Backport of Bug#41971 to mysql-next-mr
------------------------------------------------------------
revno: 2617.31.21
revision-id: davi.arnaut@stripped2zbhg15kd0z3xh8r
parent: alik@sun.com-20090402081500-78l1hpkx03twe4bf
committer: Davi Arnaut <Davi.Arnaut@stripped>
branch nick: 41971-6.0
timestamp: Thu 2009-04-02 16:39:33 -0300
message:
Bug#41971: Thread state on embedded server is always "Writing to net"
The problem is that the state of a thread on a embedded server is
always displayed as "Writing to net", which is wrong as there is
no "network" in the embedded server.
The solution is only exclude, on a embedded server, the thread
state conditions that are related to network operations. Other
thread states related to waiting on conditions or other operations
are preserved.
@ sql/sql_show.cc
Unroll conditionals into a function. Skip check for network
operations on the embedded library. Change use of thread_info::
command to retrieve the command directly from the thread
handle -- they have the same value.
M sql/sql_show.cc
2876.27.10 Kristofer Pettersson 2009-11-10
Bug#27145 EXTRA_ACL troubles
Correction of backport patch:
* Fixed signature of check_access_table() for embedded build
* Fixed typo for last argument in a check_access() call from UINT_MAX to 0.
M sql/mysql_priv.h
M sql/sql_parse.cc
2876.27.9 Magne Mahre 2009-11-05
Fix compile error on HP/UX.
SIGWINCH is not defined in termios.h on HP/UX.
M client/mysql.cc
2876.27.8 Magne Mahre 2009-11-04
BUG #8368 "mysqldump needs --slave-data option"
Added this option, named as "--dump-slave". The purpose of this option is to be
able to produce a dump from a slave used for making backups of the master. Originally,
dumping from the main master was fine, but as more data accumulated, the dump process
would take over 30 minutes, locking up the master database hence website for 30 minutes.
A slave dedicated to producing backups was the answer, but I needed a dump that could be
used to restore a slave instantly and in order to do that, it has to have three things
contained in the dump:
1. "STOP SLAVE;" at the beginning
2. "CHANGE MASTER TO ...<the master - info from 'show slave status'>"
3. "START SLAVE;" at the end
These options in this changeset contain this.
--stop-slave adds "STOP SLAVE" to the beginning of the dump and "STOP SLAVE"
to the end of the dump.
--include-host gives the user the option to have the host explicitely added
to the "CHANGE MASTER TO ..." line.
--dump-slave adds the "CHANGE MASTER ..." to the dump representing not the slave's
master binlog info, but the slave's master's info from "SHOW SLAVE STATUS"
@ client/client_priv.h
Added OPT_SLAVE_DATA to client_priv.h
@ client/mysqldump.c
* Added --dump-slave option (name per Brian)
* Added --stop-slave to print "STOP SLAVE;" into the dump
* Added --include-host option to include "MASTER_HOST=..." and "MASTER_PORT=..."
to the dump since unlike --master-data, the host can't be assumed to be
the local host
* Added do_start_slave and do_stop_slave to stop the slave sql thread upon
start of the dump process, and to start the slave sql upon finish of dump process -
to keep the log information frozen during this time.
* Added do_show_slave_status for obtaining slave information needed to compose
"CHANGE MASTER ..." output to the master of this slave.
* Added necessary long options and defines required for new options
A mysql-test/r/rpl_mysqldump_slave.result
A mysql-test/t/rpl_mysqldump_slave.test
M client/client_priv.h
M client/mysqldump.c
2876.27.7 Magne Mahre 2009-11-04
Bug#26780: automatic vertical output for wide results
Feature from Eric Bergen, CLA signed 2007-06-27.
Adds new mysql client option "--auto-vertical-output", which causes
the client to test whether a result table is too wide for the current
window (where available) and emit vertical results in that case.
Otherwise, it sends normal tabular results.
@ client/client_priv.h
Add another enum value to client options, for automatic vertical output.
@ client/mysql.cc
Add another command-line option, "auto-vertical-output".
Add functions to get the terminal width and functions to get the widths of fields.
Use them together to emit vertical output when some output table is too wide to
fit in the terminal. If the terminal doesn't support reading its width, then assume
80-positions wide.
@ mysql-test/r/mysql.result
Show that various select statements do work as expected. Wide tables become vertical
and narrow ones do not.
@ mysql-test/t/mysql.test
Show that various select statements do work as expected.
These should be suitable for a wide range of window capabilities and sizes. Under
extreme circumstances, the results could be arbitrary.
M client/client_priv.h
M client/mysql.cc
M mysql-test/r/mysql.result
M mysql-test/t/mysql.test
2876.27.6 Jon Olav Hauglid 2009-11-04
Bug #43867 ALTER TABLE on a partitioned table causes unnecessary
deadlocks
Backport of revno: 2617.68.35
The problem was that if one connection is running a multi-statement
transaction which involves a single partitioned table, and another
connection attempts to alter the table to drop a non-existing partition,
(which of course will fail), the first connection still gets
ER_LOCK_DEADLOCK and cannot proceed anymore.
This bug is no longer reproducable. This has also been tested with the
patch for Bug#46654 "False deadlock on concurrent DML/DDL with partitions,
inconsistent behavior" which concerned a similar problem but where the
ALTER TABLE is semantically correct.
Test case added in partition_sync.test.
A mysql-test/r/partition_sync.result
A mysql-test/t/partition_sync.test
2876.27.5 Magne Mahre 2009-11-04
Bug#42664: Sign ignored for TIME types when not comparing as longlong
Another code-path dropped sign of TIME, presuming all time is positive.
Minds sign now. Patch depends on ChangeSet for 42661.
@ mysql-test/r/type_time.result
Show we now no longer ignore sign of TIME-type
in this code-path.
@ mysql-test/t/type_time.test
Show we now no longer ignore sign of TIME-type
in this code-path.
@ sql/item_cmpfunc.cc
TIME_to_ulonglong() (somewhat obviously) loses sign
of its argument, so we put it back in where needed.
M mysql-test/r/type_time.result
M mysql-test/t/type_time.test
M sql/item_cmpfunc.cc
2876.27.4 Magne Mahre 2009-11-04 [merge]
Backport to 5.6.0
M mysql-test/r/func_sapdb.result
M mysql-test/t/func_sapdb.test
1810.3966.1 Tatiana A. Nurnberg 2009-04-14 [merge]
Bug#42662: maketime() and signedness
merge and additional clarifications
@ mysql-test/r/func_sapdb.result
Update test for 42661/42662 to use both TIME(...) and CAST(... AS TIME).
They go through the same code-path here, but may not in the future, and
besides, it's clearer this way.
@ mysql-test/t/func_sapdb.test
Update test for 42661/42662 to use both TIME(...) and CAST(... AS TIME).
They go through the same code-path here, but may not in the future, and
besides, it's clearer this way.
@ sql/item_timefunc.cc
- fix SEC_TO_TIME(...) for signed values
- fix TIME(...) and CAST(... AS TIME) for signed values
M mysql-test/r/func_sapdb.result
M mysql-test/t/func_sapdb.test
M sql/item_timefunc.cc
2876.27.3 Magne Mahre 2009-11-04 [merge]
Bug#42661: sec_to_time() and signedness
Bug#42662: maketime() and signedness
Item_time_typecast::val_int() dropped sign from
MYSQL_TIME gotten using from get_time().
Propagates sign now.
Backported to 5.5.0 (6.0-codebase revid: 1810.3897.1)
M mysql-test/r/func_sapdb.result
M mysql-test/t/func_sapdb.test
M sql/item_timefunc.cc
1810.3965.1 Tatiana A. Nurnberg 2009-02-09
Bug#42661: sec_to_time() and signedness
Bug#42662: maketime() and signedness
Item_time_typecast::val_int() dropped sign from
MYSQL_TIME gotten using from get_time().
Propagates sign now.
@ mysql-test/r/func_sapdb.result
Show that comparisons with TIME(-...) work now.
@ mysql-test/t/func_sapdb.test
Show that comparisons with TIME(-...) work now.
@ sql/item_timefunc.cc
don't drop sign when converting from MYSQL_TIME
M mysql-test/r/func_sapdb.result
M mysql-test/t/func_sapdb.test
M sql/item_timefunc.cc
2876.27.2 Magne Mahre 2009-11-03
Bug #36466: Adding days to day_microsecond changes interpretation of microseco
When less than six places are given for microseconds, we zerofill from
the right (leftmost place is always 1/10s). We only did this when all
announced date/time fields were given; now we also format fractional
seconds when more significant fields are left out.
@ mysql-test/r/func_time.result
show that we treat fractions of seconds correctly (zerofill from
right to six places) even if we left out fields on the left
@ mysql-test/t/func_time.test
show that we treat fractions of seconds correctly (zerofill from
right to six places) even if we left out fields on the left
@ sql/item_timefunc.cc
format fractions of seconds even if announced
more significant fields were left out
M mysql-test/r/func_time.result
M mysql-test/t/func_time.test
M sql/item_timefunc.cc
2876.27.1 Magne Mahre 2009-11-03
Bug#35224: mysqldump --help is very confusing
The presence of "--skip" parameters is obscure, when it should be
obvious from the text.
Now, for boolean options, when they're default to ON and the --skip
is more useful parameter, then tell the user of its existence.
Backported from 6.0-codebase, revid 2572.14.1
M client/mysqlcheck.c
M client/mysqldump.c
M mysys/my_getopt.c
2944.1.2 Martin Hansson 2009-11-20 [merge]
merge of Bug#33204 (backport)
D dbug/.cvsignore
D dbug/doinstall.sh
D dbug/install.sh
D dbug/mklintlib.sh
D dbug/qmake.cmd
D dbug/vargs.h
D libmysql/manager.c
D mysql-test/r/locale.result
D mysql-test/t/locale.test
A dbug/remove_function_from_trace.pl
A dbug/tests-t.pl
A dbug/tests.c
A include/mysql/service_my_snprintf.h
A include/mysql/service_thd_alloc.h
A include/mysql/services.h
A include/service_versions.h
A libservices/
A libservices/CMakeLists.txt
A libservices/HOWTO
A libservices/Makefile.am
A libservices/my_snprintf_service.c
A libservices/thd_alloc_service.c
A mysql-test/include/bug38347.inc
A mysql-test/include/have_case_insensitive_fs.inc
A mysql-test/r/case_insensitive_fs.require
A mysql-test/r/drop_debug.result
A mysql-test/r/grant4.result
A mysql-test/r/grant_lowercase_fs.result
A mysql-test/r/innodb_bug47777.result
A mysql-test/r/locale.result
A mysql-test/r/log_state_bug33693.result
A mysql-test/r/partition_column.result
A mysql-test/r/partition_column_prune.result
A mysql-test/r/partition_utf8.result
A mysql-test/r/query_cache_disabled.result
A mysql-test/r/sp-bugs.result
A mysql-test/suite/binlog/r/binlog_delete_and_flush_index.result
A mysql-test/suite/binlog/r/binlog_stm_do_db.result
A mysql-test/suite/binlog/t/binlog_delete_and_flush_index.test
A mysql-test/suite/binlog/t/binlog_stm_do_db-master.opt
A mysql-test/suite/binlog/t/binlog_stm_do_db.test
A mysql-test/suite/rpl/t/rpl_get_master_version_and_clock-slave.opt
A mysql-test/t/drop_debug.test
A mysql-test/t/grant4.test
A mysql-test/t/grant_lowercase_fs.test
A mysql-test/t/innodb_bug47777.test
A mysql-test/t/locale.test
A mysql-test/t/log_state_bug33693-master.opt
A mysql-test/t/log_state_bug33693.test
A mysql-test/t/partition_column.test
A mysql-test/t/partition_column_prune.test
A mysql-test/t/partition_utf8.test
A mysql-test/t/query_cache_disabled-master.opt
A mysql-test/t/query_cache_disabled.test
A mysql-test/t/sp-bugs.test
A sql/records.h
A sql/sql_plugin_services.h
A sql/sql_prepare.h
A unittest/mysys/my_vsnprintf-t.c
R mysql-test/include/have_community_features.inc => mysql-test/include/have_profiling.inc
R mysql-test/r/bug40113.result => mysql-test/r/innodb_lock_wait_timeout_1.result
R mysql-test/r/have_community_features.require => mysql-test/r/have_profiling.require
R mysql-test/t/bug40113-master.opt => mysql-test/t/innodb_lock_wait_timeout_1-master.opt
R mysql-test/t/bug40113.test => mysql-test/t/innodb_lock_wait_timeout_1.test
M .bzr-mysql/default.conf
M .bzrignore
M BUILD/build_mccge.sh
M CMakeLists.txt
M Makefile.am
M client/mysql.cc
M client/mysql_upgrade.c
M client/mysqladmin.cc
M client/mysqlbinlog.cc
M client/mysqlcheck.c
M client/mysqldump.c
M client/mysqlimport.c
M client/mysqlshow.c
M client/mysqlslap.c
M client/mysqltest.cc
M configure.in
M dbug/Makefile.am
M dbug/dbug.c
M dbug/dbug_add_tags.pl
M dbug/user.r
M extra/my_print_defaults.c
M extra/yassl/taocrypt/src/random.cpp
M include/Makefile.am
M include/config-win.h
M include/errmsg.h
M include/hash.h
M include/m_string.h
M include/my_base.h
M include/my_dbug.h
M include/my_global.h
M include/my_pthread.h
M include/my_sys.h
M include/myisam.h
M include/mysql.h
M include/mysql.h.pp
M include/mysql/plugin.h
M include/mysql/plugin.h.pp
M include/mysql_com.h
M libmysql/CMakeLists.txt
M libmysql/Makefile.shared
M libmysql/client_settings.h
M libmysql/errmsg.c
M libmysql/libmysql.c
M libmysql/libmysql.def
M libmysqld/lib_sql.cc
M libmysqld/libmysqld.c
M libmysqld/libmysqld.def
M mysql-test/collections/default.experimental
M mysql-test/extra/binlog_tests/drop_temp_table.test
M mysql-test/extra/rpl_tests/rpl_loaddata.test
M mysql-test/extra/rpl_tests/rpl_stm_000001.test
M mysql-test/include/query_cache_sql_prepare.inc
M mysql-test/lib/My/SafeProcess/safe_process_win.cc
M mysql-test/r/alter_table.result
M mysql-test/r/analyse.result
M mysql-test/r/create.result
M mysql-test/r/ctype_collate.result
M mysql-test/r/ctype_ldml.result
M mysql-test/r/delayed.result
M mysql-test/r/drop.result
M mysql-test/r/events_bugs.result
M mysql-test/r/explain.result
M mysql-test/r/func_math.result
M mysql-test/r/func_str.result
M mysql-test/r/gis-rtree.result
M mysql-test/r/gis.result
M mysql-test/r/grant.result
M mysql-test/r/grant2.result
M mysql-test/r/grant3.result
M mysql-test/r/information_schema.result
M mysql-test/r/information_schema_db.result
M mysql-test/r/innodb-autoinc.result
M mysql-test/r/innodb_bug46000.result
M mysql-test/r/innodb_mysql.result
M mysql-test/r/insert.result
M mysql-test/r/join.result
M mysql-test/r/loadxml.result
M mysql-test/r/log_state.result
M mysql-test/r/lowercase_fs_off.result
M mysql-test/r/lowercase_table2.result
M mysql-test/r/merge.result
M mysql-test/r/myisam.result
M mysql-test/r/myisam_crash_before_flush_keys.result
M mysql-test/r/mysqlbinlog_row.result
M mysql-test/r/mysqlbinlog_row_innodb.result
M mysql-test/r/mysqlbinlog_row_myisam.result
M mysql-test/r/mysqlbinlog_row_trans.result
M mysql-test/r/mysqldump.result
M mysql-test/r/olap.result
M mysql-test/r/outfile.result
M mysql-test/r/partition.result
M mysql-test/r/partition_datatype.result
M mysql-test/r/partition_error.result
M mysql-test/r/partition_innodb.result
M mysql-test/r/partition_list.result
M mysql-test/r/partition_mgm_err.result
M mysql-test/r/partition_pruning.result
M mysql-test/r/partition_range.result
M mysql-test/r/plugin.result
M mysql-test/r/profiling.result
M mysql-test/r/ps.result
M mysql-test/r/ps_1general.result
M mysql-test/r/ps_grant.result
M mysql-test/r/query_cache.result
M mysql-test/r/query_cache_ps_no_prot.result
M mysql-test/r/query_cache_ps_ps_prot.result
M mysql-test/r/range.result
M mysql-test/r/select.result
M mysql-test/r/show_check.result
M mysql-test/r/sp-error.result
M mysql-test/r/sp-vars.result
M mysql-test/r/sp.result
M mysql-test/r/sp_trans.result
M mysql-test/r/sql_mode.result
M mysql-test/r/strict.result
M mysql-test/r/subselect.result
M mysql-test/r/subselect3.result
M mysql-test/r/system_mysql_db.result
M mysql-test/r/trigger.result
M mysql-test/r/type_decimal.result
M mysql-test/r/type_newdecimal.result
M mysql-test/r/type_varchar.result
M mysql-test/r/update.result
M mysql-test/r/view_grant.result
M mysql-test/r/xa.result
M mysql-test/suite/binlog/r/binlog_row_drop_tmp_tbl.result
M mysql-test/suite/binlog/r/binlog_stm_drop_tmp_tbl.result
M mysql-test/suite/funcs_1/r/innodb_func_view.result
M mysql-test/suite/funcs_1/r/innodb_storedproc_07.result
M mysql-test/suite/funcs_1/r/innodb_trig_03.result
M mysql-test/suite/funcs_1/r/innodb_trig_03e.result
M mysql-test/suite/funcs_1/r/innodb_views.result
M mysql-test/suite/funcs_1/r/is_columns_is.result
M mysql-test/suite/funcs_1/r/is_columns_mysql.result
M mysql-test/suite/funcs_1/r/is_routines.result
M mysql-test/suite/funcs_1/r/is_statistics.result
M mysql-test/suite/funcs_1/r/is_user_privileges.result
M mysql-test/suite/funcs_1/r/memory_func_view.result
M mysql-test/suite/funcs_1/r/memory_storedproc_07.result
M mysql-test/suite/funcs_1/r/memory_trig_03.result
M mysql-test/suite/funcs_1/r/memory_trig_03e.result
M mysql-test/suite/funcs_1/r/memory_views.result
M mysql-test/suite/funcs_1/r/myisam_func_view.result
M mysql-test/suite/funcs_1/r/myisam_storedproc_07.result
M mysql-test/suite/funcs_1/r/myisam_trig_03.result
M mysql-test/suite/funcs_1/r/myisam_trig_03e.result
M mysql-test/suite/funcs_1/r/myisam_views.result
M mysql-test/suite/funcs_1/r/ndb_func_view.result
M mysql-test/suite/funcs_1/r/ndb_storedproc_07.result
M mysql-test/suite/funcs_1/r/ndb_trig_03.result
M mysql-test/suite/funcs_1/r/ndb_trig_03e.result
M mysql-test/suite/funcs_1/r/ndb_views.result
M mysql-test/suite/funcs_1/r/storedproc.result
M mysql-test/suite/innodb/r/innodb-zip.result
M mysql-test/suite/innodb/t/disabled.def
M mysql-test/suite/innodb/t/innodb-analyze.test
M mysql-test/suite/innodb/t/innodb-zip.test
M mysql-test/suite/innodb/t/innodb_bug36169.test
M mysql-test/suite/innodb/t/innodb_bug36172.test
M mysql-test/suite/innodb/t/innodb_information_schema.test
M mysql-test/suite/ndb/r/ndb_dd_ddl.result
M mysql-test/suite/ndb/t/ndb_dd_ddl.test
M mysql-test/suite/parts/inc/partition_key_32col.inc
M mysql-test/suite/parts/inc/partition_syntax.inc
M mysql-test/suite/parts/r/partition_special_innodb.result
M mysql-test/suite/parts/r/partition_special_myisam.result
M mysql-test/suite/parts/r/partition_syntax_innodb.result
M mysql-test/suite/parts/r/partition_syntax_myisam.result
M mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result
M mysql-test/suite/rpl/r/rpl_loaddata.result
M mysql-test/suite/rpl/r/rpl_udf.result
M mysql-test/suite/rpl/t/rpl_err_ignoredtable.test
M mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test
M mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test
M mysql-test/suite/sys_vars/r/auto_commit_basic.result
M mysql-test/suite/sys_vars/r/automatic_sp_privileges_basic.result
M mysql-test/suite/sys_vars/r/big_tables_basic.result
M mysql-test/suite/sys_vars/r/engine_condition_pushdown_basic.result
M mysql-test/suite/sys_vars/r/flush_basic.result
M mysql-test/suite/sys_vars/r/foreign_key_checks_basic.result
M mysql-test/suite/sys_vars/r/general_log_basic.result
M mysql-test/suite/sys_vars/r/innodb_checksums_basic.result
M mysql-test/suite/sys_vars/r/innodb_doublewrite_basic.result
M mysql-test/suite/sys_vars/r/innodb_locks_unsafe_for_binlog_basic.result
M mysql-test/suite/sys_vars/r/innodb_rollback_on_timeout_basic.result
M mysql-test/suite/sys_vars/r/innodb_support_xa_basic.result
M mysql-test/suite/sys_vars/r/innodb_table_locks_basic.result
M mysql-test/suite/sys_vars/r/keep_files_on_create_basic.result
M mysql-test/suite/sys_vars/r/local_infile_basic.result
M mysql-test/suite/sys_vars/r/log_bin_trust_function_creators_basic.result
M mysql-test/suite/sys_vars/r/log_queries_not_using_indexes_basic.result
M mysql-test/suite/sys_vars/r/low_priority_updates_basic.result
M mysql-test/suite/sys_vars/r/myisam_use_mmap_basic.result
M mysql-test/suite/sys_vars/r/new_basic.result
M mysql-test/suite/sys_vars/r/old_passwords_basic.result
M mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_basic.result
M mysql-test/suite/sys_vars/r/read_only_basic.result
M mysql-test/suite/sys_vars/r/relay_log_purge_basic.result
M mysql-test/suite/sys_vars/r/secure_auth_basic.result
M mysql-test/suite/sys_vars/r/slave_allow_batching_basic.result
M mysql-test/suite/sys_vars/r/slave_compressed_protocol_basic.result
M mysql-test/suite/sys_vars/r/slow_query_log_basic.result
M mysql-test/suite/sys_vars/r/sql_auto_is_null_basic.result
M mysql-test/suite/sys_vars/r/sql_big_selects_basic.result
M mysql-test/suite/sys_vars/r/sql_big_tables_basic.result
M mysql-test/suite/sys_vars/r/sql_buffer_result_basic.result
M mysql-test/suite/sys_vars/r/sql_log_bin_basic.result
M mysql-test/suite/sys_vars/r/sql_log_off_basic.result
M mysql-test/suite/sys_vars/r/sql_low_priority_updates_basic.result
M mysql-test/suite/sys_vars/r/sql_notes_basic.result
M mysql-test/suite/sys_vars/r/sql_quote_show_create_basic.result
M mysql-test/suite/sys_vars/r/sql_safe_updates_basic.result
M mysql-test/suite/sys_vars/r/sql_warnings_basic.result
M mysql-test/suite/sys_vars/r/sync_frm_basic.result
M mysql-test/suite/sys_vars/r/timed_mutexes_basic.result
M mysql-test/suite/sys_vars/r/unique_checks_basic.result
M mysql-test/suite/sys_vars/t/auto_commit_basic.test
M mysql-test/suite/sys_vars/t/automatic_sp_privileges_basic.test
M mysql-test/suite/sys_vars/t/big_tables_basic.test
M mysql-test/suite/sys_vars/t/engine_condition_pushdown_basic.test
M mysql-test/suite/sys_vars/t/flush_basic.test
M mysql-test/suite/sys_vars/t/foreign_key_checks_basic.test
M mysql-test/suite/sys_vars/t/general_log_basic.test
M mysql-test/suite/sys_vars/t/innodb_checksums_basic.test
M mysql-test/suite/sys_vars/t/innodb_doublewrite_basic.test
M mysql-test/suite/sys_vars/t/innodb_locks_unsafe_for_binlog_basic.test
M mysql-test/suite/sys_vars/t/innodb_rollback_on_timeout_basic.test
M mysql-test/suite/sys_vars/t/innodb_support_xa_basic.test
M mysql-test/suite/sys_vars/t/innodb_table_locks_basic.test
M mysql-test/suite/sys_vars/t/keep_files_on_create_basic.test
M mysql-test/suite/sys_vars/t/local_infile_basic.test
M mysql-test/suite/sys_vars/t/log_bin_trust_function_creators_basic.test
M mysql-test/suite/sys_vars/t/log_queries_not_using_indexes_basic.test
M mysql-test/suite/sys_vars/t/low_priority_updates_basic.test
M mysql-test/suite/sys_vars/t/myisam_use_mmap_basic.test
M mysql-test/suite/sys_vars/t/new_basic.test
M mysql-test/suite/sys_vars/t/old_passwords_basic.test
M mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_basic.test
M mysql-test/suite/sys_vars/t/read_only_basic.test
M mysql-test/suite/sys_vars/t/relay_log_purge_basic.test
M mysql-test/suite/sys_vars/t/secure_auth_basic.test
M mysql-test/suite/sys_vars/t/slave_allow_batching_basic.test
M mysql-test/suite/sys_vars/t/slave_compressed_protocol_basic.test
M mysql-test/suite/sys_vars/t/slow_query_log_basic.test
M mysql-test/suite/sys_vars/t/sql_auto_is_null_basic.test
M mysql-test/suite/sys_vars/t/sql_big_selects_basic.test
M mysql-test/suite/sys_vars/t/sql_big_tables_basic.test
M mysql-test/suite/sys_vars/t/sql_buffer_result_basic.test
M mysql-test/suite/sys_vars/t/sql_log_bin_basic.test
M mysql-test/suite/sys_vars/t/sql_log_off_basic.test
M mysql-test/suite/sys_vars/t/sql_low_priority_updates_basic.test
M mysql-test/suite/sys_vars/t/sql_notes_basic.test
M mysql-test/suite/sys_vars/t/sql_quote_show_create_basic.test
M mysql-test/suite/sys_vars/t/sql_safe_updates_basic.test
M mysql-test/suite/sys_vars/t/sql_warnings_basic.test
M mysql-test/suite/sys_vars/t/sync_frm_basic.test
M mysql-test/suite/sys_vars/t/timed_mutexes_basic.test
M mysql-test/suite/sys_vars/t/unique_checks_basic.test
M mysql-test/t/alter_table.test
M mysql-test/t/analyse.test
M mysql-test/t/create.test
M mysql-test/t/ctype_collate.test
M mysql-test/t/ctype_ldml.test
M mysql-test/t/ctype_utf8.test
M mysql-test/t/delayed.test
M mysql-test/t/disabled.def
M mysql-test/t/drop.test
M mysql-test/t/explain.test
M mysql-test/t/flush_read_lock_kill.test
M mysql-test/t/gis-rtree.test
M mysql-test/t/gis.test
M mysql-test/t/grant.test
M mysql-test/t/grant3.test
M mysql-test/t/information_schema_db.test
M mysql-test/t/innodb-autoinc.test
M mysql-test/t/innodb.test
M mysql-test/t/innodb_bug39438.test
M mysql-test/t/innodb_bug44369.test
M mysql-test/t/innodb_bug46000.test
M mysql-test/t/innodb_mysql.test
M mysql-test/t/insert.test
M mysql-test/t/join.test
M mysql-test/t/kill.test
M mysql-test/t/loadxml.test
M mysql-test/t/log_state.test
M mysql-test/t/lowercase_fs_off.test
M mysql-test/t/lowercase_table2.test
M mysql-test/t/merge.test
M mysql-test/t/myisam.test
M mysql-test/t/myisam_crash_before_flush_keys.test
M mysql-test/t/olap.test
M mysql-test/t/outfile.test
M mysql-test/t/partition.test
M mysql-test/t/partition_datatype.test
M mysql-test/t/partition_error.test
M mysql-test/t/partition_innodb.test
M mysql-test/t/partition_list.test
M mysql-test/t/partition_mgm_err.test
M mysql-test/t/partition_pruning.test
M mysql-test/t/partition_range.test
M mysql-test/t/plugin.test
M mysql-test/t/profiling.test
M mysql-test/t/ps.test
M mysql-test/t/query_cache.test
M mysql-test/t/range.test
M mysql-test/t/select.test
M mysql-test/t/sp-error.test
M mysql-test/t/sp-vars.test
M mysql-test/t/sp.test
M mysql-test/t/sp_trans.test
M mysql-test/t/sql_mode.test
M mysql-test/t/subselect.test
M mysql-test/t/subselect3.test
M mysql-test/t/trigger.test
M mysql-test/t/type_decimal.test
M mysql-test/t/type_newdecimal.test
M mysql-test/t/type_varchar.test
M mysql-test/t/update.test
M mysql-test/t/variables+c.test
M mysql-test/t/view_grant.test
M mysql-test/t/xa.test
M mysys/default.c
M mysys/mf_keycaches.c
M mysys/my_error.c
M mysys/my_getopt.c
M mysys/my_largepage.c
M mysys/my_thr_init.c
M mysys/typelib.c
M plugin/daemon_example/Makefile.am
M scripts/mysql_system_tables.sql
M scripts/mysql_system_tables_data.sql
M scripts/mysql_system_tables_fix.sql
M scripts/mysqld_safe.sh
M sql-common/client.c
M sql/CMakeLists.txt
M sql/Makefile.am
M sql/debug_sync.cc
M sql/event_data_objects.cc
M sql/event_scheduler.cc
M sql/events.cc
M sql/field.cc
M sql/field.h
M sql/ha_ndbcluster.cc
M sql/ha_ndbcluster_binlog.cc
M sql/ha_partition.cc
M sql/ha_partition.h
M sql/handler.cc
M sql/handler.h
M sql/hash_filo.h
M sql/hostname.cc
M sql/item.cc
M sql/item.h
M sql/item_cmpfunc.cc
M sql/item_cmpfunc.h
M sql/item_create.cc
M sql/item_func.cc
M sql/item_func.h
M sql/item_geofunc.cc
M sql/item_subselect.cc
M sql/item_sum.cc
M sql/item_sum.h
M sql/item_timefunc.cc
M sql/item_timefunc.h
M sql/lock.cc
M sql/log.cc
M sql/log_event.cc
M sql/log_event_old.cc
M sql/my_decimal.h
M sql/mysql_priv.h
M sql/mysqld.cc
M sql/net_serv.cc
M sql/opt_range.cc
M sql/partition_element.h
M sql/partition_info.cc
M sql/partition_info.h
M sql/procedure.h
M sql/protocol.cc
M sql/protocol.h
M sql/records.cc
M sql/repl_failsafe.cc
M sql/replication.h
M sql/rpl_filter.cc
M sql/rpl_handler.cc
M sql/rpl_injector.h
M sql/rpl_tblmap.cc
M sql/rpl_tblmap.h
M sql/set_var.cc
M sql/set_var.h
M sql/share/errmsg-utf8.txt
M sql/share/errmsg.txt
M sql/slave.cc
M sql/sp.cc
M sql/sp_cache.cc
M sql/sp_head.cc
M sql/sql_acl.cc
M sql/sql_acl.h
M sql/sql_base.cc
M sql/sql_cache.cc
M sql/sql_cache.h
M sql/sql_class.cc
M sql/sql_class.h
M sql/sql_connect.cc
M sql/sql_cursor.cc
M sql/sql_db.cc
M sql/sql_delete.cc
M sql/sql_error.cc
M sql/sql_handler.cc
M sql/sql_help.cc
M sql/sql_insert.cc
M sql/sql_lex.cc
M sql/sql_lex.h
M sql/sql_list.cc
M sql/sql_list.h
M sql/sql_load.cc
M sql/sql_locale.cc
M sql/sql_parse.cc
M sql/sql_partition.cc
M sql/sql_partition.h
M sql/sql_plugin.cc
M sql/sql_plugin.h
M sql/sql_prepare.cc
M sql/sql_profile.cc
M sql/sql_profile.h
M sql/sql_rename.cc
M sql/sql_repl.cc
M sql/sql_select.cc
M sql/sql_select.h
M sql/sql_servers.cc
M sql/sql_show.cc
M sql/sql_string.h
M sql/sql_table.cc
M sql/sql_tablespace.cc
M sql/sql_test.cc
M sql/sql_trigger.cc
M sql/sql_udf.cc
M sql/sql_update.cc
M sql/sql_view.cc
M sql/sql_yacc.yy
M sql/structs.h
M sql/table.cc
M sql/table.h
M sql/time.cc
M sql/tztime.cc
M storage/archive/archive_reader.c
M storage/archive/ha_archive.cc
M storage/blackhole/ha_blackhole.cc
M storage/csv/ha_tina.cc
M storage/csv/ha_tina.h
M storage/example/Makefile.am
M storage/example/ha_example.cc
M storage/federated/ha_federated.cc
M storage/innobase/ChangeLog
M storage/innobase/buf/buf0buf.c
M storage/innobase/buf/buf0flu.c
M storage/innobase/buf/buf0lru.c
M storage/innobase/fil/fil0fil.c
M storage/innobase/handler/ha_innodb.cc
M storage/innobase/handler/ha_innodb.h
M storage/innobase/handler/handler0alter.cc
M storage/innobase/include/buf0buf.h
M storage/innobase/include/buf0buf.ic
M storage/innobase/include/handler0alter.h
M storage/innobase/include/page0page.ic
M storage/innobase/include/row0merge.h
M storage/innobase/include/row0mysql.h
M storage/innobase/include/row0types.h
M storage/innobase/include/univ.i
M storage/innobase/os/os0file.c
M storage/innobase/os/os0proc.c
M storage/innobase/row/row0ins.c
M storage/innobase/row/row0merge.c
M storage/innobase/row/row0mysql.c
M storage/innobase/srv/srv0start.c
M storage/myisam/ha_myisam.cc
M storage/myisam/mi_check.c
M storage/myisam/mi_dynrec.c
M storage/myisam/myisamchk.c
M storage/myisam/myisampack.c
M storage/myisam/sort.c
M storage/mysql_storage_engine.cmake
M storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp
M strings/ctype-uca.c
M strings/my_vsnprintf.c
M tests/mysql_client_test.c
M tests/thread_test.c
M unittest/mysys/Makefile.am
M vio/viosslfactories.c
M mysql-test/include/have_profiling.inc
M mysql-test/r/innodb_lock_wait_timeout_1.result
M mysql-test/r/have_profiling.require
M mysql-test/t/innodb_lock_wait_timeout_1.test
2955.1.2 Mattias Jonsson 2009-11-20
Bug#32115: Bad use of Name_resolution_context from current LEX in partitioning
port from mysql-next (5.4?) to mysql-next-mr-bugfixes (5.5/5.6?)
3477 Mikael Ronstrom 2009-07-29
Bug#32115, made use of local lex object to avoid side effects of opening partitioned
tables
3478 Mikael Ronstrom 2009-07-29
Bug#32115, added an extra test in debug builds to ensure no dangling pointers to the
old lex object is still around
3479 Mikael Ronstrom 2009-07-29
Bug#32115, Removed an assert that was no longer needed
3480 Mikael Ronstrom 2009-08-05
Bug#32115, fixed review comments
3481 Mikael Ronstrom 2009-08-07
Bug#32115, remove now obsolete lex_start calls
M libmysqld/lib_sql.cc
M sql/ha_ndbcluster.cc
M sql/ha_ndbcluster_binlog.cc
M sql/slave.cc
M sql/sql_insert.cc
M sql/sql_partition.cc
M sql/table.cc
2955.1.1 Mattias Jonsson 2009-11-20
Bug#32115: Bad use of Name_resolution_context from current LEX in partitioning
port from mysql-next (5.4) to mysql-next-mr-bugfixing (5.5/5.6?)
2755 Konstantin Osipov 2008-11-27
Bug#32115 will remove the pre-requisite to initialize LEX to open tables.
This dependency was added in 5.1 and was supposed to be removed in 6.0.
Remove asserts and initialization of LEX in places where we don't deal
with partitioned tables.
@ sql/sp_head.cc
Fix a typo.
M sql/event_scheduler.cc
M sql/events.cc
M sql/sp_head.cc
M sql/sql_acl.cc
M sql/sql_base.cc
M sql/sql_parse.cc
M sql/sql_plugin.cc
M sql/sql_servers.cc
M sql/sql_udf.cc
M sql/table.cc
M sql/tztime.cc
2944.1.1 Martin Hansson 2009-11-10
Backport of Bug#33204 from mysql-pe to
mysql-next-mr-bugfixing.
Bug no 32858 was fixed in two different ways in what was
then called mysql 5.1 and 6.0. The fix in 6.0 was very
different since bugfix no 33204 was present. Furthermore,
the two fixes were not compatible. Hence in order to
backport Bug#33204 to the 5.1-based mysql-next-mr-bugfixing,
it was necessary to remove the 5.1 fix of 32858 and apply
the 6.0 version of the fix.
@ mysql-test/r/subselect.result
Bug#33204-backport: Test result
@ mysql-test/r/union.result
Bug#33204-backport:
- Reversal of test result: bugfix no 32858 for 5.1
- Application of test result: bugfix no 32858 for 6.0
@ mysql-test/t/subselect.test
Bug#33204-backport:
- Changed tests
- Test case
@ mysql-test/t/union.test
Bug#33204-backport:
- Reversal of test: bugfix no 32858 for 5.1
- Application of test: bugfix no 32858 for 6.0
@ sql/sql_class.cc
Bug#33204-backport: Reversal of bugfix no 32858 for 5.1
@ sql/sql_class.h
Bug#33204-backport: Reversal of bugfix no 32858 for 5.1
@ sql/sql_yacc.yy
Bug#33204-backport:
- Reversal of bugfix no 32858 for 5.1
- Application of bugfix no 32858 for 6.0
- Application of bugfix no 33204
M mysql-test/r/subselect.result
M mysql-test/r/union.result
M mysql-test/t/subselect.test
M mysql-test/t/union.test
M sql/sql_class.cc
M sql/sql_class.h
M sql/sql_yacc.yy
=== modified file 'client/client_priv.h'
--- a/client/client_priv.h 2009-10-15 12:23:43 +0000
+++ b/client/client_priv.h 2009-11-04 13:31:03 +0000
@@ -62,6 +62,9 @@ enum options_client
OPT_MYSQL_NUMBER_OF_QUERY,
OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE,
OPT_TZ_UTC, OPT_AUTO_CLOSE, OPT_CREATE_SLAP_SCHEMA,
+ OPT_MYSQLDUMP_SLAVE_APPLY,
+ OPT_MYSQLDUMP_SLAVE_DATA,
+ OPT_MYSQLDUMP_INCLUDE_MASTER_HOST_PORT,
OPT_SLAP_CSV, OPT_SLAP_CREATE_STRING,
OPT_SLAP_AUTO_GENERATE_SQL_LOAD_TYPE, OPT_SLAP_AUTO_GENERATE_WRITE_NUM,
OPT_SLAP_AUTO_GENERATE_ADD_AUTO,
@@ -78,6 +81,7 @@ enum options_client
OPT_SLAP_DETACH,
OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT_MODE, OPT_SERVER_ID,
OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
+ OPT_AUTO_VERTICAL_OUTPUT,
OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE,
OPT_WRITE_BINLOG, OPT_DUMP_DATE,
OPT_INIT_COMMAND,
=== modified file 'client/mysql.cc'
--- a/client/mysql.cc 2009-11-17 11:27:40 +0000
+++ b/client/mysql.cc 2009-11-20 14:18:37 +0000
@@ -143,6 +143,7 @@ static my_bool ignore_errors=0,wait_flag
tty_password= 0, opt_nobeep=0, opt_reconnect=1,
opt_secure_auth= 0,
default_pager_set= 0, opt_sigint_ignore= 0,
+ auto_vertical_output= 0,
show_warnings= 0, executing_query= 0, interrupted_query= 0,
ignore_spaces= 0;
static my_bool debug_info_flag, debug_check_flag;
@@ -185,6 +186,7 @@ static MEM_ROOT hash_mem_root;
static uint prompt_counter;
static char delimiter[16]= DEFAULT_DELIMITER;
static uint delimiter_length= 1;
+unsigned short terminal_width= 80;
#ifdef HAVE_SMEM
static char *shared_memory_base_name=0;
@@ -238,6 +240,8 @@ static const char* construct_prompt();
static char *get_arg(char *line, my_bool get_next_arg);
static void init_username();
static void add_int_to_prompt(int toadd);
+static int get_result_width(MYSQL_RES *res);
+static int get_field_disp_length(MYSQL_FIELD * field);
/* A structure which contains information on the commands this program
can understand. */
@@ -1065,6 +1069,10 @@ static void mysql_end_timer(ulong start_
static void nice_time(double sec,char *buff,bool part_second);
extern "C" sig_handler mysql_end(int sig);
extern "C" sig_handler handle_sigint(int sig);
+#if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
+static sig_handler window_resize(int sig);
+#endif
+
int main(int argc,char *argv[])
{
@@ -1148,8 +1156,8 @@ int main(int argc,char *argv[])
if (sql_connect(current_host,current_db,current_user,opt_password,
opt_silent))
{
- quick=1; // Avoid history
- status.exit_status=1;
+ quick= 1; // Avoid history
+ status.exit_status= 1;
mysql_end(-1);
}
if (!status.batch)
@@ -1161,6 +1169,13 @@ int main(int argc,char *argv[])
signal(SIGINT, handle_sigint); // Catch SIGINT to clean up
signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up
+#if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
+ /* Readline will call this if it installs a handler */
+ signal(SIGWINCH, window_resize);
+ /* call the SIGWINCH handler to get the default term width */
+ window_resize(0);
+#endif
+
put_info("Welcome to the MySQL monitor. Commands end with ; or \\g.",
INFO_INFO);
sprintf((char*) glob_buffer.ptr(),
@@ -1333,6 +1348,16 @@ err:
}
+#if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
+sig_handler window_resize(int sig)
+{
+ struct winsize window_size;
+
+ if (ioctl(fileno(stdin), TIOCGWINSZ, &window_size) == 0)
+ terminal_width= window_size.ws_col;
+}
+#endif
+
static struct my_option my_long_options[] =
{
{"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
@@ -1350,6 +1375,9 @@ static struct my_option my_long_options[
{"no-auto-rehash", 'A',
"No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"auto-vertical-output", OPT_AUTO_VERTICAL_OUTPUT,
+ "Automatically switch to vertical output mode if the result is wider than the terminal width.",
+ (uchar**) &auto_vertical_output, (uchar**) &auto_vertical_output, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"batch", 'B',
"Don't use history file. Disable interactive behavior. (Enables --silent)", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"character-sets-dir", OPT_CHARSETS_DIR,
@@ -3056,7 +3084,7 @@ com_go(String *buffer,char *line __attri
print_table_data_html(result);
else if (opt_xml)
print_table_data_xml(result);
- else if (vertical)
+ else if (vertical || (auto_vertical_output && (terminal_width < get_result_width(result))))
print_table_data_vertically(result);
else if (opt_silent && verbose <= 2 && !output_tables)
print_tab_data(result);
@@ -3387,6 +3415,65 @@ print_table_data(MYSQL_RES *result)
my_afree((uchar*) num_flag);
}
+/**
+ Return the length of a field after it would be rendered into text.
+
+ This doesn't know or care about multibyte characters. Assume we're
+ using such a charset. We can't know that all of the upcoming rows
+ for this column will have bytes that each render into some fraction
+ of a character. It's at least possible that a row has bytes that
+ all render into one character each, and so the maximum length is
+ still the number of bytes. (Assumption 1: This can't be better
+ because we can never know the number of characters that the DB is
+ going to send -- only the number of bytes. 2: Chars <= Bytes.)
+
+ @param field Pointer to a field to be inspected
+
+ @returns number of character positions to be used, at most
+*/
+static int get_field_disp_length(MYSQL_FIELD *field)
+{
+ uint length= column_names ? field->name_length : 0;
+
+ if (quick)
+ length= max(length, field->length);
+ else
+ length= max(length, field->max_length);
+
+ if (length < 4 && !IS_NOT_NULL(field->flags))
+ length= 4; /* Room for "NULL" */
+
+ return length;
+}
+
+/**
+ For a new result, return the max number of characters that any
+ upcoming row may return.
+
+ @param result Pointer to the result to judge
+
+ @returns The max number of characters in any row of this result
+*/
+static int get_result_width(MYSQL_RES *result)
+{
+ unsigned int len= 0;
+ MYSQL_FIELD *field;
+ MYSQL_FIELD_OFFSET offset;
+
+#ifndef DBUG_OFF
+ offset= mysql_field_tell(result);
+ DBUG_ASSERT(offset == 0);
+#else
+ offset= 0;
+#endif
+
+ while ((field= mysql_fetch_field(result)) != NULL)
+ len+= get_field_disp_length(field) + 3; /* plus bar, space, & final space */
+
+ (void) mysql_field_seek(result, offset);
+
+ return len + 1; /* plus final bar. */
+}
static void
tee_print_sized_data(const char *data, unsigned int data_length, unsigned int total_bytes_to_send, bool right_justified)
=== modified file 'client/mysqladmin.cc'
--- a/client/mysqladmin.cc 2009-11-17 11:27:40 +0000
+++ b/client/mysqladmin.cc 2009-11-20 14:18:37 +0000
@@ -901,23 +901,38 @@ static int execute_commands(MYSQL *mysql
{
char buff[128],crypted_pw[64];
time_t start_time;
+ char *typed_password= NULL, *verified= NULL;
/* Do initialization the same way as we do in mysqld */
start_time=time((time_t*) 0);
randominit(&rand_st,(ulong) start_time,(ulong) start_time/2);
- if (argc < 2)
+ if (argc < 1)
{
my_printf_error(0, "Too few arguments to change password", error_flags);
return 1;
}
- if (argv[1][0])
+ else if (argc == 1)
+ {
+ /* prompt for password */
+ typed_password= get_tty_password("New password: ");
+ verified= get_tty_password("Confirm new password: ");
+ if (strcmp(typed_password, verified) != 0)
+ {
+ my_printf_error(0,"Passwords don't match",MYF(ME_BELL));
+ return -1;
+ }
+ }
+ else
+ typed_password= argv[1];
+
+ if (typed_password[0])
{
- char *pw= argv[1];
bool old= (find_type(argv[0], &command_typelib, 2) ==
ADMIN_OLD_PASSWORD);
#ifdef __WIN__
- uint pw_len= (uint) strlen(pw);
- if (pw_len > 1 && pw[0] == '\'' && pw[pw_len-1] == '\'')
+ size_t pw_len= strlen(typed_password);
+ if (pw_len > 1 && typed_password[0] == '\'' &&
+ typed_password[pw_len-1] == '\'')
printf("Warning: single quotes were not trimmed from the password by"
" your command\nline client, as you might have expected.\n");
#endif
@@ -955,9 +970,9 @@ static int execute_commands(MYSQL *mysql
}
}
if (old)
- make_scrambled_password_323(crypted_pw, pw);
+ make_scrambled_password_323(crypted_pw, typed_password);
else
- make_scrambled_password(crypted_pw, pw);
+ make_scrambled_password(crypted_pw, typed_password);
}
else
crypted_pw[0]=0; /* No password */
@@ -992,6 +1007,12 @@ static int execute_commands(MYSQL *mysql
return -1;
}
}
+ /* free up memory from prompted password */
+ if (typed_password != argv[1])
+ {
+ my_free(typed_password,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(verified,MYF(MY_ALLOW_ZERO_PTR));
+ }
argc--; argv++;
break;
}
@@ -1083,8 +1104,8 @@ static void usage(void)
kill id,id,... Kill mysql threads");
#if MYSQL_VERSION_ID >= 32200
puts("\
- password new-password Change old password to new-password, MySQL 4.1 hashing.\n\
- old-password new-password Change old password to new-password in old format.\n");
+ password [new-password] Change old password to new-password in current format\n\
+ old-password [new-password] Change old password to new-password in old format");
#endif
puts("\
ping Check if mysqld is alive\n\
=== modified file 'client/mysqlcheck.c'
--- a/client/mysqlcheck.c 2009-11-17 11:27:40 +0000
+++ b/client/mysqlcheck.c 2009-11-20 14:18:37 +0000
@@ -128,7 +128,7 @@ static struct my_option my_long_options[
"Faster than extended-check, but only finds 99.99 percent of all errors. Should be good enough for most cases.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"write-binlog", OPT_WRITE_BINLOG,
- "Log ANALYZE, OPTIMIZE and REPAIR TABLE commands. Enabled by default; use --skip-write-binlog when commands should not be sent to replication slaves.",
+ "Log ANALYZE, OPTIMIZE and REPAIR TABLE commands. Use --skip-write-binlog when commands should not be sent to replication slaves.",
(uchar**) &opt_write_binlog, (uchar**) &opt_write_binlog, 0, GET_BOOL, NO_ARG,
1, 0, 0, 0, 0, 0},
{"optimize", 'o', "Optimize table.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0,
=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c 2009-11-17 11:27:40 +0000
+++ b/client/mysqldump.c 2009-11-20 14:18:37 +0000
@@ -98,6 +98,8 @@ static my_bool verbose= 0, opt_no_creat
opt_complete_insert= 0, opt_drop_database= 0,
opt_replace_into= 0,
opt_dump_triggers= 0, opt_routines=0, opt_tz_utc=1,
+ opt_slave_apply= 0,
+ opt_include_master_host_port= 0,
opt_events= 0,
opt_alltspcs=0, opt_notspcs= 0;
static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0;
@@ -118,7 +120,10 @@ static my_bool server_supports_switching
static ulong opt_compatible_mode= 0;
#define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL 1
#define MYSQL_OPT_MASTER_DATA_COMMENTED_SQL 2
+#define MYSQL_OPT_SLAVE_DATA_EFFECTIVE_SQL 1
+#define MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL 2
static uint opt_mysql_port= 0, opt_master_data;
+static uint opt_slave_data;
static uint my_end_arg;
static char * opt_mysql_unix_port=0;
static int first_error=0;
@@ -206,6 +211,10 @@ static struct my_option my_long_options[
{"allow-keywords", OPT_KEYWORDS,
"Allow creation of column names that are keywords.", (uchar**) &opt_keywords,
(uchar**) &opt_keywords, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"apply-slave-statements", OPT_MYSQLDUMP_SLAVE_APPLY,
+ "Adds 'STOP SLAVE' prior to 'CHANGE MASTER' and 'START SLAVE' to bottom of dump.",
+ (uchar**) &opt_slave_apply, (uchar**) &opt_slave_apply, 0, GET_BOOL, NO_ARG,
+ 0, 0, 0, 0, 0, 0},
#ifdef __NETWARE__
{"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
@@ -264,6 +273,19 @@ static struct my_option my_long_options[
{"disable-keys", 'K',
"'/*!40000 ALTER TABLE tb_name DISABLE KEYS */; and '/*!40000 ALTER TABLE tb_name ENABLE KEYS */; will be put in the output.", (uchar**) &opt_disable_keys,
(uchar**) &opt_disable_keys, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
+ {"dump-slave", OPT_MYSQLDUMP_SLAVE_DATA,
+ "This causes the binary log position and filename of the master to be "
+ "appended to the dumped data output. Setting the value to 1, will print"
+ "it as a CHANGE MASTER command in the dumped data output; if equal"
+ " to 2, that command will be prefixed with a comment symbol. "
+ "This option will turn --lock-all-tables on, unless "
+ "--single-transaction is specified too (in which case a "
+ "global read lock is only taken a short time at the beginning of the dump "
+ "- don't forget to read about --single-transaction below). In all cases "
+ "any action on logs will happen at the exact moment of the dump."
+ "Option automatically turns --lock-tables off.",
+ (uchar**) &opt_slave_data, (uchar**) &opt_slave_data, 0,
+ GET_UINT, OPT_ARG, 0, 0, MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL, 0, 0, 0},
{"events", 'E', "Dump events.",
(uchar**) &opt_events, (uchar**) &opt_events, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0},
@@ -317,6 +339,12 @@ static struct my_option my_long_options[
"use the directive multiple times, once for each table. Each table must "
"be specified with both database and table names, e.g. --ignore-table=database.table",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"include-master-host-port", OPT_MYSQLDUMP_INCLUDE_MASTER_HOST_PORT,
+ "Adds 'MASTER_HOST=<host>, MASTER_PORT=<port>' to 'CHANGE MASTER TO..' in dump produced with --dump-slave.",
+ (uchar**) &opt_include_master_host_port,
+ (uchar**) &opt_include_master_host_port,
+ 0, GET_BOOL, NO_ARG,
+ 0, 0, 0, 0, 0, 0},
{"insert-ignore", OPT_INSERT_IGNORE, "Insert rows with INSERT IGNORE.",
(uchar**) &opt_ignore, (uchar**) &opt_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0},
@@ -402,7 +430,7 @@ static struct my_option my_long_options[
(uchar**) &opt_routines, (uchar**) &opt_routines, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"set-charset", OPT_SET_CHARSET,
- "Add 'SET NAMES default_character_set' to the output. Enabled by default; suppress with --skip-set-charset.",
+ "Add 'SET NAMES default_character_set' to the output.",
(uchar**) &opt_set_charset, (uchar**) &opt_set_charset, 0, GET_BOOL, NO_ARG, 1,
0, 0, 0, 0, 0},
{"set-variable", 'O',
@@ -764,6 +792,10 @@ get_one_option(int optid, const struct m
if (!argument) /* work like in old versions */
opt_master_data= MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL;
break;
+ case (int) OPT_MYSQLDUMP_SLAVE_DATA:
+ if (!argument) /* work like in old versions */
+ opt_slave_data= MYSQL_OPT_SLAVE_DATA_EFFECTIVE_SQL;
+ break;
case (int) OPT_OPTIMIZE:
extended_insert= opt_drop= opt_lock= quick= create_options=
opt_disable_keys= lock_tables= opt_set_charset= 1;
@@ -897,6 +929,14 @@ static int get_options(int *argc, char *
return(EX_USAGE);
}
+ /* We don't delete master logs if slave data option */
+ if (opt_slave_data)
+ {
+ opt_lock_all_tables= !opt_single_transaction;
+ opt_master_data= 0;
+ opt_delete_master_logs= 0;
+ }
+
/* Ensure consistency of the set of binlog & locking options */
if (opt_delete_master_logs && !opt_master_data)
opt_master_data= MYSQL_OPT_MASTER_DATA_COMMENTED_SQL;
@@ -907,7 +947,10 @@ static int get_options(int *argc, char *
return(EX_USAGE);
}
if (opt_master_data)
+ {
opt_lock_all_tables= !opt_single_transaction;
+ opt_slave_data= 0;
+ }
if (opt_single_transaction || opt_lock_all_tables)
lock_tables= 0;
if (enclosed && opt_enclosed)
@@ -4334,6 +4377,130 @@ static int do_show_master_status(MYSQL *
return 0;
}
+static int do_stop_slave_sql(MYSQL *mysql_con)
+{
+ MYSQL_RES *slave;
+ /* We need to check if the slave sql is running in the first place */
+ if (mysql_query_with_error_report(mysql_con, &slave, "SHOW SLAVE STATUS"))
+ return(1);
+ else
+ {
+ MYSQL_ROW row= mysql_fetch_row(slave);
+ if (row && row[11])
+ {
+ /* if SLAVE SQL is not running, we don't stop it */
+ if (!strcmp(row[11],"No"))
+ {
+ mysql_free_result(slave);
+ /* Silently assume that they don't have the slave running */
+ return(0);
+ }
+ }
+ }
+ mysql_free_result(slave);
+
+ /* now, stop slave if running */
+ if (mysql_query_with_error_report(mysql_con, 0, "STOP SLAVE SQL_THREAD"))
+ return(1);
+
+ return(0);
+}
+
+static int add_stop_slave(void)
+{
+ if (opt_comments)
+ fprintf(md_result_file,
+ "\n--\n-- stop slave statement to make a recovery dump)\n--\n\n");
+ fprintf(md_result_file, "STOP SLAVE;\n");
+ return(0);
+}
+
+static int add_slave_statements(void)
+{
+ if (opt_comments)
+ fprintf(md_result_file,
+ "\n--\n-- start slave statement to make a recovery dump)\n--\n\n");
+ fprintf(md_result_file, "START SLAVE;\n");
+ return(0);
+}
+
+static int do_show_slave_status(MYSQL *mysql_con)
+{
+ MYSQL_RES *slave;
+ const char *comment_prefix=
+ (opt_slave_data == MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL) ? "-- " : "";
+ if (mysql_query_with_error_report(mysql_con, &slave, "SHOW SLAVE STATUS"))
+ {
+ if (!ignore_errors)
+ {
+ /* SHOW SLAVE STATUS reports nothing and --force is not enabled */
+ my_printf_error(0, "Error: Slave not set up", MYF(0));
+ }
+ mysql_free_result(slave);
+ return 1;
+ }
+ else
+ {
+ MYSQL_ROW row= mysql_fetch_row(slave);
+ if (row && row[9] && row[21])
+ {
+ /* SHOW MASTER STATUS reports file and position */
+ if (opt_comments)
+ fprintf(md_result_file,
+ "\n--\n-- Position to start replication or point-in-time "
+ "recovery from (the master of this slave)\n--\n\n");
+
+ fprintf(md_result_file, "%sCHANGE MASTER TO ", comment_prefix);
+
+ if (opt_include_master_host_port)
+ {
+ if (row[1])
+ fprintf(md_result_file, "MASTER_HOST='%s', ", row[1]);
+ if (row[3])
+ fprintf(md_result_file, "MASTER_PORT='%s', ", row[3]);
+ }
+ fprintf(md_result_file,
+ "MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;\n", row[9], row[21]);
+
+ check_io(md_result_file);
+ }
+ mysql_free_result(slave);
+ }
+ return 0;
+}
+
+static int do_start_slave_sql(MYSQL *mysql_con)
+{
+ MYSQL_RES *slave;
+ /* We need to check if the slave sql is stopped in the first place */
+ if (mysql_query_with_error_report(mysql_con, &slave, "SHOW SLAVE STATUS"))
+ return(1);
+ else
+ {
+ MYSQL_ROW row= mysql_fetch_row(slave);
+ if (row && row[11])
+ {
+ /* if SLAVE SQL is not running, we don't start it */
+ if (!strcmp(row[11],"Yes"))
+ {
+ mysql_free_result(slave);
+ /* Silently assume that they don't have the slave running */
+ return(0);
+ }
+ }
+ }
+ mysql_free_result(slave);
+
+ /* now, start slave if stopped */
+ if (mysql_query_with_error_report(mysql_con, 0, "START SLAVE"))
+ {
+ my_printf_error(0, "Error: Unable to start slave", MYF(0));
+ return 1;
+ }
+ return(0);
+}
+
+
static int do_flush_tables_read_lock(MYSQL *mysql_con)
{
@@ -4996,6 +5163,9 @@ int main(int argc, char **argv)
if (!path)
write_header(md_result_file, *argv);
+ if (opt_slave_data && do_stop_slave_sql(mysql))
+ goto err;
+
if ((opt_lock_all_tables || opt_master_data) &&
do_flush_tables_read_lock(mysql))
goto err;
@@ -5014,8 +5184,13 @@ int main(int argc, char **argv)
goto err;
flush_logs= 0; /* not anymore; that would not be sensible */
}
+ /* Add 'STOP SLAVE to beginning of dump */
+ if (opt_slave_apply && add_stop_slave())
+ goto err;
if (opt_master_data && do_show_master_status(mysql))
goto err;
+ if (opt_slave_data && do_show_slave_status(mysql))
+ goto err;
if (opt_single_transaction && do_unlock_tables(mysql)) /* unlock but no commit! */
goto err;
@@ -5043,6 +5218,14 @@ int main(int argc, char **argv)
dump_databases(argv);
}
+ /* if --dump-slave , start the slave sql thread */
+ if (opt_slave_data && do_start_slave_sql(mysql))
+ goto err;
+
+ /* add 'START SLAVE' to end of dump */
+ if (opt_slave_apply && add_slave_statements())
+ goto err;
+
/* ensure dumped data flushed */
if (md_result_file && fflush(md_result_file))
{
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc 2009-11-17 11:27:40 +0000
+++ b/client/mysqltest.cc 2009-11-20 14:18:37 +0000
@@ -75,7 +75,8 @@
enum {
OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION,
OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
- OPT_MAX_CONNECT_RETRIES, OPT_MARK_PROGRESS, OPT_LOG_DIR, OPT_TAIL_LINES
+ OPT_MAX_CONNECT_RETRIES, OPT_MARK_PROGRESS, OPT_LOG_DIR, OPT_TAIL_LINES,
+ OPT_RESULT_FORMAT_VERSION
};
static int record= 0, opt_sleep= -1;
@@ -88,6 +89,7 @@ const char *opt_logdir= "";
const char *opt_include= 0, *opt_charsets_dir;
static int opt_port= 0;
static int opt_max_connect_retries;
+static int opt_result_format_version;
static my_bool opt_compress= 0, silent= 0, verbose= 0;
static my_bool debug_info_flag= 0, debug_check_flag= 0;
static my_bool tty_password= 0;
@@ -284,11 +286,12 @@ enum enum_commands {
Q_SEND_QUIT, Q_CHANGE_USER, Q_MKDIR, Q_RMDIR,
Q_LIST_FILES, Q_LIST_FILES_WRITE_FILE, Q_LIST_FILES_APPEND_FILE,
Q_SEND_SHUTDOWN, Q_SHUTDOWN_SERVER,
+ Q_RESULT_FORMAT_VERSION,
Q_MOVE_FILE, Q_SEND_EVAL,
-
Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */
- Q_COMMENT_WITH_COMMAND
+ Q_COMMENT_WITH_COMMAND,
+ Q_EMPTY_LINE
};
@@ -378,6 +381,7 @@ const char *command_names[]=
"list_files_append_file",
"send_shutdown",
"shutdown_server",
+ "result_format",
"move_file",
"send_eval",
@@ -2193,6 +2197,59 @@ void var_query_set(VAR *var, const char
}
+static void
+set_result_format_version(ulong new_version)
+{
+ switch (new_version){
+ case 1:
+ /* The first format */
+ break;
+ case 2:
+ /* New format that also writes comments and empty lines
+ from test file to result */
+ break;
+ default:
+ die("Version format %lu has not yet been implemented", new_version);
+ break;
+ }
+ opt_result_format_version= new_version;
+}
+
+
+/*
+ Set the result format version to use when generating
+ the .result file
+*/
+
+static void
+do_result_format_version(struct st_command *command)
+{
+ long version;
+ static DYNAMIC_STRING ds_version;
+ const struct command_arg result_format_args[] = {
+ "version", ARG_STRING, TRUE, &ds_version, "Version to use",
+ };
+
+ DBUG_ENTER("do_result_format_version");
+
+ check_command_args(command, command->first_argument,
+ result_format_args,
+ sizeof(result_format_args)/sizeof(struct command_arg),
+ ',');
+
+ /* Convert version number to int */
+ if (!str2int(ds_version.str, 10, (long) 0, (long) INT_MAX, &version))
+ die("Invalid version number: '%s'", ds_version.str);
+
+ set_result_format_version(version);
+
+ dynstr_append(&ds_res, "result_format: ");
+ dynstr_append_mem(&ds_res, ds_version.str, ds_version.length);
+ dynstr_append(&ds_res, "\n");
+ dynstr_free(&ds_version);
+}
+
+
/*
Set variable from the result of a field in a query
@@ -5273,7 +5330,7 @@ my_bool end_of_query(int c)
int read_line(char *buf, int size)
{
- char c, UNINIT_VAR(last_quote);
+ char c, UNINIT_VAR(last_quote), last_char= 0;
char *p= buf, *buf_end= buf + size - 1;
int skip_char= 0;
enum {R_NORMAL, R_Q, R_SLASH_IN_Q,
@@ -5371,14 +5428,24 @@ int read_line(char *buf, int size)
}
else if (my_isspace(charset_info, c))
{
- /* Skip all space at begining of line */
if (c == '\n')
{
+ if (last_char == '\n')
+ {
+ /* Two new lines in a row, return empty line */
+ DBUG_PRINT("info", ("Found two new lines in a row"));
+ *p++= c;
+ *p= 0;
+ DBUG_RETURN(0);
+ }
+
/* Query hasn't started yet */
start_lineno= cur_file->lineno;
DBUG_PRINT("info", ("Query hasn't started yet, start_lineno: %d",
start_lineno));
}
+
+ /* Skip all space at begining of line */
skip_char= 1;
}
else if (end_of_query(c))
@@ -5419,6 +5486,8 @@ int read_line(char *buf, int size)
}
+ last_char= c;
+
if (!skip_char)
{
/* Could be a multibyte character */
@@ -5628,9 +5697,10 @@ int read_command(struct st_command** com
DBUG_RETURN(1);
}
- convert_to_format_v1(read_command_buf);
+ if (opt_result_format_version == 1)
+ convert_to_format_v1(read_command_buf);
- DBUG_PRINT("info", ("query: %s", read_command_buf));
+ DBUG_PRINT("info", ("query: '%s'", read_command_buf));
if (*p == '#')
{
command->type= Q_COMMENT;
@@ -5640,6 +5710,10 @@ int read_command(struct st_command** com
command->type= Q_COMMENT_WITH_COMMAND;
p+= 2; /* Skip past -- */
}
+ else if (*p == '\n')
+ {
+ command->type= Q_EMPTY_LINE;
+ }
/* Skip leading spaces */
while (*p && my_isspace(charset_info, *p))
@@ -5734,6 +5808,11 @@ static struct my_option my_long_options[
{"result-file", 'R', "Read/Store result from/in this file.",
(uchar**) &result_file_name, (uchar**) &result_file_name, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"result-format-version", OPT_RESULT_FORMAT_VERSION,
+ "Version of the result file format to use",
+ (uchar**) &opt_result_format_version,
+ (uchar**) &opt_result_format_version, 0,
+ GET_INT, REQUIRED_ARG, 1, 1, 2, 0, 0, 0},
{"server-arg", 'A', "Send option value to embedded server as a parameter.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"server-file", 'F', "Read embedded server arguments from file.",
@@ -5943,6 +6022,9 @@ get_one_option(int optid, const struct m
sf_malloc_quick=1;
#endif
break;
+ case OPT_RESULT_FORMAT_VERSION:
+ set_result_format_version(opt_result_format_version);
+ break;
case 'V':
print_version();
exit(0);
@@ -7818,6 +7900,7 @@ int main(int argc, char **argv)
case Q_MOVE_FILE: do_move_file(command); break;
case Q_CHMOD_FILE: do_chmod_file(command); break;
case Q_PERL: do_perl(command); break;
+ case Q_RESULT_FORMAT_VERSION: do_result_format_version(command); break;
case Q_DELIMITER:
do_delimiter(command);
break;
@@ -7935,9 +8018,38 @@ int main(int argc, char **argv)
do_sync_with_master2(command, 0);
break;
}
- case Q_COMMENT: /* Ignore row */
+ case Q_COMMENT:
+ {
command->last_argument= command->end;
+
+ /* Don't output comments in v1 */
+ if (opt_result_format_version == 1)
+ break;
+
+ /* Don't output comments if query logging is off */
+ if (disable_query_log)
+ break;
+
+ /* Write comment's with two starting #'s to result file */
+ const char* p= command->query;
+ if (p && *p == '#' && *(p+1) == '#')
+ {
+ dynstr_append_mem(&ds_res, command->query, command->query_len);
+ dynstr_append(&ds_res, "\n");
+ }
break;
+ }
+ case Q_EMPTY_LINE:
+ /* Don't output newline in v1 */
+ if (opt_result_format_version == 1)
+ break;
+
+ /* Don't output newline if query logging is off */
+ if (disable_query_log)
+ break;
+
+ dynstr_append(&ds_res, "\n");
+ break;
case Q_PING:
handle_command_error(command, mysql_ping(&cur_con->mysql));
break;
=== modified file 'client/sql_string.cc'
--- a/client/sql_string.cc 2009-03-24 13:58:52 +0000
+++ b/client/sql_string.cc 2009-11-11 20:19:41 +0000
@@ -23,6 +23,7 @@
#include <my_sys.h>
#include <m_string.h>
#include <m_ctype.h>
+#include <mysql_com.h>
#ifdef HAVE_FCONVERT
#include <floatingpoint.h>
#endif
=== modified file 'client/sql_string.h'
--- a/client/sql_string.h 2009-09-23 21:32:31 +0000
+++ b/client/sql_string.h 2009-11-11 20:19:41 +0000
@@ -22,10 +22,6 @@
#pragma interface /* gcc class implementation */
#endif
-#ifndef NOT_FIXED_DEC
-#define NOT_FIXED_DEC 31
-#endif
-
class String;
int sortcmp(const String *a,const String *b, CHARSET_INFO *cs);
String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
=== modified file 'config/ac-macros/misc.m4'
--- a/config/ac-macros/misc.m4 2009-07-30 15:24:09 +0000
+++ b/config/ac-macros/misc.m4 2009-11-11 20:43:31 +0000
@@ -601,15 +601,15 @@ dnl ------------------------------------
dnl MYSQL_NEEDS_MYSYS_NEW
AC_DEFUN([MYSQL_NEEDS_MYSYS_NEW],
-[AC_CACHE_CHECK([needs mysys_new helpers], mysql_use_mysys_new,
+[AC_CACHE_CHECK([needs mysys_new helpers], mysql_cv_use_mysys_new,
[
AC_LANG_PUSH(C++)
AC_TRY_LINK([], [
class A { public: int b; }; A *a=new A; a->b=10; delete a;
-], mysql_use_mysys_new=no, mysql_use_mysys_new=yes)
+], mysql_cv_use_mysys_new=no, mysql_cv_use_mysys_new=yes)
AC_LANG_POP(C++)
])
-if test "$mysql_use_mysys_new" = "yes"
+if test "$mysql_cv_use_mysys_new" = "yes"
then
AC_DEFINE([USE_MYSYS_NEW], [1], [Needs to use mysys_new helpers])
fi
=== modified file 'include/m_string.h'
--- a/include/m_string.h 2009-11-02 20:05:42 +0000
+++ b/include/m_string.h 2009-11-19 23:48:08 +0000
@@ -260,4 +260,73 @@ typedef struct st_mysql_lex_string LEX_S
#define USTRING_WITH_LEN(X) ((uchar*) X), ((size_t) (sizeof(X) - 1))
#define C_STRING_WITH_LEN(X) ((char *) (X)), ((size_t) (sizeof(X) - 1))
+/* SPACE_INT is a word that contains only spaces */
+#if SIZEOF_INT == 4
+#define SPACE_INT 0x20202020
+#elif SIZEOF_INT == 8
+#define SPACE_INT 0x2020202020202020
+#else
+#error define the appropriate constant for a word full of spaces
+#endif
+
+/**
+ Skip trailing space.
+
+ On most systems reading memory in larger chunks (ideally equal to the size of
+ the chinks that the machine physically reads from memory) causes fewer memory
+ access loops and hence increased performance.
+ This is why the 'int' type is used : it's closest to that (according to how
+ it's defined in C).
+ So when we determine the amount of whitespace at the end of a string we do
+ the following :
+ 1. We divide the string into 3 zones :
+ a) from the start of the string (__start) to the first multiple
+ of sizeof(int) (__start_words)
+ b) from the end of the string (__end) to the last multiple of sizeof(int)
+ (__end_words)
+ c) a zone that is aligned to sizeof(int) and can be safely accessed
+ through an int *
+ 2. We start comparing backwards from (c) char-by-char. If all we find is
+ space then we continue
+ 3. If there are elements in zone (b) we compare them as unsigned ints to a
+ int mask (SPACE_INT) consisting of all spaces
+ 4. Finally we compare the remaining part (a) of the string char by char.
+ This covers for the last non-space unsigned int from 3. (if any)
+
+ This algorithm works well for relatively larger strings, but it will slow
+ the things down for smaller strings (because of the additional calculations
+ and checks compared to the naive method). Thus the barrier of length 20
+ is added.
+
+ @param ptr pointer to the input string
+ @param len the length of the string
+ @return the last non-space character
+*/
+
+static inline const uchar *skip_trailing_space(const uchar *ptr,size_t len)
+{
+ const uchar *end= ptr + len;
+
+ if (len > 20)
+ {
+ const uchar *end_words= (const uchar *)(intptr)
+ (((ulonglong)(intptr)end) / SIZEOF_INT * SIZEOF_INT);
+ const uchar *start_words= (const uchar *)(intptr)
+ ((((ulonglong)(intptr)ptr) + SIZEOF_INT - 1) / SIZEOF_INT * SIZEOF_INT);
+
+ DBUG_ASSERT(((ulonglong)(intptr)ptr) >= SIZEOF_INT);
+ if (end_words > ptr)
+ {
+ while (end > end_words && end[-1] == 0x20)
+ end--;
+ if (end[-1] == 0x20 && start_words < end_words)
+ while (end > start_words && ((unsigned *)end)[-1] == SPACE_INT)
+ end -= SIZEOF_INT;
+ }
+ }
+ while (end > ptr && end[-1] == 0x20)
+ end--;
+ return (end);
+}
+
#endif
=== modified file 'include/mysql_com.h'
--- a/include/mysql_com.h 2009-11-02 11:10:04 +0000
+++ b/include/mysql_com.h 2009-11-11 20:19:41 +0000
@@ -524,4 +524,5 @@ uchar *net_store_length(uchar *pkg, ulon
#define MYSQL_STMT_HEADER 4
#define MYSQL_LONG_DATA_HEADER 6
+#define NOT_FIXED_DEC 31
#endif
=== modified file 'include/violite.h'
--- a/include/violite.h 2009-11-02 22:19:58 +0000
+++ b/include/violite.h 2009-11-19 23:48:08 +0000
@@ -51,9 +51,6 @@ Vio* vio_new_win32shared_memory(HANDLE h
HANDLE event_client_wrote,
HANDLE event_client_read,
HANDLE event_conn_closed);
-size_t vio_read_pipe(Vio *vio, uchar * buf, size_t size);
-size_t vio_write_pipe(Vio *vio, const uchar * buf, size_t size);
-int vio_close_pipe(Vio * vio);
#else
#define HANDLE void *
#endif /* __WIN__ */
@@ -87,7 +84,8 @@ my_socket vio_fd(Vio*vio);
my_bool vio_peer_addr(Vio* vio, char *buf, uint16 *port);
/* Remotes in_addr */
void vio_in_addr(Vio *vio, struct in_addr *in);
-my_bool vio_poll_read(Vio *vio,uint timeout);
+my_bool vio_poll_read(Vio *vio, uint timeout);
+my_bool vio_is_connected(Vio *vio);
#ifdef HAVE_OPENSSL
#include <openssl/opensslv.h>
@@ -136,12 +134,6 @@ struct st_VioSSLFd
void free_vio_ssl_acceptor_fd(struct st_VioSSLFd *fd);
#endif /* HAVE_OPENSSL */
-#ifdef HAVE_SMEM
-size_t vio_read_shared_memory(Vio *vio, uchar * buf, size_t size);
-size_t vio_write_shared_memory(Vio *vio, const uchar * buf, size_t size);
-int vio_close_shared_memory(Vio * vio);
-#endif
-
void vio_end(void);
#ifdef __cplusplus
@@ -164,6 +156,8 @@ void vio_end(void);
#define vio_peer_addr(vio, buf, prt) (vio)->peer_addr(vio, buf, prt)
#define vio_in_addr(vio, in) (vio)->in_addr(vio, in)
#define vio_timeout(vio, which, seconds) (vio)->timeout(vio, which, seconds)
+#define vio_poll_read(vio, timeout) (vio)->poll_read(vio, timeout)
+#define vio_is_connected(vio) (vio)->is_connected(vio)
#endif /* !defined(DONT_MAP_VIO) */
/* This enumerator is used in parser - should be always visible */
@@ -208,6 +202,8 @@ struct st_vio
my_bool (*was_interrupted)(Vio*);
int (*vioclose)(Vio*);
void (*timeout)(Vio*, unsigned int which, unsigned int timeout);
+ my_bool (*poll_read)(Vio *vio, uint timeout);
+ my_bool (*is_connected)(Vio*);
#ifdef HAVE_OPENSSL
void *ssl_arg;
#endif
=== modified file 'libmysql/libmysql.c'
--- a/libmysql/libmysql.c 2009-11-10 07:31:33 +0000
+++ b/libmysql/libmysql.c 2009-11-19 23:48:08 +0000
@@ -3478,10 +3478,7 @@ static void fetch_float_with_conversion(
*/
char buff[MAX_DOUBLE_STRING_REP_LENGTH];
char *end;
- /* TODO: move this to a header shared between client and server. */
-#define NOT_FIXED_DEC 31
if (field->decimals >= NOT_FIXED_DEC)
-#undef NOT_FIXED_DEC
{
/*
DBL_DIG below is to ensure that the server and client has the same
=== modified file 'libmysqld/lib_sql.cc'
--- a/libmysqld/lib_sql.cc 2009-10-23 11:22:21 +0000
+++ b/libmysqld/lib_sql.cc 2009-11-20 14:18:37 +0000
@@ -119,7 +119,6 @@ emb_advanced_command(MYSQL *mysql, enum
thd->current_stmt= stmt;
thd->store_globals(); // Fix if more than one connect
- lex_start(thd);
/*
We have to call free_old_query before we start to fill mysql->fields
for new query. In the case of embedded server we collect field data
@@ -138,6 +137,7 @@ emb_advanced_command(MYSQL *mysql, enum
result= dispatch_command(command, thd, (char *) arg, arg_length);
thd->cur_data= 0;
+ thd->mysys_var= NULL;
if (!skip_check)
result= thd->is_error() ? -1 : 0;
=== modified file 'mysql-test/r/alias.result'
--- a/mysql-test/r/alias.result 2005-06-27 11:12:10 +0000
+++ b/mysql-test/r/alias.result 2009-11-10 20:43:43 +0000
@@ -73,3 +73,142 @@ UPDATE t1 SET t1.xstatus_vor = Greatest(
"40004712" AND t1.plnfl = "000001" AND t1.vornr > "0010" ORDER BY t1.vornr
ASC LIMIT 1;
drop table t1;
+drop table if exists t1,t2,t3;
+create table t1 (a int, b int, c int);
+create table t2 (d int);
+create table t3 (a1 int, b1 int, c1 int);
+insert into t1 values(1,2,3);
+insert into t1 values(11,22,33);
+insert into t2 values(99);
+select t1.* as 'with_alias' from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias' from t1' at line 1
+select t2.* as 'with_alias' from t2;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias' from t2' at line 1
+select t1.*, t1.* as 'with_alias' from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias' from t1' at line 1
+select t1.* as 'with_alias', t1.* from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias', t1.* from t1' at line 1
+select t1.* as 'with_alias', t1.* as 'alias2' from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias', t1.* as 'alias2' from t1' at line 1
+select t1.* as 'with_alias', a, t1.* as 'alias2' from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias', a, t1.* as 'alias2' from t1' at line 1
+select a, t1.* as 'with_alias' from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias' from t1' at line 1
+select t1.* as 'with_alias', a from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias', a from t1' at line 1
+select a, t1.* as 'with_alias', b from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias', b from t1' at line 1
+select (select d from t2 where d > a), t1.* as 'with_alias' from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias' from t1' at line 1
+select t1.* as 'with_alias', (select a from t2 where d > a) from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias', (select a from t2 where d > a) from t1' at line 1
+select a as 'x', t1.* as 'with_alias' from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias' from t1' at line 1
+select t1.* as 'with_alias', a as 'x' from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias', a as 'x' from t1' at line 1
+select a as 'x', t1.* as 'with_alias', b as 'x' from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias', b as 'x' from t1' at line 1
+select (select d from t2 where d > a) as 'x', t1.* as 'with_alias' from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias' from t1' at line 1
+select t1.* as 'with_alias', (select a from t2 where d > a) as 'x' from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias', (select a from t2 where d > a) as 'x' from t1' at line 1
+select (select t2.* as 'x' from t2) from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'x' from t2) from t1' at line 1
+select a, (select t2.* as 'x' from t2) from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'x' from t2) from t1' at line 1
+select t1.*, (select t2.* as 'x' from t2) from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'x' from t2) from t1' at line 1
+insert into t3 select t1.* as 'with_alias' from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias' from t1' at line 1
+insert into t3 select t2.* as 'with_alias', 1, 2 from t2;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias', 1, 2 from t2' at line 1
+insert into t3 select t2.* as 'with_alias', d as 'x', d as 'z' from t2;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias', d as 'x', d as 'z' from t2' at line 1
+insert into t3 select t2.*, t2.* as 'with_alias', 3 from t2;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias', 3 from t2' at line 1
+create table t3 select t1.* as 'with_alias' from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias' from t1' at line 1
+create table t3 select t2.* as 'with_alias', 1, 2 from t2;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias', 1, 2 from t2' at line 1
+create table t3 select t2.* as 'with_alias', d as 'x', d as 'z' from t2;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias', d as 'x', d as 'z' from t2' at line 1
+create table t3 select t2.*, t2.* as 'with_alias', 3 from t2;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'with_alias', 3 from t2' at line 1
+select t1.* from t1;
+a b c
+1 2 3
+11 22 33
+select t2.* from t2;
+d
+99
+select t1.*, t1.* from t1;
+a b c a b c
+1 2 3 1 2 3
+11 22 33 11 22 33
+select t1.*, a, t1.* from t1;
+a b c a a b c
+1 2 3 1 1 2 3
+11 22 33 11 11 22 33
+select a, t1.* from t1;
+a a b c
+1 1 2 3
+11 11 22 33
+select t1.*, a from t1;
+a b c a
+1 2 3 1
+11 22 33 11
+select a, t1.*, b from t1;
+a a b c b
+1 1 2 3 2
+11 11 22 33 22
+select (select d from t2 where d > a), t1.* from t1;
+(select d from t2 where d > a) a b c
+99 1 2 3
+99 11 22 33
+select t1.*, (select a from t2 where d > a) from t1;
+a b c (select a from t2 where d > a)
+1 2 3 1
+11 22 33 11
+select a as 'x', t1.* from t1;
+x a b c
+1 1 2 3
+11 11 22 33
+select t1.*, a as 'x' from t1;
+a b c x
+1 2 3 1
+11 22 33 11
+select a as 'x', t1.*, b as 'x' from t1;
+x a b c x
+1 1 2 3 2
+11 11 22 33 22
+select (select d from t2 where d > a) as 'x', t1.* from t1;
+x a b c
+99 1 2 3
+99 11 22 33
+select t1.*, (select a from t2 where d > a) as 'x' from t1;
+a b c x
+1 2 3 1
+11 22 33 11
+select (select t2.* from t2) from t1;
+(select t2.* from t2)
+99
+99
+select a, (select t2.* from t2) from t1;
+a (select t2.* from t2)
+1 99
+11 99
+select t1.*, (select t2.* from t2) from t1;
+a b c (select t2.* from t2)
+1 2 3 99
+11 22 33 99
+insert into t3 select t1.* from t1;
+insert into t3 select t2.*, 1, 2 from t2;
+insert into t3 select t2.*, d as 'x', d as 'z' from t2;
+insert into t3 select t2.*, t2.*, 3 from t2;
+create table t4 select t1.* from t1;
+drop table t4;
+create table t4 select t2.*, 1, 2 from t2;
+drop table t4;
+create table t4 select t2.*, d as 'x', d as 'z' from t2;
+drop table t4;
+drop table t1,t2,t3;
=== modified file 'mysql-test/r/delete.result'
--- a/mysql-test/r/delete.result 2009-09-28 10:48:52 +0000
+++ b/mysql-test/r/delete.result 2009-11-10 18:48:46 +0000
@@ -259,8 +259,8 @@ ERROR 42S02: Unknown table 't2' in MULTI
DELETE FROM db1.t1 alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a' at line 1
DELETE FROM alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
-ERROR 42S02: Unknown table 'alias' in MULTI DELETE
DELETE FROM db2.alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
+ERROR 42S02: Unknown table 'alias' in MULTI DELETE
DELETE FROM t1 USING t1 WHERE a = 1;
SELECT * FROM t1;
a
@@ -279,6 +279,147 @@ ERROR 42000: Incorrect number of argumen
DROP TABLE t1;
DROP FUNCTION f1;
End of 5.0 tests
+DROP DATABASE IF EXISTS db1;
+DROP DATABASE IF EXISTS db2;
+DROP DATABASE IF EXISTS db3;
+DROP DATABASE IF EXISTS db4;
+DROP TABLE IF EXISTS t1, t2;
+DROP PROCEDURE IF EXISTS count;
+USE test;
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+CREATE TABLE db1.t1 (a INT, b INT);
+INSERT INTO db1.t1 VALUES (1,1),(2,2),(3,3);
+CREATE TABLE db1.t2 AS SELECT * FROM db1.t1;
+CREATE TABLE db2.t1 AS SELECT * FROM db1.t2;
+CREATE TABLE db2.t2 AS SELECT * FROM db2.t1;
+CREATE TABLE t1 AS SELECT * FROM db2.t2;
+CREATE TABLE t2 AS SELECT * FROM t1;
+CREATE PROCEDURE count_rows()
+BEGIN
+SELECT COUNT(*) AS "COUNT(db1.t1)" FROM db1.t1;
+SELECT COUNT(*) AS "COUNT(db1.t2)" FROM db1.t2;
+SELECT COUNT(*) AS "COUNT(db2.t1)" FROM db2.t1;
+SELECT COUNT(*) AS "COUNT(db2.t2)" FROM db2.t2;
+SELECT COUNT(*) AS "COUNT(test.t1)" FROM test.t1;
+SELECT COUNT(*) AS "COUNT(test.t2)" FROM test.t2;
+END|
+CREATE DATABASE db3;
+USE db3;
+DROP DATABASE db3;
+SELECT * FROM t1;
+ERROR 3D000: No database selected
+DELETE a1,a2 FROM db1.t1, db2.t2;
+ERROR 3D000: No database selected
+DELETE a1,a2 FROM db1.t1, db2.t2;
+ERROR 3D000: No database selected
+DELETE a1,a2 FROM db1.t1 AS a1, db2.t2;
+ERROR 3D000: No database selected
+DELETE a1,a2 FROM db1.t1, db2.t2 AS a2;
+ERROR 3D000: No database selected
+DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
+ERROR 3D000: No database selected
+DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
+ERROR 3D000: No database selected
+DELETE FROM a1,a2 USING db1.t1, db2.t2;
+ERROR 3D000: No database selected
+DELETE FROM a1,a2 USING db1.t1, db2.t2;
+ERROR 3D000: No database selected
+DELETE FROM a1,a2 USING db1.t1 AS a1, db2.t2;
+ERROR 3D000: No database selected
+DELETE FROM a1,a2 USING db1.t1, db2.t2 AS a2;
+ERROR 3D000: No database selected
+DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
+ERROR 3D000: No database selected
+DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
+ERROR 3D000: No database selected
+DELETE a1 FROM db1.t1 AS a1, db2.t2 AS a1;
+ERROR 3D000: No database selected
+DELETE a1 FROM db1.a1, db2.t2 AS a1;
+ERROR 3D000: No database selected
+DELETE a1 FROM a1, db1.t1 AS a1;
+ERROR 3D000: No database selected
+DELETE t1 FROM db1.t1, db2.t1 AS a1;
+ERROR 3D000: No database selected
+DELETE t1 FROM db1.t1 AS a1, db2.t1 AS a2;
+ERROR 3D000: No database selected
+DELETE t1 FROM db1.t1, db2.t1;
+ERROR 3D000: No database selected
+USE test;
+DELETE a1,a2 FROM db1.t1, db2.t2;
+ERROR 42S02: Unknown table 'a1' in MULTI DELETE
+DELETE a1,a2 FROM db1.t1, db2.t2;
+ERROR 42S02: Unknown table 'a1' in MULTI DELETE
+DELETE a1,a2 FROM db1.t1 AS a1, db2.t2;
+ERROR 42S02: Unknown table 'a2' in MULTI DELETE
+DELETE a1,a2 FROM db1.t1, db2.t2 AS a2;
+ERROR 42S02: Unknown table 'a1' in MULTI DELETE
+DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
+ERROR 42S02: Table 'db3.t1' doesn't exist
+DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
+ERROR 42S02: Table 'db3.t1' doesn't exist
+DELETE FROM a1,a2 USING db1.t1, db2.t2;
+ERROR 42S02: Unknown table 'a1' in MULTI DELETE
+DELETE FROM a1,a2 USING db1.t1, db2.t2;
+ERROR 42S02: Unknown table 'a1' in MULTI DELETE
+DELETE FROM a1,a2 USING db1.t1 AS a1, db2.t2;
+ERROR 42S02: Unknown table 'a2' in MULTI DELETE
+DELETE FROM a1,a2 USING db1.t1, db2.t2 AS a2;
+ERROR 42S02: Unknown table 'a1' in MULTI DELETE
+DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
+ERROR 42S02: Table 'db3.t1' doesn't exist
+DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
+ERROR 42S02: Table 'db3.t1' doesn't exist
+DELETE a1 FROM db1.t1 AS a1, db2.t2 AS a1;
+ERROR 42000: Not unique table/alias: 'a1'
+DELETE a1 FROM db1.a1, db2.t2 AS a1;
+ERROR 42S02: Table 'db1.a1' doesn't exist
+DELETE a1 FROM a1, db1.t1 AS a1;
+ERROR 42000: Not unique table/alias: 'a1'
+DELETE t1 FROM db1.t1, db2.t1 AS a1;
+ERROR 42S02: Unknown table 't1' in MULTI DELETE
+DELETE t1 FROM db1.t1 AS a1, db2.t1 AS a2;
+ERROR 42S02: Unknown table 't1' in MULTI DELETE
+DELETE t1 FROM db1.t1, db2.t1;
+ERROR 42S02: Unknown table 't1' in MULTI DELETE
+DELETE t1 FROM db1.t2 AS t1, db2.t2 AS t2 WHERE t2.a = 1 AND t1.a = t2.a;
+SELECT ROW_COUNT();
+ROW_COUNT()
+1
+CALL count_rows();
+COUNT(db1.t1)
+3
+COUNT(db1.t2)
+2
+COUNT(db2.t1)
+3
+COUNT(db2.t2)
+3
+COUNT(test.t1)
+3
+COUNT(test.t2)
+3
+DELETE a1, a2 FROM db2.t1 AS a1, t2 AS a2 WHERE a1.a = 2 AND a2.a = 2;
+SELECT ROW_COUNT();
+ROW_COUNT()
+2
+CALL count_rows();
+COUNT(db1.t1)
+3
+COUNT(db1.t2)
+2
+COUNT(db2.t1)
+2
+COUNT(db2.t2)
+3
+COUNT(test.t1)
+3
+COUNT(test.t2)
+2
+DROP DATABASE db1;
+DROP DATABASE db2;
+DROP PROCEDURE count_rows;
+DROP TABLE t1, t2;
#
# Bug#46958: Assertion in Diagnostics_area::set_ok_status, trigger,
# merge table
=== modified file 'mysql-test/r/derived.result'
--- a/mysql-test/r/derived.result 2009-07-11 18:44:29 +0000
+++ b/mysql-test/r/derived.result 2009-11-10 18:48:46 +0000
@@ -277,7 +277,7 @@ select * from t1;
N M
3 0
delete P1.*,p2.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS p2 ON P1.N = p2.N;
-ERROR 42S02: Unknown table 'p2' in MULTI DELETE
+ERROR HY000: The target table p2 of the DELETE is not updatable
delete P1.* from `t1` AS P1 INNER JOIN (SELECT aaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
ERROR 42S22: Unknown column 'aaa' in 'field list'
drop table t1;
=== modified file 'mysql-test/r/dirty_close.result'
--- a/mysql-test/r/dirty_close.result 2009-03-03 20:34:18 +0000
+++ b/mysql-test/r/dirty_close.result 2009-11-10 19:09:27 +0000
@@ -7,3 +7,13 @@ n
2
3
DROP TABLE t1;
+SELECT GET_LOCK("dangling", 0);
+GET_LOCK("dangling", 0)
+1
+SELECT GET_LOCK('dangling', 3600);;
+SELECT GET_LOCK('dangling', 3600);;
+SELECT RELEASE_LOCK('dangling');
+RELEASE_LOCK('dangling')
+1
+GET_LOCK('dangling', 3600)
+1
=== modified file 'mysql-test/r/func_sapdb.result'
--- a/mysql-test/r/func_sapdb.result 2009-10-13 16:50:08 +0000
+++ b/mysql-test/r/func_sapdb.result 2009-11-04 09:17:39 +0000
@@ -282,3 +282,33 @@ TIMEDIFF(TIME('17:59:00'),TIME('17:00:00
TIMEDIFF(TIME('17:00:00'),TIME('17:59:00'));
1Eq 1NEq1 1NEq2 2Eq 2NEq1 2NEq2 3Eq 3NEq1 3NEq2 Time0 Time00 Literal0000 TIMEDIFF(TIME('17:59:00'),TIME('17:00:00')) TIMEDIFF(TIME('17:00:00'),TIME('17:59:00'))
1 0 0 1 0 0 1 0 0 00:00:00 00:00:00 00:00:00 00:59:00 -00:59:00
+SELECT sec_to_time(3020399)=TIME('838:59:59');
+sec_to_time(3020399)=TIME('838:59:59')
+1
+SELECT sec_to_time(-3020399)=TIME('-838:59:59');
+sec_to_time(-3020399)=TIME('-838:59:59')
+1
+SELECT sec_to_time(-3020399)='-838:59:59';
+sec_to_time(-3020399)='-838:59:59'
+1
+SELECT time(sec_to_time(-3020399))=TIME('-838:59:59');
+time(sec_to_time(-3020399))=TIME('-838:59:59')
+1
+SELECT time(sec_to_time(-3020399))=TIME('-838:59:58');
+time(sec_to_time(-3020399))=TIME('-838:59:58')
+0
+SELECT maketime(-1,0,1)='-01:00:01';
+maketime(-1,0,1)='-01:00:01'
+1
+SELECT TIME(maketime(-1,0,1))=CAST('-01:00:01' AS TIME);
+TIME(maketime(-1,0,1))=CAST('-01:00:01' AS TIME)
+1
+SELECT maketime(-1,0,1)=CAST('-01:00:01' AS TIME);
+maketime(-1,0,1)=CAST('-01:00:01' AS TIME)
+1
+SELECT maketime(1,0,1)=CAST('01:00:01' AS TIME);
+maketime(1,0,1)=CAST('01:00:01' AS TIME)
+1
+SELECT maketime(1,0,1)=CAST('01:00:02' AS TIME);
+maketime(1,0,1)=CAST('01:00:02' AS TIME)
+0
=== modified file 'mysql-test/r/func_time.result'
--- a/mysql-test/r/func_time.result 2009-10-13 16:50:08 +0000
+++ b/mysql-test/r/func_time.result 2009-11-03 22:29:16 +0000
@@ -1301,6 +1301,12 @@ SELECT '2008-02-18' + INTERVAL 1 FRAC_SE
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FRAC_SECOND' at line 1
SELECT '2008-02-18' - INTERVAL 1 FRAC_SECOND;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FRAC_SECOND' at line 1
+select date_add('1000-01-01 00:00:00', interval '1.03:02:01.05' day_microsecond);
+date_add('1000-01-01 00:00:00', interval '1.03:02:01.05' day_microsecond)
+1000-01-02 03:02:01.050000
+select date_add('1000-01-01 00:00:00', interval '1.02' day_microsecond);
+date_add('1000-01-01 00:00:00', interval '1.02' day_microsecond)
+1000-01-01 00:00:01.020000
End of 5.0 tests
select date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND);
date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND)
=== modified file 'mysql-test/r/mysql.result'
--- a/mysql-test/r/mysql.result 2009-10-15 12:23:43 +0000
+++ b/mysql-test/r/mysql.result 2009-11-04 12:20:02 +0000
@@ -201,6 +201,202 @@ COUNT (*)
ERROR 2005 (HY000) at line 1: Unknown MySQL server host 'invalid_hostname' (errno)
End of 5.0 tests
WARNING: --server-arg option not supported in this configuration.
+*************************** 1. row ***************************
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+0: 0
++---+
+| 1 |
++---+
+| 1 |
++---+
Warning (Code 1286): Unknown table engine 'nonexistent'
Warning (Code 1266): Using storage engine MyISAM for table 't2'
Warning (Code 1286): Unknown table engine 'nonexistent2'
=== added file 'mysql-test/r/partition_sync.result'
--- a/mysql-test/r/partition_sync.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/partition_sync.result 2009-11-04 11:59:46 +0000
@@ -0,0 +1,25 @@
+#
+# Bug #43867 ALTER TABLE on a partitioned table
+# causes unnecessary deadlocks
+#
+CREATE TABLE t1 (a int) PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (1),
+PARTITION p1 VALUES LESS THAN (2));
+INSERT INTO t1 VALUES (0),(1);
+# Connection 2
+BEGIN;
+SELECT * FROM t1;
+a
+0
+1
+# Connection 1
+ALTER TABLE t1 DROP PARTITION p3;
+ERROR HY000: Error in list of partitions to DROP
+# Connection 2
+# This failed with deadlock and should not do so.
+SELECT * FROM t1;
+a
+0
+1
+# Connection 1
+DROP TABLE t1;
=== added file 'mysql-test/r/rpl_mysqldump_slave.result'
--- a/mysql-test/r/rpl_mysqldump_slave.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/rpl_mysqldump_slave.result 2009-11-04 13:31:03 +0000
@@ -0,0 +1,17 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+#
+# New --dump-slave, --apply-slave-statements functionality
+#
+use test;
+CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=107;
+STOP SLAVE;
+CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=107;
+START SLAVE;
+STOP SLAVE;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT='MASTER_MYPORT', MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=107;
+START SLAVE;
=== modified file 'mysql-test/r/sp-error.result'
--- a/mysql-test/r/sp-error.result 2009-11-05 09:20:41 +0000
+++ b/mysql-test/r/sp-error.result 2009-11-19 23:48:08 +0000
@@ -1659,6 +1659,18 @@ begin
declare continue handler for sqlstate '00000' set @x=0;
end$$
ERROR 42000: Bad SQLSTATE: '00000'
+drop procedure if exists p1;
+set @old_recursion_depth = @@max_sp_recursion_depth;
+set @@max_sp_recursion_depth = 255;
+create procedure p1(a int)
+begin
+declare continue handler for 1436 -- ER_STACK_OVERRUN_NEED_MORE
+select 'exception';
+call p1(a+1);
+end|
+call p1(1);
+set @@max_sp_recursion_depth = @old_recursion_depth;
+drop procedure p1;
LOAD DATA INFILE '../../tmp/proc.txt' INTO TABLE mysql.proc;
CREATE TABLE t1 (a INT, b INT);
INSERT INTO t1 VALUES (1,1), (2,2);
=== modified file 'mysql-test/r/sp.result'
--- a/mysql-test/r/sp.result 2009-11-06 14:20:27 +0000
+++ b/mysql-test/r/sp.result 2009-11-19 23:48:08 +0000
@@ -6941,6 +6941,101 @@ SELECT * FROM t1 WHERE a = f1();
ERROR 42S02: Table 'test.t_non_existing' doesn't exist
DROP FUNCTION f1;
DROP TABLE t1;
+DROP PROCEDURE IF EXISTS p1;
+CREATE PROCEDURE p1(a INT, b CHAR)
+BEGIN
+IF a > 0 THEN
+CALL p1(a-1, 'ab');
+ELSE
+SELECT 1;
+END IF;
+END|
+SET @save_max_sp_recursion= @@max_sp_recursion_depth;
+SET @@max_sp_recursion_depth= 5;
+CALL p1(4, 'a');
+1
+1
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b' at row 1
+SET @@max_sp_recursion_depth= @save_max_sp_recursion;
+DROP PROCEDURE p1;
+DROP PROCEDURE IF EXISTS p1;
+CREATE PROCEDURE p1(a CHAR)
+BEGIN
+SELECT 1;
+SELECT CAST('10 ' as UNSIGNED INTEGER);
+SELECT 1;
+END|
+CALL p1('data truncated parameter');
+1
+1
+CAST('10 ' as UNSIGNED INTEGER)
+10
+1
+1
+Warnings:
+Warning 1265 Data truncated for column 'a' at row 1
+Warning 1292 Truncated incorrect INTEGER value: '10 '
+DROP PROCEDURE p1;
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+DROP PROCEDURE IF EXISTS p3;
+DROP PROCEDURE IF EXISTS p4;
+CREATE PROCEDURE p1()
+CALL p2()|
+CREATE PROCEDURE p2()
+CALL p3()|
+CREATE PROCEDURE p3()
+CALL p4()|
+CREATE PROCEDURE p4()
+BEGIN
+SELECT 1;
+SELECT CAST('10 ' as UNSIGNED INTEGER);
+SELECT 2;
+END|
+CALL p1();
+1
+1
+CAST('10 ' as UNSIGNED INTEGER)
+10
+2
+2
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: '10 '
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+DROP PROCEDURE p4;
+DROP FUNCTION IF EXISTS f1;
+DROP FUNCTION IF EXISTS f2;
+DROP FUNCTION IF EXISTS f3;
+DROP FUNCTION IF EXISTS f4;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a CHAR(2));
+INSERT INTO t1 VALUES ('aa');
+CREATE FUNCTION f1() RETURNS CHAR
+RETURN (SELECT f2())|
+CREATE FUNCTION f2() RETURNS CHAR
+RETURN (SELECT f3())|
+CREATE FUNCTION f3() RETURNS CHAR
+RETURN (SELECT f4())|
+CREATE FUNCTION f4() RETURNS CHAR
+BEGIN
+RETURN (SELECT a FROM t1);
+END|
+SELECT f1();
+f1()
+a
+Warnings:
+Warning 1265 Data truncated for column 'f4()' at row 1
+DROP FUNCTION f1;
+DROP FUNCTION f2;
+DROP FUNCTION f3;
+DROP FUNCTION f4;
+DROP TABLE t1;
#
# Bug#34197: CREATE PROCEDURE fails when COMMENT truncated in non
# strict SQL mode
=== modified file 'mysql-test/r/subselect.result'
--- a/mysql-test/r/subselect.result 2009-11-06 16:15:09 +0000
+++ b/mysql-test/r/subselect.result 2009-11-20 12:29:43 +0000
@@ -3562,9 +3562,7 @@ SELECT sql_no_cache * FROM t1 WHERE NOT
(SELECT i FROM t1) UNION
(SELECT i FROM t1)
);
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION
-(SELECT i FROM t1)
-)' at line 3
+i
SELECT * FROM t1
WHERE NOT EXISTS (((SELECT i FROM t1) UNION (SELECT i FROM t1)));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION (SELECT i FROM t1)))' at line 2
@@ -3574,7 +3572,11 @@ ERROR 42000: You have an error in your S
from t1' at line 1
explain select * from t1 where not exists
((select t11.i from t1 t11) union (select t12.i from t1 t12));
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'union (select t12.i from t1 t12))' at line 2
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
+3 UNION NULL NULL NULL NULL NULL NULL NULL no matching row in const table
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(250), b INT auto_increment, PRIMARY KEY (b));
insert into t1 (a) values (FLOOR(rand() * 100));
@@ -4279,8 +4281,15 @@ Note 1003 select 2 AS `2` from `test`.`t
EXPLAIN EXTENDED
SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION
(SELECT 1 FROM t2 WHERE t1.a = t2.a));
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION
-(SELECT 1 FROM t2 WHERE t1.a = t2.a))' at line 2
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
+3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 2 100.00 Using where
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
+Warnings:
+Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
+Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1
+Note 1003 select 2 AS `2` from `test`.`t1` where exists((select 1 AS `1` from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 AS `1` from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)))
DROP TABLE t1,t2;
create table t1(f11 int, f12 int);
create table t2(f21 int unsigned not null, f22 int, f23 varchar(10));
@@ -4563,6 +4572,270 @@ id g v s
51 50 NULL l
61 60 NULL l
drop table t1, t2;
+#
+# Bug#33204: INTO is allowed in subselect, causing inconsistent results
+#
+CREATE TABLE t1( a INT );
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2( a INT, b INT );
+SELECT *
+FROM (SELECT a INTO @var FROM t1 WHERE a = 2) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @var FROM t1 WHERE a = 2) t1a' at line 2
+SELECT *
+FROM (SELECT a INTO OUTFILE 'file' FROM t1 WHERE a = 2) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' FROM t1 WHERE a = 2) t1a' at line 2
+SELECT *
+FROM (SELECT a INTO DUMPFILE 'file' FROM t1 WHERE a = 2) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' FROM t1 WHERE a = 2) t1a' at line 2
+SELECT * FROM (
+SELECT 1 a
+UNION
+SELECT a INTO @var FROM t1 WHERE a = 2
+) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @var FROM t1 WHERE a = 2
+) t1a' at line 4
+SELECT * FROM (
+SELECT 1 a
+UNION
+SELECT a INTO OUTFILE 'file' FROM t1 WHERE a = 2
+) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' FROM t1 WHERE a = 2
+) t1a' at line 4
+SELECT * FROM (
+SELECT 1 a
+UNION
+SELECT a INTO DUMPFILE 'file' FROM t1 WHERE a = 2
+) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' FROM t1 WHERE a = 2
+) t1a' at line 4
+SELECT * FROM (SELECT a FROM t1 WHERE a = 2) t1a;
+a
+2
+SELECT * FROM (
+SELECT a FROM t1 WHERE a = 2
+UNION
+SELECT a FROM t1 WHERE a = 2
+) t1a;
+a
+2
+SELECT * FROM (
+SELECT 1 a
+UNION
+SELECT a FROM t1 WHERE a = 2
+UNION
+SELECT a FROM t1 WHERE a = 2
+) t1a;
+a
+1
+2
+SELECT * FROM ((SELECT 1 a) UNION SELECT 1 a);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a)) alias;
+a
+1
+SELECT * FROM (SELECT 1 UNION SELECT 1) t1a;
+1
+1
+SELECT * FROM ((SELECT 1 a INTO @a)) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @a)) t1a' at line 1
+SELECT * FROM ((SELECT 1 a INTO OUTFILE 'file' )) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' )) t1a' at line 1
+SELECT * FROM ((SELECT 1 a INTO DUMPFILE 'file' )) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' )) t1a' at line 1
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO @a)) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @a)) t1a' at line 1
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO DUMPFILE 'file' )) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' )) t1a' at line 1
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO OUTFILE 'file' )) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' )) t1a' at line 1
+SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO @a))) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @a))) t1a' at line 1
+SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO DUMPFILE 'file' ))) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' ))) t1a' at line 1
+SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO OUTFILE 'file' ))) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' ))) t1a' at line 1
+SELECT * FROM (SELECT 1 a ORDER BY a) t1a;
+a
+1
+SELECT * FROM (SELECT 1 a UNION SELECT 1 a ORDER BY a) t1a;
+a
+1
+SELECT * FROM (SELECT 1 a UNION SELECT 1 a LIMIT 1) t1a;
+a
+1
+SELECT * FROM (SELECT 1 a UNION SELECT 1 a ORDER BY a LIMIT 1) t1a;
+a
+1
+SELECT * FROM t1 JOIN (SELECT 1 UNION SELECT 1) alias ON 1;
+a 1
+1 1
+2 1
+SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) ON 1' at line 1
+SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON 1' at line 1
+SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ON 1' at line 1
+SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't1a ON 1' at line 1
+SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't1a ON 1' at line 1
+SELECT * FROM t1 JOIN (t1 t1a) ON 1;
+a a
+1 1
+2 1
+1 2
+2 2
+SELECT * FROM t1 JOIN ((t1 t1a)) ON 1;
+a a
+1 1
+2 1
+1 2
+2 2
+SELECT * FROM (t1 t1a);
+a
+1
+2
+SELECT * FROM ((t1 t1a));
+a
+1
+2
+SELECT * FROM t1 JOIN (SELECT 1 t1a) alias ON 1;
+a t1a
+1 1
+2 1
+SELECT * FROM t1 JOIN ((SELECT 1 t1a)) alias ON 1;
+a t1a
+1 1
+2 1
+SELECT * FROM t1 JOIN (SELECT 1 a) a ON 1;
+a a
+1 1
+2 1
+SELECT * FROM t1 JOIN ((SELECT 1 a)) a ON 1;
+a a
+1 1
+2 1
+SELECT * FROM (t1 JOIN (SELECT 1) t1a1 ON 1) t1a2;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't1a2' at line 1
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE a = ANY ( SELECT 3 UNION SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO @a);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @a)' at line 1
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' )' at line 1
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' )' at line 1
+SELECT * FROM t1 WHERE a = ( SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE a = ( SELECT 1 INTO @a);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @a)' at line 1
+SELECT * FROM t1 WHERE a = ( SELECT 1 INTO OUTFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' )' at line 1
+SELECT * FROM t1 WHERE a = ( SELECT 1 INTO DUMPFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' )' at line 1
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO @a);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @a)' at line 1
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' )' at line 1
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' )' at line 1
+SELECT ( SELECT 1 INTO @v );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v )' at line 1
+SELECT ( SELECT 1 INTO OUTFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' )' at line 1
+SELECT ( SELECT 1 INTO DUMPFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' )' at line 1
+SELECT ( SELECT 1 UNION SELECT 1 INTO @v );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v )' at line 1
+SELECT ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' )' at line 1
+SELECT ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' )' at line 1
+SELECT ( SELECT a FROM t1 WHERE a = 1 ), a FROM t1;
+( SELECT a FROM t1 WHERE a = 1 ) a
+1 1
+1 2
+SELECT ( SELECT a FROM t1 WHERE a = 1 UNION SELECT 1 ), a FROM t1;
+( SELECT a FROM t1 WHERE a = 1 UNION SELECT 1 ) a
+1 1
+1 2
+SELECT * FROM t2 WHERE (a, b) IN (SELECT a, b FROM t2);
+a b
+SELECT 1 UNION ( SELECT 1 UNION SELECT 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 )' at line 1
+( SELECT 1 UNION SELECT 1 ) UNION SELECT 1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) UNION SELECT 1' at line 1
+SELECT ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) )' at line 1
+SELECT ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1' at line 1
+SELECT ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+( SELECT 1 UNION SELECT 1 UNION SELECT 1 )
+1
+SELECT ((SELECT 1 UNION SELECT 1 UNION SELECT 1));
+((SELECT 1 UNION SELECT 1 UNION SELECT 1))
+1
+SELECT * FROM ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) )' at line 1
+SELECT * FROM ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') UNION SELECT 1 )' at line 1
+SELECT * FROM ( SELECT 1 UNION SELECT 1 UNION SELECT 1 ) a;
+1
+1
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) )' at line 1
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) )' at line 1
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) )' at line 1
+SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) )' at line 1
+SELECT * FROM t1 WHERE a = ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 )' at line 1
+SELECT * FROM t1 WHERE a = ALL ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) UNION SELECT 1 )' at line 1
+SELECT * FROM t1 WHERE a = ANY ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) UNION SELECT 1 )' at line 1
+SELECT * FROM t1 WHERE a IN ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 )' at line 1
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE EXISTS ( SELECT 1 UNION SELECT 1 INTO @v );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v )' at line 1
+SELECT EXISTS(SELECT 1+1);
+EXISTS(SELECT 1+1)
+1
+SELECT EXISTS(SELECT 1+1 INTO @test);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @test)' at line 1
+SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION SELECT 1 INTO @v );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v )' at line 1
+SELECT * FROM t1 WHERE EXISTS ( SELECT 1 INTO @v );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v )' at line 1
+SELECT * FROM t1 WHERE a IN ( SELECT 1 INTO @v );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v )' at line 1
+DROP TABLE t1, t2;
CREATE TABLE t1 (a ENUM('rainbow'));
INSERT INTO t1 VALUES (),(),(),(),();
SELECT 1 FROM t1 GROUP BY (SELECT 1 FROM t1 ORDER BY AVG(LAST_INSERT_ID()));
=== modified file 'mysql-test/r/trigger.result'
--- a/mysql-test/r/trigger.result 2009-10-12 10:59:55 +0000
+++ b/mysql-test/r/trigger.result 2009-11-10 18:11:27 +0000
@@ -2115,3 +2115,50 @@ s1
DELETE FROM t1;
DROP TABLE t1;
DROP TEMPORARY TABLE t2;
+DROP TRIGGER IF EXISTS trg1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT);
+CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE a CHAR;
+SELECT 'ab' INTO a;
+SELECT 'ab' INTO a;
+SELECT 'a' INTO a;
+END|
+INSERT INTO t1 VALUES (1);
+Warnings:
+Warning 1265 Data truncated for column 'a' at row 1
+DROP TRIGGER trg1;
+DROP TABLE t1;
+DROP TRIGGER IF EXISTS trg1;
+DROP TRIGGER IF EXISTS trg2;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT);
+CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE trg1 CHAR;
+SELECT 'ab' INTO trg1;
+END|
+CREATE TRIGGER trg2 AFTER INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE trg2 CHAR;
+SELECT 'ab' INTO trg2;
+END|
+INSERT INTO t1 VALUES (0);
+Warnings:
+Warning 1265 Data truncated for column 'trg1' at row 1
+Warning 1265 Data truncated for column 'trg2' at row 1
+SELECT * FROM t1;
+a
+0
+SHOW WARNINGS;
+Level Code Message
+INSERT INTO t1 VALUES (1),(2);
+Warnings:
+Warning 1265 Data truncated for column 'trg1' at row 1
+Warning 1265 Data truncated for column 'trg2' at row 1
+Warning 1265 Data truncated for column 'trg1' at row 1
+Warning 1265 Data truncated for column 'trg2' at row 1
+DROP TRIGGER trg1;
+DROP TRIGGER trg2;
+DROP TABLE t1;
=== modified file 'mysql-test/r/type_time.result'
--- a/mysql-test/r/type_time.result 2009-05-15 08:42:57 +0000
+++ b/mysql-test/r/type_time.result 2009-11-04 10:28:50 +0000
@@ -85,6 +85,7 @@ sec_to_time(time_to_sec(t))
13:00:00
09:00:00
drop table t1;
+End of 4.1 tests
select cast('100:55:50' as time) < cast('24:00:00' as time);
cast('100:55:50' as time) < cast('24:00:00' as time)
0
@@ -138,3 +139,27 @@ CAST(c AS TIME)
00:00:00
DROP TABLE t1;
End of 5.0 tests
+CREATE TABLE t1 (f1 TIME);
+INSERT INTO t1 VALUES ('24:00:00');
+SELECT '24:00:00' = (SELECT f1 FROM t1);
+'24:00:00' = (SELECT f1 FROM t1)
+1
+SELECT CAST('24:00:00' AS TIME) = (SELECT f1 FROM t1);
+CAST('24:00:00' AS TIME) = (SELECT f1 FROM t1)
+1
+SELECT CAST('-24:00:00' AS TIME) = (SELECT f1 FROM t1);
+CAST('-24:00:00' AS TIME) = (SELECT f1 FROM t1)
+0
+TRUNCATE t1;
+INSERT INTO t1 VALUES ('-24:00:00');
+SELECT CAST('24:00:00' AS TIME) = (SELECT f1 FROM t1);
+CAST('24:00:00' AS TIME) = (SELECT f1 FROM t1)
+0
+SELECT CAST('-24:00:00' AS TIME) = (SELECT f1 FROM t1);
+CAST('-24:00:00' AS TIME) = (SELECT f1 FROM t1)
+1
+SELECT '-24:00:00' = (SELECT f1 FROM t1);
+'-24:00:00' = (SELECT f1 FROM t1)
+1
+DROP TABLE t1;
+End of 6.0 tests
=== modified file 'mysql-test/r/union.result'
--- a/mysql-test/r/union.result 2009-05-15 07:11:07 +0000
+++ b/mysql-test/r/union.result 2009-11-10 12:52:46 +0000
@@ -153,48 +153,6 @@ ERROR 42S22: Unknown column 'a' in 'fiel
1 3
1 3
2 1
-CREATE TABLE t1 (a INT);
-INSERT INTO t1 VALUES (1);
-SELECT a INTO @v FROM (
-SELECT a FROM t1
-UNION
-SELECT a FROM t1
-) alias;
-SELECT a INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM (
-SELECT a FROM t1
-UNION
-SELECT a FROM t1 WHERE 0
-) alias;
-SELECT a INTO DUMPFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM (
-SELECT a FROM t1
-UNION
-SELECT a FROM t1 WHERE 0
-) alias;
-SELECT a FROM (
-SELECT a FROM t1
-UNION
-SELECT a INTO @v FROM t1
-) alias;
-SELECT a FROM (
-SELECT a FROM t1
-UNION
-SELECT a INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1
-) alias;
-SELECT a FROM (
-SELECT a FROM t1
-UNION
-SELECT a INTO DUMPFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1
-) alias;
-SELECT a FROM t1 UNION SELECT a INTO @v FROM t1;
-SELECT a FROM t1 UNION SELECT a INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1;
-SELECT a FROM t1 UNION SELECT a INTO DUMPFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1;
-SELECT a INTO @v FROM t1 UNION SELECT a FROM t1;
-ERROR HY000: Incorrect usage of UNION and INTO
-SELECT a INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1 UNION SELECT a FROM t1;
-ERROR HY000: Incorrect usage of UNION and INTO
-SELECT a INTO DUMPFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1 UNION SELECT a FROM t1;
-ERROR HY000: Incorrect usage of UNION and INTO
-DROP TABLE t1;
CREATE TABLE t1 (
`pseudo` char(35) NOT NULL default '',
`pseudo1` char(35) NOT NULL default '',
@@ -1588,3 +1546,39 @@ Warnings:
Note 1003 select '0' AS `a` from `test`.`t1` union select '0' AS `a` from `test`.`t1` order by `a`
DROP TABLE t1;
End of 5.0 tests
+#
+# Bug#32858: Error: "Incorrect usage of UNION and INTO" does not take
+# subselects into account
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1);
+# Tests fix in parser rule select_derived_union.
+SELECT a INTO @v FROM (
+SELECT a FROM t1
+UNION
+SELECT a FROM t1
+) alias;
+SELECT a INTO OUTFILE 'union.out.file' FROM (
+SELECT a FROM t1
+UNION
+SELECT a FROM t1 WHERE 0
+) alias;
+SELECT a INTO DUMPFILE 'union.out.file2' FROM (
+SELECT a FROM t1
+UNION
+SELECT a FROM t1 WHERE 0
+) alias;
+SELECT a FROM t1 UNION SELECT a INTO @v FROM t1;
+SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file5' FROM t1;
+SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file6' FROM t1;
+SELECT a INTO @v FROM t1 UNION SELECT a FROM t1;
+ERROR HY000: Incorrect usage of UNION and INTO
+SELECT a INTO OUTFILE 'union.out.file7' FROM t1 UNION SELECT a FROM t1;
+ERROR HY000: Incorrect usage of UNION and INTO
+SELECT a INTO DUMPFILE 'union.out.file8' FROM t1 UNION SELECT a FROM t1;
+ERROR HY000: Incorrect usage of UNION and INTO
+# Tests fix in parser rule query_expression_body.
+SELECT ( SELECT a UNION SELECT a ) INTO @v FROM t1;
+SELECT ( SELECT a UNION SELECT a ) INTO OUTFILE 'union.out.file3' FROM t1;
+SELECT ( SELECT a UNION SELECT a ) INTO DUMPFILE 'union.out.file4' FROM t1;
+DROP TABLE t1;
=== modified file 'mysql-test/suite/rpl/r/rpl_multi_delete2.result'
--- a/mysql-test/suite/rpl/r/rpl_multi_delete2.result 2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/r/rpl_multi_delete2.result 2009-11-10 18:48:46 +0000
@@ -16,7 +16,7 @@ DELETE alias FROM a alias WHERE alias.i=
SELECT * FROM a;
i
insert into a values(2),(3);
-delete a alias FROM a alias where alias.i=2;
+delete alias FROM a alias where alias.i=2;
select * from a;
i
3
=== modified file 'mysql-test/suite/rpl/t/rpl_multi_delete2.test'
--- a/mysql-test/suite/rpl/t/rpl_multi_delete2.test 2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/t/rpl_multi_delete2.test 2009-11-10 18:48:46 +0000
@@ -25,7 +25,7 @@ INSERT INTO a VALUES(1);
DELETE alias FROM a alias WHERE alias.i=1;
SELECT * FROM a;
insert into a values(2),(3);
-delete a alias FROM a alias where alias.i=2;
+delete alias FROM a alias where alias.i=2;
select * from a;
save_master_pos;
connection slave;
=== modified file 'mysql-test/suite/sys_vars/r/group_concat_max_len_func.result'
--- a/mysql-test/suite/sys_vars/r/group_concat_max_len_func.result 2008-12-19 15:12:15 +0000
+++ b/mysql-test/suite/sys_vars/r/group_concat_max_len_func.result 2009-11-10 18:26:39 +0000
@@ -41,7 +41,10 @@ id rollno GROUP_CONCAT(name)
4 3 Reco
7 4 Reco
Warnings:
-Warning 1260 4 line(s) were cut by GROUP_CONCAT()
+Warning 1260 Row 1 was cut by GROUP_CONCAT()
+Warning 1260 Row 2 was cut by GROUP_CONCAT()
+Warning 1260 Row 3 was cut by GROUP_CONCAT()
+Warning 1260 Row 4 was cut by GROUP_CONCAT()
## Changing session value of variable and verifying its behavior, ##
## warning should come here ##
SET @@session.group_concat_max_len = 10;
@@ -52,7 +55,9 @@ id rollno GROUP_CONCAT(name)
4 3 Record_4,R
7 4 Record_7,R
Warnings:
-Warning 1260 3 line(s) were cut by GROUP_CONCAT()
+Warning 1260 Row 2 was cut by GROUP_CONCAT()
+Warning 1260 Row 5 was cut by GROUP_CONCAT()
+Warning 1260 Row 7 was cut by GROUP_CONCAT()
'#--------------------FN_DYNVARS_034_03-------------------------#'
## Connecting with new connection test_con2 ##
## Verifying initial value of variable. It should be 4 ##
@@ -71,7 +76,7 @@ id rollno GROUP_CONCAT(name)
4 3 Record_4,Record_6
7 4 Record_7,Record_8
Warnings:
-Warning 1260 1 line(s) were cut by GROUP_CONCAT()
+Warning 1260 Row 3 was cut by GROUP_CONCAT()
'#--------------------FN_DYNVARS_034_04-------------------------#'
## Setting session value of variable to 26. No warning should appear here ##
## because the value after concatination is less than 30 ##
=== modified file 'mysql-test/t/alias.test'
--- a/mysql-test/t/alias.test 2005-10-31 11:25:08 +0000
+++ b/mysql-test/t/alias.test 2009-11-10 20:43:43 +0000
@@ -86,3 +86,132 @@ ASC LIMIT 1;
drop table t1;
# End of 4.1 tests
+
+#
+# Bug#27249 table_wild with alias: select t1.* as something
+#
+
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
+create table t1 (a int, b int, c int);
+create table t2 (d int);
+create table t3 (a1 int, b1 int, c1 int);
+insert into t1 values(1,2,3);
+insert into t1 values(11,22,33);
+insert into t2 values(99);
+
+# Invalid queries with alias on wild
+--error ER_PARSE_ERROR
+select t1.* as 'with_alias' from t1;
+--error ER_PARSE_ERROR
+select t2.* as 'with_alias' from t2;
+--error ER_PARSE_ERROR
+select t1.*, t1.* as 'with_alias' from t1;
+--error ER_PARSE_ERROR
+select t1.* as 'with_alias', t1.* from t1;
+--error ER_PARSE_ERROR
+select t1.* as 'with_alias', t1.* as 'alias2' from t1;
+--error ER_PARSE_ERROR
+select t1.* as 'with_alias', a, t1.* as 'alias2' from t1;
+
+# other fields without alias
+--error ER_PARSE_ERROR
+select a, t1.* as 'with_alias' from t1;
+--error ER_PARSE_ERROR
+select t1.* as 'with_alias', a from t1;
+--error ER_PARSE_ERROR
+select a, t1.* as 'with_alias', b from t1;
+--error ER_PARSE_ERROR
+select (select d from t2 where d > a), t1.* as 'with_alias' from t1;
+--error ER_PARSE_ERROR
+select t1.* as 'with_alias', (select a from t2 where d > a) from t1;
+
+# other fields with alias
+--error ER_PARSE_ERROR
+select a as 'x', t1.* as 'with_alias' from t1;
+--error ER_PARSE_ERROR
+select t1.* as 'with_alias', a as 'x' from t1;
+--error ER_PARSE_ERROR
+select a as 'x', t1.* as 'with_alias', b as 'x' from t1;
+--error ER_PARSE_ERROR
+select (select d from t2 where d > a) as 'x', t1.* as 'with_alias' from t1;
+--error ER_PARSE_ERROR
+select t1.* as 'with_alias', (select a from t2 where d > a) as 'x' from t1;
+
+# some more subquery
+--error ER_PARSE_ERROR
+select (select t2.* as 'x' from t2) from t1;
+--error ER_PARSE_ERROR
+select a, (select t2.* as 'x' from t2) from t1;
+--error ER_PARSE_ERROR
+select t1.*, (select t2.* as 'x' from t2) from t1;
+
+# insert
+--error ER_PARSE_ERROR
+insert into t3 select t1.* as 'with_alias' from t1;
+--error ER_PARSE_ERROR
+insert into t3 select t2.* as 'with_alias', 1, 2 from t2;
+--error ER_PARSE_ERROR
+insert into t3 select t2.* as 'with_alias', d as 'x', d as 'z' from t2;
+--error ER_PARSE_ERROR
+insert into t3 select t2.*, t2.* as 'with_alias', 3 from t2;
+
+# create
+--error ER_PARSE_ERROR
+create table t3 select t1.* as 'with_alias' from t1;
+--error ER_PARSE_ERROR
+create table t3 select t2.* as 'with_alias', 1, 2 from t2;
+--error ER_PARSE_ERROR
+create table t3 select t2.* as 'with_alias', d as 'x', d as 'z' from t2;
+--error ER_PARSE_ERROR
+create table t3 select t2.*, t2.* as 'with_alias', 3 from t2;
+
+#
+# Valid queries without alias on wild
+# (proof the above fail due to invalid aliasing)
+#
+
+select t1.* from t1;
+select t2.* from t2;
+select t1.*, t1.* from t1;
+select t1.*, a, t1.* from t1;
+
+# other fields without alias
+select a, t1.* from t1;
+select t1.*, a from t1;
+select a, t1.*, b from t1;
+select (select d from t2 where d > a), t1.* from t1;
+select t1.*, (select a from t2 where d > a) from t1;
+
+# other fields with alias
+select a as 'x', t1.* from t1;
+select t1.*, a as 'x' from t1;
+select a as 'x', t1.*, b as 'x' from t1;
+select (select d from t2 where d > a) as 'x', t1.* from t1;
+select t1.*, (select a from t2 where d > a) as 'x' from t1;
+
+# some more subquery
+select (select t2.* from t2) from t1;
+select a, (select t2.* from t2) from t1;
+select t1.*, (select t2.* from t2) from t1;
+
+# insert
+insert into t3 select t1.* from t1;
+insert into t3 select t2.*, 1, 2 from t2;
+insert into t3 select t2.*, d as 'x', d as 'z' from t2;
+insert into t3 select t2.*, t2.*, 3 from t2;
+
+# create
+create table t4 select t1.* from t1;
+drop table t4;
+create table t4 select t2.*, 1, 2 from t2;
+drop table t4;
+create table t4 select t2.*, d as 'x', d as 'z' from t2;
+drop table t4;
+
+# end
+drop table t1,t2,t3;
+
+# End of 5.2 tests
=== modified file 'mysql-test/t/delete.test'
--- a/mysql-test/t/delete.test 2009-09-28 10:48:52 +0000
+++ b/mysql-test/t/delete.test 2009-11-10 18:48:46 +0000
@@ -265,8 +265,8 @@ DELETE FROM t1, alias USING t1, t2 alias
DELETE FROM t1, t2 USING t1, t2 alias WHERE t1.a = alias.a;
--error ER_PARSE_ERROR
DELETE FROM db1.t1 alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
---error ER_UNKNOWN_TABLE
DELETE FROM alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
+--error ER_UNKNOWN_TABLE
DELETE FROM db2.alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
DELETE FROM t1 USING t1 WHERE a = 1;
SELECT * FROM t1;
@@ -293,6 +293,159 @@ DROP FUNCTION f1;
--echo End of 5.0 tests
+#
+# Bug#27525: table not found when using multi-table-deletes with aliases over
+# several databas
+# Bug#21148: MULTI-DELETE fails to resolve a table by alias if it's from a
+# different database
+#
+
+--disable_warnings
+DROP DATABASE IF EXISTS db1;
+DROP DATABASE IF EXISTS db2;
+DROP DATABASE IF EXISTS db3;
+DROP DATABASE IF EXISTS db4;
+DROP TABLE IF EXISTS t1, t2;
+DROP PROCEDURE IF EXISTS count;
+--enable_warnings
+USE test;
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+
+CREATE TABLE db1.t1 (a INT, b INT);
+INSERT INTO db1.t1 VALUES (1,1),(2,2),(3,3);
+CREATE TABLE db1.t2 AS SELECT * FROM db1.t1;
+CREATE TABLE db2.t1 AS SELECT * FROM db1.t2;
+CREATE TABLE db2.t2 AS SELECT * FROM db2.t1;
+CREATE TABLE t1 AS SELECT * FROM db2.t2;
+CREATE TABLE t2 AS SELECT * FROM t1;
+
+delimiter |;
+CREATE PROCEDURE count_rows()
+BEGIN
+ SELECT COUNT(*) AS "COUNT(db1.t1)" FROM db1.t1;
+ SELECT COUNT(*) AS "COUNT(db1.t2)" FROM db1.t2;
+ SELECT COUNT(*) AS "COUNT(db2.t1)" FROM db2.t1;
+ SELECT COUNT(*) AS "COUNT(db2.t2)" FROM db2.t2;
+ SELECT COUNT(*) AS "COUNT(test.t1)" FROM test.t1;
+ SELECT COUNT(*) AS "COUNT(test.t2)" FROM test.t2;
+END|
+delimiter ;|
+
+#
+# Testing without a selected database
+#
+
+CREATE DATABASE db3;
+USE db3;
+DROP DATABASE db3;
+--error ER_NO_DB_ERROR
+SELECT * FROM t1;
+
+# Detect missing table references
+
+--error ER_NO_DB_ERROR
+DELETE a1,a2 FROM db1.t1, db2.t2;
+--error ER_NO_DB_ERROR
+DELETE a1,a2 FROM db1.t1, db2.t2;
+--error ER_NO_DB_ERROR
+DELETE a1,a2 FROM db1.t1 AS a1, db2.t2;
+--error ER_NO_DB_ERROR
+DELETE a1,a2 FROM db1.t1, db2.t2 AS a2;
+--error ER_NO_DB_ERROR
+DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
+--error ER_NO_DB_ERROR
+DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
+
+--error ER_NO_DB_ERROR
+DELETE FROM a1,a2 USING db1.t1, db2.t2;
+--error ER_NO_DB_ERROR
+DELETE FROM a1,a2 USING db1.t1, db2.t2;
+--error ER_NO_DB_ERROR
+DELETE FROM a1,a2 USING db1.t1 AS a1, db2.t2;
+--error ER_NO_DB_ERROR
+DELETE FROM a1,a2 USING db1.t1, db2.t2 AS a2;
+--error ER_NO_DB_ERROR
+DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
+--error ER_NO_DB_ERROR
+DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
+
+# Ambiguous table references
+
+--error ER_NO_DB_ERROR
+DELETE a1 FROM db1.t1 AS a1, db2.t2 AS a1;
+--error ER_NO_DB_ERROR
+DELETE a1 FROM db1.a1, db2.t2 AS a1;
+--error ER_NO_DB_ERROR
+DELETE a1 FROM a1, db1.t1 AS a1;
+--error ER_NO_DB_ERROR
+DELETE t1 FROM db1.t1, db2.t1 AS a1;
+--error ER_NO_DB_ERROR
+DELETE t1 FROM db1.t1 AS a1, db2.t1 AS a2;
+--error ER_NO_DB_ERROR
+DELETE t1 FROM db1.t1, db2.t1;
+
+# Test all again, now with a selected database
+
+USE test;
+
+# Detect missing table references
+
+--error ER_UNKNOWN_TABLE
+DELETE a1,a2 FROM db1.t1, db2.t2;
+--error ER_UNKNOWN_TABLE
+DELETE a1,a2 FROM db1.t1, db2.t2;
+--error ER_UNKNOWN_TABLE
+DELETE a1,a2 FROM db1.t1 AS a1, db2.t2;
+--error ER_UNKNOWN_TABLE
+DELETE a1,a2 FROM db1.t1, db2.t2 AS a2;
+--error ER_NO_SUCH_TABLE
+DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
+--error ER_NO_SUCH_TABLE
+DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
+
+--error ER_UNKNOWN_TABLE
+DELETE FROM a1,a2 USING db1.t1, db2.t2;
+--error ER_UNKNOWN_TABLE
+DELETE FROM a1,a2 USING db1.t1, db2.t2;
+--error ER_UNKNOWN_TABLE
+DELETE FROM a1,a2 USING db1.t1 AS a1, db2.t2;
+--error ER_UNKNOWN_TABLE
+DELETE FROM a1,a2 USING db1.t1, db2.t2 AS a2;
+--error ER_NO_SUCH_TABLE
+DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
+--error ER_NO_SUCH_TABLE
+DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
+
+# Ambiguous table references
+
+--error ER_NONUNIQ_TABLE
+DELETE a1 FROM db1.t1 AS a1, db2.t2 AS a1;
+--error ER_NO_SUCH_TABLE
+DELETE a1 FROM db1.a1, db2.t2 AS a1;
+--error ER_NONUNIQ_TABLE
+DELETE a1 FROM a1, db1.t1 AS a1;
+--error ER_UNKNOWN_TABLE
+DELETE t1 FROM db1.t1, db2.t1 AS a1;
+--error ER_UNKNOWN_TABLE
+DELETE t1 FROM db1.t1 AS a1, db2.t1 AS a2;
+--error ER_UNKNOWN_TABLE
+DELETE t1 FROM db1.t1, db2.t1;
+
+# Test multiple-table cross database deletes
+
+DELETE t1 FROM db1.t2 AS t1, db2.t2 AS t2 WHERE t2.a = 1 AND t1.a = t2.a;
+SELECT ROW_COUNT();
+CALL count_rows();
+DELETE a1, a2 FROM db2.t1 AS a1, t2 AS a2 WHERE a1.a = 2 AND a2.a = 2;
+SELECT ROW_COUNT();
+CALL count_rows();
+
+DROP DATABASE db1;
+DROP DATABASE db2;
+DROP PROCEDURE count_rows;
+DROP TABLE t1, t2;
+
--echo #
--echo # Bug#46958: Assertion in Diagnostics_area::set_ok_status, trigger,
--echo # merge table
=== modified file 'mysql-test/t/derived.test'
--- a/mysql-test/t/derived.test 2009-07-11 18:44:29 +0000
+++ b/mysql-test/t/derived.test 2009-11-10 18:48:46 +0000
@@ -158,7 +158,7 @@ UPDATE `t1` AS P1 INNER JOIN (SELECT aaa
delete P1.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
select * from t1;
--replace_result P2 p2
---error ER_UNKNOWN_TABLE
+--error ER_NON_UPDATABLE_TABLE
delete P1.*,P2.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
-- error 1054
delete P1.* from `t1` AS P1 INNER JOIN (SELECT aaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
=== modified file 'mysql-test/t/dirty_close.test'
--- a/mysql-test/t/dirty_close.test 2009-03-03 20:34:18 +0000
+++ b/mysql-test/t/dirty_close.test 2009-11-13 12:56:38 +0000
@@ -1,3 +1,4 @@
+--source include/not_embedded.inc
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
@@ -22,6 +23,38 @@ disconnect con2;
# End of 4.1 tests
+#
+# Bug#10374 GET_LOCK does not let connection to close on the server side if it's aborted
+#
+
+connection default;
+SELECT GET_LOCK("dangling", 0);
+connect(con1, localhost, root,,);
+connection con1;
+--send SELECT GET_LOCK('dangling', 3600);
+connection default;
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = "User lock"
+ AND INFO = "SELECT GET_LOCK('dangling', 3600)";
+--source include/wait_condition.inc
+dirty_close con1;
+let $wait_condition=
+ SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = "User lock"
+ AND INFO = "SELECT GET_LOCK('dangling', 3600)";
+--source include/wait_condition.inc
+connect(con1, localhost, root,,);
+--send SELECT GET_LOCK('dangling', 3600);
+connection default;
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = "User lock"
+ AND INFO = "SELECT GET_LOCK('dangling', 3600)";
+--source include/wait_condition.inc
+SELECT RELEASE_LOCK('dangling');
+connection con1;
+--reap
+connection default;
+disconnect con1;
+
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
=== modified file 'mysql-test/t/func_sapdb.test'
--- a/mysql-test/t/func_sapdb.test 2009-02-07 15:50:31 +0000
+++ b/mysql-test/t/func_sapdb.test 2009-11-04 09:17:39 +0000
@@ -169,4 +169,26 @@ SELECT TIMEDIFF(TIME('17:00:00'),TIME('1
TIMEDIFF(TIME('17:59:00'),TIME('17:00:00')),
TIMEDIFF(TIME('17:00:00'),TIME('17:59:00'));
+#
+# Bug#42661 - sec_to_time() and signedness
+#
+
+SELECT sec_to_time(3020399)=TIME('838:59:59');
+SELECT sec_to_time(-3020399)=TIME('-838:59:59');
+SELECT sec_to_time(-3020399)='-838:59:59';
+SELECT time(sec_to_time(-3020399))=TIME('-838:59:59');
+SELECT time(sec_to_time(-3020399))=TIME('-838:59:58');
+
+#
+# Bug#42662 - maketime() and signedness
+#
+
+# TIME(...) and CAST(... AS TIME) go through the same code-path here,
+# but we'll explicitly show show that both work in case the ever changes.
+SELECT maketime(-1,0,1)='-01:00:01';
+SELECT TIME(maketime(-1,0,1))=CAST('-01:00:01' AS TIME);
+SELECT maketime(-1,0,1)=CAST('-01:00:01' AS TIME);
+SELECT maketime(1,0,1)=CAST('01:00:01' AS TIME);
+SELECT maketime(1,0,1)=CAST('01:00:02' AS TIME);
+
# End of 5.0 tests
=== modified file 'mysql-test/t/func_time.test'
--- a/mysql-test/t/func_time.test 2009-01-23 12:22:05 +0000
+++ b/mysql-test/t/func_time.test 2009-11-03 22:29:16 +0000
@@ -819,6 +819,16 @@ SELECT '2008-02-18' + INTERVAL 1 FRAC_SE
--error ER_PARSE_ERROR
SELECT '2008-02-18' - INTERVAL 1 FRAC_SECOND;
+#
+# Bug #36466:
+# Adding days to day_microsecond changes interpretation of microseconds
+#
+
+# show that we treat fractions of seconds correctly (zerofill from right to
+# six places) even if we left out fields on the left.
+select date_add('1000-01-01 00:00:00', interval '1.03:02:01.05' day_microsecond);
+select date_add('1000-01-01 00:00:00', interval '1.02' day_microsecond);
+
--echo End of 5.0 tests
#
=== modified file 'mysql-test/t/lock_multi.test'
--- a/mysql-test/t/lock_multi.test 2009-07-10 23:12:13 +0000
+++ b/mysql-test/t/lock_multi.test 2009-11-10 14:23:55 +0000
@@ -1,5 +1,3 @@
--- source include/not_embedded.inc
-
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
=== modified file 'mysql-test/t/mysql.test'
--- a/mysql-test/t/mysql.test 2009-10-15 12:23:43 +0000
+++ b/mysql-test/t/mysql.test 2009-11-04 12:20:02 +0000
@@ -367,6 +367,14 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug310
--enable_query_log
#
+# Bug#26780: patch to add auto vertical output option to the cli.
+#
+# Make this wide enough that it will wrap almost everywhere.
+--exec $MYSQL test --auto-vertical-output --table -e "SELECT 1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0;"
+# Too short to wrap.
+--exec $MYSQL test --auto-vertical-output --table -e "SELECT 1;"
+
+#
# Bug #25146: Some warnings/errors not shown when using --show-warnings
#
=== added file 'mysql-test/t/partition_sync.test'
--- a/mysql-test/t/partition_sync.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/partition_sync.test 2009-11-04 11:59:46 +0000
@@ -0,0 +1,41 @@
+--source include/have_partition.inc
+# Save the initial number of concurrent sessions.
+--source include/count_sessions.inc
+
+--echo #
+--echo # Bug #43867 ALTER TABLE on a partitioned table
+--echo # causes unnecessary deadlocks
+--echo #
+
+CREATE TABLE t1 (a int) PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (1),
+ PARTITION p1 VALUES LESS THAN (2));
+
+INSERT INTO t1 VALUES (0),(1);
+
+connect(con1,localhost,root);
+
+--echo # Connection 2
+connection con1;
+BEGIN;
+SELECT * FROM t1;
+
+--echo # Connection 1
+connection default;
+--error ER_DROP_PARTITION_NON_EXISTENT
+ALTER TABLE t1 DROP PARTITION p3;
+
+--echo # Connection 2
+connection con1;
+--echo # This failed with deadlock and should not do so.
+SELECT * FROM t1;
+
+--echo # Connection 1
+connection default;
+disconnect con1;
+DROP TABLE t1;
+
+
+# Check that all connections opened by test cases in this file are really
+# gone so execution of other tests won't be affected by their presence.
+--source include/wait_until_count_sessions.inc
=== added file 'mysql-test/t/rpl_mysqldump_slave.test'
--- a/mysql-test/t/rpl_mysqldump_slave.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/rpl_mysqldump_slave.test 2009-11-04 13:31:03 +0000
@@ -0,0 +1,25 @@
+source include/master-slave.inc;
+
+--echo #
+--echo # New --dump-slave, --apply-slave-statements functionality
+--echo #
+
+# There is a gap between when START SLAVE returns and when MASTER_LOG_FILE and
+# MASTER_LOG_POS are set. Ensure that we don't call SHOW SLAVE STATUS during
+# that gap.
+--sync_slave_with_master
+
+connection master;
+use test;
+
+connection slave;
+
+# Execute mysqldump with --dump-slave
+--exec $MYSQL_DUMP_SLAVE --compact --dump-slave test
+
+# Execute mysqldump with --dump-slave and --apply-slave-statements
+--exec $MYSQL_DUMP_SLAVE --compact --dump-slave --apply-slave-statements test
+
+--replace_result $MASTER_MYPORT MASTER_MYPORT
+# Execute mysqldump with --dump-slave ,--apply-slave-statements and --include-master-host-port
+--exec $MYSQL_DUMP_SLAVE --compact --dump-slave --apply-slave-statements --include-master-host-port test
=== modified file 'mysql-test/t/shm.test'
--- a/mysql-test/t/shm.test 2009-03-26 23:17:27 +0000
+++ b/mysql-test/t/shm.test 2009-11-10 19:36:38 +0000
@@ -7,10 +7,17 @@ let $shm= query_get_value("SHOW VARIABLE
if (`SELECT '$shm' != 'ON'`){
skip No shm support;
}
+let $shm_name= query_get_value("SHOW GLOBAL VARIABLES LIKE 'shared_memory_base_name'", Value, 1);
+
+# Connect using SHM for testing
+connect(shm_con,localhost,root,,,,$shm_name,SHM);
# Source select test case
-- source include/common-tests.inc
+connection default;
+disconnect shm_con;
+
#
# Bug #24924: shared-memory-base-name that is too long causes buffer overflow
#
@@ -20,7 +27,6 @@ if (`SELECT '$shm' != 'ON'`){
# Bug #33899: Deadlock in mysql_real_query with shared memory connections
#
-let $name= query_get_value("SHOW GLOBAL VARIABLES LIKE 'shared_memory_base_name'", Value, 1);
let $stmt= `SELECT REPEAT('a', 2048)`;
SET @max_allowed_packet= @@global.max_allowed_packet;
@@ -30,7 +36,7 @@ SET GLOBAL max_allowed_packet= 1024;
SET GLOBAL net_buffer_length= 1024;
--error 1
---exec echo SELECT '$stmt'| $MYSQL --protocol=memory --shared-memory-base-name=$name 2>&1
+--exec echo SELECT '$stmt'| $MYSQL --protocol=memory --shared-memory-base-name=$shm_name 2>&1
SET GLOBAL max_allowed_packet= @max_allowed_packet;
SET GLOBAL net_buffer_length= @net_buffer_length;
=== modified file 'mysql-test/t/sp-error.test'
--- a/mysql-test/t/sp-error.test 2009-10-19 13:55:04 +0000
+++ b/mysql-test/t/sp-error.test 2009-11-19 23:48:08 +0000
@@ -2419,6 +2419,27 @@ end$$
delimiter ;$$
+#
+# Bug#15192: "fatal errors" are caught by handlers in stored procedures
+#
+
+--disable_warnings
+drop procedure if exists p1;
+--enable_warnings
+set @old_recursion_depth = @@max_sp_recursion_depth;
+set @@max_sp_recursion_depth = 255;
+delimiter |;
+create procedure p1(a int)
+begin
+ declare continue handler for 1436 -- ER_STACK_OVERRUN_NEED_MORE
+ select 'exception';
+ call p1(a+1);
+end|
+delimiter ;|
+--error 0,ER_STACK_OVERRUN_NEED_MORE,ER_SP_RECURSION_LIMIT
+call p1(1);
+set @@max_sp_recursion_depth = @old_recursion_depth;
+drop procedure p1;
#
# BUG#NNNN: New bug synopsis
=== modified file 'mysql-test/t/sp.test'
--- a/mysql-test/t/sp.test 2009-11-06 14:20:27 +0000
+++ b/mysql-test/t/sp.test 2009-11-19 23:48:08 +0000
@@ -8295,6 +8295,119 @@ SELECT * FROM t1 WHERE a = f1();
DROP FUNCTION f1;
DROP TABLE t1;
+#
+# Bug#36649: Condition area is not properly cleaned up after stored routine invocation
+#
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+delimiter |;
+CREATE PROCEDURE p1(a INT, b CHAR)
+BEGIN
+ IF a > 0 THEN
+ CALL p1(a-1, 'ab');
+ ELSE
+ SELECT 1;
+ END IF;
+END|
+delimiter ;|
+
+SET @save_max_sp_recursion= @@max_sp_recursion_depth;
+SET @@max_sp_recursion_depth= 5;
+CALL p1(4, 'a');
+SET @@max_sp_recursion_depth= @save_max_sp_recursion;
+
+DROP PROCEDURE p1;
+
+#
+# Ensure that rules for message list clean up are being respected.
+#
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+delimiter |;
+CREATE PROCEDURE p1(a CHAR)
+BEGIN
+ SELECT 1;
+ SELECT CAST('10 ' as UNSIGNED INTEGER);
+ SELECT 1;
+END|
+delimiter ;|
+
+CALL p1('data truncated parameter');
+
+DROP PROCEDURE p1;
+
+#
+# Cascading stored procedure/function calls.
+#
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+DROP PROCEDURE IF EXISTS p3;
+DROP PROCEDURE IF EXISTS p4;
+--enable_warnings
+
+delimiter |;
+CREATE PROCEDURE p1()
+ CALL p2()|
+CREATE PROCEDURE p2()
+ CALL p3()|
+CREATE PROCEDURE p3()
+ CALL p4()|
+CREATE PROCEDURE p4()
+BEGIN
+ SELECT 1;
+ SELECT CAST('10 ' as UNSIGNED INTEGER);
+ SELECT 2;
+END|
+delimiter ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+DROP PROCEDURE p4;
+
+--disable_warnings
+DROP FUNCTION IF EXISTS f1;
+DROP FUNCTION IF EXISTS f2;
+DROP FUNCTION IF EXISTS f3;
+DROP FUNCTION IF EXISTS f4;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a CHAR(2));
+
+INSERT INTO t1 VALUES ('aa');
+
+delimiter |;
+CREATE FUNCTION f1() RETURNS CHAR
+ RETURN (SELECT f2())|
+CREATE FUNCTION f2() RETURNS CHAR
+ RETURN (SELECT f3())|
+CREATE FUNCTION f3() RETURNS CHAR
+ RETURN (SELECT f4())|
+CREATE FUNCTION f4() RETURNS CHAR
+BEGIN
+ RETURN (SELECT a FROM t1);
+END|
+delimiter ;|
+
+SELECT f1();
+
+DROP FUNCTION f1;
+DROP FUNCTION f2;
+DROP FUNCTION f3;
+DROP FUNCTION f4;
+DROP TABLE t1;
+
--echo #
--echo # Bug#34197: CREATE PROCEDURE fails when COMMENT truncated in non
--echo # strict SQL mode
=== modified file 'mysql-test/t/subselect.test'
--- a/mysql-test/t/subselect.test 2009-11-06 16:15:09 +0000
+++ b/mysql-test/t/subselect.test 2009-11-20 12:29:43 +0000
@@ -2513,8 +2513,6 @@ DROP TABLE t1, t2;
CREATE TABLE t1 (i INT);
(SELECT i FROM t1) UNION (SELECT i FROM t1);
-#TODO:not supported
---error ER_PARSE_ERROR
SELECT sql_no_cache * FROM t1 WHERE NOT EXISTS
(
(SELECT i FROM t1) UNION
@@ -2531,8 +2529,6 @@ WHERE NOT EXISTS (((SELECT i FROM t1) UN
explain select ((select t11.i from t1 t11) union (select t12.i from t1 t12))
from t1;
-#TODO:not supported
---error ER_PARSE_ERROR
explain select * from t1 where not exists
((select t11.i from t1 t11) union (select t12.i from t1 t12));
@@ -3203,8 +3199,6 @@ EXPLAIN EXTENDED
SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a));
-#TODO:not supported
---error ER_PARSE_ERROR
EXPLAIN EXTENDED
SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION
(SELECT 1 FROM t2 WHERE t1.a = t2.a));
@@ -3544,6 +3538,232 @@ where v in(select v
where t1.g=t2.g) is unknown;
drop table t1, t2;
+-- echo #
+-- echo # Bug#33204: INTO is allowed in subselect, causing inconsistent results
+-- echo #
+CREATE TABLE t1( a INT );
+INSERT INTO t1 VALUES (1),(2);
+
+CREATE TABLE t2( a INT, b INT );
+
+--error ER_PARSE_ERROR
+SELECT *
+FROM (SELECT a INTO @var FROM t1 WHERE a = 2) t1a;
+--error ER_PARSE_ERROR
+SELECT *
+FROM (SELECT a INTO OUTFILE 'file' FROM t1 WHERE a = 2) t1a;
+--error ER_PARSE_ERROR
+SELECT *
+FROM (SELECT a INTO DUMPFILE 'file' FROM t1 WHERE a = 2) t1a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM (
+ SELECT 1 a
+ UNION
+ SELECT a INTO @var FROM t1 WHERE a = 2
+) t1a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM (
+ SELECT 1 a
+ UNION
+ SELECT a INTO OUTFILE 'file' FROM t1 WHERE a = 2
+) t1a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM (
+ SELECT 1 a
+ UNION
+ SELECT a INTO DUMPFILE 'file' FROM t1 WHERE a = 2
+) t1a;
+
+SELECT * FROM (SELECT a FROM t1 WHERE a = 2) t1a;
+
+SELECT * FROM (
+ SELECT a FROM t1 WHERE a = 2
+ UNION
+ SELECT a FROM t1 WHERE a = 2
+) t1a;
+
+SELECT * FROM (
+ SELECT 1 a
+ UNION
+ SELECT a FROM t1 WHERE a = 2
+ UNION
+ SELECT a FROM t1 WHERE a = 2
+) t1a;
+
+# This was not allowed previously. Possibly, it should be allowed on the future.
+# For now, the intent is to keep the fix as non-intrusive as possible.
+--error ER_PARSE_ERROR
+SELECT * FROM ((SELECT 1 a) UNION SELECT 1 a);
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a)) alias;
+SELECT * FROM (SELECT 1 UNION SELECT 1) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM ((SELECT 1 a INTO @a)) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM ((SELECT 1 a INTO OUTFILE 'file' )) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM ((SELECT 1 a INTO DUMPFILE 'file' )) t1a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO @a)) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO DUMPFILE 'file' )) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO OUTFILE 'file' )) t1a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO @a))) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO DUMPFILE 'file' ))) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO OUTFILE 'file' ))) t1a;
+
+SELECT * FROM (SELECT 1 a ORDER BY a) t1a;
+SELECT * FROM (SELECT 1 a UNION SELECT 1 a ORDER BY a) t1a;
+SELECT * FROM (SELECT 1 a UNION SELECT 1 a LIMIT 1) t1a;
+SELECT * FROM (SELECT 1 a UNION SELECT 1 a ORDER BY a LIMIT 1) t1a;
+
+# Test of rule
+# table_factor: '(' get_select_lex query_expression_body ')' opt_table_alias
+# UNION should not be allowed inside the parentheses, nor should
+# aliases after.
+#
+SELECT * FROM t1 JOIN (SELECT 1 UNION SELECT 1) alias ON 1;
+--error ER_PARSE_ERROR
+SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1;
+--error ER_PARSE_ERROR
+SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1;
+--error ER_PARSE_ERROR
+SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1;
+--error ER_PARSE_ERROR
+SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1;
+--error ER_PARSE_ERROR
+SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1;
+
+SELECT * FROM t1 JOIN (t1 t1a) ON 1;
+SELECT * FROM t1 JOIN ((t1 t1a)) ON 1;
+
+SELECT * FROM (t1 t1a);
+SELECT * FROM ((t1 t1a));
+
+SELECT * FROM t1 JOIN (SELECT 1 t1a) alias ON 1;
+SELECT * FROM t1 JOIN ((SELECT 1 t1a)) alias ON 1;
+
+SELECT * FROM t1 JOIN (SELECT 1 a) a ON 1;
+SELECT * FROM t1 JOIN ((SELECT 1 a)) a ON 1;
+
+# For the join, TABLE_LIST::select_lex == NULL
+# Check that we handle this.
+--error ER_PARSE_ERROR
+SELECT * FROM (t1 JOIN (SELECT 1) t1a1 ON 1) t1a2;
+
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 );
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION SELECT 1 );
+SELECT * FROM t1 WHERE a = ANY ( SELECT 3 UNION SELECT 1 );
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO @a);
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
+
+SELECT * FROM t1 WHERE a = ( SELECT 1 );
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 INTO @a);
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 INTO OUTFILE 'file' );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 INTO DUMPFILE 'file' );
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO @a);
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
+
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 INTO @v );
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 INTO OUTFILE 'file' );
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 INTO DUMPFILE 'file' );
+
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 UNION SELECT 1 INTO @v );
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
+
+# Make sure context is popped when we leave the nested select
+SELECT ( SELECT a FROM t1 WHERE a = 1 ), a FROM t1;
+SELECT ( SELECT a FROM t1 WHERE a = 1 UNION SELECT 1 ), a FROM t1;
+
+# Make sure we have feature F561 (see .yy file)
+SELECT * FROM t2 WHERE (a, b) IN (SELECT a, b FROM t2);
+
+# Make sure the parser does not allow nested UNIONs anywhere
+
+--error ER_PARSE_ERROR
+SELECT 1 UNION ( SELECT 1 UNION SELECT 1 );
+--error ER_PARSE_ERROR
+( SELECT 1 UNION SELECT 1 ) UNION SELECT 1;
+
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+--error ER_PARSE_ERROR
+SELECT ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1;
+SELECT ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+SELECT ((SELECT 1 UNION SELECT 1 UNION SELECT 1));
+
+--error ER_PARSE_ERROR
+SELECT * FROM ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+--error ER_PARSE_ERROR
+SELECT * FROM ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+SELECT * FROM ( SELECT 1 UNION SELECT 1 UNION SELECT 1 ) a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ALL ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ANY ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a IN ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE EXISTS ( SELECT 1 UNION SELECT 1 INTO @v );
+SELECT EXISTS(SELECT 1+1);
+--error ER_PARSE_ERROR
+SELECT EXISTS(SELECT 1+1 INTO @test);
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION SELECT 1 INTO @v );
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE EXISTS ( SELECT 1 INTO @v );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a IN ( SELECT 1 INTO @v );
+
+DROP TABLE t1, t2;
#
# Bug #31157: Crash when select+order by the avg of some field within the
# group by
=== modified file 'mysql-test/t/trigger.test'
--- a/mysql-test/t/trigger.test 2009-10-12 10:59:55 +0000
+++ b/mysql-test/t/trigger.test 2009-11-10 18:11:27 +0000
@@ -2425,3 +2425,67 @@ DELETE FROM t1;
DROP TABLE t1;
DROP TEMPORARY TABLE t2;
+
+#
+# Bug#36649: Condition area is not properly cleaned up after stored routine invocation
+#
+
+--disable_warnings
+DROP TRIGGER IF EXISTS trg1;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT);
+
+delimiter |;
+CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+ DECLARE a CHAR;
+ SELECT 'ab' INTO a;
+ SELECT 'ab' INTO a;
+ SELECT 'a' INTO a;
+END|
+delimiter ;|
+
+INSERT INTO t1 VALUES (1);
+
+DROP TRIGGER trg1;
+DROP TABLE t1;
+
+#
+# Successive trigger actuations
+#
+
+--disable_warnings
+DROP TRIGGER IF EXISTS trg1;
+DROP TRIGGER IF EXISTS trg2;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT);
+
+delimiter |;
+
+CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+ DECLARE trg1 CHAR;
+ SELECT 'ab' INTO trg1;
+END|
+
+CREATE TRIGGER trg2 AFTER INSERT ON t1 FOR EACH ROW
+BEGIN
+ DECLARE trg2 CHAR;
+ SELECT 'ab' INTO trg2;
+END|
+
+delimiter ;|
+
+INSERT INTO t1 VALUES (0);
+SELECT * FROM t1;
+SHOW WARNINGS;
+INSERT INTO t1 VALUES (1),(2);
+
+DROP TRIGGER trg1;
+DROP TRIGGER trg2;
+DROP TABLE t1;
+
=== modified file 'mysql-test/t/type_time.test'
--- a/mysql-test/t/type_time.test 2009-05-15 08:16:00 +0000
+++ b/mysql-test/t/type_time.test 2009-11-04 10:28:50 +0000
@@ -39,7 +39,7 @@ drop table t1;
# SELECT CAST(0.2359591234567e+30 AS TIME);
# ##########################################################
-# End of 4.1 tests
+--echo End of 4.1 tests
#
# Bug#29555: Comparing time values as strings may lead to a wrong result.
@@ -90,3 +90,22 @@ DROP TABLE t1;
--echo End of 5.0 tests
+
+
+#
+# Bug#42664 - Sign ignored for TIME types when not comparing as longlong
+#
+
+CREATE TABLE t1 (f1 TIME);
+INSERT INTO t1 VALUES ('24:00:00');
+SELECT '24:00:00' = (SELECT f1 FROM t1);
+SELECT CAST('24:00:00' AS TIME) = (SELECT f1 FROM t1);
+SELECT CAST('-24:00:00' AS TIME) = (SELECT f1 FROM t1);
+TRUNCATE t1;
+INSERT INTO t1 VALUES ('-24:00:00');
+SELECT CAST('24:00:00' AS TIME) = (SELECT f1 FROM t1);
+SELECT CAST('-24:00:00' AS TIME) = (SELECT f1 FROM t1);
+SELECT '-24:00:00' = (SELECT f1 FROM t1);
+DROP TABLE t1;
+
+--echo End of 6.0 tests
=== modified file 'mysql-test/t/union.test'
--- a/mysql-test/t/union.test 2009-05-15 07:11:07 +0000
+++ b/mysql-test/t/union.test 2009-11-10 12:52:46 +0000
@@ -91,88 +91,6 @@ SELECT @a:=1 UNION SELECT @a:=@a+1;
(SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a);
(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2);
-
-#
-# Bug#32858: Erro: "Incorrect usage of UNION and INTO" does not take subselects
-# into account
-#
-CREATE TABLE t1 (a INT);
-INSERT INTO t1 VALUES (1);
-
-SELECT a INTO @v FROM (
- SELECT a FROM t1
- UNION
- SELECT a FROM t1
-) alias;
-
---let $outfile = $MYSQLTEST_VARDIR/tmp/union.out.file
---error 0,1
---remove_file $outfile
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a INTO OUTFILE '$outfile' FROM (
- SELECT a FROM t1
- UNION
- SELECT a FROM t1 WHERE 0
-) alias;
---remove_file $outfile
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a INTO DUMPFILE '$outfile' FROM (
- SELECT a FROM t1
- UNION
- SELECT a FROM t1 WHERE 0
-) alias;
---remove_file $outfile
-
-#
-# INTO will not be allowed in subqueries in version 5.1 and above.
-#
-SELECT a FROM (
- SELECT a FROM t1
- UNION
- SELECT a INTO @v FROM t1
-) alias;
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a FROM (
- SELECT a FROM t1
- UNION
- SELECT a INTO OUTFILE '$outfile' FROM t1
-) alias;
---remove_file $outfile
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a FROM (
- SELECT a FROM t1
- UNION
- SELECT a INTO DUMPFILE '$outfile' FROM t1
-) alias;
---remove_file $outfile
-
-SELECT a FROM t1 UNION SELECT a INTO @v FROM t1;
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a FROM t1 UNION SELECT a INTO OUTFILE '$outfile' FROM t1;
---remove_file $outfile
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a FROM t1 UNION SELECT a INTO DUMPFILE '$outfile' FROM t1;
---remove_file $outfile
-
---error ER_WRONG_USAGE
-SELECT a INTO @v FROM t1 UNION SELECT a FROM t1;
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
---error ER_WRONG_USAGE
-eval SELECT a INTO OUTFILE '$outfile' FROM t1 UNION SELECT a FROM t1;
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
---error ER_WRONG_USAGE
-eval SELECT a INTO DUMPFILE '$outfile' FROM t1 UNION SELECT a FROM t1;
-
-DROP TABLE t1;
-
#
# Test bug reported by joc@stripped
#
@@ -1102,3 +1020,45 @@ DROP TABLE t1;
--echo End of 5.0 tests
+-- echo #
+-- echo # Bug#32858: Error: "Incorrect usage of UNION and INTO" does not take
+-- echo # subselects into account
+-- echo #
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1);
+
+-- echo # Tests fix in parser rule select_derived_union.
+SELECT a INTO @v FROM (
+ SELECT a FROM t1
+ UNION
+ SELECT a FROM t1
+) alias;
+
+SELECT a INTO OUTFILE 'union.out.file' FROM (
+ SELECT a FROM t1
+ UNION
+ SELECT a FROM t1 WHERE 0
+) alias;
+
+SELECT a INTO DUMPFILE 'union.out.file2' FROM (
+ SELECT a FROM t1
+ UNION
+ SELECT a FROM t1 WHERE 0
+) alias;
+
+SELECT a FROM t1 UNION SELECT a INTO @v FROM t1;
+SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file5' FROM t1;
+SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file6' FROM t1;
+--error ER_WRONG_USAGE
+SELECT a INTO @v FROM t1 UNION SELECT a FROM t1;
+--error ER_WRONG_USAGE
+SELECT a INTO OUTFILE 'union.out.file7' FROM t1 UNION SELECT a FROM t1;
+--error ER_WRONG_USAGE
+SELECT a INTO DUMPFILE 'union.out.file8' FROM t1 UNION SELECT a FROM t1;
+
+-- echo # Tests fix in parser rule query_expression_body.
+SELECT ( SELECT a UNION SELECT a ) INTO @v FROM t1;
+SELECT ( SELECT a UNION SELECT a ) INTO OUTFILE 'union.out.file3' FROM t1;
+SELECT ( SELECT a UNION SELECT a ) INTO DUMPFILE 'union.out.file4' FROM t1;
+
+DROP TABLE t1;
=== modified file 'mysys/my_alloc.c'
--- a/mysys/my_alloc.c 2009-01-15 18:11:25 +0000
+++ b/mysys/my_alloc.c 2009-11-10 20:31:28 +0000
@@ -155,7 +155,7 @@ void *alloc_root(MEM_ROOT *mem_root, siz
DBUG_ASSERT(alloc_root_inited(mem_root));
length+=ALIGN_SIZE(sizeof(USED_MEM));
- if (!(next = (USED_MEM*) my_malloc(length,MYF(MY_WME))))
+ if (!(next = (USED_MEM*) my_malloc(length,MYF(MY_WME | ME_FATALERROR))))
{
if (mem_root->error_handler)
(*mem_root->error_handler)();
@@ -198,7 +198,7 @@ void *alloc_root(MEM_ROOT *mem_root, siz
get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
get_size= max(get_size, block_size);
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
+ if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME | ME_FATALERROR))))
{
if (mem_root->error_handler)
(*mem_root->error_handler)();
=== modified file 'mysys/my_getopt.c'
--- a/mysys/my_getopt.c 2009-11-06 14:20:27 +0000
+++ b/mysys/my_getopt.c 2009-11-19 23:48:08 +0000
@@ -1222,6 +1222,14 @@ void my_print_help(const struct my_optio
printf("%s", comment);
}
putchar('\n');
+ if ((optp->var_type & GET_TYPE_MASK) == GET_NO_ARG ||
+ (optp->var_type & GET_TYPE_MASK) == GET_BOOL)
+ {
+ if (optp->def_value != 0)
+ {
+ printf("%*s(Defaults to on; use --skip-%s to disable.)\n", name_space, "", optp->name);
+ }
+ }
}
}
=== modified file 'sql/event_data_objects.cc'
--- a/sql/event_data_objects.cc 2009-11-05 20:28:35 +0000
+++ b/sql/event_data_objects.cc 2009-11-19 23:48:08 +0000
@@ -196,7 +196,7 @@ Event_basic::Event_basic()
{
DBUG_ENTER("Event_basic::Event_basic");
/* init memory root */
- init_alloc_root(&mem_root, 256, 512);
+ init_sql_alloc(&mem_root, 256, 512);
dbname.str= name.str= NULL;
dbname.length= name.length= 0;
time_zone= NULL;
=== modified file 'sql/event_scheduler.cc'
--- a/sql/event_scheduler.cc 2009-10-13 18:29:28 +0000
+++ b/sql/event_scheduler.cc 2009-11-19 23:13:54 +0000
@@ -128,7 +128,6 @@ post_init_event_thread(THD *thd)
thd->cleanup();
return TRUE;
}
- lex_start(thd);
pthread_mutex_lock(&LOCK_thread_count);
threads.append(thd);
=== modified file 'sql/events.cc'
--- a/sql/events.cc 2009-11-21 04:28:01 +0000
+++ b/sql/events.cc 2009-11-21 04:48:54 +0000
@@ -925,7 +925,6 @@ Events::init(my_bool opt_noacl_or_bootst
*/
thd->thread_stack= (char*) &thd;
thd->store_globals();
- lex_start(thd);
/*
We will need Event_db_repository anyway, even if the scheduler is
=== modified file 'sql/field.cc'
--- a/sql/field.cc 2009-11-10 07:31:33 +0000
+++ b/sql/field.cc 2009-11-19 23:48:08 +0000
@@ -6819,86 +6819,6 @@ int Field_string::do_save_field_metadata
}
-/*
- Compare two packed keys
-
- SYNOPSIS
- pack_cmp()
- a New key
- b Original key
- length Key length
- insert_or_update 1 if this is an insert or update
-
- RETURN
- < 0 a < b
- 0 a = b
- > 0 a > b
-*/
-
-int Field_string::pack_cmp(const uchar *a, const uchar *b, uint length,
- my_bool insert_or_update)
-{
- uint a_length, b_length;
- if (length > 255)
- {
- a_length= uint2korr(a);
- b_length= uint2korr(b);
- a+= 2;
- b+= 2;
- }
- else
- {
- a_length= (uint) *a++;
- b_length= (uint) *b++;
- }
- return field_charset->coll->strnncollsp(field_charset,
- a, a_length,
- b, b_length,
- insert_or_update);
-}
-
-
-/**
- Compare a packed key against row.
-
- @param key Original key
- @param length Key length. (May be less than field length)
- @param insert_or_update 1 if this is an insert or update
-
- @return
- < 0 row < key
- @return
- 0 row = key
- @return
- > 0 row > key
-*/
-
-int Field_string::pack_cmp(const uchar *key, uint length,
- my_bool insert_or_update)
-{
- uint row_length, local_key_length;
- uchar *end;
- if (length > 255)
- {
- local_key_length= uint2korr(key);
- key+= 2;
- }
- else
- local_key_length= (uint) *key++;
-
- /* Only use 'length' of key, not field_length */
- end= ptr + length;
- while (end > ptr && end[-1] == ' ')
- end--;
- row_length= (uint) (end - ptr);
-
- return field_charset->coll->strnncollsp(field_charset,
- ptr, row_length,
- key, local_key_length,
- insert_or_update);
-}
-
-
uint Field_string::packed_col_length(const uchar *data_ptr, uint length)
{
if (length > 255)
@@ -7258,90 +7178,6 @@ uchar *Field_varstring::pack(uchar *to,
}
-uchar *
-Field_varstring::pack_key(uchar *to, const uchar *key, uint max_length,
- bool low_byte_first __attribute__((unused)))
-{
- uint length= length_bytes == 1 ? (uint) *key : uint2korr(key);
- uint local_char_length= ((field_charset->mbmaxlen > 1) ?
- max_length/field_charset->mbmaxlen : max_length);
- key+= length_bytes;
- if (length > local_char_length)
- {
- local_char_length= my_charpos(field_charset, key, key+length,
- local_char_length);
- set_if_smaller(length, local_char_length);
- }
- *to++= (char) (length & 255);
- if (max_length > 255)
- *to++= (char) (length >> 8);
- if (length)
- memcpy(to, key, length);
- return to+length;
-}
-
-
-/**
- Unpack a key into a record buffer.
-
- A VARCHAR key has a maximum size of 64K-1.
- In its packed form, the length field is one or two bytes long,
- depending on 'max_length'.
-
- @param to Pointer into the record buffer.
- @param key Pointer to the packed key.
- @param max_length Key length limit from key description.
-
- @return
- Pointer to end of 'key' (To the next key part if multi-segment key)
-*/
-
-const uchar *
-Field_varstring::unpack_key(uchar *to, const uchar *key, uint max_length,
- bool low_byte_first __attribute__((unused)))
-{
- /* get length of the blob key */
- uint32 length= *key++;
- if (max_length > 255)
- length+= (*key++) << 8;
-
- /* put the length into the record buffer */
- if (length_bytes == 1)
- *ptr= (uchar) length;
- else
- int2store(ptr, length);
- memcpy(ptr + length_bytes, key, length);
- return key + length;
-}
-
-/**
- Create a packed key that will be used for storage in the index tree.
-
- @param to Store packed key segment here
- @param from Key segment (as given to index_read())
- @param max_length Max length of key
-
- @return
- end of key storage
-*/
-
-uchar *
-Field_varstring::pack_key_from_key_image(uchar *to, const uchar *from, uint max_length,
- bool low_byte_first __attribute__((unused)))
-{
- /* Key length is always stored as 2 bytes */
- uint length= uint2korr(from);
- if (length > max_length)
- length= max_length;
- *to++= (char) (length & 255);
- if (max_length > 255)
- *to++= (char) (length >> 8);
- if (length)
- memcpy(to, from+HA_KEY_BLOB_LENGTH, length);
- return to+length;
-}
-
-
/**
Unpack a varstring field from row data.
@@ -7384,59 +7220,6 @@ Field_varstring::unpack(uchar *to, const
}
-int Field_varstring::pack_cmp(const uchar *a, const uchar *b,
- uint key_length_arg,
- my_bool insert_or_update)
-{
- uint a_length, b_length;
- if (key_length_arg > 255)
- {
- a_length=uint2korr(a); a+= 2;
- b_length=uint2korr(b); b+= 2;
- }
- else
- {
- a_length= (uint) *a++;
- b_length= (uint) *b++;
- }
- return field_charset->coll->strnncollsp(field_charset,
- a, a_length,
- b, b_length,
- insert_or_update);
-}
-
-
-int Field_varstring::pack_cmp(const uchar *b, uint key_length_arg,
- my_bool insert_or_update)
-{
- uchar *a= ptr+ length_bytes;
- uint a_length= length_bytes == 1 ? (uint) *ptr : uint2korr(ptr);
- uint b_length;
- uint local_char_length= ((field_charset->mbmaxlen > 1) ?
- key_length_arg / field_charset->mbmaxlen :
- key_length_arg);
-
- if (key_length_arg > 255)
- {
- b_length=uint2korr(b); b+= HA_KEY_BLOB_LENGTH;
- }
- else
- b_length= (uint) *b++;
-
- if (a_length > local_char_length)
- {
- local_char_length= my_charpos(field_charset, a, a+a_length,
- local_char_length);
- set_if_smaller(a_length, local_char_length);
- }
-
- return field_charset->coll->strnncollsp(field_charset,
- a, a_length,
- b, b_length,
- insert_or_update);
-}
-
-
uint Field_varstring::packed_col_length(const uchar *data_ptr, uint length)
{
if (length > 255)
@@ -8135,139 +7918,6 @@ const uchar *Field_blob::unpack(uchar *t
DBUG_RETURN(from + master_packlength + length);
}
-/* Keys for blobs are like keys on varchars */
-
-int Field_blob::pack_cmp(const uchar *a, const uchar *b, uint key_length_arg,
- my_bool insert_or_update)
-{
- uint a_length, b_length;
- if (key_length_arg > 255)
- {
- a_length=uint2korr(a); a+=2;
- b_length=uint2korr(b); b+=2;
- }
- else
- {
- a_length= (uint) *a++;
- b_length= (uint) *b++;
- }
- return field_charset->coll->strnncollsp(field_charset,
- a, a_length,
- b, b_length,
- insert_or_update);
-}
-
-
-int Field_blob::pack_cmp(const uchar *b, uint key_length_arg,
- my_bool insert_or_update)
-{
- uchar *a;
- uint a_length, b_length;
- memcpy_fixed(&a,ptr+packlength,sizeof(char*));
- if (!a)
- return key_length_arg > 0 ? -1 : 0;
-
- a_length= get_length(ptr);
- if (key_length_arg > 255)
- {
- b_length= uint2korr(b); b+=2;
- }
- else
- b_length= (uint) *b++;
- return field_charset->coll->strnncollsp(field_charset,
- a, a_length,
- b, b_length,
- insert_or_update);
-}
-
-/** Create a packed key that will be used for storage from a MySQL row. */
-
-uchar *
-Field_blob::pack_key(uchar *to, const uchar *from, uint max_length,
- bool low_byte_first __attribute__((unused)))
-{
- uchar *save= ptr;
- ptr= (uchar*) from;
- uint32 length=get_length(); // Length of from string
- uint local_char_length= ((field_charset->mbmaxlen > 1) ?
- max_length/field_charset->mbmaxlen : max_length);
- if (length)
- get_ptr((uchar**) &from);
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
- local_char_length);
- set_if_smaller(length, local_char_length);
- *to++= (uchar) length;
- if (max_length > 255) // 2 byte length
- *to++= (uchar) (length >> 8);
- memcpy(to, from, length);
- ptr=save; // Restore org row pointer
- return to+length;
-}
-
-
-/**
- Unpack a blob key into a record buffer.
-
- A blob key has a maximum size of 64K-1.
- In its packed form, the length field is one or two bytes long,
- depending on 'max_length'.
- Depending on the maximum length of a blob, its length field is
- put into 1 to 4 bytes. This is a property of the blob object,
- described by 'packlength'.
- Blobs are internally stored apart from the record buffer, which
- contains a pointer to the blob buffer.
-
-
- @param to Pointer into the record buffer.
- @param from Pointer to the packed key.
- @param max_length Key length limit from key description.
-
- @return
- Pointer into 'from' past the last byte copied from packed key.
-*/
-
-const uchar *
-Field_blob::unpack_key(uchar *to, const uchar *from, uint max_length,
- bool low_byte_first __attribute__((unused)))
-{
- /* get length of the blob key */
- uint32 length= *from++;
- if (max_length > 255)
- length+= *from++ << 8;
-
- /* put the length into the record buffer */
- put_length(to, length);
-
- /* put the address of the blob buffer or NULL */
- if (length)
- memcpy_fixed(to + packlength, &from, sizeof(from));
- else
- bzero(to + packlength, sizeof(from));
-
- /* point to first byte of next field in 'from' */
- return from + length;
-}
-
-
-/** Create a packed key that will be used for storage from a MySQL key. */
-
-uchar *
-Field_blob::pack_key_from_key_image(uchar *to, const uchar *from, uint max_length,
- bool low_byte_first __attribute__((unused)))
-{
- uint length=uint2korr(from);
- if (length > max_length)
- length=max_length;
- *to++= (char) (length & 255);
- if (max_length > 255)
- *to++= (char) (length >> 8);
- if (length)
- memcpy(to, from+HA_KEY_BLOB_LENGTH, length);
- return to+length;
-}
-
-
uint Field_blob::packed_col_length(const uchar *data_ptr, uint length)
{
if (length > 255)
=== modified file 'sql/field.h'
--- a/sql/field.h 2009-11-06 14:20:27 +0000
+++ b/sql/field.h 2009-11-19 23:48:08 +0000
@@ -25,7 +25,6 @@
#pragma interface /* gcc class implementation */
#endif
-#define NOT_FIXED_DEC 31
#define DATETIME_DEC 6
const uint32 max_field_size= (uint32) 4294967295U;
@@ -410,32 +409,11 @@ public:
DBUG_RETURN(result);
}
- virtual uchar *pack_key(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first)
- {
- return pack(to, from, max_length, low_byte_first);
- }
- virtual uchar *pack_key_from_key_image(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first)
- {
- return pack(to, from, max_length, low_byte_first);
- }
- virtual const uchar *unpack_key(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first)
- {
- return unpack(to, from, max_length, low_byte_first);
- }
virtual uint packed_col_length(const uchar *to, uint length)
{ return length;}
virtual uint max_packed_col_length(uint max_length)
{ return max_length;}
- virtual int pack_cmp(const uchar *a,const uchar *b, uint key_length_arg,
- my_bool insert_or_update)
- { return cmp(a,b); }
- virtual int pack_cmp(const uchar *b, uint key_length_arg,
- my_bool insert_or_update)
- { return cmp(ptr,b); }
uint offset(uchar *record)
{
return (uint) (ptr - record);
@@ -1503,9 +1481,6 @@ public:
int compatible_field_size(uint field_metadata,
const Relay_log_info *rli);
uint row_pack_length() { return (field_length + 1); }
- int pack_cmp(const uchar *a,const uchar *b,uint key_length,
- my_bool insert_or_update);
- int pack_cmp(const uchar *b,uint key_length,my_bool insert_or_update);
uint packed_col_length(const uchar *to, uint length);
uint max_packed_col_length(uint max_length);
uint size_of() const { return sizeof(*this); }
@@ -1579,16 +1554,8 @@ public:
void sql_type(String &str) const;
virtual uchar *pack(uchar *to, const uchar *from,
uint max_length, bool low_byte_first);
- uchar *pack_key(uchar *to, const uchar *from, uint max_length, bool low_byte_first);
- uchar *pack_key_from_key_image(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first);
virtual const uchar *unpack(uchar* to, const uchar *from,
uint param_data, bool low_byte_first);
- const uchar *unpack_key(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first);
- int pack_cmp(const uchar *a, const uchar *b, uint key_length,
- my_bool insert_or_update);
- int pack_cmp(const uchar *b, uint key_length,my_bool insert_or_update);
int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0L);
int key_cmp(const uchar *,const uchar*);
int key_cmp(const uchar *str, uint length);
@@ -1764,17 +1731,8 @@ public:
}
virtual uchar *pack(uchar *to, const uchar *from,
uint max_length, bool low_byte_first);
- uchar *pack_key(uchar *to, const uchar *from,
- uint max_length, bool low_byte_first);
- uchar *pack_key_from_key_image(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first);
virtual const uchar *unpack(uchar *to, const uchar *from,
uint param_data, bool low_byte_first);
- const uchar *unpack_key(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first);
- int pack_cmp(const uchar *a, const uchar *b, uint key_length,
- my_bool insert_or_update);
- int pack_cmp(const uchar *b, uint key_length,my_bool insert_or_update);
uint packed_col_length(const uchar *col_ptr, uint length);
uint max_packed_col_length(uint max_length);
void free() { value.free(); }
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2009-11-10 07:31:33 +0000
+++ b/sql/ha_ndbcluster.cc 2009-11-20 00:20:08 +0000
@@ -6952,7 +6952,6 @@ int ndb_create_table_from_engine(THD *th
LEX *old_lex= thd->lex, newlex;
thd->lex= &newlex;
newlex.current_select= NULL;
- lex_start(thd);
int res= ha_create_table_from_engine(thd, db, table_name);
thd->lex= old_lex;
return res;
@@ -9272,7 +9271,6 @@ pthread_handler_t ndb_util_thread_func(v
thd->thread_stack= (char*)&thd; /* remember where our stack is */
if (thd->store_globals())
goto ndb_util_thread_fail;
- lex_start(thd);
thd->init_for_queries();
thd->version=refresh_version;
thd->main_security_ctx.host_or_ip= "";
=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc 2009-11-10 07:31:33 +0000
+++ b/sql/ha_ndbcluster_binlog.cc 2009-11-20 00:20:08 +0000
@@ -3669,7 +3669,6 @@ pthread_handler_t ndb_binlog_thread_func
pthread_exit(0);
return NULL; // Avoid compiler warnings
}
- lex_start(thd);
thd->init_for_queries();
thd->command= COM_DAEMON;
=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc 2009-11-03 11:37:02 +0000
+++ b/sql/ha_partition.cc 2009-11-19 23:48:08 +0000
@@ -1980,8 +1980,7 @@ partition_element *ha_partition::find_pa
return part_elem;
}
DBUG_ASSERT(0);
- my_error(ER_OUT_OF_RESOURCES, MYF(0));
- current_thd->fatal_error(); // Abort
+ my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR));
return NULL;
}
=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc 2009-11-03 12:48:59 +0000
+++ b/sql/item_cmpfunc.cc 2009-11-19 23:48:08 +0000
@@ -855,7 +855,8 @@ get_time_value(THD *thd, Item ***item_ar
else
{
*is_null= item->get_time(<ime);
- value= !*is_null ? (longlong) TIME_to_ulonglong_datetime(<ime) : 0;
+ value= !*is_null ? (longlong) TIME_to_ulonglong_datetime(<ime) *
+ (ltime.neg ? -1 : 1) : 0;
}
/*
Do not cache GET_USER_VAR() function as its const_item() may return TRUE
=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc 2009-11-06 14:20:27 +0000
+++ b/sql/item_func.cc 2009-11-19 23:48:08 +0000
@@ -3474,6 +3474,48 @@ void debug_sync_point(const char* lock_n
#endif
+
+/**
+ Wait for a given condition to be signaled within the specified timeout.
+
+ @param cond the condition variable to wait on
+ @param lock the associated mutex
+ @param abstime the amount of time in seconds to wait
+
+ @retval return value from pthread_cond_timedwait
+*/
+
+#define INTERRUPT_INTERVAL (5 * ULL(1000000000))
+
+static int interruptible_wait(THD *thd, pthread_cond_t *cond,
+ pthread_mutex_t *lock, double time)
+{
+ int error;
+ struct timespec abstime;
+ ulonglong slice, timeout= (ulonglong) (time * 1000000000.0);
+
+ do
+ {
+ /* Wait for a fixed interval. */
+ if (timeout > INTERRUPT_INTERVAL)
+ slice= INTERRUPT_INTERVAL;
+ else
+ slice= timeout;
+
+ timeout-= slice;
+ set_timespec_nsec(abstime, slice);
+ error= pthread_cond_timedwait(cond, lock, &abstime);
+ if (error == ETIMEDOUT || error == ETIME)
+ {
+ /* Return error if timed out or connection is broken. */
+ if (!timeout || !thd->is_connected())
+ break;
+ }
+ } while (error && timeout);
+
+ return error;
+}
+
/**
Get a user level lock. If the thread has an old lock this is first released.
@@ -3489,8 +3531,7 @@ longlong Item_func_get_lock::val_int()
{
DBUG_ASSERT(fixed == 1);
String *res=args[0]->val_str(&value);
- longlong timeout=args[1]->val_int();
- struct timespec abstime;
+ double timeout= args[1]->val_real();
THD *thd=current_thd;
User_level_lock *ull;
int error;
@@ -3554,12 +3595,11 @@ longlong Item_func_get_lock::val_int()
thd->mysys_var->current_mutex= &LOCK_user_locks;
thd->mysys_var->current_cond= &ull->cond;
- set_timespec(abstime,timeout);
error= 0;
while (ull->locked && !thd->killed)
{
DBUG_PRINT("info", ("waiting on lock"));
- error= pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime);
+ error= interruptible_wait(thd, &ull->cond, &LOCK_user_locks, timeout);
if (error == ETIMEDOUT || error == ETIME)
{
DBUG_PRINT("info", ("lock wait timeout"));
@@ -3754,13 +3794,13 @@ void Item_func_benchmark::print(String *
longlong Item_func_sleep::val_int()
{
THD *thd= current_thd;
- struct timespec abstime;
pthread_cond_t cond;
+ double timeout;
int error;
DBUG_ASSERT(fixed == 1);
- double time= args[0]->val_real();
+ timeout= args[0]->val_real();
/*
On 64-bit OSX pthread_cond_timedwait() waits forever
if passed abstime time has already been exceeded by
@@ -3770,10 +3810,8 @@ longlong Item_func_sleep::val_int()
We assume that the lines between this test and the call
to pthread_cond_timedwait() will be executed in less than 0.00001 sec.
*/
- if (time < 0.00001)
+ if (timeout < 0.00001)
return 0;
-
- set_timespec_nsec(abstime, (ulonglong)(time * ULL(1000000000)));
pthread_cond_init(&cond, NULL);
pthread_mutex_lock(&LOCK_user_locks);
@@ -3785,7 +3823,7 @@ longlong Item_func_sleep::val_int()
error= 0;
while (!thd->killed)
{
- error= pthread_cond_timedwait(&cond, &LOCK_user_locks, &abstime);
+ error= interruptible_wait(thd, &cond, &LOCK_user_locks, timeout);
if (error == ETIMEDOUT || error == ETIME)
break;
error= 0;
@@ -3817,7 +3855,7 @@ static user_var_entry *get_variable(HASH
uint size=ALIGN_SIZE(sizeof(user_var_entry))+name.length+1+extra_size;
if (!my_hash_inited(hash))
return 0;
- if (!(entry = (user_var_entry*) my_malloc(size,MYF(MY_WME))))
+ if (!(entry = (user_var_entry*) my_malloc(size,MYF(MY_WME | ME_FATALERROR))))
return 0;
entry->name.str=(char*) entry+ ALIGN_SIZE(sizeof(user_var_entry))+
extra_size;
@@ -3955,6 +3993,8 @@ bool Item_func_set_user_var::register_fi
@param dv derivation for new value
@param unsigned_arg indiates if a value of type INT_RESULT is unsigned
+ @note Sets error and fatal error if allocation fails.
+
@retval
false success
@retval
@@ -3998,7 +4038,8 @@ update_hash(user_var_entry *entry, bool
if (entry->value == pos)
entry->value=0;
entry->value= (char*) my_realloc(entry->value, length,
- MYF(MY_ALLOW_ZERO_PTR | MY_WME));
+ MYF(MY_ALLOW_ZERO_PTR | MY_WME |
+ ME_FATALERROR));
if (!entry->value)
return 1;
}
@@ -4035,7 +4076,6 @@ Item_func_set_user_var::update_hash(void
if (::update_hash(entry, (null_value= args[0]->null_value),
ptr, length, res_type, cs, dv, unsigned_arg))
{
- current_thd->fatal_error(); // Probably end of memory
null_value= 1;
return 1;
}
@@ -4768,11 +4808,6 @@ void Item_func_get_user_var::fix_length_
m_cached_result_type= STRING_RESULT;
max_length= MAX_BLOB_WIDTH;
}
-
- if (error)
- thd->fatal_error();
-
- return;
}
@@ -4843,18 +4878,16 @@ bool Item_user_var_as_out_param::fix_fie
void Item_user_var_as_out_param::set_null_value(CHARSET_INFO* cs)
{
- if (::update_hash(entry, TRUE, 0, 0, STRING_RESULT, cs,
- DERIVATION_IMPLICIT, 0 /* unsigned_arg */))
- current_thd->fatal_error(); // Probably end of memory
+ ::update_hash(entry, TRUE, 0, 0, STRING_RESULT, cs,
+ DERIVATION_IMPLICIT, 0 /* unsigned_arg */);
}
void Item_user_var_as_out_param::set_value(const char *str, uint length,
CHARSET_INFO* cs)
{
- if (::update_hash(entry, FALSE, (void*)str, length, STRING_RESULT, cs,
- DERIVATION_IMPLICIT, 0 /* unsigned_arg */))
- current_thd->fatal_error(); // Probably end of memory
+ ::update_hash(entry, FALSE, (void*)str, length, STRING_RESULT, cs,
+ DERIVATION_IMPLICIT, 0 /* unsigned_arg */);
}
=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc 2009-11-06 16:13:33 +0000
+++ b/sql/item_subselect.cc 2009-11-19 23:48:08 +0000
@@ -1740,8 +1740,6 @@ subselect_union_engine::subselect_union_
:subselect_engine(item_arg, result_arg)
{
unit= u;
- if (!result_arg) //out of memory
- current_thd->fatal_error();
unit->item= item_arg;
}
@@ -1753,10 +1751,7 @@ int subselect_single_select_engine::prep
join= new JOIN(thd, select_lex->item_list,
select_lex->options | SELECT_NO_UNLOCK, result);
if (!join || !result)
- {
- thd->fatal_error(); //out of memory
- return 1;
- }
+ return 1; /* Fatal error is set already. */
prepared= 1;
SELECT_LEX *save_select= thd->lex->current_select;
thd->lex->current_select= select_lex;
=== modified file 'sql/item_timefunc.cc'
--- a/sql/item_timefunc.cc 2009-10-28 17:22:36 +0000
+++ b/sql/item_timefunc.cc 2009-11-19 23:48:08 +0000
@@ -865,6 +865,8 @@ static bool get_interval_info(const char
{
const char *end=str+length;
uint i;
+ long msec_length= 0;
+
while (str != end && !my_isdigit(cs,*str))
str++;
@@ -874,12 +876,7 @@ static bool get_interval_info(const char
const char *start= str;
for (value=0; str != end && my_isdigit(cs,*str) ; str++)
value= value*LL(10) + (longlong) (*str - '0');
- if (transform_msec && i == count - 1) // microseconds always last
- {
- long msec_length= 6 - (uint) (str - start);
- if (msec_length > 0)
- value*= (long) log_10_int[msec_length];
- }
+ msec_length= 6 - (str - start);
values[i]= value;
while (str != end && !my_isdigit(cs,*str))
str++;
@@ -893,6 +890,10 @@ static bool get_interval_info(const char
break;
}
}
+
+ if (transform_msec && msec_length > 0)
+ values[count - 1] *= (long) log_10_int[msec_length];
+
return (str != end);
}
@@ -1854,7 +1855,7 @@ longlong Item_func_sec_to_time::val_int(
sec_to_time(arg_val, args[0]->unsigned_flag, <ime);
return (ltime.neg ? -1 : 1) *
- ((ltime.hour)*10000 + ltime.minute*100 + ltime.second);
+ (longlong) ((ltime.hour)*10000 + ltime.minute*100 + ltime.second);
}
@@ -2666,7 +2667,8 @@ longlong Item_time_typecast::val_int()
null_value= 1;
return 0;
}
- return ltime.hour * 10000L + ltime.minute * 100 + ltime.second;
+ return (ltime.neg ? -1 : 1) *
+ (longlong) ((ltime.hour)*10000 + ltime.minute*100 + ltime.second);
}
String *Item_time_typecast::val_str(String *str)
=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h 2009-11-21 04:28:01 +0000
+++ b/sql/mysql_priv.h 2009-11-21 04:48:54 +0000
@@ -1076,9 +1076,9 @@ inline bool check_access(THD *thd, ulong
return false;
}
inline bool check_table_access(THD *thd, ulong requirements,TABLE_LIST *tables,
- bool no_errors,
bool any_combination_of_privileges_will_do,
- uint number)
+ uint number,
+ bool no_errors)
{ return false; }
#endif /*NO_EMBEDDED_ACCESS_CHECKS*/
=== modified file 'sql/opt_sum.cc'
--- a/sql/opt_sum.cc 2009-10-28 10:07:30 +0000
+++ b/sql/opt_sum.cc 2009-11-10 20:31:28 +0000
@@ -175,8 +175,7 @@ int opt_sum_query(TABLE_LIST *tables, Li
error= tl->table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
if(error)
{
- tl->table->file->print_error(error, MYF(0));
- tl->table->in_use->fatal_error();
+ tl->table->file->print_error(error, MYF(ME_FATALERROR));
return error;
}
count*= tl->table->file->stats.records;
@@ -427,8 +426,7 @@ int opt_sum_query(TABLE_LIST *tables, Li
if (error == HA_ERR_KEY_NOT_FOUND || error == HA_ERR_END_OF_FILE)
return HA_ERR_KEY_NOT_FOUND; // No rows matching WHERE
/* HA_ERR_LOCK_DEADLOCK or some other error */
- table->file->print_error(error, MYF(0));
- table->in_use->fatal_error();
+ table->file->print_error(error, MYF(ME_FATALERROR));
return(error);
}
removed_tables|= table->map;
=== modified file 'sql/share/errmsg.txt'
--- a/sql/share/errmsg.txt 2009-10-28 17:22:36 +0000
+++ b/sql/share/errmsg.txt 2009-11-19 23:48:08 +0000
@@ -4880,6 +4880,7 @@ ER_ZLIB_Z_DATA_ERROR
spa "ZLIB: Dato de entrada fu�orrompido para zlib"
ER_CUT_VALUE_GROUP_CONCAT
eng "Row %u was cut by GROUP_CONCAT()"
+ por "Linha %u foi cortada por GROUP_CONCAT()"
ER_WARN_TOO_FEW_RECORDS 01000
eng "Row %ld doesn't contain data for all columns"
ger "Zeile %ld enth� nicht f�e Felder Daten"
=== modified file 'sql/slave.cc'
--- a/sql/slave.cc 2009-11-10 07:31:33 +0000
+++ b/sql/slave.cc 2009-11-20 00:20:08 +0000
@@ -2121,7 +2121,6 @@ static int init_slave_thread(THD* thd, S
thd->cleanup();
DBUG_RETURN(-1);
}
- lex_start(thd);
if (thd_type == SLAVE_THD_SQL)
thd_proc_info(thd, "Waiting for the next event in relay log");
=== modified file 'sql/sp.cc'
--- a/sql/sp.cc 2009-11-21 04:28:01 +0000
+++ b/sql/sp.cc 2009-11-21 04:48:54 +0000
@@ -1719,6 +1719,9 @@ sp_cache_routines_and_add_tables_aux(THD
ret= SP_OK;
break;
default:
+ /* Query might have been killed, don't set error. */
+ if (thd->killed)
+ break;
/*
Any error when loading an existing routine is either some problem
with the mysql.proc table, or a parse error because the contents
=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc 2009-11-21 04:28:01 +0000
+++ b/sql/sp_head.cc 2009-11-21 04:48:54 +0000
@@ -1086,7 +1086,6 @@ sp_head::execute(THD *thd)
Item_change_list old_change_list;
String old_packet;
Reprepare_observer *save_reprepare_observer= thd->m_reprepare_observer;
-
Object_creation_ctx *saved_creation_ctx;
Warning_info *saved_warning_info, warning_info(thd->warning_info->warn_id());
@@ -4006,7 +4005,7 @@ sp_head::add_used_tables_to_table_list(T
/**
- Simple function for adding an explicetly named (systems) table to
+ Simple function for adding an explicitly named (systems) table to
the global table list, e.g. "mysql", "proc".
*/
@@ -4018,10 +4017,7 @@ sp_add_to_query_tables(THD *thd, LEX *le
TABLE_LIST *table;
if (!(table= (TABLE_LIST *)thd->calloc(sizeof(TABLE_LIST))))
- {
- thd->fatal_error();
return NULL;
- }
table->db_length= strlen(db);
table->db= thd->strmake(db, table->db_length);
table->table_name_length= strlen(name);
=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc 2009-11-21 04:28:01 +0000
+++ b/sql/sql_acl.cc 2009-11-21 04:48:54 +0000
@@ -276,7 +276,6 @@ my_bool acl_init(bool dont_read_acl_tabl
DBUG_RETURN(1); /* purecov: inspected */
thd->thread_stack= (char*) &thd;
thd->store_globals();
- lex_start(thd);
/*
It is safe to call acl_reload() since acl_* arrays and hashes which
will be freed there are global static objects and thus are initialized
@@ -3525,7 +3524,6 @@ my_bool grant_init()
DBUG_RETURN(1); /* purecov: deadcode */
thd->thread_stack= (char*) &thd;
thd->store_globals();
- lex_start(thd);
return_val= grant_reload(thd);
delete thd;
/* Remember that we don't have a THD */
=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc 2009-11-21 04:28:01 +0000
+++ b/sql/sql_base.cc 2009-11-21 04:48:54 +0000
@@ -2536,9 +2536,6 @@ TABLE *open_table(THD *thd, TABLE_LIST *
HASH_SEARCH_STATE state;
DBUG_ENTER("open_table");
- /* Parsing of partitioning information from .frm needs thd->lex set up. */
- DBUG_ASSERT(thd->lex->is_lex_started);
-
/* find a unused table in the open table cache */
if (refresh)
*refresh=0;
=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc 2009-11-06 15:28:25 +0000
+++ b/sql/sql_cache.cc 2009-11-19 23:48:08 +0000
@@ -1331,12 +1331,12 @@ end:
@param thd Pointer to the thread handler
@param sql A pointer to the sql statement *
@param query_length Length of the statement in characters
-
+
@return status code
- @retval 1 Query was not cached.
- @retval 0 The query was cached and user was sent the result.
- @retval -1 The query was cached but we didn't have rights to use it.
-
+ @retval 0 Query was not cached.
+ @retval 1 The query was cached and user was sent the result.
+ @retval -1 The query was cached but we didn't have rights to use it.
+
In case of -1, no error is sent to the client.
*) The buffer must be allocated memory of size:
=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc 2009-11-10 07:31:33 +0000
+++ b/sql/sql_class.cc 2009-11-20 14:18:37 +0000
@@ -1609,7 +1609,6 @@ void THD::rollback_item_tree_changes()
select_result::select_result()
{
thd=current_thd;
- nest_level= -1;
}
void select_result::send_error(uint errcode,const char *err)
=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h 2009-11-21 04:28:01 +0000
+++ b/sql/sql_class.h 2009-11-21 04:48:54 +0000
@@ -1982,9 +1982,15 @@ public:
DBUG_VOID_RETURN;
}
inline bool vio_ok() const { return net.vio != 0; }
+ /** Return FALSE if connection to client is broken. */
+ bool is_connected()
+ {
+ return vio_ok() ? vio_is_connected(net.vio) : FALSE;
+ }
#else
void clear_error();
- inline bool vio_ok() const { return true; }
+ inline bool vio_ok() const { return TRUE; }
+ inline bool is_connected() { return TRUE; }
#endif
/**
Mark the current error as fatal. Warning: this does not
@@ -1993,6 +1999,7 @@ public:
*/
inline void fatal_error()
{
+ DBUG_ASSERT(main_da.is_error());
is_fatal_error= 1;
DBUG_PRINT("error",("Fatal error set"));
}
@@ -2158,7 +2165,10 @@ public:
else
{
x_free(db);
- db= new_db ? my_strndup(new_db, new_db_len, MYF(MY_WME)) : NULL;
+ if (new_db)
+ db= my_strndup(new_db, new_db_len, MYF(MY_WME | ME_FATALERROR));
+ else
+ db= NULL;
}
db_length= db ? new_db_len : 0;
return new_db && !db;
@@ -2400,7 +2410,6 @@ class select_result :public Sql_alloc {
protected:
THD *thd;
SELECT_LEX_UNIT *unit;
- uint nest_level;
public:
select_result();
virtual ~select_result() {};
@@ -2437,12 +2446,6 @@ public:
*/
virtual void cleanup();
void set_thd(THD *thd_arg) { thd= thd_arg; }
- /**
- The nest level, if supported.
- @return
- -1 if nest level is undefined, otherwise a positive integer.
- */
- int get_nest_level() { return nest_level; }
#ifdef EMBEDDED_LIBRARY
virtual void begin_dataset() {}
#else
@@ -2537,14 +2540,6 @@ class select_export :public select_to_fi
CHARSET_INFO *write_cs; // output charset
public:
select_export(sql_exchange *ex) :select_to_file(ex) {}
- /**
- Creates a select_export to represent INTO OUTFILE <filename> with a
- defined level of subquery nesting.
- */
- select_export(sql_exchange *ex, uint nest_level_arg) :select_to_file(ex)
- {
- nest_level= nest_level_arg;
- }
~select_export();
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
bool send_data(List<Item> &items);
@@ -2554,15 +2549,6 @@ public:
class select_dump :public select_to_file {
public:
select_dump(sql_exchange *ex) :select_to_file(ex) {}
- /**
- Creates a select_export to represent INTO DUMPFILE <filename> with a
- defined level of subquery nesting.
- */
- select_dump(sql_exchange *ex, uint nest_level_arg) :
- select_to_file(ex)
- {
- nest_level= nest_level_arg;
- }
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
bool send_data(List<Item> &items);
};
@@ -3033,16 +3019,6 @@ class select_dumpvar :public select_resu
public:
List<my_var> var_list;
select_dumpvar() { var_list.empty(); row_count= 0;}
- /**
- Creates a select_dumpvar to represent INTO <variable> with a defined
- level of subquery nesting.
- */
- select_dumpvar(uint nest_level_arg)
- {
- var_list.empty();
- row_count= 0;
- nest_level= nest_level_arg;
- }
~select_dumpvar() {}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
bool send_data(List<Item> &items);
=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc 2009-11-21 04:28:01 +0000
+++ b/sql/sql_insert.cc 2009-11-21 04:48:54 +0000
@@ -1922,20 +1922,17 @@ bool delayed_get_table(THD *thd, TABLE_L
if (! (di= find_handler(thd, table_list)))
{
if (!(di= new Delayed_insert()))
- {
- thd->fatal_error();
goto end_create;
- }
pthread_mutex_lock(&LOCK_thread_count);
thread_count++;
pthread_mutex_unlock(&LOCK_thread_count);
di->thd.set_db(table_list->db, (uint) strlen(table_list->db));
- di->thd.set_query(my_strdup(table_list->table_name, MYF(MY_WME)), 0);
+ di->thd.set_query(my_strdup(table_list->table_name,
+ MYF(MY_WME | ME_FATALERROR)), 0);
if (di->thd.db == NULL || di->thd.query() == NULL)
{
/* The error is reported */
delete di;
- thd->fatal_error();
goto end_create;
}
di->table_list= *table_list; // Needed to open table
@@ -1953,8 +1950,7 @@ bool delayed_get_table(THD *thd, TABLE_L
pthread_mutex_unlock(&di->mutex);
di->unlock();
delete di;
- my_error(ER_CANT_CREATE_THREAD, MYF(0), error);
- thd->fatal_error();
+ my_error(ER_CANT_CREATE_THREAD, MYF(ME_FATALERROR), error);
goto end_create;
}
@@ -2308,12 +2304,6 @@ static void handle_delayed_insert_impl(T
goto err;
}
- /*
- Open table requires an initialized lex in case the table is
- partitioned. The .frm file contains a partial SQL string which is
- parsed using a lex, that depends on initialized thd->lex.
- */
- lex_start(thd);
thd->lex->sql_command= SQLCOM_INSERT; // For innodb::store_lock()
/*
Statement-based replication of INSERT DELAYED has problems with RAND()
@@ -2331,8 +2321,8 @@ static void handle_delayed_insert_impl(T
}
if (!(di->table->file->ha_table_flags() & HA_CAN_INSERT_DELAYED))
{
- thd->fatal_error();
- my_error(ER_DELAYED_NOT_SUPPORTED, MYF(0), di->table_list.table_name);
+ my_error(ER_DELAYED_NOT_SUPPORTED, MYF(ME_FATALERROR),
+ di->table_list.table_name);
goto err;
}
if (di->table->triggers)
=== modified file 'sql/sql_list.h'
--- a/sql/sql_list.h 2009-10-22 19:31:06 +0000
+++ b/sql/sql_list.h 2009-11-10 20:31:28 +0000
@@ -458,7 +458,7 @@ struct ilink
struct ilink **prev,*next;
static void *operator new(size_t size) throw ()
{
- return (void*)my_malloc((uint)size, MYF(MY_WME | MY_FAE));
+ return (void*)my_malloc((uint)size, MYF(MY_WME | MY_FAE | ME_FATALERROR));
}
static void operator delete(void* ptr_arg, size_t size)
{
=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc 2009-11-21 04:28:01 +0000
+++ b/sql/sql_parse.cc 2009-11-21 04:48:54 +0000
@@ -1369,54 +1369,6 @@ bool dispatch_command(enum enum_server_c
thd->stmt_da->disable_status(); // Don't send anything back
error=TRUE; // End server
break;
-
-#ifdef REMOVED
- case COM_CREATE_DB: // QQ: To be removed
- {
- LEX_STRING db, alias;
- HA_CREATE_INFO create_info;
-
- status_var_increment(thd->status_var.com_stat[SQLCOM_CREATE_DB]);
- if (thd->make_lex_string(&db, packet, packet_length, FALSE) ||
- thd->make_lex_string(&alias, db.str, db.length, FALSE) ||
- check_db_name(&db))
- {
- my_error(ER_WRONG_DB_NAME, MYF(0), db.str ? db.str : "NULL");
- break;
- }
- if (check_access(thd, CREATE_ACL, db.str , 0, 1, 0,
- is_schema_db(db.str)))
- break;
- general_log_print(thd, command, "%.*s", db.length, db.str);
- bzero(&create_info, sizeof(create_info));
- mysql_create_db(thd, (lower_case_table_names == 2 ? alias.str : db.str),
- &create_info, 0);
- break;
- }
- case COM_DROP_DB: // QQ: To be removed
- {
- status_var_increment(thd->status_var.com_stat[SQLCOM_DROP_DB]);
- LEX_STRING db;
-
- if (thd->make_lex_string(&db, packet, packet_length, FALSE) ||
- check_db_name(&db))
- {
- my_error(ER_WRONG_DB_NAME, MYF(0), db.str ? db.str : "NULL");
- break;
- }
- if (check_access(thd, DROP_ACL, db.str, 0, 1, 0, is_schema_db(db.str)))
- break;
- if (thd->locked_tables || thd->active_transaction())
- {
- my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
- ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
- break;
- }
- general_log_write(thd, command, "%.*s", db.length, db.str);
- mysql_rm_db(thd, db.str, 0, 0);
- break;
- }
-#endif
#ifndef EMBEDDED_LIBRARY
case COM_BINLOG_DUMP:
{
@@ -2073,7 +2025,6 @@ mysql_execute_command(THD *thd)
A better approach would be to reset this for any commands
that is not a SHOW command or a select that only access local
variables, but for now this is probably good enough.
- Don't reset warnings when executing a stored routine.
*/
if ((sql_command_flags[lex->sql_command] & CF_DIAGNOSTIC_STMT) != 0)
thd->warning_info->set_read_only(TRUE);
@@ -2276,7 +2227,7 @@ mysql_execute_command(THD *thd)
privileges_requested,
all_tables, FALSE, UINT_MAX, FALSE);
else
- res= check_access(thd, privileges_requested, any_db, 0, 0, 0, UINT_MAX);
+ res= check_access(thd, privileges_requested, any_db, 0, 0, 0, 0);
if (res)
break;
@@ -5831,7 +5782,6 @@ bool check_stack_overrun(THD *thd, long
my_snprintf(ebuff, sizeof(ebuff), ER(ER_STACK_OVERRUN_NEED_MORE),
stack_used, my_thread_stack_size, margin);
my_message(ER_STACK_OVERRUN_NEED_MORE, ebuff, MYF(ME_FATALERROR));
- thd->fatal_error();
return 1;
}
#ifndef DBUG_OFF
@@ -6495,13 +6445,17 @@ TABLE_LIST *st_select_lex::add_table_to_
DBUG_RETURN(0); /* purecov: inspected */
if (table->db.str)
{
+ ptr->is_fqtn= TRUE;
ptr->db= table->db.str;
ptr->db_length= table->db.length;
}
else if (lex->copy_db_to(&ptr->db, &ptr->db_length))
DBUG_RETURN(0);
+ else
+ ptr->is_fqtn= FALSE;
ptr->alias= alias_str;
+ ptr->is_alias= alias ? TRUE : FALSE;
if (lower_case_table_names && table->table.length)
table->table.length= my_casedn_str(files_charset_info, table->table.str);
ptr->table_name=table->table.str;
@@ -7051,7 +7005,6 @@ bool reload_acl_and_cache(THD *thd, ulon
{
thd->thread_stack= (char*) &tmp_thd;
thd->store_globals();
- lex_start(thd);
}
if (thd)
@@ -7548,6 +7501,63 @@ bool multi_delete_precheck(THD *thd, TAB
}
+/*
+ Given a table in the source list, find a correspondent table in the
+ table references list.
+
+ @param lex Pointer to LEX representing multi-delete.
+ @param src Source table to match.
+ @param ref Table references list.
+
+ @remark The source table list (tables listed before the FROM clause
+ or tables listed in the FROM clause before the USING clause) may
+ contain table names or aliases that must match unambiguously one,
+ and only one, table in the target table list (table references list,
+ after FROM/USING clause).
+
+ @return Matching table, NULL otherwise.
+*/
+
+static TABLE_LIST *multi_delete_table_match(LEX *lex, TABLE_LIST *tbl,
+ TABLE_LIST *tables)
+{
+ TABLE_LIST *match= NULL;
+ DBUG_ENTER("multi_delete_table_match");
+
+ for (TABLE_LIST *elem= tables; elem; elem= elem->next_local)
+ {
+ int cmp;
+
+ if (tbl->is_fqtn && elem->is_alias)
+ continue; /* no match */
+ if (tbl->is_fqtn && elem->is_fqtn)
+ cmp= my_strcasecmp(table_alias_charset, tbl->table_name, elem->table_name) ||
+ strcmp(tbl->db, elem->db);
+ else if (elem->is_alias)
+ cmp= my_strcasecmp(table_alias_charset, tbl->alias, elem->alias);
+ else
+ cmp= my_strcasecmp(table_alias_charset, tbl->table_name, elem->table_name) ||
+ strcmp(tbl->db, elem->db);
+
+ if (cmp)
+ continue;
+
+ if (match)
+ {
+ my_error(ER_NONUNIQ_TABLE, MYF(0), elem->alias);
+ DBUG_RETURN(NULL);
+ }
+
+ match= elem;
+ }
+
+ if (!match)
+ my_error(ER_UNKNOWN_TABLE, MYF(0), tbl->table_name, "MULTI DELETE");
+
+ DBUG_RETURN(match);
+}
+
+
/**
Link tables in auxilary table list of multi-delete with corresponding
elements in main table list, and set proper locks for them.
@@ -7573,20 +7583,9 @@ bool multi_delete_set_locks_and_link_aux
{
lex->table_count++;
/* All tables in aux_tables must be found in FROM PART */
- TABLE_LIST *walk;
- for (walk= tables; walk; walk= walk->next_local)
- {
- if (!my_strcasecmp(table_alias_charset,
- target_tbl->alias, walk->alias) &&
- !strcmp(walk->db, target_tbl->db))
- break;
- }
+ TABLE_LIST *walk= multi_delete_table_match(lex, target_tbl, tables);
if (!walk)
- {
- my_error(ER_UNKNOWN_TABLE, MYF(0),
- target_tbl->table_name, "MULTI DELETE");
DBUG_RETURN(TRUE);
- }
if (!walk->derived)
{
target_tbl->table_name= walk->table_name;
=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc 2009-11-21 04:28:01 +0000
+++ b/sql/sql_partition.cc 2009-11-21 04:48:54 +0000
@@ -932,6 +932,85 @@ int check_signed_flag(partition_info *pa
return error;
}
+/**
+ Initialize lex object for use in fix_fields and parsing.
+
+ SYNOPSIS
+ init_lex_with_single_table()
+ @param thd The thread object
+ @param table The table object
+ @return Operation status
+ @retval TRUE An error occurred, memory allocation error
+ @retval FALSE Ok
+
+ DESCRIPTION
+ This function is used to initialize a lex object on the
+ stack for use by fix_fields and for parsing. In order to
+ work properly it also needs to initialize the
+ Name_resolution_context object of the lexer.
+ Finally it needs to set a couple of variables to ensure
+ proper functioning of fix_fields.
+*/
+
+static int
+init_lex_with_single_table(THD *thd, TABLE *table, LEX *lex)
+{
+ TABLE_LIST *table_list;
+ Table_ident *table_ident;
+ SELECT_LEX *select_lex= &lex->select_lex;
+ Name_resolution_context *context= &select_lex->context;
+ /*
+ We will call the parser to create a part_info struct based on the
+ partition string stored in the frm file.
+ We will use a local lex object for this purpose. However we also
+ need to set the Name_resolution_object for this lex object. We
+ do this by using add_table_to_list where we add the table that
+ we're working with to the Name_resolution_context.
+ */
+ thd->lex= lex;
+ lex_start(thd);
+ context->init();
+ if ((!(table_ident= new Table_ident(thd,
+ table->s->table_name,
+ table->s->db, TRUE))) ||
+ (!(table_list= select_lex->add_table_to_list(thd,
+ table_ident,
+ NULL,
+ 0))))
+ return TRUE;
+ context->resolve_in_table_list_only(table_list);
+ lex->use_only_table_context= TRUE;
+ select_lex->cur_pos_in_select_list= UNDEF_POS;
+ table->map= 1; //To ensure correct calculation of const item
+ table->get_fields_in_item_tree= TRUE;
+ table_list->table= table;
+ return FALSE;
+}
+
+/**
+ End use of local lex with single table
+
+ SYNOPSIS
+ end_lex_with_single_table()
+ @param thd The thread object
+ @param table The table object
+ @param old_lex The real lex object connected to THD
+
+ DESCRIPTION
+ This function restores the real lex object after calling
+ init_lex_with_single_table and also restores some table
+ variables temporarily set.
+*/
+
+static void
+end_lex_with_single_table(THD *thd, TABLE *table, LEX *old_lex)
+{
+ LEX *lex= thd->lex;
+ table->map= 0;
+ table->get_fields_in_item_tree= FALSE;
+ lex_end(lex);
+ thd->lex= old_lex;
+}
/*
The function uses a new feature in fix_fields where the flag
@@ -972,55 +1051,18 @@ static bool fix_fields_part_func(THD *th
bool is_sub_part)
{
partition_info *part_info= table->part_info;
- uint dir_length, home_dir_length;
bool result= TRUE;
- TABLE_LIST tables;
- TABLE_LIST *save_table_list, *save_first_table, *save_last_table;
int error;
- Name_resolution_context *context;
const char *save_where;
- char* db_name;
- char db_name_string[FN_REFLEN];
- bool save_use_only_table_context;
+ LEX *old_lex= thd->lex;
+ LEX lex;
DBUG_ENTER("fix_fields_part_func");
- /*
- Set-up the TABLE_LIST object to be a list with a single table
- Set the object to zero to create NULL pointers and set alias
- and real name to table name and get database name from file name.
- TODO: Consider generalizing or refactoring Lex::add_table_to_list() so
- it can be used in all places where we create TABLE_LIST objects.
- Also consider creating appropriate constructors for TABLE_LIST.
- */
-
- bzero((void*)&tables, sizeof(TABLE_LIST));
- tables.alias= tables.table_name= (char*) table->s->table_name.str;
- tables.table= table;
- tables.next_local= 0;
- tables.next_name_resolution_table= 0;
- /*
- Cache the table in Item_fields. All the tables can be cached except
- the trigger pseudo table.
- */
- tables.cacheable_table= TRUE;
- context= thd->lex->current_context();
- tables.select_lex= context->select_lex;
- strmov(db_name_string, table->s->normalized_path.str);
- dir_length= dirname_length(db_name_string);
- db_name_string[dir_length - 1]= 0;
- home_dir_length= dirname_length(db_name_string);
- db_name= &db_name_string[home_dir_length];
- tables.db= db_name;
+ if (init_lex_with_single_table(thd, table, &lex))
+ goto end;
- table->map= 1; //To ensure correct calculation of const item
- table->get_fields_in_item_tree= TRUE;
- save_table_list= context->table_list;
- save_first_table= context->first_name_resolution_table;
- save_last_table= context->last_name_resolution_table;
- context->table_list= &tables;
- context->first_name_resolution_table= &tables;
- context->last_name_resolution_table= NULL;
- func_expr->walk(&Item::change_context_processor, 0, (uchar*) context);
+ func_expr->walk(&Item::change_context_processor, 0,
+ (uchar*) &lex.select_lex.context);
save_where= thd->where;
thd->where= "partition function";
/*
@@ -1035,30 +1077,18 @@ static bool fix_fields_part_func(THD *th
that does this during val_int must be disallowed as partition
function.
SEE Bug #21658
- */
- /*
+
This is a tricky call to prepare for since it can have a large number
of interesting side effects, both desirable and undesirable.
*/
-
- save_use_only_table_context= thd->lex->use_only_table_context;
- thd->lex->use_only_table_context= TRUE;
- thd->lex->current_select->cur_pos_in_select_list= UNDEF_POS;
-
error= func_expr->fix_fields(thd, (Item**)&func_expr);
- thd->lex->use_only_table_context= save_use_only_table_context;
-
- context->table_list= save_table_list;
- context->first_name_resolution_table= save_first_table;
- context->last_name_resolution_table= save_last_table;
if (unlikely(error))
{
DBUG_PRINT("info", ("Field in partition function not part of table"));
clear_field_flag(table);
goto end;
}
- thd->where= save_where;
if (unlikely(func_expr->const_item()))
{
my_error(ER_CONST_EXPR_IN_PARTITION_FUNC_ERROR, MYF(0));
@@ -1069,8 +1099,11 @@ static bool fix_fields_part_func(THD *th
goto end;
result= set_up_field_array(table, is_sub_part);
end:
- table->get_fields_in_item_tree= FALSE;
- table->map= 0; //Restore old value
+ end_lex_with_single_table(thd, table, old_lex);
+#if !defined(DBUG_OFF)
+ func_expr->walk(&Item::change_context_processor, 0,
+ (uchar*) 0);
+#endif
DBUG_RETURN(result);
}
@@ -2407,8 +2440,7 @@ char *generate_partition_syntax(partitio
default:
DBUG_ASSERT(0);
/* We really shouldn't get here, no use in continuing from here */
- my_error(ER_OUT_OF_RESOURCES, MYF(0));
- current_thd->fatal_error();
+ my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR));
DBUG_RETURN(NULL);
}
if (part_info->part_expr)
@@ -4109,26 +4141,13 @@ bool mysql_unpack_partition(THD *thd,
LEX lex;
DBUG_ENTER("mysql_unpack_partition");
- thd->lex= &lex;
thd->variables.character_set_client= system_charset_info;
Parser_state parser_state(thd, part_buf, part_info_len);
- lex_start(thd);
- *work_part_info_used= false;
- /*
- We need to use the current SELECT_LEX since I need to keep the
- Name_resolution_context object which is referenced from the
- Item_field objects.
- This is not a nice solution since if the parser uses current_select
- for anything else it will corrupt the current LEX object.
- Also, we need to make sure there even is a select -- if the statement
- was a "USE ...", current_select will be NULL, but we may still end up
- here if we try to log to a partitioned table. This is currently
- unsupported, but should still fail rather than crash!
- */
- if (!(thd->lex->current_select= old_lex->current_select))
+ if (init_lex_with_single_table(thd, table, &lex))
goto end;
+
/*
All Items created is put into a free list on the THD object. This list
is used to free all Item objects after completing a query. We don't
@@ -4138,6 +4157,7 @@ bool mysql_unpack_partition(THD *thd,
Thus we move away the current list temporarily and start a new list that
we then save in the partition info structure.
*/
+ *work_part_info_used= FALSE;
lex.part_info= new partition_info();/* Indicates MYSQLparse from this place */
if (!lex.part_info)
{
@@ -4251,8 +4271,7 @@ bool mysql_unpack_partition(THD *thd,
result= FALSE;
end:
- lex_end(thd->lex);
- thd->lex= old_lex;
+ end_lex_with_single_table(thd, table, old_lex);
thd->variables.character_set_client= old_character_set_client;
DBUG_RETURN(result);
}
@@ -5484,10 +5503,7 @@ static bool mysql_change_partitions(ALTE
&lpt->deleted, lpt->pack_frm_data,
lpt->pack_frm_len)))
{
- if (error != ER_OUTOFMEMORY)
- file->print_error(error, MYF(0));
- else
- lpt->thd->fatal_error();
+ file->print_error(error, MYF(error != ER_OUTOFMEMORY ? 0 : ME_FATALERROR));
DBUG_RETURN(TRUE);
}
DBUG_RETURN(FALSE);
=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc 2009-11-10 07:31:33 +0000
+++ b/sql/sql_plugin.cc 2009-11-19 23:13:54 +0000
@@ -1359,7 +1359,6 @@ static void plugin_load(MEM_ROOT *tmp_ro
}
new_thd->thread_stack= (char*) &tables;
new_thd->store_globals();
- lex_start(new_thd);
new_thd->db= my_strdup("mysql", MYF(0));
new_thd->db_length= 5;
bzero((uchar*)&tables, sizeof(tables));
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2009-11-12 12:13:43 +0000
+++ b/sql/sql_select.cc 2009-11-20 14:18:37 +0000
@@ -9760,7 +9760,7 @@ Field *create_tmp_field(THD *thd, TABLE
Item_sum *item_sum=(Item_sum*) item;
result= item_sum->create_tmp_field(group, table, convert_blob_length);
if (!result)
- thd->fatal_error();
+ my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR));
return result;
}
case Item::FIELD_ITEM:
@@ -10904,8 +10904,7 @@ bool create_myisam_from_heap(THD *thd, T
We don't want this error to be converted to a warning, e.g. in case of
INSERT IGNORE ... SELECT.
*/
- thd->fatal_error();
- table->file->print_error(error,MYF(0));
+ table->file->print_error(error, MYF(ME_FATALERROR));
DBUG_RETURN(1);
}
@@ -15111,8 +15110,7 @@ calc_group_buffer(JOIN *join,ORDER *grou
default:
/* This case should never be choosen */
DBUG_ASSERT(0);
- my_error(ER_OUT_OF_RESOURCES, MYF(0));
- join->thd->fatal_error();
+ my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR));
}
}
parts++;
=== modified file 'sql/sql_servers.cc'
--- a/sql/sql_servers.cc 2009-10-14 16:37:38 +0000
+++ b/sql/sql_servers.cc 2009-11-20 14:18:37 +0000
@@ -128,7 +128,7 @@ bool servers_init(bool dont_read_servers
}
/* Initialize the mem root for data */
- init_alloc_root(&mem, ACL_ALLOC_BLOCK_SIZE, 0);
+ init_sql_alloc(&mem, ACL_ALLOC_BLOCK_SIZE, 0);
if (dont_read_servers_table)
goto end;
@@ -140,7 +140,6 @@ bool servers_init(bool dont_read_servers
DBUG_RETURN(TRUE);
thd->thread_stack= (char*) &thd;
thd->store_globals();
- lex_start(thd);
/*
It is safe to call servers_reload() since servers_* arrays and hashes which
will be freed there are global static objects and thus are initialized
@@ -180,7 +179,7 @@ static bool servers_load(THD *thd, TABLE
my_hash_reset(&servers_cache);
free_root(&mem, MYF(0));
- init_alloc_root(&mem, ACL_ALLOC_BLOCK_SIZE, 0);
+ init_sql_alloc(&mem, ACL_ALLOC_BLOCK_SIZE, 0);
init_read_record(&read_record_info,thd,table=tables[0].table,NULL,1,0,
FALSE);
=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc 2009-11-10 09:32:29 +0000
+++ b/sql/sql_show.cc 2009-11-19 23:48:08 +0000
@@ -1705,6 +1705,32 @@ public:
template class I_List<thread_info>;
#endif
+static const char *thread_state_info(THD *tmp)
+{
+ if (tmp->locked)
+ return "Locked";
+#ifndef EMBEDDED_LIBRARY
+ if (tmp->net.reading_or_writing)
+ {
+ if (tmp->net.reading_or_writing == 2)
+ return "Writing to net";
+ else if (tmp->command == COM_SLEEP)
+ return "";
+ else
+ return "Reading from net";
+ }
+ else
+#endif
+ {
+ if (tmp->proc_info)
+ return tmp->proc_info;
+ else if (tmp->mysys_var && tmp->mysys_var->current_cond)
+ return "Waiting on cond";
+ else
+ return NULL;
+ }
+}
+
void mysqld_list_processes(THD *thd,const char *user, bool verbose)
{
Item *field;
@@ -1766,20 +1792,7 @@ void mysqld_list_processes(THD *thd,cons
if ((mysys_var= tmp->mysys_var))
pthread_mutex_lock(&mysys_var->mutex);
thd_info->proc_info= (char*) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0);
-#ifndef EMBEDDED_LIBRARY
- thd_info->state_info= (char*) (tmp->locked ? "Locked" :
- tmp->net.reading_or_writing ?
- (tmp->net.reading_or_writing == 2 ?
- "Writing to net" :
- thd_info->command == COM_SLEEP ? "" :
- "Reading from net") :
- tmp->proc_info ? tmp->proc_info :
- tmp->mysys_var &&
- tmp->mysys_var->current_cond ?
- "Waiting on cond" : NullS);
-#else
- thd_info->state_info= (char*)"Writing to net";
-#endif
+ thd_info->state_info= thread_state_info(tmp);
if (mysys_var)
pthread_mutex_unlock(&mysys_var->mutex);
@@ -1891,21 +1904,7 @@ int fill_schema_processlist(THD* thd, TA
table->field[5]->store((longlong)(tmp->start_time ?
now - tmp->start_time : 0), FALSE);
/* STATE */
-#ifndef EMBEDDED_LIBRARY
- val= (char*) (tmp->locked ? "Locked" :
- tmp->net.reading_or_writing ?
- (tmp->net.reading_or_writing == 2 ?
- "Writing to net" :
- tmp->command == COM_SLEEP ? "" :
- "Reading from net") :
- tmp->proc_info ? tmp->proc_info :
- tmp->mysys_var &&
- tmp->mysys_var->current_cond ?
- "Waiting on cond" : NullS);
-#else
- val= (char *) (tmp->proc_info ? tmp->proc_info : NullS);
-#endif
- if (val)
+ if ((val= thread_state_info(tmp)))
{
table->field[6]->store(val, strlen(val), cs);
table->field[6]->set_notnull();
@@ -5071,8 +5070,7 @@ static int get_schema_partitions_record(
break;
default:
DBUG_ASSERT(0);
- my_error(ER_OUT_OF_RESOURCES, MYF(0));
- current_thd->fatal_error();
+ my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR));
DBUG_RETURN(1);
}
table->field[7]->set_notnull();
=== modified file 'sql/sql_string.cc'
--- a/sql/sql_string.cc 2009-09-30 05:09:28 +0000
+++ b/sql/sql_string.cc 2009-11-11 20:19:41 +0000
@@ -23,6 +23,7 @@
#include <my_sys.h>
#include <m_string.h>
#include <m_ctype.h>
+#include <mysql_com.h>
#ifdef HAVE_FCONVERT
#include <floatingpoint.h>
#endif
@@ -499,22 +500,6 @@ bool String::append(const char *s,uint32
return FALSE;
}
-
-#ifdef TO_BE_REMOVED
-bool String::append(FILE* file, uint32 arg_length, myf my_flags)
-{
- if (realloc(str_length+arg_length))
- return TRUE;
- if (my_fread(file, (uchar*) Ptr + str_length, arg_length, my_flags))
- {
- shrink(str_length);
- return TRUE;
- }
- str_length+=arg_length;
- return FALSE;
-}
-#endif
-
bool String::append(IO_CACHE* file, uint32 arg_length)
{
if (realloc(str_length+arg_length))
=== modified file 'sql/sql_string.h'
--- a/sql/sql_string.h 2009-10-28 07:55:44 +0000
+++ b/sql/sql_string.h 2009-11-11 20:19:41 +0000
@@ -22,10 +22,6 @@
#pragma interface /* gcc class implementation */
#endif
-#ifndef NOT_FIXED_DEC
-#define NOT_FIXED_DEC 31
-#endif
-
class String;
int sortcmp(const String *a,const String *b, CHARSET_INFO *cs);
String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
=== modified file 'sql/sql_trigger.cc'
--- a/sql/sql_trigger.cc 2009-11-21 04:28:01 +0000
+++ b/sql/sql_trigger.cc 2009-11-21 04:48:54 +0000
@@ -1660,7 +1660,7 @@ bool Table_triggers_list::drop_all_trigg
DBUG_ENTER("drop_all_triggers");
bzero(&table, sizeof(table));
- init_alloc_root(&table.mem_root, 8192, 0);
+ init_sql_alloc(&table.mem_root, 8192, 0);
if (Table_triggers_list::check_n_load(thd, db, name, &table, 1))
{
@@ -1871,7 +1871,7 @@ bool Table_triggers_list::change_table_n
DBUG_ENTER("change_table_name");
bzero(&table, sizeof(table));
- init_alloc_root(&table.mem_root, 8192, 0);
+ init_sql_alloc(&table.mem_root, 8192, 0);
/*
This method interfaces the mysql server code protected by
=== modified file 'sql/sql_udf.cc'
--- a/sql/sql_udf.cc 2009-11-21 04:28:01 +0000
+++ b/sql/sql_udf.cc 2009-11-21 04:48:54 +0000
@@ -135,7 +135,6 @@ void udf_init()
initialized = 1;
new_thd->thread_stack= (char*) &new_thd;
new_thd->store_globals();
- lex_start(new_thd);
new_thd->set_db(db, sizeof(db)-1);
bzero((uchar*) &tables,sizeof(tables));
=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc 2009-11-21 04:28:01 +0000
+++ b/sql/sql_update.cc 2009-11-21 04:48:54 +0000
@@ -662,11 +662,13 @@ int mysql_update(THD *thd,
If (ignore && error is ignorable) we don't have to
do anything; otherwise...
*/
+ myf flags= 0;
+
if (table->file->is_fatal_error(error, HA_CHECK_DUP_KEY))
- thd->fatal_error(); /* Other handler errors are fatal */
+ flags|= ME_FATALERROR; /* Other handler errors are fatal */
prepare_record_for_error_message(error, table);
- table->file->print_error(error,MYF(0));
+ table->file->print_error(error,MYF(flags));
error= 1;
break;
}
@@ -763,9 +765,8 @@ int mysql_update(THD *thd,
*/
{
/* purecov: begin inspected */
- thd->fatal_error();
prepare_record_for_error_message(loc_error, table);
- table->file->print_error(loc_error,MYF(0));
+ table->file->print_error(loc_error,MYF(ME_FATALERROR));
error= 1;
/* purecov: end */
}
@@ -1742,11 +1743,13 @@ bool multi_update::send_data(List<Item>
If (ignore && error == is ignorable) we don't have to
do anything; otherwise...
*/
+ myf flags= 0;
+
if (table->file->is_fatal_error(error, HA_CHECK_DUP_KEY))
- thd->fatal_error(); /* Other handler errors are fatal */
+ flags|= ME_FATALERROR; /* Other handler errors are fatal */
prepare_record_for_error_message(error, table);
- table->file->print_error(error,MYF(0));
+ table->file->print_error(error,MYF(flags));
DBUG_RETURN(1);
}
}
@@ -2030,9 +2033,8 @@ int multi_update::do_updates()
err:
{
- thd->fatal_error();
prepare_record_for_error_message(local_error, table);
- table->file->print_error(local_error,MYF(0));
+ table->file->print_error(local_error,MYF(ME_FATALERROR));
}
err2:
=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy 2009-11-12 12:13:43 +0000
+++ b/sql/sql_yacc.yy 2009-11-20 14:18:37 +0000
@@ -466,6 +466,90 @@ Item* handle_sql2003_note184_exception(T
DBUG_RETURN(result);
}
+/**
+ @brief Creates a new SELECT_LEX for a UNION branch.
+
+ Sets up and initializes a SELECT_LEX structure for a query once the parser
+ discovers a UNION token. The current SELECT_LEX is pushed on the stack and
+ the new SELECT_LEX becomes the current one.
+
+ @param lex The parser state.
+
+ @param is_union_distinct True if the union preceding the new select statement
+ uses UNION DISTINCT.
+
+ @param is_top_level This should be @c TRUE if the newly created SELECT_LEX
+ is a non-nested statement.
+
+ @return <code>false</code> if successful, <code>true</code> if an error was
+ reported. In the latter case parsing should stop.
+ */
+bool add_select_to_union_list(LEX *lex, bool is_union_distinct,
+ bool is_top_level)
+{
+ /*
+ Only the last SELECT can have INTO. Since the grammar won't allow INTO in
+ a nested SELECT, we make this check only when creating a top-level SELECT.
+ */
+ if (is_top_level && lex->result)
+ {
+ my_error(ER_WRONG_USAGE, MYF(0), "UNION", "INTO");
+ return TRUE;
+ }
+ if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
+ {
+ my_parse_error(ER(ER_SYNTAX_ERROR));
+ return TRUE;
+ }
+ /* This counter shouldn't be incremented for UNION parts */
+ lex->nest_level--;
+ if (mysql_new_select(lex, 0))
+ return TRUE;
+ mysql_init_select(lex);
+ lex->current_select->linkage=UNION_TYPE;
+ if (is_union_distinct) /* UNION DISTINCT - remember position */
+ lex->current_select->master_unit()->union_distinct=
+ lex->current_select;
+ return FALSE;
+}
+
+/**
+ @brief Initializes a SELECT_LEX for a query within parentheses (aka
+ braces).
+
+ @return false if successful, true if an error was reported. In the latter
+ case parsing should stop.
+ */
+bool setup_select_in_parentheses(LEX *lex)
+{
+ SELECT_LEX * sel= lex->current_select;
+ if (sel->set_braces(1))
+ {
+ my_parse_error(ER(ER_SYNTAX_ERROR));
+ return TRUE;
+ }
+ if (sel->linkage == UNION_TYPE &&
+ !sel->master_unit()->first_select()->braces &&
+ sel->master_unit()->first_select()->linkage ==
+ UNION_TYPE)
+ {
+ my_parse_error(ER(ER_SYNTAX_ERROR));
+ return TRUE;
+ }
+ if (sel->linkage == UNION_TYPE &&
+ sel->olap != UNSPECIFIED_OLAP_TYPE &&
+ sel->master_unit()->fake_select_lex)
+ {
+ my_error(ER_WRONG_USAGE, MYF(0), "CUBE/ROLLUP", "ORDER BY");
+ return TRUE;
+ }
+ /* select in braces, can't contain global parameters */
+ if (sel->master_unit()->fake_select_lex)
+ sel->master_unit()->global_parameters=
+ sel->master_unit()->fake_select_lex;
+ return FALSE;
+}
+
%}
%union {
int num;
@@ -519,10 +603,10 @@ bool my_yyoverflow(short **a, YYSTYPE **
%pure_parser /* We have threads */
/*
- Currently there are 168 shift/reduce conflicts.
+ Currently there are 174 shift/reduce conflicts.
We should not introduce new conflicts any more.
*/
-%expect 168
+%expect 174
/*
Comments for TOKENS.
@@ -1192,7 +1276,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
%type <item>
literal text_literal insert_ident order_ident
- simple_ident select_item2 expr opt_expr opt_else sum_expr in_sum_expr
+ simple_ident expr opt_expr opt_else sum_expr in_sum_expr
variable variable_aux bool_pri
predicate bit_expr
table_wild simple_expr udf_expr
@@ -1235,6 +1319,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
join_table_list join_table
table_factor table_ref esc_table_ref
select_derived derived_table_list
+ select_derived_union
%type <date_time_type> date_time_type;
%type <interval> interval
@@ -1270,8 +1355,9 @@ bool my_yyoverflow(short **a, YYSTYPE **
%type <variable> internal_variable_name
-%type <select_lex> subselect take_first_select
- get_select_lex
+%type <select_lex> subselect
+ get_select_lex query_specification
+ query_expression_body
%type <boolfunc2creator> comp_op
@@ -1352,7 +1438,7 @@ END_OF_INPUT
%type <NONE>
'-' '+' '*' '/' '%' '(' ')'
',' '!' '{' '}' '&' '|' AND_SYM OR_SYM OR_OR_SYM BETWEEN_SYM CASE_SYM
- THEN_SYM WHEN_SYM DIV_SYM MOD_SYM OR2_SYM AND_AND_SYM
+ THEN_SYM WHEN_SYM DIV_SYM MOD_SYM OR2_SYM AND_AND_SYM DELETE_SYM
%%
/*
@@ -6807,37 +6893,22 @@ select_init:
select_paren:
SELECT_SYM select_part2
{
- LEX *lex= Lex;
- SELECT_LEX * sel= lex->current_select;
- if (sel->set_braces(1))
- {
- my_parse_error(ER(ER_SYNTAX_ERROR));
- MYSQL_YYABORT;
- }
- if (sel->linkage == UNION_TYPE &&
- !sel->master_unit()->first_select()->braces &&
- sel->master_unit()->first_select()->linkage ==
- UNION_TYPE)
- {
- my_parse_error(ER(ER_SYNTAX_ERROR));
+ if (setup_select_in_parentheses(Lex))
MYSQL_YYABORT;
- }
- if (sel->linkage == UNION_TYPE &&
- sel->olap != UNSPECIFIED_OLAP_TYPE &&
- sel->master_unit()->fake_select_lex)
- {
- my_error(ER_WRONG_USAGE, MYF(0),
- "CUBE/ROLLUP", "ORDER BY");
- MYSQL_YYABORT;
- }
- /* select in braces, can't contain global parameters */
- if (sel->master_unit()->fake_select_lex)
- sel->master_unit()->global_parameters=
- sel->master_unit()->fake_select_lex;
}
| '(' select_paren ')'
;
+/* The equivalent of select_paren for nested queries. */
+select_paren_derived:
+ SELECT_SYM select_part2_derived
+ {
+ if (setup_select_in_parentheses(Lex))
+ MYSQL_YYABORT;
+ }
+ | '(' select_paren_derived ')'
+ ;
+
select_init2:
select_part2
{
@@ -6998,7 +7069,14 @@ select_item_list:
;
select_item:
- remember_name select_item2 remember_end select_alias
+ remember_name table_wild remember_end
+ {
+ THD *thd= YYTHD;
+
+ if (add_item_to_list(thd, $2))
+ MYSQL_YYABORT;
+ }
+ | remember_name expr remember_end select_alias
{
THD *thd= YYTHD;
DBUG_ASSERT($1 < $3);
@@ -7035,11 +7113,6 @@ remember_end:
}
;
-select_item2:
- table_wild { $$=$1; /* table.* */ }
- | expr { $$=$1; }
- ;
-
select_alias:
/* empty */ { $$=null_lex_str;}
| AS ident { $$=$2; }
@@ -8676,6 +8749,7 @@ when_list:
}
;
+/* Equivalent to <table reference> in the SQL:2003 standard. */
/* Warning - may return NULL in case of incomplete SELECT */
table_ref:
table_factor { $$=$1; }
@@ -8703,6 +8777,7 @@ esc_table_ref:
| '{' ident table_ref '}' { $$=$3; }
;
+/* Equivalent to <table reference list> in the SQL:2003 standard. */
/* Warning - may return NULL in case of incomplete SELECT */
derived_table_list:
esc_table_ref { $$=$1; }
@@ -8856,6 +8931,13 @@ normal_join:
| CROSS JOIN_SYM {}
;
+/*
+ This is a flattening of the rules <table factor> and <table primary>
+ in the SQL:2003 standard, since we don't have <sample clause>
+
+ I.e.
+ <table factor> ::= <table primary> [ <sample clause> ]
+*/
/* Warning - may return NULL in case of incomplete SELECT */
table_factor:
{
@@ -8893,12 +8975,29 @@ table_factor:
/* incomplete derived tables return NULL, we must be
nested in select_derived rule to be here. */
}
- | '(' get_select_lex select_derived union_opt ')' opt_table_alias
+ /*
+ Represents a flattening of the following rules from the SQL:2003
+ standard. This sub-rule corresponds to the sub-rule
+ <table primary> ::= ... | <derived table> [ AS ] <correlation name>
+
+ The following rules have been flattened into query_expression_body
+ (since we have no <with clause>).
+
+ <derived table> ::= <table subquery>
+ <table subquery> ::= <subquery>
+ <subquery> ::= <left paren> <query expression> <right paren>
+ <query expression> ::= [ <with clause> ] <query expression body>
+
+ For the time being we use the non-standard rule
+ select_derived_union which is a compromise between the standard
+ and our parser. Possibly this rule could be replaced by our
+ query_expression_body.
+ */
+ | '(' get_select_lex select_derived_union ')' opt_table_alias
{
/* Use $2 instead of Lex->current_select as derived table will
alter value of Lex->current_select. */
-
- if (!($3 || $6) && $2->embedding &&
+ if (!($3 || $5) && $2->embedding &&
!$2->embedding->nested_join->join_list.elements)
{
/* we have a derived table ($3 == NULL) but no alias,
@@ -8920,7 +9019,7 @@ table_factor:
if (ti == NULL)
MYSQL_YYABORT;
if (!($$= sel->add_table_to_list(lex->thd,
- ti, $6, 0,
+ new Table_ident(unit), $5, 0,
TL_READ)))
MYSQL_YYABORT;
@@ -8928,7 +9027,8 @@ table_factor:
lex->pop_context();
lex->nest_level--;
}
- else if ($4 || $6)
+ else if ($3->select_lex &&
+ $3->select_lex->master_unit()->is_union() || $5)
{
/* simple nested joins cannot have aliases or unions */
my_parse_error(ER(ER_SYNTAX_ERROR));
@@ -8943,6 +9043,62 @@ table_factor:
}
;
+select_derived_union:
+ select_derived opt_order_clause opt_limit_clause
+ | select_derived_union
+ UNION_SYM
+ union_option
+ {
+ if (add_select_to_union_list(Lex, (bool)$3, FALSE))
+ MYSQL_YYABORT;
+ }
+ query_specification
+ {
+ /*
+ Remove from the name resolution context stack the context of the
+ last select in the union.
+ */
+ Lex->pop_context();
+ }
+ opt_order_clause opt_limit_clause
+ ;
+
+/* The equivalent of select_init2 for nested queries. */
+select_init2_derived:
+ select_part2_derived
+ {
+ LEX *lex= Lex;
+ SELECT_LEX * sel= lex->current_select;
+ if (lex->current_select->set_braces(0))
+ {
+ my_parse_error(ER(ER_SYNTAX_ERROR));
+ MYSQL_YYABORT;
+ }
+ if (sel->linkage == UNION_TYPE &&
+ sel->master_unit()->first_select()->braces)
+ {
+ my_parse_error(ER(ER_SYNTAX_ERROR));
+ MYSQL_YYABORT;
+ }
+ }
+ ;
+
+/* The equivalent of select_part2 for nested queries. */
+select_part2_derived:
+ {
+ LEX *lex= Lex;
+ SELECT_LEX *sel= lex->current_select;
+ if (sel->linkage != UNION_TYPE)
+ mysql_init_select(lex);
+ lex->current_select->parsing_place= SELECT_LIST;
+ }
+ select_options select_item_list
+ {
+ Select->parsing_place= NO_MATTER;
+ }
+ opt_select_from select_lock_type
+ ;
+
/* handle contents of parentheses in join expression */
select_derived:
get_select_lex
@@ -9557,8 +9713,7 @@ procedure_item:
select_var_list_init:
{
LEX *lex=Lex;
- if (!lex->describe &&
- (!(lex->result= new select_dumpvar(lex->nest_level))))
+ if (!lex->describe && (!(lex->result= new select_dumpvar())))
MYSQL_YYABORT;
}
select_var_list
@@ -9639,7 +9794,7 @@ into_destination:
LEX *lex= Lex;
lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
if (!(lex->exchange= new sql_exchange($2.str, 0)) ||
- !(lex->result= new select_export(lex->exchange, lex->nest_level)))
+ !(lex->result= new select_export(lex->exchange)))
MYSQL_YYABORT;
}
opt_load_data_charset
@@ -9653,7 +9808,7 @@ into_destination:
lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
if (!(lex->exchange= new sql_exchange($2.str,1)))
MYSQL_YYABORT;
- if (!(lex->result= new select_dump(lex->exchange, lex->nest_level)))
+ if (!(lex->result= new select_dump(lex->exchange)))
MYSQL_YYABORT;
}
}
@@ -10114,7 +10269,7 @@ delete:
lex->ignore= 0;
lex->select_lex.init_order();
}
- opt_delete_options single_multi {}
+ opt_delete_options single_multi
;
single_multi:
@@ -10129,45 +10284,45 @@ single_multi:
| table_wild_list
{ mysql_init_multi_delete(Lex); }
FROM join_table_list where_clause
- {
+ {
if (multi_delete_set_locks_and_link_aux_tables(Lex))
MYSQL_YYABORT;
}
| FROM table_alias_ref_list
{ mysql_init_multi_delete(Lex); }
USING join_table_list where_clause
- {
+ {
if (multi_delete_set_locks_and_link_aux_tables(Lex))
MYSQL_YYABORT;
}
;
table_wild_list:
- table_wild_one {}
- | table_wild_list ',' table_wild_one {}
+ table_wild_one
+ | table_wild_list ',' table_wild_one
;
table_wild_one:
- ident opt_wild opt_table_alias
+ ident opt_wild
{
Table_ident *ti= new Table_ident($1);
if (ti == NULL)
MYSQL_YYABORT;
if (!Select->add_table_to_list(YYTHD,
ti,
- $3,
+ NULL,
TL_OPTION_UPDATING | TL_OPTION_ALIAS,
Lex->lock_option))
MYSQL_YYABORT;
}
- | ident '.' ident opt_wild opt_table_alias
+ | ident '.' ident opt_wild
{
Table_ident *ti= new Table_ident(YYTHD, $1, $3, 0);
if (ti == NULL)
MYSQL_YYABORT;
if (!Select->add_table_to_list(YYTHD,
ti,
- $5,
+ NULL,
TL_OPTION_UPDATING | TL_OPTION_ALIAS,
Lex->lock_option))
MYSQL_YYABORT;
@@ -13272,33 +13427,8 @@ union_clause:
union_list:
UNION_SYM union_option
{
- LEX *lex=Lex;
- if (lex->result &&
- (lex->result->get_nest_level() == -1 ||
- lex->result->get_nest_level() == lex->nest_level))
- {
- /*
- Only the last SELECT can have INTO unless the INTO and UNION
- are at different nest levels. In version 5.1 and above, INTO
- will onle be allowed at top level.
- */
- my_error(ER_WRONG_USAGE, MYF(0), "UNION", "INTO");
- MYSQL_YYABORT;
- }
- if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
- {
- my_parse_error(ER(ER_SYNTAX_ERROR));
- MYSQL_YYABORT;
- }
- /* This counter shouldn't be incremented for UNION parts */
- Lex->nest_level--;
- if (mysql_new_select(lex, 0))
+ if (add_select_to_union_list(Lex, (bool)$2, TRUE))
MYSQL_YYABORT;
- mysql_init_select(lex);
- lex->current_select->linkage=UNION_TYPE;
- if ($2) /* UNION DISTINCT - remember position */
- lex->current_select->master_unit()->union_distinct=
- lex->current_select;
}
select_init
{
@@ -13351,22 +13481,39 @@ union_option:
| ALL { $$=0; }
;
-take_first_select: /* empty */
- {
- $$= Lex->current_select->master_unit()->first_select();
- };
+query_specification:
+ SELECT_SYM select_init2_derived
+ {
+ $$= Lex->current_select->master_unit()->first_select();
+ }
+ | '(' select_paren_derived ')'
+ {
+ $$= Lex->current_select->master_unit()->first_select();
+ }
+ ;
+query_expression_body:
+ query_specification
+ | query_expression_body
+ UNION_SYM union_option
+ {
+ if (add_select_to_union_list(Lex, (bool)$3, FALSE))
+ MYSQL_YYABORT;
+ }
+ query_specification
+ {
+ Lex->pop_context();
+ $$= $1;
+ }
+ ;
+
+/* Corresponds to <query expression> in the SQL:2003 standard. */
subselect:
- SELECT_SYM subselect_start select_init2 take_first_select
- subselect_end
- {
- $$= $4;
- }
- | '(' subselect_start select_paren take_first_select
- subselect_end ')'
- {
- $$= $4;
- };
+ subselect_start query_expression_body subselect_end
+ {
+ $$= $2;
+ }
+ ;
subselect_start:
{
=== modified file 'sql/table.cc'
--- a/sql/table.cc 2009-11-02 11:10:04 +0000
+++ b/sql/table.cc 2009-11-20 00:20:08 +0000
@@ -1649,9 +1649,6 @@ int open_table_from_share(THD *thd, TABL
DBUG_PRINT("enter",("name: '%s.%s' form: 0x%lx", share->db.str,
share->table_name.str, (long) outparam));
- /* Parsing of partitioning information from .frm needs thd->lex set up. */
- DBUG_ASSERT(thd->lex->is_lex_started);
-
error= 1;
bzero((char*) outparam, sizeof(*outparam));
outparam->in_use= thd;
=== modified file 'sql/table.h'
--- a/sql/table.h 2009-11-02 11:10:04 +0000
+++ b/sql/table.h 2009-11-10 18:48:46 +0000
@@ -1332,6 +1332,12 @@ struct TABLE_LIST
*/
bool create;
bool internal_tmp_table;
+ /** TRUE if an alias for this table was specified in the SQL. */
+ bool is_alias;
+ /** TRUE if the table is referred to in the statement using a fully
+ qualified name (<db_name>.<table_name>).
+ */
+ bool is_fqtn;
/* View creation context. */
=== modified file 'sql/tztime.cc'
--- a/sql/tztime.cc 2009-10-14 16:37:38 +0000
+++ b/sql/tztime.cc 2009-11-20 14:18:37 +0000
@@ -1578,7 +1578,6 @@ my_tz_init(THD *org_thd, const char *def
DBUG_RETURN(1);
thd->thread_stack= (char*) &thd;
thd->store_globals();
- lex_start(thd);
/* Init all memory structures that require explicit destruction */
if (my_hash_init(&tz_names, &my_charset_latin1, 20,
@@ -1594,7 +1593,7 @@ my_tz_init(THD *org_thd, const char *def
my_hash_free(&tz_names);
goto end;
}
- init_alloc_root(&tz_storage, 32 * 1024, 0);
+ init_sql_alloc(&tz_storage, 32 * 1024, 0);
VOID(pthread_mutex_init(&tz_LOCK, MY_MUTEX_INIT_FAST));
tz_inited= 1;
=== modified file 'storage/ndb/include/kernel/signaldata/DictTabInfo.hpp'
--- a/storage/ndb/include/kernel/signaldata/DictTabInfo.hpp 2007-04-26 11:50:04 +0000
+++ b/storage/ndb/include/kernel/signaldata/DictTabInfo.hpp 2008-03-05 14:27:35 +0000
@@ -30,10 +30,6 @@
#define DECIMAL_MAX_LENGTH ((8 * 9) - 8)
-#ifndef NOT_FIXED_DEC
-#define NOT_FIXED_DEC 31
-#endif
-
C_MODE_START
extern int decimal_bin_size(int, int);
C_MODE_END
=== modified file 'strings/ctype-bin.c'
--- a/strings/ctype-bin.c 2007-06-05 22:22:35 +0000
+++ b/strings/ctype-bin.c 2009-11-11 16:03:02 +0000
@@ -278,14 +278,11 @@ void my_hash_sort_8bit_bin(CHARSET_INFO
{
const uchar *pos = key;
- key+= len;
-
/*
Remove trailing spaces. We have to do this to be able to compare
'A ' and 'A' as identical
*/
- while (key > pos && key[-1] == ' ')
- key--;
+ key= skip_trailing_space(key, len);
for (; pos < (uchar*) key ; pos++)
{
=== modified file 'strings/ctype-latin1.c'
--- a/strings/ctype-latin1.c 2007-05-10 09:59:39 +0000
+++ b/strings/ctype-latin1.c 2009-11-11 16:03:02 +0000
@@ -678,13 +678,12 @@ void my_hash_sort_latin1_de(CHARSET_INFO
const uchar *key, size_t len,
ulong *nr1, ulong *nr2)
{
- const uchar *end= key+len;
+ const uchar *end;
/*
Remove end space. We have to do this to be able to compare
'AE' and '� as identical
*/
- while (end > key && end[-1] == ' ')
- end--;
+ end= skip_trailing_space(key, len);
for (; key < end ; key++)
{
=== modified file 'strings/ctype-mb.c'
--- a/strings/ctype-mb.c 2009-02-13 16:41:47 +0000
+++ b/strings/ctype-mb.c 2009-11-11 16:03:02 +0000
@@ -469,14 +469,11 @@ static void my_hash_sort_mb_bin(CHARSET_
{
const uchar *pos = key;
- key+= len;
-
/*
Remove trailing spaces. We have to do this to be able to compare
'A ' and 'A' as identical
*/
- while (key > pos && key[-1] == ' ')
- key--;
+ key= skip_trailing_space(key, len);
for (; pos < (uchar*) key ; pos++)
{
=== modified file 'strings/ctype-simple.c'
--- a/strings/ctype-simple.c 2009-10-12 07:43:15 +0000
+++ b/strings/ctype-simple.c 2009-11-11 16:03:02 +0000
@@ -304,14 +304,13 @@ void my_hash_sort_simple(CHARSET_INFO *c
ulong *nr1, ulong *nr2)
{
register uchar *sort_order=cs->sort_order;
- const uchar *end= key + len;
+ const uchar *end;
/*
Remove end space. We have to do this to be able to compare
'A ' and 'A' as identical
*/
- while (end > key && end[-1] == ' ')
- end--;
+ end= skip_trailing_space(key, len);
for (; key < (uchar*) end ; key++)
{
@@ -1165,9 +1164,8 @@ size_t my_well_formed_len_8bit(CHARSET_I
size_t my_lengthsp_8bit(CHARSET_INFO *cs __attribute__((unused)),
const char *ptr, size_t length)
{
- const char *end= ptr+length;
- while (end > ptr && end[-1] == ' ')
- end--;
+ const char *end;
+ end= (const char *) skip_trailing_space((const uchar *)ptr, length);
return (size_t) (end-ptr);
}
=== modified file 'vio/vio.c'
--- a/vio/vio.c 2009-11-02 22:19:58 +0000
+++ b/vio/vio.c 2009-11-19 23:48:08 +0000
@@ -22,6 +22,28 @@
#include "vio_priv.h"
+#if defined(__WIN__) || defined(HAVE_SMEM)
+
+/**
+ Stub poll_read method that defaults to indicate that there
+ is data to read.
+
+ Used for named pipe and shared memory VIO types.
+
+ @param vio Unused.
+ @param timeout Unused.
+
+ @retval FALSE There is data to read.
+*/
+
+static my_bool no_poll_read(Vio *vio __attribute__((unused)),
+ uint timeout __attribute__((unused)))
+{
+ return FALSE;
+}
+
+#endif
+
/*
* Helper to fill most of the Vio* with defaults.
*/
@@ -60,6 +82,9 @@ static void vio_init(Vio* vio, enum enum
vio->vioblocking =vio_blocking;
vio->is_blocking =vio_is_blocking;
+ vio->poll_read =no_poll_read;
+ vio->is_connected =vio_is_connected_pipe;
+
vio->timeout=vio_win32_timeout;
/* Set default timeout */
vio->read_timeout_millis = INFINITE;
@@ -87,6 +112,9 @@ static void vio_init(Vio* vio, enum enum
vio->vioblocking =vio_blocking;
vio->is_blocking =vio_is_blocking;
+ vio->poll_read =no_poll_read;
+ vio->is_connected =vio_is_connected_shared_memory;
+
/* Currently, shared memory is on Windows only, hence the below is ok*/
vio->timeout= vio_win32_timeout;
/* Set default timeout */
@@ -112,6 +140,8 @@ static void vio_init(Vio* vio, enum enum
vio->vioblocking =vio_ssl_blocking;
vio->is_blocking =vio_is_blocking;
vio->timeout =vio_timeout;
+ vio->poll_read =vio_poll_read;
+ vio->is_connected =vio_is_connected;
DBUG_VOID_RETURN;
}
#endif /* HAVE_OPENSSL */
@@ -130,6 +160,8 @@ static void vio_init(Vio* vio, enum enum
vio->vioblocking =vio_blocking;
vio->is_blocking =vio_is_blocking;
vio->timeout =vio_timeout;
+ vio->poll_read =vio_poll_read;
+ vio->is_connected =vio_is_connected;
}
DBUG_VOID_RETURN;
}
=== modified file 'vio/vio_priv.h'
--- a/vio/vio_priv.h 2009-11-12 12:13:43 +0000
+++ b/vio/vio_priv.h 2009-11-20 14:18:37 +0000
@@ -29,6 +29,20 @@
void vio_win32_timeout(Vio *vio, uint which, uint timeout);
#endif
+#ifdef __WIN__
+size_t vio_read_pipe(Vio *vio, uchar * buf, size_t size);
+size_t vio_write_pipe(Vio *vio, const uchar * buf, size_t size);
+my_bool vio_is_connected_pipe(Vio *vio);
+int vio_close_pipe(Vio * vio);
+#endif
+
+#ifdef HAVE_SMEM
+size_t vio_read_shared_memory(Vio *vio, uchar * buf, size_t size);
+size_t vio_write_shared_memory(Vio *vio, const uchar * buf, size_t size);
+my_bool vio_is_connected_shared_memory(Vio *vio);
+int vio_close_shared_memory(Vio * vio);
+#endif
+
void vio_timeout(Vio *vio,uint which, uint timeout);
#ifdef HAVE_OPENSSL
=== modified file 'vio/viosocket.c'
--- a/vio/viosocket.c 2009-11-12 12:13:43 +0000
+++ b/vio/viosocket.c 2009-11-20 14:18:37 +0000
@@ -350,25 +350,160 @@ void vio_in_addr(Vio *vio, struct in_add
}
-/* Return 0 if there is data to be read */
+/**
+ Indicate whether there is data to read on a given socket.
+
+ @note An exceptional condition event and/or errors are
+ interpreted as if there is data to read.
+
+ @param sd A connected socket.
+ @param timeout Maximum time in seconds to poll.
+
+ @retval FALSE There is data to read.
+ @retval TRUE There is no data to read.
+*/
-my_bool vio_poll_read(Vio *vio,uint timeout)
+static my_bool socket_poll_read(my_socket sd, uint timeout)
{
-#ifndef HAVE_POLL
- return 0;
-#else
+#ifdef __WIN__
+ int res;
+ my_socket fd= sd;
+ fd_set readfds, errorfds;
+ struct timeval tm;
+ DBUG_ENTER("socket_poll_read");
+ tm.tv_sec= timeout;
+ tm.tv_usec= 0;
+ FD_ZERO(&readfds);
+ FD_ZERO(&errorfds);
+ FD_SET(fd, &readfds);
+ FD_SET(fd, &errorfds);
+ if ((res= select(fd, &readfds, NULL, &errorfds, &tm) <= 0))
+ {
+ DBUG_RETURN(res < 0 ? 0 : 1);
+ }
+ res= FD_ISSET(fd, &readfds) || FD_ISSET(fd, &errorfds);
+ DBUG_RETURN(!res);
+#elif defined(HAVE_POLL)
struct pollfd fds;
int res;
- DBUG_ENTER("vio_poll");
- fds.fd=vio->sd;
+ DBUG_ENTER("socket_poll_read");
+ fds.fd=sd;
fds.events=POLLIN;
fds.revents=0;
if ((res=poll(&fds,1,(int) timeout*1000)) <= 0)
{
DBUG_RETURN(res < 0 ? 0 : 1); /* Don't return 1 on errors */
}
- DBUG_RETURN(fds.revents & POLLIN ? 0 : 1);
+ DBUG_RETURN(fds.revents & (POLLIN | POLLERR | POLLHUP) ? 0 : 1);
+#else
+ return 0;
+#endif
+}
+
+
+/**
+ Retrieve the amount of data that can be read from a socket.
+
+ @param vio A VIO object.
+ @param bytes[out] The amount of bytes available.
+
+ @retval FALSE Success.
+ @retval TRUE Failure.
+*/
+
+static my_bool socket_peek_read(Vio *vio, uint *bytes)
+{
+#ifdef __WIN__
+ int len;
+ if (ioctlsocket(vio->sd, FIONREAD, &len))
+ return TRUE;
+ *bytes= len;
+ return FALSE;
+#elif FIONREAD_IN_SYS_IOCTL
+ int len;
+ if (ioctl(vio->sd, FIONREAD, &len) < 0)
+ return TRUE;
+ *bytes= len;
+ return FALSE;
+#else
+ char buf[1024];
+ ssize_t res= recv(vio->sd, &buf, sizeof(buf), MSG_PEEK);
+ if (res < 0)
+ return TRUE;
+ *bytes= res;
+ return FALSE;
+#endif
+}
+
+
+/**
+ Indicate whether there is data to read on a given socket.
+
+ @remark Errors are interpreted as if there is data to read.
+
+ @param sd A connected socket.
+ @param timeout Maximum time in seconds to wait.
+
+ @retval FALSE There is data (or EOF) to read. Also FALSE if error.
+ @retval TRUE There is _NO_ data to read or timed out.
+*/
+
+my_bool vio_poll_read(Vio *vio, uint timeout)
+{
+ my_socket sd= vio->sd;
+ DBUG_ENTER("vio_poll_read");
+#ifdef HAVE_OPENSSL
+ if (vio->type == VIO_TYPE_SSL)
+ sd= SSL_get_fd((SSL*) vio->ssl_arg);
+#endif
+ DBUG_RETURN(socket_poll_read(sd, timeout));
+}
+
+
+/**
+ Determine if the endpoint of a connection is still available.
+
+ @remark The socket is assumed to be disconnected if an EOF
+ condition is encountered.
+
+ @param vio The VIO object.
+
+ @retval TRUE EOF condition not found.
+ @retval FALSE EOF condition is signaled.
+*/
+
+my_bool vio_is_connected(Vio *vio)
+{
+ uint bytes= 0;
+ DBUG_ENTER("vio_is_connected");
+
+ /* In the presence of errors the socket is assumed to be connected. */
+
+ /*
+ The first step of detecting a EOF condition is veryfing
+ whether there is data to read. Data in this case would
+ be the EOF.
+ */
+ if (vio_poll_read(vio, 0))
+ DBUG_RETURN(TRUE);
+
+ /*
+ The second step is read() or recv() from the socket returning
+ 0 (EOF). Unfortunelly, it's not possible to call read directly
+ as we could inadvertently read meaningful connection data.
+ Simulate a read by retrieving the number of bytes available to
+ read -- 0 meaning EOF.
+ */
+ if (socket_peek_read(vio, &bytes))
+ DBUG_RETURN(TRUE);
+
+#ifdef HAVE_OPENSSL
+ /* There might be buffered data at the SSL layer. */
+ if (!bytes && vio->type == VIO_TYPE_SSL)
+ bytes= SSL_pending((SSL*) vio->ssl_arg);
#endif
+
+ DBUG_RETURN(bytes ? TRUE : FALSE);
}
@@ -494,6 +629,15 @@ size_t vio_write_pipe(Vio * vio, const u
}
+my_bool vio_is_connected_pipe(Vio *vio)
+{
+ if (PeekNamedPipe(vio->hPipe, NULL, 0, NULL, NULL, NULL))
+ return TRUE;
+ else
+ return (GetLastError() != ERROR_BROKEN_PIPE);
+}
+
+
int vio_close_pipe(Vio * vio)
{
int r;
@@ -645,6 +789,12 @@ size_t vio_write_shared_memory(Vio * vio
}
+my_bool vio_is_connected_shared_memory(Vio *vio)
+{
+ return (WaitForSingleObject(vio->event_conn_closed, 0) != WAIT_OBJECT_0);
+}
+
+
/**
Close shared memory and DBUG_PRINT any errors that happen on closing.
@return Zero if all closing functions succeed, and nonzero otherwise.
Attachment: [text/bzr-bundle] bzr/zhenxing.he@sun.com-20091121044854-1pddwq4lhavp7c8f.bundle
| Thread |
|---|
| • bzr commit into mysql-5.6-next-mr-bugfixing branch (zhenxing.he:2957) | He Zhenxing | 21 Nov |