Commit graph

490 commits

Author SHA1 Message Date
Georgi Kodinov
2d8869d248 Bug #49734: Crash on EXPLAIN EXTENDED UNION ... ORDER BY <any non-const-function>
Several problems fixed : 
1. Non constant expressions in UNION ... ORDER BY were not correctly cleaned up
in st_select_lex_unit::cleanup() causing crashes in EXPLAIN EXTENDED because of
fields quoted by these expressions pointing to the already freed temporary table
used to calculate the UNION.
Fixed by correctly cleaning up expressions of any depth.

2. Subqueries in the order by part of UNION ... ORDER BY ... caused a crash in 
EXPLAIN EXTENDED because of a transformation attempt made during EXPLAIN EXTENDED
execution. Fixed by not doing the transformation when in EXPLAIN.

3. Fulltext functions caused crash when in the ORDER BY part of an un-parenthesized
UNION that gets "promoted" to be valid for the whole union, e.g. 
SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY MATCHES (a) AGAINST ('abc' IN BOOLEAN MODE).
This is a case that demonstrates a more general problem of parts of the query being
moved to another level. When doing such transformation late in the optimization run
when most of the flags about the contents of the query are already aggregated it's possible 
to "split" the flags so that they correctly reflect the new queries after the transformation.
In specific the ST_SELECT_LEX::ftfunc_list is holding all the free text function for all the 
parts of the second SELECT in the UNION and we don't know what part of that is in the ORDER BY
that we're to move to the UNION level and what part is about the other parts of the second SELECT.
Fixed by throwing and error when such statements are about to be processed by adding a check 
for the presence of MATCH() inside the ORDER BY clause that's going to get promoted to UNION.
To workaround this new limitation one must parenthesize the UNION SELECTs and provide a real 
global ORDER BY for the UNION outside of the parenthesis.
2009-12-22 17:52:15 +02:00
Alexey Kopytov
d65fdb3168 Automerge 2009-12-13 23:57:57 +03:00
Alexey Kopytov
c08e6c8867 Bug #42849: innodb crash with varying time_zone on partitioned
timestamp primary key 
 
Since TIMESTAMP values are adjusted by the current time zone  
settings in both numeric and string contexts, using any 
expressions involving TIMESTAMP values as a  
(sub)partitioning function leads to undeterministic behavior of  
partitioned tables. The effect may vary depending on a storage  
engine, it can be either incorrect data being retrieved or  
stored, or an assertion failure. The root cause of this is the  
fact that the calculated partition ID may differ from a  
previously calculated ID for the same data due to timezone  
adjustments of the partitioning expression value. 
 
Fixed by disabling any expressions involving TIMESTAMP values  
to be used in partitioning functions with the follwing two 
exceptions: 
 
1. Creating or altering into a partitioned table that violates 
the above rule is not allowed, but opening existing such tables 
results in a warning rather than an error so that such tables 
could be fixed. 
 
2. UNIX_TIMESTAMP() is the only way to get a 
timezone-independent value from a TIMESTAMP column, because it 
returns the internal representation (a time_t value) of a 
TIMESTAMP argument verbatim. So UNIX_TIMESTAMP(timestamp_column)
is allowed and should be used to fix existing tables if one 
wants to use TIMESTAMP columns with partitioning.

mysql-test/r/partition_bug18198.result:
  Corrected the error.
mysql-test/r/partition_error.result:
  Corrected error texts.
  Added test cases for bug #42849.
mysql-test/t/partition_bug18198.test:
  Corrected error code.
mysql-test/t/partition_error.test:
  Corrected error codes.
  Added test cases for bug #42849.
sql/item.h:
  Added is_timezone_dependent_processor() to Item.
sql/item_func.h:
  Added has_timestamp_args() and the implementation of
  is_timezone_dependent_processor() for Item_func.
sql/item_timefunc.h:
  Added is_timezone_dependent_processor() to 
  Item_func_unix_timestamp.
sql/share/errmsg.txt:
  Renamed ER_CONST_EXPR_IN_PARTITION_FUNC_ERROR to
  ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR to better reflect the
  meaning. Adjusted the error message.
sql/sql_partition.cc:
  Modified fix_fields_part_func() to walk through partitioning
  expression tree with is_timezone_dependent_processor() and issue
  a warning/error if it depends on the timezone settings.
  
  Changed fix_fields_part_func() to a static function since it is
  not used anywhere except sql_partition.cc
sql/sql_partition.h:
  Removed the unneeded declaration of fix_fields_part_func()
  since it is now a static function.
sql/sql_yacc.yy:
  ER_CONST_EXPR_IN_PARTITION_FUNC_ERROR ->
  ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR.
2009-12-13 23:29:50 +03:00
Evgeny Potemkin
9f638f535e Manual merge of the fix for bug#43668. 2009-11-24 18:26:13 +03:00
Evgeny Potemkin
bc43bff7ed Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
MySQL manual describes values of the YEAR(2) field type as follows:
values 00 - 69 mean 2000 - 2069 years and values 70 - 99 mean 1970 - 1999
years. MIN/MAX and comparison functions was comparing them as int values
thus producing wrong result.

Now the Arg_comparator class is extended with compare_year function which
performs correct comparison of the YEAR type.
The Item_sum_hybrid class now uses Item_cache and Arg_comparator objects to
correctly calculate its value.
To allow Arg_comparator to use func_name() function for Item_func and Item_sum
objects the func_name declaration is moved to the Item_result_field class.
A helper function is_owner_equal_func is added to the Arg_comparator class.
It checks whether the Arg_comparator object owner is the <=> function or not.
A helper function setup is added to the Item_sum_hybrid class. It sets up
cache item and comparator.

mysql-test/r/func_group.result:
  Added a test case for the bug#43668.
mysql-test/t/func_group.test:
  Added a test case for the bug#43668.
sql/item.cc:
  Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
  Now Item_cache_int returns the type of cached item.
sql/item.h:
  Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
  To allow Arg_comparator to use func_name() function for Item_func and Item_sum
  objects the func_name declaration is moved to the Item_result_field class.
sql/item_cmpfunc.cc:
  Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
  The Arg_comparator class is extended with compare_year function which
  performs correct comparison of the YEAR type.
sql/item_cmpfunc.h:
  Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
  The year_as_datetime variable is added to the Arg_comparator class.
  It's set to TRUE when YEAR value should be converted to the
  YYYY-00-00 00:00:00 format for correct YEAR-DATETIME comparison.
sql/item_geofunc.cc:
  Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
  Item_func_spatial_rel::val_int chenged to use Arg_comparator's string
  buffers.
sql/item_subselect.h:
  Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
  Added an implementation of the virtual func_name function.
sql/item_sum.cc:
  Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
  The Item_sum_hybrid class now uses Item_cache and Arg_comparator objects to
  correctly calculate its value.
  A helper function setup is added to the Item_sum_hybrid class. It sets up
  cache item and comparator.
sql/item_sum.h:
  Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
  The Item_sum_hybrid class now uses Item_cache and Arg_comparator objects to
  correctly calculate its value.
  Added an implementation of the virtual func_name function.
2009-11-17 17:06:46 +03:00
Davi Arnaut
1ca80ed19e Bug#48370: Absolutely wrong calculations with GROUP BY and decimal fields when using IF
Bug#45261: Crash, stored procedure + decimal

Revert fix for Bug#45261 due to unforeseen bugs.
2009-11-02 09:21:39 -02:00
Davi Arnaut
fc39459504 Bug#45261: Crash, stored procedure + decimal
The problem was that creating a DECIMAL column from a decimal
value could lead to a failed assertion as decimal values can
have a higher precision than those attached to a table. The
assert could be triggered by creating a table from a decimal
with a large (> 30) scale. Also, there was a problem in
calculating the number of digits in the integral and fractional
parts if both exceeded the maximum number of digits permitted
by the new decimal type.

The solution is to ensure that truncation procedure is executed
when deducing a DECIMAL column from a decimal value of higher
precision. If the integer part is equal to or bigger than the
maximum precision for the DECIMAL type (65), the integer part
is truncated to fit and the fractional becomes zero. Otherwise,
the fractional part is truncated to fit into the space left
after the integer part is copied.

This patch borrows code and ideas from Martin Hansson's patch.

mysql-test/r/type_newdecimal.result:
  Add test case result for Bug#45261. Also, update test case to
  reflect that an additive operation increases the precision of
  the resulting type by 1.
mysql-test/t/type_newdecimal.test:
  Add test case for Bug#45261
sql/field.cc:
  Added DBUG_ASSERT to ensure object's invariant is maintained.
  Implement method to create a field to hold a decimal value
  from an item.
sql/field.h:
  Explain member variable. Add method to create a new decimal field.
sql/item.cc:
  The precision should only be capped when storing the value
  on a table. Also, this makes it impossible to calculate the
  integer part if Item::decimals (the scale) is larger than the
  precision.
sql/item.h:
  Simplify calculation of integer part.
sql/item_cmpfunc.cc:
  Do not limit the precision. It will be capped later.
sql/item_func.cc:
  Use new method for allocating a new decimal field.
  Add a specialized method for retrieving the precision
  of a user variable item.
sql/item_func.h:
  Add method to return the precision of a user variable.
sql/item_sum.cc:
  Use new method for allocating a new decimal field.
sql/my_decimal.h:
  The integer part could be improperly calculated for a decimal
  with 31 digits in the fractional part.
sql/sql_select.cc:
  Use new method which truncates the integer or decimal parts
  as needed.
2009-08-24 16:47:08 -03:00
Anurag Shekhar
0ad57bef5d merging with 5.0 bugteam tree 2009-07-15 15:43:45 +05:30
Anurag Shekhar
c77b836ab8 Bug#37740 Server crashes on execute statement with full text search and
match against.


Server crashes when executing prepared statement with duplicating
MATCH() function calls in SELECT and ORDER BY expressions, e.g.:
SELECT MATCH(a) AGAINST('test') FROM t1 ORDER BY MATCH(a) AGAINST('test')

This query gets optimized by the server, so the value returned
by MATCH() from the SELECT list is reused for ORDER BY purposes.
To make this optimization server is comparing items from
SELECT and ORDER BY lists. We were getting server crash because
comparision function for MATCH() item is not intended to be called
at this point of execution.

In 5.0 and 5.1 this problem is workarounded by resetting MATCH()
item to the state as it was during PREPARE.

In 6.0 correct comparision function will be implemented and
duplicating MATCH() items from the ORDER BY list will be
optimized.

mysql-test/r/fulltext.result:
  Updated with the test case for Bug#37740
mysql-test/t/fulltext.test:
  A test case for Bug#37740.
sql/item_func.h:
  True initialization of 'table' happens in ::fix_fields(). As
  Item_func_match::eq() may be called before ::fix_fields(), it is
  expected that 'table' is initialized to 0 when it is reused.
  
  This is mostly affecting prepared statements, when the same item
  doesn't get destroyed, but rather cleaned up and reused.
2009-07-15 15:00:58 +05:30
Alexey Kopytov
2d4df13ef2 Manual merge. 2009-07-03 14:36:04 +04:00
Alexey Kopytov
096c12b2c4 Bug #45262: Bad effects with CREATE TABLE and DECIMAL
Using DECIMAL constants with more than 65 digits in CREATE 
TABLE ... SELECT led to bogus errors in release builds or 
assertion failures in debug builds. 
 
The problem was in inconsistency in how DECIMAL constants and 
fields are handled internally. We allow arbitrarily long 
DECIMAL constants, whereas DECIMAL(M,D) columns are limited to 
M<=65 and D<=30. my_decimal_precision_to_length() was used in 
both Item and Field code and truncated precision to 
DECIMAL_MAX_PRECISION when calculating value length without 
adjusting precision and decimals. As a result, a DECIMAL 
constant with more than 65 digits ended up having length less 
than precision or decimals which led to assertion failures. 
 
Fixed by modifying my_decimal_precision_to_length() so that 
precision is truncated to DECIMAL_MAX_PRECISION only for Field 
object which is indicated by the new 'truncate' parameter. 
 
Another inconsistency fixed by this patch is how DECIMAL 
constants and expressions are handled for CREATE ... SELECT. 
create_tmp_field_from_item() (which is used for constants) was 
changed as a part of the bugfix for bug #24907 to handle long 
DECIMAL constants gracefully. Item_func::tmp_table_field() 
(which is used for expressions) on the other hand was still 
using a simplistic approach when creating a Field_new_decimal 
from a DECIMAL expression. 

mysql-test/r/type_newdecimal.result:
  Added a test case for bug #45262.
mysql-test/t/type_newdecimal.test:
  Added a test case for bug #45262.
sql/item.cc:
  Use the new 'truncate' parameter in 
  my_decimal_precision_to_length().
sql/item_cmpfunc.cc:
  Use the new 'truncate' parameter in 
  my_decimal_precision_to_length().
sql/item_func.cc:
  1. Use the new 'truncate' parameter in 
  my_decimal_precision_to_length().
  
  2. Do not truncate decimal precision to DECIMAL_MAX_PRECISION
  for additive expressions involving long DECIMAL constants.
  
  3. Fixed an incosistency in how DECIMAL constants and 
  expressions are handled for CREATE ... SELECT.
sql/item_func.h:
  Use the new 'truncate' parameter in 
  my_decimal_precision_to_length().
sql/item_sum.cc:
  Use the new 'truncate' parameter in 
  my_decimal_precision_to_length().
sql/my_decimal.h:
  Do not truncate precision to DECIMAL_MAX_PRECISION
  when calculating length in 
  my_decimal_precision_to_length() if 'truncate' parameter
  is FALSE.
sql/sql_select.cc:
  1. Use the new 'truncate' parameter in 
  my_decimal_precision_to_length().
  
  2. Use a more correct logic when adjusting value's length.
2009-07-03 11:41:19 +04:00
Gleb Shchepa
06142cd545 Bug #42778: delete order by null global variable causes
assertion .\filesort.cc, line 797

A query with the "ORDER BY @@some_system_variable" clause,
where @@some_system_variable is NULL, causes assertion
failure in the filesort procedures.

The reason of the failure is in the value of
Item_func_get_system_var::maybe_null: it was unconditionally
set to false even if the value of a variable was NULL.


mysql-test/r/variables.result:
  Added test case for bug #42778.
mysql-test/suite/sys_vars/r/innodb_data_home_dir_basic.result:
  Updated test case for bug #42778:
  system variables were NOT NULL, now they are nullable.
mysql-test/suite/sys_vars/r/innodb_flush_method_basic.result:
  Updated test case for bug #42778:
  system variables were NOT NULL, now they are nullable.
mysql-test/suite/sys_vars/r/rpl_init_slave_func.result:
  Updated test case for bug #42778:
  system variables were NOT NULL, now they are nullable.
mysql-test/suite/sys_vars/r/ssl_capath_basic.result:
  Updated test case for bug #42778:
  system variables were NOT NULL, now they are nullable.
mysql-test/suite/sys_vars/r/ssl_cipher_basic.result:
  Updated test case for bug #42778:
  system variables were NOT NULL, now they are nullable.
mysql-test/suite/sys_vars/t/innodb_data_home_dir_basic.test:
  Updated test case for bug #42778:
  system variables were NOT NULL, now they are nullable.
mysql-test/suite/sys_vars/t/innodb_flush_method_basic.test:
  Updated test case for bug #42778:
  system variables were NOT NULL, now they are nullable.
mysql-test/suite/sys_vars/t/ssl_capath_basic.test:
  Updated test case for bug #42778:
  system variables were NOT NULL, now they are nullable.
mysql-test/suite/sys_vars/t/ssl_cipher_basic.test:
  Updated test case for bug #42778:
  system variables were NOT NULL, now they are nullable.
mysql-test/t/variables.test:
  Added test case for bug #42778.
sql/item.cc:
  Bug #42778: delete order by null global variable causes
              assertion .\filesort.cc, line 797
  
  The longlong_from_string_with_check function has been modified
  to skip unwanted warnings: now it uses the THD::no_errors
  flag to suppress warnings.
  The Item_func_get_system_var::update_null_value method
  sets the no_error flag.
sql/item_func.cc:
  Bug #42778: delete order by null global variable causes
              assertion .\filesort.cc, line 797
  
  1. The Item_func_get_system_var::fix_length_and_dec method
     has been modified to make system variables truly nullable.
  
  2. The Item_func_get_system_var::update_null_value method
     method has been overloaded with a simple wrapper (like
     Item_field::update_null_value) to suppress unwanted warnings
     from Item_func_get_system_var::val_int() calls on non-numeric
     variable values: the Item_func_get_system_var::update_null_value
     method sets and restores THD::no_errors flag for a nested
     call of the longlong_from_string_with_check function.
sql/item_func.h:
  Bug #42778: delete order by null global variable causes
              assertion .\filesort.cc, line 797
  
  The Item_func_get_system_var::update_null_value method
  method has been overloaded.
2009-05-22 01:22:46 +05:00
Gleb Shchepa
405bd2af11 Bug #44768: SIGFPE crash when selecting rand from a view containing null
The RAND(N) function where the N is a field of "constant" table
(table of single row) failed with a SIGFPE.

Evaluation of RAND(N) rely on constant status of its argument.
Current server "seeded" random value for each constant argument
only once, in the Item_func_rand::fix_fields method.
Then the server skipped a call to seed_random() in the
Item_func_rand::val_real method for such constant arguments.

However, non-constant state of an argument may be changed
after the call to fix_fields, if an argument is a field of
"constant" table. Thus, pre-initialization of random value
in the fix_fields method is too early.


Initialization of random value by seed_random() has been
removed from Item_func_rand::fix_fields method.
The Item_func_rand::val_real method has been modified to
call seed_random() on the first evaluation of this method
if an argument is a function.


mysql-test/r/func_math.result:
  Added test case for bug #44768.
mysql-test/t/func_math.test:
  Added test case for bug #44768.
sql/item_func.cc:
  Bug #44768: SIGFPE crash when selecting rand from a view containing null
  
  1. Initialization of random value by seed_random() has been
     removed from Item_func_rand::fix_fields method.
  2. The Item_func_rand::val_real method has been modified to
     call seed_random() on the first evaluation of this method
     if an argument is a function.
sql/item_func.h:
  Bug #44768: SIGFPE crash when selecting rand from a view containing null
  
  1. The Item_func_rand::first_eval has been added to trace
     the first evaluation of the val_real method.
  2. The Item_func_rand::cleanup method has been added to
     cleanup the first_eval flag.
2009-05-18 09:21:25 +05:00
Ramil Kalimullin
3c08b9b1ab Manual merge. 2009-05-10 21:20:35 +05:00
Ramil Kalimullin
bd414485de Fix for bug#42009: SELECT into variable gives different results to direct SELECT
Problem: storing "SELECT ... INTO @var ..." results in variables we used val_xxx()
methods which returned results of the current row. 
So, in some cases (e.g. SELECT DISTINCT, GROUP BY or HAVING) we got data
from the first row of a new group (where we evaluate a clause) instead of
data from the last row of the previous group.

Fix: use val_xxx_result() counterparts to get proper results.


mysql-test/r/distinct.result:
  Fix for bug#42009: SELECT into variable gives different results to direct SELECT
    - results adjusted.
mysql-test/r/user_var.result:
  Fix for bug#42009: SELECT into variable gives different results to direct SELECT
    - test result.
mysql-test/t/user_var.test:
  Fix for bug#42009: SELECT into variable gives different results to direct SELECT
    - test case.
sql/item_func.cc:
  Fix for bug#42009: SELECT into variable gives different results to direct SELECT
    - Item_func_set_user_var::save_item_result() added to evaluate and store 
      an item's result into a user variable.
sql/item_func.h:
  Fix for bug#42009: SELECT into variable gives different results to direct SELECT
    - Item_func_set_user_var::save_item_result() added to evaluate and store 
      an item's result into a user variable.
sql/sql_class.cc:
  Fix for bug#42009: SELECT into variable gives different results to direct SELECT
    - use Item_func_set_user_var::save_item_result() to store results into user 
      variables.
2009-02-24 18:47:12 +04:00
Gleb Shchepa
93991b6be9 Bug#42188: crash and/or memory corruption with user variables
in trigger

Interchangeable calls to the mysql_change_user client function
and invocations of a trigger changing some user variable caused
a memory corruption and a crash.

The mysql_change_user API call forces TDH::cleanup() on a server
that frees user variable entries.
However it didn't reset Item_func_set_user_var::entry to NULL
because Item_func_set_user_var::cleanup() was not overloaded.
So, Item_func_set_user_var::entry held a pointer to freed memory,
that caused a crash.

The Item_func_set_user_var::cleanup method has been overloaded
to cleanup the Item_func_set_user_var::entry field.


mysql-test/r/user_var.result:
  Added test case for bug #42188.
mysql-test/t/user_var.test:
  Added test case for bug #42188.
sql/item_func.cc:
  Bug#42188: crash and/or memory corruption with user variables
             in trigger
  
  The Item_func_set_user_var::cleanup method has been overloaded
  to cleanup the Item_func_set_user_var::entry field.
sql/item_func.h:
  Bug#42188: crash and/or memory corruption with user variables
             in trigger
  
  The Item_func_set_user_var::cleanup method has been overloaded
  to cleanup the Item_func_set_user_var::entry field.
2009-01-23 22:18:02 +04:00
Georgi Kodinov
4d8e73c818 merged 5.0-bugteam -> 5.1-bugteam 2009-01-16 17:38:38 +02:00
Georgi Kodinov
bdec5458ae auto merge 2009-01-16 16:48:41 +02:00
Georgi Kodinov
f97ef7a40e merged 5.1-main -> 5.1-bugteam 2009-01-05 18:10:20 +02:00
Gleb Shchepa
cd42f4ba2c auto merge 5.0-bugteam --> 5.1-bugteam (bug 40761) 2008-12-12 18:19:33 +04:00
Gleb Shchepa
af5cf536bc Bug #40761: Assert on sum function on
IF(..., CAST(longtext AS UNSIGNED), signed_val)
            (was: LEFT JOIN on inline view crashes server)

Select from a LONGTEXT column wrapped with an expression
like "IF(..., CAST(longtext_column AS UNSIGNED), smth_signed)"
failed an assertion or crashed the server. IFNULL function was
affected too.

LONGTEXT column item has a maximum length of 32^2-1 bytes,
at the same time this is a maximum possible length of any
MySQL item. CAST(longtext_column AS UNSIGNED) returns some
unsigned numeric result of length 32^2-1, so the result of
IF/IFNULL function of this number and some other signed number
will have text length of (32^2-1)+1=32^2 (one byte for the
minus sign) - there is integer overflow, and the length is
equal to zero. That caused assert/crash.

CAST AS UNSIGNED function has been modified to limit maximal
length of resulting number to 67 (maximal length of DECIMAL
and two characters for minus sign and dot).


mysql-test/r/func_if.result:
  Added test case for bug #40761.
mysql-test/t/func_if.test:
  Added test case for bug #40761.
sql/item_func.h:
  Bug #40761: Assert on sum function on
              IF(..., CAST(longtext AS UNSIGNED), signed_val)
  
  CAST AS UNSIGNED function has been modified to limit maximal
  length of resulting number to 67 (maximal length of DECIMAL
  and two characters for minus sign and dot).
2008-12-12 17:16:25 +04:00
Gleb Shchepa
749847686c rollback of bug #40761 fix 2008-12-12 15:13:11 +04:00
Gleb Shchepa
5ff1bcbc2a rollback of bug #40761 fix 2008-12-12 14:59:10 +04:00
Gleb Shchepa
a4467c9798 manual merge 5.0-bugteam -> 5.1-bugteam (bug 40761) 2008-12-12 02:04:06 +04:00
Gleb Shchepa
ffe23f0eb7 Bug #40761: Assert on sum function on
IF(..., CAST(longtext AS UNSIGNED), signed_val)
            (was: LEFT JOIN on inline view crashes server)

Select from a LONGTEXT column wrapped with an expression
like "IF(..., CAST(longtext_column AS UNSIGNED), smth_signed)"
failed an assertion or crashed the server. IFNULL function was
affected too.

LONGTEXT column item has a maximum length of 32^2-1 bytes,
at the same time this is a maximum possible length of any
MySQL item. CAST(longtext_column AS UNSIGNED) returns some
unsigned numeric result of length 32^2-1, so the result of
IF/IFNULL function of this number and some other signed number
will have text length of (32^2-1)+1=32^2 (one byte for the
minus sign) - there is integer overflow, and the length is
equal to zero. That caused assert/crash.

The bug has been fixed by the same solution as in the CASE
function implementation.


mysql-test/r/func_if.result:
  Added test case for bug #40761.
mysql-test/t/func_if.test:
  Added test case for bug #40761.
sql/item_cmpfunc.cc:
  Bug #40761: Assert on sum function on
              IF(..., CAST(longtext AS UNSIGNED), signed_val)
  
  1. Item_func_case::agg_str_lengths method has been moved
     to the Item_func superclass.
  2. Item_func_ifnull/Item_func_if::fix_length_and_dec methods
     have been updated to calculate max_length, decimals and
     unsigned flag like Item_func_case.
sql/item_cmpfunc.h:
  Bug #40761: Assert on sum function on
              IF(..., CAST(longtext AS UNSIGNED), signed_val)
  
  Item_func_case::agg_str_lengths method has been moved to
  the Item_func superclass.
sql/item_func.cc:
  Bug #40761: Assert on sum function on
              IF(..., CAST(longtext AS UNSIGNED), signed_val)
  
  Item_func_case::agg_str_lengths method has been moved to
  the Item_func superclass.
sql/item_func.h:
  Bug #40761: Assert on sum function on
              IF(..., CAST(longtext AS UNSIGNED), signed_val)
  
  Item_func_case::agg_str_lengths method has been moved to
  the Item_func superclass.
2008-12-12 00:57:32 +04:00
Joerg Bruehe
2181c95918 Merge main 5.1 into 5.1-build 2008-12-10 21:14:50 +01:00
unknown
96e0bf50d9 Merge from mysql-5.1.30-release 2008-11-27 00:02:10 +01:00
Ramil Kalimullin
c3dc1d6dfb Fix for bug#40770: Server Crash when running with triggers including
variable settings (rpl_sys)

Problem: under certain conditions (e.g. user variables usage in triggers)
accessing a user defined variable we may use a variables hash table that
belongs to already deleted thread. It happens if
thd= new THD;
has the same address as just deleted thd as we use
if (stored_thd == thd)
to check.
That may lead to unpredictable results, server crash etc.

Fix: use thread_id instead of thd address to distinguish threads.

Note: no simple and repeatable test case.


sql/item_func.cc:
  Fix for bug#40770: Server Crash when running with triggers including
  variable settings (rpl_sys)
    - store and use thd->thread_id to distinguish threads instead of
  thread address as it may be the same as just deleted thread had, 
  i.e. we may get (old_thd == new_thd) after
  delete old_thd;
  new_thd= new THD;
    - set entry_thread_id only when we get a real entry, clear it 
  if the hash search fails.
sql/item_func.h:
  Fix for bug#40770: Server Crash when running with triggers including
  variable settings (rpl_sys)
    - Item_func_set_user_var::entry_thread_id introduced.
2008-11-20 15:25:26 +04:00
Build Team
e85fe79430 Added "Sun Microsystems, Inc." to copyright headers on files modified
since Oct 1st
2008-11-10 21:21:49 +01:00
Georgi Kodinov
e7a6e86f78 Bug #38637: COUNT DISTINCT prevents NULL testing in HAVING clause
IS NULL was not checking the correct row in a HAVING context.
At the first row of a new group (where the HAVING clause is evaluated)
the column and SELECT list references in the HAVING clause should 
refer to the last row of the previous group and not to the current one. 
This was not done for IS NULL, because it was using Item::is_null() doesn't
have a  Item_is_null_result() counterpart to access the data from the 
last row of the previous group. Note that all the Item::val_xxx() functions 
(e.g. Item::val_int()) have their _result counterparts (e.g. Item::val_int_result()).

Fixed by implementing a is_null_result() (similarly to int_result()) and
calling this instead of is_null() column and SELECT list references inside
the HAVING clause.

mysql-test/r/having.result:
  Bug #38637: test case
mysql-test/t/having.test:
  Bug #38637: test case
sql/item.cc:
  Bug #38637: implement Item::is_null_result() and call it
  from Item_ref and Item_field as appropriate.
sql/item.h:
  Bug #38637: implement Item::is_null_result() and call it
  from Item_ref and Item_field as appropriate.
sql/item_func.cc:
  Bug #38637: implement Item::is_null_result() and call it
  from Item_ref and Item_field as appropriate.
sql/item_func.h:
  Bug #38637: implement Item::is_null_result() and call it
  from Item_ref and Item_field as appropriate.
2008-10-17 13:55:16 +03:00
Georgi Kodinov
9f31df646f Bug #32124 addendum
Fixed the handling of system variable retrieval
in prepared statements : added a cleanup method
that clears up the cache and restores the 
original scope of the variable (which is overwritten
at fix_fields()).

sql/item_func.cc:
  ug #32124: 
   - preserve the requested variable scope
   - clean up the cache and restore the variable
     scope for prepared statements.
sql/item_func.h:
  Bug #32124: preserve the requested variable scope
2008-10-09 18:03:23 +03:00
Georgi Kodinov
6d54b0443a Bug #32124: crash if prepared statements refer to variables in the where clause
The code to get read the value of a system variable was extracting its value 
on PREPARE stage and was substituting the value (as a constant) into the parse tree.
Note that this must be a reversible transformation, i.e. it must be reversed before
each re-execution.
Unfortunately this cannot be reliably done using the current code, because there are
other non-reversible source tree transformations that can interfere with this
reversible transformation.
Fixed by not resolving the value at PREPARE, but at EXECUTE (as the rest of the 
functions operate). Added a cache of the value (so that it's constant throughout
the execution of the query). Note that the cache also caches NULL values.
Updated an obsolete related test suite (variables-big) and the code to test the 
result type of system variables (as per bug 74).

mysql-test/extra/rpl_tests/rpl_insert_id.test:
  Bug #32124: removed ambiguous testcase
mysql-test/r/innodb_data_home_dir_basic.result:
  Bug #32124: fixed wrong test case
mysql-test/r/innodb_flush_method_basic.result:
  Bug #32124: fixed wrong test case
mysql-test/r/ps_11bugs.result:
  Bug #32124: test case
mysql-test/r/ssl_capath_basic.result:
  Bug #32124: fixed wrong test case
mysql-test/r/ssl_cipher_basic.result:
  Bug #32124: fixed wrong test case
mysql-test/r/variables.result:
  Bug #32124: system vars are shown as such in EXPLAIN EXTENDED, not as constants.
mysql-test/suite/rpl/r/rpl_insert_id.result:
  Bug #32124: removed ambiguous testcase
mysql-test/t/ps_11bugs.test:
  Bug #32124: test case
sql/item.cc:
  Bug #32124: placed the code to convert string to longlong or double 
  to a function (so that it can be reused)
sql/item.h:
  Bug #32124: placed the code to convert string to longlong or double 
  to a function (so that it can be reused)
sql/item_func.cc:
  Bug #32124: moved the evaluation of system variables at runtime (val_xxx).
sql/item_func.h:
  Bug #32124: moved the evaluation of system variables at runtime (val_xxx).
sql/set_var.cc:
  Bug #32124: removed the code that calculated the system variable's value 
  at PREPARE
sql/set_var.h:
  Bug #32124: removed the code that calculated the system variable's value 
  at PREPARE
tests/mysql_client_test.c:
  Bug #32124 : removed the reading of the system variable, because its max
  length is depended on the system charset and client charset and can't be
  easily calculated.
2008-10-08 14:23:53 +03:00
Gleb Shchepa
e9cb71fc3a Bug#26020: User-Defined Variables are not consistent with
columns data types

The "SELECT @lastId, @lastId := Id FROM t" query returns
different result sets depending on the type of the Id column
(INT or BIGINT).

Note: this fix doesn't cover the case when a select query
references an user variable and stored function that
updates a value of that variable, in this case a result
is indeterminate.


The server uses incorrect assumption about a constantness of
an user variable value as a select list item: 

The server caches a last query number where that variable
was changed and compares this number with a current query
number. If these numbers are different, the server guesses,
that the variable is not updating in the current query, so
a respective select list item is a constant. However, in some
common cases the server updates cached query number too late.


The server has been modified to memorize user variable
assignments during the parse phase to take them into account
on the next (query preparation) phase independently of the
order of user variable references/assignments in a select
item list.


mysql-test/r/user_var.result:
  Added test case for bug #26020.
mysql-test/t/user_var.test:
  Added test case for bug #26020.
sql/item_func.cc:
  An update of entry and update_query_id variables has been
  moved from Item_func_set_user_var::fix_fields() to a separate
  method, Item_func_set_user_var::set_entry().
sql/item_func.h:
  1. The Item_func_set_user_var::set_entry() method has been
  added to update Item_func_set_user_var::entry.
  
  2. The Item_func_set_user_var::entry_thd field has beend
  added to update Item_func_set_user_var::entry only when
  needed.
sql/sql_base.cc:
  Fix: setup_fiedls() calls Item_func_set_user_var::set_entry()
  for all items from the thd->lex->set_var_list before the first
  call of ::fix_fields().
sql/sql_lex.cc:
  The lex_start function has been modified to reset
  the st_lex::set_var_list list.
sql/sql_lex.h:
  New st_lex::set_var_list field has been added to
  memorize all user variable assignments in the current
  select query.
sql/sql_yacc.yy:
  The variable_aux rule has been modified to memorize
  in-query user variable assignments in the
  st_lex::set_var_list list.
2008-09-18 13:38:44 +05:00
unknown
03c110ea21 Merge stella.local:/home2/mydev/mysql-5.1-amain
into  stella.local:/home2/mydev/mysql-5.1-axmrg


mysql-test/r/ctype_big5.result:
  Auto merged
mysql-test/r/ctype_euckr.result:
  Auto merged
mysql-test/r/ctype_gb2312.result:
  Auto merged
mysql-test/r/ctype_gbk.result:
  Auto merged
mysql-test/r/ctype_uca.result:
  Auto merged
mysql-test/r/ctype_ucs.result:
  Auto merged
mysql-test/suite/binlog/r/binlog_row_ctype_cp932.result:
  Auto merged
mysql-test/suite/binlog/r/binlog_stm_ctype_cp932.result:
  Auto merged
mysql-test/t/ctype_ucs.test:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/log.cc:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/rpl_rli.cc:
  Auto merged
sql/slave.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/lib/mtr_report.pl:
  SCCS merged
2008-03-26 10:27:00 +01:00
unknown
774d21cf3b Merge dl145h.mysql.com:/data0/mkindahl/mysql-5.1
into  dl145h.mysql.com:/data0/mkindahl/mysql-5.1-rpl


mysql-test/include/commit.inc:
  Auto merged
mysql-test/lib/mtr_report.pl:
  Auto merged
mysql-test/r/commit_1innodb.result:
  Auto merged
mysql-test/r/variables.result:
  Auto merged
mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result:
  Auto merged
mysql-test/t/variables.test:
  Auto merged
sql/handler.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/log.cc:
  Auto merged
sql/rpl_rli.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2008-03-14 18:32:01 +01:00
unknown
e79249f81b Manual merge
configure.in:
  Auto merged
mysql-test/r/func_misc.result:
  Auto merged
mysql-test/r/myisam.result:
  Auto merged
mysql-test/r/partition.result:
  Auto merged
mysql-test/r/partition_symlink.result:
  Auto merged
mysql-test/t/func_misc.test:
  Auto merged
mysql-test/t/partition.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/field.h:
  Auto merged
sql/item.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/log.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/partition_info.cc:
  Auto merged
sql/partition_info.h:
  Auto merged
sql/rpl_rli.cc:
  Auto merged
sql/sql_plugin.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_parse.cc:
  Manual merge. Needs later fix. New code in create table was not
  accepted. Needs to be added to mysql_create_table_no_lock().
2008-03-14 12:02:11 +01:00
unknown
d6df18dd33 Merge kaamos.(none):/data/src/mysql-5.1
into  kaamos.(none):/data/src/opt/mysql-5.1-opt


client/mysql.cc:
  Auto merged
client/mysqldump.c:
  Auto merged
configure.in:
  Auto merged
include/my_global.h:
  Auto merged
libmysql/libmysql.c:
  Auto merged
libmysqld/lib_sql.cc:
  Auto merged
mysql-test/include/mix1.inc:
  Auto merged
mysql-test/r/create.result:
  Auto merged
mysql-test/r/func_str.result:
  Auto merged
mysql-test/r/innodb.result:
  Auto merged
mysql-test/r/innodb_mysql.result:
  Auto merged
mysql-test/r/select.result:
  Auto merged
mysql-test/r/subselect.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
mysql-test/t/disabled.def:
  Auto merged
sql/filesort.cc:
  Auto merged
sql/handler.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/item_sum.cc:
  Auto merged
sql/log.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_plugin.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
storage/ndb/src/kernel/blocks/backup/Backup.hpp:
  Auto merged
tests/mysql_client_test.c:
  Auto merged
mysql-test/r/func_time.result:
  Manual merge.
mysql-test/r/view.result:
  Manual merge.
mysql-test/t/view.test:
  Manual merge.
scripts/mysql_config.sh:
  Manual merge.
sql-common/client.c:
  Manual merge.
sql/sql_parse.cc:
  Manual merge.
2008-03-12 11:19:46 +03:00
unknown
ccf7f74e52 Merge tnurnberg@bk-internal.mysql.com:/home/bk/mysql-5.1-opt
into  mysql.com:/misc/mysql/34749/51-34749


mysql-test/r/func_misc.result:
  Auto merged
mysql-test/t/func_misc.test:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/item_func.h:
  Auto merged
2008-03-10 07:39:04 +01:00
unknown
111de516ab Merge mysql.com:/misc/mysql/34749/50-34749
into  mysql.com:/misc/mysql/34749/51-34749


mysql-test/r/func_misc.result:
  Auto merged
mysql-test/t/func_misc.test:
  Auto merged
sql/ha_ndbcluster_cond.cc:
  Auto merged
sql/ha_ndbcluster_cond.h:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/item_func.h:
  Auto merged
2008-03-10 07:07:56 +01:00
unknown
7b5da0aa77 Merge pcg5ppc.xiphis.org:/Network/Servers/anubis.xiphis.org/home/antony/work/mysql-5.1-engines
into  pcg5ppc.xiphis.org:/Network/Servers/anubis.xiphis.org/home/antony/work/merge.20080307/mysql-5.1


configure.in:
  Auto merged
include/mysql/plugin.h:
  Auto merged
mysql-test/r/information_schema.result:
  Auto merged
mysql-test/r/partition_innodb.result:
  Auto merged
mysql-test/t/information_schema.test:
  Auto merged
mysql-test/t/partition_innodb.test:
  Auto merged
sql/item.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/log.cc:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/repl_failsafe.cc:
  Auto merged
sql/slave.cc:
  Auto merged
sql/slave.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_partition.cc:
  Auto merged
sql/sql_plugin.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
storage/myisam/mi_dynrec.c:
  Auto merged
2008-03-07 13:46:29 -08:00
unknown
875ad6d8b8 BUG#31168: @@hostname does not replicate
Problem: in mixed and statement mode, a query that refers to a
system variable will use the slave's value when replayed on
slave. So if the value of a system variable is inserted into a
table, the slave will differ from the master.
Fix: mark statements that refer to a system variable as "unsafe",
meaning they will be replicated by row in mixed mode and produce a warning
in statement mode. There are some exceptions: some variables are actually
replicated. Those should *not* be marked as unsafe.
BUG#34732: mysqlbinlog does not print default values for auto_increment variables
Problem: mysqlbinlog does not print default values for some variables,
including auto_increment_increment and others. So if a client executing
the output of mysqlbinlog has different default values, replication will
be wrong.
Fix: Always print default values for all variables that are replicated.
I need to fix the two bugs at the same time, because the test cases would
fail if I only fixed one of them.


include/m_ctype.h:
  Added definition of ILLEGAL_CHARSET_INFO_NUMBER. We just need a symbol
  for a number that will never be used by any charset. ~0U should be safe
  since charset numbers are sequential, starting from 0.
mysql-test/include/commit.inc:
  Upated test to avoid making statements unsafe.
mysql-test/r/commit_1innodb.result:
  Updated test needs updated result file.
mysql-test/r/mysqlbinlog.result:
  Updated result file.
mysql-test/r/mysqlbinlog2.result:
  Updated result file.
mysql-test/r/user_var-binlog.result:
  Updated result file.
mysql-test/suite/binlog/r/binlog_base64_flag.result:
  Updated result file.
mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result:
  Updated result file.
mysql-test/suite/binlog/r/binlog_unsafe.result:
  Modified test file needs modified result file.
mysql-test/suite/binlog/t/binlog_base64_flag.test:
  Need to filter out pseudo_thread_id from result since it is
  nondeterministic.
mysql-test/suite/binlog/t/binlog_unsafe.test:
  Add tests that using variables is unsafe. The 'CREATE VIEW' tests didn't
  make sense, so I removed them. SHOW WARNINGS is not necessary either,
  because we get warnings for each statement in the result file.
mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result:
  Updated result file.
mysql-test/suite/rpl/r/rpl_skip_error.result:
  Updated result file.
mysql-test/suite/rpl/t/rpl_skip_error.test:
  The test used @@server_id, which is not safe to replicate, so it would
  have given a warning. The way it used @@server_id was hackish (issue a
  query on master that removes rows only on master), so I replaced it by a
  more robust way to do the same thing (connect to slave and insert the
  rows only there).
  Also clarified what the test case does.
mysql-test/t/mysqlbinlog2.test:
  Use --short-form instead of manually filtering out nondeterministic stuff
  from mysqlbinlog (because we added the nondeterministic @@pseudo_thread_id
  to the output).
sql/item_func.cc:
  Added method of Item_func_get_system_var that indicates whether the given
  system variable will be written to the binlog or not.
sql/item_func.h:
  Added method of Item_func_get_system_var that indicates whether the given
  system variable will be written to the binlog or not.
sql/log_event.cc:
   - auto_increment_offset was not written to the binlog if
  auto_increment_increment=1
   - mysqlbinlog did not output default values for some variables
  (BUG#34732). In st_print_event_info, we remember for each variable whether
  it has been printed or not. This is achieved in different ways for
  different variables:
      - For auto_increment_*, lc_time_names, charset_database_number,
        we set the default values in st_print_event_info to something
        illegal, so that it will look like they have changed the first time
        they are seen.
      - For charset, sql_mode, pseudo_thread_id, we add a flag to
        st_print_event_info which indicates whether the variable has been
        printed.
      - Since pseudo_thread_id is now printed more often, and its value is
        not guaranteed to be constant across different runs of the same
        test script, I replaced it by a constant if --short-form is used.
   - Moved st_print_event_info constructor from log_event.h to log_event.cc,
  since it now depends on ILLEGAL_CHARSET_NUMBER, which is defined in
  m_ctype.h, which is better to include from a .cc file than from a header
  file.
sql/log_event.h:
  Added fields to st_print_event_info that indicate whether some of the
  variables have been written or not. Since the initialization of
  charset_database_number now depends on ILLEGAL_CHARSET_INFO_NUMBER, which
  is defined in a header file, which we'd better not include from this
  header file -- I moved the constructor from here to log_event.cc.
sql/set_var.cc:
  System variables now have a flag binlog_status, which indicates if they
  are written to the binlog. If nothing is specified, all variables are
  marked as not written to the binlog (NOT_IN_BINLOG) when created. In this
  file, the variables that are written to the binlog are marked with
  SESSION_VARIABLE_IN_BINLOG.
sql/set_var.h:
  Added flag binlog_status to class sys_var. Added a getter and a
  constructor parameter that sets it.
  Since I had to change sys_var_thd_enum constructor anyways, I simplified
  it to use default values of arguments instead of three copies of the
  constructor.
sql/sql_yacc.yy:
  Mark statements that refer to a system variable as "unsafe",
  meaning they will be replicated by row in mixed mode. Added comment to
  explain strange piece of code just above.
mysql-test/include/diff_tables.inc:
  New auxiliary test file that tests whether two tables (possibly one on
  master and one on slave) differ.
mysql-test/suite/rpl/r/rpl_variables.result:
  New test case needs new result file.
mysql-test/suite/rpl/r/rpl_variables_stm.result:
  New test file needs new result file.
mysql-test/suite/rpl/t/rpl_variables.test:
  Test that INSERT of @@variables is replicated correctly (by switching to
  row-based mode).
mysql-test/suite/rpl/t/rpl_variables_stm.test:
  Test that replication of @@variables which are replicated explicitly works
  as expected in statement mode (without giving warnings).
2008-03-07 13:59:36 +01:00
unknown
a0eec8abbb Bug#34749: Server crash when using NAME_CONST() with an aggregate function
NAME_CONST('whatever', -1) * MAX(whatever) bombed since -1 was
not seen as constant, but as FUNCTION_UNARY_MINUS(constant)
while we are at the same time pretending it was a basic const
item. This confused the aggregate handlers in exciting ways.
We now make NAME_CONST() behave more consistently.


mysql-test/r/func_misc.result:
  show that a combination of NAME_CONST('x', -y) and an aggregate
  no longer crashes the server.
mysql-test/t/func_misc.test:
  show that a combination of NAME_CONST('x', -y) and an aggregate
  no longer crashes the server.
sql/ha_ndbcluster_cond.cc:
  tell cluster about "new" function type NEG_FUNC.
  (this was previous identified as UNKNOWN_FUNC,
  so we just handle it the same way, that's all.)
sql/ha_ndbcluster_cond.h:
  tell cluster about "new" function type NEG_FUNC.
  (this was previous identified as UNKNOWN_FUNC,
  so we just handle it the same way, that's all.)
sql/item.cc:
  make NAME_CONST() transparent in that type() of
  -constant is that of constant, not that of unary
  minus (id est, FUNC_ITEM).
sql/item.h:
  Move constructor to item.cc
sql/item_func.h:
  Revert Bug#30832; we can apply the magic more narrowly
  (just for NAME_CONST() rather than all Item_func_neg).
  
  Introduce new function type "NEG_FUNC."
2008-02-28 14:23:22 +01:00
unknown
a3e83048a3 Fix for Bug#30217: Views: changes in metadata behaviour
between 5.0 and 5.1.
  
The problem was that in the patch for Bug#11986 it was decided
to store original query in UTF8 encoding for the INFORMATION_SCHEMA.
This approach however turned out to be quite difficult to implement
properly. The main problem is to preserve the same IS-output after
dump/restore.
  
So, the fix is to rollback to the previous functionality, but also
to fix it to support multi-character-set-queries properly. The idea
is to generate INFORMATION_SCHEMA-query from the item-tree after
parsing view declaration. The IS-query should:
  - be completely in UTF8;
  - not contain character set introducers.
  
For more information, see WL4052.


mysql-test/include/ddl_i18n.check_views.inc:
  Add a test case for Bug#30217.
mysql-test/r/ddl_i18n_koi8r.result:
  Update result file.
mysql-test/r/ddl_i18n_utf8.result:
  Update result file.
mysql-test/r/information_schema.result:
  Update result file.
mysql-test/r/information_schema_db.result:
  Update result file.
mysql-test/r/mysqldump.result:
  Update result file.
mysql-test/r/show_check.result:
  Update result file.
mysql-test/t/ddl_i18n_koi8r.test:
  Add a test case for Bug#30217.
mysql-test/t/ddl_i18n_utf8.test:
  Add a test case for Bug#30217.
mysql-test/t/mysqldump.test:
  Add a test case for Bug#30217.
sql/ha_ndbcluster.cc:
  Add a parameter to print().
sql/item.cc:
  1. Add a parameter to print().
  2. Item_string::print():
        - Do not append character set introducer to the text literal
          if we're building a query for INFORMATION_SCHEMA;
        - Convert text literal to UTF8 if we're building a query
          for INFORMATION_SCHEMA.
sql/item.h:
  Add a parameter to print().
sql/item_cmpfunc.cc:
  Add a parameter to print().
sql/item_cmpfunc.h:
  Add a parameter to print().
sql/item_func.cc:
  Add a parameter to print().
sql/item_func.h:
  Add a parameter to print().
sql/item_geofunc.h:
  Add a parameter to print().
sql/item_row.cc:
  Add a parameter to print().
sql/item_row.h:
  Add a parameter to print().
sql/item_strfunc.cc:
  Add a parameter to print().
sql/item_strfunc.h:
  Add a parameter to print().
sql/item_subselect.cc:
  Add a parameter to print().
sql/item_subselect.h:
  Add a parameter to print().
sql/item_sum.cc:
  Add a parameter to print().
sql/item_sum.h:
  Add a parameter to print().
sql/item_timefunc.cc:
  Add a parameter to print().
sql/item_timefunc.h:
  Add a parameter to print().
sql/mysql_priv.h:
  Add a parameter to print().
sql/sp_head.cc:
  Add a parameter to print().
sql/sql_lex.cc:
  Add a parameter to print().
sql/sql_lex.h:
  Add a parameter to print().
sql/sql_parse.cc:
  Add a parameter to print().
sql/sql_select.cc:
  Add a parameter to print().
sql/sql_show.cc:
  Add a parameter to print().
sql/sql_test.cc:
  Add a parameter to print().
sql/sql_view.cc:
  Build INFORMATION_SCHEMA query from Item-tree.
sql/sql_yacc.yy:
  Build INFORMATION_SCHEMA query from Item-tree.
sql/table.h:
  Add a parameter to print().
2008-02-22 13:30:33 +03:00
unknown
61c31af45d Fix for bug #31236: Inconsistent division by zero behavior for
floating point numbers

Some math functions did not check if the result is a valid number
(i.e. neither of +-inf or nan).

Fixed by validating the result where necessary and returning NULL in
case of invalid result.


BitKeeper/deleted/.del-matherr.c:
  Rename: sql/matherr.c -> BitKeeper/deleted/.del-matherr.c
configure.in:
  Removed DONT_USE_FINITE, it is not used anywhere.
include/my_global.h:
  isfinite() is a C99 macro which absoletes finite(). First try to use
  it, then fall back to finite() if the target platform has it,
  otherwise use our own implementation.
mysql-test/r/func_math.result:
  Added a test case for bug #31236.
mysql-test/r/strict.result:
  Fixed a test case which relied on old behavior.
mysql-test/t/func_math.test:
  Added a test case for bug #31236.
mysql-test/t/strict.test:
  Fixed a test case which relied on old behavior.
sql/field.cc:
  No need to check if the finite() or its equivalent is available.
sql/item_func.cc:
  Use fix_result() wherever the result can be one of +-inf or nan, 
  assuming the function arguments are valid numbers.
  Removed fix_result() from functions that are defined for all possible
  input numbers.
sql/item_func.h:
  Moved fix_result() from Item_dec_func to Item_func which is a common
  ancestor for Item_dec_func and Item_num_op.
sql/unireg.h:
  Removed POSTFIX_ERROR because no code returns it.
2008-02-20 00:33:43 +03:00
unknown
bb091abb14 BUG#33182: Disallow division due to div_precision_increment problems
mysql-test/r/partition.result:
  New test case to validate that '/' is no longer allowed,
  only integer division is allowed
mysql-test/t/partition.test:
  New test case to validate that '/' is no longer allowed,
  only integer division is allowed
sql/item_func.h:
  +,-,*, mod is allowed
  / is disallowed
2008-01-28 22:05:25 +01:00
unknown
9a10c20ba9 Merge mysql.com:/home/gluh/MySQL/Merge/5.1
into  mysql.com:/home/gluh/MySQL/Merge/5.1-opt


BitKeeper/etc/ignore:
  auto-union
client/mysql.cc:
  Auto merged
client/mysqltest.c:
  Auto merged
include/mysql_com.h:
  Auto merged
libmysql/CMakeLists.txt:
  Auto merged
libmysqld/lib_sql.cc:
  Auto merged
mysql-test/r/archive.result:
  Auto merged
mysql-test/r/create.result:
  Auto merged
mysql-test/r/delayed.result:
  Auto merged
mysql-test/r/func_misc.result:
  Auto merged
mysql-test/r/innodb.result:
  Auto merged
mysql-test/r/innodb_mysql.result:
  Auto merged
mysql-test/r/merge.result:
  Auto merged
mysql-test/r/ps.result:
  Auto merged
mysql-test/r/type_date.result:
  Auto merged
mysql-test/suite/rpl/r/rpl_innodb_bug28430.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
mysql-test/t/func_misc.test:
  Auto merged
mysql-test/t/information_schema.test:
  Auto merged
mysql-test/t/merge.test:
  Auto merged
mysql-test/t/subselect.test:
  Auto merged
mysql-test/t/type_date.test:
  Auto merged
mysql-test/t/type_datetime.test:
  Auto merged
mysql-test/t/variables.test:
  Auto merged
mysys/queues.c:
  Auto merged
sql/events.cc:
  Auto merged
sql/field.cc:
  Auto merged
sql/field.h:
  Auto merged
sql/ha_partition.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/item.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/protocol.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/slave.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_db.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_partition.cc:
  Auto merged
sql/sql_plugin.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_string.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/table.cc:
  Auto merged
sql/table.h:
  Auto merged
storage/myisam/ha_myisam.cc:
  Auto merged
storage/myisam/mi_check.c:
  Auto merged
storage/myisam/mi_open.c:
  Auto merged
tests/mysql_client_test.c:
  Auto merged
mysql-test/lib/mtr_report.pl:
  manual merge
mysql-test/r/myisam.result:
  manual merge
mysql-test/r/partition.result:
  manual merge
mysql-test/r/user_var.result:
  manual merge
mysql-test/t/myisam.test:
  manual merge
mysql-test/t/partition.test:
  manual merge
mysql-test/t/user_var.test:
  manual merge
sql/item.h:
  manual merge
sql/item_func.cc:
  manual merge
storage/myisammrg/ha_myisammrg.cc:
  manual merge
2007-12-13 15:56:04 +04:00
unknown
33f82b1789 Merge mysql.com:/home/gluh/MySQL/Merge/5.0
into  mysql.com:/home/gluh/MySQL/Merge/5.0-opt


client/mysql.cc:
  Auto merged
client/mysqltest.c:
  Auto merged
include/mysql_com.h:
  Auto merged
libmysql/CMakeLists.txt:
  Auto merged
myisam/mi_check.c:
  Auto merged
mysql-test/r/delayed.result:
  Auto merged
mysql-test/r/innodb.result:
  Auto merged
mysql-test/r/myisam.result:
  Auto merged
mysql-test/r/ps.result:
  Auto merged
mysql-test/t/merge.test:
  Auto merged
mysql-test/t/myisam.test:
  Auto merged
mysql-test/t/subselect.test:
  Auto merged
mysql-test/t/type_datetime.test:
  Auto merged
mysql-test/t/variables.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/ha_myisam.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/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/r/func_misc.result:
  manual merge
mysql-test/r/innodb_mysql.result:
  manual merge
mysql-test/t/func_misc.test:
  manual merge
mysql-test/t/innodb_mysql.test:
  manual merge
sql/sql_insert.cc:
  manual merge
2007-12-13 14:52:49 +04:00
unknown
9d503cea20 Merge magare.gmz:/home/kgeorge/mysql/work/B30355-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/work/B30355-5.1-opt


include/mysql_com.h:
  Auto merged
mysql-test/r/udf.result:
  Auto merged
mysql-test/t/udf.test:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/udf_example.c:
  Auto merged
2007-11-27 17:19:51 +02:00
unknown
63b6516953 Bug #30355: Incorrect ordering of UDF results
There's currently no way of knowing the determinicity of an UDF.
And the optimizer and the sequence() UDFs were making wrong
assumptions about what the is_const member means.
Plus there was no implementation of update_system_tables()
causing the optimizer to overwrite the information returned by
the <udf>_init function.

Fixed by equating the assumptions about the semantics of 
is_const and providing a implementation of update_used_tables().
Added a TODO item for the UDF API change needed to make a better 
implementation.


include/mysql_com.h:
  Bug #30355: comment added
mysql-test/r/udf.result:
  Bug #30355: test case
mysql-test/t/udf.test:
  Bug #30355: test case
sql/item_func.cc:
  Bug #30355: keep const_item_cache and used_tables_cache in sync
sql/item_func.h:
  Bug #30355: 
   - a better implementation of update_used_tables()
   - keep const_item_cache and used_tables_cache in sync
sql/udf_example.c:
  Bug #30355: Wrong value for const_item fixed.
2007-11-27 17:16:52 +02:00
unknown
6cc8a820d3 Merge mysql.com:/home/ram/work/b32558/b32558.5.0
into  mysql.com:/home/ram/work/b32558/b32558.5.1


mysql-test/r/olap.result:
  Auto merged
sql/item_func.h:
  Auto merged
2007-11-23 12:35:02 +04:00