Added a test case for bug #11414.
sql_select.cc:
Fixed bug #11414: crash on Windows with some simple
GROUP BY queries.
It happened to an allocation of an array containing
0 Copy_field elements in setup_copy_fields.
The bug had been already fixed in 5.0.
The reason it happened was that both, JOIN::cleanup() and JOIN::join_free(),
went over all nested joins and called cleanup/join_free for them.
For that:
- split recursive and non-recursive parts of JOIN::cleanup() and
JOIN::join_free()
- rename JOIN::cleanup to JOIN::destroy, as it actually destroys its
argument
- move the recursive part of JOIN::cleanup to st_select_lex::cleanup
- move the non-recursive part of JOIN::join_free to the introduced
method JOIN::cleanup().
We need every instruction to have its own arena, because we want to
track instruction's state (INITIALIZED_FOR_SP -> EXECUTED). Because of
`if' statements and other conditional instructions used in stored
procedures, not every instruction of a stored procedure gets executed
during the first (or even subsequent) execution of the procedure.
So it's better if we track the execution state of every instruction
independently.
All instructions of a given procedure now also share sp_head's
mem_root, but keep their own free_list.
This simplifies juggling with free Item lists in sp_head::execute.
- free_items() moved to be a member of Query_arena.
- logic of 'backup_arena' debug member of Query_arena has been
changed to support
multi-backups. Until now, TRUE 'backup_arena' meant that there is
exactly one active backup of the THD arena. Now it means simply that
the arena is used for backup, so that we can't accidentally overwrite an
existing backup. This allows doing multiple backups, e.g. in
sp_head::execute and Cursor::fetch, when THD arena is already backed up
but we want to set yet another arena (usually the 'permanent' arena,
to save permanent transformations/optimizations of a parsed tree).
Added a test case for bug #10124.
sql_select.h, item_subselect.cc, sql_select.cc:
Fixed bug #10124.
The copy method of the store_key classes can return
STORE_KEY_OK=0, STORE_KEY_FATAL=1, STORE_KEY_CONV=2 now.
field.cc:
Fixed bug #10124.
When ussuing a warning the store methods return 2 instead of 1 now.
Fix for yaSSL link failures with Forte Developer 7, MIPSpro Compilers, Compaq C++.
These compilers have problem with implicit template instantiation in archives
(libyassl.a, libtaocrypt.a). Instantiate templates explicitly.
Fix for yaSSL link failure on powermacg5 (gcc 3.3). When -O3 is specified gcc inlines
__cxa_pure_virtual. This is wrong behavior, __cxa_pure_virtual must never be inlined.
Added a test case for bug #8614.
sql_select.cc:
Fixed bug #8614.
SELECT DISTINCT ... GROUP BY 'const' must be equivalent to
SELECT ... GROUP BY 'const'.
Added a teast case for bug #11284.
sql_select.cc:
Fixed bug #11284.
Optimization with empty inner table currently cannot be
used in the case of nested outer join.
Added a test case for bug #11285.
sql_select.cc:
Fixed bug #11285.
The problem occurred with Item_equal in an 'on expression'
that was evaluated to false.
When the GROUP BY clause contains a column reference that can be resolved to
both an aliased column in the SELECT list, and to a column in the FROM clause,
the group column is resolved to the column in the FROM clause (for ANSI conformance).
However, it may be so that the user's intent is just the other way around, and he/she
gets the query results grouped by a completely different column than expexted.
This patch adds a warning in such cases that tells the user that there is potential
ambiguity in the group column.
sql/sql_select.cc
- Added a warning when a GROUP column is ambiguous due to that there is a
column reference with the same name both in the SELECT and FROM clauses.
In this case we resolve to the column in FROM clause and warn the user
of a possible ambiguity.
- More extensive comments.
- Changed the function to return bool instead of int (as in other places).
mysql-test/t/group_by.test
Added test for BUG#11211.
mysql-test/r/group_by.result
Added test for BUG#11211.
Wrong method for creating temporary field was choosen, which results in
sending int field with int header but lonlong data.
Test case is added to mysql_client_test.c because client library is required
to test the bug.
Added a test case for bug #11167.
sql_select.cc:
Fixed bug #11167.
In 4.1 char/varchar fields are limited by 255 characters in
length that make them longer than 255 bytes in size for such
character sets as UTF8. The functions store_record_in_cache
and read_cached_records did not take into account this
Moreover the code did not take into account that the size
of the varchar fields in 5.0 can be up to 65535 bytes
CURSOR_TYPE_READ_ONLY". The bug was that we (me) don't perform proper
cleanups of the prepared statement when done fetching from a cursor.
Another patch.
error for LIMIT placeholder".
The patch adds grammar support for LIMIT ?, ? and changes the
type of ST_SELECT_LEX::select_limit,offset_limit from ha_rows to Item*,
so that it can point to Item_param.
Fixed bug #11088: a crash for queries with GROUP BY a BLOB column
+ COUNT(DISTINCT...) due to an attempt to allocate a too large
buffer for the BLOB field.
Now the size of the buffer is limited by max_sort_length.
group_by.test, group_by.result:
Added a test case for bug #11088.
Added a test case for bug #6866.
sql_select.cc:
Fixed bug #6866.
Bug was due to the fact that on_expr was not backed up
for the second execution of the stored procedure.
Simple optimization for 2 argument usage to function of variable arguments
Fix stack overrun when using 1+1+1+1+1+1+1+....
Update crash-me results for 5.0
Don't call post_open if pre_open() fails (optimization)
Ensure that 'null_value' is not accessed before val() is called in FIELD() functions
Fixed initialization of key maps. This fixes some problems with keys when you have more than 64 keys
Fixed that ROLLUP don't always create a temporary table. This fix ensures that func_gconcat.test results are now predictable
"the server side preparedStatement error for LIMIT placeholder",
which moves all uses of LIMIT clause from PREPARE to OPTIMIZE
and later steps.
After-review fixes.
Added test cases for bug #7894.
sql_select.cc:
Fixed bug #7894: GROUP BY queries with ROLLUP returned
wrong results for expressions containing group by columns.
The fix ensured correct results by replacement of all
occurrences of group by fields in non-aggregate expressions
for corresponding ref objects and preventing creation of
fields in temporary tables for expression containing group
by fields.
server"
Bug appears only on Windows platform. Freeing memory in
TMP_TABLE_PARAM::cleanup() allocated by new Copy_fields[0] in
setup_copy_fields() results in memory destruction. In test IF used instead
of CONCAT because IF have more stable crash.
Added test cases for optimization request #10561.
opt_range.cc, sql_select.cc:
Fixed bug #10561: an optimization request to allow
range analysis for NOT IN and NOT BETWEEN.
Fixed bug #8528.
Representation for single-table views was made similar to
representation for multi-table views.
view.test:
Added test case for bug #8528.
view.result:
Added test case for bug #8528. Fixed other test cases.
with cursor". The patch refactors do_select/sub_select
functions, which implement the nested loop algorithm, and reuses them to
fetch rows for cursors as well.
Pushing with view.test failing (--ps-protocol).
Make get_quick_select_for_ref() accept estimated # records as parameter and
set QUICK_RANGE_SELECT::records, as this value is used to allocate buffers
in Multi-Range Read.
Fixed bug #9681.
The bug happened with queries using derived tables specified by
a SELECT with ROLLUP, such as:
SELECT * FROM (SELECT a, SUM(a) FROM t1 GROUP BY a WITH ROLLUP) t2,
if column a of table t1 is declared as NOT NULL.
This was to the fact that the first column of the temporary table
created to contain the derived table erroneously inherited the NOT NULL
attribute from column a.
olap.result, olap.test:
Added a test case for bug #9681.
Don't produce data truncation warnings from within cp_buffer_from_ref(). This function
is only used to make index search tuples and data truncation that occurs here has no
relation with truncated values being saved into tables.
Added a test case for bug #9338.
sql_select.cc:
Fixed bug #9338.
When an occurence of a field reference has to be replaced
by another field reference the whole Item_field must be
replaced.
item.cc:
Fixed bug #9338.
The method Item_field::replace_equal_field_processor was
replaced by Item_field::replace_equal_field. The new method
is used to replace the occurences of Item_field objects.
item.h:
Fixed bug #9338.
The virtual function replace_equal_field_processor was replaced
by replace_equal_field. The latter is supposed to be used as a
callback function in calls of the method transform.
Fixed warnings by valgrind for sum_distinct.test
Enable buffered-record-reads after filesort for InnoDB tables with short primary key
Enabled sort-with-data for MyISAM temporary files
"Early NULL-values filtering for ref access" (attempt2+post-review fixes)
1. update_ref_and_keys() accumulates info about null-rejecting
predicates in in KEY_FIELD::null_rejecting, add_key_part saves
these to KEYUSE.
2. create_ref_for_key copies them to TABLE_REF.
3. add_not_null_conds adds "x IS NOT NULL" to join_tab->select_cond of
appropiate JOIN_TAB members.
Includes code cleanups:
* add_key_field() params: s/COND/Item_func/ (as only Item_funcs are
passed to it)
* add_key_fields() params: JOIN_TAB *stat removed (wasn't used)
there was no check of result of
table->file->write_row() function. When count of rows was
more than table max_rows(HEAP table) the following recodrs
were not inserted to the table
-'schema_table_store_record' function is added.
The function checks result of write_row function
and convert HEAP table to MyISAM if necessary
- Result check after write_row is added into all
I_S function which store the records to I_S tables
Added a test case for bug #9210.
sql_select.cc:
Fixed bug #9210.
The function calc_group_buffer did not cover the case
when the GROUP BY expression was decimal.
Slightly optimized the other code.
Windows to call CreateFileMapping() with correct arguments, and
propogating the introduction of query_id_t to everywhere query ids are
passed around. (Bug #8826)
Added a test case for bug #8617.
sql_select.cc:
Fixed bug #8617.
Queries with ROLLUP and LIMIT n returned more than n rows
if SQL_CALC_FOUND_ROWS was used.
Added a test for bug #8615.
sql_select.cc:
Fixed bug #8615.
This fix only removed the cause of the reported crash.
It does not resolve other problems of rollup queries
with DISTINCT. They were fixed in the previous patch
for bug 8616.
Added a test case for bug #8616.
item.h:
Fixed bug #8616.
Added class Item_null_result used in rollup processing.
sql_select.h, sql_select.cc:
Fixed bug #8616.
Added JOIN::rollup_write_data to cover rollup queries
with DISTINCT. Modified other rollup methods.
implementation of AVG(DISTINCT) which utilizes the approach with Fields.
The patch implemented in October is portede to the up-to-date tree
containing DECIMAL type.
Tests for AVG(DISTINCT) (although there is not much to test provided
that SUM(DISTINCT) works), cleanups for COUNT(DISTINCT) and GROUP_CONCAT()
will follow in another changeset.
and bug#8849 "problem with insert statement with table alias's":
make equality propagation work in stored procedures and prepared
statements.
Equality propagation can change AND/OR structure of ON expressions,
so the fix is to provide each execution of PS/SP with it's own
copy of AND/OR tree. We have been doing that already for WHERE clauses,
now ON clauses are also copied.
Lots of small fixes to multi-precision-math path
Give Note for '123.4e'
Added helper functions type 'val_string_from_real()
Don't give warnings for end space for string2decimal()
Changed storage of values for SP so that we can detect length of argument without strlen()
Changed interface for str2dec() so that we must supple the pointer to the last character in the buffer
Remove TMP_TABLE_PARAM::copy_funcs_it. TMP_TABLE_PARAM is a member of JOIN which is
copied via memcpy, and List_iterator_fast TMP_TABLE_PARAM::copy_funcs_it ends up
pointing to the wrong List.
Ensure that references in HAVING, ORDER BY or GROUP BY are calculated after fields in SELECT.
This will ensure that any reference to these has a valid value.
Generalized the code for split_sum_func()
Added a test case for bug #7945.
sql_select.cc:
Fixed bug #7945. If DISTINCT is used only with constants
in a query with GROUP BY, we can apply an optimization
that set LIMIT to 1 only in the case when there is
no SQL_CALC_FOUND_ROWS.
Version for 5.0. Committed for merge.
If the result table is one of the select tables in INSERT SELECT,
we must not disable the result tables indexes before selecting.
Now the preparation is split into two prepare methods.
The first detects the situation and defers some preparations
until the second phase.
Version for 4.1. Committed for merge.
If the result table is one of the select tables in INSERT SELECT,
we must not disable the result tables indexes before selecting.
mysql_execute_command() detects the match for other reasons and
adds the flag OPTION_BUFFER_RESULT to the 'select_options'.
In this case the result is put into a temporary table first.
Hence, we can defer the preparation of the insert
table until the result is to be used.
Version for 4.0. Committed for merge.
If the result table is one of the select tables in INSERT SELECT,
we must not disable the result tables indexes before selecting.
mysql_execute_command() detects the match for other reasons and
adds the flag OPTION_BUFFER_RESULT to the 'select_options'.
In this case the result is put into a temporary table first.
Hence, we can defer the preparation of the insert
table until the result is to be used.
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