The problem is that the query cache stores packets containing
the server status of the time when the cached statement was run.
This might lead to a wrong transaction status in the client side
if a statement is cached during a transaction and is later served
outside a transaction context (and vice-versa).
The solution is to take into account the transaction status when
storing in and serving from the query cache.
mysql-test/r/innodb_cache.result:
Update test case result.
mysql-test/r/query_cache.result:
Add test case result for Bug#36326
mysql-test/t/query_cache.test:
Add test case for Bug#36326
sql/mysql_priv.h:
Add new flags.
sql/sql_cache.cc:
Remember the transaction and autocommit status stored in the packet.
tests/mysql_client_test.c:
Add test case for Bug#36326
The problem is that we cannot insert new record into memory table
when table size exceeds max memory table size.
The fix is to use schema_table_store_record() function which
converts memory table into MyISAM in case of table size exceeding.
Note:
There is no test case for this bug, the reason is that
1. The code that was added already is checked(i.e. works) with existing tests
2. Correct work of schema_table_store_record() is checked with other test cases
(information_schema tests)
So new code is fully covered with existing test cases.
sql/mysql_priv.h:
make schema_table_store_record() function global
sql/sql_acl.cc:
The problem is that we cannot insert new record into memory table
when table size exceeds max memory table size.
The fix is to use schema_table_store_record() function which
converts memory table into MyISAM in case of table size exceeding.
sql/sql_show.cc:
make schema_table_store_record() function global
The MONTHNAME/DAYNAME functions
returns binary string, so the LOWER/UPPER functions
are not effective on the result of MONTHNAME/DAYNAME call.
Character set of the MONTHNAME/DAYNAME function
result has been changed to connection character set.
include/m_ctype.h:
added my_charset_repertoire function
mysql-test/r/ctype_ucs.result:
test result
mysql-test/r/func_time.result:
test result
mysql-test/t/ctype_ucs.test:
test case
mysql-test/t/func_time.test:
test case
sql/item_timefunc.cc:
Item_func_monthname::fix_length_and_dec and
Item_func_dayname::fix_length_and_dec methods have been
modified to use connection character set
sql/item_timefunc.h:
Item_func_monthname::fix_length_and_dec and
Item_func_dayname::fix_length_and_dec methods have been
modified to use connection character set
sql/mysql_priv.h:
added max_month_name_length, max_day_name_length fields into MY_LOCALE struct
sql/mysqld.cc:
The test_lc_time_sz function controls modifications
of the locale database in debugging mode.
sql/sql_locale.cc:
initialization of max_month_name_length, max_day_name_length fields
strings/ctype.c:
added my_charset_repertoire function
enable uncacheable flag if we update a view with check option
and check option has a subselect, otherwise, the check option
can be evaluated after the subselect was freed as independent
(See full_local in JOIN::join_free())
mysql-test/r/subselect.result:
test result
mysql-test/t/subselect.test:
test case
sql/mysql_priv.h:
added UNCACHEABLE_CHECKOPTION flag
sql/sql_update.cc:
enable uncacheable flag if we update a view with check option
and check option has a subselect, otherwise, the check option
can be evaluated after the subselect was freed as independent
(See full_local in JOIN::join_free())
We pretended that TIMEDIFF() would always return positive results;
this gave strange results in comparisons of the TIMEDIFF(low,hi)<TIME(0)
type that rendered a negative result, but still gave false in comparison.
We also inadvertantly dropped the sign when converting times to
decimal.
CAST(time AS DECIMAL) handles signs of the times correctly.
TIMEDIFF() marked up as signed. Time/date comparison code switched to
signed for clarity.
mysql-test/r/func_sapdb.result:
show that time-related comparisons work with negative
time values now.
show that converting time to DECIMAL no longer drops sign.
mysql-test/t/func_sapdb.test:
show that time-related comparisons work with negative
time values now.
show that converting time to DECIMAL no longer drops sign.
sql/item_cmpfunc.cc:
signed returns
sql/item_cmpfunc.h:
signed now (time/date < > =)
sql/item_func.cc:
signed now
sql/item_timefunc.h:
Functions such as TIMEDIFF() return signed results!
The file-comments pretended we were doing that all along, anyway...
sql/my_decimal.cc:
heed sign when converting time to my_decimal;
times may actually be negative!
Needed for SELECT CAST(time('-73:42:12') AS DECIMAL);
sql/mysql_priv.h:
using signed for dates and times now
The '@' symbol can not be used in the host name according to rfc952.
The fix:
added function check_host_name(LEX_STRING *str)
which checks that all symbols in host name string are valid and
host name length is not more than max host name length
(just moved check_string_length() function from the parser into check_host_name()).
mysql-test/r/create.result:
test result
mysql-test/t/create.test:
test case
sql/mysql_priv.h:
added function check_host_name(LEX_STRING *str)
sql/sql_parse.cc:
added function check_host_name(LEX_STRING *str)
which checks that all symbols in host name string are valid and
host name length is not more than max host name length(HOSTNAME_LENGTH).
sql/sql_yacc.yy:
using newly added function check_host_name()
test_if_data_home_dir fixed to look into real path.
Checks added to mi_open for symlinks into data home directory.
per-file messages:
include/my_sys.h
Bug#32167 another privilege bypass with DATA/INDEX DIRECTORY.
my_is_symlink interface added
include/myisam.h
Bug#32167 another privilege bypass with DATA/INDEX DIRECTORY.
myisam_test_invalid_symlink interface added
myisam/mi_check.c
Bug#32167 another privilege bypass with DATA/INDEX DIRECTORY.
mi_open_datafile calls modified
myisam/mi_open.c
Bug#32167 another privilege bypass with DATA/INDEX DIRECTORY.
code added to mi_open to check for symlinks into data home directory.
mi_open_datafile now accepts 'original' file path to check if it's
an allowed symlink.
myisam/mi_static.c
Bug#32167 another privilege bypass with DATA/INDEX DIRECTORY.
myisam_test_invlaid_symlink defined
myisam/myisamchk.c
Bug#32167 another privilege bypass with DATA/INDEX DIRECTORY.
mi_open_datafile call modified
myisam/myisamdef.h
Bug#32167 another privilege bypass with DATA/INDEX DIRECTORY.
mi_open_datafile interface modified - 'real_path' parameter added
mysql-test/r/symlink.test
Bug#32167 another privilege bypass with DATA/INDEX DIRECTORY.
error codes corrected as some patch now rejected pointing inside datahome
mysql-test/r/symlink.result
Bug#32167 another privilege bypass with DATA/INDEX DIRECTORY.
error messages corrected in the result
mysys/my_symlink.c
Bug#32167 another privilege bypass with DATA/INDEX DIRECTORY.
my_is_symlink() implementsd
my_realpath() now returns the 'realpath' even if a file isn't a symlink
sql/mysql_priv.h
Bug#32167 another privilege bypass with DATA/INDEX DIRECTORY.
test_if_data_home_dir interface
sql/mysqld.cc
Bug#32167 another privilege bypass with DATA/INDEX DIRECTORY.
myisam_test_invalid_symlik set with the 'test_if_data_home_dir'
sql/sql_parse.cc
Bug#32167 another privilege bypass with DATA/INDEX DIRECTORY.
error messages corrected
test_if_data_home_dir code fixed
- In QUICK_INDEX_MERGE_SELECT::read_keys_and_merge: when we got table->sort from Unique,
tell init_read_record() not to use rr_from_cache() because a) rowids are already sorted
and b) it might be that the the data is used by filesort(), which will need record rowids
(which rr_from_cache() cannot provide).
- Fully de-initialize the table->sort read in QUICK_INDEX_MERGE_SELECT::get_next(). This fixes BUG#35477.
(bk trigger: file as fix for BUG#35478).
sql/filesort.cc:
BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
- make find_all_keys() use quick->get_next() instead of init_read_record(r)/r.read_record() calls
- added dbug printout
sql/mysql_priv.h:
BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
- Added parameter to init_read_record
sql/opt_range.cc:
BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
- In QUICK_INDEX_MERGE_SELECT::read_keys_and_merge: when we got table->sort from Unique,
tell init_read_record() not to use rr_from_cache() because a) rowids are already sorted
and b) it might be that the the data is used by filesort(), which will need record rowids
(which rr_from_cache() cannot provide).
- Fully de-initialize the table->sort read in QUICK_INDEX_MERGE_SELECT::get_next().
sql/records.cc:
BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
- Added disable_rr_cache parameter to init_read_record
- Added comment
sql/sql_acl.cc:
BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
- Added parameter to init_read_record
sql/sql_delete.cc:
BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
- Added parameter to init_read_record
sql/sql_help.cc:
BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
- Added parameter to init_read_record
sql/sql_select.cc:
BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
- Added parameter to init_read_record
sql/sql_table.cc:
BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
- Added parameter to init_read_record
sql/sql_udf.cc:
BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
- Added parameter to init_read_record
sql/sql_update.cc:
BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
- Added parameter to init_read_record
into moonbone.local:/work/27219-5.0-opt-mysql
sql/item.cc:
Auto merged
sql/item_subselect.cc:
Auto merged
sql/item_sum.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sql_select.cc:
Auto merged
Mixing aggregate functions and non-grouping columns is not allowed in the
ONLY_FULL_GROUP_BY mode. However in some cases the error wasn't thrown because
of insufficient check.
In order to check more thoroughly the new algorithm employs a list of outer
fields used in a sum function and a SELECT_LEX::full_group_by_flag.
Each non-outer field checked to find out whether it's aggregated or not and
the current select is marked accordingly.
All outer fields that are used under an aggregate function are added to the
Item_sum::outer_fields list and later checked by the Item_sum::check_sum_func
function.
mysql-test/t/group_by.test:
Added a test case for the bug#27219: Aggregate functions in ORDER BY.
mysql-test/r/group_by.result:
Added a test case for the bug#27219: Aggregate functions in ORDER BY.
sql/sql_select.cc:
Bug#27219: Aggregate functions in ORDER BY.
Implementation of new check for mixing non aggregated fields and aggregation
function in the ONLY_FULL_GROUP_BY mode.
sql/sql_lex.cc:
Bug#27219: Aggregate functions in ORDER BY.
Initialization of the full_group_by_flag bitmap.
SELECT_LEX::test_limit function doesn't reset ORDER BY
clause anymore.
sql/sql_lex.h:
Bug#27219: Aggregate functions in ORDER BY.
The full_group_by_flag is added to the SELECT_LEX class.
sql/item_sum.h:
Bug#27219: Aggregate functions in ORDER BY.
The outer_fields list is added to the Item_sum class.
sql/mysql_priv.h:
Bug#27219: Aggregate functions in ORDER BY.
Defined a set of constants used in the new check for mixing non aggregated
fields and sum functions in the ONLY_FULL_GROUP_BY_MODE.
sql/item_subselect.cc:
Bug#27219: Aggregate functions in ORDER BY.
The Item_in_subselect::select_in_like_transformer function now drops
ORDER BY clause in all selects in a subquery.
sql/item_sum.cc:
Bug#27219: Aggregate functions in ORDER BY.
Now the Item_sum::check_sum_func function now checks whether fields in the
outer_fields list are aggregated or not and marks selects accordingly.
sql/item.cc:
Bug#27219: Aggregate functions in ORDER BY.
Now the Item_field::fix_fields function checks whether the field is aggregated
or not and marks its select_lex accordingly.
The bool data type was redefined to BOOL (4 bytes on windows).
Removed the #define and fixed some of the warnings that were uncovered
by this.
Note that the fix also disables 2 warnings :
4800 : 'type' : forcing value to bool 'true' or 'false' (performance warning)
4805: 'operation' : unsafe mix of type 'type' and type 'type' in operation
These warnings will be handled in a separate bug, as they are performance related or bogus.
Fixed to int the return type of functions that return more than
2 distinct values.
CMakeLists.txt:
Bug #26461: disable the C4800 and C4805 warnings temporarily
include/config-win.h:
Bug #26461:
- no need for this define for Windows.
- windows C++ compilers have a bool type
include/my_global.h:
Bug #26461: removed bool_defined (no longer needed)
sql/handler.h:
Bug #26461: bool functions must return boolean values
sql/mysql_priv.h:
Bug #26461: fixed return type of functions that return more than
2 distinct values.
sql/procedure.h:
Bug #26461: fixed return type of functions that return more than
2 distinct values.
sql/sql_acl.cc:
Bug #26461: fixed return type of functions that return more than
2 distinct values.
sql/sql_acl.h:
Bug #26461: fixed return type of functions that return more than
2 distinct values.
sql/sql_analyse.cc:
Bug #26461: fixed return type of functions that return more than
2 distinct values.
sql/sql_analyse.h:
Bug #26461: fixed return type of functions that return more than
2 distinct values.
sql/sql_base.cc:
Bug #26461: fixed return type of functions that return more than
2 distinct values.
sql/sql_db.cc:
Bug #26461: fixed return type of functions that return more than
2 distinct values.
sql/sql_delete.cc:
Bug #26461: fixed return type of functions that return more than
2 distinct values.
sql/sql_load.cc:
Bug #26461: fixed return type of functions that return more than
2 distinct values.
sql/sql_parse.cc:
Bug #26461: fixed return type of functions that return more than
2 distinct values.
sql/sql_prepare.cc:
Bug #26461: fixed return type of functions that return more than
2 distinct values.
sql/sql_update.cc:
Bug #26461: fixed return type of functions that return more than
2 distinct values.
added new function test_if_data_home_dir() which checks that
path does not contain mysql data home directory.
Using of mysql data home directory in
DATA DIRECTORY & INDEX DIRECTORY is disallowed.
mysql-test/r/symlink.result:
test result
mysql-test/t/symlink.test:
test case
sql/mysql_priv.h:
new variable mysql_unpacked_real_data_home
sql/mysqld.cc:
new variable mysql_unpacked_real_data_home
sql/sql_parse.cc:
added new function test_if_data_home_dir() which checks that
path does not contain mysql data home directory.
Using of mysql data home directory in
DATA DIRECTORY & INDEX DIRECTORY is disallowed.
when executed in version 5
Zero fill is a field attribute only. So we can't always
propagate constants for zerofill fields : the values and
expression results don't have that flag.
Fixed by converting the const value to a string and
using that in const propagation when the context allows it.
Disable const propagation for fields with ZEROFILL flag in
all the other cases.
mysql-test/r/compare.result:
Bug #31887: test case
mysql-test/t/compare.test:
Bug #31887: test case
sql/item.cc:
Bug #31887: If the context allows conversion
of an int constant to a zero-filled string constant
put the string constant instead of the int constant
when doing const propagation
sql/mysql_priv.h:
Bug #31887: a macro to get all the Field_num
descendant fields.
Default values of variables were not subject to upper/lower bounds
and step, while setting variables was. Bounds and step are also
applied to defaults now; defaults are corrected quietly, values
given by the user are corrected, and a correction-warning is thrown
as needed. Lastly, very large values could wrap around, starting
from 0 again. They are bounded at the maximum value for the
respective data-type now if no lower maximum is specified in the
variable's definition.
client/mysql.cc:
correct maxima in options array
client/mysqltest.c:
adjust minimum for "sleep" option so default value is no longer
out of bounds.
include/m_string.h:
ullstr() - the unsigned brother of llstr()
include/my_getopt.h:
Flag if we bounded the value (that is, correct anything aside from
making value a multiple of block-size)
mysql-test/r/delayed.result:
We throw a warning now when we adjust out of range parameters.
mysql-test/r/index_merge.result:
We throw a warning now when we adjust out of range parameters.
mysql-test/r/innodb.result:
We throw a warning now when we adjust out of range parameters.
mysql-test/r/innodb_mysql.result:
We throw a warning now when we adjust out of range parameters.
mysql-test/r/key_cache.result:
We throw a warning now when we adjust out of range parameters.
mysql-test/r/packet.result:
We throw a warning now when we adjust out of range parameters.
mysql-test/r/ps.result:
We throw a warning now when we adjust out of range parameters.
mysql-test/r/subselect.result:
We throw a warning now when we adjust out of range parameters.
mysql-test/r/type_bit.result:
We throw a warning now when we adjust out of range parameters.
mysql-test/r/type_bit_innodb.result:
We throw a warning now when we adjust out of range parameters.
mysql-test/r/variables.result:
correct results: bounds and step apply to variables' default values, too
mysql-test/t/variables.test:
correct results: bounds and step apply to variables' default values, too
mysys/my_getopt.c:
- apply bounds/step to default values of variables (based on work by serg)
- print complaints about incorrect values for variables (truncation etc.,
by requestion of consulting)
- if no lower maximum is specified in variable definition, bound unsigned
values at their maximum to prevent wrap-around
- some calls to error_reporter had a \n, some didn't. remove \n from calls,
let reporter-function handle it, so the default reporter behaves like that
in mysqld
sql/mysql_priv.h:
correct RANGE_ALLOC_BLOCK_SIZE (cleared with monty)
sql/mysqld.cc:
correct maxima to correct data-type.
correct minima where higher than default.
correct range-alloc-block-size.
correct inno variables so GET_* corresponds to actual variable's type.
sql/set_var.cc:
When the new value for a variable is out of bounds, we'll send the
client a warning (but not if the value was simply not a multiple of
'blocksize'). sys_var_thd_ulong had this, sys_var_long_ptr_global
didn't; broken out and streamlined to avoid duplication of code.
strings/llstr.c:
ullstr() - the unsigned brother of llstr()
The "mysql client in mysqld"(which is used by
replication and federated) should use alarms instead of setting
socket timeout value if the rest of the server uses alarm. By
always calling 'my_net_set_write_timeout'
or 'net_set_read_timeout' when changing the timeout value(s), the
selection whether to use alarms or timeouts will be handled by
ifdef's in those two functions.
This is minimal backport of patch for BUG#26664, which was pushed
to 5.0 and up.
Affects 4.1 only.
include/mysql_com.h:
Move the net_set_*_timeout function declarations to mysql_com.h
sql-common/client.c:
Use my_net_read_timeout or my_net_write_timeout when setting the timeouts
sql/mysql_priv.h:
Move the net_set_*_timeout function declarations to mysql_com.h
into polly.(none):/home/kaa/src/opt/mysql-5.0-opt
mysql-test/r/variables.result:
Auto merged
mysql-test/t/variables.test:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/set_var.cc:
Auto merged
doesn't recognize it
This is a 5.0 version of the patch, it will be null-merged to 5.1
Problem:
'log' and 'log_slow_queries' were "fixed" variables, i.e. they showed up
in SHOW VARIABLES, but could not be used in expressions like
"select @@log". Also, using them in the SET statement produced an
incorrect "unknown system variable" error.
Solution:
Make 'log' and 'log_slow_queries' read-only dynamic variables to make
them available for use in expressions, and produce a correct error
about the variable being read-only when used in the SET statement.
mysql-test/r/variables.result:
Added a test case for bug #29131.
mysql-test/t/variables.test:
Added a test case for bug #29131.
sql/mysql_priv.h:
Changed the type of opt_log and opt_slow_log to my_bool to
align with the interfaces in set_var.cc
sql/mysqld.cc:
Changed the type of opt_log and opt_slow_log to my_bool to
align with the interfaces in set_var.cc
sql/set_var.cc:
Made 'log' and 'log_slow_queries' to be read-only dynamic system
variable, i.e. available for use in expressions with the @@var syntax.
sql/set_var.h:
Added a new system variable class representing a read-only boolean
variable.
into mysql.com:/home/gluh/MySQL/Merge/5.0-opt
client/mysqldump.c:
Auto merged
include/config-win.h:
Auto merged
libmysql/libmysql.c:
Auto merged
myisam/sort.c:
Auto merged
mysql-test/r/func_sapdb.result:
Auto merged
mysql-test/r/variables.result:
Auto merged
mysql-test/t/variables.test:
Auto merged
sql/field.cc:
Auto merged
sql/ha_innodb.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/item_sum.cc:
Auto merged
sql/item_timefunc.h:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/set_var.cc:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
tests/mysql_client_test.c:
Auto merged
mysql-test/r/type_datetime.result:
manual merge
mysql-test/r/type_decimal.result:
manual merge
mysql-test/t/type_datetime.test:
manual merge
mysql-test/t/type_decimal.test:
manual merge
sql/item.cc:
manual merge
into lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.0-rt-merge
mysql-test/r/udf.result:
Auto merged
mysql-test/t/udf.test:
Auto merged
sql/item.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/set_var.cc:
Auto merged
sql/udf_example.c:
Auto merged
sql/udf_example.def:
Auto merged
type of the result.
There are several functions that accept parameters of different types.
The result field type of such functions was determined based on
the aggregated result type of its arguments. As the DATE and the DATETIME
types are represented by the STRING type, the result field type
of the affected functions was always STRING for DATE/DATETIME arguments.
The affected functions are COALESCE, IF, IFNULL, CASE, LEAST/GREATEST, CASE.
Now the affected functions aggregate the field types of their arguments rather
than their result types and return the result of aggregation as their result
field type.
The cached_field_type member variable is added to the number of classes to
hold the aggregated result field type.
The str_to_date() function's result field type now defaults to the
MYSQL_TYPE_DATETIME.
The agg_field_type() function is added. It aggregates field types with help
of the Field::field_type_merge() function.
The create_table_from_items() function now uses the
item->tmp_table_field_from_field_type() function to get the proper field
when the item is a function with a STRING result type.
libmysql/libmysql.c:
Bug#27216: functions with parameters of different date types may return wrong
type of the result.
The client library now accepts the NEWDATE type as a string.
sql/item_cmpfunc.cc:
Bug#27216: functions with parameters of different date types may return wrong
type of the result.
Now the fix_length_and_dec functions of the
Item_func_ifnull,Item_func_if, Item_func_case, Item_func_coalesce
classes are use agg_field_type function to find out the type of their
result field.
sql/item_cmpfunc.h:
Bug#27216: functions with parameters of different date types may return wrong
type of the result.
The cached_field type is added to the Item_func_case, Item_func_if and
Item_func_coalesce classes.
The field_type function is added to the Item_func_ifnull, Item_func_if,
Item_func_coalesce, Item_func_case classes.
sql/item_func.cc:
Bug#27216: functions with parameters of different date types may return wrong
type of the result.
The Item_func_min_max::fix_length_and_dec function now uses the agg_field_type
function to find out the correct type of the result field.
sql/item_func.h:
Bug#27216: functions with parameters of different date types may return wrong
type of the result.
The cached_field_type variable is added to the Item_func_min_max class.
sql/item_timefunc.cc:
Bug#27216: functions with parameters of different date types may return wrong
type of the result.
The result of the str_to_date function now defaults to the
DATETIME type.
sql/mysql_priv.h:
Bug#27216: functions with parameters of different date types may return wrong
type of the result.
The prototype of the agg_field_type function is added.
sql/protocol.cc:
Bug#27216: functions with parameters of different date types may return wrong
type of the result.
The Protocol_simple::store function is now used to store fields of NEWDATE type.
sql/sql_insert.cc:
Bug#27216: functions with parameters of different date types may return wrong
type of the result.
The create_table_from_items function now uses the
tmp_table_field_from_field_type function to get field for items with the
STRING result type.
mysql-test/r/date_formats.result:
A test case result corrected after fixing bug#27216.
mysql-test/r/type_datetime.result:
Added a test case for the bug#27216: functions with parameters of different
date types may return wrong type of the result.
mysql-test/t/type_datetime.test:
Added a test case for the bug#27216: functions with parameters of different
date types may return wrong type of the result.
The problem was that aborted_threads variable was updated
twice when a client connection had been aborted.
The fix is to refactor a code to have aborted_threads updated
only in one place.
sql/mysql_priv.h:
Make do_command() a private function.
sql/sql_parse.cc:
1. Make do_command() a private function;
2. Update aborted_threads in the only one place.
between perm and temp tables. Review fixes.
The original bug report complains that if we locked a temporary table
with LOCK TABLES statement, we would not leave LOCK TABLES mode
when this temporary table is dropped.
Additionally, the bug was escalated when it was discovered than
when a temporary transactional table that was previously
locked with LOCK TABLES statement was dropped, futher actions with
this table, such as UNLOCK TABLES, would lead to a crash.
The problem originates from incomplete support of transactional temporary
tables. When we added calls to handler::store_lock()/handler::external_lock()
to operations that work with such tables, we only covered the normal
server code flow and did not cover LOCK TABLES mode.
In LOCK TABLES mode, ::external_lock(LOCK) would sometimes be called without
matching ::external_lock(UNLOCK), e.g. when a transactional temporary table
was dropped. Additionally, this table would be left in the list of LOCKed
TABLES.
The patch aims to address this inadequacy. Now, whenever an instance
of 'handler' is destroyed, we assert that it was priorly
external_lock(UNLOCK)-ed. All the places that violate this assert
were fixed.
This patch introduces no changes in behavior -- the discrepancy in
behavior will be fixed when we start calling ::store_lock()/::external_lock()
for all tables, regardless whether they are transactional or not,
temporary or not.
mysql-test/r/innodb_mysql.result:
Update test results (Bug#24918)
mysql-test/t/innodb_mysql.test:
Add a test case for Bug#24918
sql/handler.h:
Make handler::external_lock() a protected method. Backport from 5.1 its
public wrapper handler::ha_external_lock().
Assert that the handler is not closed if it is still locked.
sql/lock.cc:
In mysql_lock_tables only call lock_external() for the list of tables that
we called store_lock() for.
E.g. get_lock_data() does not add non-transactional temporary tables to the
lock list, so lock_external() should not be called for them.
Use handler::ha_external_lock() instead of handler::external_lock().
Add comments for mysql_lock_remove(), parameterize one strange
side effect that it has. At least in one place where mysql_lock_remove
is used, this side effect is not desired (DROP TABLE). The parameter
will be dropped in 5.1, along with the side effect.
sql/mysql_priv.h:
Update declaration of mysql_lock_remove().
sql/opt_range.cc:
Deploy handler::ha_external_lock() instead of handler::external_lock()
sql/sql_base.cc:
When closing a temporary table, remove the table from the list of LOCKed
TABLES of this thread, in case it's there.
It's there if it is a transactional temporary table.
Use a new declaration of mysql_lock_remove().
sql/sql_class.h:
Extend the comment for THD::temporary_tables.
sql/sql_table.cc:
Deploy handler::ha_external_lock() instead of handler::external_lock()
into sin.intern.azundris.com:/home/tnurnberg/27198/41-27198
sql/mysql_priv.h:
Bug #27198: Error returns from time() are ignored
manual merge
sql/sql_class.h:
Bug #27198: Error returns from time() are ignored
manual merge
gettimeofday() can fail and presumably, so can time().
Keep an eye on it.
Since we have no data on this at all so far, we just
retry on failure (and log the event), assuming that
this is just an intermittant failure. This might of
course hang the threat until we succeed. Once we know
more about these failures, an appropriate more clever
scheme may be picked (only try so many times per thread,
etc., if that fails, return last "good" time() we got or
some such). Using sql_print_information() to log as this
probably only occurs in high load scenarios where the debug-
trace likely is disabled (or might interfere with testing
the effect). No test-case as this is a non-deterministic
issue.
sql/mysql_priv.h:
Bug#27198: Error returns from time() are ignored
move declarations for log.cc to before inclusion of
sql_class.h as we now use sql_print_information() in
there.
sql/sql_class.h:
Bug#27198: Error returns from time() are ignored
gettimeofday() can fail and presumably, so can time().
Keep an eye on it.
The need arose when working on Bug 26141, where it became
necessary to replace TABLE_LIST with its forward declaration in a few
headers, and this involved a lot of s/TABLE_LIST/st_table_list/.
Although other workarounds exist, this patch is in line
with our general strategy of moving away from typedef-ed names.
Sometime in future we might also rename TABLE_LIST to follow the
coding style, but this is a huge change.
sql/item.cc:
st_table_list -> TABLE_LIST
sql/item.h:
st_table_list -> TABLE_LIST
sql/mysql_priv.h:
st_table_list -> TABLE_LIST
sql/sql_base.cc:
st_table_list -> TABLE_LIST
sql/sql_lex.cc:
st_table_list -> TABLE_LIST
sql/sql_lex.h:
st_table_list -> TABLE_LIST
sql/sql_select.cc:
st_table_list -> TABLE_LIST
sql/sql_show.cc:
st_table_list -> TABLE_LIST
sql/sql_udf.h:
Was not needed.
sql/table.cc:
st_table_list -> TABLE_LIST
sql/table.h:
st_table_list -> TABLE_LIST
into quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/jun05/50
mysql-test/mysql-test-run.pl:
Auto merged
mysql-test/t/mysqltest.test:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
into polly.local:/home/kaa/src/maint/mysql-5.0-maint
sql/field.cc:
Auto merged
sql/field.h:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
strings/strtod.c:
Auto merged
When storing a large number to a FLOAT or DOUBLE field with fixed length, it could be incorrectly truncated if the field's length was greater than 31.
This patch also does some code cleanups to be able to reuse code which is common between Field_float::store() and Field_double::store().
include/m_string.h:
Added declarations for log_10 and log_01 from strtod.c
mysql-test/r/type_float.result:
Added the testcase for bug #28121 "INSERT or UPDATE into DOUBLE(200,0) field being truncated to 31 digits"
mysql-test/t/type_float.test:
Added the testcase for bug #28121 "INSERT or UPDATE into DOUBLE(200,0) field being truncated to 31 digits"
sql/field.cc:
Moved common code from Field_float::store() and Field_double:store() to Field_real::truncate()
Fixed the algorithm to not truncate large input numbers if the field length is greater than 31.
Fixed rounding to not depend on FLT_MAX/DBL_MAX constants.
sql/field.h:
Moved not_fixed member from Field_double to Field_real to allow code reuse between Field_float::store() and Field_double::store()
Added truncate() method to Field_real which is used by both Field_float and Field_double
sql/init.cc:
log_10[] and log_01[] are now defined as statical arrays in strtod.c, no need to pre-computed them.
sql/item_cmpfunc.cc:
log_01[] now starts from 1e0, not from 1e-1 for consistency.
sql/mysql_priv.h:
Moved log_10[] and log_01[] from mysqld.cc to libmystrings.
sql/mysqld.cc:
Moved log_10[] and log_01[] from mysqld.cc to libmystrings.
strings/strtod.c:
Define and use log_10[] and log_01[] as static arrays of constants instead of values pre-computed at startup.
into pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
libmysql/libmysql.c:
Auto merged
sql-common/client.c:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/net_serv.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_repl.cc:
Auto merged
- The "mysql client in mysqld"(which is used by
replication and federated) should use alarms instead of setting
socket timeout value if the rest of the server uses alarm. By
always calling 'my_net_set_write_timeout'
or 'my_net_set_read_timeout' when changing the timeout value(s), the
selection whether to use alarms or timeouts will be handled by
ifdef's in those two functions.
- Move declaration of 'vio_timeout' into "vio_priv.h"
include/mysql_com.h:
Move the net_set_*_timeout function declarations to mysql_com.h and
rename to my_net_set_*_timeout to avoid name clashes
include/violite.h:
Move declaration of 'vio_timeout' to vio_priv.h (to make
the function as private as possible)
libmysql/libmysql.c:
Use my_net_read_timeout or my_net_write_timeout when setting
the timeouts. Move the global variables for my_net_read/my_write_timeout
into the only place where they are used. Thus removing them...
server-tools/instance-manager/mysql_connection.cc:
Use my_net_read_timeout or my_net_write_timeout when setting the timeouts
sql-common/client.c:
Use my_net_read_timeout or my_net_write_timeout when setting the timeouts
sql/mysql_priv.h:
Move the net_set_*_timeout function declarations to mysql_com.h
sql/net_serv.cc:
No need to cast the net->write_timeout value from "uint" to "uint"
sql/set_var.cc:
Rename net_set_*_timeout to my_net_set_*_timeout
sql/sql_client.cc:
Use my_net_read_timeout or my_net_write_timeout when setting the timeouts
sql/sql_parse.cc:
Rename net_set_*_timeout to my_net_set_*_timeout
sql/sql_repl.cc:
Rename net_set_*_timeout to my_net_set_*_timeout
vio/vio_priv.h:
Move declaration of 'vio_timeout' to vio_priv.h
vio/viosocket.c:
Cleanup 'vio_timeout'
- Use "const void*" on POSIX and "const char*" on windows for
setsockopt
- Add DBUG_PRINT's
- Add comment about why we don't have an implementation of
vio_timeout for platforms not supporting SO_SNDTIMEO or SO_RCVTIMEO
Bug #23667 "CREATE TABLE LIKE is not isolated from alteration
by other connections"
Bug #18950 "CREATE TABLE LIKE does not obtain LOCK_open"
As well as:
Bug #25578 "CREATE TABLE LIKE does not require any privileges
on source table".
The first and the second bugs resulted in various errors and wrong
binary log order when one tried to execute concurrently CREATE TABLE LIKE
statement and DDL statements on source table or DML/DDL statements on its
target table.
The problem was caused by incomplete protection/table-locking against
concurrent statements implemented in mysql_create_like_table() routine.
We solve it by simply implementing such protection in proper way (see
comment for sql_table.cc for details).
The third bug allowed user who didn't have any privileges on table create
its copy and therefore circumvent privilege check for SHOW CREATE TABLE.
This patch solves this problem by adding privilege check, which was missing.
Finally it also removes some duplicated code from mysql_create_like_table().
Note that, altough tests covering concurrency-related aspects of CREATE TABLE
LIKE behaviour will only be introduced in 5.1, they were run manually for
this patch as well.
mysql-test/r/grant2.result:
Added test for bug#25578 "CREATE TABLE LIKE does not require any privileges
on source table".
mysql-test/t/grant2.test:
Added test for bug#25578 "CREATE TABLE LIKE does not require any privileges
on source table".
sql/handler.h:
Introduced new flag for HA_CREATE_INFO::options in order to be able to
distinguish CREATE TABLE ... LIKE from other types of CREATE TABLE.
sql/mysql_priv.h:
mysql_create_like_table() now takes source table name not as a
Table_ident object but as regular table list element.
sql/sql_parse.cc:
CREATE TABLE ... LIKE implementation now uses statement's table list
for storing information about the source table. We also use flag
in LEX::create_info.options for distinguishing it from other types
of CREATE TABLE.
Finally CREATE TABLE ... LIKE now requires the same privileges on
the source tables as SHOW CREATE TABLE. Moved this privilege check
to check_show_create_table_access() function.
sql/sql_table.cc:
mysql_create_like_table():
- Provided proper protection from concurrent statements.
This is achieved by keeping name-lock on the source table and holding
LOCK_open mutex during whole operation. This gives protection against
concurrent DDL on source table. Also holding this mutex makes copying
of .frm file, call to ha_create_table() and binlogging atomic against
concurrent DML and DDL operations on target table.
- Get rid of duplicated code related to source database/table name
handling. All these operations are already done in
st_select_lex::add_table_to_list(), so we achieve the same effect
by including source table into the statement's table list.
sql/sql_yacc.yy:
Now we use special flag in LEX::create_info::options for distinguishing
CREATE TABLE ... LIKE from other types of CREATE TABLE and store name
of source table as regular element in statement's table list.
Increase STACK_BUFF_ALLOC to avoid execution_constants test failure on the hpita2.
sql/mysql_priv.h:
Fix for bug #21476: stack overflow crashes server; error-message stack reservation too small
- due to the failing execution_constants test on the hpita2,
increase STACK_BUFF_ALLOC, that is used in the Item_func::fix_fields() to
allocate on the stack a "dummy" buffer large enough for the corresponding exec.
into siva.hindu.god:/home/tsmith/m/bk/maint/50
mysql-test/r/type_datetime.result:
Auto merged
mysql-test/t/outfile.test:
Auto merged
mysql-test/t/type_datetime.test:
Auto merged
sql/field.cc:
Auto merged
sql/item.cc:
Auto merged
sql/item.h:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/item_func.h:
Auto merged
sql/my_decimal.h:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sp.cc:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_class.h:
Auto merged
Made year 2000 handling more uniform
Removed year 2000 handling out from calc_days()
The above removes some bugs in date/datetimes with year between 0 and 200
Now we get a note when we insert a datetime value into a date column
For default values to CREATE, don't give errors for warning level NOTE
Fixed some compiler failures
Added library ws2_32 for windows compilation (needed if we want to compile with IOCP support)
Removed duplicate typedef TIME and replaced it with MYSQL_TIME
Better (more complete) fix for: Bug#21103 "DATE column not compared as DATE"
Fixed properly Bug#18997 "DATE_ADD and DATE_SUB perform year2K autoconversion magic on 4-digit year value"
Fixed Bug#23093 "Implicit conversion of 9912101 to date does not match cast(9912101 as date)"
include/my_time.h:
Removed not used define YY_MAGIC_BELOW
Added prototype for year_2000_handling()
mysql-test/r/date_formats.result:
Updated results (fixed bug in date_format() with year < 99
mysql-test/r/func_sapdb.result:
Added more testing of make_date()
mysql-test/r/ps_2myisam.result:
Now we get a note when we insert a datetime value into a date column
mysql-test/r/ps_3innodb.result:
Now we get a note when we insert a datetime value into a date column
mysql-test/r/ps_4heap.result:
Now we get a note when we insert a datetime value into a date column
mysql-test/r/ps_5merge.result:
Now we get a note when we insert a datetime value into a date column
mysql-test/r/ps_7ndb.result:
Now we get a note when we insert a datetime value into a date column
mysql-test/r/strict.result:
zero-year in str_to_date() throws warning in strict
mysql-test/r/type_date.result:
Added test for date conversions
mysql-test/r/type_datetime.result:
Added testcase for datetime to date conversion.
mysql-test/t/date_formats.test:
Added testing of dates < 200
mysql-test/t/func_sapdb.test:
More testing of makedate()
mysql-test/t/type_date.test:
Added test for date conversions
mysql-test/t/type_datetime.test:
Added testcase for datetime to date conversion
sql/field.cc:
Give note if we insert a datetime value in a date field
Don't give notes if we are doing internal test conversions (like from convert_constant_item())
More documentation (store functions can now return '3' to inform that the function did return a NOTE (not warning or error))
Revert some changes in Field_newdate::store() to get more optimal code
Field::set_warning() will now ignore notes if CHECK_FIELD_IGNORE is set.
New parameters to make_truncated_value_warning()
sql/field.h:
Give note if we insert a datetime value in a date field
Don't give notes if we are doing internal test conversions (like from convert_constant_item())
More documentation (store functions can now return '3' to inform that the function did return a NOTE (not warning or error))
Revert some changes in Field_newdate::store() to get more optimal code
Field::set_warning() will now ignore notes if CHECK_FIELD_IGNORE is set.
New parameters to make_truncated_value_warning()
sql/item.cc:
Give note if we insert a datetime value in a date field
Don't give notes if we are doing internal test conversions (like from convert_constant_item())
More documentation (store functions can now return '3' to inform that the function did return a NOTE (not warning or error))
Revert some changes in Field_newdate::store() to get more optimal code
Field::set_warning() will now ignore notes if CHECK_FIELD_IGNORE is set.
New parameters to make_truncated_value_warning()
sql/item.h:
TIME -> MYSQL_TIME
sql/item_cmpfunc.cc:
Don't print notes in convert_constant_item()
sql/item_func.h:
TIME -> MYSQL_TIME
sql/item_timefunc.cc:
New parameters to make_truncated_value_warning()
Moved year 2000 handling out from calc_days()
sql/item_timefunc.h:
TIME -> MYSQL_TIME
sql/my_decimal.cc:
TIME -> MYSQL_TIME
sql/my_decimal.h:
TIME -> MYSQL_TIME
sql/mysql_priv.h:
Added error level to make_truncated_value_warning()
sql/protocol.cc:
TIME -> MYSQL_TIME
sql/protocol.h:
TIME -> MYSQL_TIME
sql/sp.cc:
TIME -> MYSQL_TIME
sql/sql_base.cc:
Make testing of result value of save_in_field() uniform
sql/sql_class.h:
TIME -> MYSQL_TIME
sql/sql_show.cc:
TIME -> MYSQL_TIME
sql/structs.h:
TIME -> MYSQL_TIME
sql/time.cc:
Added error level to make_truncated_value_warning()
sql/tztime.cc:
TIME -> MYSQL_TIME
sql/tztime.h:
TIME -> MYSQL_TIME
sql/unireg.cc:
For default values to CREATE, don't give errors for warning level NOTE
(Fixed failed CREATE when we give a datetime value to a date field)
sql-common/my_time.c:
Added year_2000_handling()
Removed year 2000 handling from calc_daynr()
into vajra.(none):/opt/local/work/mysql-5.0-runtime
sql/item.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/set_var.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_prepare.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
into mockturtle.local:/home/dlenev/src/mysql-5.0-cts-3
sql/mysql_priv.h:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_prepare.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
Bug #20662 "Infinite loop in CREATE TABLE IF NOT EXISTS ... SELECT
with locked tables"
Bug #20903 "Crash when using CREATE TABLE .. SELECT and triggers"
Bug #24738 "CREATE TABLE ... SELECT is not isolated properly"
Bug #24508 "Inconsistent results of CREATE TABLE ... SELECT when
temporary table exists"
Deadlock occured when one tried to execute CREATE TABLE IF NOT
EXISTS ... SELECT statement under LOCK TABLES which held
read lock on target table.
Attempt to execute the same statement for already existing
target table with triggers caused server crashes.
Also concurrent execution of CREATE TABLE ... SELECT statement
and other statements involving target table suffered from
various races (some of which might've led to deadlocks).
Finally, attempt to execute CREATE TABLE ... SELECT in case
when a temporary table with same name was already present
led to the insertion of data into this temporary table and
creation of empty non-temporary table.
All above problems stemmed from the old implementation of CREATE
TABLE ... SELECT in which we created, opened and locked target
table without any special protection in a separate step and not
with the rest of tables used by this statement.
This underminded deadlock-avoidance approach used in server
and created window for races. It also excluded target table
from prelocking causing problems with trigger execution.
The patch solves these problems by implementing new approach to
handling of CREATE TABLE ... SELECT for base tables.
We try to open and lock table to be created at the same time as
the rest of tables used by this statement. If such table does not
exist at this moment we create and place in the table cache special
placeholder for it which prevents its creation or any other usage
by other threads.
We still use old approach for creation of temporary tables.
Also note that we decided to postpone introduction of some tests
for concurrent behaviour of CREATE TABLE ... SELECT till 5.1.
The main reason for this is absence in 5.0 ability to set @@debug
variable at runtime, which can be circumvented only by using several
test files with individual .opt files. Since the latter is likely
to slowdown test-suite unnecessary we chose not to push this tests
into 5.0, but run them manually for this version and later push
their optimized version into 5.1
mysql-test/r/create.result:
Extended test coverage for CREATE TABLE ... SELECT. In particular added
tests for bug #24508 "Inconsistent results of CREATE TABLE ... SELECT
when temporary table exists" and bug #20662 "Infinite loop in CREATE
TABLE IF NOT EXISTS ... SELECT with locked tables".
mysql-test/r/trigger.result:
Added test case for bug #20903 "Crash when using CREATE TABLE .. SELECT
and triggers"
mysql-test/t/create.test:
Extended test coverage for CREATE TABLE ... SELECT. In particular added
tests for bug #24508 "Inconsistent results of CREATE TABLE ... SELECT
when temporary table exists" and bug #20662 "Infinite loop in CREATE
TABLE IF NOT EXISTS ... SELECT with locked tables".
mysql-test/t/trigger.test:
Added test case for bug #20903 "Crash when using CREATE TABLE .. SELECT
and triggers"
sql/lock.cc:
Now for creation of name-lock placeholder in lock_table_name() we use
auxiliary function table_cache_insert_placeholder().
sql/mysql_priv.h:
Made build_table_path() function available outside of sql_table.cc file.
reopen_name_locked_table() now has 3rd argument which controls linking
in of table being opened into THD::open_tables (this is useful in
cases when placeholder used for name-locking is already linked into
this list).
Added declaration of auxiliary function table_cache_insert_placeholder()
which is used for creation of table placeholders for name-locking.
Added declaration of table_cache_has_open_placeholder() function which
can be used for checking if table cache contains an open placeholder for
the table and if this placeholder was created by another thread.
(This function is needed only in 5.0 where we use it in various versions
of CREATE TABLE in order to protect it from concurrent CREATE TABLE
... SELECT operations for the table. Starting from 5.1 we use different
approach so it is going to be removed there).
Made close_old_data_files() static within sql_base.cc file.
Added auxiliary drop_open_table() routine.
Moved declaration of refresh_version to table.h header to make it
accessible from inline methods of TABLE class.
MYSQL_OPEN_IGNORE_LOCKED_TABLES flag is no longer used. Instead
MYSQL_OPEN_TEMPORARY_ONLY option was added.
sql/sql_base.cc:
Added support for the new approach to the handling of CREATE TABLE
... SELECT for base tables.
Now we try to open and lock table to be created at the same time as
the rest of tables used by this statement. If such table does not
exist at this moment we create and place in the table cache special
placeholder for it which prevents its creation or any other usage
by other threads.
Note significant distinctions of this placeholder from the placeholder
used for normal name-lock: 1) It is treated like open table by other
name-locks so it does not allow name-lock taking operations like DROP
TABLE or RENAME TABLE to proceed. 2) it is linked into THD::open_tables
list and automatically removed during close_thread_tables() call.
open_tables():
Implemented logic described above. To do this added
auxiliary check_if_table_exists() function.
Removed support for MYSQL_OPEN_IGNORE_LOCKED_TABLES option
which is no longer used.
Added MYSQL_OPEN_TEMPORARY_ONLY which is used to restrict
search for temporary tables only.
close_cached_tables()/close_thread_table()/reopen_tables()/
close_old_data_files()/table_is_used()/remove_table_from_cache():
Added support for open placeholders (note that we also use them
when we need to re-open tables during flush).
Added auxiliary drop_open_table() routine.
reopen_name_locked_table():
Now has 3rd argument which controls linking in of table being
opened into THD::open_tables (this is useful in cases when
placeholder used for name-locking is already linked into
this list).
Added auxiliary table_cache_insert_placeholder() routine which
simplifies creation of placeholders used for name-locking.
Added table_cache_has_open_placeholder() function which can be
used for checking if table cache contains an open placeholder for
the table and if this placeholder was created by another thread.
(This function is needed only in 5.0 where we use it in various versions
of CREATE TABLE in order to protect it from concurrent CREATE TABLE
... SELECT operations for the table. Starting from 5.1 we use different
approach so it is going to be removed there).
sql/sql_handler.cc:
Adjusted mysql_ha_mark_tables_for_reopen() routine to properly
handle placeholders which now can be linked into open tables
list.
sql/sql_insert.cc:
Introduced new approach to handling of base tables in CREATE TABLE
... SELECT statement.
Now we try to open and lock table to be created at the same time as
the rest of tables used by this statement. If such table does not
exist at this moment we create and place in the table cache special
placeholder for it which prevents its creation or any other usage
by other threads. By doing this we avoid races which existed with
previous approach in which we created, opened and locked target in
separate step without any special protection.
This also allows properly calculate prelocking set in cases when
target table already exists and has some on insert triggers.
Note that we don't employ the same approach for temporary tables
(this is okay as such tables are unaffected by other threads).
Changed create_table_from_items() and select_create methods to
implement this approach.
sql/sql_parse.cc:
The new approach to handling of CREATE TABLE ... SELECT for
base tables assumes that all tables (including table to be
created) are opened and (or) locked at the same time.
So in cases when we create base table we have to pass to
open_and_lock_tables() table list which includes target table.
sql/sql_prepare.cc:
The new approach to handling of CREATE TABLE ... SELECT for
base tables assumes that all tables (including table to be
created) are opened and (or) locked at the same time.
So in cases when we create base table we have to pass to
open_and_lock_tables() table list which includes target table.
sql/sql_table.cc:
Now mysql_create_table_internal(), mysql_create_like_table() and
mysql_alter_table() not only check that destination table doesn't
exist on disk but also check that there is no create placeholder
in table cache for it (i.e. there is no CREATE TABLE ... SELECT
operation in progress for it). Note that starting from 5.1 we
use different approach in order to to protect CREATE TABLE ... SELECT
from concurrent CREATE TABLE (ALTER TABLE ... RENAME) operations,
the latter simply take name-locks on table before its creation
(on target table name before renaming).
Also made build_table_path() available from other files and
asjusted calls to reopen_name_locked_table(), which now takes
extra argument, which controls linking of open table into
THD::open_tables list.
sql/sql_trigger.cc:
reopen_name_locked_tables() now has one more argument which controls
linking of opened table into the THD::open_tables list.
sql/sql_yacc.yy:
The new approach to handling of CREATE TABLE ... SELECT statement
for base tables assumes that all tables including table to be
created are open and (or) locked at the same time. Therefore
we need to set correct lock for target table.
sql/table.h:
Moved declaration of refresh_version variable from mysql_priv.h
to make it accessible from inline methods of TABLE class.
Renamed TABLE::locked_by_flush member to open_placeholder since
now it is also used for taking exclusive name-lock and not only
by flush.
Introduced TABLE::is_name_opened() helper method which can be used
to distinguish TABLE instances corresponding to open tables or
placeholders for them from closed instances (e.g. due to their old
version). Also introduced TABLE::needs_reopen_or_name_lock() helper
which allows to check if TABLE instance corresponds to outdated
version of table or to name-lock placeholder.
Introduced TABLE_LIST::create member which marks elements of
table list corresponds to the table to be created.
Adjusted TABLE_LIST::placeholder() method to take into account
name-lock placeholders for tables to be created (this, for example,
allows to properly handle such placeholders in lock_tables()).
mysql-test/r/query_cache.result:
Added 5.0 testcase
mysql-test/t/query_cache.test:
Added 5.0 test case
sql/mysql_priv.h:
Added support for div_precision_increment
sql/set_var.cc:
- Added query cache flush when system variable ft_boolean_syntax is
updated since this also invalidates all cached result sets using this
variable.
sql/sql_cache.cc:
- Added the local system variable div_precision_increment as an identification flag
for cached queries.