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.
into moonbone.local:/work/15538-bug-5.0-mysql
mysql-test/r/select.result:
Auto merged
mysql-test/t/select.test:
Auto merged
sql/sql_yacc.yy:
Auto merged
Absence of table in left part of LEFT/RIGHT join wasn't checked before
name resolution which resulted in NULL dereferencing and server crash.
Modified rules:
"table_ref LEFT opt_outer JOIN_SYM table_ref" and "table_ref RIGHT opt_outer
JOIN_SYM table_ref"
NULL check is moved before push_new_name_resolution_context()
sql/sql_yacc.yy:
Fixed bug #15538: unchecked table absence caused server crash.
Modified rules:
"table_ref LEFT opt_outer JOIN_SYM table_ref" and "table_ref RIGHT opt_outer
JOIN_SYM table_ref"
NULL check is moved before push_new_name_resolution_context()
mysql-test/r/select.result:
Added test case for bug #15538: unchecked table absence caused server crash.
mysql-test/t/select.test:
Added test case for bug #15538: unchecked table absence caused server crash.
functions are involved.
When subselect is a join with set functions and no record have been found in
it, end_send_group() sets null_row for all tables in order aggregate functions
to calculate their values correctly. Normally this null_row flag is cleared for
each table in sub_select(), but flush_cached_records() doesn't do so.
Due to this all fields from the table processed by flush_cached_records() are
always evaluated as nulls and whole select produces wrong result.
flush_cached_records() now clears null_row flag at the very beginning.
mysql-test/t/select.test:
Added test case for bug #15347: Wrong result of subselect when records cache
and set functions are involved
mysql-test/r/select.result:
Added test case for bug #15347: Wrong result of subselect when records cache
and set functions are involved
sql/sql_select.cc:
Fixed bug #15347: Wrong result of subselect when records cache and set functions are involved
flush_cached_records() now clears null_row flag at the very beginning.
select result
Item equal objects are employed only at the optimize phase. Usually they are not
supposed to be evaluated. Yet in some cases we call the method val_int() for
them. Here we have to take care of restricting the predicate such an object
represents f1=f2= ...=fn to the projection of known fields fi1=...=fik.
Added a check for field's table being const in Item_equal::val_int().
If the field's table is not const val_int() just skips that field when
evaluating Item_equal.
mysql-test/t/select.test:
Added test case for bug #15633: Evaluation of Item_equal for non-const table caused wrong select result
mysql-test/r/select.result:
Added test case for bug #15633: Evaluation of Item_equal for non-const table caused wrong select result
mysql-test/r/func_group.result:
Corrected test result for bug #12882 after fix for bug#15633
sql/item_cmpfunc.h:
Fixed bug #15633: Evaluation of Item_equal for non-const table caused wrong select result
Added comment about fields from non-const tables in class description.
sql/item_cmpfunc.cc:
Fixed bug #15633: Evaluation of Item_equal for non-const table caused wrong select result
Added check for field's table being const in Item_equal::val_int().
cmp_item_sort_string::cmp() wasn't checking values_res variable for null.
Later called function was dereferenced it and crashed server.
Added null check to cmp_item_sort_string::cmp().
sql/item_cmpfunc.h:
Fix bug#15268 Unchecked null value caused server crash
Added null check to cmp_item_sort_string::cmp().
mysql-test/t/select.test:
Test case for bug#15268 Unchecked null value caused server crash
mysql-test/r/select.result:
Test case for bug#15268 Unchecked null value caused server crash
A typo bug caused loss of a predicate of the form field=const in some cases.
mysql-test/r/select.result:
Added a test case for bug #15106.
mysql-test/t/select.test:
Added a test case for bug #15106.
the same column as an aliased and as a non-aliased column.
The problem was that Item_direct_view_ref::eq() was first comparing view columns
by name, and in this case the name of one of them is different since it is aliased.
mysql-test/r/select.result:
Added test for BUG#14662.
mysql-test/t/select.test:
Added test for BUG#14662.
sql/item.cc:
Changed the way view column refenreces are compared. Two view columns are
equal if they resolve to the same result field of a view.
Invalid date like 2000-02-32 wasn't converted to int, which lead to not
using index and comparison with field as astring, which results in slow
query execution.
convert_constatn_item() and get_mm_leaf() now forces MODE_INVALID_DATES to
allow such conversion.
sql/item.h:
Fix bug #14093 Query takes a lot of time when date format is not valid
To Item_int_with_ref added method real_item() which returns ref.
sql/item_cmpfunc.cc:
Fix bug #14093 Query takes a lot of time when date format is not valid
convert_constant_item() now allows conversion of invalid dates like 2000-01-32 to int to make it possible to use index when comparing fields with such dates.
sql/opt_range.cc:
Fix bug #14093 Query takes a lot of time when date format is not valid
get_mm_leaf() modified so it allows index usage for comparing fields with invalid dates like 2000-01-32.
mysql-test/r/select.result:
Test case for bug#14093 Query takes a lot of time when date format is not valid
mysql-test/t/select.test:
Test case for bug#14093 Query takes a lot of time when date format is not valid
mysql-test/r/insert_select.result:
Merge from 4.1 to 5.0.
mysql-test/r/select.result:
Merge from 4.1 to 5.0.
mysql-test/t/insert_select.test:
Merge from 4.1 to 5.0.
mysys/my_handler.c:
Merge from 4.1 to 5.0.
sql/item.cc:
Merge from 4.1 to 5.0.
sql/item_timefunc.cc:
Imported bug fix from 4.1 to 5.0. (Bug#14016)
sql/item_timefunc.h:
Imported bug fix from 4.1 to 5.0. (Bug#14016)
into ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-5.0-tmp
heap/_check.c:
Auto merged
heap/hp_create.c:
Auto merged
include/config-netware.h:
Auto merged
include/my_base.h:
Auto merged
include/my_handler.h:
Auto merged
include/myisam.h:
Auto merged
innobase/include/Makefile.am:
Auto merged
myisam/mi_check.c:
Auto merged
myisam/mi_delete.c:
Auto merged
myisam/mi_rnext_same.c:
Auto merged
myisam/mi_search.c:
Auto merged
myisam/mi_write.c:
Auto merged
myisam/myisamdef.h:
Auto merged
myisam/sort.c:
Auto merged
mysql-test/mysql-test-run.sh:
Auto merged
mysql-test/r/date_formats.result:
Auto merged
mysql-test/r/update.result:
Auto merged
mysql-test/t/date_formats.test:
Auto merged
mysql-test/t/select.test:
Auto merged
mysql-test/t/update.test:
Auto merged
mysys/my_getopt.c:
Auto merged
mysys/my_handler.c:
Auto merged
scripts/make_binary_distribution.sh:
Auto merged
sql/ha_myisam.cc:
Auto merged
sql/item_timefunc.cc:
Auto merged
sql/records.cc:
Auto merged
sql/sql_load.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/structs.h:
Auto merged
strings/conf_to_src.c:
Auto merged
strings/ctype-win1250ch.c:
Auto merged
Makefile.am:
Merged from 4.1
myisam/myisamchk.c:
Merged from 4.1
mysql-test/mysql-test-run.pl:
Merged from 4.1
mysql-test/r/insert_select.result:
Merged from 4.1
mysql-test/r/myisam.result:
Merged from 4.1
mysql-test/r/select.result:
Merged from 4.1
mysql-test/t/insert_select.test:
Merged from 4.1
mysql-test/t/myisam.test:
Merged from 4.1
netware/mysql_test_run.c:
Merged from 4.1
sql/item.cc:
Merged from 4.1
sql/mysqld.cc:
Merged from 4.1
sql/sql_update.cc:
Merged from 4.1
tests/mysql_client_test.c:
Merged from 4.1
include/config-netware.h:
Auto merged
sql/sql_select.cc:
Auto merged
mysql-test/r/select.result:
Manually merged fix for bug#13855
mysql-test/t/select.test:
Manuall merged fix for bug#13855
into mysql.com:/home/timka/mysql/src/5.0-bug-13832
mysql-test/r/select.result:
Auto merged
mysql-test/t/select.test:
Auto merged
sql/sql_yacc.yy:
Auto merged
The cause for the bug is that the priorities of all rules/terminals
that process the FROM clause are not fully specified, and the
parser generator produces a parser that doesn't always parse
the FROM clause so that JOINs are left-associative. As a result
the final join tree produced by the parser is incorrect, which
is the cause for subsequent name resolution to fail.
mysql-test/r/select.result:
Test for BUG#13832.
mysql-test/t/select.test:
Test for BUG#13832.
sql/sql_yacc.yy:
Fix for BUG#13832 - Unknown column t1.a in 'on clause'.
List all join-related operators as having lower priority
than the join operands to make the parser process join-
related productions from left to right.
ESCAPE has length of 1 if specified and sql_mode is NO_BACKSLASH_ESCAPES
or has length of 0 or 1 in every other situation.
(approved patch applied on a up-to-date tree re-commit)
mysql-test/r/select.result:
results of test for bug 12595
mysql-test/t/select.test:
test for bug #12595 (ESCAPE must be exactly one character long)
sql/item_cmpfunc.cc:
if ESCAPE was in the statement check whether its length is
different than 1. In NO_BACKSLASH_ESCAPES mode only length of 1 is
allowed, otherwise the length could be 0 or 1 character (code point
in the sense of Unicode).
sql/item_cmpfunc.h:
pass variable from the parsing stage - whether
ESCAPE clause was found in the statement
sql/sql_help.cc:
pass FALSE for escape_used_in_parsing because we
want the default mode of no error checking - our internal code.
sql/sql_lex.cc:
initialized variable used to transfer information during
parsing up in the stack when reducing in the grammar
sql/sql_lex.h:
new variable used for transfering information when
reducing in the grammar.
sql/sql_yacc.yy:
initialize Lex->escape_used and then use it when reducing.
This is needed as fix for bug #12595 to distinguish between
situation where ESCAPE was found and when not because internally
we may pass a string an empty string and there is no other way
to find out whether this is correct or not in case of
NO_BACKSLASH_ESCAPES mode, which allows only length of 1 if
ESCAPE is part of the SQL statement.
DISTINCT wasn't optimized away and caused creation of tmp table in wrong
case. This result in integer overrun and running out of memory.
Fix backported from 4.1. Now if optimizer founds that in result be only 1
row it removes distinct.
sql/sql_select.cc:
Fix bug #13855 select distinct with group by caused server crash
mysql-test/r/select.result:
Test case for bug#13855 select distinct with group by caused server crash
mysql-test/t/select.test:
Test case for bug#13855 select distinct with group by caused server crash
field::sort_key() now adds length last for varbinary/blob
VARBINARY/BLOB is now sorted by filesort so that shorter strings comes before longer ones
Fixed issues in test cases from last merge
mysql-test/r/select.result:
Change column name in test to get GROUP BY to use the alias
mysql-test/r/type_blob.result:
Test BLOB and VARCHAR sorting
mysql-test/t/select.test:
Change column name in test to get GROUP BY to use the alias
Drop used tables at start of test
Don't use table names 'a', 'b' or 'c'
mysql-test/t/type_blob.test:
Test BLOB and VARCHAR sorting
sql/field.cc:
Store length last in VARBINARY() and BLOB() columns to get shorter strings sorted before longer onces
sql/field.h:
Added method 'sort_length()' to allow one to have length bytes last for VARBINARY/BLOB to get these to sort properly
sql/filesort.cc:
Use 'sort_length()' instead of 'pack_length()' to get length of field.
Store suffix_length last for varbinary (blob) objects.
The above ensures that BLOB/VARBINARY are correctly sorted (shorter strings before longer ones)
sql/sql_class.h:
Added sort suffix length (to get varbinary/blob to sort correctly)
sql/sql_select.cc:
Use sort_length() instead of pack_lengths()
strings/ctype-bin.c:
Don't let strnxfrm_bin store length last
Better to do it in MySQL field object to ensure it's done properly for all cases
into mysql.com:/home/my/mysql-5.0
mysql-test/t/select.test:
Auto merged
sql/item.cc:
Auto merged
sql/slave.cc:
Auto merged
sql/sql_select.cc:
Auto merged
vio/vio.c:
Auto merged
mysql-test/r/select.result:
Merge and change table names a,b,c to t1,t2.t3
into ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-5.0
configure.in:
Auto merged
include/config-win.h:
Auto merged
include/m_string.h:
Auto merged
include/my_pthread.h:
Auto merged
myisam/mi_search.c:
Auto merged
mysql-test/r/cast.result:
Auto merged
mysql-test/t/cast.test:
Auto merged
mysql-test/t/select.test:
Auto merged
mysys/my_pthread.c:
Auto merged
mysys/thr_alarm.c:
Auto merged
netware/pack_isam.def:
Auto merged
sql/item.h:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
strings/ctype-big5.c:
Auto merged
strings/ctype-tis620.c:
Auto merged
strings/xml.c:
Auto merged
vio/vio.c:
Auto merged
vio/viosocket.c:
Auto merged
mysql-test/r/select.result:
Merged from 4.1.
netware/BUILD/mwenv:
Merged from 4.1.
scripts/make_binary_distribution.sh:
Merged from 4.1.
sql/mysqld.cc:
Merged from 4.1.
sql/sql_show.cc:
Merged from 4.1.
strings/my_strtoll10.c:
Merged from 4.1.
When fixing Item_func_plus in ORDER BY clause field c is searched in all
opened tables, but because c is an alias it wasn't found there.
This patch adds a flag to select_lex which allows Item_field::fix_fields()
to look up in select's item_list to find aliased fields.
sql/item.cc:
Fix bug#7672 Unknown column error in order clause
When fixing fields in ORDER BY clause allow Item_field::fix_fields() to look up items in select's item list to find aliased fields.
sql/sql_lex.cc:
Fix bug#7672 Unknown column error in order clause
sql/sql_lex.h:
Fix bug#7672 Unknown column error in order clause
Added flag to select_lex allowing Item_field::fix_fields to look up items in select's item list.
sql/sql_select.cc:
Fix bug#7672 Unknown column error in order clause
mysql-test/t/select.test:
Test case for bug#7672 Unknown column error in order clause
mysql-test/r/select.result:
Test case for bug#7672 Unknown column error in order clause
- Use %lx instead of %p as %p is not portable
- Don't replace ROW item with Item_null
myisam/mi_rkey.c:
Use %lx instead of %p as %p is not portable
myisam/mi_search.c:
Use %lx instead of %p as %p is not portable
mysql-test/r/select.result:
More test for ROW comparison
mysql-test/t/select.test:
More test for ROW comparison
sql/item.cc:
We can't replace a ROW item with Item_null because:
- Arg_comparator is still using the orignal row items and it's not good to have args[0] different from what is actually compared
- If we are using the <=> comparator, NULL can still be compared as true
- We would break things if we would ever use resolve_const_item() for operators like >, < etc.
After SHOW TABLE STATUS last_insert_id wasn't cleaned, and next select
erroneously rewrites WHERE condition and returs a row;
5.0 isn't affected because of different SHOW TABLE STATUS handling.
last_insert_id cleanup added to mysqld_extend_show_tables().
sql/sql_show.cc:
Fix bug #13535 Incorrect result from SELECT statement after SHOW TABLE STATUS
Added last_insert_id cleanup after SHOW TABLE STATUS command.
mysql-test/t/select.test:
Test case for bug #13535 Incorrect result from SELECT statement after SHOW TABLE STATUS
mysql-test/r/select.result:
Test case for bug #13535 Incorrect result from SELECT statement after SHOW TABLE STATUS
The problem was in that when finding the last table reference in a nested join tree,
the procedure doing the iteration over the right-most branches of a join tree
was testing for RIGHT JOINs the table reference that represents the join, and not
the second operand of the JOIN. Currently the information whether a join is LEFT/RIGHT
is stored not on the join object itself, but on one of its operands.
mysql-test/r/select.result:
Added test for BUG#13597
mysql-test/t/select.test:
Added test for BUG#13597
sql/table.cc:
- test whether a table reference is a right join by testing the
rigth join operand (first in the list of operands), and not
the table reference that represents the join itself.
- clearer comments
into neptunus.(none):/home/msvensson/mysql/mysql-5.0
BitKeeper/deleted/.del-disabled.def:
Delete: mysql-test/t/disabled.def
libmysqld/lib_sql.cc:
Auto merged
mysql-test/t/innodb.test:
Auto merged
sql/ha_innodb.cc:
Auto merged
mysql-test/r/innodb.result:
Manual merge from 4.1 to 5.0
mysql-test/r/select.result:
Manual merge from 4.1 to 5.0
mysql-test/t/select.test:
Manual merge from 4.1 to 5.0
sql/item.cc:
Manual merge from 4.1 to 5.0
resolve_const_item() assumed to be not called for Item_row items. For
ensuring that DBUG_ASSERT(0) was set there.
This patch adds section for Item_row items. If it can it recursively calls
resolve_const_item() for each item the Item_row contains. If any of the
contained items is null then whole Item_row substitued by Item_null. Otherwise
it just returns.
sql/item.cc:
Fix bug#13356 resolve_const_item() wasn't able to handle Item_row items.
Added section to resolve_const_item() for Item_row items. If it can it
recursively calls resolve_const_item() for each item the Item_row contains. If
any of the contained items is null then Item_row is substituted by Item_null.
Otherwise it just returns.
Comment moved closer to function it belongs to.
mysql-test/t/select.test:
Test case for bug#13356 resolve_const_item() wasn't able to handle Item_row items.
mysql-test/r/select.result:
Test case for bug#13356 resolve_const_item() wasn't able to handle Item_row items.
The problem was in the way table references are pre-filtered when
resolving a qualified field. When resolving qualified table references
we search recursively in the operands of the join. If there is
natural/using join with a merge view, the first call to find_field_in_table_ref
makes a recursive call to itself with the view as the new table reference
to search for the column. However the view has both nested_join and
join_columns != NULL so it skipped the test whether the view name matches
the field qualifier. As a result the field was found in the view since the
view already has a field with the same name. Thus the field was incorrectly
resolved as the view field.
mysql-test/r/select.result:
Test for BUG#13127.
mysql-test/t/select.test:
Test for BUG#13127.
sql/sql_base.cc:
The patch contains two independent changes:
- When searching for qualified fields, include merge views and information schema tables
used with SHOW (both using TABLE_LIST::field_translation to represent result fields) in
the test that compares the qualifying table with the name of the table reference being
searched. This change fixes the bug.
- Do not search the materialized list of columns of a NATURAL/USING join if 'table_list'
is a stored table or merge view. Instead search directly in the table or view as if it
is not under a natural join. This is a performance improvement since if 'table_list'
is a stored table, then the search can utilize the name hash for table names.
Optimizer did choose "Range checked for each record" for one of the tables.
For first few loops over that table it choose sequential access, on later
stage it choose to use index. Because table was previously initialized for
sequential access, it skips intitialization for index access, and when
server tries to retrieve data error occurs.
QUICK_RANGE_SELECT::init() changes so if file already initialized for
sequential access, it calls ha_rnd_end() and initializes file for index
access.
sql/opt_range.cc:
Fix bug #12291 Table wasn't reinited for index scan after sequential scan
mysql-test/t/select.test:
Test case for bug #12291 Table wasn't reinited for index scan after sequential scan
mysql-test/r/select.result:
Test case for bug #12291 Table wasn't reinited for index scan after sequential scan
mysql-test/r/select.result:
Test for BUG#13067
mysql-test/t/select.test:
Test for BUG#13067
sql/sql_base.cc:
Correctly compare field names with respect to case sensitivity.
The problem was that in the first production in rule 'join_table', that
processes simple cross joins, the parser was processing the second join operand
before the first one due to unspecified priorities of JOINs. As a result in the
case of cross joins the parser constructed a tree with incorrect nesting:
the expression "t1 join t2 join t3 on some_cond" was interpreted as
"t1 join (t2 join t3 on some_cond)" instead of
"(t1 join t2) join t3 on some_cond".
Because of this incorrect nesting the method make_join_on_context picked an
incorrect table as the first table of the name resolution context.
The solution assignes correct priorities to the related production.
mysql-test/r/select.result:
Added test for BUG#12943.
mysql-test/t/select.test:
Added test for BUG#12943.
sql/sql_parse.cc:
Fixed typo.
sql/sql_yacc.yy:
Provide explicit priorities of the JOIN operator and the 'table_ref' rule,
to enforce left-associativity of [INNER | CROSS] JOIN.
mysql-test/r/select.result:
Test for BUG#12977.
mysql-test/t/select.test:
Test for BUG#12977.
sql/sql_base.cc:
- Compare table qualifier of qualified fields only with tables that
are not natural joins or their operands.
- For qualified fields perform recursive search in all operands of
natural joins that are nested joins.
- Symmetrically detect ambiguous columns for both operands of
NATURAL/USING joins.