Commit graph

776 commits

Author SHA1 Message Date
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
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
kostja@bodhi.local
2ab1e065e4 Fix compiler warnings in sql_udf.h: ISO C++ forbids casting
between pointer to function and pointer to object.
2006-07-09 13:03:51 +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
ramil@mysql.com
10914578f1 Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/usr/home/ram/work/mysql-5.0
2006-06-16 16:43:44 +05:00
ramil@mysql.com
f2899063ee after-merge fixes. 2006-06-16 14:05:58 +05:00
serg@serg.mylan
816bd73362 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into serg.mylan:/usr/home/serg/Abk/mysql-5.0
2006-06-16 10:01:13 +02:00
serg@serg.mylan
16861b2e3b Bug#14708: Inconsistent treatment of NULLs in LEFT JOINed FULLTEXT matching without index
Don't rely on table->null_row when no index is used - it may be a multi-table search
2006-06-16 09:49:18 +02: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
ramil@mysql.com
0bdae38efb Fix for bug #6880: LAST_INSERT_ID() within a statement 2006-06-07 14:01:10 +05: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
knielsen@mysql.com
c8fd62f3b2 After-merge fixes; some function signatures changed from Item * to Item **. 2006-05-15 19:57:10 +02:00
konstantin@mysql.com
85c6883146 Merge mysql.com:/opt/local/work/mysql-5.0-root
into  mysql.com:/opt/local/work/mysql-5.0-runtime-merge
2006-05-15 00:51:12 +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
anozdrin@mysql.com
65b87b86a3 Fix for BUG#18587: Function that accepts and returns TEXT
garbles data if longer than 766 chars.

The problem is that a stored routine returns BLOBs to the previous
caller, BLOBs are shallow-copied (i.e. only pointers to the data are
copied). The fix is to also copy data of BLOBs.
2006-05-10 23:16:30 +04:00
msvensson@neptunus.(none)
2759603c1d Merge neptunus.(none):/home/msvensson/mysql/mysql-5.0-maint
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0
2006-05-09 10:44:19 +02:00
aelkin@mysql.com
899cf9b584 Merge mysql.com:/usr_rh9/home/elkin.rh9/4.1
into  mysql.com:/usr_rh9/home/elkin.rh9/MySQL/Merge/5.0-bug19136
2006-05-07 16:02:55 +03:00
aelkin@mysql.com
7dcd1383a8 Merge mysql.com:/usr_rh9/home/elkin.rh9/MySQL/BARE/4.1
into  mysql.com:/usr_rh9/home/elkin.rh9/MySQL/FIXES/4.1-bug19136_unass_user_var
2006-05-07 11:43:27 +03:00
kroki@mysql.com
0acef25de8 Merge mysql.com:/home/tomash/src/mysql_ab/tmp_merge
into  mysql.com:/home/tomash/src/mysql_ab/mysql-5.0-merge
2006-05-06 11:18:42 +04:00
aelkin@mysql.com
8c57924a6a Bug#19136: Crashing log-bin and uninitialized user variables in a derived table
The reason of the bug is in that `get_var_with_binlog' performs missed
assingment of
the variables as side-effect. Doing that it eventually calls
`free_underlaid_joins' to pass as an argument `thd->lex->select_lex' of the lex
which belongs to the user query, not 
to one which is emulated i.e SET @var1:=NULL.


`get_var_with_binlog' is refined to supply a temporary lex to sql_set_variables's stack.
2006-05-05 11:21:21 +03:00
msvensson@shellback.(none)
53b842866e Fix small bug in udf_example.cc, it was processing one char too much and thus returning junk
Add more DBUG_PRINT's in udf_handler::val_str
Enable udf.test
2006-04-28 11:37:20 +02:00
jimw@mysql.com
ca2b14e7b4 Merge mysql.com:/home/jimw/my/mysql-5.0-12792
into  mysql.com:/home/jimw/my/mysql-5.0-clean
2006-04-26 11:39:48 -07:00
kroki@mysql.com
c77336c260 Bug#16501: IS_USED_LOCK does not appear to work
Update User_level_lock::thread_id on acquiring an existing lock,
and reset it on lock release.
2006-04-24 18:06:43 +04:00
jimw@mysql.com
ec00b92f48 Bug #12792: @@system_time_zone is not SELECTable
Bug #15684: @@version_* are not all SELECTable

  Added the appropriate information as read-only system variables, and
  also removed some special-case handling of @@version along the way.

  @@version_bdb was added, but isn't included in the test because it
  depends on the presence of BDB.
2006-04-20 21:56:53 -07:00
dlenev@mysql.com
19e558a09d Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  mysql.com:/home/dlenev/mysql-5.0-bg16021
2006-04-19 19:35:32 +04:00
pem@mysql.com
868ffcca86 Merge mysql.com:/extern/mysql/bk/mysql-5.0-runtime
into  mysql.com:/extern/mysql/5.0/bug18787/mysql-5.0-runtime
2006-04-18 11:20:18 +02:00