Commit graph

617 commits

Author SHA1 Message Date
evgen@moonbone.local
ace038ef1f Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  moonbone.local:/home/evgen/bk-trees/mysql-5.0-opt
2006-07-13 18:03:43 +04:00
igor@olga.mysql.com
f6d6ac1e0f Merge olga.mysql.com:/home/igor/mysql-4.1-opt
into  olga.mysql.com:/home/igor/mysql-5.0-opt
2006-07-06 13:40:08 -07:00
sergefp@mysql.com
d581287b34 Better comments for void Item::top_level_item() 2006-07-04 13:28:30 +04:00
gluh@mysql.com
d2b378d57f Merge sgluhov@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/gluh/MySQL/Merge/5.0-kt
2006-07-03 13:19:18 +05:00
konstantin@mysql.com
1c4dffc8ca Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/opt/local/work/mysql-5.0-runtime
2006-07-01 22:13:42 +04:00
konstantin@mysql.com
fbeb42a9e1 Remove an unused variable. 2006-07-01 00:33:47 +04:00
knielsen@mysql.com
1d56a9720c BUG#20769: Dangling pointer in ctype_recoding test case.
In some functions dealing with strings and character sets, the wrong
pointers were saved for restoration in THD::rollback_item_tree_changes().
This could potentially cause random corruption or crashes.

Fixed by passing the original Item ** locations, not local stack copies.

Also remove unnecessary use of default arguments.
2006-06-30 09:26:36 +02:00
gluh@eagle.intranet.mysql.r18.ru
f9214221fc Bug#19671 mysql_list_fields returns incorrect table name for VIEWs
After view onening real view db name and table name are placed
into table_list->view_db & table_list->view_name.
Item_field class does not handle these names properly during 
intialization of Send_field.
The fix is to use new class 'Item_ident_for_show' 
which sets correct view db name and table name for Send_field.
2006-06-29 16:52:46 +05:00
evgen@moonbone.local
e35a0ca4b7 Manually merged 2006-06-14 23:54:08 +04:00
evgen@moonbone.local
67de8c46a5 Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.

All date/time functions has the STRING result type thus their results are
compared as strings. The string date representation allows a user to skip 
some of leading zeros. This can lead to wrong comparison result if a date/time 
function result is compared to such a string constant.

The idea behind this bug fix is to compare results of date/time functions
and data/time constants as ints, because that date/time representation is 
more exact. To achieve this the agg_cmp_type() is changed to take in the
account that a date/time field or an date/time item should be compared 
as ints.

This bug fix is partially back ported from 5.0.

The agg_cmp_type() function now accepts THD as one of parameters. 
In addition, it now checks if a date/time field/function is present in the
list. If so, it tries to coerce all constants to INT to make date/time
comparison return correct result. The field for the constant coercion is
taken from the Item_field or constructed from the Item_func. In latter case
the constructed field will be freed after conversion of all constant items.
Otherwise the result is same as before - aggregated with help of the
item_cmp_type() function.

From the Item_func_between::fix_length_and_dec() function removed the part
which was converting date/time constants to int if possible. Now this is 
done by the agg_cmp_type() function.

The new function result_as_longlong() is added to the Item class. 
It indicates that the item is a date/time item and result of it can be
compared as int. Such items are date/time fields/functions.

Correct val_int() methods are implemented for classes Item_date_typecast, 
Item_func_makedate, Item_time_typecast, Item_datetime_typecast. All these
classes are derived from Item_str_func and Item_str_func::val_int() converts
its string value to int without regard to the date/time type of these items.

Arg_comparator::set_compare_func() and Arg_comparator::set_cmp_func()
functions are changed to substitute result type of an item with the INT_RESULT
if the item is a date/time item and another item is a constant. This is done
to get a correct result of comparisons like date_time_function() = string_constant.
2006-06-13 19:09:24 +04:00
gkodinov@mysql.com
486837b0fa Merge mysql.com:/home/kgeorge/mysql/5.0/clean
into  mysql.com:/home/kgeorge/mysql/5.0/B19700
2006-05-25 10:45:00 +03: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
monty@mysql.com
97b941d924 Remove dflt_field from field structure as this was only needed when createing temporary table and I found another soultion that doesn't increase the size of the field structure for all table instances. (Better fix for bug #19089)
Fixed compiler warnings
Fixed valgrind warning in Item_date_add_intervall::eq. (Recoding of bugfix #19490)
2006-05-24 11:56:59 +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
konstantin@mysql.com
d0c7c5fe8a Merge mysql.com:/opt/local/work/mysql-5.0-root
into  mysql.com:/opt/local/work/mysql-5.0-runtime-merge
2006-05-16 03:44:50 +04:00
knielsen@mysql.com
c8fd62f3b2 After-merge fixes; some function signatures changed from Item * to Item **. 2006-05-15 19:57:10 +02:00
kroki@mysql.com
a6904ef018 Remove 'const' that prevents Microsoft VC realize that
Item_trigger_field::set_required_privilege(const bool rw) is an
overloading of Settable_routine_parameter::set_required_privilege(bool rw).
2006-05-15 18:18:37 +04:00
kroki@mysql.com
0963c705cd Bug#14635: Accept NEW.x as INOUT parameters to stored procedures
from within triggers

Add support for passing NEW.x as INOUT and OUT parameters to stored
procedures.  Passing NEW.x as INOUT parameter requires SELECT and
UPDATE privileges on that column, and passing it as OUT parameter
requires only UPDATE privilege.
2006-05-12 13:55:21 +04: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
sergefp@mysql.com
1d4acfb668 BUG#15872: Don't run the range analyzer on "t1.keypart NOT IN (const1, ..., )", as that consumes
too much memory. Instead, either create the equvalent SEL_TREE manually, or create only two ranges that
strictly include the area to scan
(Note: just to re-iterate: increasing NOT_IN_IGNORE_THRESHOLD will make optimization run slower for big 
IN-lists, but the server will not run out of memory. O(N^2) memory use has been eliminated)
2006-04-25 23:33:31 +04:00
kroki@mysql.com
c8e22ff70b Bug#16461: connection_id() does not work properly inside trigger
CONNECTION_ID() was implemented as a constant Item, i.e. an instance of
Item_static_int_func class holding value computed at creation time.
Since Items are created on parsing, and trigger statements are parsed
on table open, the first connection to open a particular table would
effectively set its own CONNECTION_ID() inside trigger statements for
that table.

Re-implement CONNECTION_ID() as a class derived from Item_int_func, and
compute connection_id on every call to fix_fields().
2006-04-12 19:31:00 +04:00
timour@mysql.com
b85bd1e835 Merge mysql.com:/home/timka/mysql/src/5.0-virgin
into  mysql.com:/home/timka/mysql/src/5.0-bug-16710
2006-03-31 12:39:33 +03:00
timour@mysql.com
eed7cf09dd Fix for BUG#16710.
The bug was due to a missed case in the detection of whether an index
can be used for loose scan. More precisely, the range optimizer chose
to use loose index scan for queries for which the condition(s) over
an index key part could not be pushed to the index together with the
loose scan.

As a result, loose index scan was selecting the first row in the
index with a given GROUP BY prefix, and was applying the WHERE
clause after that, while it should have inspected all rows with
the given prefix, and apply the WHERE clause to all of them.

The fix detects and skips such cases.
2006-03-31 12:34:28 +03:00
pem@mysql.com
d85e929547 Fixed BUG#17476: Stored procedure not returning data when it is called first
time per connection
  Removed const_string() method from Item_string (it was only used in one
  place, in a bad way). Defer possible SP variable, and access data directly
  instead, in date_format item.
2006-03-02 14:54:04 +01:00
holyfoot@deer.(none)
dc052a3a00 bug #9088 (bigint WHERE fails) 2006-03-01 15:50:15 +04:00
monty@mysql.com
54274976e7 Fixed compiler warnings from gcc 4.0.2:
- Added empty constructors and virtual destructors to many classes and structs
- Removed some usage of the offsetof() macro to instead use C++ class pointers
2006-02-25 17:46:30 +02:00
evgen@moonbone.local
611f25f932 Merge 2006-02-16 21:11:38 +03:00
evgen@moonbone.local
4d2b0fd026 Fix bug #15706 find_field_in_tables() returns field from outer select
If item->cached_table is set, find_field_in_tables() returns found field
even if it doesn't belong to current select. Because Item_field::fix_fields
doesn't expect such behaviour, reported bug occurs.

Item_field::fix_fields() was modifed to detect when find_field_in_tables() 
can return field from outer select and process such fields accordingly.
In order to ease this code which was searching and processing outed fields was
moved into separate function called Item_field::fix_outer_field().
2006-02-15 19:45:06 +03:00
anozdrin@mysql.com
378147a23d Fix for the following bugs:
- BUG#15166: Wrong update permissions required to execute triggers
  - BUG#15196: Wrong select permission required to execute triggers

The idea of the fix is to check necessary privileges
in Item_trigger_field::fix_fields(), instead of having "special variables"
technique. To achieve this, we should pass to an Item_trigger_field instance
a flag, which will indicate the usage/access type of this trigger variable.
2006-01-24 20:15:12 +03:00
monty@mysql.com
b0a5ea01ef Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/my/mysql-5.0
2006-01-06 01:08:48 +02:00
monty@mysql.com
6e22e29de6 Review fixes of new pushed code
- Fixed tests
- Optimized new code
- Fixed some unlikely core dumps
- Better bug fixes for:
  - #14397 - OPTIMIZE TABLE with an open HANDLER causes a crash
  - #14850 (ERROR 1062 when a quering a view using a Group By on a column that can be null
2006-01-06 00:47:49 +02:00
igor@rurik.mysql.com
ad53d72033 Merge rurik.mysql.com:/home/igor/mysql-5.0
into  rurik.mysql.com:/home/igor/dev/mysql-5.0-2
2005-12-10 23:31:03 -08:00
konstantin@mysql.com
bbf3a593c9 A fix and a test case for Bug#15441 "Running SP causes Server
to Crash": the bug was that due to non-standard name
resolution precedence in stored procedures (See Bug#5967)
a stored procedure variable took precedence over a table column
when the arguments for VALUES() function were resolved.
The implementation of VALUES() function was not designed to work
with Item_splocal and crashed.
VALUES() function is non-standard. It can refer to, and
is meaningful for, table columns only. The patch disables SP 
variables as possible arguments of VALUES() function.
2005-12-09 00:58:59 +03:00
anozdrin@mysql.com
5b981a4844 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/alik/Documents/AllProgs/MySQL/devel/5.0-sp-vars-merge-2
2005-12-07 17:17:42 +03:00
anozdrin@mysql.com
0ff8f60b45 Patch for WL#2894: Make stored routine variables work
according to the standard.

The idea is to use Field-classes to implement stored routines
variables. Also, we should provide facade to Item-hierarchy
by Item_field class (it is necessary, since SRVs take part
in expressions).

The patch fixes the following bugs:
  - BUG#8702: Stored Procedures: No Error/Warning shown for inappropriate data 
    type matching; 
 
  - BUG#8768: Functions: For any unsigned data type, -ve values can be passed 
    and returned; 
 
  - BUG#8769: Functions: For Int datatypes, out of range values can be passed 
    and returned; 
 
  - BUG#9078: STORED PROCDURE: Decimal digits are not displayed when we use 
    DECIMAL datatype; 
 
  - BUG#9572: Stored procedures: variable type declarations ignored; 
 
  - BUG#12903: upper function does not work inside a function; 
 
  - BUG#13705: parameters to stored procedures are not verified; 
 
  - BUG#13808: ENUM type stored procedure parameter accepts non-enumerated
    data; 
 
  - BUG#13909: Varchar Stored Procedure Parameter always BINARY string (ignores 
    CHARACTER SET); 
 
  - BUG#14161: Stored procedure cannot retrieve bigint unsigned;

  - BUG#14188: BINARY variables have no 0x00 padding;

  - BUG#15148: Stored procedure variables accept non-scalar values;
2005-12-07 17:01:17 +03:00
timour@mysql.com
6d6b617a2e Merge mysql.com:/home/timka/mysql/src/5.0-virgin
into  mysql.com:/home/timka/mysql/src/5.0-2486
2005-12-06 18:04:26 +02:00
igor@rurik.mysql.com
09e6597015 Merge rurik.mysql.com:/home/igor/mysql-5.0
into  rurik.mysql.com:/home/igor/dev/mysql-5.0-2
2005-12-02 20:42:36 -08:00
ramil@mysql.com
681252c82d Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/usr/home/ram/work/5.0.b12956
2005-12-02 11:57:26 +04:00
ramil@mysql.com
b46c240b96 Addition to fix for bug #12956: cast make differ rounding.
- use rint() in some other val_int() methods as well.
2005-11-29 18:06:58 +04:00
timour@mysql.com
cc7d1268c4 WL#2486 - Natural/using join according to SQL:2003.
Post-review fixes according to Monty's review.
2005-11-28 21:57:50 +02:00
bar@mysql.com
1263105c43 Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/usr/home/bar/mysql-5.0.param
2005-11-28 12:49:00 +04:00
bar@mysql.com
4ac260ae27 item.cc, item.h:
Fixing Item_param::safe_charset_converter to do less "new"s.
2005-11-28 12:41:44 +04: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
7d2442a160 Merge sanja.is.com.ua:/home/bell/mysql/bk/work-bug2-5.0
into  sanja.is.com.ua:/home/bell/mysql/bk/work-merge-5.0
2005-11-23 00:58:13 +02:00
bell@sanja.is.com.ua
2bcd68973b Fix for BUG#13549 "Server crash with nested stored procedures
if inner routine has more local variables than outer one, and
one of its last variables was used as argument to NOT operator".

THD::spcont was non-0 when we were parsing stored routine/trigger
definition during execution of another stored routine. This confused
methods of Item_splocal and forced them use wrong runtime context.
Fix ensures that we always have THD::spcont equal to zero during
routine/trigger body parsing. This also allows to avoid problems
with errors which occur during parsing and SQL exception handlers.
2005-11-23 00:50:37 +02:00
bell@sanja.is.com.ua
7f162c7899 Merge sanja.is.com.ua:/home/bell/mysql/bk/work-bug1-5.0
into  sanja.is.com.ua:/home/bell/mysql/bk/work-merge-5.0
2005-11-21 21:15:48 +02: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
aaf066bc86 Merge rurik.mysql.com:/home/igor/mysql-5.0
into  rurik.mysql.com:/home/igor/dev/mysql-5.0-2
2005-11-15 23:01:29 -08:00
evgen@moonbone.local
70e1974f76 Fix bug #14850 Item_ref's null_value wasn't updated
Item_ref's null_value wasn't updated in save_org_in_field() causing reported
error.
2005-11-14 21:52:39 +03:00