Commit graph

87 commits

Author SHA1 Message Date
gkodinov/kgeorge@magare.gmz
54cea40003 Bug #30715: Assertion failed: item_field->field->real_maybe_null(),
file .\opt_sum.cc, line
The optimizer pre-calculates the MIN/MAX values for queries like
 SELECT MIN(kp_k) WHERE kp_1 = const AND ... AND kp_k-1 = const
when there is a key over kp_1...kp_k
In doing so it was not checking correctly nullability and 
there was a superfluous assert(). 
Fixed by making sure that the field can be null before checking and
taking out the wrong assert().
.
Introduced a correct check for nullability 
The MIN(field) can return NULL when all the row values in the group
are NULL-able or if there were no rows.
Fixed the assertion to reflect the case when there are no rows.
2007-10-24 11:15:08 +03:00
mhansson/martin@linux-st28.site
5bc137ff17 Bug#27573: MIN() on an indexed column which is always NULL sets _other_ results
to NULL

For queries of the form SELECT MIN(key_part_k) FROM t1 
WHERE key_part_1 = const and ... and key_part_k-1 = const,
the opt_sum_query optimization tries to
use an index to substitute MIN/MAX functions with their values according
to the following rules:
1) Insert the minimum non-null values where the WHERE clause still matches, or
3) A row of nulls

However, the correct semantics requires that there is a third case 2)
such that a NULL value is substituted if there are only NULL values for 
key_part_k.

The patch modifies opt_sum_query() to handle this missing case.
2007-05-15 15:29:12 +03:00
igor@olga.mysql.com
3eff8907e2 Merge olga.mysql.com:/home/igor/dev-opt/mysql-4.1-opt-bug24987
into  olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug24987
2007-01-30 13:14:52 -08:00
igor@olga.mysql.com
60ac1f1b78 Fixed bug #24987.
Made the function opt_sum_query to return HA_ERR_KEY_NOT_FOUND when
no matches were found (instead of -1 it returned prior this patch).
This changes allow us to avoid possible conflicts with return values
from user-defined handler methods which also may return -1. 
No particular test cases are provided with this fix.
2007-01-30 13:06:36 -08:00
kent@mysql.com/kent-amd64.(none)
226a5c833f Many files:
Changed header to GPL version 2 only
2006-12-23 20:17:15 +01:00
stewart@willster.(none)
c1903d967a Merge willster.(none):/home/stewart/Documents/MySQL/4.1/bug19914-mk2
into  willster.(none):/home/stewart/Documents/MySQL/5.0/bug19914-mk2-merge
2006-10-16 17:39:38 +10:00
stewart@willster.(none)
3ecc09e0e4 Merge willster.(none):/home/stewart/Documents/MySQL/4.1/main
into  willster.(none):/home/stewart/Documents/MySQL/4.1/bug19914-mk2
2006-09-25 14:48:39 +10:00
gkodinov/kgeorge@macbook.gmz
91e93eb7d0 Merge macbook.gmz:/Users/kgeorge/mysql/work/B16792-4.1-opt
into  macbook.gmz:/Users/kgeorge/mysql/work/B16792-5.0-opt
2006-09-05 17:09:12 +03:00
stewart@willster.(none)
9d2e6b8d23 BUG#19914 SELECT COUNT(*) sometimes returns MAX_INT on cluster tables
allow handler::info to return an error code (that will be returned to the user)
2006-08-10 22:55:20 +08:00
gkodinov/kgeorge@macbook.gmz
9ff33b5d93 Bug #16792 query with subselect, join, and group not returning proper values
Treat queries with no FROM and aggregate functions as normal queries,
so the aggregate function get correctly calculated as if there is 1 row. 
This means that they will be considered to have one row, so COUNT(*) will return
1 instead of 0. Other aggregates will behave in compatible manner.
2006-08-10 16:45:02 +03:00
svoj@may.pils.ru
ffd8ea244d Merge may.pils.ru:/home/svoj/devel/mysql/BUG20357/mysql-4.1
into  may.pils.ru:/home/svoj/devel/mysql/BUG20357/mysql-5.0
2006-06-21 19:41:09 +05:00
svoj@may.pils.ru
e560564cfa Merge april:devel/BitKeeper/mysql-4.1
into  may.pils.ru:/home/svoj/devel/mysql/BUG20357/mysql-4.1
2006-06-21 17:51:16 +05:00
svoj@may.pils.ru
8b98be2844 BUG#20357 - Got error 124 from storage engine using MIN and MAX
functions in queries

Using MAX()/MIN() on table with disabled indexes (by ALTER TABLE)
results in error 124 (wrong index) from storage engine.

The problem was that optimizer use disabled index to optimize
MAX()/MIN(). Normally it must skip disabled index and perform
table scan.

This patch skips disabled indexes for min/max optimization.
2006-06-21 17:30:59 +05:00
igor@rurik.mysql.com
1241d86787 Merge rurik.mysql.com:/home/igor/mysql-4.1-opt
into  rurik.mysql.com:/home/igor/mysql-5.0-opt
2006-06-15 18:40:18 -07:00
igor@rurik.mysql.com
5cdd1eb62d Post-review corrections of the fix for bug #18206. 2006-06-13 22:38:00 -07:00
igor@rurik.mysql.com
3f5f33d8f8 Merge rurik.mysql.com:/home/igor/mysql-4.1-opt
into  rurik.mysql.com:/home/igor/mysql-5.0-opt
2006-06-13 20:04:48 -07:00
igor@rurik.mysql.com
f1afd17821 Cleanup for the fix of bug 18206. 2006-06-02 19:15:32 -07:00
igor@rurik.mysql.com
5ade9e75dc Merge rurik.mysql.com:/home/igor/mysql-4.1-opt
into  rurik.mysql.com:/home/igor/mysql-5.0-opt
2006-06-02 17:06:10 -07:00
igor@rurik.mysql.com
37e049db01 Fixed bug #18206.
The bug report revealed two problems related to min/max optimization:
1. If the length of a constant key used in a SARGable condition for
for the MIN/MAX fields is greater than the length of the field an 
unwanted warning on key truncation is issued;
2. If MIN/MAX optimization is applied to a partial index, like INDEX(b(4))
than can lead to returning a wrong result set.
2006-06-02 14:14:57 -07:00
sergefp@mysql.com
be0ebd9e0a Remove redundant code in opt_sum_query() 2006-04-06 21:42:03 +04:00
igor@rurik.mysql.com
f485125968 Fixed bug #18237.
The code in opt_sum_query that prevented the COUNT/MIN/MAX 
optimization from being applied to outer joins  was not adjusted 
after introducing nested joins. As a result if an outer join
contained a reference to a view as an inner table the code of
opt_sum_query missed the presence of an on expressions and
erroneously applied the mentioned optimization.
2006-04-04 12:55:02 -07:00
igor@rurik.mysql.com
d2cfad167b Fixed bug #16016: MIN/MAX optimization was not applied to views. 2006-01-06 22:28:26 -08:00
msvensson@neptunus.(none)
fbf4a5e079 Merge neptunus.(none):/home/msvensson/mysql/mysql-4.1
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0
2005-09-28 11:34:53 +02:00
monty@mysql.com
ea6d5f9ec3 Fixed error found during review of new pushed code 2005-09-25 21:22:23 +03:00
msvensson@neptunus.(none)
d55eeed8fd Merge from 4.1 to 5.0 2005-09-23 14:37:22 +02:00
msvensson@neptunus.(none)
02c7645cc1 Merge neptunus.(none):/home/msvensson/mysql/mysql-4.1
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0
2005-09-23 09:18:56 +02:00
timour@mysql.com
6ae8a56f72 Merge mysql.com:/home/timka/mysql/src/4.1-virgin
into  mysql.com:/home/timka/mysql/src/4.1-dbg
2005-09-21 09:53:42 +03:00
timour@mysql.com
633d118d01 Fix for BUG#12882 - min/max inconsistent on empty table.
The problem was in that the MIN/MAX optimization in opt_sum_query was
replacing MIN/MAX functions with their constant argument without
taking into account that a query has no result rows.
2005-09-21 09:49:19 +03:00
evgen@moonbone.local
afa8187fb7 Fix bug #13218: InnoDB: using a partial-field key prefix in search
This is backport from 5.0 of fix for bug #11039
2005-09-19 04:39:49 +04:00
monty@mysql.com
e18bb16ee5 Fixed wrong key length when using MIN() optimization (non fatal, but caused InnoDB to write warnings to the log file)
This fixed bug #11039: InnoDB: Warning: using a partial-field key prefix in search
2005-06-06 14:03:33 +03:00
monty@mishka.local
a9f6aab4c9 Fixes while reviewing new code
Added option --count to mysqlshow (to show number of rows)
Fixed possible core dump in information schema
2005-05-06 11:39:30 +03:00
bar@mysql.com
d50d213162 Merge 2005-03-05 18:20:35 +04:00
igor@linux.local
6d7862aeaf logging_ok:
Logging to logging@openlogging.org accepted
func_group.result, func_group.test:
  Added a test case for bug #8893.
opt_sum.cc:
  A misplaced initialization for the returned parameter
  prefix_len in the function find_key_for_maxmin caused
  usage of a wrong key prefix by the min/max optimization
  in cases when the matching index was not the first index
  that contained the min/max field.
2005-03-04 20:24:13 -08:00
monty@mysql.com
d35140a851 First stage of table definition cache
Split TABLE to TABLE and TABLE_SHARE (TABLE_SHARE is still allocated as part of table, will be fixed soon)
Created Field::make_field() and made Field_num::make_field() to call this
Added 'TABLE_SHARE->db' that points to database name; Changed all usage of table_cache_key as database name to use this instead
Changed field->table_name to point to pointer to alias. This allows us to change alias for a table by just updating one pointer.
Renamed TABLE_SHARE->real_name to table_name
Renamed TABLE->table_name to alias
Renamed TABLE_LIST->real_name to table_name
2005-01-06 13:00:13 +02:00
monty@mysql.com
77207d19f2 Merge with new VARCHAR code 2004-12-06 19:18:35 +02:00
monty@mysql.com
67ce247965 Add support for up to VARCHAR (size up to 65535)
Renamed HA_VAR_LENGTH to HA_VAR_LENGTH_PART
Renamed in all files FIELD_TYPE_STRING and FIELD_TYPE_VAR_STRING to MYSQL_TYPE_STRING and MYSQL_TYPE_VAR_STRING to make it easy to catch all possible errors
Added support for VARCHAR KEYS to heap
Removed support for ISAM
Now only long VARCHAR columns are changed to TEXT on demand (not CHAR)
Internal temporary files can now use fixed length tables if the used VARCHAR columns are short
2004-12-06 02:00:37 +02:00
bell@sanja.is.com.ua
072d38eb12 merge 2004-11-21 20:08:12 +02:00
gluh@gluh.mysql.r18.ru
321f803784 WL#1629: SHOW with WHERE(partially) &
WL#173:  Create Data Dictionary Tables for SHOW Commands
2004-11-13 13:56:39 +03:00
bell@sanja.is.com.ua
0ef0b030a5 merge 2004-11-11 21:18:10 +02:00
monty@mysql.com
afbe601302 merge with 4.1 2004-10-29 19:26:52 +03:00
igor@rurik.mysql.com
a03e5ad8e4 Merge for post-merge fixes for Item_equal patch. 2004-10-19 16:07:10 -07:00
igor@rurik.mysql.com
71f6ab7a09 Merge for Item_equal. 2004-10-09 10:34:13 -07:00
igor@rurik.mysql.com
cfbd2b7f7a opt_sum.cc:
Slightly improved the fix for bug #5406.
2004-09-15 23:52:46 -07:00
bell@sanja.is.com.ua
f797298fc5 fixed merged view fields names (BUG#5147)
support of merged VIEW over several tables added (WL#1809)
2004-09-14 19:28:29 +03:00
igor@rurik.mysql.com
7777f759cb func_group.test, func_group.result:
Added test case for bug #5406.
opt_sum.cc:
  Fixed bug #5406.
2004-09-07 19:46:09 -07:00
timour@mysql.com
e2cd3dd1ce WL#1724 "Min/Max Optimization for Queries with Group By Clause"
- after-review changes
- merged with the source tree from 204-08-27
2004-08-27 16:37:13 +03:00
bell@sanja.is.com.ua
9336d36cf8 VIEW
two TABLE_LIST copy eliminated
2004-07-16 01:15:55 +03:00
monty@mysql.com
db7efa2780 New handler::index_flags() definition to make it easy to check the full used key and a specific key part.
Added key part to optimize_range() to fix problems when using fields in key parts.
2004-07-08 15:45:25 +03:00
serg@serg.mylan
08738d2847 fowwlowup fixes for index_flags() 2004-06-30 10:40:15 +02:00
serg@serg.mylan
3f1c4ba745 handler interface cleanups:
more logical table/index_flags
  return  HA_ERR_WRONG_COMMAND instead of abstract methods where appropriate
  max_keys and other limits renamed to max_supported_keys/etc
  max_keys/etc are now wrappers to max_supported_keys/etc 
  ha_index_init/ha_rnd_init/ha_index_end/ha_rnd_end are now wrappers to real {index,rnd}_{init,end} to enforce strict pairing
2004-06-23 12:29:05 +02:00