summaryrefslogtreecommitdiff
path: root/mysql-test/r/having.result
Commit message (Collapse)AuthorAgeFilesLines
* 5.3->5.5 mergeSergei Golubchik2013-02-281-2/+2
|\
| * Fixed bug mdev-3913.Igor Babaev2013-02-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The wrong result set returned by the left join query from the bug test case happened due to several inconsistencies and bugs of the legacy mysql code. The bug test case uses an execution plan that employs a scan of a materialized IN subquery from the WHERE condition. When materializing such an IN- subquery the optimizer injects additional equalities into the WHERE clause. These equalities express the constraints imposed by the subquery predicate. The injected equality of the query in the test case happens to belong to the same equality class, and a new equality imposing a condition on the rows of the materialized subquery is inferred from this class. Simultaneously the multiple equality is added to the ON expression of the LEFT JOIN used in the main query. The inferred equality of the form f1=f2 is taken into account when optimizing the scan of the rows the temporary table that is the result of the subquery materialization: only the values of the field f1 are read from the table into the record buffer. Meanwhile the inferred equality is removed from the WHERE conditions altogether as a constraint on the fields of the temporary table that has been used when filling this table. This equality is supposed to be removed from the ON expression when the multiple equalities of the ON expression are converted into an optimal set of equality predicates. It supposed to be removed from the ON expression as an equality inferred from only equalities of the WHERE condition. Yet, it did not happened due to the following bug in the code. Erroneously the code tried to build multiple equality for ON expression twice: the first time, when it called optimize_cond() for the WHERE condition, the second time, when it called this function for the HAVING condition. When executing optimize_con() for the WHERE condition a reference to the multiple equality of the WHERE condition is set in the multiple equality of the ON expression. This reference would allow later to convert multiple equalities of the ON expression into equality predicates. However the the second call of build_equal_items() for the ON expression that happened when optimize_cond() was called for the HAVING condition reset this reference to NULL. This bug fix blocks calling build_equal_items() for ON expressions for the second time. In general, it will be beneficial for many queries as it removes from ON expressions any equalities that are to be checked for the WHERE condition. The patch also fixes two bugs in the list manipulation operations and a bug in the function substitute_for_best_equal_field() that resulted in passing wrong reference to the multiple equalities of where conditions when processing multiple equalities of ON expressions. The code of substitute_for_best_equal_field() and the code the helper function eliminate_item_equal() were also streamlined and cleaned up. Now the conversion of the multiple equalities into an optimal set of equality predicates first produces the sequence of the all equalities processing multiple equalities one by one, and, only after this, it inserts the equalities at the beginning of the other conditions. The multiple changes in the output of EXPLAIN EXTENDED are mainly the result of this streamlining, but in some cases is the result of the removal of unneeded equalities from ON expressions. In some test cases this removal were reflected in the output of EXPLAIN resulted in disappearance of “Using where” in some rows of the execution plans.
* | Merge 5.3->5.5.Igor Babaev2012-03-011-0/+41
|\ \ | |/
| * Merge 5.2->5.3Igor Babaev2012-02-261-0/+65
| |\
| | * Fix of LP bug:938518 (also LP bug:791761 and LP bug:806955)unknown2012-02-251-0/+61
| | | | | | | | | | | | Cause of the bug is uninitialized items before evaluation HAVING clasue in case of empty result.
| * | Rolled back the patch for bug 791761.Igor Babaev2012-02-261-24/+0
| | | | | | | | | | | | A better fix for this bug will be pulled from mariadb-5.2.
* | | after merge changes:Sergei Golubchik2011-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* | | mysql-5.5.18 mergeSergei Golubchik2011-11-031-1/+1
|\ \ \
| * | | Update the German error message translations (by Stefan Hinz)Marko Mäkelä2011-09-291-1/+1
| | | | | | | | | | | | | | | | and fix some Swedish too.
* | | | merge with 5.3Sergei Golubchik2011-10-191-3/+27
|\ \ \ \ | | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | | Fixed LP bug #791761.Igor Babaev2011-07-201-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | Merge with 5.1-microsecondsMichael Widenius2011-05-281-2/+2
| |\ \ \ | | |_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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()
| | * | wl#173 - temporal types with sub-second resolutionSergei Golubchik2011-03-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | | Merge with MySQL 5.1.57/58Michael Widenius2011-05-021-0/+22
| |\ \ \ | | | | | | | | | | | | | | | Moved some BSD string functions from Unireg
* | \ \ \ 5.5-mergeSergei Golubchik2011-07-021-0/+22
|\ \ \ \ \ | | |_|_|/ | |/| | |
| * | | | 5.1 -> 5.5 mergeSergey Glukhov2011-04-221-0/+22
| |\ \ \ \ | | | |/ / | | |/| |
| | * | | Bug#11756928 48916: SERVER INCORRECTLY PROCESSING HAVING CLAUSES WITH AN ↵Sergey Glukhov2011-04-221-0/+22
| | | |/ | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | merge.Sergei Golubchik2010-11-251-4/+6
|\ \ \ \ | |/ / / |/| | / | | |/ | |/| | | | checkpoint. does not compile.
| * | Reverted the MySQL fix for bug 51242 that was rejected once for mariadb-5.1.48Igor Babaev2010-10-141-4/+6
| |/ | | | | | | and mistakingly pulled in back for maria-5.1.50.
* | 5.1-bugteam->trunk-merge mergeSergey Glukhov2010-07-091-0/+16
|\ \ | |/
| * Bug#54416 MAX from JOIN with HAVING returning NULL with 5.1 and Empty setSergey Glukhov2010-07-091-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Some post-merge fixes afer a merge from mysql-5.1-bugteam.Alexey Kopytov2010-04-111-0/+2
| |
* | Automerge of mysql-5.1-bugteam to mysql-trunk-merge.Alexey Kopytov2010-04-111-2/+46
|\ \ | |/
| * Bug#52336 Segfault / crash in 5.1 copy_fields (param=0x9872980) at ↵Sergey Glukhov2010-04-051-2/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Manual merge of mysql-5.1-bugteam to mysql-trunk-merge.Alexey Kopytov2010-03-201-0/+35
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Bug#51242 HAVING clause on table join produce incorrect resultsSergey Glukhov2010-03-191-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Manual merge of mysql-5.1-bugteam into mysql-trunk-merge.Alexey Kopytov2010-03-071-1/+1
|\ \ | |/ | | | | | | | | | | | | | | | | | | 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
| * Bug#47669 Query showed by EXPLAIN EXTENDED gives different result from ↵Sergey Glukhov2010-02-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Manual merge from mysql-5.1-bugteam to mysql-trunk-merge.Alexey Kopytov2010-02-261-0/+20
|\ \ | |/ | | | | | | | | | | | | Conflicts: Text conflict in scripts/Makefile.am Text conflict in sql/share/Makefile.am
| * Bug#50995 Having clause on subquery result produces incorrect results.Sergey Glukhov2010-02-261-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Bug#30302: Tables that were optimized away are printed in theEvgeny Potemkin2009-10-191-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* merged 5.0-bugteam -> 5.1-bugteamGeorgi Kodinov2009-01-161-0/+7
|\
| * Bug #38637: COUNT DISTINCT prevents NULL testing in HAVING clauseGeorgi Kodinov2008-10-171-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge gleb.loc:/home/uchum/work/bk/5.0-optunknown2007-07-261-0/+19
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * Merge olga.mysql.com:/home/igor/dev-opt/mysql-4.1-opt-bug29911unknown2007-07-211-0/+19
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| | * Fixed bug #29911.unknown2007-07-201-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| | * Fixed bug #14927.unknown2006-05-061-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-optunknown2007-03-111-1/+1
|\ \ \ | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | Bug#22331: Wrong WHERE in EXPLAIN EXTENDED when all expressions were optimizedunknown2007-03-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | BUG#14940 "MySQL choose wrong index", v.2unknown2006-07-281-2/+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
* | Fixed bug #19573.unknown2006-05-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Fixed bug#18739: non-standard HAVING extension was allowed in strict ANSI ↵unknown2006-04-211-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Made the test case for bug #15917 independent on platforms.unknown2006-04-101-2/+0
| |
* | Fixed bug #15917: unexpected complain for a NIST test case.unknown2006-04-061-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Fixed bug #16504.unknown2006-03-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Fixes after manual mergeunknown2006-02-021-17/+0
| |
* | Merge rurik.mysql.com:/home/igor/dev/mysql-4.1-0unknown2006-02-021-0/+34
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | FIxed bug #14927.unknown2006-01-311-0/+17
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge rurik.mysql.com:/home/igor/dev/mysql-4.1-0unknown2006-01-071-0/+13
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | 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.
| * Fixed bug #14274: a query with a having clause containing only set function ↵unknown2006-01-071-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.