Commit graph

278 commits

Author SHA1 Message Date
unknown
fb36d923ce Fixed BUG#16474: SP crashed MySQL
fix_fields() was not called for "order by" variables if the type was a
  "constant integer", and thus interpreted as a column index.
  However, a local variable is an expression and should not be interpreted
  as a column index. Instead it behaves just like when using a user variable
  for instance (i.e. it will not affect the ordering).



mysql-test/r/sp.result:
  Updated results for new test case (BUG#16474).
mysql-test/t/sp.test:
  New test case for BUG#16474.
sql/sql_select.cc:
  When processing order list,
2006-03-10 14:04:56 +01:00
unknown
942ba22ee3 Merge mysql.com:/extern/mysql/5.0/bug16887/mysql-5.0-runtime
into  mysql.com:/extern/mysql/5.0/bug16887/mysql-5.0


sql/sql_yacc.yy:
  Auto merged
mysql-test/r/sp.result:
  Manual merge.
mysql-test/t/sp.test:
  Manual merge.
2006-03-03 19:18:17 +01:00
unknown
d95921376c Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/usr/home/ram/work/5.0.b17615


mysql-test/r/sp.result:
  merging
mysql-test/t/sp.test:
  merging
2006-03-03 09:35:25 +04:00
unknown
7865ce6188 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.


mysql-test/r/sp.result:
  Updated results for new test (BUG#17476).
mysql-test/t/sp.test:
  New test case (BUG#17476)
sql/item.h:
  Removed const_string() from Item_string.
  It was only used in one place, and we can just use str_value in Item directly.
sql/item_timefunc.cc:
  Must defer a (possible) local SP variable to use max_length and str_value
  in Item_func_date_format::fix_length_and_dec(), and refer to str_value
  directly without the const_string() method (now removed); the cast didn't
  work in all cases anyway.
2006-03-02 14:54:04 +01:00
unknown
6ea2c3cd57 Fix for bug #17615: invalid handling of function results in UPDATE...SET statement.
sql/item_func.cc:
  Fix for bug #17615: invalid handling of function results in UPDATE...SET statement.
  - set proper collation
2006-03-02 15:05:55 +04:00
unknown
0afb6ff660 Fixes to embedded server to be able to run tests with it
(Needed for "list of pushes" web page and autopush)


include/mysql.h:
  Fix to embedded server to be able to run tests on it
libmysql/libmysql.c:
  Fix to embedded server to be able to run tests on it
libmysqld/emb_qcache.cc:
  Fix to embedded server to be able to run tests on it
libmysqld/embedded_priv.h:
  Fix to embedded server to be able to run tests on it
libmysqld/lib_sql.cc:
  Fix to embedded server to be able to run tests on it
libmysqld/libmysqld.c:
  Fix to embedded server to be able to run tests on it
mysql-test/mysql-test-run.sh:
  Fix to embedded server to be able to run tests on it
mysql-test/r/binlog.result:
  Updated test for embedded server
mysql-test/r/ctype_cp932.result:
  Updated test for embedded server
mysql-test/r/innodb.result:
  Updated test for embedded server
mysql-test/r/mysqltest.result:
  Updated test for embedded server
mysql-test/r/query_cache.result:
  Updated test for embedded server
mysql-test/r/query_cache_notembedded.result:
  Updated test for embedded server
mysql-test/r/sp-error.result:
  Updated test for embedded server
mysql-test/r/sp.result:
  Updated test for embedded server
mysql-test/r/subselect.result:
  Updated test for embedded server
mysql-test/r/view.result:
  Updated test for embedded server
mysql-test/r/view_grant.result:
  Updated test for embedded server
mysql-test/t/backup.test:
  Updated test for embedded server
mysql-test/t/binlog.test:
  Updated test for embedded server
mysql-test/t/blackhole.test:
  Updated test for embedded server
mysql-test/t/compress.test:
  Updated test for embedded server
mysql-test/t/ctype_cp932.test:
  Updated test for embedded server
mysql-test/t/delayed.test:
  Updated test for embedded server
mysql-test/t/handler.test:
  Updated test for embedded server
mysql-test/t/innodb.test:
  Updated test for embedded server
mysql-test/t/mysql.test:
  Updated test for embedded server
mysql-test/t/mysql_client_test.test:
  Updated test for embedded server
mysql-test/t/mysqltest.test:
  Updated test for embedded server
mysql-test/t/query_cache.test:
  Updated test for embedded server
mysql-test/t/query_cache_notembedded.test:
  Updated test for embedded server
mysql-test/t/read_only.test:
  Updated test for embedded server
mysql-test/t/skip_grants.test:
  Updated test for embedded server
mysql-test/t/sp-destruct.test:
  Updated test for embedded server
mysql-test/t/sp-error.test:
  Updated test for embedded server
mysql-test/t/sp-threads.test:
  Updated test for embedded server
mysql-test/t/sp.test:
  Updated test for embedded server
mysql-test/t/subselect.test:
  Updated test for embedded server
mysql-test/t/temp_table.test:
  Updated test for embedded server
mysql-test/t/view.test:
  Updated test for embedded server
mysql-test/t/view_grant.test:
  Updated test for embedded server
mysql-test/t/wait_timeout.test:
  Updated test for embedded server
mysys/mf_dirname.c:
  Review fix: Don't access data outside of array
mysys/my_bitmap.c:
  Remove compiler warnings
scripts/mysql_fix_privilege_tables.sql:
  Add flush privileges to .sql script so that one doesn't have to reboot mysqld when one runs the mysql_fix_privilege_script
sql-common/client.c:
  Updated test for embedded server
sql/item.cc:
  Remove DBUG_PRINT statement that can cause crashes when running with --debug
sql/mysqld.cc:
  Fix to embedded server to be able to run tests on it
sql/protocol.cc:
  Fix to embedded server to be able to run tests on it
  (Trivial reconstruction of code)
sql/protocol.h:
  Fix to embedded server to be able to run tests on it
sql/sql_base.cc:
  Better comment
sql/sql_class.cc:
  Fix to embedded server to be able to run tests on it
sql/sql_class.h:
  Fix to embedded server to be able to run tests on it
sql/sql_cursor.cc:
  Fix to embedded server to be able to run tests on it
sql/sql_parse.cc:
  Fix to embedded server to be able to run tests on it
  Don't crash for disabled commands when using embedded server
sql/sql_prepare.cc:
  Fix to embedded server to be able to run tests on it
mysql-test/r/ctype_cp932_notembedded.result:
  New BitKeeper file ``mysql-test/r/ctype_cp932_notembedded.result''
mysql-test/r/innodb_notembedded.result:
  New BitKeeper file ``mysql-test/r/innodb_notembedded.result''
mysql-test/r/sp.result.orig:
  New BitKeeper file ``mysql-test/r/sp.result.orig''
mysql-test/r/sp_notembedded.result:
  New BitKeeper file ``mysql-test/r/sp_notembedded.result''
mysql-test/r/subselect_notembedded.result:
  New BitKeeper file ``mysql-test/r/subselect_notembedded.result''
mysql-test/t/ctype_cp932_notembedded.test:
  New BitKeeper file ``mysql-test/t/ctype_cp932_notembedded.test''
mysql-test/t/innodb_notembedded.test:
  New BitKeeper file ``mysql-test/t/innodb_notembedded.test''
mysql-test/t/sp.test.orig:
  New BitKeeper file ``mysql-test/t/sp.test.orig''
mysql-test/t/sp_notembedded.test:
  New BitKeeper file ``mysql-test/t/sp_notembedded.test''
mysql-test/t/subselect_notembedded.test:
  New BitKeeper file ``mysql-test/t/subselect_notembedded.test''
2006-02-24 18:34:15 +02:00
unknown
f7295f2438 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0


mysql-test/r/sp.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
2006-02-23 10:45:39 +01:00
unknown
3a9f0e7617 Merge neptunus.(none):/home/msvensson/mysql/mysqltest_replace/my50-mysqltest_replace
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0


mysql-test/r/sp.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
client/mysqltest.c:
  Merge
mysql-test/mysql-test-run.pl:
  Merge, undo removal
mysql-test/t/mysqldump.test:
  Merge
mysql-test/t/mysqltest.test:
  Merge
2006-02-21 09:40:18 +01:00
unknown
2c07e96ca0 Use the tmp dir of MYSQLTEST_VARDIR 2006-02-16 22:10:25 +01:00
unknown
4628da295f Additional tests for nested handlers added to sp.test.
A follow-up to BUG#15011 (already fixed).


mysql-test/r/sp.result:
  Updated results for new handler tests.
mysql-test/t/sp.test:
  Additional tests for nested handlers.
2006-02-15 17:28:34 +01:00
unknown
7f02b0a01b Fixed BUG#16887: Cursor causes server segfault
The problem was a code generation bug: cpop instructions were not generated
  when using ITERATE back to an outer block from a context with a declared
  cursor; this would make it push a new cursor without popping in-between,
  eventually overrunning the cursor stack with a crash as the result.
  Fixed the calculation of how many cursors to pop (in sp_pcontext.cc:
  diff_cursors()), and also corrected diff_cursors() and diff_handlers()
  to when doing a "leave"; don't include the last context we're leaving
  (we are then jumping to the appropriate pop instructions).


mysql-test/r/sp.result:
  Updated result for new test case (BUG#16887)
mysql-test/t/sp.test:
  New test case for BUG#16887
sql/sp_pcontext.cc:
  Added new parameter to sp_pcontext::diff_handlers() and diff_cursors():
  They can either include (for iterate jumps) or exclude (for leave jumps)
  the outer context.
  Fixed bug in diff_cursors(); it was just plain wrong and would return
  zero in some situations when it shouldn't.
sql/sp_pcontext.h:
  Added new parameter to sp_pcontext::diff_handlers() and diff_cursors():
  They can either include (for iterate jumps) or exclude (for leave jumps)
  the outer context.
sql/sql_yacc.yy:
  Added parameter to diff_handlers/diff_cursors depending on if it's an
  iterate or leave jump.
  For "leave", we don't have to include the last context we're leaving since
  we will jump to the appropriate pop instructions.
2006-02-15 12:11:29 +01:00
unknown
fa461152ef Merge mysql.com:/extern/mysql/bk/mysql-5.0
into  mysql.com:/extern/mysql/work/bug16568/mysql-5.0


mysql-test/r/sp.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2006-02-06 14:09:14 +01:00
unknown
af187fa29d Fixed on BUG#16568: Continue handler with simple CASE not working correctly
After trying multiple inheritance (to messy and hard make it work) and
  sublassing jump_if_not (worked, but ugly), decided to on this solution
  instead:
  Inserting an abstract sp_instr_opt_meta class as parent for all instructions
  with destinations makes it possible to handle a continuation pointer for
  sp_instr_set_case_expr too.
  Note: No special test case; the fix is captured by the changed behaviour of
  bug14643_2, and bug14498_4 (formerly disabled), in sp.test.


mysql-test/r/sp.result:
  Updated results for BUG#16568 (affects results for bug14643_2 and bug14498_4)
mysql-test/t/sp.test:
  Enabled test bug14498_4 for BUG#16568.
sql/sp_head.cc:
  Changed type of some parameters and variables (sp_instr_opt_meta instead of sp_instr_jump*).
  Added consistency check of m_ip member in instructions in sp_head::show_routine_code().
  Updated print() method of, and added opt_mark() and opt_move() methods to
  sp_instr_set_case_expr, to handle the new continuation destination.
sql/sp_head.h:
  New abstract class between sp_instr and instructions with destinations, in particular
  sp_instr_set_case_expr, for continuation destination handling.
  Changed type of some parameters and variables (sp_instr_opt_meta instead of sp_instr_jump*).
  Added opt_mark(), opt_move() and set_destination() methods to
  sp_instr_set_case_expr.
sql/sql_parse.cc:
  Fixed small bug at show_routine_code() call (tested return value the wrong way).
sql/sql_yacc.yy:
  sp_instr_set_case_expr is now added to backpatch list (for the new cont. destination).
2006-01-26 17:26:25 +01:00
unknown
cc037976c3 Fixed BUGS#15011: error handler for mysql errno in nested block not activated
For nested sql errno handlers (unlike sqlexception and other), we didn't stop
  searching when the innermost handler was found - now make sure we do.


mysql-test/r/sp.result:
  Updated result for BUG#15011.
mysql-test/t/sp.test:
  New testcase for BUG#15011.
sql/sp_rcontext.cc:
  Make sure we stop at the innermost sql_errno handler.
2006-01-25 17:19:54 +01:00
unknown
1fe1288417 Fix of fix for BUG#15866. (Actually change the fib() call in sp.test)
mysql-test/r/sp.result:
  Updated results.
mysql-test/t/sp.test:
  Actually change the fib(20) into fib(10).  (Doh!)
2006-01-20 08:32:22 +01:00
unknown
7fc2604cd7 Fixed BUG#15866: Thread stack limit insufficient for recursive call "fib(20)"
Lowered the parameter to 10, and also renamed non-standard table names to t3.


mysql-test/r/sp.result:
  Updated results.
mysql-test/r/sp_trans.result:
  Updated results.
mysql-test/t/sp.test:
  Renamed fac, primes and fib tables to t3.
  Lowered fib() test parameter to 10 (20 hit the stack overrun check on some machines).
mysql-test/t/sp_trans.test:
  Added drop of t3 for safety. (Might be left from sp.test after certain test failures.)
2006-01-19 17:55:54 +01:00
unknown
a1187b7123 Merge mysql.com:/extern/mysql/bk/mysql-5.0
into  mysql.com:/extern/mysql/work/bug15231/mysql-5.0


mysql-test/r/sp.result:
  Manual merge.
mysql-test/t/sp.test:
  Manual merge.
2006-01-17 12:44:51 +01:00
unknown
c5216f4eee Post-merge fixes (BUG#14498)
mysql-test/r/sp-code.result:
  Post-merge fix; updated result.
mysql-test/t/sp.test:
  Post-merge fix; added comment (still can't call bug14498_4 test)
2006-01-16 17:55:22 +01:00
unknown
746705da8e Merge mysql.com:/extern/mysql/bk/mysql-5.0
into  mysql.com:/extern/mysql/work/bug14498/mysql-5.0


sql/sp_head.h:
  Auto merged
sql/sp_pcontext.h:
  Auto merged
mysql-test/r/sp.result:
  Manual merge.
mysql-test/t/sp.test:
  Manual merge.
sql/sp_head.cc:
  Manual merge.
sql/sql_yacc.yy:
  Manual merge.
2006-01-16 15:37:25 +01:00
unknown
3bf3bb2008 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/dlenev/src/mysql-5.0-bg12198-2


mysql-test/r/sp.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
sql/sp_head.cc:
  Auto merged
2006-01-13 01:56:57 +03:00
unknown
c12a3dfefd Fix for bug #12198 "Temporary table aliasing does not work inside stored
functions".

We should ignore alias when we check if table was already marked as temporary
when we calculate set of tables to be prelocked. Otherwise we will erroneously
treat tables which are used in same routine and have same name but different
alias as non-temporary.


mysql-test/r/sp.result:
  Added test for bug #12198 "Temporary table aliasing does not work inside stored
  functions" and other tests which cover handling of temporary tables in prelocked
  mode.
mysql-test/t/sp.test:
  Added test for bug #12198 "Temporary table aliasing does not work inside stored
  functions" and other tests which cover handling of temporary tables in prelocked
  mode.
sql/sp_head.cc:
  sp_head::merge_table_list():
    We should ignore alias when we check if table was already marked as temporary
    when we calculate set of tables to be prelocked. Otherwise we will erroneously
    treat tables which are used in same routine and have same name but different
    alias as non-temporary.
2006-01-13 01:51:56 +03:00
unknown
2111e2035b Added bug synopsis in comment for sp.test case BUG#15231.
mysql-test/t/sp.test:
  Added bug synopsis in comment for test case BUG#15231.
2005-12-13 13:22:15 +01:00
unknown
5e84bbcb8f Fixed BUG#15231: Stored procedure bug with not found condition handler
Make the distinction between "exception conditions" and "completion
  conditions" (warning and "no data") as defined by the standard. The latter
  should not terminate a routine if no handler is found in the lexical scope.


mysql-test/r/sp.result:
  New test case for BUG#15231.
  Moved part of the test for BUG#7049 to the new testcase (since it was actually
  an example of 15231).
mysql-test/t/sp.test:
  New test case for BUG#15231.
  Moved part of the test for BUG#7049 to the new testcase (since it was actually
  an example of 15231).
sql/sp_rcontext.cc:
  Only search for matching condition handlers in caller's contexts if it's
  an exception conditition.
2005-12-13 13:12:42 +01:00
unknown
9c4985de77 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.


mysql-test/r/sp.result:
  Test results fixed (Bug#15441).
  Also make sure that the recently added test cases follow sp.test
  internal tests standard.
mysql-test/t/sp.test:
  Add a test case for Bug#15441 "Running SP causes Server to Crash".
sql/item.cc:
  Cleanup Item_insert_value::fix_fields().
sql/item.h:
  Add a comment for Item_insert_value.
sql/sql_yacc.yy:
  Actual fix for Bug#15441 "Running SP causes Server to Crash":
  we should not allow VALUES() function to reference SP variables.
2005-12-09 00:58:59 +03:00
unknown
943edab9a5 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


mysql-test/r/sp.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/sp_head.cc:
  Merge.
2005-12-07 17:17:42 +03:00
unknown
6b2f13098a 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;


mysql-test/r/ctype_ujis.result:
  Explicitly specify correct charset.
mysql-test/r/schema.result:
  Drop our test database to not affect this test if some test
  left it cause of failure.
mysql-test/r/show_check.result:
  Drop our test database to not affect this test if some test
  left it cause of failure.
mysql-test/r/skip_name_resolve.result:
  Ignore columns with unpredictable values.
mysql-test/r/sp-big.result:
  Add cleanup statement.
mysql-test/r/sp-dynamic.result:
  Add cleanup statements.
mysql-test/r/sp.result:
  Update result file.
mysql-test/r/sum_distinct-big.result:
  Update result file.
mysql-test/r/type_newdecimal-big.result:
  Update result file.
mysql-test/t/ctype_ujis.test:
  Explicitly specify correct charset.
mysql-test/t/schema.test:
  Drop our test database to not affect this test if some test
  left it cause of failure.
mysql-test/t/show_check.test:
  Drop our test database to not affect this test if some test
  left it cause of failure.
mysql-test/t/skip_name_resolve.test:
  Ignore columns with unpredictable values.
mysql-test/t/sp-big.test:
  Add cleanup statement.
mysql-test/t/sp-dynamic.test:
  Add cleanup statements.
mysql-test/t/sp.test:
  Non-scalar values prohibited for assignment to SP-vars;
  polishing.
mysql-test/t/type_newdecimal-big.test:
  Update type specification so that the variables
  can contain the large values used in the test.
sql/field.cc:
  Extract create_field::init() to initialize an existing
  instance of create_field from new_create_field().
sql/field.h:
  Extract create_field::init() to initialize an existing
  instance of create_field from new_create_field().
sql/item.cc:
  - Introduce a new class: Item_sp_variable -- a base class
    of stored-routine-variables classes;
  - Introduce Item_case_expr -- an Item, which is used to access
    to the expression of CASE statement;
sql/item.h:
  - Introduce a new class: Item_sp_variable -- a base class
    of stored-routine-variables classes;
  - Introduce Item_case_expr -- an Item, which is used to access
    to the expression of CASE statement;
sql/item_func.cc:
  Pass the Field (instead of Item) for the return value of
  a function to the function execution routine.
sql/item_func.h:
  Pass the Field (instead of Item) for the return value of
  a function to the function execution routine.
sql/mysql_priv.h:
  Move create_virtual_tmp_table() out of sql_select.h.
sql/sp.cc:
  Use create_result_field() instead of make_field().
sql/sp_head.cc:
  - Add a function to map enum_field_types to Item::Type;
  - Add sp_instr_push_case_expr instruction -- an instruction
    to push CASE expression into the active running context;
  - Add sp_instr_pop_case_expr instruction -- an instruction
    to pop CASE expression from the active running context;
  - Adapt the SP-execution code to using Fields instead of Items
    for SP-vars;
  - Use create_field structure for field description instead of
    a set of members.
sql/sp_head.h:
  - Add a function to map enum_field_types to Item::Type;
  - Add sp_instr_push_case_expr instruction -- an instruction
    to push CASE expression into the active running context;
  - Add sp_instr_pop_case_expr instruction -- an instruction
    to pop CASE expression from the active running context;
  - Adapt the SP-execution code to using Fields instead of Items
    for SP-vars;
  - Use create_field structure for field description instead of
    a set of members.
sql/sp_pcontext.cc:
  - Change rules to assign an index of SP-variable: use
    transparent index;
  - Add an operation to retrieve a list of defined SP-vars
    from the processing context recursively.
sql/sp_pcontext.h:
  - Change rules to assign an index of SP-variable: use
    transparent index;
  - Add an operation to retrieve a list of defined SP-vars
    from the processing context recursively.
sql/sp_rcontext.cc:
  - Change rules to assign an index of SP-variable: use
    transparent index;
  - Use a tmp virtual table to store SP-vars instead of Items;
  - Provide operations to work with CASE expresion.
sql/sp_rcontext.h:
  - Change rules to assign an index of SP-variable: use
    transparent index;
  - Use a tmp virtual table to store SP-vars instead of Items;
  - Provide operations to work with CASE expresion.
sql/sql_class.cc:
  - Reflect Item_splocal ctor changes;
  - Item_splocal::get_offset() has been renamed to get_var_idx().
sql/sql_class.h:
  Polishing.
sql/sql_parse.cc:
  Extract create_field::init() to initialize an existing
  instance of create_field from new_create_field().
sql/sql_select.cc:
  Take care of BLOB columns in create_virtual_tmp_table().
sql/sql_select.h:
  Move create_virtual_tmp_table() out of sql_select.h.
sql/sql_trigger.cc:
  Use boolean constants for boolean type instead of numerical ones.
sql/sql_yacc.yy:
  Provide an instance of create_field for each SP-var.
mysql-test/include/sp-vars.inc:
  The definitions of common-procedures, which are created
  under different circumstances.
mysql-test/r/sp-vars.result:
  Result file for the SP-vars test.
mysql-test/sp-vars.test:
  A new test for checking SP-vars functionality.
2005-12-07 17:01:17 +03:00
unknown
6cf8483dfe merged
mysql-test/t/sp.test:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2005-12-07 08:50:14 +01:00
unknown
8c2d8ac750 A fix and a test case for Bug#15392 "Server crashes during
prepared statement execute


mysql-test/r/sp.result:
  Test results fixed: a fix for Bug#15392
mysql-test/t/sp.test:
  A test case for Bug#15392 "Server crashes during prepared
  statement execute". No test case for error in
  Item_func_set_user_var::update as the only possible one is OOM.
sql/sp_head.cc:
  A fix for Bug#15392 "Server crashes during prepared statement
  execute": the bug was caused by mysql_change_db() call
  which was overwriting the error state of 'ret'.
  Later in the code, suv->fix_fields() would discover
  thd->net.report_error and return it without completing
  its work. As the return value of fix_fields() was ignored,
  the server would afterwards crash in suv->update().
  The fix makes sure that a possible internal error
  is raised in reset_lex_and_exec_core and then is
  handled in sp_head::execute_procedure.
2005-12-07 00:57:15 +03:00
unknown
6b5b3f3a54 Merge
mysql-test/r/sp-error.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/share/errmsg.txt:
  SCCS merged
2005-12-06 18:21:46 +01:00
unknown
47fe447536 Merge mysql.com:/usr/local/bk/mysql-5.0
into  mysql.com:/usr/home/pem/bug14233/mysql-5.0


mysql-test/r/sp-error.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sp.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_trigger.h:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/share/errmsg.txt:
  SCCS merged
2005-12-06 13:34:18 +01:00
unknown
da8b9967a8 this has nothing to do with the bug#13012.
it's about mysql_admin_commands not being reexecution-safe
(and CHECK still isn't)


mysql-test/r/sp-error.result:
  optimize is now allowed in SP
mysql-test/r/sp.result:
  test repair/optimize/analyze in SP
mysql-test/t/backup.test:
  clean up after itself
mysql-test/t/sp-error.test:
  optimize is now allowed in SP
mysql-test/t/sp.test:
  test repair/optimize/analyze in SP
sql/sp_head.cc:
  all mysql_admin commands return result set
sql/sql_parse.cc:
  all mysql_admin commands modify table list and we should restore it for SP
sql/sql_table.cc:
  optimization - don't execute views when no view is expected/allowed
sql/sql_yacc.yy:
  optimize is now allowed in SP
2005-12-03 15:02:09 +01:00
unknown
17a024b05f Bug#13012: REPAIR/BACKUP/RESTORE TABLE cause "packet out of order" in SP.
Mark them properly as result-returning statements
2005-12-02 22:59:45 +01:00
unknown
eeec92c50b Add a test case for Bug#5967 "Stored procedure declared variable
used instead of column", the bug is to be fixed later.


mysql-test/r/sp.result:
  Test results were fixed (Bug#5967)
2005-12-02 22:43:56 +03:00
unknown
110b887c4e Merge mysql.com:/usr/local/bk/mysql-5.0
into  mysql.com:/usr/home/pem/bug14376/mysql-5.0


sql/sp_pcontext.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/r/sp.result:
  SCCS merged
mysql-test/t/sp.test:
  SCCS merged
sql/sp_pcontext.h:
  SCCS merged
2005-12-02 15:04:50 +01:00
unknown
f853fbc9f4 Fix for bug #14304: auto_increment field incorrect set from within stored procedure (insert select).
sql/sp_head.cc:
  Fix for bug #14304: auto_increment field incorrect set from within stored procedure (insert select).
  - call thd->cleanup_after_query() to clean next_insert_id.
sql/sql_class.cc:
  Fix for bug #14304: auto_increment field incorrect set from within stored procedure (insert select).
  - save/restore clear_next_insert_id
sql/sql_class.h:
  Fix for bug #14304: auto_increment field incorrect set from within stored procedure (insert select).
  - clear_next_insert_id added
2005-12-01 14:26:46 +04:00
unknown
50d615f31f Merge mysql.com:/usr/local/bk/mysql-5.0
into  mysql.com:/usr/home/pem/bug14643/mysql-5.0


sql/sp_head.cc:
  Auto merged
mysql-test/r/sp.result:
  Manual merge.
mysql-test/t/sp.test:
  Manual merge.
2005-11-28 13:20:15 +01:00
unknown
06887bc330 Enabled back bunch of tests for stored routines which were disabled
earlier because of various features/checks missing (these features/checks
are now implemented).


mysql-test/r/sp.result:
  Enabled back bunch of tests which were previously disabled because of various
  features/checks missing (since these features/checks are now implemented).
mysql-test/t/sp.test:
  Enabled back bunch of tests which were previously disabled because of various
  features/checks missing (since these features/checks are now implemented).
2005-11-26 19:15:17 +03:00
unknown
0b262a6213 Some post-merge cleaning, and made assert THD::store_globals() work at all times.
mysql-test/t/sp.test:
  Tidying up after merge.
sql/mysqld.cc:
  Make sure we have thd->thread_stack set before calling store_globals().
  (And fixed compiler warning.)
sql/sql_class.cc:
  Init THD::tread_stack in constructor.
2005-11-24 19:13:13 +01:00
unknown
ccb7673681 Merge mysql.com:/usr/local/bk/mysql-5.0
into  mysql.com:/usr/home/pem/bug13729/mysql-5.0


mysql-test/r/sp.result:
  Manual merge fix.
mysql-test/t/sp.test:
  Manual merge fix.
2005-11-24 12:12:49 +01:00
unknown
b118282377 Fixed BUG#13729 Stored procedures: packet error after exception handled
Don't set thd->is_fatal_error in sql_update for duplicate key errors.


mysql-test/r/sp.result:
  New test case for BUG#13729.
mysql-test/r/sp_trans.result:
  New test case for BUG#14840.
mysql-test/t/sp.test:
  New test case for BUG#13729.
mysql-test/t/sp_trans.test:
  New test case for BUG#14840.
sql/sql_update.cc:
  Don't set thd->is_fatal_error if it's a duplicate key error.
2005-11-23 11:56:53 +01:00
unknown
aa06123f83 Merge sanja.is.com.ua:/home/bell/mysql/bk/work-bug7-5.0
into  sanja.is.com.ua:/home/bell/mysql/bk/work-merge-5.0


mysql-test/r/sp-error.result:
  Auto merged
mysql-test/r/trigger.result:
  Auto merged
mysql-test/t/sp-error.test:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
mysql-test/t/trigger.test:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
mysql-test/r/sp.result:
  merge
sql/share/errmsg.txt:
  merge
2005-11-23 01:28:32 +02:00
unknown
164ce4c5cd Recursion support made for SP (BUG#10100).
client/mysqltest.c:
  An expected error messages hiding from the log if disable_result_log is in force.
mysql-test/r/sp-dynamic.result:
  The test expanded for case of allowed/disalowed recursion.
mysql-test/r/sp-error.result:
  Error messages changed.
  Test of bug11394() made with allowed recursion.
mysql-test/r/sp.result:
  Tests for recursion.
mysql-test/r/trigger.result:
  Check that triggers are not affected by this patch.
mysql-test/r/variables.result:
  Test of max_sp_recursion_depth variable.
mysql-test/t/sp-dynamic.test:
  The test expanded for case of allowed/disalowed recursion.
mysql-test/t/sp-error.test:
  Error messages changed.
  Test of bug11394() made with allowed recursion.
mysql-test/t/sp.test:
  Tests for recursion.
mysql-test/t/trigger.test:
  Check that triggers are not affected by this patch.
mysql-test/t/variables.test:
  Test of max_sp_recursion_depth variable.
sql/item_func.cc:
  sp_find_function() and sp_find_procedure() joined to sp_find_routine()
    function as it was mentioned in TODO.
sql/mysqld.cc:
  max_sp_recursion_depth variable added.
sql/set_var.cc:
  max_sp_recursion_depth variable added.
sql/share/errmsg.txt:
  An error message changed.
  An error message added.
sql/sp.cc:
  sp_find_function() and sp_find_procedure() joined to sp_find_routine()
    function as it was mentioned in TODO.
  Temory LEX is allocated on a stack, not on a heap.
  Recursion support added for stored procedures.
sql/sp.h:
  sp_find_function() and sp_find_procedure() joined to sp_find_routine()
    function as it was mentioned in TODO.
sql/sp_head.cc:
  Initialization of new sp_head fields to get correct list of instances
    contained one instance only.
  Stack requirement for SP instruction is increased.
  Stack free space is checked before mem root initialisation to avoid
    memory leak.
  Pointer to the free instance management added before and after
    SP execution.
sql/sp_head.h:
  New sp_head variables added to support inst of instances of SP
    for recursion and pointer on ths first free to use instance.
sql/sql_base.cc:
  open_table() consume a lot of stack space so we check free stack space before it.
sql/sql_class.h:
  max_sp_recursion_depth variable added.
sql/sql_parse.cc:
  sp_find_function() and sp_find_procedure() joined to sp_find_routine()
    function as it was mentioned in TODO.
2005-11-23 01:11:19 +02:00
unknown
a2c26aa710 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


sql/item.h:
  Auto merged
sql/protocol.cc:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_trigger.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/r/sp.result:
  merge
mysql-test/r/trigger.result:
  merge
mysql-test/t/sp.test:
  merge
mysql-test/t/trigger.test:
  merge
sql/item.cc:
  merge
sql/sp_rcontext.h:
  merge
2005-11-23 00:58:13 +02:00
unknown
6574612df8 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.


mysql-test/r/sp.result:
  Test suite for bug#13549.
mysql-test/r/trigger.result:
  Test suite for bug#13549.
mysql-test/t/sp.test:
  Test suite for bug#13549.
mysql-test/t/trigger.test:
  Test suite for bug#13549.
sql/item.cc:
  Protection against using wrong context by SP local variable.
sql/item.h:
  Protection against using wrong context by SP local variable.
sql/protocol.cc:
  An incorrect macro name fixed.
sql/protocol.h:
  An incorrect macro name fixed.
sql/sp.cc:
  Do not allow SP which we are parsing to use other SP
  context (BUG#13549).
sql/sp_head.cc:
  Protection against using wrong context by SP local variable.
sql/sp_rcontext.h:
  Protection against using wrong context by SP local variable.
sql/sql_cache.h:
  An incorrect macro name fixed.
sql/sql_class.cc:
  Protection against using wrong context by SP local variable.
sql/sql_class.h:
  Protection against using wrong context by SP local variable.
sql/sql_trigger.cc:
  Do not allow Trigger which we are parsing to use
  other SP context (BUG#13549).
sql/sql_yacc.yy:
  Protection against using wrong context by SP local variable.
2005-11-23 00:50:37 +02:00
unknown
fe94b6bfb3 A test case for Bug#14845 "mysql_stmt_fetch returns MYSQL_NO_DATA
when COUNT(*) is 0". The bug itself cannot be repeated.


mysql-test/r/sp.result:
  Test results were fixed (Bug#14845)
mysql-test/t/sp.test:
  An SQL language test case for Bug#14845
tests/mysql_client_test.c:
  A test case for Bug#14845
2005-11-18 17:55:52 +03:00
unknown
425207c938 Fixed BUG#14723: Dumping of stored functions seems to cause corruption
in the function body
  Changed the way the end of query was found from the lex state.
  The routine body was not extracted correctly when using the
  /*!version ... */ wrapper (in dump files); for some types of routines
  (e.g. with a label at the first begin), the trailing "*/" was not skipped.


mysql-test/r/sp.result:
  New test case for BUG#14723.
mysql-test/t/sp.test:
  New test case for BUG#14723.
sql/sp_head.cc:
  Changed the way the end of the definition and body is found from the lex state.
  In the case of /*!version */ wrappers we must take the trailing " */" into account.
2005-11-11 11:10:52 +01:00
unknown
850cfe786a Fixed BUG#14643: Stored Procedure: Continuing after failed var.
initialization crashes server.
  Make sure variables are initialized to something (like null) when
  the default initialization fails and a continue handler is in effect.


mysql-test/r/sp.result:
  New test case for BUG#14643.
mysql-test/t/sp.test:
  New test case for BUG#14643.
sql/sp_head.cc:
  Make sure variables are initialized to something (like null) when
  the default initialization fails and a continue handler is in effect.
  If this also fails (out of memory), we have to abort without letting
  the handler catch.
2005-11-08 14:47:33 +01:00
unknown
898adb8cfc Fixed BUG#14498: Stored procedures: hang if undefined variable and exception
The problem was to continue at the right place in the code after the
  test expression in a flow control statement fails with an exception
  (internally, the test in sp_instr_jump_if_not), and the exception is
  caught by a continue handler. Execution must then be resumed after the
  the entire flow control statement (END IF, END WHILE, etc).


mysql-test/r/sp.result:
  New test case for BUG#14498.
mysql-test/t/sp.test:
  New test case for BUG#14498.
  (Note that one call is disabled at the moment. Depends on BUG#14643.)
sql/sp_head.cc:
  Added a continuation destination for sp_instr_jump_if_not, for the case when
  an error in the test expression causes a continue handler to catch.
  This includes new members in sp_instr_jump_if_not, adjustment of the optmizer
  (mark and move methods), and separate backpatching code (since we can't use
  the normal one for this).
  
  Also removed the class sp_instr_jump, since it's never used.
  
  ...and added some comments to the optimizer.
sql/sp_head.h:
  Added a continuation destination for sp_instr_jump_if_not, for the case when
  an error in the test expression causes a continue handler to catch.
  This includes new members in sp_instr_jump_if_not, adjustment of the optmizer
  (mark and move methods), and separate backpatching code (since we can't use
  the normal one for this).
  
  Also removed the class sp_instr_jump, since it's never used.
sql/sql_yacc.yy:
  Added backpatching of the continue destination for all conditional statements
  (using sp_instr_jump_if_not).
2005-11-04 15:37:39 +01:00
unknown
3fa0dd23e0 A fix and a test case for Bug#14210 "Simple query with > operator on
large table gives server crash": make sure that when a MyISAM temporary
table is created for a cursor, it's created in its memory root,
not the memory root of the current query.


mysql-test/r/sp.result:
  Test results fixed: a test case for Bug#14210
mysql-test/t/sp.test:
  A test case for Bug#14210 "Simple query with > operator on large table 
  gives server crash"
sql/handler.cc:
  - rewrite get_new_handler to accept a memory root and use it for
sql/handler.h:
  - get_new_handler declaration changed
sql/opt_range.cc:
  - get_new_handler declaration changed
sql/sql_base.cc:
  - get_new_handler declaration changed
sql/sql_select.cc:
  - the actual fix for Bug#14210. In create_myisam_from_heap we should
  create the new table handler in TABLE::mem_root, not in THD::mem_root:
  the latter is freed shortly after cursor is open.
  - adjust create_tmp_table to explicitly supply &table->mem_root
  to get_new_handler when creating a handler for a new temporary table
sql/sql_table.cc:
  - get_new_handler declaration changed
sql/table.cc:
  - get_new_handler declaration changed
sql/unireg.cc:
  - get_new_handler declaration changed
tests/mysql_client_test.c:
  A test case for Bug#14210 "Simple query with > operator on large table
   gives server crash": a C API test case is worth adding because of different
  memory allocation/freeing patterns in handling of C API and SP cursors
2005-11-03 14:20:13 +03:00
unknown
2c4c542ba2 Fixed BUG#14376: MySQL crash on scoped variable (re)initialization
Added finer scope control for default clauses of local variable
  declarations.


mysql-test/r/sp.result:
  New test case for BUG#14376.
mysql-test/t/sp.test:
  New test case for BUG#14376.
sql/sp_pcontext.cc:
  Added boundary variable for local parameters/variables,
  for better scope control of default values.
sql/sp_pcontext.h:
  Added boundary variable for local parameters/variables,
  for better scope control of default values.
sql/sql_yacc.yy:
  Make the variables of the current DECLARE "invisible" to its DEFAULT clause.
2005-11-01 14:58:52 +01:00