Commit graph

70 commits

Author SHA1 Message Date
Igor Babaev
8b469eb515 Merge 5.3->5.5. 2012-03-01 14:22:22 -08:00
Igor Babaev
c92d8cba45 Merge 5.2->5.3 2012-02-26 02:42:45 -08:00
Igor Babaev
d2e3b33b8c Rolled back the patch for bug 791761.
A better fix for this bug will be pulled from mariadb-5.2.
2012-02-26 00:19:07 -08:00
unknown
6a72fbe396 Fix of LP bug:938518 (also LP bug:791761 and LP bug:806955)
Cause of the bug is uninitialized items before evaluation HAVING clasue in case of empty result.
2012-02-25 09:03:06 +02:00
Sergei Golubchik
2ccf247e93 after merge changes:
* rename all debugging related command-line options
  and variables to start from "debug-", and made them all
  OFF by default.
* replace "MySQL" with "MariaDB" in error messages
* "Cast ... converted ... integer to it's ... complement"
  is now a note, not a warning
* @@query_cache_strip_comments now has a session scope,
  not global.
2011-12-12 23:58:40 +01:00
Sergei Golubchik
0e007344ea mysql-5.5.18 merge 2011-11-03 19:17:05 +01:00
Sergei Golubchik
76f0b94bb0 merge with 5.3
sql/sql_insert.cc:
  CREATE ... IF NOT EXISTS may do nothing, but
  it is still not a failure. don't forget to my_ok it.
  ******
  CREATE ... IF NOT EXISTS may do nothing, but
  it is still not a failure. don't forget to my_ok it.
sql/sql_table.cc:
  small cleanup
  ******
  small cleanup
2011-10-19 21:45:18 +02:00
Marko Mäkelä
0c775ea96f Update the German error message translations (by Stefan Hinz)
and fix some Swedish too.
2011-09-29 15:31:46 +03:00
Igor Babaev
2e8542f462 Fixed LP bug #791761.
An aggregating query over an empty set of a join of two tables
with a rejecting HAVING clause erroneously could return a row.
It could happen in the cases when the optimizer made a conclusion
that the aggregating set was empty.
Wrong results were produced because the server missed initial
setting for aggregation functions in the mentioned cases.
2011-07-20 21:55:55 -07:00
Sergei Golubchik
9809f05199 5.5-merge 2011-07-02 22:08:51 +02:00
Michael Widenius
f197991f41 Merge with 5.1-microseconds
A lot of small fixes and new test cases.

client/mysqlbinlog.cc:
  Cast removed
client/mysqltest.cc:
  Added missing DBUG_RETURN
include/my_pthread.h:
  set_timespec_time_nsec() now only takes one argument
mysql-test/t/date_formats.test:
  Remove --disable_ps_protocl as now also ps supports microseconds
mysys/my_uuid.c:
  Changed to use my_interval_timer() instead of my_getsystime()
mysys/waiting_threads.c:
  Changed to use my_hrtime()
sql/field.h:
  Added bool special_const_compare() for fields that may convert values before compare (like year)
sql/field_conv.cc:
  Added test to get optimal copying of identical temporal values.
sql/item.cc:
  Return that item_int is equal if it's positive, even if unsigned flag is different.
  Fixed Item_cache_str::save_in_field() to have identical null check as other similar functions
  Added proper NULL check to Item_cache_int::save_in_field()
sql/item_cmpfunc.cc:
  Don't call convert_constant_item() if there is nothing that is worth converting.
  Simplified test when years should be converted
sql/item_sum.cc:
  Mark cache values in Item_sum_hybrid as not constants to ensure they are not replaced by other cache values in compare_datetime()
sql/item_timefunc.cc:
  Changed sec_to_time() to take a my_decimal argument to ensure we don't loose any sub seconds.
  Added Item_temporal_func::get_time() (This simplifies some things)
sql/mysql_priv.h:
  Added Lazy_string_decimal()
sql/mysqld.cc:
  Added my_decimal constants max_seconds_for_time_type, time_second_part_factor
sql/table.cc:
  Changed expr_arena to be of type CONVENTIONAL_EXECUTION to ensure that we don't loose any items that are created by fix_fields()
sql/tztime.cc:
  TIME_to_gmt_sec() now sets *in_dst_time_gap in case of errors
  This is needed to be able to detect if timestamp is 0
storage/maria/lockman.c:
  Changed from my_getsystime() to set_timespec_time_nsec()
storage/maria/ma_loghandler.c:
  Changed from my_getsystime() to my_hrtime()
storage/maria/ma_recovery.c:
  Changed from my_getsystime() to mmicrosecond_interval_timer()
storage/maria/unittest/trnman-t.c:
  Changed from my_getsystime() to mmicrosecond_interval_timer()
storage/xtradb/handler/ha_innodb.cc:
  Added support for new time,datetime and timestamp
unittest/mysys/thr_template.c:
  my_getsystime() -> my_interval_timer()
unittest/mysys/waiting_threads-t.c:
  my_getsystime() -> my_interval_timer()
2011-05-28 05:11:32 +03:00
Michael Widenius
e415ba0fb2 Merge with MySQL 5.1.57/58
Moved some BSD string functions from Unireg
2011-05-02 20:58:45 +03:00
Sergey Glukhov
a5e8d9029b Bug#11756928 48916: SERVER INCORRECTLY PROCESSING HAVING CLAUSES WITH AN ORDER BY CLAUSE
Before sorting HAVING condition is split into two parts,
first part is a table related condition and the rest of is
HAVING part. Extraction of HAVING part does not take into account
the fact that some of conditions might be non-const but
have 'used_tables' == 0 (independent subqueries)
and because of that these conditions are cut off by
make_cond_for_table() function.
The fix is to use (table_map) 0 instead of used_tables in
third argument for make_cond_for_table() function.
It allows to extract elements which belong to sorted
table and in addition elements which are independend
subqueries.


mysql-test/r/having.result:
  test case
mysql-test/t/having.test:
  test case
sql/sql_select.cc:
  The fix is to use (table_map) 0 instead of used_tables in
  third argument for make_cond_for_table() function.
  It allows to extract elements which belong to sorted
  table and in addition elements which are independend
  subqueries.
2011-04-22 11:20:55 +04:00
Sergey Glukhov
1930168448 5.1 -> 5.5 merge 2011-04-22 11:39:42 +04:00
Sergei Golubchik
a8a757c6bb wl#173 - temporal types with sub-second resolution
and collateral changes.

* introduce my_hrtime_t, my_timediff_t, and conversion macros
* inroduce TIME_RESULT, but it can only be returned from Item::cmp_type(),
  never from Item::result_type()
* pack_time/unpack_time function for "packed" representation of
  MYSQL_TIME in a longlong that can be compared
* ADDTIME()/SUBTIME()/+- INTERVAL now work with TIME values
* numbers aren't quoted in EXPLAIN EXTENDED
* new column I_S.COLUMNS.DATETIME_PRECISION
* date/time values are compares to anything as date/time, not as strings or numbers.
* old timestamp(X) is no longer supported
* MYSQL_TIME to string conversion functions take precision as an argument
* unified the warnings from Field_timestamp/datetime/time/date/newdate store methods
* Field_timestamp_hires, Field_datetime_hires, Field_time_hires
* Field_temporal
* Lazy_string class to pass a value (string, number, time) polymorphically down the stack
* make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants
* removed Field::can_be_compared_as_longlong(). Use Field::cmp_type() == INT_RESULT instead
* introduced Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
* in many cases date/time types are treated like other types, not as special cases
* greatly simplified Arg_comparator (regarding date/time/year code)
* SEC_TO_TIME is real function, not integer.
* microsecond precision in NOW, CURTIME, etc
* Item_temporal. All items derived from it only provide get_date, but no val* methods
* replication of NOW(6)
* Protocol::store(time) now takes the precision as an argument
* @@TIMESTAMP is a double

client/mysqlbinlog.cc:
  remove unneded casts
include/my_sys.h:
  introduce my_hrtime_t, my_timediff_t, and conversion macros
include/my_time.h:
  pack_time/unpack_time, etc.
  convenience functions to work with MYSQL_TIME::second_part
libmysql/libmysql.c:
  str_to_time() is gone. str_to_datetime() does it now.
  my_TIME_to_str() takes the precision as an argument
mysql-test/include/ps_conv.inc:
  time is not equal to datetime anymore
mysql-test/r/distinct.result:
  a test for an old MySQL bug
mysql-test/r/explain.result:
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/func_default.result:
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/func_sapdb.result:
  when decimals=NOT_FIXED_DEC it means "not fixed" indeed
mysql-test/r/func_test.result:
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/func_time.result:
  ADDTIME()/SUBTIME()/+- INTERVAL now work with TIME values
mysql-test/r/having.result:
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/information_schema.result:
  new column I_S.COLUMNS.DATETIME_PRECISION
mysql-test/r/join_outer.result:
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/metadata.result:
  TIMESTAMP no longer has zerofill flag
mysql-test/r/range.result:
  invalid datetime is not compared with as a string
mysql-test/r/select.result:
  NO_ZERO_IN_DATE, etc only affect storage - according to the manual
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/subselect.result:
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/sysdate_is_now.result:
  when decimals=NOT_FIXED_DEC it means "not fixed" indeed
mysql-test/r/type_blob.result:
  TIMESTAMP(N) is not deprecated
mysql-test/r/type_timestamp.result:
  old TIMESTAMP(X) semantics is not supported anymore
mysql-test/r/union.result:
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/varbinary.result:
  numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/t/distinct.test:
  test for an old MySQL bug
mysql-test/t/func_time.test:
  +- INTERVAL now works with TIME values
mysql-test/t/select.test:
  typo
mysql-test/t/subselect.test:
  only one error per statement, please
mysql-test/t/system_mysql_db_fix40123.test:
  old timestamp(X) is no longer supported
mysql-test/t/system_mysql_db_fix50030.test:
  old timestamp(X) is no longer supported
mysql-test/t/system_mysql_db_fix50117.test:
  old timestamp(X) is no longer supported
mysql-test/t/type_blob.test:
  old timestamp(X) is no longer supported
mysql-test/t/type_timestamp.test:
  old timestamp(X) is no longer supported
mysys/my_getsystime.c:
  functions to get the time with microsecond precision
mysys/my_init.c:
  move the my_getsystime.c initialization code to my_getsystime.c
mysys/my_static.c:
  no need to make these variables extern
mysys/my_static.h:
  no need to make these variables extern
scripts/mysql_system_tables.sql:
  old timestamp(X) is no longer supported
scripts/mysql_system_tables_fix.sql:
  old timestamp(X) is no longer supported
scripts/mysqlhotcopy.sh:
  old timestamp(X) is no longer supported
sql-common/my_time.c:
  * call str_to_time from str_to_datetime, as appropriate
  * date/time to string conversions take precision as an argument
  * number_to_time()
  * TIME_to_double()
  * pack_time() and unpack_time()
sql/event_data_objects.cc:
  cast is not needed
  my_datetime_to_str() takes precision as an argument
sql/event_db_repository.cc:
  avoid dangerous downcast (because the pointer is
  not always Field_timestamp, see events_1.test)
sql/event_queue.cc:
  avoid silly double-work for cond_wait
  (having an endpoint of wait, subtract the current time to get the timeout,
  and use set_timespec() macro to fill in struct timespec, by adding the current
  time to the timeout)
sql/field.cc:
  * remove virtual Field::get_time(), everyone should use only Field::get_date()
  * remove lots of #ifdef WORDS_BIGENDIAN
  * unified the warnings from Field_timestamp/datetime/time/date/newdate store methods
  * Field_timestamp_hires, Field_datetime_hires, Field_time_hires
  * Field_temporal
  * make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants
sql/field.h:
  * remove virtual Field::get_time(), everyone should use only Field::get_date()
  * remove lots of #ifdef WORDS_BIGENDIAN
  * unified the warnings from Field_timestamp/datetime/time/date/newdate store methods
  * Field_timestamp_hires, Field_datetime_hires, Field_time_hires
  * Field_temporal
  * make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants
  * removed Field::can_be_compared_as_longlong(). Use Field::cmp_type() == INT_RESULT instead
sql/filesort.cc:
  TIME_RESULT, cmp_time()
sql/item.cc:
  * numbers aren't quoted in EXPLAIN EXTENDED
  * Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
  * virtual Item::get_time() is gone
  * Item_param::field_type() is set correctly
  * Item_datetime, for a datetime constant
  * time to anything is compared as a time
  * Item_cache::print() prints the value is available
  * bug fixed in Item_cache_int::val_str()
sql/item.h:
  * Item::print_value(), to be used from Item_xxx::print() when needed
  * Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
  * virtual Item::get_time() is gone
  * Item_datetime, for a datetime constant
  * better default for cast_to_int_type()
  * Item_cache objects now *always* have the field_type() set
sql/item_cmpfunc.cc:
  * get_year_value, get_time_value are gone. get_datetime_value does it all
  * get_value_a_func, get_value_b_func are gone
  * can_compare_as_dates() is gone too, TIME_RESULT is used instead
  * cmp_type() instead or result_type() when doing a comparison
  * compare_datetime and compate_e_datetime in the comparator_matrix, is_nulls_eq is gone
  * Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
sql/item_cmpfunc.h:
  greatly simplified Arg_comparator
sql/item_create.cc:
  * fix a bug in error messages in CAST
sql/item_func.cc:
  Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
  mention all possibitiles in switch over Item_result values, or use default:
sql/item_row.h:
  overwrite the default cmp_type() for Item_row,
  as no MYSQL_TYPE_xxx value corresponds to ROW_RESULT
sql/item_timefunc.cc:
  rewrite make_datetime to support precision argument
  SEC_TO_TIME is real function, not integer.
  many functions that returned temporal values had duplicate code in val_* methods,
  some of them did not have get_date() which resulted in unnecessary date->str->date conversions. 
  Now they all are derived from Item_temporal_func and *only* provide get_date, not val* methods.
  many fixes to set decimals (datetime precision) correctly.
sql/item_timefunc.h:
  SEC_TO_TIME is real function, not integer.
  many functions that returned temporal values had duplicate code in val_* methods,
  some of them did not have get_date() which resulted in unnecessary date->str->date conversions. 
  Now they all are derived from Item_temporal_func and *only* provide get_date, not val* methods.
  many fixes to set decimals (datetime precision) correctly.
sql/log_event.cc:
  replication of NOW(6)
sql/log_event.h:
  replication of NOW(6)
sql/mysql_priv.h:
  Lazy_string class to pass a value (string, number, time) polymorphically down the stack.
  make_truncated_value_warning() that uses it.
sql/mysqld.cc:
  datetime in Arg_comparator::comparator_matrix
sql/opt_range.cc:
  cleanup: don't disable warnings before calling save_in_field_no_warnings()
sql/protocol.cc:
  Protocol::store(time) now takes the precision as an argument
sql/protocol.h:
  Protocol::store(time) now takes the precision as an argument
sql/rpl_rli.cc:
  small cleanup
sql/set_var.cc:
  SET TIMESTAMP=double
sql/set_var.h:
  @@TIMESTAMP is a double
sql/share/errmsg.txt:
  precision and scale are unsigned
sql/slave.cc:
  replication of NOW(6)
sql/sp_head.cc:
  cleanup
sql/sql_class.cc:
  support for NOW(6)
sql/sql_class.h:
  support for NOW(6)
sql/sql_insert.cc:
  support for NOW(6)
sql/sql_select.cc:
  use item->cmp_type().
  move a comment where it belongs
sql/sql_show.cc:
  new column I_S.COLUMNS.DATETIME_PRECISION
sql/sql_yacc.yy:
  TIME(X), DATETIME(X), cast, NOW(X), CURTIME(X), etc
sql/time.cc:
  fix date_add_interval() to support MYSQL_TIMESTAMP_TIME argument
storage/myisam/ha_myisam.cc:
  TIMESTAMP no longer carries ZEROFIELD flag, still we keep MYI file compatible.
strings/my_vsnprintf.c:
  warnings
tests/mysql_client_test.c:
  old timestamp(X) does not work anymore
  datetime is no longer equal to time
2011-03-01 13:24:36 +01:00
Sergei Golubchik
65ca700def merge.
checkpoint.
does not compile.
2010-11-25 18:17:28 +01:00
Igor Babaev
f0c6576b85 Reverted the MySQL fix for bug 51242 that was rejected once for mariadb-5.1.48
and mistakingly pulled in back for maria-5.1.50.
2010-10-14 14:47:38 -07:00
Sergey Glukhov
024dba64b6 5.1-bugteam->trunk-merge merge 2010-07-09 14:46:46 +04:00
Sergey Glukhov
013136364c Bug#54416 MAX from JOIN with HAVING returning NULL with 5.1 and Empty set
The problem there is that HAVING condition evaluates const
parts of condition despite the condition has references
on aggregate functions. Table t1 became const tables
after make_join_statistics and table1.pk = 1, HAVING is
transformed into MAX(1) < 7 and taken away from HAVING.
The fix is to skip evaluation of HAVING conts parts if
HAVING condition has references on aggregate functions.


mysql-test/r/having.result:
  test case
mysql-test/t/having.test:
  test case
sql/sql_select.cc:
  skip evaluation of HAVING conts parts if
  HAVING condition has references on aggregate functions.
2010-07-09 14:39:47 +04:00
Alexey Kopytov
199f2ce47e Some post-merge fixes afer a merge from mysql-5.1-bugteam. 2010-04-11 14:42:05 +04:00
Alexey Kopytov
456235a13c Automerge of mysql-5.1-bugteam to mysql-trunk-merge. 2010-04-11 11:17:42 +04:00
Sergey Glukhov
c1ad5072b8 Bug#52336 Segfault / crash in 5.1 copy_fields (param=0x9872980) at sql_select.cc:15355
The problem is that we can not use make_cond_for_table().
This function relies on used_tables() condition
which is not set properly for subqueries.
As result subquery is not filtered out.
The fix is to use remove_eq_conds() function instead
of make_cond_for_table() func. 'remove_eq_conds()'
algorithm relies on const_item() value and it allows
to handle subqueries in right way.


mysql-test/r/having.result:
  test case
mysql-test/t/having.test:
  test case
sql/sql_select.cc:
  The fix is to use remove_eq_conds() function instead
  of make_cond_for_table() function.
2010-04-05 16:10:26 +05:00
Alexey Kopytov
5d407d0c1a Manual merge of mysql-5.1-bugteam to mysql-trunk-merge.
Conflicts:

Text conflict in mysql-test/r/partition_innodb.result
Text conflict in sql/field.h
Text conflict in sql/item.h
Text conflict in sql/item_cmpfunc.h
Text conflict in sql/item_sum.h
Text conflict in sql/log_event_old.cc
Text conflict in sql/protocol.cc
Text conflict in sql/sql_select.cc
Text conflict in sql/sql_yacc.yy
2010-03-20 23:23:42 +03:00
Sergey Glukhov
ad6e00e3b2 Bug#51242 HAVING clause on table join produce incorrect results
The problem is that when we make conditon for
grouped result const part of condition is cut off.
It happens because some parts of 'having' condition
which refer to outer join become const after
make_join_statistics. These parts may be lost
during further having condition transformation
in JOIN::exec. The fix is adding 'having'
condition check for const tables after
make_join_statistics is performed.


mysql-test/r/having.result:
  test case
mysql-test/t/having.test:
  test result
sql/sql_select.cc:
  added 'having' condition check for const tables
  after make_join_statistics is performed.
2010-03-19 13:09:22 +04:00
Alexey Kopytov
6e7b8b6a7a Manual merge of mysql-5.1-bugteam into mysql-trunk-merge.
Conflicts:

Text conflict in .bzr-mysql/default.conf
Text conflict in mysql-test/r/explain.result
Text conflict in mysql-test/r/having.result
Text conflict in mysql-test/suite/rpl/t/disabled.def
Text conflict in mysql-test/suite/rpl/t/rpl_slave_skip.test
Text conflict in storage/federated/ha_federated.cc
2010-03-07 19:40:59 +03:00
Sergey Glukhov
ca6691533a Bug#47669 Query showed by EXPLAIN EXTENDED gives different result from original query
Item_field::print method does not take into
account fields whose values may be null.
The fix is to print 'NULL' if field value is null.


mysql-test/r/explain.result:
  test case
mysql-test/r/func_str.result:
  result fix
mysql-test/r/having.result:
  result fix
mysql-test/r/select.result:
  result fix
mysql-test/r/subselect.result:
  result fix
mysql-test/r/union.result:
  result fix
mysql-test/t/explain.test:
  test case
sql/item.cc:
  print 'NULL' if field value is null.
2010-02-26 17:40:01 +04:00
Alexey Kopytov
84766b060a Manual merge from mysql-5.1-bugteam to mysql-trunk-merge.
Conflicts:

Text conflict in scripts/Makefile.am
Text conflict in sql/share/Makefile.am
2010-02-26 16:06:31 +03:00
Sergey Glukhov
9245ed4a12 Bug#50995 Having clause on subquery result produces incorrect results.
The problem is that cond->fix_fields(thd, 0) breaks
condition(cuts off 'having'). The reason of that is
that NULL valued Item pointer is present in the
middle of Item list and it breaks the Item processing
loop.


mysql-test/r/having.result:
  test case
mysql-test/t/having.test:
  test case
sql/item_cmpfunc.h:
  added ASSERT to make sure that we do not add NULL valued Item pointer
sql/sql_select.cc:
  skip adding an item to condition if Item pointer is NULL.
  skip adding a list to condition if this list is empty.
2010-02-26 15:39:25 +04:00
Evgeny Potemkin
60fc8507bd Bug#30302: Tables that were optimized away are printed in the
EXPLAIN EXTENDED warning.

Query optimizer searches for the constant tables and optimizes them away. This
means that fields of such tables are substituted for their values and on later
phases they are treated as constants. After this constant tables are removed
from the query execution plan. Nevertheless constant tables were shown in 
the EXPLAIN EXTENDED warning thus producing query that might be not an
equivalent of the original query.
        
Now the print_join function skips all tables that were optimized away from
printing to the EXPLAIN EXTENDED warning. If all tables were optimized away it
produces the 'FROM dual' clause.


mysql-test/r/explain.result:
  A test case added for the bug#30302.
mysql-test/r/func_default.result:
  Adjusted test case result after fix for the bug#30302.
mysql-test/r/func_regexp.result:
  Adjusted test case result after fix for the bug#30302.
mysql-test/r/func_test.result:
  Adjusted test case result after fix for the bug#30302.
mysql-test/r/having.result:
  Adjusted test case result after fix for the bug#30302.
mysql-test/r/select.result:
  Adjusted test case result after fix for the bug#30302.
mysql-test/r/subselect.result:
  Adjusted test case result after fix for the bug#30302.
mysql-test/r/subselect3.result:
  Adjusted test case result after fix for the bug#30302.
mysql-test/r/type_datetime.result:
  Adjusted test case result after fix for the bug#30302.
mysql-test/t/explain.test:
  A test case added for the bug#30302.
sql/sql_select.cc:
  Bug#30302: Tables that were optimized away are printed in the
  EXPLAIN EXTENDED warning.
  Now the print_join function skips all tables that were optimized away from
  printing to the EXPLAIN EXTENDED warning. If all tables were optimized away it
  produces the 'FROM dual' clause.
sql/table.h:
  Adjusted test case result after fix for the bug#30302.
  The optimized_away flag is added to the TABLE_LIST struct.
2009-10-19 15:13:26 +04:00
Georgi Kodinov
4d8e73c818 merged 5.0-bugteam -> 5.1-bugteam 2009-01-16 17:38:38 +02: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
unknown
21b83ab756 Merge gleb.loc:/home/uchum/work/bk/5.0-opt
into  gleb.loc:/home/uchum/work/bk/5.1-opt


mysql-test/r/having.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
mysql-test/t/having.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
mysql-test/include/mix1.inc:
  Merge with 5.0-opt.
mysql-test/r/create.result:
  Merge with 5.0-opt.
mysql-test/r/innodb_mysql.result:
  Merge with 5.0-opt.
mysql-test/r/type_enum.result:
  Merge with 5.0-opt.
mysql-test/t/type_enum.test:
  Merge with 5.0-opt.
sql/filesort.cc:
  Merge with 5.0-opt.
sql/sql_base.cc:
  Merge with 5.0-opt.
sql/table.cc:
  Merge with 5.0-opt.
storage/innobase/handler/ha_innodb.cc:
  Merge with 5.0-opt.
2007-07-26 01:23:39 +05:00
unknown
3520da5b25 Merge olga.mysql.com:/home/igor/dev-opt/mysql-4.1-opt-bug29911
into  olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug29911


mysql-test/t/having.test:
  Auto merged
sql/sql_select.cc:
  Auto merged
mysql-test/r/having.result:
  SCCS merged
2007-07-21 12:34:18 -07:00
unknown
72c6c789cf Fixed bug #29911.
This bug manifested itself for join queries with GROUP BY and HAVING clauses
whose SELECT lists contained DISTINCT. It occurred when the optimizer could
deduce that the result set would have not more than one row.
The bug could lead to wrong result sets for queries of this type because
HAVING conditions were erroneously ignored in some cases in the function
remove_duplicates.   


mysql-test/r/having.result:
  Added a test case for bug #29911.
mysql-test/t/having.test:
  Added a test case for bug #29911.
2007-07-20 22:56:19 -07:00
unknown
8a140cb72e Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  moonbone.local:/mnt/gentoo64/work/bk-trees/mysql-5.1-opt


mysql-test/r/explain.result:
  Auto merged
mysql-test/r/func_default.result:
  Auto merged
mysql-test/r/func_regexp.result:
  Auto merged
mysql-test/r/func_test.result:
  Auto merged
mysql-test/r/having.result:
  Auto merged
mysql-test/r/olap.result:
  Auto merged
mysql-test/r/subselect.result:
  Auto merged
mysql-test/r/union.result:
  Auto merged
mysql-test/r/varbinary.result:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/sql_union.cc:
  Auto merged
mysql-test/r/func_str.result:
  Manually merged
mysql-test/t/func_str.test:
  Manually merged
2007-03-11 00:26:45 +03:00
unknown
944030aef7 Bug#22331: Wrong WHERE in EXPLAIN EXTENDED when all expressions were optimized
away.

Additional fix for bug#22331. Now Item_field prints its value in the case of
the const field.


mysql-test/r/varbinary.result:
  Corrected test case after fix for bug#22331.
mysql-test/r/union.result:
  Corrected test case after fix for bug#22331.
mysql-test/r/subselect.result:
  Corrected test case after fix for bug#22331.
mysql-test/r/func_test.result:
  Corrected test case after fix for bug#22331.
mysql-test/r/having.result:
  Corrected test case after fix for bug#22331.
mysql-test/r/func_regexp.result:
  Corrected test case after fix for bug#22331.
mysql-test/r/func_str.result:
  Corrected test case after fix for bug#22331.
mysql-test/r/func_default.result:
  Corrected test case after fix for bug#22331.
mysql-test/r/explain.result:
  Corrected test case after fix for bug#22331.
sql/sql_union.cc:
  Bug#22331: Wrong WHERE in EXPLAIN EXTENDED when all expressions were optimized
  away.
  Cleanup of the SELECT_LEX::order_list list.
sql/item.h:
  Bug#22331: Wrong WHERE in EXPLAIN EXTENDED when all expressions were optimized
  away.
  Added the print() member function to the Item_field class.
sql/item.cc:
  Bug#22331: Wrong WHERE in EXPLAIN EXTENDED when all expressions were optimized
  away.
  Added the print() member function to the Item_field class.
2007-03-10 00:29:02 +03:00
unknown
ef452e19bf BUG#14940 "MySQL choose wrong index", v.2
- Make the range-et-al optimizer produce E(#table records after table 
                                           condition is applied),
- Make the join optimizer use this value,
- Add "filtered" column to EXPLAIN EXTENDED to show 
  fraction of records left after table condition is applied
- Adjust test results, add comments


mysql-test/r/archive_gis.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/auto_increment.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/bdb_gis.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/bench_count_distinct.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/binlog_stm_blackhole.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/case.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/cast.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/compress.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/ctype_collate.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/ctype_cp1250_ch.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/date_formats.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/distinct.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/fulltext.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/func_compress.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/func_crypt.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/func_default.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/func_encrypt.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/func_gconcat.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/func_group.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/func_if.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/func_in.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/func_like.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/func_math.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/func_op.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/func_regexp.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/func_set.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/func_str.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/func_system.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/func_test.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/func_time.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/gis.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/group_by.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/group_min_max.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/having.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/heap.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/heap_hash.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/index_merge.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/index_merge_innodb.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/index_merge_ror.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/innodb_gis.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/insert_update.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/join.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/join_nested.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/key_diff.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/myisam.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/ndb_gis.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/negation_elimination.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/null.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/olap.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/partition_pruning.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/query_cache.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/row.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/rpl_get_lock.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/rpl_master_pos_wait.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/select.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/ssl.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/ssl_compress.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/subselect.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/type_blob.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/union.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/varbinary.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/variables.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/r/view.result:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/t/ctype_cp1250_ch.test:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/t/func_like.test:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/t/group_min_max.test:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/t/index_merge_ror.test:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/t/index_merge_ror_cpk.test:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/t/join.test:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
mysql-test/t/partition_pruning.test:
  BUG#14940: Adjust the test results: EXPLAIN EXTENDED now has extra "filtered" column
sql/opt_range.cc:
  BUG#14940: Make range/index_merge/group-min-max optimizer produce TABLE::quick_condition_rows -
    estimate of #records that will match the table condition.
sql/sql_class.cc:
  BUG#14940: Add "filtered" column to output of EXPLAIN EXTENDED
sql/sql_select.cc:
  BUG#14940: 
  - Make the join optimizer to use TABLE::quick_condition_rows=
    = E(#table records after filtering with table condition) 
  - Add "filtered" column to output of EXPLAIN EXTENDED
sql/sql_select.h:
  BUG#14940: Added comments
sql/table.h:
  BUG#14940: Added comments
2006-07-28 21:27:01 +04:00
unknown
f1efd0883d Fixed bug #19573.
The select statement that specified a view could be
slightly changed when the view was saved in a frm file.
In particular references to an alias name in the HAVING
clause could be substituted for the expression named by
this alias.
This could result in an error message for a query of
the form SELECT * FROM <view>. Yet no such message
appeared when executing the query specifying the view.


mysql-test/r/having.result:
  Adjusted results after fixing bug #19573.
mysql-test/r/view.result:
  Added a test case for bug #19573.
mysql-test/t/view.test:
  Added a test case for bug #19573.
2006-05-16 22:19:44 -07:00
unknown
375749b8af Fixed bug #14927.
A query with a group by and having clauses could return a wrong
result set if the having condition contained a constant conjunct 
evaluated to FALSE.
It happened because the pushdown condition for table with
grouping columns lost its constant conjuncts.
Pushdown conditions are always built by the function make_cond_for_table
that ignores constant conjuncts. This is apparently not correct when
constant false conjuncts are present.



mysql-test/r/having.result:
  Added a test case for bug #14927.
mysql-test/t/having.test:
  Added a test case for bug #14927.
sql/sql_lex.cc:
  Fixed bug #14927.
  Initialized fields for having conditions in  st_select_lex::init_query().
sql/sql_lex.h:
  Fixed bug #14927.
  Added a field to restore having condititions for execution in SP and PS.
sql/sql_prepare.cc:
  Fixed bug #14927.
  Added code to restore havinf conditions for execution in SP and PS.
sql/sql_select.cc:
  Fixed bug #14927.
  Performed evaluation of constant expressions in having clauses.
  If the having condition contains a constant conjunct that is always false
  an empty result set is returned after the optimization phase.
  In this case the corresponding EXPLAIN command now returns 
  "Impossible HAVING" in the last column.
2006-05-06 23:48:13 -07:00
unknown
4b7c4cd27f Fixed bug#18739: non-standard HAVING extension was allowed in strict ANSI sql mode.
The SQL standard doesn't allow to use in HAVING clause fields that are not 
present in GROUP BY clause and not under any aggregate function in the HAVING
clause. However, mysql allows using such fields. This extension assume that 
the non-grouping fields will have the same group-wise values. Otherwise, the 
result will be unpredictable. This extension allowed in strict 
MODE_ONLY_FULL_GROUP_BY sql mode results in misunderstanding of HAVING 
capabilities.

The new error message ER_NON_GROUPING_FIELD_USED message is added. It says
"non-grouping field '%-.64s' is used in %-.64s clause". This message is
supposed to be used for reporting errors when some field is not found in the
GROUP BY clause but have to be present there. Use cases for this message are 
this bug and when a field is present in a SELECT item list not under any 
aggregate function and there is GROUP BY clause present which doesn't mention 
that field. It renders the ER_WRONG_FIELD_WITH_GROUP error message obsolete as
being more descriptive.
The resolve_ref_in_select_and_group() function now reports the 
ER_NON_GROUPING_FIELD_FOUND error if the strict mode is set and the field for 
HAVING clause is found in the SELECT item list only.



sql/share/errmsg.txt:
  Added the new ER_NON_GROUPING_FIELD_USED error message for the bug#14169.
mysql-test/t/having.test:
  Added test case for the bug#18739:  non-standard HAVING extension was allowed in strict ANSI sql mode.
mysql-test/r/having.result:
  Added test case for the bug#18739:  non-standard HAVING extension was allowed in strict ANSI sql mode.
sql/sql_select.cc:
  Added TODO comment to change the ER_WRONG_FIELD_WITH_GROUP to more detailed ER_NON_GROUPING_FIELD_USED message.
sql/item.cc:
  Fixed bug#18739: non-standard HAVING extension was allowed in strict ANSI sql mode.
  The resolve_ref_in_select_and_group() function now reports the
  ER_NON_GROUPING_FIELD_FOUND error if the strict MODE_ONLY_FULL_GROUP_BY mode
  is set and the field for HAVING clause is found in the SELECT item list only.
2006-04-21 01:52:59 +04:00
unknown
6978949b49 Made the test case for bug #15917 independent on platforms. 2006-04-10 14:14:20 -07:00
unknown
998b9d8b14 Fixed bug #15917: unexpected complain for a NIST test case.
The problem was due to the fact that with --lower-case-table-names set to 1 
the function find_field_in_group did not convert the prefix 'HU' in
HU.PROJ.CITY into lower case when looking for it in the group list. Yet the
names in the group list were extended by the database name in lower case.


mysql-test/r/having.result:
  Added a test case for bug #15917.
mysql-test/t/having.test:
  Added a test case for bug #15917.
sql/item.cc:
  Fixed bug #15917: unexpected complain for a NIST test case.
  The problem was due to the fact that with --lower-case-table-names set to 1 
  the function find_field_in_group did not convert the prefix 'HU' in
  HU.PROJ.CITY into lower case when looking for it in the group list. Yet the
  names in the group list were extended by the database name in lower case.
  The needed conversion was added to the code of find_field_in_group.
2006-04-06 15:29:15 -07:00
unknown
5ef6e903a4 Fixed bug #16504.
Multiple equalities were not adjusted after reading constant tables.
It resulted in neglecting good index based methods that could be
used to access of other tables.


mysql-test/r/having.result:
  Adjusted a test case results after fix for bug #16504.
mysql-test/r/select.result:
  Added a test case for bug #16504.
mysql-test/r/subselect.result:
  Adjusted a test case results after fix for bug #16504.
mysql-test/r/varbinary.result:
  Adjusted a test case results after fix for bug #16504.
mysql-test/t/select.test:
  Added a test case for bug #16504.
sql/item.cc:
  Fixed bug #16504.
  An Item_equal object may contain only a constant member.
  It may happen after reading constant tables.
sql/item_cmpfunc.cc:
  Fixed bug #16504.
  Added method Item_equal::check_const that check appearance of new 
  constant items in a multiple equality.
sql/item_cmpfunc.h:
  Fixed bug #16504.
  Added method Item_equal::check_const that check appearance of new 
  constant items in a multiple equality.
sql/sql_select.cc:
  Fixed bug #16504.
  Adjusted multiple equalities after reading constant tables.
  Fixed a few typo in comments.
2006-03-31 21:26:17 -08:00
unknown
ac21d0294d Fixes after manual merge 2006-02-02 23:56:08 -08:00
unknown
8300149963 Merge rurik.mysql.com:/home/igor/dev/mysql-4.1-0
into  rurik.mysql.com:/home/igor/dev/mysql-5.0-0


mysql-test/t/having.test:
  Auto merged
mysql-test/r/having.result:
  Manual merge
sql/sql_lex.cc:
  Manual merge
sql/sql_lex.h:
  Manual merge
sql/sql_prepare.cc:
  Manual merge
sql/sql_select.cc:
  Manual merge
2006-02-02 21:23:36 -08:00
unknown
a400e7feb9 FIxed bug #14927.
A query with a group by and having clauses could return a wrong
result set if the having condition contained a constant conjunct 
evaluated to FALSE.
It happened because the pushdown condition for table with
grouping columns lost its constant conjuncts.
Pushdown conditions are always built by the function make_cond_for_table
that ignores constant conjuncts. This is apparently not correct when
constant false conjuncts are present.


mysql-test/r/having.result:
  Added A test case for bug #14927.
mysql-test/t/having.test:
  Added A test case for bug #14927.
sql/sql_lex.cc:
  Fixed bug #14927.
  Initialized fields for having conditions in  st_select_lex::init_query().
sql/sql_lex.h:
  Fixed bug #14927.
  Added a field to restore having condititions for execution in SP and PS.
sql/sql_prepare.cc:
  Fixed bug #14927.
  Added code to restore havinf conditions for execution in SP and PS.
sql/sql_select.cc:
  Fixed bug #14927.
  Performed evaluation of constant expressions in having clauses.
  If the having condition contains a constant conjunct that is always false
  an empty result set is returned after the optimization phase.
  In this case the corresponding EXPLAIN command now returns 
  "Impossible HAVING" in the last column.
2006-01-31 21:48:32 -08:00
unknown
48c8241853 Merge rurik.mysql.com:/home/igor/dev/mysql-4.1-0
into  rurik.mysql.com:/home/igor/dev/mysql-5.0-0


mysql-test/t/having.test:
  Auto merged
mysql-test/r/having.result:
  Manual merge.
sql/sql_select.cc:
  Manual merge.
2006-01-07 23:10:08 -08:00
unknown
770e0e8118 Fixed bug #14274: a query with a having clause containing only set function returned a wrong result set.
mysql-test/r/having.result:
  Added a test case for bug #14274.
mysql-test/t/having.test:
  Added a test case for bug #14274.
sql/sql_select.cc:
  Fixed bug #14274: a query with a having clause containing only set function returned a wrong result set.
  It happened because processing of the set functions in having started with a call of the split_sum_func
  method, instead of the split_sum_func2 method.
2006-01-07 23:00:06 -08:00
unknown
476ca52ee7 Fix for BUG#11211 "GROUP BY doesn't work correctly"
When the GROUP BY clause contains a column reference that can be resolved to
both an aliased column in the SELECT list, and to a column in the FROM clause,
the group column is resolved to the column in the FROM clause (for ANSI conformance).
However, it may be so that the user's intent is just the other way around, and he/she
gets the query results grouped by a completely different column than expexted.
This patch adds a warning in such cases that tells the user that there is potential
ambiguity in the group column.

sql/sql_select.cc
- Added a warning when a GROUP column is ambiguous due to that there is a
  column reference with the same name both in the SELECT and FROM clauses.
  In this case we resolve to the column in FROM clause and warn the user
  of a possible ambiguity.
- More extensive comments.
- Changed the function to return bool instead of int (as in other places).

mysql-test/t/group_by.test
  Added test for BUG#11211.

mysql-test/r/group_by.result
  Added test for BUG#11211.


mysql-test/r/group_by.result:
  Import patch 11211.diff
mysql-test/t/group_by.test:
  Import patch 11211.diff
sql/sql_select.cc:
  Import patch 11211.diff
BitKeeper/etc/ignore:
  Added ndb/src/dummy.cpp to the ignore list
mysql-test/r/alias.result:
  Added warning for potentially ambiguous column.
mysql-test/r/having.result:
  Added warning for potentially ambiguous column.
2005-06-15 10:12:49 +03:00
unknown
afbb5d8fac WL#1972 "Evaluate HAVING before SELECT select-list"
- post-review fix regarding Item_fields
- added test for the changed name resolution


mysql-test/r/having.result:
  Test for changed name resolution of Item_fields
mysql-test/t/having.test:
  Test for changed name resolution of Item_fields
sql/item.cc:
  - Changed Item_field::fix_fields to perform the same name
    resolution as Item_ref::fix_fields because column references
    of subqueries inside HAVING may be represented as Item_fields,
    and they need to be resolved as Item_refs.
  - Adjusted Item_field::fix_fields so that it has the same variable
    names and structure as Item_ref::fix_fields.
2004-11-09 17:56:33 +02:00