Commit graph

490 commits

Author SHA1 Message Date
Georgi Kodinov
152943f39f Bug #46807: subselect test fails on PB-2 with a crash
The check for stack overflow was independent of the size of the 
structure stored in the heap. 
Fixed by adding sizeof(PARAM) to the requested free heap size.
2009-08-19 17:53:43 +03:00
Georgi Kodinov
097c7b38c8 Bug #45287: phase 2 : 5.0 64 bit compilation warnings
Fixed various compilation warnings when compiling on a 
 64 bit windows.
2009-07-16 15:37:38 +03:00
Georgi Kodinov
3e82a86ed2 Bug #45386: Wrong query result with MIN function in field list,
WHERE and GROUP BY clause

Loose index scan may use range conditions on the argument of 
the MIN/MAX aggregate functions to find the beginning/end of 
the interval that satisfies the range conditions in a single go.
These range conditions may have open or closed minimum/maximum 
values. When the comparison returns 0 (equal) the code should 
check the type of the min/max values of the current interval 
and accept or reject the row based on whether the limit is 
open or not.
There was a wrong composite condition on checking this and it was
not working in all cases.
Fixed by simplifying the conditions and reversing the logic.

mysql-test/r/group_min_max.result:
  Bug #45386: test case
mysql-test/t/group_min_max.test:
  Bug #45386: test case
sql/opt_range.cc:
  Bug #45386: fix the check whether to use the value if on the
  interval boundry
2009-06-12 15:38:55 +03:00
Staale Smedseng
a073ee45c2 Bug #43414 Parenthesis (and other) warnings compiling MySQL
with gcc 4.3.2
      
Compiling MySQL with gcc 4.3.2 and later produces a number of 
warnings, many of which are new with the recent compiler
versions.
      
This bug will be resolved in more than one patch to limit the
size of changesets. This is the first patch, fixing a number 
of the warnings, predominantly "suggest using parentheses 
around && in ||", and empty for and while bodies.
2009-06-09 18:11:21 +02:00
Ignacio Galarza
675c3ce2bb auto-merge 2009-03-19 09:44:58 -04:00
Georgi Kodinov
15760fe9d8 Bug #41610: key_infix_len can be overwritten causing some group by queries to
return no rows

The algorithm of determining the best key for loose index scan is doing a loop
over the available indexes and selects the one that has the best cost.
It retrieves the parameters of the current index into a set of variables.
If the cost of using the current index is lower than the best cost so far it 
copies these variables into another set of variables that contain the 
information for the best index so far.
After having checked all the indexes it uses these variables (outside of the 
index loop) to create the table read plan object instance.
The was a single omission : the key_infix/key_infix_len variables were used 
outside of the loop without being preserved in the loop for the best index 
so far.
This causes these variables to get overwritten by the next index(es) checked.
Fixed by adding variables to hold the data for the current index, passing 
the new variables to the function that assigns values to them and copying 
the new variables into the existing ones when selecting a new current best 
index.
To avoid further such problems moved the declarations of the variables used 
to keep information about the current index inside the loop's compound 
statement.

mysql-test/r/group_min_max.result:
  Bug #41610: test case
mysql-test/t/group_min_max.test:
  Bug #41610: test case
sql/opt_range.cc:
  Bug #41610: copy the infix data for the current best index
2009-02-27 15:25:06 +02:00
Ignacio Galarza
54fbbf9591 Bug#29125 Windows Server X64: so many compiler warnings
- Remove bothersome warning messages.  This change focuses on the warnings 
that are covered by the ignore file: support-files/compiler_warnings.supp.
- Strings are guaranteed to be max uint in length
2009-02-10 17:47:54 -05:00
Sergey Petrunia
7658444b97 Merge 2008-12-22 23:28:08 +03:00
Sergey Petrunia
7976735a0c BUG#40974: Incorrect query results when using clause evaluated using range check
- QUICK_INDEX_MERGE_SELECT deinitializes its rnd_pos() scan when it reaches EOF, but we 
  need to make the deinitialization in QUICK_INDEX_MERGE_SELECT destructor also. This is because
  certain execution strategies can stop scanning without reaching EOF, then then try to do a full
  table scan on this table. Failure to deinitialize caused the full scan to use (already empty) 
  table->sort and produce zero records.

mysql-test/r/index_merge.result:
  BUG#40974: Incorrect query results when using clause evaluated using range check
  - Testcase
mysql-test/t/index_merge.test:
  BUG#40974: Incorrect query results when using clause evaluated using range check
  - Testcase
2008-12-19 16:38:39 +03:00
Georgi Kodinov
979974c53b backported the fix for bug #34773 to 5.0 2008-12-09 20:35:02 +02:00
Gleb Shchepa
097b60bd06 Bug #37894: Assertion in init_read_record_seq in handler.h line 1444
Select with a "NULL NOT IN" condition containing complex
subselect from the same table as in the outer select failed
with an assertion.


The failure was caused by a concatenation of circumstances:
1) an inner select was optimized by make_join_statistics to use
   the QUICK_RANGE_SELECT access method (that implies an index
   scan of the table);
2) a subselect was independent (constant) from the outer select;
3) a condition was pushed down into inner select.

During the evaluation of a constant IN expression an optimizer
temporary changed the access method from index scan to table
scan, but an engine handler was already initialized for index
access by make_join_statistics. That caused an assertion.


Unnecessary index initialization has been removed from
the QUICK_RANGE_SELECT::init method (QUICK_RANGE_SELECT::reset
reinvokes this initialization).


mysql-test/r/subselect3.result:
  Added test case for bug #37894.
mysql-test/t/subselect3.test:
  Added test case for bug #37894.
sql/opt_range.cc:
  Bug #37894: Assertion in init_read_record_seq in handler.h line 1444
  
  Unnecessary index initialization has been removed from
  the QUICK_RANGE_SELECT::init method (QUICK_RANGE_SELECT::reset
  reinvokes this initialization).
2008-10-10 15:27:58 +05:00
Georgi Kodinov
eb3c08069d Bug#37943: Reproducible mysqld crash/sigsegv in sel_trees_can_be_ored
When analyzing the possible index use cases the server was re-using an internal structure.
This is wrong, as this internal structure gets updated during the analysis.
Fixed by making a copy of the internal structure for every place it needs to be used.
Also stopped the generation of empty SEL_TREE structures that unnecessary 
complicate the analysis.

mysql-test/r/index_merge.result:
  Bug#37943: test case
mysql-test/t/index_merge.test:
  Bug#37943: test case
sql/opt_range.cc:
  Bug#37943: 
   - Make copy constructors for SEL_TREE and sub-structures and use them when OR-ing trees.
   - don't generate empty SEL_TREEs. Return NULL instead.
2008-10-01 18:50:55 +03:00
Sergey Petrunia
c770161ae8 BUG#36639: subselect.test crashes on 64 bit pentium4 when compiled for valgrind, commit into 5.0
- Use the compiler's default copy constructor for QUICK_RANGE_SELECT. 
  bcopy(this, copy, ...) call caused some odd action on gcc-4.1.2 on x86_64

sql/opt_range.cc:
  BUG#36639: subselect.test crashes on 64 bit pentium4 when compiled for valgrind
  - Set QUICK_SELECT_DESC not to use MRR implementation (code moved to here
    from opt_range.h)
sql/opt_range.h:
  BUG#36639: subselect.test crashes on 64 bit pentium4 when compiled for valgrind
  - Use the compiler's default copy constructor for QUICK_RANGE_SELECT. 
    bcopy(this, copy, ...) call caused some odd action on gcc-4.1.2 on x86_64
2008-08-25 21:02:54 +04:00
Georgi Kodinov
dd85aa78ba Bug#37830 : ORDER BY ASC/DESC - no difference
Range scan in descending order for c <= <col> <= c type of
ranges was ignoring the DESC flag.
However some engines like InnoDB have the primary key parts 
as a suffix for every secondary key.
When such primary key suffix is used for ordering ignoring 
the DESC is not valid.
But we generally would like to do this because it's faster.
            
Fixed by performing only reverse scan if the primary key is used.
Removed some dead code in the process.

mysql-test/r/innodb_mysql.result:
  Bug#37830 : test case
mysql-test/t/innodb_mysql.test:
  Bug#37830 : test case
sql/opt_range.cc:
  Bug#37830 : 
  - preserve and use used_key_parts to
    distinguish when a primary key suffix is used
  - removed some dead code
sql/opt_range.h:
  Bug#37830 : 
  - preserve used_key_parts
  - dead code removed
sql/sql_select.cc:
  Bug#37830 : Do only reverse order traversal
  if the primary key suffix is used.
2008-07-23 14:25:00 +03:00
Sergey Petrunia
62513bb1bc BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
- In QUICK_INDEX_MERGE_SELECT::read_keys_and_merge: when we got table->sort from Unique,
  tell init_read_record() not to use rr_from_cache() because a) rowids are already sorted
  and b) it might be that the the data is used by filesort(), which will need record rowids
  (which rr_from_cache() cannot provide).
- Fully de-initialize the table->sort read in QUICK_INDEX_MERGE_SELECT::get_next(). This fixes BUG#35477.
(bk trigger: file as fix for BUG#35478).

sql/filesort.cc:
  BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
  - make find_all_keys() use quick->get_next() instead of init_read_record(r)/r.read_record() calls
  - added dbug printout
sql/mysql_priv.h:
  BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
  - Added parameter to init_read_record
sql/opt_range.cc:
  BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
  - In QUICK_INDEX_MERGE_SELECT::read_keys_and_merge: when we got table->sort from Unique,
    tell init_read_record() not to use rr_from_cache() because a) rowids are already sorted
    and b) it might be that the the data is used by filesort(), which will need record rowids
    (which rr_from_cache() cannot provide).
  - Fully de-initialize the table->sort read in QUICK_INDEX_MERGE_SELECT::get_next().
sql/records.cc:
  BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
  - Added disable_rr_cache parameter to init_read_record
  - Added comment
sql/sql_acl.cc:
  BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
  - Added parameter to init_read_record
sql/sql_delete.cc:
  BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
  - Added parameter to init_read_record
sql/sql_help.cc:
  BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
  - Added parameter to init_read_record
sql/sql_select.cc:
  BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
  - Added parameter to init_read_record
sql/sql_table.cc:
  BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
  - Added parameter to init_read_record
sql/sql_udf.cc:
  BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
  - Added parameter to init_read_record
sql/sql_update.cc:
  BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
  - Added parameter to init_read_record
2008-07-15 18:13:21 +04:00
unknown
a9089cf460 Bug#26243 mysql command line crash after control-c
- Backported the 5.1 DBUG to 5.0.
- Avoid memory cleanup race on Windows client for CTRL-C


client/mysql.cc:
  Bug#26243 mysql command line crash after control-c
  - On Windows, the sigint handler shouldn't call mysql_end
  because the main thread will do so automatically.
  - Remove unnecessary signal call from the sigint handler.
  - Call my_end with proper value.
dbug/dbug.c:
  Bug#26243 mysql command line crash after control-c
  - Backported the 5.1 DBUG library. The old version uses a non-thread 
  safe global variable 'static struct state *stack'.
dbug/factorial.c:
  Bug#26243 mysql command line crash after control-c
  - Backported the 5.1 DBUG library. The old version uses a non-thread 
  safe global variable 'static struct state *stack'.
dbug/user.r:
  Bug#26243 mysql command line crash after control-c
  - Backported the 5.1 DBUG library. The old version uses a non-thread 
  safe global variable 'static struct state *stack'.
include/my_dbug.h:
  Bug#26243 mysql command line crash after control-c
  - Backported the 5.1 DBUG library. The old version uses a non-thread 
  safe global variable 'static struct state *stack'.
libmysql/libmysql.c:
  Bug#26243 mysql command line crash after control-c
  - Update for new DBUG library.
myisam/mi_open.c:
  Bug#26243 mysql command line crash after control-c
  - Update for new DBUG library.
sql/ha_federated.cc:
  Bug#26243 mysql command line crash after control-c
  - Update for new DBUG library.
sql/ha_innodb.cc:
  Bug#26243 mysql command line crash after control-c
  - Update for new DBUG library.
sql/ha_myisammrg.cc:
  Bug#26243 mysql command line crash after control-c
  - Update for new DBUG library.
sql/item_cmpfunc.cc:
  Bug#26243 mysql command line crash after control-c
  - Update for new DBUG library.
sql/mysqld.cc:
  Bug#26243 mysql command line crash after control-c
  - Update for new DBUG library.
sql/net_serv.cc:
  Bug#26243 mysql command line crash after control-c
  - Update for new DBUG library.
sql/opt_range.cc:
  Bug#26243 mysql command line crash after control-c
  - Update for new DBUG library.
sql/set_var.cc:
  Bug#26243 mysql command line crash after control-c
  - Update for new DBUG library.
sql/slave.cc:
  Bug#26243 mysql command line crash after control-c
  - Update for new DBUG library.
sql/sql_cache.cc:
  Bug#26243 mysql command line crash after control-c
  - Update for new DBUG library.
sql/sql_select.cc:
  Bug#26243 mysql command line crash after control-c
  - Update for new DBUG library.
tests/mysql_client_test.c:
  Bug#26243 mysql command line crash after control-c
  - Update for new DBUG library.
2008-03-28 14:02:27 -04:00
unknown
ec62aba3f0 Bug#34731: highest possible value for INT erroneously filtered by WHERE
WHERE f1 < n ignored row if f1 was indexed integer column and
f1 = TYPE_MAX ^ n = TYPE_MAX+1. The latter value when treated
as TYPE overflowed (obviously). This was not handled, it is now.


mysql-test/r/range.result:
  show that on an index int column, we no longer disregard
  a field val of TYPE_MAX in SELECT ... WHERE ... < TYPE_MAX+1
mysql-test/t/range.test:
  show that on an index int column, we no longer disregard
  a field val of TYPE_MAX in SELECT ... WHERE ... < TYPE_MAX+1
sql/opt_range.cc:
  Handle overflowing of int-types in range-optimizer.
  Unfortunately requires re-indentation of entire block.
  Overflow (err == 1) was handled, but only if
  field->cmp_type() != value->result_type(), which it
  just wasn't in our case.
2008-03-10 11:12:12 +01:00
unknown
33f82b1789 Merge mysql.com:/home/gluh/MySQL/Merge/5.0
into  mysql.com:/home/gluh/MySQL/Merge/5.0-opt


client/mysql.cc:
  Auto merged
client/mysqltest.c:
  Auto merged
include/mysql_com.h:
  Auto merged
libmysql/CMakeLists.txt:
  Auto merged
myisam/mi_check.c:
  Auto merged
mysql-test/r/delayed.result:
  Auto merged
mysql-test/r/innodb.result:
  Auto merged
mysql-test/r/myisam.result:
  Auto merged
mysql-test/r/ps.result:
  Auto merged
mysql-test/t/merge.test:
  Auto merged
mysql-test/t/myisam.test:
  Auto merged
mysql-test/t/subselect.test:
  Auto merged
mysql-test/t/type_datetime.test:
  Auto merged
mysql-test/t/variables.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/ha_myisam.cc:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/r/func_misc.result:
  manual merge
mysql-test/r/innodb_mysql.result:
  manual merge
mysql-test/t/func_misc.test:
  manual merge
mysql-test/t/innodb_mysql.test:
  manual merge
sql/sql_insert.cc:
  manual merge
2007-12-13 14:52:49 +04:00
unknown
c6675cd187 BUG#32198: Comparison of DATE with DATETIME still not using indexes correctly
- Make conditions like "date_col $CMP$ 'datetime-const'" range-sargable


mysql-test/r/range.result:
  BUG#32198: Comparison of DATE with DATETIME still not using indexes correctly
  - Testcase
mysql-test/t/range.test:
  BUG#32198: Comparison of DATE with DATETIME still not using indexes correctly
  - Testcase
sql/field.cc:
  BUG#32198: Comparison of DATE with DATETIME still not using indexes correctly
  - Added comments
2007-12-13 13:38:22 +03:00
unknown
55a420e134 Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-5.0
into  ramayana.hindu.god:/home/tsmith/m/bk/maint/50


client/mysqldump.c:
  Auto merged
include/my_sys.h:
  Auto merged
libmysql/CMakeLists.txt:
  Auto merged
libmysql/Makefile.shared:
  Auto merged
myisam/ft_boolean_search.c:
  Auto merged
myisam/sort.c:
  Auto merged
mysql-test/t/cast.test:
  Auto merged
mysql-test/t/variables.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/ha_myisam.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_cmpfunc.h:
  Auto merged
sql/item_timefunc.cc:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
mysql-test/mysql-test-run.pl:
  Manual merge
mysql-test/r/ctype_ucs.result:
  Manual merge
mysql-test/r/func_misc.result:
  Manual merge
mysql-test/t/binlog_killed.test:
  Manual merge
mysql-test/t/ctype_ucs.test:
  Manual merge
mysql-test/t/func_misc.test:
  Manual merge
sql/item_strfunc.h:
  Manual merge
strings/ctype-simple.c:
  Manual merge
2007-12-04 20:58:21 -07:00
unknown
a5799544cd Merge gleb.loc:/work/bk/5.0-opt-32403
into  gleb.loc:/work/bk/5.0-opt


sql/opt_range.cc:
  Auto merged
2007-11-27 19:28:27 +04:00
unknown
d068dd1aab Fixed bug #32403: query causes a crash due to stack and
memory corruptions.

The right pointer field of the SEL_ARG structure was not
initialized in the constructor and sometimes that led to
server crashes.

There is no testcase because the bug occurs only when
uninitialized memory has particular values, which can't be
re-created in the test suite.


sql/opt_range.cc:
  Fixed bug #32403.
  
  The eq_tree function requires that SEL_ARG::left and
  SEL_ARG::right are equal to null pointer if SEL_ARG
  type is MAYBE_KEY, but SEL_ARG::right was not initialized
  and contained garbage.
2007-11-27 19:14:48 +04:00
unknown
a197c4e95d opt_range.cc:
Fix for the bug#31048 for 64bit platforms.
subselect.test, subselect.result:
  Corrected text case for the bug#31048.


mysql-test/t/subselect.test:
  Corrected text case for the bug#31048.
mysql-test/r/subselect.result:
  Corrected text case for the bug#31048.
sql/opt_range.cc:
  Fix for the bug#31048 for 64bit platforms.
2007-11-23 00:16:17 +03:00
unknown
13105534fa Bug#31048: Many nested subqueries may cause server crash.
This bug is actually two. The first one manifests itself on an EXPLAIN
SELECT query with nested subqueries that employs the filesort algorithm.
The whole SELECT under explain is marked as UNCACHEABLE_EXPLAIN to preserve
some temporary structures for explain. As a side-effect of this values of
nested subqueries weren't cached and subqueries were re-evaluated many
times. Each time buffer for filesort was allocated but wasn't freed because
freeing occurs at the end of topmost SELECT. Thus all available memory was
eaten up step by step and OOM event occur.
The second bug manifests itself on SELECT queries with conditions where
a subquery result is compared with a key field and the subquery itself also
has such condition. When a long chain of such nested subqueries is present
the stack overrun occur. This happens because at some point the range optimizer
temporary puts the PARAM structure on the stack. Its size if about 8K and
the stack is exhausted very fast.

Now the subselect_single_select_engine::exec function allows subquery result
caching when the UNCACHEABLE_EXPLAIN flag is set.
Now the SQL_SELECT::test_quick_select function calls the check_stack_overrun
function for stack checking purposes to prevent server crash.


mysql-test/t/subselect.test:
  Added a test case for the bug#31048: Many nested subqueries may cause server crash.
mysql-test/r/subselect.result:
  Added a test case for the bug#31048: Many nested subqueries may cause server crash.
sql/opt_range.cc:
  Bug#31048: Many nested subqueries may cause server crash.
  Now the SQL_SELECT::test_quick_select function calls the check_stack_overrun
  function for stack checking purposes to preven server crash.
sql/item_subselect.cc:
  Bug31048: Many nested subqueries may cause server crash.
  Now the subselect_single_select_engine::exec function allows subquery result
  caching when the UNCACHEABLE_EXPLAIN flag is set.
2007-11-19 20:00:25 +00:00
unknown
4e5c8bc7e0 type conversions fixed to get rid of warnings
sql/ha_heap.cc:
  type conversion fix
sql/opt_range.cc:
  type conversion fix
2007-10-23 16:32:05 +05:00
unknown
8262c4f445 type conversion fixed to get rid of warnings
sql/opt_range.cc:
  type conversion fixed
2007-10-23 15:34:10 +05:00
unknown
e1dc86b079 type conversions fixed to avoid warnings on Windows
myisam/mi_write.c:
  type conversion fixed
myisam/sort.c:
  type conversion fixed
sql/ha_federated.cc:
  type conversion fixed
sql/ha_heap.cc:
  type conversion fixed
sql/ha_innodb.cc:
  type conversion fixed
sql/ha_myisam.cc:
  type conversion fixed
sql/opt_range.cc:
  type conversion fixed
sql/sql_map.cc:
  type conversion fixed
sql/sql_select.cc:
  type conversion fixed
sql/sql_update.cc:
  type conversion fixed
2007-10-23 14:27:11 +05:00
unknown
ce8bf087b0 Fix for bug #31207: Test "join_nested" shows different strategy on IA64
CPUs / Intel's ICC compile

The bug is a combination of two problems:

1. IA64/ICC MySQL binaries use glibc's qsort(), not the one in mysys.

2. The order relation implemented by join_tab_cmp() is not transitive,
i.e. it is possible to choose such a, b and c that (a < b) && (b < c)
but (c < a). This implies that result of a sort using the relation
implemented by join_tab_cmp() depends on the order in which
elements are compared, i.e. the result is implementation-specific. Since
choose_plan() uses qsort() to pre-sort the
join tables using join_tab_cmp() as a compare function, the results of
the sorting may vary depending on qsort() implementation.

It is neither possible nor important to implement a better ordering
algorithm in join_tab_cmp(). Therefore the only way to fix it is to
force our own qsort() to be used by renaming it to my_qsort(), so we don't depend
on linker to decide that.

This patch also "fixes" bug #20530: qsort redefinition violates the
standard.


include/my_sys.h:
  Renamed qsort() and qsort2() to my_qsort() and my_qsort2(). Since
  previously we relied on stdlib.h to provide a declaration for qsort(), a
  separate declaration for my_qsort() is now required.
libmysql/Makefile.shared:
  Added mf_qsort.c to libmysql, since my_lib.c now uses my_qsort() instead of qsort().
myisam/ft_boolean_search.c:
  Replaced qsort2() with my_qsort2().
myisam/ft_nlq_search.c:
  Replaced qsort2() with my_qsort2().
myisam/myisampack.c:
  Replaced qsort() with my_qsort().
myisam/sort.c:
  Replaced qsort2() with my_qsort2().
mysys/mf_keycache.c:
  Replaced qsort() with my_qsort().
mysys/mf_qsort.c:
  Renamed qsort() to my_qsort() and qsort2() to my_qsort2().
mysys/mf_sort.c:
  Replaced qsort2() with my_qsort2().
mysys/my_lib.c:
  Replaced qsort() with my_qsort().
mysys/queues.c:
  Replaced qsort2() with my_qsort2().
sql/item_cmpfunc.cc:
  Replaced qsort2() with my_qsort2().
sql/item_cmpfunc.h:
  Replaced qsort2() with my_qsort2().
sql/opt_range.cc:
  Replaced qsort() with my_qsort().
sql/records.cc:
  Replaced qsort() with my_qsort().
sql/sql_acl.cc:
  Replaced qsort() with my_qsort().
sql/sql_array.h:
  Replaced qsort() with my_qsort().
sql/sql_help.cc:
  Replaced qsort() with my_qsort().
sql/sql_select.cc:
  Replaced qsort() with my_qsort().
sql/examples/ha_tina.cc:
  Replaced qsort() with my_qsort().
sql/sql_table.cc:
  Replaced qsort() with my_qsort().
2007-10-17 20:08:58 +04:00
unknown
0068c18930 Better wording in comments 2007-09-12 18:13:19 +04:00
unknown
9d466ad479 Merge mysql.com:/home/psergey/mysql-4.1-bug30385
into  mysql.com:/home/psergey/mysql-5.0-bug30385


sql/opt_range.cc:
  Auto merged
mysql-test/r/delete.result:
  Manual merge
mysql-test/t/delete.test:
  Manual merge
2007-09-11 02:24:08 +04:00
unknown
732f05a642 BUG#30385: Server crash when deleting with ORDER BY and LIMIT
in get_index_for_order(), don't walk over the end of the index key parts
when matching index description and needed ordering.


mysql-test/r/delete.result:
  BUG#30385: Testcase
mysql-test/t/delete.test:
  BUG#30385: Testcase
2007-09-10 16:26:51 +04:00
unknown
f4a163c3a5 Merge mhansson@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  dl145s.mysql.com:/data0/mhansson/my50-bug28570


sql/opt_range.cc:
  Auto merged
mysql-test/r/innodb_mysql.result:
  Bug#28570: Manual Merge
mysql-test/t/innodb_mysql.test:
  Bug#28570: Manual Merge
2007-08-16 14:13:07 +02:00
unknown
01f8130aa6 bug#28570: handler::index_read() is called with different find_flag when
ORDER BY is used

The range analysis module did not correctly signal to the 
handler that a range represents a ref (EQ_RANGE flag). This causes 
non-range queries like 
SELECT ... FROM ... WHERE keypart_1=const, ..., keypart_n=const 
ORDER BY ... FOR UPDATE
to wait for a lock unneccesarily if another running transaction uses
SELECT ... FOR UPDATE on the same table.

Fixed by setting EQ_RANGE for all range accesses that represent 
an equality predicate. 


mysql-test/r/innodb_mysql.result:
  bug#28570: Test Result
mysql-test/t/innodb_mysql.test:
  bug#28570: Test Case
sql/handler.cc:
  bug#28570: Updated comment
sql/opt_range.cc:
  bug#28570: Removed the criterion that key has to be unique (HA_NOSAME) in 
  order for the EQ_RANGE flag to be set. It is sufficient that the range 
  represent a ref access.
2007-08-15 09:23:44 +02:00
unknown
0936976e8d A fix and a test case for Bug#24918 drop table and lock / inconsistent
between perm and temp tables. Review fixes.

The original bug report complains that if we locked a temporary table
with LOCK TABLES statement, we would not leave LOCK TABLES mode
when this temporary table is dropped.

Additionally, the bug was escalated when it was discovered than
when a temporary transactional table that was previously
locked with LOCK TABLES statement was dropped, futher actions with
this table, such as UNLOCK TABLES, would lead to a crash.

The problem originates from incomplete support of transactional temporary
tables. When we added calls to handler::store_lock()/handler::external_lock()
to operations that work with such tables, we only covered the normal
server code flow and did not cover LOCK TABLES mode. 
In LOCK TABLES mode, ::external_lock(LOCK) would sometimes be called without
matching ::external_lock(UNLOCK), e.g. when a transactional temporary table
was dropped. Additionally, this table would be left in the list of LOCKed 
TABLES.

The patch aims to address this inadequacy. Now, whenever an instance
of 'handler' is destroyed, we assert that it was priorly
external_lock(UNLOCK)-ed. All the places that violate this assert
were fixed.

This patch introduces no changes in behavior -- the discrepancy in
behavior will be fixed when we start calling ::store_lock()/::external_lock()
for all tables, regardless whether they are transactional or not, 
temporary or not.


mysql-test/r/innodb_mysql.result:
  Update test results (Bug#24918)
mysql-test/t/innodb_mysql.test:
  Add a test case for Bug#24918
sql/handler.h:
  Make handler::external_lock() a protected method. Backport from 5.1 its
  public wrapper handler::ha_external_lock().
  Assert that the handler is not closed if it is still locked.
sql/lock.cc:
  In mysql_lock_tables only call lock_external() for the list of tables that
  we called store_lock() for. 
  E.g. get_lock_data() does not add non-transactional temporary tables to the
  lock list, so lock_external() should not be called for them.
  
  Use handler::ha_external_lock() instead of handler::external_lock().
  
  Add comments for mysql_lock_remove(), parameterize one strange
  side effect that it has. At least in one place where mysql_lock_remove
  is used, this side effect is not desired (DROP TABLE). The parameter
  will be dropped in 5.1, along with the side effect.
sql/mysql_priv.h:
  Update declaration of mysql_lock_remove().
sql/opt_range.cc:
  Deploy handler::ha_external_lock() instead of handler::external_lock()
sql/sql_base.cc:
  When closing a temporary table, remove the table from the list of LOCKed 
  TABLES of this thread, in case it's there. 
  It's there if it is a transactional temporary table.
  Use a new declaration of mysql_lock_remove().
sql/sql_class.h:
  Extend the comment for THD::temporary_tables.
sql/sql_table.cc:
  Deploy handler::ha_external_lock() instead of handler::external_lock()
2007-07-27 16:37:29 +04:00
unknown
043f697aee Mark deadcode for gcov 2007-07-18 00:29:25 +04:00
unknown
2679e53a73 Small comments fix 2007-07-17 22:46:51 +04:00
unknown
955c19961d [pb problem]: ha_heap->clone() fails on windows because of mess with
'/' and '\' in path delimiters:
- Fix this by creating new handler with exactly the same path line as
  was passed to ha_create/ha_open.


sql/opt_range.cc:
  Set thd->net.report_error on handler::clone() failure
2007-07-17 19:51:50 +04:00
unknown
38f4c6137a BUG#29740: Wrong query results for index_merge/union over HEAP table.
- return HA_KEY_SCAN_NOT_ROR flag for HASH indexes;
- Fix ha_heap::cmp_ref() to work with BTREE index scans.


mysql-test/r/index_merge.result:
  BUG#29740: testcase
mysql-test/t/index_merge.test:
  BUG#29740: testcase
sql/ha_heap.h:
  BUG#29740: Wrong query results for index_merge/union over HEAP table.
  - make HEAP table engine return HA_KEY_SCAN_NOT_ROR flag for HASH 
    indexes,as HASH index does not guarantee any ordering for rows
    within the hash bucket.
  - Fix BTREE indexes: make ha_heap::cmp_ref() compare the rowids in the 
    same way as ha_key_cmp() does.
sql/opt_range.cc:
  BUG#29740: Fix comment about ROR scans.
2007-07-13 19:13:40 +04:00
unknown
2016b21ce1 BUG#26624, pushbuild fixes: Merge to 5.0
mysql-test/r/range.result:
  Auto merged
mysql-test/t/range.test:
  Auto merged
2007-03-31 00:48:31 +04:00
unknown
080c0c7ac8 BUG#26624: high mem usage (crash) in range optimizer
Pushbuild fixes: 
 - Make MAX_SEL_ARGS smaller (even 16K records_in_range() calls is 
   more than it makes sense to do in typical cases)
 - Don't call sel_arg->test_use_count() if we've already allocated 
   more than MAX_SEL_ARGs elements. The test will succeed but will take
   too much time for the test suite (and not provide much value).


mysql-test/r/range.result:
  BUG#26624: high mem usage (crash) in range optimizer
  Pushbuild fixes: make the test go faster
mysql-test/t/range.test:
  BUG#26624: high mem usage (crash) in range optimizer
  Pushbuild fixes: make the test go faster
2007-03-31 00:29:18 +04:00
unknown
bedd5b8766 Merge of BUG#26624 and BUG#26625
mysql-test/r/range.result:
  Auto merged
mysql-test/t/range.test:
  Auto merged
2007-03-29 10:35:28 +04:00
unknown
9b358f811b BUG#26624: high mem usage (crash) in range optimizer
- Post-review fixes
2007-03-29 10:27:58 +04:00
unknown
9639eb3dda BUG#26624: high mem usage (crash) in range optimizer
- Added PARAM::alloced_sel_args where we count the # of SEL_ARGs
  created by SEL_ARG tree cloning operations.
- Made the range analyzer to shortcut and not do any more cloning 
  if we've already created MAX_SEL_ARGS SEL_ARG objects in cloning.
- Added comments about space complexity of SEL_ARG-graph 
  representation.


mysql-test/r/range.result:
  BUG#26624: Testcase
mysql-test/t/range.test:
  BUG#26624: Testcase
2007-03-28 20:16:01 +04:00
unknown
bac27bb9f5 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/autopush/B24484-5.0


mysql-test/r/subselect3.result:
  Auto merged
sql/item.h:
  Auto merged
sql/item_sum.cc:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
2007-03-20 19:49:38 +02:00
unknown
9c89dd654e Bug #24484:
To correctly decide which predicates can be evaluated with a given table
the optimizer must know the exact set of tables that a predicate depends 
on. If that mask is too wide (refer to non-existing tables) the optimizer
can erroneously skip a predicate.
One such case of wrong table usage mask were the aggregate functions.
The have a all-1 mask (meaning depend on all tables, including non-existent
ones).
Fixed by making a real used_tables mask for the aggregates. The mask is
constructed in the following way :
1. OR the table dependency masks of all the arguments of the aggregate.
2. If all the arguments of the function are from the local name resolution 
  context and it is evaluated in the same name resolution
  context where it is referenced all the tables from that name resolution 
  context are OR-ed to the dependency mask. This is to denote that an
  aggregate function depends on the number of rows it processes.
3. Handle correctly the case of an aggregate function optimization (such that
  the aggregate function can be pre-calculated and made a constant).

Made sure that an aggregate function is never a constant (unless subject of a 
specific optimization and pre-calculation).  

One other flaw was revealed and fixed in the process : references were 
not calling the recalculation method for used_tables of their targets.


mysql-test/r/subselect3.result:
  Bug #24484: test case
mysql-test/t/subselect3.test:
  Bug #24484: test case
sql/item.h:
  Bug #24484: Item_ref must update the used tables.
sql/item_sum.cc:
  Bug #24484: correct calculation of used_tables for aggregates.
sql/item_sum.h:
  Bug #24484: correct calculation of used_tables for aggregates.
sql/opt_range.cc:
  Bug #24484: fixed ref resolution in loose index scan
sql/sql_base.cc:
  Bug #24484: moved counting of leaf tables inside 
  setup_tables_and_check_access.
sql/sql_class.h:
  Bug #24484: changed table count to more narrow type.
sql/sql_insert.cc:
  Bug #24484: moved counting of leaf tables inside 
  setup_tables_and_check_access. Substract the first
  table (and its subtables) of an INSERT statement
  from leaf_count.
sql/sql_select.cc:
  Bug #24484: correct check for aggregates
2007-03-20 19:46:02 +02:00
unknown
4d6ad7ac60 Fixed bug #26830: a crash for the query with a subselect containing ROLLUP.
Crash happened because the function get_best_group_min_max detected
joins with ROLLUP incorrectly.


mysql-test/r/olap.result:
  Added a test case for bug #26830.
mysql-test/t/olap.test:
  Added a test case for bug #26830.
2007-03-10 02:47:47 -08:00
unknown
1384e64005 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/my/mysql-5.0


BitKeeper/etc/ignore:
  auto-union
BUILD/SETUP.sh:
  Auto merged
Makefile.am:
  Auto merged
client/mysql.cc:
  Auto merged
cmd-line-utils/readline/display.c:
  Auto merged
configure.in:
  Auto merged
extra/yassl/include/buffer.hpp:
  Auto merged
extra/yassl/include/crypto_wrapper.hpp:
  Auto merged
extra/yassl/include/yassl_imp.hpp:
  Auto merged
extra/yassl/include/yassl_int.hpp:
  Auto merged
extra/yassl/src/crypto_wrapper.cpp:
  Auto merged
extra/yassl/taocrypt/include/algebra.hpp:
  Auto merged
extra/yassl/taocrypt/include/des.hpp:
  Auto merged
extra/yassl/taocrypt/include/hash.hpp:
  Auto merged
extra/yassl/taocrypt/include/hmac.hpp:
  Auto merged
extra/yassl/taocrypt/include/modarith.hpp:
  Auto merged
extra/yassl/taocrypt/include/modes.hpp:
  Auto merged
extra/yassl/taocrypt/include/rsa.hpp:
  Auto merged
extra/yassl/taocrypt/include/type_traits.hpp:
  Auto merged
extra/yassl/taocrypt/mySTL/list.hpp:
  Auto merged
extra/yassl/taocrypt/src/aes.cpp:
  Auto merged
extra/yassl/taocrypt/src/algebra.cpp:
  Auto merged
extra/yassl/testsuite/testsuite.cpp:
  Auto merged
include/my_global.h:
  Auto merged
include/my_pthread.h:
  Auto merged
libmysqld/lib_sql.cc:
  Auto merged
myisam/mi_open.c:
  Auto merged
mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/r/mysqltest.result:
  Auto merged
mysql-test/t/mysqltest.test:
  Auto merged
mysys/default.c:
  Auto merged
ndb/src/common/transporter/Transporter.cpp:
  Auto merged
ndb/src/common/util/File.cpp:
  Auto merged
ndb/src/common/util/SocketClient.cpp:
  Auto merged
ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp:
  Auto merged
ndb/src/kernel/blocks/dbtc/Dbtc.hpp:
  Auto merged
ndb/src/kernel/blocks/qmgr/Qmgr.hpp:
  Auto merged
ndb/src/kernel/blocks/qmgr/QmgrMain.cpp:
  Auto merged
ndb/src/mgmapi/mgmapi.cpp:
  Auto merged
ndb/src/mgmclient/CommandInterpreter.cpp:
  Auto merged
ndb/src/mgmsrv/ConfigInfo.cpp:
  Auto merged
ndb/src/mgmsrv/MgmtSrvr.cpp:
  Auto merged
ndb/src/ndbapi/ClusterMgr.hpp:
  Auto merged
ndb/src/ndbapi/Ndb.cpp:
  Auto merged
ndb/src/ndbapi/NdbScanOperation.cpp:
  Auto merged
ndb/src/ndbapi/SignalSender.cpp:
  Auto merged
sql/field.cc:
  Auto merged
sql/filesort.cc:
  Auto merged
sql/ha_myisammrg.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/item_cmpfunc.h:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/item_subselect.h:
  Auto merged
sql/item_sum.cc:
  Auto merged
sql/item_timefunc.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/net_serv.cc:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/opt_range.h:
  Auto merged
sql/repl_failsafe.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/slave.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_union.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
sql-common/client.c:
  Auto merged
sql/sql_view.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/table.cc:
  Auto merged
sql/unireg.cc:
  Auto merged
extra/yassl/taocrypt/src/asn.cpp:
  Manual merge (Fix shadowed variable name)
extra/yassl/taocrypt/test/test.cpp:
  No changes
ndb/src/common/util/ConfigValues.cpp:
  Manual merge (Fix shadowed variable name)
sql/field.h:
  manual merge
sql/ha_myisam.cc:
  manual merge
sql/ha_ndbcluster.cc:
  manual merge
sql/item_cmpfunc.cc:
  manual merge
sql/item_subselect.cc:
  Manual merge (Fix shadowed variable name)
sql/mysqld.cc:
  no changes
2007-02-21 14:07:08 +02:00
unknown
7ca34a798f valgrind error fix 2007-02-12 19:28:49 +04:00
unknown
3e4f834dfb Fixed bug #26159.
A wrong order of statements in QUICK_GROUP_MIN_MAX_SELECT::reset
caused a crash when a query with DISTINCT was executed by a loose scan
for an InnoDB table that had been emptied. 


mysql-test/r/innodb_mysql.result:
  Added a test case for bug #26159.
mysql-test/t/innodb_mysql.test:
  Added a test case for bug #26159.
sql/opt_range.cc:
  Fixed bug #26159.
  A wrong order of statements in QUICK_GROUP_MIN_MAX_SELECT::reset
  caused a crash when a query with DISTINCT was executed by a loose scan
  for an InnoDB table that had been emptied. 
  For an empty table quick_prefix_select->reset() was not called at all
  and thus some important initialization steps were missing.
2007-02-10 23:55:56 -08:00
unknown
e0d8e8fd09 Fix bug #24035.
This performance degradation for UPDATEs could be observed in the update
statements for which the search key cannot be converted to any valid
value of the type of the search column, like for a  the condition
int_fld=99999999999999999999999999, though it can be guaranteed here
that there is no row with such a key value. 


mysql-test/r/update.result:
  Added a test case for bug #24035.
mysql-test/t/update.test:
  Added a test case for bug #24035.
sql/opt_range.cc:
  Fix bug #24035.
  This performance degradation for could be observed in the update
  statements for which the search key cannot be converted to any valid
  value of the type of the search column, like for a  the condition
  int_fld=99999999999999999999999999, though it can be guaranteed here
  that there is no row with such a key value. 
  Now the function get_mm_leaf creates trees of the type SEL_ARG::IMPOSSIBLE 
  for such conditions that tells the range scan not to perform any search
  at all.
2007-02-02 15:22:10 -08:00