Commit graph

220 commits

Author SHA1 Message Date
unknown
06eabeeea8 Fixed BUG#12589: Assert when creating temp. table from decimal stored
procedure variable
  Second version, after review.
  Keep the unsigned_flag in Item_decimal updated. Note that this also changed
  the result of several old test results - creating tables from decimal
  templates now gives unsigned columns and different sizes. (Several tests
  had Length > Max_length before.)


mysql-test/r/case.result:
  Updated result (after fixing BUG#12589).
mysql-test/r/metadata.result:
  Updated result (after fixing BUG#12589).
mysql-test/r/ps_2myisam.result:
  Updated result (after fixing BUG#12589).
mysql-test/r/ps_3innodb.result:
  Updated result (after fixing BUG#12589).
mysql-test/r/ps_4heap.result:
  Updated result (after fixing BUG#12589).
mysql-test/r/ps_5merge.result:
  Updated result (after fixing BUG#12589).
mysql-test/r/ps_6bdb.result:
  Updated result (after fixing BUG#12589).
mysql-test/r/ps_7ndb.result:
  Updated result (after fixing BUG#12589).
mysql-test/r/sp.result:
  New test case for BUG#12589.
mysql-test/r/type_newdecimal.result:
  Updated result (after fixing BUG#12589).
mysql-test/t/sp.test:
  New test case for BUG#12589.
sql/item.cc:
  Keep the unsigned_flag updated in Item_splocal and Item_decimal.
2005-09-27 17:07:28 +02:00
unknown
ad8ff14165 Fixed BUG#6127: Stored procedure handlers within handlers don't work
Replaced the dumb in-handler/not-in-handler check with a proper recursion
    check of handlers being executed.
    (Re-commit in a different tree, to make push possible.)


mysql-test/r/sp.result:
  New test case for BUG#6127.
mysql-test/t/sp.test:
  New test case for BUG#6127.
sql/sp_head.cc:
  Replaced the setting of ctx->in_handler with a enter/exit handler methods.
sql/sp_rcontext.cc:
  Replaced the boolean in_handler flag with a stack of handlers being exectuted, for proper recursion check.
sql/sp_rcontext.h:
  Replaced the boolean in_handler flag with a stack of handlers being exectuted, for proper recursion check.
  (And added some comments in the sp_rcontext class.)
2005-09-26 18:22:00 +02:00
unknown
7a47331f7d Manual merge
sql/item_func.cc:
  Auto merged
2005-09-20 03:31:00 +04:00
unknown
43dd29dfaa Fix bug #12812 create view calling a function works without execute right on function
Execution rigths on function was checked just before function execution,
thus it was unknown on prepare stage whether user have right to execute 
particular function.

Added access rights checking function which is called right after fixing
Item_func_sp.
This have additional effect that if user don't have rights for execution
query will fail on earlier stage and will not waste resources on optimizing
with failing on execution stage.


sql/item_func.h:
  Fix bug#12812 create view calling a function works without execute right on function
sql/item_func.cc:
  Fix bug#12812 create view calling a function works without execute right on function
  Added function Item_func_sp::check_access() which checks access rights.
  Added function Item_func_sp::fix_field() which calls check_access() after fixing.
  Item_func_sp::execute() now calls to check_access() to check access rights.
mysql-test/t/sp.test:
  Test case for bug#12812 create view calling a function works without execute right on function
mysql-test/r/sp.result:
  Test case for bug#12812 create view calling a function works without execute right on function
2005-09-20 03:05:35 +04:00
unknown
0b318fd64f Merge pchardin@bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/cps/mysql/trees/mysql-5.0-virgin


mysql-test/r/sp.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
2005-09-14 14:54:48 +04:00
unknown
8c86f8e4bf Post-review fix for BUG#12712: SET AUTOCOMMIT should fail within SP/functions/triggers
mysql-test/r/sp.result:
  Added missing drop table.
mysql-test/t/sp.test:
  Added missing drop table.
sql/sp_head.h:
  Post-review fix for autocommit check in SPs and triggers.
sql/sql_yacc.yy:
  Post-review fix for autocommit check in SPs and triggers.
2005-09-14 10:54:02 +02:00
unknown
685173664a fix for Bug #12979 Stored procedures: crash if inout decimal parameter
mysql-test/r/sp.result:
  fix result
mysql-test/r/type_newdecimal.result:
  fix result
mysql-test/t/sp.test:
  add a test for the bug
mysql-test/t/type_newdecimal.test:
  add a test for the bug
sql/item_func.cc:
  call correct method of the item
2005-09-14 07:25:32 +04:00
unknown
3a1801b49b Merge pchardin@bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/cps/mysql/trees/mysql-5.0-virgin


mysql-test/t/sp.test:
  Auto merged
mysql-test/r/sp.result:
  SCCS merged
2005-09-13 18:54:47 +04:00
unknown
b6aba9db70 Fixed BUG#12379: PROCEDURE with HANDLER calling FUNCTION with error
get strange result
  according to Monty's suggestions, fixing the SELECT behaviour on errors
  with SP handlers. Note that some warnings from SELECT still shows up when
  the handler has caught - this is an effect of another known bug (BUG#7049).


mysql-test/r/sp.result:
  New test cases for BUG#12379.
mysql-test/t/sp.test:
  New test cases for BUG#12379.
sql/sql_class.cc:
  Abort selects on errors more graceful with SP handlers.
sql/sql_class.h:
  Abort selects on errors more graceful with SP handlers.
2005-09-13 15:32:42 +02:00
unknown
7f70f599c3 Merge pchardin@bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/cps/mysql/trees/mysql-5.0


mysql-test/r/sp.result:
  manual merge
mysql-test/t/sp.test:
  manual merge
2005-09-13 17:05:17 +04:00
unknown
dd51642361 Fix for Bug #13124 Stored Procedure using SELECT INTO crashes server
mysql-test/r/sp.result:
  added a test
mysql-test/t/sp.test:
  corrected result file
sql/item.cc:
  check for NULL value before copying string
2005-09-13 15:15:38 +04:00
unknown
902932a1e8 Fixed BUG#13133: Local variables in stored procedures are not initialized correctly.
Have to init. all local variables in their frames, not just once at the beginning
  of invocation.


mysql-test/r/sp.result:
  New test case for BUG#13133.
mysql-test/t/sp.test:
  New test case for BUG#13133.
sql/sp_head.cc:
  Just init. local variable slots in the fram to NULL. (Real init. will be done
  in each block.)
sql/sp_pcontext.cc:
  Removed isset flag, since it's not used.
sql/sp_pcontext.h:
  Removed isset flag, since it's not used.
sql/sql_yacc.yy:
  Initialize local variables in the block to null, or the default value, given.
  (Untabifed block too.)
2005-09-13 12:50:21 +02:00
unknown
5ed7e97310 Merge spetrunia@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/psergey/mysql-5.0-bug12943


mysql-test/r/sp.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
2005-09-09 10:08:46 +04:00
unknown
1b15f430d6 fix for Bug #12849 Stored Procedure: Crash on procedure call with CHAR type 'INOUT' parameter
(recommit with the right Bug#)


mysql-test/r/sp.result:
  result file modified to reflect new test
mysql-test/t/sp.test:
  added test for the bug
sql/item.cc:
  protect Item_splocal value from modification by CONCAT() et al
sql/item.h:
  added a buffer to save Item_splocal string pointer
sql/sp_head.cc:
  don't employ reuse mechanism to save var into itself
2005-09-08 18:25:42 +02:00
unknown
eb769e54b8 Fix for BUG#12637: Make SPs+user variables replication work:
* Allocate thd->user_var_events elements on appropriate mem_root
* If several SP statements are binlogged as a single statement, collect all user var
  accesses they make (grep for StoredRoutinesBinlogging for details)


mysql-test/r/rpl_sp_effects.result:
  Testcase for BUG#12637
mysql-test/r/sp.result:
  re-enabled test case for BUG#12297
mysql-test/t/rpl_sp_effects.test:
  Testcase for BUG#12637
mysql-test/t/sp.test:
  re-enabled test case for BUG#12297
sql/item_func.cc:
  Fix for BUG#12637: Make SPs+user variables replication work:
  * Allocate thd->user_var_events elements on appropriate mem_root
  * If several SP statements are binlogged as a single statement, collect all user var
    accesses they make.
sql/log.cc:
  Fix for BUG#12637: Make SPs+user variables replication work:
  * Allocate thd->user_var_events elements on appropriate mem_root
  * If several SP statements are binlogged as a single statement, collect all user var
    accesses they make.
sql/sp_head.cc:
  Fix for BUG#12637: Make SPs+user variables replication work:
  * Allocate thd->user_var_events elements on appropriate mem_root
  * If several SP statements are binlogged as a single statement, collect all user var
    accesses they make.
sql/sp_head.h:
  Remove compiler warning.
sql/sql_class.h:
  Fix for BUG#12637: Make SPs+user variables replication work.
sql/sql_parse.cc:
  Fix for BUG#12637: Make SPs+user variables replication work.
2005-09-07 19:39:47 +04:00
unknown
d5be483c62 retest the fix for bug #10362 (SHOW PROCEDURE always qualifies name with database)
(already approved)


mysql-test/r/information_schema.result:
  update test results
mysql-test/r/sp.result:
  update test results
mysql-test/r/sql_mode.result:
  update test results
sql/sp.cc:
  don qualify the name
2005-08-27 12:29:36 +02:00
unknown
bddf61cfb3 Bug#9048
"Creating a function with char binary IN parameter fails"
  Parse BINARY as part of type declaration, not as 
  a column attribute.


mysql-test/r/sp.result:
  test for bug 9048
mysql-test/t/sp.test:
  test for bug 9048
sql/sql_yacc.yy:
  fix bug 9048
  parse BINARY as part of type declaration and not as column modifier.
2005-08-27 07:26:14 +01:00
unknown
da7a46ad9f Merge pchardin@bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/cps/mysql/devel/mysql-5.0-sp11333


mysql-test/r/sp.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/sp_head.cc:
  manual merge
2005-08-25 16:06:49 +04:00
unknown
d29df5645b Fix Bug#11333 "Stored Procedure: Memory blow up on repeated SELECT ... INTO query"
mysql-test/r/sp.result:
  update result
mysql-test/t/sp.test:
  Add test for Bug #11333 "Stored Procedure: Memory blow up on repeated SELECT ... INTO query"
sql/item.cc:
  we should call destructors for Items before reuse
sql/item.h:
  Add new method and constructor for Item_string.
sql/sp_head.cc:
  String allocation should be done on the system heap for now.
2005-08-25 15:34:14 +04:00
unknown
0183ec75e1 fix test for a bug to use correct tables
mysql-test/r/sp.result:
  fix result
mysql-test/t/sp.test:
  fix test for a bug: tests in sp.test should reuse tables t1 and t2 and create/drop tables t3, t4 etc.
  So, tables t1 and t2 were renamed into t3 and t4
2005-08-24 12:25:57 +04:00
unknown
276bd123b7 A fix and a test case for "Bug #12168 'DECLARE CONTINUE HANDLER FOR
NOT FOUND ...' in conditional handled incorrectly".

Whenever we remove an instruction during optimization, we need to
adjust instruction numbers (ip - instruction pointer) stored in all
instructions. In addition to that, sp_instr_hpush_jump, which 
corresponds to DECLARE CONTINUE HANDLER needs adjustment for m_handler,
which holds the number of instruction with the continue handler.
In the bug report, a wrong ip stored in m_handler was pointing at 
FETCH, which resulted in an error message and abnormal SP termination.
The fix is to just remove m_handler member from sp_instr_hpush_jump,
as it's always points to the instruction next to the DECLARE
statement itself (m_ip+1).


mysql-test/r/sp.result:
  Test results fixed (Bug#12168)
mysql-test/t/sp.test:
  A test case for Bug#12168 "'DECLARE CONTINUE HANDLER FOR NOT
  FOUND ...' in conditional handled incorrectly"
sql/sp_head.cc:
  Remove m_handler (the number of continue handler instruction)
  as it always equal to m_ip+1
sql/sp_head.h:
  Remove m_handler (the number of continue handler instruction)
  as it always equal to m_ip+1
2005-08-19 17:03:21 +04:00
unknown
fa19a9f246 Fix for Bug#11247 Stored procedures: Function calls in long loops leak memory
and Bug#12297 SP crashes the server if data inserted inside a lon loop
Third commit attempt. With fixes to the issues, showed up after full rebuild and
tests on other hosts.


mysql-test/r/rpl_sp.result:
  New warnings appeared in result file, as now we always create spcont in a stored routine.
  This is correct behaviour. We swallowed some warnings, as we used thd->spcont to check whether
  we are in the SP though we didn't set spcont in certain cases. This is fixed now.
mysql-test/r/sp.result:
  fixed result file to reflect new tests
mysql-test/t/sp.test:
  Added tests for bugs. Though one of them is disabled, as it fails because of the other bug.
  It should be enabled, when bug 12297 is fixed.
sql/sp_head.cc:
  Per-instruction arena is implemented
sql/sp_rcontext.cc:
   Now we should deal with callers_arena->free_list when we employ reuse mechanism with callers_arena
   switched during sp_eval_func_item
sql/sp_rcontext.h:
  Add new member to sp_rcontext class, in order to handle instructions with assignment
  and/or with nested SP processing properly.
2005-08-18 11:23:54 +02:00
unknown
8103db27bb Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/dlenev/src/mysql-5.0-is


mysql-test/r/information_schema.result:
  Auto merged
mysql-test/t/information_schema.test:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sp.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
mysql-test/r/sp.result:
  Manual merge
mysql-test/t/sp.test:
  Manual merge
sql/sql_class.h:
  Manual merge
2005-08-09 11:43:55 +04:00
unknown
39fda60043 Fix for bug #10055 "Using stored function with information_schema causes empty
result set".

To enable full access to contents of I_S tables from stored functions
or statements that use them, we manipulate with thread's open tables
state and ensure that we won't cause deadlock when we open tables by
ignoring flushes and name-locks.
Building of contents of I_S.TABLES no longer requires locking of tables
since we use use handler::info() method with HA_STATUS_AUTO flag instead
of handler::update_auto_increment() for obtaining information about
auto-increment values. But this also means that handlers have to implement
support for HA_STATUS_AUTO flag (particularly InnoDB needs it).


mysql-test/r/alter_table.result:
  Updated test results. This change was caused by the fact that now when
  we build contents of I_S tables (and thus output of SHOW INDEX) we
  don't use instances of tables which may be already opened and locked
  by thread (we always use new instance).
mysql-test/r/information_schema.result:
  Added test which checks how information about current auto-increment value for
  table is reported in INFORMATION_SCHEMA.TABLES view.
mysql-test/r/sp.result:
  Added test for bug #10055 "Using stored function with information_schema causes
  empty result set".
mysql-test/t/information_schema.test:
  Added test which checks how information about current auto-increment value for
  table is reported in INFORMATION_SCHEMA.TABLES view.
mysql-test/t/sp.test:
  Added test for bug #10055 "Using stored function with information_schema causes
  empty result set".
sql/mysql_priv.h:
  close_thread_tables():
    Get rid of 'stopper' argument which is no longer used. Now when we need
    to open and then close some table without touching tables which are already
    opened we use THD::reset_n/restore_backup_open_tables_state() methods.
  open_tables()/open_normal_and_derived_tables():
    Added 'flags' argument to be able open tables even if some has done
    a flush or hold namelock on them.
sql/sp.cc:
  close_proc_table/open_proc_table_for_read/db_find_routine():
    Replaced push_open_tables_state/pop_open_tables_state() methods which
    were saving/restoring current open tables state in/from THD::open_state_list
    with reset_n_backup_open_tables_state/restore_backup_open_tables_state()
    methods which assume that backup storage for this state is allocated on
    stack (or elsewhere) by their caller.
  open_proc_table_for_read():
    Since now we can have several open tables states stacked up we can't rely
    rely on checking whether we have some tables open in previous state.
    Instead we always assume that some tables are open and we need to ignore
    flush while locking mysql.proc. We don't really need 
    MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK in this case since we open mysql.proc table
    only for reading.
sql/sp.h:
  Added declarations of open_proc_table_for_read()/close_proc_table() to be
  able to use them in sql_show.cc.
sql/sql_base.cc:
  close_thread_tables():
    Get rid of 'stopper' argument which is no longer used. Now when we need
    to open and then close some table without touching tables which are already
    opened we use THD::reset_n/restore_backup_open_tables_state() methods.
  open_tables()/open_normal_and_derived_tables():
    Added 'flags' argument to be able open tables even if some has done
    a flush or hold namelock on them.
sql/sql_class.cc:
  Open_tables_state, THD:
    Replaced push_open_tables_state/pop_open_tables_state() methods which
    were saving/restoring current open tables state in/from THD::open_state_list
    with reset_n_backup_open_tables_state/restore_backup_open_tables_state()
    methods which assume that backup storage for this state is allocated on
    stack (or elsewhere) by their caller.
sql/sql_class.h:
  Open_tables_state, THD:
    Replaced push_open_tables_state/pop_open_tables_state() methods which
    were saving/restoring current open tables state in/from THD::open_state_list
    with reset_n_backup_open_tables_state/restore_backup_open_tables_state()
    methods which assume that backup storage for this state is allocated on
    stack (or elsewhere) by their caller.
sql/sql_handler.cc:
  open_tables()/open_normal_and_derived_tables():
    Added 'flags' argument to be able open tables even if some has done
    a flush or hold namelock on them.
sql/sql_prepare.cc:
  open_tables()/open_normal_and_derived_tables():
    Added 'flags' argument to be able open tables even if some has done
    a flush or hold namelock on them.
sql/sql_show.cc:
  get_all_tables():
    Now we use THD::reset_n_/restore_backup_open_tables_state() for 
    saving/restoring open tables state instead of working with it directly
    (This also allows us to have proper content of I_S system tables in
    statements with stored functions and in stored functions). We also
    ignore possible flushes when opening tables (we may create deadlock
    otherwise). Also we do all needed manipulations with LEX in this function
    and not in get_schema_tables_result() now.
  get_schema_tables_record():
    Let us use handler::info() method with HA_STATUS_AUTO flag for obtaining
    information about table's auto-increment value. This allows to avoid locking
    of tables which is needed when we use handler::update_auto_increment() method.
  fill_schema_proc():
    Now we use open_proc_table_for_read/close_proc_table() for access to
    mysql.proc table (so we won't cause deadlock if we already have some
    tables open and locked, this also allows us to have proper content in
    ROUTINES system table in statements using stored functions/in stored
    functions).
  get_schema_tables_result():
    Moved all manipulations with Open_tables_state and LEX needed for
    safe opening of tables to ST_SCHEMA_TABLE::fill_table functions
    (i.e. get_all_tables() and fill_schema_proc()).
sql/sql_update.cc:
  open_tables()/open_normal_and_derived_tables():
    Added 'flags' argument to be able open tables even if some has done
    a flush or hold namelock on them.
2005-08-08 17:46:06 +04:00
unknown
e442059c0d Manual merge
mysql-test/r/sp.result:
  Auto merged
mysql-test/r/view.result:
  Auto merged
mysql-test/t/view.test:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_trigger.h:
  Auto merged
2005-08-03 03:47:07 +00:00
unknown
b323667ffc Prelocking-free SPs, post-review fixes:
* Don't activate prelocking mode for evaluating procedure arguments when it is not necessary.
* Code structure simplification and cleanup.
* Cleanup in .test files


mysql-test/r/sp-prelocking.result:
  Prelocking-free SPs, post-review fixes:
  Added comment, s/testdb/mysqltest/, fixed a wrong test (error wasnt reported because of known bug in mysqltestrun)
mysql-test/r/sp-security.result:
  Don't drop the table we're not using.
mysql-test/r/sp.result:
  Prelocking-free SPs, post-review fixes:
  remove redundant "drop table if exists t3" statements
mysql-test/t/sp-prelocking.test:
  Prelocking-free SPs, post-review fixes:
  Added comment, s/testdb/mysqltest/, fixed a wrong test (error wasnt reported because of known bug in mysqltestrun)
mysql-test/t/sp-security.test:
  Don't drop the table we're not using.
mysql-test/t/sp.test:
  Prelocking-free SPs, post-review fixes:
  remove redundant "drop table if exists t3" statements
sql/sp.cc:
  New, better defined, sp_get_prelocking_info() function to get info about
    statement prelocking options
sql/sp.h:
  Prelocking-free SPs, post-review fixes: New, better defined, sp_get_prelocking_info() 
  function to get info about statement prelocking options
sql/sp_cache.h:
  Prelocking-free SPs, post-review fixes: Amended the comments
sql/sp_head.cc:
  Prelocking-free SPs, post-review fixes: Amend the comments, simplify the code that 
  attaches removes statement's prelocking tables.
sql/sql_base.cc:
  Prelocking-free SPs, post-review fixes:
  * Use a better defined sp_get_prelocking_info() function to get info about 
    statement prelocking options
  * Don't activate prelocked mode for evaluation of SP arguments that use tables 
    but don't need prelocking.
sql/sql_class.cc:
  Prelocking-free SPs, post-review fixes: Initialize THD members in the order they are declared.
2005-08-03 03:37:32 +00:00
unknown
11abe15eab Added Non-prelocked SP execution: Now a PROCEDURE doesn't enter/leave prelocked mode for
its body, but lets each statement to get/release its own locks. This allows a broader set
of statements to be executed inside PROCEDUREs (but breaks replication)
This patch should fix BUG#8072, BUG#8766, BUG#9563, BUG#11126


mysql-test/r/sp-security.result:
  Drop tables this test attempts to create
mysql-test/r/sp-threads.result:
  Update test results
mysql-test/r/sp.result:
  Disabled a test that triggers BUG#11986, cleanup used tables when tests start.
mysql-test/r/view.result:
  Enabled a test case that now works with prelocking-free SPs
mysql-test/t/sp-security.test:
  Drop tables this test attempts to create
mysql-test/t/sp.test:
  Disabled a test that triggers BUG#11986, cleanup used tables when tests start.
mysql-test/t/view.test:
  Enabled a test case that now works with prelocking-free SPs
sql/handler.cc:
  Rename: thd->transaction.in_sub_stmt -> thd->in_sub_stmt
sql/item_func.cc:
  Rename: thd->transaction.in_sub_stmt -> thd->in_sub_stmt
sql/sp.cc:
  Non-prelocked SP execution: Added support for skipping prelocking of procedure body for
  "CALL proc(...)" statements.
sql/sp.h:
  Non-prelocked SP execution: Added support for skipping prelocking of procedure body for
  "CALL proc(...)" statements.
sql/sp_cache.h:
  Added comments
sql/sp_head.cc:
  Non-prelocked SP execution:
  * Try to unlock tables after PROCEDURE arguments have been evaluated.
  * Make sp_lex_keeper be able to execute in 2 modes: A) when already in prelocked mode
    B) when its statement enters/leaves prelocked mode itself.
sql/sp_head.h:
  Non-prelocked SP execution:  Make sp_lex_keeper to additionally keep list of tables it 
  needs to prelock when its statement enters/leaves prelocked mode on its own.
sql/sql_base.cc:
  Non-prelocked SP execution: Make open_tables() to
   * detect 'CALL proc(...)' and not to do prelocking for procedure body statements.
   * Make lex->query_tables_last to point precisely to a boundary in lex->query_tables 
     list where 'own' tables and views' tables end and added-for-prelocking tables begin.
     (it was not true before - view's tables could end up after query_tables_own_last)
sql/sql_class.cc:
  Rename: thd->transaction.in_sub_stmt -> thd->in_sub_stmt
sql/sql_class.h:
  Rename: thd->transaction.in_sub_stmt -> thd->in_sub_stmt
sql/sql_lex.cc:
  Non-prelocked SP execution: More rigourous cleanup in st_lex::cleanup_after_one_table_open()
sql/sql_parse.cc:
  Rename: thd->transaction.in_sub_stmt -> thd->in_sub_stmt, remove outdated comments
sql/sql_trigger.h:
  Rename: thd->transaction.in_sub_stmt -> thd->in_sub_stmt
2005-07-30 08:19:57 +00:00
unknown
675c4bb48c Added sql_mode saving to mysql_dump (BUG#5891, part 2)
client/client_priv.h:
  add OPT_ for --trigger parameter
client/mysqldump.c:
  fixed short simbol for trigger
  fixed lines break for more compiler compatibility
  added sql_mode output
  added comments
  made protection of trigger and view restoring commands from execution by old versions of mysql
mysql-test/r/mysqldump.result:
  changed test, to test sql_mode
mysql-test/r/sp.result:
  now sql_mode preserved in SP
mysql-test/t/mysqldump.test:
  changed test, to test sql_mode
mysql-test/t/sp.test:
  now sql_mode preserved in SP
sql/set_var.cc:
  fixed comment
2005-07-29 23:39:08 +03:00
unknown
0c17b6ed37 fix for bug#8692
mysql-test/r/sp.result:
  added expected result for bug #8692
mysql-test/t/sp.test:
  added testcase for bug #8692
sql/protocol_cursor.cc:
  fixed detecting of null fields: A field contains a null value only 
  if length is NULL_LENGTH
2005-07-22 08:11:23 +02:00
unknown
7bdc4dd0a1 After-merge fixes (4.1 -> 5.0).
mysql-test/r/sp.result:
  Test results fixed: rewritten test for Bug#6129
mysql-test/r/view.result:
  Push a change to the result file from Sanja's patch.
mysql-test/t/sp.test:
  Rewrite the test for Bug#6129 (now that stored procedures don't
  evaluate system variables at parse, the test produced different results).
  The old test failed with 1 in the second invocation (the old
  result was wrong).
sql/item_func.cc:
  After-merge fix.
sql/item_func.h:
  After-merge fix.
sql/mysql_priv.h:
  After-merge fix.
sql/mysqld.cc:
  Rollback the patch for Bug#7403 (it breaks the test suite).
2005-07-16 16:10:42 +04:00
unknown
51308e2327 Post-review fix: Made test bug9538 test robust.
mysql-test/r/sp.result:
  Made test bug9538 test robust.
mysql-test/t/sp.test:
  Made test bug9538 test robust.
2005-07-15 19:46:44 +02:00
unknown
6f619804fc Fixed BUG#9538: SProc: Creation fails if we try to SET system variable
using @@var_name in proc
  Made sure we don't lose the tokenizer state when swapping lex in during SET
  parsing.


mysql-test/r/sp.result:
  New test case for BUG#9538.
mysql-test/t/sp.test:
  New test case for BUG#9538.
sql/sp_head.cc:
  Keep lex->next_state when swapping lex during SP parsing (for SET mainly),
  otherwise the tokenizer gets confused.
2005-07-15 17:24:19 +02:00
unknown
32e157ec0b Added test case for bug #9565 "Wrong locking in stored procedure if a
sub-sequent procedure is called" which was fixed by the same patch
as bug #9597 "read lock stays when querying view from stored procedure".


mysql-test/r/sp.result:
  Added test case for bug #9565 "Wrong locking in stored procedure if a
  sub-sequent procedure is called".
mysql-test/t/sp.test:
  Added test case for bug #9565 "Wrong locking in stored procedure if a
  sub-sequent procedure is called".
2005-07-15 13:34:48 +04:00
unknown
eb314af492 Merge mysql.com:/usr/local/bk/mysql-5.0
into  mysql.com:/home/pem/work/mysql-5.0


mysql-test/r/sp-error.result:
  Auto merged
mysql-test/r/sp.result:
  Auto merged
mysql-test/t/sp-error.test:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2005-07-11 12:46:42 +02:00
unknown
eef5f17bde Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/dlenev/src/mysql-5.0-bg8406


mysql-test/r/sp.result:
  Auto merged
mysql-test/r/trigger.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
mysql-test/t/trigger.test:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_trigger.cc:
  Auto merged
mysql-test/r/sp-error.result:
  Manual merge.
mysql-test/t/sp-error.test:
  Manual merge.
sql/sp_head.cc:
  Manual merge.
sql/sql_yacc.yy:
  Manual merge.
2005-07-09 22:04:18 +04:00
unknown
14b1f91ba4 Enable support of access to tables from triggers. Thus fix bug #8406 "Triggers
crash if referencing a table" and several other related bugs.
Fix for bug #11834 "Re-execution of prepared statement with dropped function
crashes server." which was spotted during work on previous bugs.

Also couple of nice cleanups:
- Replaced two separate hashes for stored routines used by statement with one.
- Now instead of doing one pass through all routines used in statement for
  caching them and then doing another pass for adding their tables to table
  list, we do only one pass during which do both things.


mysql-test/r/sp-error.result:
  Added test for bug #11834 "Re-execution of prepared statement with dropped
  function crashes server" also covering handling of prepared statements
  which use stored functions but does not require prelocking.
mysql-test/r/sp.result:
  Updated test for LOCK TABLES with views in table list.
  (Old version of statement used in this test will work ok now, since prelocking
   algorithm was tuned and will lock only one multi-set of tables for each routine
   even if this routine is used in several different views).
mysql-test/r/trigger.result:
  Added several tests for triggers using tables.
mysql-test/t/sp-error.test:
  Added test for bug #11834 "Re-execution of prepared statement with dropped
  function crashes server" also covering handling of prepared statements
  which use stored functions but does not require prelocking.
mysql-test/t/sp.test:
  Updated comment about recursive views to reflect current situation.
  Updated test for LOCK TABLES with views in table list.
  (Old version of statement used in this test will work ok now, since prelocking
   algorithm was tuned and will lock only one multi-set of tables for each routine
   even if this routine is used in several different views).
mysql-test/t/trigger.test:
  Added several tests for triggers using tables.
sql/item_func.cc:
  Item_func_sp::cleanup():
    By next statement execution stored function can be dropped or altered so
    we can't assume that sp_head object for it will be still valid.
sql/sp.cc:
  - Added Sroutine_hash_entry structure that represents element in the set of
    stored routines used by statement or routine. We can't as before use
    LEX_STRING for this purprose because we want link all elements of this set
    in list.
  - Replaced sp_add_to_hash() with sp_add_used_routine() which takes into account
    that now we use one hash for stored routines used by statement instead of two
    and which mantains list linking all elelemnts in this hash.
  - Renamed sp_merge_hash() to sp_update_sp_used_routines().
  - Introduced sp_update_stmt_used_routines() for adding elements to the set of
    routines used by statement from another similar set for statement or routine.
    This function will also mantain list linking elements of destination set.
  - Now instead of one sp_cache_routines() function we have family of 
    sp_cache_routines_and_add_tables() functions which are also responsible for
    adding tables used by routines being cached to statement table list. Nice
    optimization - thanks to list linking all elements in the hash of routines
    used by statement we don't need to perform several iterations over this hash
    (as it was before in cases when we have added new elements to it).
sql/sp.h:
  Added declarations of functions used for manipulations with set (hash) of stored
  routines used by statement.
sql/sp_head.cc:
  sp_name::init_qname():
    Now sp_name also holds key identifying routine in the set (hash) of
    stored routines used by statement. 
  sp_head:
    Instead of two separate hashes sp_funs/m_spprocs representing sets of stored
    routines used by this routine we use one hash - m_sroutines. 
  sp_instr_set_trigger_field:
    Added support for subqueries in assignments to row accessors in triggers.
  Removed definition of sp_add_sp_tables_to_table_list() and auxilary functions 
  since now we don't have separate stage on which we add tables used by routines
  used by statement to table list for prelocking. We do it on the same stage as
  we load those routines in SP cache. So all this functionality moved to
  sp_cache_routines_and_add_tables() family of functions.
sql/sp_head.h:
  sp_name:
    Now this class also holds key identifying routine in the set (hash) of stored
    routines used by statement. 
  sp_head:
    Instead of two separate hashes sp_funs/m_spprocs representing sets of stored
    routines used by this routine we use one hash - m_sroutines. 
  sp_instr_set_trigger_field:
    Added support for subqueries in assignments to row accessors in triggers.
  Removed declaration of sp_add_sp_tables_to_table_list() since now we don't have
  separate stage on which we add tables used by routines used by statement to
  table list for prelocking. We do it on the same stage as we load those routines
  in SP cache.
sql/sql_base.cc:
  open_tables():
  - LEX::spfuns/spprocs hashes were replaced with one LEX::sroutines hash.
  - Now instead of doing one pass through all routines used in statement for
    caching them and then doing another pass for adding their tables to table
    list, we do only one pass during which do both things. It is easy to do
    since all routines in the set of routines used by statement are linked in
    the list. This also allows us to calculate table list for prelocking more
    precisely.
  - Now triggers properly inform prelocking algorithm about tables they use.
sql/sql_lex.cc:
  lex_start():
    Replaced LEX::spfuns/spprocs with with one LEX::sroutines hash.
    Added LEX::sroutines_list list linking all elements in this hash.
  st_lex::st_lex():
    Moved definition of LEX constructor to sql_lex.cc file to be able
    use sp_sroutine_key declaration from sp.h in it.
sql/sql_lex.h:
  LEX:
    Replaced two separate hashes for stored routines used by statement with one.
    Added list linking all elements in this hash to be able to iterate through all
    elements and add new elements to this hash at the same time.
    Moved constructor definition to sql_lex.cc.
sql/sql_parse.cc:
  mysql_execute_command():
    Replaced LEX::spfuns/spprocs with one LEX::sroutines hash.
sql/sql_trigger.cc:
  Added missing GNU GPL notice.
  Table_triggers_list::check_n_load()
    Added initialization of sroutines_key which stores key representing
    triggers of this table in the set (hash) of routines used by this statement.
sql/sql_trigger.h:
  Added missing GNU GPL notice.
  Table_triggers_list:
    Added sroutines_key member to store key representing triggers of this
    table in the set (hash) of routines used by this statement.
    Declared sp_cache_routines_and_add_tables_for_triggers() as friend since
    it needs access to sroutines_key and trigger bodies.
sql/sql_yacc.yy:
  - Now we use sp_add_used_routine() instead of sp_add_to_hash() for adding
    elements to the set of stored routines used in statement.
  - Enabled support of subqueries as right sides in assignments to triggers' row
    accessors.
2005-07-09 21:51:59 +04:00
unknown
afdc702665 Merge mysql.com:/usr/local/bk/mysql-5.0
into  mysql.com:/home/pem/work/mysql-5.0


mysql-test/r/sp.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2005-07-07 09:13:49 +02:00
unknown
de40b79a63 Updated sp.result
mysql-test/r/sp.result:
  Updated test result.
2005-07-06 16:56:38 +02:00
unknown
23cc601089 Fixed BUG#7088: Stored procedures: labels won't work if character set is utf8.
We used 'IDENT' for labels as a temporary fix for the  parser conflicts
  introduced if the proper rule 'ident' was used. Now a specially tailored
  'label_ident' rule is used for labels instead.


mysql-test/r/sp.result:
  New test cases for BUG#7088.
mysql-test/t/sp.test:
  New test cases for BUG#7088.
sql/sql_yacc.yy:
  Make labels in stored procedures work with other character sets than latin1.
  Using a separate 'label_ident' rule (instead of 'ident') and splitting
  the 'keyword' rule into two got rid of the temporary fix of using 'IDENT' for
  labels (which didn't heed character sets).
2005-07-06 16:37:57 +02:00
unknown
99cee82126 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/dlenev/src/mysql-5.0-bg11394


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
mysql-test/r/sp-error.result:
  Manual merge.
mysql-test/t/sp-error.test:
  Manual merge.
sql/share/errmsg.txt:
  Manual merge.
2005-07-06 10:21:27 +04:00
unknown
1ff4a0ebf1 Disabled the GOTO feature. (It's non-standard and undocumented.)
We want to have the defacto standard syntax for labels ("L:" instead of "label L;"),
and fix some known bugs, before we enable this again.
The code is left intact (#ifdef'ed SP_GOTO) and the test cases are kept in
sp-goto.test, for the future...


mysql-test/r/sp-error.result:
  Moved all goto tests to sp-goto.test.
mysql-test/r/sp.result:
  Moved all goto tests to sp-goto.test.
mysql-test/t/disabled.def:
  Disabled GOTO/LABEL (until the label syntax and some bugs can be fixed).
  We keep the tests in sp-goto.test for the future, but disable for now.
mysql-test/t/sp-error.test:
  Moved all goto tests to sp-goto.test.
mysql-test/t/sp.test:
  Moved all goto tests to sp-goto.test.
sql/lex.h:
  Disabled GOTO/LABEL (until the label syntax and some bugs can be fixed).
sql/sql_yacc.yy:
  Disabled GOTO/LABEL (until the label syntax and some bugs can be fixed).
2005-07-01 15:25:51 +02:00
unknown
0f64a49506 "Fix" for bug #11394 "Recursion in SP crash server" and bug #11600
"Stored procedures: crash with function calling itself".

Disallow recursive stored routines until we either make Item's and LEX
reentrant safe or will use spearate sp_head instances (and thus separate
LEX objects and Item trees) for each routine invocation.


mysql-test/r/sp-error.result:
  Added tests for bug #11394 "Recursion in SP crash server" and
  bug #11600 "Stored procedures: crash with function calling itself".
  (We simply disallow recursion for stored routines).
mysql-test/r/sp.result:
  Disabled test cases containing recursive stored routines until we will
  support for them.
mysql-test/t/sp-error.test:
  Added tests for bug #11394 "Recursion in SP crash server" and
  bug #11600 "Stored procedures: crash with function calling itself".
  (We simply disallow recursion for stored routines).
mysql-test/t/sp.test:
  Disabled test cases containing recursive stored routines until we will
  support for them.
sql/share/errmsg.txt:
  Added error message saying that recursive stored routines are disallowed.
sql/sp_head.cc:
  sp_head::execute():
    Since many Item's and LEX members can't be used in reentrant fashion
    we have to disable recursion for stored routines. So let us track
    routine invocations using sp_head::m_is_invoked member and raise
    error when one attempts to call routine recursively.
sql/sp_head.h:
  sp_head:
    Added m_is_invoked member for tracking of routine invocations and
    preventing recursion.
2005-07-01 13:01:46 +04:00
unknown
a95bb38a7f Fixed BUG#11529: crash server after use stored procedure
Make sure to cleanup the items for a cursor query after each open, otherwise
it's done too late, after the run-time mem_root is freed.


mysql-test/r/sp.result:
  New test case for BUG#11529.
mysql-test/t/sp.test:
  New test case for BUG#11529.
sql/sp_head.cc:
  Add a back pointer from a sp_cursor to its cpush instruction, and use it to set
  the arena and cleanup the items for the cursor's query when opening it.
sql/sp_rcontext.cc:
  Store pointer in sp_cursor to its cpush instruction.
sql/sp_rcontext.h:
  Store pointer in sp_cursor to its cpush instruction.
2005-06-30 18:07:06 +02:00
unknown
ef36e81b2a fixed items cleunup for SP (BUG#10136)
mysql-test/r/sp.result:
  test commented until bug#11394 fix
  test for bug#10136
mysql-test/t/sp.test:
  test commented until bug#11394 fix
  bug10136
sql/sp_head.cc:
  fixed items cleunup for SP
2005-06-22 00:17:08 +03:00
unknown
4b0264dffd Merge mysql.com:/usr/local/bk/mysql-5.0
into mysql.com:/home/pem/work/mysql-5.0


mysql-test/r/sp.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_rcontext.cc:
  Auto merged
2005-06-10 16:56:34 +02:00
unknown
03949f8ce8 Post review and additional fix for BUG#10968: Stored procedures: crash if long loop.
Fixed valgrind complaints. This fixes the memory leak problems for
  procedured, and partially for functions. There's still a leak involving
  results from functions that turned out to be too involved, so it will be
  fixed separately.


mysql-test/r/sp.result:
  Fixed some minor mistake (spotted while debugging).
mysql-test/t/sp.test:
  Fixed some minor mistake (spotted while debugging).
sql/item_func.cc:
  Moved Item_func_sp::cleanup() from item_func.h to ease debugging,
  and made a debug output come out right.
sql/item_func.h:
  Moved Item_func_sp::cleanup() to item_func.cc to ease debugging.
sql/sp_head.cc:
  Fixed valgrind problems with the previous memory leak fix (unit cleanup and
  putting result field in a differen mem_root), and removed prealloc flag from
  init_alloc_root() calls.
sql/sp_rcontext.cc:
  New mem_root pointer used for return fields from functions.
sql/sp_rcontext.h:
  New mem_root pointer used for return fields from functions.
2005-06-10 16:14:01 +02:00
unknown
3b808af0fd sp.test, sp.result:
Added a test case for bug #6866.
sql_select.cc:
  Fixed bug #6866.
  Bug was due to the fact that on_expr was not backed up
  for the second execution of the stored procedure.


sql/sql_select.cc:
  Fixed bug #6866.
  Bug was due to the fact that on_expr was not backed up
  for the second execution of the stored procedure.
mysql-test/r/sp.result:
  Added a test case for bug #6866.
mysql-test/t/sp.test:
  Added a test case for bug #6866.
2005-06-06 06:05:11 -07:00
unknown
77bd9d36e6 Fixed BUG#10961: Stored procedures: crash if select * from dual
Have to catch errors from SELECT when opening a cursor.


mysql-test/r/sp.result:
  New test case for BUG#10961.
mysql-test/t/sp.test:
  New test case for BUG#10961.
sql/protocol.h:
  Init data in Protocol_cursor constructor, for error cases.
sql/sp_head.cc:
  Catch "hidden" errors during SELECT when opening a cursor.
2005-06-01 12:18:41 +02:00
unknown
d5f4c14b6e Fixed BUG#9559: Functions: Numeric Operations using -ve value gives incorrect
results.
  Actually a problem when converting decimal to int for user variables.


mysql-test/r/sp.result:
  New test case for BUG#9559.
mysql-test/t/sp.test:
  New test case for BUG#9559.
sql/item_func.cc:
  Don't set the unsigned flag when converting decimal user var to int.
2005-05-27 14:48:33 +02:00
unknown
d214d50160 merge
mysql-test/t/sp.test:
  Auto merged
sql/item.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
2005-05-09 02:06:18 +03:00