Commit graph

311 commits

Author SHA1 Message Date
sergefp@mysql.com
84e9cb794f BUG#16255: Merge to 5.0 2006-08-24 20:56:28 +04:00
sergefp@mysql.com
d4cacdb5cc Bug #16255: Subquery in WHERE (the cset by Georgi Kodinov)
Must not use Item_direct_ref in HAVING because it points to
 the new value (witch is not yet calculated for the first row).
2006-08-24 19:14:36 +04:00
msvensson@neptunus.(none)
7280f63100 Merge neptunus.(none):/home/msvensson/mysql/mysql-5.0
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0-maint
2006-08-03 09:32:58 +02:00
msvensson@neptunus.(none)
31be565d2e Merge neptunus.(none):/home/msvensson/mysql/mysql-5.0
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0-maint
2006-08-01 20:24:30 +02:00
sergefp@mysql.com
305788527e Post-merge fixes 2006-07-22 16:18:28 +04:00
sergefp@mysql.com
9024ed81c7 Merge mysql.com:/home/psergey/mysql-4.1-opt
into  mysql.com:/home/psergey/mysql-5.0-opt
2006-07-21 23:45:34 +04:00
sergefp@mysql.com
bffd438de3 BUG#20975: Incorrect query result for NOT (subquery):
Add implementations of Item_func_{nop,not}_all::neg_transformer
2006-07-21 03:04:04 +04:00
msvensson@neptunus.(none)
cb23cd759e Merge neptunus.(none):/home/msvensson/mysql/bug7498/my50-bug7498
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0-maint
2006-07-20 13:41:50 +02:00
evgen@moonbone.local
4b1730241d Merge moonbone.local:/work/16302-bug-4.1-opt-mysql
into  moonbone.local:/work/tmp_merge-5.0-opt-mysql
2006-07-13 18:18:20 +04:00
evgen@moonbone.local
d34189715e Fixed bug#16302: Quantified subquery without any tables gives wrong results
The ALL/ANY subqueries are the subject of MIN/MAX optimization. The matter
of this optimization is to embed MIN() or MAX() function into the subquery
in order to get only one row by which we can tell whether the expression
with ALL/ANY subquery is true or false.
But when it is applied to a subquery like 'select a_constant' the reported bug
occurs. As no tables are specified in the subquery the do_select() function 
isn't called for the optimized subquery and thus no values have been added 
to a MIN()/MAX() function and it returns NULL instead of a_constant.
This leads to a wrong query result.

For the subquery like 'select a_constant' there is no reason to apply
MIN/MAX optimization because the subquery anyway will return at most one row.
Thus the Item_maxmin_subselect class is more appropriate for handling such
subqueries.

The Item_in_subselect::single_value_transformer() function now checks
whether tables are specified for the subquery. If no then this subselect is
handled like a UNION using an Item_maxmin_subselect object.
2006-07-11 00:34:37 +04:00
msvensson@neptunus.(none)
9ebf7944e3 Bug #7498 User variable SET saves SIGNED BIGINT as UNSIGNED BIGINT
- Add unsigned flag to user_var_entry, used when 'type' is INT_RESULT
- Propagate unsigned flag from the query executed by Item_single_row_subselect
2006-06-09 19:35:54 +02:00
gkodinov@mysql.com
d6b5a89044 Bug #19700: subselect returning BIGINT always returned it as SIGNED
The unsigned flag in Item was not propagated through the single value subqueries.
This caused the result to be treated as signed.
2006-05-25 10:39:18 +03:00
evgen@moonbone.local
1d820585ae Fixed bug#19077: A nested materialized derived table is used before being populated.
The convert_constant_item() function converts constant items to ints on
prepare phase to optimize execution speed. In this case it tries to evaluate
subselect which contains a derived table and is contained in a derived table. 
All derived tables are filled only after all derived tables are prepared.
So evaluation of subselect with derived table at the prepare phase will
return a wrong result.

A new flag with_subselect is added to the Item class. It indicates that
expression which this item represents is a subselect or contains a subselect.
It is set to 0 by default. It is set to 1 in the Item_subselect constructor
for subselects.
For Item_func and Item_cond derived classes it is set after fixing any argument
in Item_func::fix_fields() and Item_cond::fix_fields accordingly.
The convert_constant_item() function now doesn't convert a constant item
if the with_subselect flag set in it.
2006-05-18 00:55:28 +04:00
gkodinov@mysql.com
0486cfbee2 BUG#7549: Missing error message for invalid view selection with subquery.
When a view statement is compiled on CREATE VIEW time, most of the 
optimizations should not be done. Finding the right optimization 
for a subquery is one of them.
Unfortunately the optimizer is resolving the column references of 
the left expression of IN subqueries in the process of deciding 
witch optimization to use (if needed). So there should be a 
special case in Item_in_subselect::fix_fields() : check the 
validity of the left expression of IN subqueries in CREATE VIEW 
mode and then proceed as normal.
2006-05-11 15:30:54 +03:00
gkodinov@lsmy3.wdf.sap.corp
6e5cf86f4d Merge lsmy3.wdf.sap.corp:/data/users/gkodinov/mysql-4.1-B18492
into  lsmy3.wdf.sap.corp:/data/users/gkodinov/mysql-5.0-B18492
2006-04-28 12:06:54 +02:00
gkodinov@lsmy3.wdf.sap.corp
ca79343359 BUG#18492: mysqld reports ER_ILLEGAL_REFERENCE in --ps-protocol
In the code that converts IN predicates to EXISTS predicates it is changing
the select list elements to constant 1. Example :
SELECT ... FROM ...  WHERE a IN (SELECT c FROM ...)
is transformed to :
SELECT ... FROM ... WHERE EXISTS (SELECT 1 FROM ...  HAVING a = c)
However there can be no FROM clause in the IN subquery and it may not be
a simple select : SELECT ... FROM ... WHERE a IN (SELECT f(..) AS
c UNION SELECT ...) This query is transformed to : SELECT ... FROM ...
WHERE EXISTS (SELECT 1 FROM (SELECT f(..) AS c UNION SELECT ...)
x HAVING a = c) In the above query c in the HAVING clause is made to be
an Item_null_helper (a subclass of Item_ref) pointing to the real
Item_field (which is not referenced anywhere else in the query anymore).
This is done because Item_ref_null_helper collects information whether
there are NULL values in the result.  This is OK for directly executed
statements, because the Item_field pointed by the Item_null_helper is
already fixed when the transformation is done.  But when executed as
a prepared statement all the Item instances are "un-fixed" before the
recompilation of the prepared statement. So when the Item_null_helper
gets fixed it discovers that the Item_field it points to is not fixed
and issues an error.  The remedy is to keep the original select list
references when there are no tables in the FROM clause. So the above
becomes : SELECT ... FROM ...  WHERE EXISTS (SELECT c FROM (SELECT f(..)
AS c UNION SELECT ...) x HAVING a = c) In this way c is referenced
directly in the select list as well as by reference in the HAVING
clause. So it gets correctly fixed even with prepared statements.  And
since the Item_null_helper subclass of Item_ref_null_helper is not used
anywhere else it's taken out.
2006-04-28 11:23:31 +02:00
igor@rurik.mysql.com
7b1b69a6e7 Merge rurik.mysql.com:/home/igor/mysql-5.0
into  rurik.mysql.com:/home/igor/dev/mysql-5.0-2
2005-11-22 23:00:57 -08:00
bell@sanja.is.com.ua
806f9e24ff Inefficient usage of String::append() fixed.
Bad examples of usage of a string with its length fixed.
The incorrect length in the trigger file configuration descriptor
  fixed (BUG#14090).
A hook for unknown keys added to the parser to support old .TRG files.
2005-11-20 20:47:07 +02:00
igor@rurik.mysql.com
c136e9c43b Fixed bug #12762:
allowed set functions aggregated in outer subqueries, allowed nested set functions.
2005-10-15 14:32:37 -07:00
konstantin@mysql.com
b2ff38202d A fix and a test case for Bug#12736 "Server crash during a select".
The bug was in JOIN::join_free which was wrongly determining that
all joins have been already executed and therefore all used tables
can be closed.
2005-10-13 11:53:00 +04:00
konstantin@mysql.com
6f8d3c4844 A fix and a test case for Bug#6513 "Test Suite: Values inserted by using
cursor is interpreted latin1 character and Bug#9819 "Cursors: Mysql Server
Crash while fetching from table with 5 million records."
A fix for a possible memory leak when fetching into an SP cursor
in a long loop.
The patch uses a common implementation of cursors in the binary protocol and 
in stored procedures and implements materialized cursors.
For implementation details, see comments in sql_cursor.cc
2005-09-22 02:11:21 +04:00
konstantin@mysql.com
a3ddcdf8fb Rename:
- current_arena to stmt_arena: the thread may have more than one
'current' arenas: one for runtime data, and one for the parsed 
tree of a statement. Only one of them is active at any moment.
- set_item_arena -> set_query_arena, because Item_arena was renamed to 
Query_arena a while ago
- set_n_backup_item_arena -> set_n_backup_active_arena;
the active arena is the arena thd->mem_root and thd->free_list
are currently pointing at.
- restore_backup_item_arena -> restore_active_arena (with the same
rationale)
- change_arena_if_needed -> activate_stmt_arena_if_needed; this
method sets thd->stmt_arena active if it's not done yet.
2005-09-02 17:21:19 +04:00
sanja@hasky.mysql.fi
2e2b897ff3 item_subselect.cc:
postmerge fix
subselect.result:
  new 5.0 result (postmerge)
2005-08-13 11:15:17 +03:00
sanja@hasky.mysql.fi
16d279bb12 Merge abelkin@bk-internal.mysql.com:/home/bk/mysql-4.1
into  hasky.mysql.fi:/home/sanja/work-merge-5.0
2005-08-13 08:19:34 +03:00
bell@50.0.168.192.in-addr.arpa
1e248ceaf1 fixed convertion and handling IN subqueries with rows (BUG#11867) 2005-08-13 07:45:14 +03:00
dlenev@mysql.com
0f75d64734 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/dlenev/src/mysql-5.0-bg11973-2
2005-08-11 10:39:33 +04:00
dlenev@mysql.com
60511c3df2 Clumsy but working fix for bug #11973 "SELECT .. INTO var_name; in trigger
cause crash on update".

Let us update "thd" pointer in LEX, all its units and in LEX::result before
executing statement in trigger body, since triggers are associated with TABLE
object and because of this can be used in different threads.
2005-08-10 00:23:56 +04:00
igor@rurik.mysql.com
c6d1a05aa0 Manual merge 2005-08-07 15:10:06 -07:00
igor@rurik.mysql.com
b2a189ab07 subselect.result:
Added test case for bug #11867.
  Fixed results for two existing test cases.
subselect.test:
  Added test case for bug #11867.
item_subselect.cc:
  Fixed bug #11867.
  Added missing code in Item_in_subselect::row_value_transformer
  that caused problems for queries with
  ROW(elems) IN (SELECT DISTINCT cols FROM ...).
2005-08-07 14:03:46 -07:00
bell@sanja.is.com.ua
d3905f3d0e Name resolution context added (BUG#6443) 2005-07-01 07:05:42 +03:00
konstantin@mysql.com
8b0cee88f0 A fix and a test case for Bug#10736 "mysql_stmt_attr_set
CURSOR_TYPE_READ_ONLY select within select".
The bug was caused by the reset of thd->mem_root to thd->main_mem_root in 
Item_subselect::exec, which in turn triggered too early free_root() for
data which was needed on subsequent fetches from a cursor.
This reset also caused a memory leak in stored procedures, as 
subsequent executions of instructions containing a subselect
were allocating memory in thd->main_mem_root, which is not freed
until the end of the entire SP, instead of the per-call mem_root,
which is freed in the end of execution of the instruction.
2005-06-28 20:52:15 +04:00
igor@rurik.mysql.com
268110b34b Manual merge 2005-06-23 11:22:30 -07:00
igor@rurik.mysql.com
c73c2af614 func_str.result, func_str.test:
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.
2005-06-23 06:15:50 -07:00
serg@serg.mylan
01b3c70926 renamed:
Item_buff -> Cached_item
  Item_arena -> Query_arena
  TEST_ASSERT -> YYERROR_UNLESS
2005-06-15 19:58:35 +02:00
ramil@mysql.com
6f8ef49895 A fix (bug #11153: Ambiguous call to overloaded function, acording to Visual Studio 6) 2005-06-08 11:37:43 +05:00
konstantin@mysql.com
ac2a9eb699 Manual merge. 2005-06-07 14:50:45 +04:00
konstantin@mysql.com
9f379d7f05 Patch two (the final one) for Bug#7306 "the server side preparedStatement
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.
2005-06-07 14:11:36 +04:00
monty@mysql.com
775f17667b Merge with 4.1 2005-06-07 00:31:53 +03:00
serg@serg.mylan
6a5349028c a compiler must see '#pragma implementation' *before*
'#pragma interface' (that comes with the #include'd header file)
2005-06-05 19:38:52 +02:00
monty@mysql.com
4b7882dc73 merge 2005-06-05 17:19:50 +03:00
monty@mysql.com
29fd1f2fd9 Move USE_PRAGMA_IMPLEMENTATION to proper place
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
2005-06-03 23:46:03 +03:00
konstantin@mysql.com
123bcb9d8d Give Item_arena::is_stmt_prepare a more descriptive name (it marks
the code that is active for SP as well in 5.0)
2005-06-03 00:02:47 +04:00
brian@zim.(none)
113a99626d Merge of 4.1->5.0. This contained the fixes for GCC 4.0 2005-06-01 21:56:30 -07:00
brian@zim.(none)
efb5ed5bab Merge 2005-06-01 18:48:29 -07:00
kent@mysql.com
bd48eed988 tztime.cc:
Set #pragma implementation" earlier
Many files:
  Need to include <my_global.h> before #ifdef USE_PRAGMA_IMPLEMENTATION
2005-06-02 02:43:32 +02:00
brian@zim.(none)
ba9b9f8993 Mainly cleanups for gcc 4.0. Some small pieces from looking at -Wall. Removed a number of dumb things in ha_tina. 2005-06-01 17:34:10 -07:00
monty@mysql.com
a69f432115 Code cleanups during code reviews
Ensure we get error if INSERT IGNORE ... SELECT fails
Fixed wrong key_part->key_length usage in index_merge
2005-06-01 16:35:09 +03:00
monty@mysql.com
e253b7815a Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/my/mysql-5.0
2005-05-31 15:22:44 +03:00
pem@mysql.com
53abbdc39b Merge mysql.com:/usr/local/bk/mysql-5.0
into mysql.com:/home/pem/work/mysql-5.0
2005-05-31 12:07:16 +02:00
pem@mysql.comhem.se
063896a6e7 Post-review fixes of BUG#9937: Crash on call to stored procedure. 2005-05-31 12:06:15 +02:00