An error occurred fetching the project authors.
  1. 26 Aug, 2005 1 commit
    • unknown's avatar
      Slightly amended Monty's SP replication code cleanup patch · 9bc3976c
      unknown authored
      sql/item.cc:
        Code cleanup
      sql/item.h:
        Code cleanup
      sql/log.cc:
        Added comments
      sql/sp_head.cc:
        Code cleanup patch from Monty: 
        in subst_spvars()
        - Move local variables first in block
        - Use res|= instead of res |=
        - Use strmake() instead of alloc + memcpy
        Added:
        - Fail the query if we don't have enough memory to produce a binlog-suitable query string: 
          if we're so low on memory we're likely to fail the query anyway, and failing now removes
          the need for hack with THD::query_str_binlog_suitable.
      sql/sql_class.cc:
        Remove THD::query_str_binlog_unsuitable
      sql/sql_class.h:
        Remove THD::query_str_binlog_unsuitable
      sql/sql_delete.cc:
        Remove THD::query_str_binlog_unsuitable
      sql/sql_insert.cc:
        Remove THD::query_str_binlog_unsuitable
      sql/sql_parse.cc:
        Code cleanup
      sql/sql_update.cc:
        Remove THD::query_str_binlog_unsuitable
      9bc3976c
  2. 25 Aug, 2005 3 commits
    • unknown's avatar
      Compiler error fix for ICC 8.1 · 8b3299bd
      unknown authored
      8b3299bd
    • unknown's avatar
      Fix for BUG#12335 (SP replication) : New binlogging strategy for stored PROCEDUREs/FUNCTIONs. · 8a5e5274
      unknown authored
      "Interleaved SPs execution is now binlogged properly, "SELECT spfunc()" is binlogged too.
      The known remaining issue is binlogging/replication of "a routine is deleted while it is executed" scenario.
      
      
      mysql-test/r/rpl_sp.result:
        Fix for BUG#12335: updated test cases/results
      mysql-test/t/rpl_sp.test:
        Fix for BUG#12335: updated test cases/results
      sql/item.cc:
        Fix for BUG#12335 (SP replication): 
         - Added Item_name_const 'function'
         - Addede 'delete reuse' to call dtor on item reuse
      sql/item.h:
        Fix for BUG#12335 (SP replication) : Added Item_name_const 'function' + code cleanup
      sql/item_create.cc:
         Fix for BUG#12335 (SP replication) : Added Item_name_const 'function'
      sql/item_create.h:
         Fix for BUG#12335 (SP replication) : Added Item_name_const 'function'
      sql/item_func.cc:
        Fix for BUG#12335 (SP replication) : binary log is now constrolled from within execute_function.
      sql/lex.h:
        Fix for BUG#12335 (SP replication) : Added Item_name_const 'function'
      sql/log.cc:
        Fix for BUG#12335 (SP replication) : Added MYSQL_LOG::{start|stop}_union_events to allow
        one to temporary disable binlogging but collect a 'union' information about binlog write
        calls.
      sql/mysql_priv.h:
        Fix for BUG#12335 (SP replication)
      sql/sp_head.cc:
        Fix for BUG#12335 (SP replication) : Now we use different SP binlogging strategy, grep for 
        StoredRoutinesBinlogging for details
      sql/sp_head.h:
        Comments added
      sql/sp_pcontext.h:
        Comments added
      sql/sp_rcontext.h:
        Comments added
      sql/sql_class.cc:
        Fix for BUG#12335 (SP replication) : Now we use different SP binlogging strategy, grep for 
        StoredRoutinesBinlogging for details
      sql/sql_class.h:
        Fix for BUG#12335 (SP replication) : Added MYSQL_LOG::{start|stop}_union_events to allow
        one to temporary disable binlogging but collect a 'union' information about binlog write
        calls.
      sql/sql_delete.cc:
        Fix for BUG#12335: check THD::query_str_binlog_unsuitable when writing to binlog.
      sql/sql_insert.cc:
        Fix for BUG#12335: check THD::query_str_binlog_unsuitable when writing to binlog.
      sql/sql_lex.cc:
        Fix for BUG#12335 (SP replication): Add ability to extract previous returned token from
        the tokenizer.
      sql/sql_lex.h:
        Fix for BUG#12335 (SP replication): Add ability to extract previous returned token from
        the tokenizer.
      sql/sql_parse.cc:
        Fix for BUG#12335 (SP replication) : Now we use different SP binlogging strategy, grep for 
        StoredRoutinesBinlogging for details
      sql/sql_update.cc:
        Fix for BUG#12335: check THD::query_str_binlog_unsuitable when writing to binlog.
      sql/sql_yacc.yy:
        Fix for BUG#12335 (SP replication) : When creating Item_splocal, remember where it is located
        in the query.
      8a5e5274
    • unknown's avatar
      Fix Bug#11333 "Stored Procedure: Memory blow up on repeated SELECT ... INTO query" · d29df564
      unknown authored
      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.
      d29df564
  3. 24 Aug, 2005 1 commit
  4. 21 Aug, 2005 1 commit
    • unknown's avatar
      Cleanup during review of new pushed code · 72340a48
      unknown authored
      include/my_global.h:
        Safer macros to avoid possible overflows
      sql/item_cmpfunc.cc:
        Simple optimization
      sql/sp_head.cc:
        Indentation fixes
        Remove not needed "else" levels
        Added error checking for 'new'
        Simpler reseting of thd->spcont in execute_procedure
      sql/sql_base.cc:
        Faster new
      sql/sql_lex.cc:
        Use 'TRUE' instead of 'true'
      sql/sql_parse.cc:
        Faster new
      sql/sql_view.cc:
        No need to set 'tables' as it's not used
      sql/table.cc:
        Simpler DBUG_ASSERT()
      72340a48
  5. 19 Aug, 2005 1 commit
    • unknown's avatar
      A fix and a test case for "Bug #12168 'DECLARE CONTINUE HANDLER FOR · 276bd123
      unknown authored
      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
      276bd123
  6. 18 Aug, 2005 1 commit
    • unknown's avatar
      Fix for Bug#11247 Stored procedures: Function calls in long loops leak memory · fa19a9f2
      unknown authored
          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.
      fa19a9f2
  7. 15 Aug, 2005 2 commits
    • unknown's avatar
      Clean up merge from 4.1 · c78623fa
      unknown authored
      mysql-test/r/func_date_add.result:
        Update results
      mysql-test/r/func_time.result:
        Update results
      server-tools/instance-manager/protocol.cc:
        Fix call to list_rest()
      sql/sp_head.cc:
        sp_change_db() removed, call mysql_change_db() instead.
      c78623fa
    • unknown's avatar
      Save and clear run context before executing a stored function or trigger and restore it afterwards. · a914b527
      unknown authored
      This allows us to use statement replication with functions and triggers
      The following things are fixed with this patch:
      - NOW() and automatic timestamps takes the value from the main event for functions and triggers (which allows these to replicate with statement level logging)
      - No side effects for triggers or functions with auto-increment values(), last_insert_id(), rand() or found_rows()
      - Triggers can't return result sets
      
      Fixes bugs:
      #12480: NOW() is not constant in a trigger
      #12481: Using NOW() in a stored function breaks statement based replication
      #12482: Triggers has side effects with auto_increment values
      #11587: trigger causes lost connection error
      
      
      mysql-test/r/trigger.result:
        Added test fpr big
      mysql-test/t/sp-error.test:
        Changed error message numbers
      mysql-test/t/trigger.test:
        Added test for trigger returning result (#11587)
      sql/item_func.cc:
        Store the first used seed value for RAND() value.
        (This makes rand() replicatable in functions and triggers)
        Save and clear run context before executing a stored function and restore it afterwards.
        This removes side effects of stored functions for RAND(), auto-increment values and NOW() and makes most stored function replicatable
      sql/share/errmsg.txt:
        Reuse error message also for triggers
      sql/sp_head.cc:
        If in function or trigger, don't change value of NOW()
        (This allows us to use statement replication with functions that directly or indirectly uses timestamps)
      sql/sql_class.cc:
        Added framework for storing and retrieving run context while exceuting triggers or stored functions.
      sql/sql_class.h:
        Added framework for storing and retrieving run context while exceuting triggers or stored functions.
      sql/sql_parse.cc:
        If in function or trigger, don't change value of NOW()
        (This allows us to use statement replication with functions that directly or indirectly uses timestamps)
      sql/sql_trigger.cc:
        Moved process_triggers function from sql_trigger.h
        Use reset/restore sub_statement_state while executing triggers to avoid side effects and make them replicatable
      sql/sql_trigger.h:
        Moved process_triggers function from sql_trigger.h
        Use reset/restore sub_statement_state while executing triggers to avoid side effects and make them replicatable
      sql/sql_yacc.yy:
        Give error message if trigger can return a result set (Bug #11587)
      tests/fork_big2.pl:
        Removed return from end of lines
      mysql-test/r/rpl_trigger.result:
        New BitKeeper file ``mysql-test/r/rpl_trigger.result''
      mysql-test/t/rpl_trigger.test:
        New BitKeeper file ``mysql-test/t/rpl_trigger.test''
      a914b527
  8. 11 Aug, 2005 1 commit
    • unknown's avatar
      Cleanups during review of new code · d83f6908
      unknown authored
      mysql-test/t/sp.test:
        Use --disable_parsing instead of comments
      sql/lock.cc:
        Remove compiler warning
      sql/mysqld.cc:
        Always send valid flag argument to reload_acl_and_cache()
      sql/sp_cache.cc:
        Simple optimization
        Don't use mutex to read 'long' variable
        Indentation fixes
      sql/sp_head.cc:
        Fix comments to use /* */
        Set proc_info to 0 after close_thread_tables()
      sql/sql_base.cc:
        remove not needed test
      sql/sql_parse.cc:
        Always send valid flag argument to reload_acl_and_cache()
        Fixed indentation
        Ensure we get an error if reset_master() fails.
      d83f6908
  9. 09 Aug, 2005 1 commit
  10. 03 Aug, 2005 1 commit
    • unknown's avatar
      Prelocking-free SPs, post-review fixes: · b323667f
      unknown authored
      * 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.
      b323667f
  11. 01 Aug, 2005 1 commit
  12. 30 Jul, 2005 1 commit
    • unknown's avatar
      Added Non-prelocked SP execution: Now a PROCEDURE doesn't enter/leave prelocked mode for · 11abe15e
      unknown authored
      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
      11abe15e
  13. 28 Jul, 2005 1 commit
    • unknown's avatar
      store/restore sql_mode which was in force during ctrigger creation (BUG#5891) · a66928bb
      unknown authored
      other sql_mode fixes
      
      
      mysql-test/r/information_schema.result:
        changes in information schema
      mysql-test/r/trigger.result:
        storing and restoring sql modes for triggers
      mysql-test/t/trigger.test:
        storing and restoring parsing modes for triggers
      sql/mysqld.cc:
        add length of mode names
      sql/parse_file.cc:
        new type of list (ulonglong)
      sql/parse_file.h:
        new type of list (ulonglong)
      sql/set_var.cc:
        mode output made as static method
      sql/set_var.h:
        mode output made as static method
      sql/sp_head.cc:
        added sql_mode storing/restoring during SP execution
        optimised sql_mode printing
      sql/sp_head.h:
        comment fixed according this changes
      sql/sql_show.cc:
        added sql_mode field
      sql/sql_trigger.cc:
        store/restore sql_mode which was in force during ctrigger creation
      sql/sql_trigger.h:
        store/restore sql_mode which was in force during ctrigger creation
      sql/sql_view.cc:
        fixed sql_mode
      a66928bb
  14. 15 Jul, 2005 1 commit
    • unknown's avatar
      Fixed BUG#9538: SProc: Creation fails if we try to SET system variable · 6f619804
      unknown authored
                        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.
      6f619804
  15. 09 Jul, 2005 1 commit
    • unknown's avatar
      Enable support of access to tables from triggers. Thus fix bug #8406 "Triggers · 14b1f91b
      unknown authored
      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.
      14b1f91b
  16. 04 Jul, 2005 2 commits
  17. 01 Jul, 2005 2 commits
    • unknown's avatar
      "Fix" for bug #11394 "Recursion in SP crash server" and bug #11600 · 0f64a495
      unknown authored
      "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.
      0f64a495
    • unknown's avatar
      Name resolution context added (BUG#6443) · b4f595b9
      unknown authored
      include/my_bitmap.h:
        new bitmap operation
      mysql-test/r/view.result:
        added warnings
        Correct inserting data check (absence of default value) for view underlying tables (BUG#6443)
      mysql-test/t/view.test:
        Correct inserting data check (absence of default value) for view underlying tables (BUG#6443)
      mysys/my_bitmap.c:
        new bitmap operation
      sql/field.h:
        index of field in table added
      sql/item.cc:
        Name resolution context added
        table list removed from fix_fields() arguments
      sql/item.h:
        Name resolution context added
        table list removed from fix_fields() arguments
      sql/item_cmpfunc.cc:
        table list removed from fix_fields() arguments
      sql/item_cmpfunc.h:
        table list removed from fix_fields() arguments
      sql/item_func.cc:
        table list removed from fix_fields() arguments
      sql/item_func.h:
        table list removed from fix_fields() arguments
      sql/item_row.cc:
        table list removed from fix_fields() arguments
      sql/item_row.h:
        table list removed from fix_fields() arguments
      sql/item_strfunc.cc:
        fixed server crash on NULL argument
      sql/item_strfunc.h:
        table list removed from fix_fields() arguments
      sql/item_subselect.cc:
        table list removed from fix_fields() arguments
      sql/item_subselect.h:
        table list removed from fix_fields() arguments
      sql/item_sum.cc:
        table list removed from fix_fields() arguments
      sql/item_sum.h:
        table list removed from fix_fields() arguments
      sql/item_timefunc.cc:
        table list removed from fix_fields() arguments
      sql/item_timefunc.h:
        table list removed from fix_fields() arguments
      sql/item_uniq.h:
        table list removed from fix_fields() arguments
      sql/log_event.cc:
        Name resolution context added
      sql/log_event.h:
        Name resolution context added
      sql/mysql_priv.h:
        Name resolution context added
      sql/set_var.cc:
        table list removed from fix_fields() arguments
      sql/share/errmsg.txt:
        new error message
      sql/sp.cc:
        Name resolution context added
      sql/sp_head.cc:
        table list removed from fix_fields() arguments
      sql/sp_head.h:
        Name resolution context added
      sql/sql_base.cc:
        table list removed from fix_fields() arguments
        Name resolution context added
      sql/sql_class.cc:
        renamed variable
      sql/sql_delete.cc:
        Name resolution context added
      sql/sql_derived.cc:
        Name resolution context added
      sql/sql_do.cc:
        table list removed from fix_fields() arguments
      sql/sql_handler.cc:
        Name resolution context added
      sql/sql_help.cc:
        Name resolution context added
      sql/sql_insert.cc:
        Name resolution context added
        table list removed from fix_fields() arguments
      sql/sql_lex.cc:
        Name resolution context added
      sql/sql_lex.h:
        removed resolve mode (information stored into name resolution context)
      sql/sql_load.cc:
        table list removed from fix_fields() arguments
      sql/sql_olap.cc:
        Name resolution context added
      sql/sql_parse.cc:
        Name resolution context added
      sql/sql_prepare.cc:
        table list removed from fix_fields() arguments
      sql/sql_select.cc:
        table list removed from fix_fields() arguments
      sql/sql_show.cc:
        Name resolution context added
      sql/sql_trigger.cc:
        table list removed from fix_fields() arguments
      sql/sql_udf.h:
        table list removed from fix_fields() arguments
      sql/sql_union.cc:
        Name resolution context added
      sql/sql_update.cc:
        Name resolution context added
      sql/sql_view.cc:
        Name resolution context added
      sql/sql_view.h:
        table list removed from fix_fields() arguments
      sql/sql_yacc.yy:
        Name resolution context added
      sql/table.cc:
        Name resolution context added
        merged view processing moved
      sql/table.h:
        merged view processing moved
      b4f595b9
  18. 30 Jun, 2005 2 commits
    • unknown's avatar
      Fixing comment format in sp_head.cc. · 6a5ba8fd
      unknown authored
      sql/sp_head.cc:
        Fixing comment format.
      6a5ba8fd
    • unknown's avatar
      Fixed BUG#11529: crash server after use stored procedure · a95bb38a
      unknown authored
      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.
      a95bb38a
  19. 29 Jun, 2005 1 commit
  20. 28 Jun, 2005 1 commit
    • unknown's avatar
      Fixed comments. · d2f7623d
      unknown authored
      sql/opt_range.cc:
        comment fixed.
      sql/sp_head.cc:
        An obsolete comment removed.
      d2f7623d
  21. 23 Jun, 2005 1 commit
    • unknown's avatar
      - implement inheritance of sp_instr: public Query_arena. · 91180cb8
      unknown authored
        We need every instruction to have its own arena, because we want to
        track instruction's state (INITIALIZED_FOR_SP -> EXECUTED). Because of 
        `if' statements and other conditional instructions used in stored 
        procedures, not every instruction of a stored procedure gets executed 
        during the first (or even subsequent) execution of the procedure. 
        So it's better if we track the execution state of every instruction 
        independently.
        All instructions of a given procedure now also share sp_head's 
        mem_root, but keep their own free_list.
        This simplifies juggling with free Item lists in sp_head::execute.
      - free_items() moved to be a member of Query_arena. 
      - logic of 'backup_arena' debug member of Query_arena has been
        changed to support
        multi-backups. Until now, TRUE 'backup_arena' meant that there is
        exactly one active backup of the THD arena. Now it means simply that
        the arena is used for backup, so that we can't accidentally overwrite an 
        existing backup. This allows doing multiple backups, e.g. in
        sp_head::execute and Cursor::fetch, when THD arena is already backed up
        but we want to set yet another arena (usually the 'permanent' arena,
        to save permanent transformations/optimizations of a parsed tree).
      
      
      sql/sp_head.cc:
        - use Query_arena support in sp_head::execute() as now sp_instr inherites
          from it.
      sql/sp_head.h:
        - inherite sp_instr from Query_arena
      sql/sql_class.cc:
        - changed the principle of Query_arena::backup_arena; free_items is now
          a member of Query_arena.
      sql/sql_class.h:
        - changed the principle of Query_arena::backup_arena; free_items is now
          a member of Query_arena.
      sql/sql_prepare.cc:
        free_items() is now a member of Query_arena.
      sql/sql_select.cc:
        free_items() now automatically sets free_list to zero.
      91180cb8
  22. 22 Jun, 2005 1 commit
    • unknown's avatar
      Adjust to the changed Query_arena constructor: · 40f0738b
      unknown authored
      main_mem_root is moved out of class Query_arena.
      
      
      sql/sp_head.cc:
        Adjust to the changed Query_arena constructor. 
        main_mem_root is moved out of class Query_arena.
      sql/sp_head.h:
        main_mem_root is moved out of class Query_arena: add it to class sp_head.
      sql/sql_class.cc:
        main_mem_root is moved out of class Query_arena: remove
        constructors no longer relevant, remove dead code.
      sql/sql_class.h:
        main_mem_root is moved out of class Query_arena.
      sql/sql_prepare.cc:
        It's better to not use main_mem_root anywhere: logically, it's not
        a public member (can't fix sp_head::make_field and Item_subselect::exec
        to make it protected)
      sql/sql_select.cc:
        New Cursor constructor, which avoids unneeded memory allocation
        when initializign main_mem_root.
      sql/sql_select.h:
        main_mem_root is moved out of class Query_arena.
      40f0738b
  23. 21 Jun, 2005 2 commits
    • unknown's avatar
      fixed items cleunup for SP (BUG#10136) · ef36e81b
      unknown authored
      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
      ef36e81b
    • unknown's avatar
      A preparatory patch to help adding JOIN::transform() and move one-time · 04f6f63d
      unknown authored
      query transformations to the PREPARE stage (prepared statements).
      
      
      sql/item.h:
        Remove an unused friend declaration.
      sql/mysql_priv.h:
        Change signature of insert_fields()
      sql/sp_head.cc:
        Make is_stmt_prepare_or_first_sp_execute really work: reset SP state
        to EXECUTED after execution.
      sql/sql_base.cc:
        allocate_view_names flag of insert_fields is removed.
        The purpose of this variable was to amend the case when a view
        is replaced with a base table between subsequent executions of a prepared
        statement: in that case the new table theoretically can be used instead
        of the view. If allocate_view_names was set,
        all the references to the view expressions were replaced with Item_field's
        which in turn could have been resolved by their names.
        But this approach doesn't work for other reasons, so let's not try
        to help what must be solved by TDC.
      sql/sql_class.h:
        Add is_first_sp_execute() helper method.
      sql/sql_handler.cc:
        insert_fields signature changed.
      sql/sql_lex.h:
        Add a comment for variable 'first_execution'.
      04f6f63d
  24. 15 Jun, 2005 1 commit
    • unknown's avatar
      renamed: · f1e42a0b
      unknown authored
        Item_buff -> Cached_item
        Item_arena -> Query_arena
        TEST_ASSERT -> YYERROR_UNLESS
      
      
      sql/item.h:
        renamed:
          Item_buff -> Cached_item
      sql/item_buff.cc:
        renamed:
          Item_buff -> Cached_item
      sql/item_func.cc:
        renamed:
          Item_arena -> Query_arena
      sql/item_subselect.cc:
        renamed:
          Item_arena -> Query_arena
      sql/sp_head.cc:
        renamed:
          Item_arena -> Query_arena
      sql/sp_head.h:
        renamed:
          Item_arena -> Query_arena
      sql/sql_base.cc:
        renamed:
          Item_arena -> Query_arena
      sql/sql_class.cc:
        renamed:
          Item_arena -> Query_arena
      sql/sql_class.h:
        renamed:
          Item_arena -> Query_arena
      sql/sql_lex.cc:
        renamed:
          Item_arena -> Query_arena
      sql/sql_prepare.cc:
        renamed:
          Item_arena -> Query_arena
      sql/sql_select.cc:
        renamed:
          Item_arena -> Query_arena
      sql/sql_select.h:
        renamed:
          Item_buff -> Cached_item
          Item_arena -> Query_arena
      sql/sql_union.cc:
        renamed:
          Item_arena -> Query_arena
      sql/sql_view.cc:
        renamed:
          Item_arena -> Query_arena
      sql/sql_yacc.yy:
        renamed:
          TEST_ASSERT -> YYERROR_UNLESS
      sql/table.cc:
        renamed:
          Item_arena -> Query_arena
      f1e42a0b
  25. 10 Jun, 2005 1 commit
    • unknown's avatar
      Post review and additional fix for BUG#10968: Stored procedures: crash if long loop. · 03949f8c
      unknown authored
        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.
      03949f8c
  26. 09 Jun, 2005 1 commit
    • unknown's avatar
      A fix and test case for Bug#10729 "mysql_stmt_attr_set · d0db7027
      unknown authored
      CURSOR_TYPE_READ_ONLY". The bug was that we (me) don't perform proper
      cleanups of the prepared statement when done fetching from a cursor.
      Another patch.
      
      
      sql/mysql_priv.h:
        Rename reset_stmt_for_execute to init_stmt_before_use (to correspond to
        cleanup_stmt_and_thd_after_use).
      sql/sp_head.cc:
        Rename.
      sql/sql_prepare.cc:
        Move common cleanup code to a cleanup function, call it when we close
        a cursor.
      sql/sql_select.cc:
        Cleanup.
      sql/sql_select.h:
        No need for init_thd, this code has been inlined in Cursor::open.
      tests/mysql_client_test.c:
        Add a test case for Bug#10729 "mysql_stmt_attr_set CURSOR_TYPE_READ_ONLY"
        (problem reusing a prepared statemnt if there was a cursor)
      d0db7027
  27. 07 Jun, 2005 1 commit
    • unknown's avatar
      Patch two (the final one) for Bug#7306 "the server side preparedStatement · 5188f031
      unknown authored
       error for LIMIT placeholder".
      The patch adds grammar support for LIMIT ?, ? and changes the
      type of ST_SELECT_LEX::select_limit,offset_limit from ha_rows to Item*,
      so that it can point to Item_param.
      
      
      mysql-test/include/ps_modify.inc:
        Fix existing tests: now LIMIT can contain placeholders.
      mysql-test/include/ps_query.inc:
        Fix existing tests: now LIMIT can contain placeholders.
      mysql-test/r/ps.result:
        Add basic test coverage for LIMIT ?, ? and fix test results.
      mysql-test/r/ps_2myisam.result:
        Fix test results: now LIMIT can contain placeholders.
      mysql-test/r/ps_3innodb.result:
        Fix test results: now LIMIT can contain placeholders.
      mysql-test/r/ps_4heap.result:
        Fix test results: now LIMIT can contain placeholders.
      mysql-test/r/ps_5merge.result:
        Fix test results: now LIMIT can contain placeholders.
      mysql-test/r/ps_6bdb.result:
        Fix test results: now LIMIT can contain placeholders.
      mysql-test/r/ps_7ndb.result:
        Fix test results: now LIMIT can contain placeholders.
      mysql-test/t/ps.test:
        Add basic test coverage for LIMIT ?, ?.
      sql/item.h:
        Add a short-cut for (ulonglong) val_int() to Item.
        Add a constructor to Item_int() that accepts ulonglong.
        Simplify Item_uint constructor by using the c-tor above.
      sql/item_subselect.cc:
        Now select_limit has type Item *.
        We can safely create an Item in Item_exists_subselect::fix_length_and_dec():
        it will be allocated in runtime memory root and freed in the end of
        execution.
      sql/sp_head.cc:
        Add a special initalization state for stored procedures to 
        be able to easily distinguish the first execution of a stored procedure
        from prepared statement prepare.
      sql/sql_class.h:
        Introduce new state 'INITIALIZED_FOR_SP' to be able to easily distinguish
        the first execution of a stored procedure from prepared statement prepare.
      sql/sql_derived.cc:
        - use unit->set_limit() to set unit->select_limit_cnt, offset_limit_cnt
          evreryplace. Add a warning about use of set_limit in 
        mysql_derived_filling.
      sql/sql_error.cc:
        - use unit->set_limit() to set unit->select_limit_cnt, offset_limit_cnt
          evreryplace.
        - this change is also aware of bug#11095 "show warnings limit 0 returns 
        all rows instead of zero rows", so the one who merges the bugfix from
        4.1 can use local version of sql_error.cc.
      sql/sql_handler.cc:
        - use unit->set_limit() to initalize 
        unit->select_limit_cnt,offset_limit_cnt everyplace.
      sql/sql_lex.cc:
        Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
      sql/sql_lex.h:
        Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
      sql/sql_parse.cc:
        - use unit->set_limit() to initalize 
        unit->select_limit_cnt,offset_limit_cnt everyplace. 
        - we can create an Item_int to set global limit of a statement:
        it will be created in the runtime mem root and freed in the end of
        execution.
      sql/sql_repl.cc:
        Use unit->set_limit to initialize limits.
      sql/sql_select.cc:
        - select_limit is now Item* so the proper way to check for default value
        is to compare it with NULL.
      sql/sql_union.cc:
        Evaluate offset_limit_cnt using the new type of ST_SELECT_LEX::offset_limit
      sql/sql_view.cc:
        Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
      sql/sql_yacc.yy:
        Add grammar support for LIMIT ?, ? clause.
      5188f031
  28. 05 Jun, 2005 2 commits
    • unknown's avatar
      sp_rcontext.cc, sp_pcontext.cc, sp_head.cc, sp_cache.cc, ha_federated.cc: · 9a3bb0c7
      unknown authored
        Include "mysql_priv.h" before testing USE_PRAGMA_IMPLEMENTATION
      
      
      sql/ha_federated.cc:
        Include "mysql_priv.h" before testing USE_PRAGMA_IMPLEMENTATION
      sql/sp_cache.cc:
        Include "mysql_priv.h" before testing USE_PRAGMA_IMPLEMENTATION
      sql/sp_head.cc:
        Include "mysql_priv.h" before testing USE_PRAGMA_IMPLEMENTATION
      sql/sp_pcontext.cc:
        Include "mysql_priv.h" before testing USE_PRAGMA_IMPLEMENTATION
      sql/sp_rcontext.cc:
        Include "mysql_priv.h" before testing USE_PRAGMA_IMPLEMENTATION
      9a3bb0c7
    • unknown's avatar
      Cleanup during review · b08b3a15
      unknown authored
      Simple optimization for 2 argument usage to function of variable arguments
      Fix stack overrun when using 1+1+1+1+1+1+1+....
      Update crash-me results for 5.0
      Don't call post_open if pre_open() fails (optimization)
      
      
      
      sql-bench/limits/mysql-4.1.cfg:
        Rename: sql-bench/limits/mysql.cfg -> sql-bench/limits/mysql-4.1.cfg
      libmysql/libmysql.c:
        More portable define
      mysql-test/mysql-test-run.sh:
        Write also InnoDB warnings to warnings.log
      mysql-test/t/type_newdecimal.test:
        Don't get errors if innodb is not defined
      mysys/my_alloc.c:
        Cleanup comments
      mysys/thr_lock.c:
        Cleanup comments
      sql/item.h:
        Remove not needed initializer
      sql/item_func.cc:
        Simple optimization for 2 argument usage to function of variable arguments
      sql/mysql_priv.h:
        We use more stackspace with the introduction of int_op() etc.
        This change ensures we don't run out of stack when doing 1+1+1+1...
        (Tested on x86, 32 bit)
      sql/sp_head.cc:
        Don't call post_open if pre_open() fails
      sql/sp_rcontext.cc:
        More comments
        Change so that post_open() doesn't have to be called if pre_open() fails
      sql/sql_parse.cc:
        Fold long lines
      sql/sql_select.cc:
        Simple reorganization to reduce number of if's
        Ensure that table_map is updated for where clause (fixed warning from valgrind)
      b08b3a15
  29. 03 Jun, 2005 1 commit
  30. 01 Jun, 2005 1 commit
    • unknown's avatar
      Fixed BUG#10961: Stored procedures: crash if select * from dual · 77bd9d36
      unknown authored
        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.
      77bd9d36
  31. 31 May, 2005 1 commit
    • unknown's avatar
      Post-review fixes of BUG#9937: Crash on call to stored procedure. · 2e113ada
      unknown authored
      sql/item_cmpfunc.cc:
        Put the buff parameter back in check_stack_overrun().
      sql/item_func.cc:
        Put the buff parameter back in check_stack_overrun().
      sql/item_subselect.cc:
        Put the buff parameter back in check_stack_overrun().
      sql/mysql_priv.h:
        Put the buff parameter back in check_stack_overrun().
      sql/mysqld.cc:
        Style fixes.
      sql/sp_head.cc:
        Put the buff parameter back in check_stack_overrun().
      sql/sql_parse.cc:
        Put the buff parameter back in check_stack_overrun(), and added comment explaining the purpose.
      sql/table.cc:
        Put the buff parameter back in check_stack_overrun().
      2e113ada
  32. 27 May, 2005 1 commit
    • unknown's avatar
      Fix for trigger.test failure in --debug mode. · d51a5bae
      unknown authored
      We can't have Item_trigger_field as aggregated object inside of
      sp_instr_set_trigger_field class since in this case its destructor
      will be called twice. So instead let us create this Item separately
      and store pointer to it in instruction object.
      
      
      sql/sp_head.cc:
        sp_instr_set_trigger_field:
          We can't have Item_trigger_field as aggregated object since in this
          case its destructor will be called twice, so let us store pointer
          to this Item (Another way to avoid this is to exclude this Item
          from free_list but this can't be done in elegant way in 5.0 and
          will also cause additional problems with Item::cleanup()).
      sql/sp_head.h:
        sp_instr_set_trigger_field:
          We can't have Item_trigger_field as aggregated object since in this
          case its destructor will be called twice, so let us store pointer
          to this Item (Another way to avoid this is to exclude this Item
          from free_list but this can't be done in elegant way in 5.0 and
          will also cause additional problems with Item::cleanup()).
      sql/sql_yacc.yy:
        We can't have Item_trigger_field as aggregated object inside of
        sp_instr_set_trigger_field class since in this case its destructor
        will be called twice. So instead let us create this Item separately
        and store pointer to it in instruction object.
      d51a5bae