Commit graph

801 commits

Author SHA1 Message Date
msvensson@neptunus.(none)
128b73fc36 Merge neptunus.(none):/home/msvensson/mysql/mysql-5.0
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0-maint
2006-12-04 19:28:38 +01:00
gkodinov@dl145s.mysql.com
d253588c69 Merge dl145s.mysql.com:/data0/bk/team_tree_merge/mysql-5.0-opt
into  dl145s.mysql.com:/data0/bk/team_tree_merge/MERGE2/mysql-5.0
2006-12-04 18:05:42 +01:00
gkodinov/kgeorge@macbook.gmz
063fe51c69 item_func.cc:
fixed a valgrind warning
type_varchar.test:
  fixed a valgrind warning
2006-12-04 14:26:05 +02:00
df@kahlann.erinye.com
da7820c37d Merge dfischer@bk-internal.mysql.com:/home/bk/mysql-5.0-marvel
into  kahlann.erinye.com:/home/df/mysql/build/mysql-5.0-build
2006-12-01 13:02:54 +01:00
monty@mysql.com/narttu.mysql.fi
3d40956039 Fixed portability issue in my_thr_init.c (was added in my last push)
Fixed compiler warnings (detected by VC++):
- Removed not used variables
- Added casts
- Fixed wrong assignments to bool
- Fixed wrong calls with bool arguments
- Added missing argument to store(longlong), which caused wrong store method to be called.
2006-11-30 18:25:05 +02:00
kostja@bodhi.local
5fea0724bc Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  bodhi.local:/opt/local/work/mysql-5.0-runtime
2006-11-29 02:44:12 +03:00
msvensson@neptunus.(none)
04d5a42bbf Merge neptunus.(none):/home/msvensson/mysql/mysql-5.0
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0-maint
2006-11-28 20:59:57 +01:00
holyfoot/hf@mysql.com/deer.(none)
e95e23b0f3 Merge bk@192.168.21.1:mysql-5.0-opt
into  mysql.com:/home/hf/work/mysql-5.0-0mrg
2006-11-17 10:30:16 +04:00
cmiller@zippy.cornsilk.net
11b5d3fabc Merge zippy.cornsilk.net:/home/cmiller/work/mysql/bug19955/my50-bug19955
into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-maint
2006-11-15 12:27:09 -05:00
cmiller@zippy.cornsilk.net
5d4c57b900 Bug#19955: unsigned bigint used as signed with MOD function
Problem:  When we have a really large number (between 2^63 and 2^64)
as the left side of the mod operator, it gets improperly corerced
into a signed value.

Solution:  Added check to see if the "negative" number is really
positive, and if so, cast it.
2006-11-15 12:23:07 -05:00
cmiller@zippy.cornsilk.net
ff26bf49c8 Merge zippy.cornsilk.net:/home/cmiller/work/mysql/bug18761/my50-bug18761
into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-maint
2006-11-13 13:19:13 -05:00
cmiller@zippy.cornsilk.net
8471897fbc Bug#18761: constant expression as UDF parameters not passed in as constant
The code that set up data to be passed to user-defined functions was very
old and analyzed the "Type" of the data that was passed into the UDF, when
it really should analyze the "return_type", which is hard-coded for simple
Items and works correctly for complex ones like functions.
---
Added test at Sergei's behest.
2006-11-13 13:13:44 -05:00
dlenev@mockturtle.local
6fd6e099c9 Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  mockturtle.local:/home/dlenev/src/mysql-5.0-bg23651
2006-11-13 11:15:02 +03:00
dlenev@mockturtle.local
dd1a4f5742 Fix for bug bug#23651 "Server crashes when trigger which uses
stored function invoked from different connections".

Invocation of trigger which was using stored function from different
connections caused server crashes (for non-debug server this happened
in highly concurrent environment, but debug server failed on assertion
in relatively simple scenario).

Item_func_sp was not safe to use in triggers (in other words for
re-execution from different threads) as artificial TABLE object
pointed by Item_func_sp::dummy_table referenced incorrect THD
object. To fix the problem we force re-initialization of this
object for each re-execution of statement.
2006-11-13 11:10:49 +03:00
cmiller@zippy.cornsilk.net
6260e12b99 Bug#10963: LEFT/RIGHT/SUBSTR/.. string functions returns wrong result \
on large length
  
Problem:  Most (all) of the numeric inputs were being coerced into
int (32 bit) sized variables.  Works OK for sane inputs; any input
larger than 2^32 (or 2^31 for signed vars) exihibited predictable
wrapping behavior (up to about 10^18) and then started having really
strange behaviour past that point (since the conversion to 64 bit int
from the DECIMAL type can do weird things on out of range numbers).

Solution: 1)  Add many tests.  2)  Convert input from (u)long type to
(u)longlong.  3)  Do (sometimes multiple) sanity checks on input,
keeping in mind that sometimes a negative longlong is not a negative
longlong (if the unsigned_flag is set).  4) Emulate existing behavior
w/rt negative and "small" out-of-bounds values.
2006-11-08 10:11:02 -05:00
cmiller@zippy.cornsilk.net
40170fbf58 Merge zippy.cornsilk.net:/home/cmiller/work/mysql/bug23411/my41-bug23411
into  zippy.cornsilk.net:/home/cmiller/work/mysql/bug23411/my50-bug23411
2006-11-06 17:45:47 -05:00
cmiller@zippy.cornsilk.net
87a5134b7c Bug#23411: ... MOD-ing zero returns strange result
The Item_func_mod objects never had maybe_null set, so users had no reason 
to expect that they can be NULL, and may therefore deduce wrong results.
Now, set maybe_null.
2006-11-06 17:13:19 -05:00
holyfoot/hf@mysql.com/deer.(none)
fca6f71435 Merge bk@192.168.21.1:mysql-5.0-opt
into  mysql.com:/home/hf/work/8663/my50-8663
2006-11-06 14:57:47 +04:00
kostja@bodhi.local
6a28c436f7 Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into  bodhi.local:/opt/local/work/mysql-4.1-runtime
2006-11-02 01:08:39 +03:00
gkodinov/kgeorge@rakia.gmz
1c6ede6aac Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  rakia.gmz:/home/kgeorge/mysql/autopush/B21809-5.0-opt
2006-10-31 16:15:35 +02:00
holyfoot/hf@mysql.com/deer.(none)
18577a8e8f Bug #8663 (cant use bigint as input to CAST)
decimal->ulong conversion fixed to assign max possible ULONG if decimal
is bigger
Item_func_unsigned now handles DECIMAL parameter separately as we can't
rely on decimal::val_int result here.
2006-10-30 09:52:50 +04:00
gkodinov/kgeorge@macbook.gmz
932d86bbb9 Bug #21809: Error 1356 while selecting from view with grouping though underlying
select OK.
The SQL parser was using Item::name to transfer user defined function attributes
to the user defined function (udf). It was not distinguishing between user defined 
function call arguments and stored procedure call arguments. Setting Item::name 
was causing Item_ref::print() method to print the argument as quoted identifiers 
and caused views that reference aggregate functions as udf call arguments (and 
rely on Item::print() for the text of the view to store) to throw an undefined 
identifier error.
Overloaded Item_ref::print to print aggregate functions as such when printing
the references to aggregate functions taken out of context by split_sum_func2()
Fixed the parser to properly detect using AS clause in stored procedure arguments
as an error.
Fixed printing the arguments of udf call to print properly the udf attribute.
2006-10-24 15:26:41 +03:00
kroki/tomash@moonlight.intranet
ee0cebf9a7 BUG#21726: Incorrect result with multiple invocations of LAST_INSERT_ID.
Note: bug#21726 does not directly apply to 4.1, as it doesn't have stored
procedures.  However, 4.1 had some bugs that were fixed in 5.0 by the
patch for bug#21726, and this patch is a backport of those fixes.
Namely, in 4.1 it fixes:

  - LAST_INSERT_ID(expr) didn't return value of expr (4.1 specific).

  - LAST_INSERT_ID() could return the value generated by current
    statement if the call happens after the generation, like in

      CREATE TABLE t1 (i INT AUTO_INCREMENT PRIMARY KEY, j INT);
      INSERT INTO t1 VALUES (NULL, 0), (NULL, LAST_INSERT_ID());

  - Redundant binary log LAST_INSERT_ID_EVENTs could be generated.
2006-10-06 13:34:07 +04:00
kroki/tomash@moonlight.intranet
8798b462b5 Fix for the patch for bug#21726: Incorrect result with multiple
invocations of LAST_INSERT_ID.

Reding of LAST_INSERT_ID inside stored function wasn't noted by caller,
and no LAST_INSERT_ID_EVENT was issued for binary log.

The solution is to add THD::last_insert_id_used_bin_log, which is much
like THD::last_insert_id_used, but is reset only for upper-level
statements.  This new variable is used to issue LAST_INSERT_ID_EVENT.
2006-10-03 13:38:16 +04:00
bar@mysql.com/bar.intranet.mysql.r18.ru
72ad606ece Merge mysql.com:/usr/home/bar/mysql-4.1.b8663
into  mysql.com:/usr/home/bar/mysql-4.1-rpl
2006-10-03 11:53:01 +05:00
kroki/tomash@moonlight.intranet
5ea8adfae7 BUG#21726: Incorrect result with multiple invocations of LAST_INSERT_ID
Non-upper-level INSERTs (the ones in the body of stored procedure,
stored function, or trigger) into a table that have AUTO_INCREMENT
column didn't affected the result of LAST_INSERT_ID() on this level.

The problem was introduced with the fix of bug 6880, which in turn was
introduced with the fix of bug 3117, where current insert_id value was
remembered on the first call to LAST_INSERT_ID() (bug 3117) and was
returned from that function until it was reset before the next
_upper-level_ statement (bug 6880).

The fix for bug#21726 brings back the behaviour of version 4.0, and
implements the following: remember insert_id value at the beginning
of the statement or expression (which at that point equals to
the first insert_id value generated by the previous statement), and
return that remembered value from LAST_INSERT_ID() or @@LAST_INSERT_ID.

Thus, the value returned by LAST_INSERT_ID() is not affected by values
generated by current statement, nor by LAST_INSERT_ID(expr) calls in
this statement.

Version 5.1 does not have this bug (it was fixed by WL 3146).
2006-10-02 14:28:23 +04:00
gkodinov@dl145s.mysql.com
cf9d1c9152 Merge bk-internal:/home/bk/mysql-5.0
into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt
2006-09-18 19:01:07 +04:00
gkodinov@dl145s.mysql.com
b1e087a717 Merge dl145s.mysql.com:/data/bk/team_tree_merge/CLEAN/mysql-5.0
into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt
2006-09-15 11:52:49 +02:00
kaa@polly.local
b9811a6df1 Fixed the faulty merge 2006-09-13 19:32:21 +04:00
kaa@polly.local
cccc3da13a Merge polly.local:/tmp/20924/bug20294/my50-bug20294
into  polly.local:/home/kaa/src/maint/m50-maint--07OGt
2006-09-13 16:06:59 +04:00
kaa@polly.local
e812ae873d Merge polly.local:/tmp/20924/bug20294/my41-bug20294
into  polly.local:/tmp/20924/bug20294/my50-bug20294
2006-09-13 15:18:14 +04:00
kaa@polly.local
397f0df9ad Cset exclude: kaa@polly.local|ChangeSet|20060912122540|09861
Cset exclude: kaa@polly.local|ChangeSet|20060908100829|09983
2006-09-13 14:41:28 +04:00
kaa@polly.local
6060b5bb50 Merge polly.local:/tmp/20924/bug20294/my50-bug20294
into  polly.local:/home/kaa/src/maint/m50-maint--07OGt
2006-09-12 19:35:44 +04:00
kaa@polly.local
13331b8d24 Fixed compilation 2006-09-12 18:28:36 +04:00
kaa@polly.local
e03faff3e4 Merge polly.local:/tmp/20924/bug20294/my41-bug20294
into  polly.local:/tmp/20924/bug20294/my50-bug20294
2006-09-12 17:57:15 +04:00
kaa@polly.local
5df7611caa Post-review fixes for bug #20924 2006-09-12 16:25:40 +04:00
igor@rurik.mysql.com
9c15b7e0e8 Post-pushbuild corrections for fix of bug #21698. 2006-09-09 09:43:09 -07:00
kaa@polly.local
268c7a3522 Bug #20924: CAST(expr as UNSIGNED) returns SIGNED value when used in various functions
- Honor unsigned_flag in the corresponding functions
- Use compare_int_signed_unsigned()/compare_int_unsigned_signed() instead of explicit comparison in GREATEST() and LEAST()
2006-09-08 14:08:29 +04:00
igor@rurik.mysql.com
34206c6f80 Fixed bug #21698: erroneously a field could be replaced by an
equal constant under any circumstances.
In fact this substitution can be allowed if the field is
not of a type string or if the field reference serves as 
an argument of a comparison predicate.
2006-09-07 11:06:37 -07:00
kostja@bodhi.local
f8d34e1030 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  bodhi.local:/opt/local/work/mysql-5.0-14897
2006-08-30 00:45:33 +04:00
kroki/tomash@moonlight.intranet
b6bee0a394 BUG#21166: Prepared statement causes signal 11 on second execution
Changes in an item tree done by optimizer weren't properly
registered and went unnoticed, which resulted in preliminary freeing
of used memory.
2006-08-24 15:49:12 +04:00
evgen@moonbone.local
44cad14bf4 item_cmpfunc.cc, item.cc:
Additional fix for bug #21475
item_func.h, item_func.cc:
  Additional fix for bug#16861
2006-08-23 01:03:28 +04:00
evgen@sunlight.local
f17a536e09 Fixed bug#16861: User defined variable can have a wrong value if a tmp table was
used.

Sorting by RAND() uses a temporary table in order to get a correct results.
User defined variable was set during filling the temporary table and later
on it is substituted for its value from the temporary table. Due to this
it contains the last value stored in the temporary table.

Now if the result_field is set for the Item_func_set_user_var object it 
updates variable from the result_field value when being sent to a client.

The Item_func_set_user_var::check() now accepts a use_result_field
parameter. Depending on its value the result_field or the args[0] is used
to get current value.
2006-08-22 17:37:41 +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
kostja@bodhi.local
1b145118b9 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  bodhi.local:/opt/local/work/mysql-5.0-runtime-merge
2006-08-02 21:54:10 +04:00
evgen@moonbone.local
b7ade8e408 item_func.h, item_func.cc, sql_select.cc, item.h:
Post review changes for bug#19862.
2006-07-26 21:36:03 +04:00
evgen@moonbone.local
4ee2e07cc0 Fixed bug#19862: Sort with filesort by function evaluates function twice
When there is no index defined filesort is used to sort the result of a
query. If there is a function in the select list and the result set should be
ordered by it's value then this function will be evaluated twice. First time to
get the value of the sort key and second time to send its value to a user.
This happens because filesort when sorts a table remembers only values of its
fields but not values of functions.
All functions are affected. But taking into account that SP and UDF functions
can be both expensive and non-deterministic a temporary table should be used 
to store their results and then sort it to avoid twice SP evaluation and to 
get a correct result.

If an expression referenced in an ORDER clause contains a SP or UDF 
function, force the use of a temporary table.

A new Item_processor function called func_type_checker_processor is added
to check whether the expression contains a function of a particular type.
2006-07-26 00:31:29 +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
kroki/tomash@moonlight.intranet
a3ea06db41 Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0
into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-bug18630
2006-07-13 17:21:44 +04:00
kroki/tomash@moonlight.intranet
4272d1efc3 Bug#18630: Arguments of suid routine calculated in wrong security
context.

Routine arguments were evaluated in the security context of the routine
itself, not in the caller's context.

The bug is fixed the following way:

  - Item_func_sp::find_and_check_access() has been split into two
    functions: Item_func_sp::find_and_check_access() itself only
    finds the function and check that the caller have EXECUTE privilege
    on it.  New function set_routine_security_ctx() changes security
    context for SUID routines and checks that definer have EXECUTE
    privilege too.

  - new function sp_head::execute_trigger() is called from
    Table_triggers_list::process_triggers() instead of
    sp_head::execute_function(), and is effectively just as the
    sp_head::execute_function() is, with all non-trigger related code
    removed, and added trigger-specific security context switch.

  - call to Item_func_sp::find_and_check_access() stays outside
    of sp_head::execute_function(), and there is a code in
    sql_parse.cc before the call to sp_head::execute_procedure() that
    checks that the caller have EXECUTE privilege, but both
    sp_head::execute_function() and sp_head::execute_procedure() call
    set_routine_security_ctx() after evaluating their parameters,
    and restore the context after the body is executed.
2006-07-13 17:12:31 +04:00