Commit graph

11178 commits

Author SHA1 Message Date
unknown
55499d2bf4 Fix for bug #32202: ORDER BY not working with GROUP BY
The bug is a regression introduced by the fix for bug30596. The problem
was that in cases when groups in GROUP BY correspond to only one row,
and there is ORDER BY, the GROUP BY was removed and the ORDER BY
rewritten to ORDER BY <group_by_columns> without checking if the
columns in GROUP BY and ORDER BY are compatible. This led to
incorrect ordering of the result set as it was sorted using the
GROUP BY columns. Additionaly, the code discarded ASC/DESC modifiers
from ORDER BY even if its columns were compatible with the GROUP BY
ones.

This patch fixes the regression by checking if ORDER BY columns form a
prefix of the GROUP BY ones, and rewriting ORDER BY only in that case,
preserving the ASC/DESC modifiers. That check is sufficient, since the
GROUP BY columns contain a unique index.


mysql-test/r/group_by.result:
  Added a test case for bug #32202.
mysql-test/t/group_by.test:
  Added a test case for bug #32202.
sql/sql_select.cc:
  In cases when groups in GROUP BY correspond to only one row and there
  is ORDER BY, rewrite the query to ORDER BY <group_by_columns> only if
  the columns in ORDER BY and GROUP BY are compatible, i.e. either one
  forms a prefix for another.
2007-11-09 19:12:12 +03:00
unknown
4713575c77 Merge polly.(none):/home/kaa/src/opt/bug32103/my41-bug26215
into  polly.(none):/home/kaa/src/opt/bug32103/my50-bug26215


mysql-test/t/select.test:
  Auto merged
mysql-test/r/select.result:
  Manual merge.
sql/item.h:
  Manual merge.
2007-11-08 11:46:58 +03:00
unknown
0a7a55d175 Fix for bug #32103: optimizer crash when join on int and mediumint with
variable in where clause.

Problem: the new_item() method of Item_uint used an incorrect
constructor. "new Item_uint(name, max_length)" calls
Item_uint::Item_uint(const char *str_arg, uint length) which assumes the
first argument to be the string representation of the value, not the
item's name. This could result in either a server crash or incorrect
results depending on usage scenarios.

Fixed by using the correct constructor in new_item():
Item_uint::Item_uint(const char *str_arg, longlong i, uint length).


mysql-test/r/select.result:
  Added a test case for bug #32103.
mysql-test/t/select.test:
  Added a test case for bug #32103.
sql/item.h:
  Use the correct constructor for Item_uint in Item_uint::new_item().
2007-11-07 18:45:04 +03:00
unknown
1daa54d697 Fix for:
bug #26215: mysql command line client should not strip comments
              from SQL statements
and
  bug #11230: Keeping comments when storing stored procedures

With the introduction of multiline comments support in the command line
client (mysql) in MySQL 4.1, it became impossible to preserve
client-side comments within single SQL statements or stored routines.
This feature was useful for monitoring tools and maintenance.

The patch adds a new option to the command line client
('--enable-comments', '-c') which allows to preserve SQL comments and
send them to the server for single SQL statements, and to keep comments
in the code for stored procedures / functions / triggers.

The patch is a modification of the contributed patch from bug #11230
with the following changes:
- code style changes to conform to the coding guidelines
- changed is_prefix() to my_strnncoll() to detect the DELIMITER
command, since the first one is case-sensitive and not charset-aware
- renamed t/comments-51.* to t/mysql_comments.*
- removed tests for comments in triggers since 5.0 does not have SHOW
CREATE TRIGGER (those tests will be added back in 5.1).

The test cases are only for bug #11230. No automated test case for bug
#26215 is possible due to the test suite deficiencies (though the cases
from the bug report were tested manually).


client/mysql.cc:
  Applied the contributed patch from bug11230 with the following changes:
  - code style changes to conform to the coding guidelines
  - changed is_prefix() to my_strnncoll() to detect the DELIMITER
  command, since the first one is case-sensitive and not charset-aware
  
  The patch adds a new option to the command line client which allows to
  preserve SQL comments and send them to the server to ensure better
  error reporting and to, keep comments in the code for stored procedures
  / functions / triggers.
mysql-test/r/mysql_comments.result:
  Added test cases for bug11230.
mysql-test/t/mysql_comments.sql:
  Added test cases for bug11230.
mysql-test/t/mysql_comments.test:
  Added test cases for bug11230.
2007-11-02 13:40:34 +03:00
unknown
04311fabaa Bug #28550 "Potential bugs related to the return type of the CHAR function".
Since, as of MySQL 5.0.15, CHAR() arguments larger than 255 are converted into multiple result bytes, a single CHAR() argument can now take up to 4 bytes. This patch fixes Item_func_char::fix_length_and_dec() to take this into account.
  
This patch also fixes a regression introduced by the patch for bug21513. As now we do not always have the 'name' member of Item set for Item_hex_string and Item_bin_string, an own print() method has been added to Item_hex_string so that it could correctly be printed by Item_func::print_args().


mysql-test/r/func_str.result:
  Import patch bug288550.patch
mysql-test/t/func_str.test:
  Import patch bug288550.patch
sql/item.cc:
  Import patch bug288550.patch
sql/item.h:
  Import patch bug288550.patch
sql/item_strfunc.h:
  Import patch bug288550.patch
2007-10-21 21:45:31 +04:00
unknown
55a3a64eb1 Merge sgluhov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  mysql.com:/home/gluh/MySQL/Merge/5.0-opt


sql/item.cc:
  Auto merged
sql/item.h:
  manual merge
2007-10-16 13:19:01 +05:00
unknown
048006e2f9 Bug#30986 Character set introducer followed by a HEX string can return bad result(addon)
issue an error if string has illegal characters


mysql-test/r/ctype_utf8.result:
  issue an error if string has illegal characters
mysql-test/t/ctype_utf8.test:
  issue an error if string has illegal characters
sql/item.cc:
  issue an error if string has illegal characters
sql/item.h:
  issue an error if string has illegal characters
sql/sql_yacc.yy:
  issue an error if string has illegal characters
2007-10-15 18:40:58 +05:00
unknown
9bb3c7ebdd Merge gleb.loc:/home/uchum/work/bk/PA/5.0-opt-31019
into  gleb.loc:/home/uchum/work/bk/5.0-opt
2007-10-15 13:34:58 +05:00
unknown
c9141ac580 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/autopush/B31156-5.0-opt
2007-10-13 09:20:23 +03:00
unknown
387d03f574 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/autopush/B31440-5.0-opt


sql/item_cmpfunc.cc:
  Auto merged
2007-10-13 09:12:15 +03:00
unknown
9380fdb1c6 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/autopush/B31440-5.0-opt
2007-10-12 14:11:27 +03:00
unknown
1fc06a1f46 Merge gleb.loc:/home/uchum/work/bk/PA/5.0-opt-31471
into  gleb.loc:/home/uchum/work/bk/5.0-opt
2007-10-11 22:42:11 +05:00
unknown
f30eacb223 Bug#30981 CHAR(0x41 USING ucs2) doesn't add leading zero
Bug#30982 CHAR(..USING..) can return a not-well-formed string
Bug#30986 Character set introducer followed by a HEX string can return bad result
check_well_formed_result moved to Item from Item_str_func
fixed Item_func_char::val_str for proper ucs symbols converting
added check for well formed strings for correct conversion of constants with underscore
charset


mysql-test/r/ctype_ucs.result:
  test result
mysql-test/r/ctype_utf8.result:
  test result
mysql-test/t/ctype_ucs.test:
  test case
mysql-test/t/ctype_utf8.test:
  test case
sql/item.cc:
  check_well_formed_result() moved from Item_str_func
sql/item.h:
  check_well_formed_result() moved from Item_str_func
sql/item_strfunc.cc:
  check_well_formed_result moved to Item
  fixed Item_func_char::val_str for proper ucs symbols converting
sql/item_strfunc.h:
  check_well_formed_result moved to Item
sql/sql_yacc.yy:
  added check for well formed string
2007-10-11 16:07:10 +05:00
unknown
76af571717 Bug #31440: 'select 1 regex null' asserts debug server
The special case with NULL as a regular expression
was handled at prepare time. But in this special case
the item was not marked as fixed. This caused an assertion
at execution time.
Fixed my marking the item as fixed even when known to 
return NULL at prepare time.


mysql-test/r/func_regexp.result:
  Bug #31440: test case
mysql-test/t/func_regexp.test:
  Bug #31440: test case
sql/item_cmpfunc.cc:
  Bug #31440: mark the item as fixed even when 
  known to return NULL.
2007-10-11 11:29:26 +03:00
unknown
c866f8015f Fixed bug #31471: decimal_bin_size: Assertion `scale >= 0 &&
precision > 0 && scale <= precision'.

A sign of a resulting item of the IFNULL function was not
updated and the maximal length of this result was calculated
improperly. Correct algorithm was copy&pasted from the IF
function implementation.


sql/item_cmpfunc.cc:
  Fixed bug #31471.
  The Item_func_ifnull::fix_length_and_dec method has been
  modified to update the Item_func_ifnull::unsigned_flag field
  and to take this field into account when calculating the
  Item_func_ifnull::max_length value.
  (See Item_func_if::fix_length_and_dec for reference).
mysql-test/t/null.test:
  Added test case for bug #31471.
mysql-test/r/null.result:
  Added test case for bug #31471.
mysql-test/r/create.result:
  Update test case after the bugfix of bug #31471.
2007-10-10 20:14:29 +05:00
unknown
62f72d3610 Bug#28893 --relay-log variable is not exposed with SHOW VARIABLES
added variables relay_log, relay_log_index, relay_log_info_file to init_vars[]
to make them visible within SHOW VARIABLES


mysql-test/r/rpl_flush_log_loop.result:
  test result
mysql-test/t/rpl_flush_log_loop.test:
  test case
sql/set_var.cc:
  added variables relay_log, relay_log_index, relay_log_info_file to init_vars[]
  to make them visible within SHOW VARIABLES
2007-10-10 12:21:11 +05:00
unknown
15453e3a6a Bug#25359 Test 'view' is dependent on current year to be 2006
removed now() call to make the test to be year independent


mysql-test/r/view.result:
  result fix
mysql-test/t/view.test:
  removed now() call to make the test to be year independent
2007-10-10 12:16:13 +05:00
unknown
69ecde861a Merge bk-internal:/home/bk/mysql-5.0-opt
into  dl145s.mysql.com:/data0/mhansson/bug31160/my50-bug31160


sql/item_timefunc.h:
  Auto merged
2007-10-09 15:25:27 +02:00
unknown
addc2f4720 Merge martin@mhansson.mysql.internal:/home/martin/mysql/src/bug31160/my50-bug31160
into  dl145s.mysql.com:/data0/mhansson/bug31160/my50-bug31160
2007-10-09 15:23:16 +02:00
unknown
ae4141ed75 Bug#31160: MAKETIME() crashes server when returning NULL in ORDER BY using filesort
Even though it returns NULL, the MAKETIME function did not have this property set,
causing a failed assertion (designed to catch exactly this).
Fixed by setting the nullability property of MAKETIME().


mysql-test/r/func_sapdb.result:
  Bug#31160: Changed test result.
mysql-test/r/func_time.result:
  Bug#31160: Test result.
mysql-test/t/func_time.test:
  Bug#31160: Test case.
sql/item_timefunc.h:
  Bug#31160: The fix: Initializing maybe_null to true
2007-10-09 14:58:09 +02:00
unknown
f2d6508fb7 Merge mhansson@bk-internal:/home/bk/mysql-5.0-opt
into  linux-st28.site:/home/martin/mysql/src/bug30832-again-push/my50-bug30832-again
2007-10-09 12:04:50 +02:00
unknown
a462f34a94 Bug#30832:Assertion + crash with select name_const('test',now());
Completion of previous patch. Negative number were denied
as the second argument to NAME_CONST.


mysql-test/r/func_misc.result:
  Bug#30832 completion: test result
mysql-test/t/func_misc.test:
  Bug#30832 completion: test case
  added negative numbers
sql/item_func.h:
  Bug#30832 completion
  The function that represents unary minus is considered a constant if the argument is.
2007-10-09 11:36:05 +02:00
unknown
6736d404a0 Bug #31156: mysqld: item_sum.cc:918: virtual bool
Item_sum_distinct::setup(THD*): Assertion

There was an assertion to detect a bug in ROLLUP
implementation. However the assertion is not true
when used in a subquery context with non-cacheable
statements.
Fixed by turning the assertion to accepted case
(just like it's done for the other aggregate functions). 


mysql-test/r/func_group.result:
  Bug #31156: test case
mysql-test/t/func_group.test:
  Bug #31156: test case
sql/item_sum.cc:
  Bug #31156: make it OK to call setup() several times:
   done for (e.g.) scalar subquery
2007-10-08 12:57:43 +03:00
unknown
60761a7cc6 Fixed bug #31019: the MOD() function and the % operator crash the server
when a divisor is less than 1 and its fractional part is very long.
For example:
1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789;

Stack buffer overflow has been fixed in the do_div_mod function.


strings/decimal.c:
  Fixed bug #31019.
  Stack buffer overflow has been fixed in the do_div_mod function:
  a value of the upper bound of the buffer was increased where
  a decrement is required.
mysql-test/t/type_decimal.test:
  Added test case for bug #31019.
mysql-test/r/type_decimal.result:
  Added test case for bug #31019.
2007-10-08 03:48:59 +05:00
unknown
d9be8ed9eb Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  mysql.com:/home/hf/work/30286/my50-30286
2007-10-05 18:53:44 +05:00
unknown
a2d88511f0 Merge mhansson@bk-internal:/home/bk/mysql-5.0-opt
into  dl145s.mysql.com:/data0/mhansson/bug30942/my50-bug30942
2007-10-05 13:42:19 +02:00
unknown
071e55af0d Merge mysql.com:/home/hf/work/30286/my41-30286
into  mysql.com:/home/hf/work/30286/my50-30286


mysql-test/t/gis.test:
  Auto merged
sql/gstream.cc:
  Auto merged
mysql-test/r/gis.result:
  SCCS merged
2007-10-05 16:33:08 +05:00
unknown
77d786b5a0 Merge mysql.com:/home/hf/work/30955/my41-30955
into  mysql.com:/home/hf/work/30286/my41-30286
2007-10-05 16:32:05 +05:00
unknown
c14e8c80dd Merge bk@192.168.21.1:mysql-4.1-opt
into  mysql.com:/home/hf/work/30286/my41-30286
2007-10-05 15:48:42 +05:00
unknown
794ed298cf Merge bk@192.168.21.1:mysql-5.0-opt
into  mysql.com:/home/hf/work/30286/my50-30286
2007-10-05 15:47:55 +05:00
unknown
8e37481553 Merge mysql.com:/home/hf/work/30286/my41-30286
into  mysql.com:/home/hf/work/30286/my50-30286


myisam/rt_index.c:
  Auto merged
myisam/rt_mbr.c:
  Auto merged
mysql-test/t/gis-rtree.test:
  Auto merged
mysql-test/r/gis-rtree.result:
  merging
2007-10-05 15:41:56 +05:00
unknown
6d54b5771b Bug #30286 spatial index cause corruption and server crash!
As the result of DOUBLE claculations can be bigger
than DBL_MAX constant we use in code, we shouldn't use this constatn
as a biggest possible value.
Particularly the rtree_pick_key function set 'min_area= DBL_MAX' relying
that any rtree_area_increase result will be less so we return valid
key. Though in rtree_area_increase function we calculate the area
of the rectangle, so the result can be 'inf' if the rectangle is
huge enough, which is bigger than DBL_MAX.

Code of the rtree_pick_key modified so we always return a valid key.


myisam/rt_index.c:
  Bug #30286 spatial index cause corruption and server crash!
  
  always set the best_key with the first key we get, so we always return
  somthing valid.
myisam/rt_mbr.c:
  Bug #30286 spatial index cause corruption and server crash!
  
  function comment extended
mysql-test/r/gis-rtree.result:
  Bug #30286 spatial index cause corruption and server crash!
  test result
mysql-test/t/gis-rtree.test:
  Bug #30286 spatial index cause corruption and server crash!
  test case
2007-10-05 15:40:32 +05:00
unknown
554d405d73 test fix(to satisfy WIN)
mysql-test/r/information_schema.result:
  result fix
2007-10-05 12:29:02 +05:00
unknown
4ae273e395 Bug#30079 A check for "hidden" I_S tables is flawed
added check for hidden I_S tables for 'show columns|keys' commands


mysql-test/r/information_schema.result:
  test result
mysql-test/t/information_schema.test:
  test case
sql/sql_parse.cc:
  added check for hidden I_S tables for 'show columns|keys' commands
2007-10-04 16:20:56 +05:00
unknown
ae2956f79a Merge mhansson@bk-internal:/home/bk/mysql-5.0-opt
into  dl145s.mysql.com:/data0/mhansson/bug30942/my50-bug30942
2007-10-04 11:06:01 +02:00
unknown
f8f021fd6b Bug #30942: select str_to_date from derived table returns varying results
The function str_to_date has a field to say whether it's invoked constant 
arguments. But this member was not initialized, causing the function to
think that it could use a cache of the format type when said cache was in 
fact not initialized.
Fixed by initializing the field to false.


mysql-test/r/type_date.result:
  Bug#30942: Test result
mysql-test/t/type_date.test:
  Bug#30942: Test case
sql/item_timefunc.h:
  Bug#30942: Initialized const_item to false
2007-10-04 09:15:26 +02:00
unknown
ae3d4bfc0e Bug #30955 geomfromtext() crasher.
end-of-line check missed in Gis_read_stream::get_next_word,
what can lead to crashes (expecially with NULL strings).

End-of-line check added


sql/gstream.cc:
  Bug #30955 geomfromtext() crasher
mysql-test/r/gis.result:
  Bug #30955 geomfromtext() crasher.
  
  test result
mysql-test/t/gis.test:
  Bug #30955 geomfromtext() crasher.
  
  test case
2007-10-03 13:35:35 +05:00
unknown
a408f34866 Merge gleb.loc:/home/uchum/work/bk/5.0-opt-31077
into  gleb.loc:/home/uchum/work/bk/5.0-opt
2007-10-03 11:37:29 +05:00
unknown
b802af43cb mysqldump.test, mysqldump.result:
Bug #31077: post-commit fix.


mysql-test/t/mysqldump.test:
  Bug #31077: post-commit fix.
mysql-test/r/mysqldump.result:
  Bug #31077: post-commit fix.
2007-10-03 11:36:42 +05:00
unknown
df4e28e75b Merge gleb.loc:/home/uchum/work/bk/5.0-opt-31077
into  gleb.loc:/home/uchum/work/bk/5.0-opt
2007-10-03 02:51:17 +05:00
unknown
853e4da88f mysqldump.c, mysqldump.test, mysqldump.result:
Bug #31077: post-commit fix.


client/mysqldump.c:
  Bug #31077: post-commit fix.
mysql-test/t/mysqldump.test:
  Bug #31077: post-commit fix.
mysql-test/r/mysqldump.result:
  Bug #31077: post-commit fix.
2007-10-03 02:50:38 +05:00
unknown
2071d63dc7 Merge gleb.loc:/home/uchum/work/bk/5.0-opt-31077
into  gleb.loc:/home/uchum/work/bk/5.0-opt
2007-10-02 22:31:51 +05:00
unknown
6400c7a238 Merge mhansson@bk-internal:/home/bk/mysql-5.0-opt
into  dl145s.mysql.com:/data0/mhansson/bug30832/my50-bug30832
2007-10-02 14:36:07 +02:00
unknown
832616f177 Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  moonbone.local:/work/31095-bug-5.0-opt-mysql
2007-10-02 12:36:06 +00:00
unknown
1a4df8a24d Bug#31095: Unexpected NULL constant caused server crash.
The Item_func_rollup_const class is used for wrapping constants to avoid
wrong result for ROLLUP queries with DISTINCT and a constant in the select
list. This class is also used to wrap up a NULL constant but its null_value
wasn't set accordingly. This led to a server crash.

Now the null_value of an object of the Item_func_rollup_const class is set
by its fix_length_and_dec member function.


mysql-test/t/olap.test:
  Added a test case for the bug#31095: Unexpected NULL constant caused server crash.
mysql-test/r/olap.result:
  Added a test case for the bug#31095: Unexpected NULL constant caused server crash.
sql/item_func.h:
  Bug#31095: Unexpected NULL constant caused server crash. 
  Now the null_value of an object of the Item_func_rollup_const class is set
  by its fix_length_and_dec member function.
2007-10-01 20:03:50 +00:00
unknown
02bb72c735 Fixed bug #31077.
mysqldump adds the "-- Dump completed on YYYY-MM-DD hh:mm:ss" string
to the end of output if the --comments switch is on.
The only way to suppress this line is to use --skip-comments/--compact
switch.

New switch has been added to the mysqldump client command line:
--dump-date.

For the compatibility with previous releases, by default the --dump-date
is on.
The --dump-date switch forces mysqldump to add date to the
"-- Dump completed on ..." string at the end of output.
The --skip-dump-date switch supresses the output of date string
and uses short form of that commentary: "-- Dump completed".
--skip-comments or --compact switches disable the whole commentary
as usual.


client/client_priv.h:
  Fixed bug #31077.
  New OPT_DUMP_DATE option has been added to implement
  the mysqldump client --dump-date switch.
client/mysqldump.c:
  Fixed bug #31077.
  The opt_dump_date variable has been added to imlements
  the mysqldump cliemt --dump-date switch.
  By default this switch is on (for compatibility with previous
  releases).
  The --dump-date switch forces mysqldump to add date to the
  "-- Dump completed on ..." string at the end of output.
  The --skip-dump-date switch supresses the output of date string
  and uses short form of that commentary: "-- Dump completed".
  --skip-comments or --compact switches disable the whole commentary
  as usual.
mysql-test/t/mysqldump.test:
  Added test case for bug #31077.
mysql-test/r/mysqldump.result:
  Added test case for bug #31077.
2007-10-01 20:35:51 +05:00
unknown
0ad23eb8a5 removed undeterministic test result from the fux for bug 30587 2007-10-01 12:51:59 +03:00
unknown
c6a4e65a40 view_grant.result, view_grant.test:
Corrected test case for the bug#29908.


mysql-test/t/view_grant.test:
  Corrected test case for the bug#29908.
mysql-test/r/view_grant.result:
  Corrected test case for the bug#29908.
2007-09-29 01:07:29 +00:00
unknown
582388e6d2 Bug #30832: Assertion + crash with select name_const('test', now());
The NAME_CONST function is required to work correctly with constants only.
When executed with functions that return types other than those returned by
Item::field_type (string, int, decimal, or real), the result gets cast to
one of those types. This cannot happen for constants.
Fixed by only allowing constants as arguments to NAME_CONST.


mysql-test/r/func_misc.result:
  Bug#30832: Test result
mysql-test/t/func_misc.test:
  Bug#30832: Test case
sql/item.h:
  Bug#30832: The fix
2007-09-28 18:05:23 +02:00
unknown
4c14efa696 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/autopush/B30587-5.0-opt


sql/item_func.cc:
  Auto merged
2007-09-28 16:57:36 +03:00