1. 03 Aug, 2006 1 commit
    • unknown's avatar
      Bug#8153 (Stored procedure with subquery and continue handler, wrong result) · f748b691
      unknown authored
      Before this fix,
      - a runtime error in a statement in a stored procedure with no error handlers
      was properly detected (as expected)
      - a runtime error in a statement with an error handler inherited from a non
      local runtime context (i.e., proc a with a handler, calling proc b) was
      properly detected (as expected)
      - a runtime error in a statement with a *local* error handler was executed
      as follows :
      a) the statement would succeed, regardless of the error condition, (bug)
      b) the error handler would be called (as expected).
      
      The root cause is that functions like my_messqge_sql would "forget" to set
      the thread flag thd->net.report_error to 1, because of the check involving
      sp_rcontext::found_handler_here().
      Failure to set this flag would cause, later in the call stack,
      in Item_func::fix_fields() at line 190, the code to return FALSE and consider
      that executing the statement was successful.
      
      With this fix :
      - error handling code, that was duplicated in different places in the code,
      is now implemented in sp_rcontext::handle_error(),
      - handle_error() correctly sets thd->net.report_error when a handler is
      present, regardless of the handler location (local, or in the call stack).
      
      A test case, bug8153_subselect, has been written to demonstrate the change
      of behavior before and after the fix.
      
      Another test case, bug8153_function_a, as also been writen.
      This test has the same behavior before and after the fix.
      This test has been written to demonstrate that the previous expected
      result of procedure bug18787, was incorrect, since select no_such_function()
      should fail and therefore not produce a result.
      
      The incorrect result for bug18787 has the same root cause as Bug#8153,
      and the expected result has been adjusted.
      
      
      sql/mysqld.cc:
        Bug#8153, use sp_rcontext::handle_error() to handle errors.
      sql/sql_error.cc:
        Bug#8153, use sp_rcontext::handle_error() to handle errors.
      sql/protocol.cc:
        Bug#8153, use sp_rcontext::handle_error() to handle errors.
      sql/sp_rcontext.h:
        Bug#8153, created helper sp_rcontext::handle_error() to handle errors.
      sql/sp_rcontext.cc:
        Bug#8153, created helper sp_rcontext::handle_error() to handle errors.
      mysql-test/t/sp.test:
        Bug#8153, added test cases.
      mysql-test/r/sp.result:
        Bug#8153, added test cases, fixed expected result of bug18787.
      f748b691
  2. 31 Jul, 2006 2 commits
    • unknown's avatar
      Merge malff@bk-internal.mysql.com:/home/bk/mysql-5.0-runtime · d57c41b7
      unknown authored
      into  weblab.(none):/home/marcsql/TREE/mysql-5.0-21269
      
      
      d57c41b7
    • unknown's avatar
      Bug#21269 (DEFINER-clause is allowed for UDF-functions) · d251e9be
      unknown authored
      The problem was that the grammar allows to create a function with an optional
      definer clause, and define it as a UDF with the SONAME keyword.
      Such combination should be reported as an error.
      
      The solution is to not change the grammar itself, and to introduce a
      specific check in the yacc actions in 'create_function_tail' for UDF,
      that now reports ER_WRONG_USAGE when using both DEFINER and SONAME.
      
      
      mysql-test/r/udf.result:
        Added tests for Bug#21269 (DEFINER-clause is allowed for UDF-functions)
      mysql-test/t/udf.test:
        Added tests for Bug#21269 (DEFINER-clause is allowed for UDF-functions)
      sql/sql_yacc.yy:
        Creating a UDF function with a DEFINER clause is now a syntax error.
      d251e9be
  3. 28 Jul, 2006 2 commits
    • unknown's avatar
      Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0 · 918f9a38
      unknown authored
      into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-bug16581
      
      
      sql/mysql_priv.h:
        Auto merged
      sql/sql_show.cc:
        Auto merged
      918f9a38
    • unknown's avatar
      Bug#16581: deadlock: server and client both read from connection in · 0abc107c
      unknown authored
                 'conc_sys' test
      
      Concurrent execution of SELECT involing at least two INFORMATION_SCHEMA
      tables, DROP DATABASE statement and DROP TABLE statement could have
      resulted in stalled connection for this SELECT statement.
      
      The problem was that for the first query of a join there was a race
      between select from I_S.TABLES and DROP DATABASE, and the error (no
      such database) was prepared to be send to the client, but the join
      processing was continued.  On second query to I_S.COLUMNS there was a
      race with DROP TABLE, but this error (no such table) was downgraded to
      warning, and thd->net.report_error was reset.  And so neither result
      nor error was sent to the client.
      
      The solution is to stop join processing once it is clear we are going
      to report a error, and also to downgrade to warnings file system errors
      like 'no such database' (unless we are in the 'SHOW' command), because
      I_S is designed not to use locks and the query to I_S should not abort
      if something is dropped in the middle.
      
      No test case is provided since this bug is a result of a race, and is
      timing dependant.  But we test that plain SHOW TABLES and SHOW COLUMNS
      give a error if there is no such database or a table respectively.
      
      
      mysql-test/r/show_check.result:
        Add result for the test that SHOW TABLES and SHOW COLUMNS give a error
        if there is no such database or a table respectively.
      mysql-test/t/show_check.test:
        Add test case that SHOW TABLES and SHOW COLUMNS give a error
        if there is no such database or a table respectively.
      sql/mysql_priv.h:
        Remove prototype of mysql_find_files(), which is made static under
        find_files() name.
      sql/sql_show.cc:
        Rename mysql_find_files() to find_files() and make it static.
        Return FIND_FILES_OK for success, FIND_FILES_OOM for out of memory,
        and FIND_FILES_DIR for directory reading error.
        Downgrade error to warning in get_all_tables() if it is a
        FIND_FILES_DIR error, and we are not in the 'SHOW' command.
        Once 'result' is set to 1 in get_schema_tables_result(), there's no
        need in continuing iterations, as we are about to return a error.
      0abc107c
  4. 27 Jul, 2006 3 commits
    • unknown's avatar
      Fix for BUG#20438: CREATE statements for views, stored routines and triggers · d36f5781
      unknown authored
      can be not replicable.
      
      Now CREATE statements for writing in the binlog are created as follows:
        - the beginning of the statement is re-created;
        - the rest of the statement is copied from the original query.
      
      The problem appears when there is a version-specific comment (produced by
      mysqldump), started in the re-created part of the statement and closed in the
      copied part -- there is closing comment-parenthesis, but there is no opening
      one.
      
      The proper fix could be to re-create original statement, but we can not
      implement it in 5.0. So, for 5.0 the fix is just to cut closing
      comment-parenthesis. This technique is also used for SHOW CREATE PROCEDURE
      statement (so we are able to reuse existing code).
      
      
      mysql-test/r/rpl_sp.result:
        Updated result file.
      mysql-test/r/rpl_trigger.result:
        Updated result file.
      mysql-test/r/rpl_view.result:
        Updated result file.
      mysql-test/t/rpl_sp.test:
        Added test case for BUG#20438.
      mysql-test/t/rpl_trigger.test:
        Added test case for BUG#20438.
      mysql-test/t/rpl_view.test:
        Added test case for BUG#20438.
      sql/sp.cc:
        Trim comments at the end.
      sql/sp_head.cc:
        Moved this code to the separate function to be re-used.
      sql/sql_lex.cc:
        Added a new function.
      sql/sql_lex.h:
        Added a new function.
      sql/sql_trigger.cc:
        Trim comments at the end.
      sql/sql_view.cc:
        Trim comments at the end.
      d36f5781
    • unknown's avatar
      Fix for BUG#16211: Stored function return type for strings is ignored. · 3c108584
      unknown authored
      Fix for BUG#16676: Database CHARSET not used for stored procedures
      
      The problem in BUG#16211 is that CHARSET-clause of the return type for
      stored functions is just ignored.
      
      The problem in BUG#16676 is that if character set is not explicitly
      specified for sp-variable, the server character set is used instead
      of the database one.
      
      The fix has two parts:
      
        - always store CHARSET-clause of the return type along with the
          type definition in mysql.proc.returns column. "Always" means that
          CHARSET-clause is appended even if it has not been explicitly
          specified in CREATE FUNCTION statement (this affects BUG#16211 only).
      
          Storing CHARSET-clause if it is not specified is essential to avoid
          changing character set if the database character set is altered in
          the future.
      
          NOTE: this change is not backward compatible with the previous releases.
      
        - use database default character set if CHARSET-clause is not explicitly
          specified (this affects both BUG#16211 and BUG#16676).
      
          NOTE: this also breaks backward compatibility.
      
      
      mysql-test/r/mysqldump.result:
        Updated result file.
      mysql-test/r/sp.result:
        Updated result file.
      mysql-test/t/sp.test:
        Provided test cases for BUG#16211, BUG#16676.
      sql/mysql_priv.h:
        Added two convenient functions for work with databases.
      sql/sp.cc:
        1. Add CHARSET-clause to CREATE-statement if it has been explicitly specified.
        2. Polishing -- provided some comments.
      sql/sp_head.cc:
        Use database charset as default charset of sp-variable.
      sql/sp_head.h:
        Move init_sp_name() out of init_strings().
      sql/sql_db.cc:
        Two new functions created:
          - load_db_opt_by_name();
          - check_db_dir_existence();
      sql/sql_show.cc:
        Eliminate duplicated code by using
        check_db_dir_existence() and load_db_opt_by_name()
      sql/sql_table.cc:
        Eliminate duplicated code by using
        check_db_dir_existence() and load_db_opt_by_name()
      sql/sql_yacc.yy:
        Call sp_head::init_sp_name() to initialize stored routine name.
      3c108584
    • unknown's avatar
      Don't complain in the error log about IM shutdown unless · 49d721d7
      unknown authored
      BUG#20761 is fixed.
      
      
      49d721d7
  5. 24 Jul, 2006 3 commits
    • unknown's avatar
      Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0 · 44a40f1d
      unknown authored
      into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-bug14702
      
      
      44a40f1d
    • unknown's avatar
      BUG#14702: misleading error message when syntax error in · 3037459a
      unknown authored
                 CREATE PROCEDURE
      
      The bug was fixed already.  This changeset adds a test case.
      
      
      mysql-test/r/sp-error.result:
        Add result for bug#14702: misleading error message when syntax error
        in CREATE PROCEDURE.
      mysql-test/t/sp-error.test:
        Add test case for bug#14702: misleading error message when syntax error
        in CREATE PROCEDURE.
      3037459a
    • unknown's avatar
      A fix and a test case for Bug#15752 "Lost connection to MySQL server · 36510232
      unknown authored
      when calling a SP from C API"
      
      The bug was caused by lack of checks for misuse in mysql_real_query. 
      A stored procedure always returns at least one result, which is the 
      status of execution of the procedure itself.
      This result, or so-called OK packet, is similar to a result
      returned by INSERT/UPDATE/CREATE operations: it contains the overall
      status of execution, the number of affected rows and the number of
      warnings. The client test program attached to the bug did not read this 
      result and ivnoked the next query. In turn, libmysql had no check for 
      such scenario and mysql_real_query was simply trying to send that query 
      without reading the pending response, thus messing up the communication
      protocol.
      
      The fix is to return an error from mysql_real_query when it's called
      prior to retrieval of all pending results.
      
      
      client/mysqlbinlog.cc:
        net_safe_read -> cli_safe_read
      include/mysql.h:
        Remove a private function from the public header.
      include/mysql_com.h:
        Remove a define that is never used.
      include/sql_common.h:
        Add a declaration for cli_safe_read - a function that reads one packet
        from the server.
      libmysql/libmysql.c:
        net_safe_read -> cli_safe_read
        Return CR_COMMANDS_OUT_OF_SYNC on attempt to execute a statement
        using a connection which has pending result sets.
      sql-common/client.c:
        Actual fix for Bug#15752: if the server has pending result sets for
        the client, return CR_COMMANDS_OUT_OF_SYNC on attempt to execute
        another query. Similarly to the behaviour of mysql_use_result(),
        multiple result sets block the connection and must be fetched
        before it can be used for another query.
        This uncovered an error in the protocol: the server doesn't drop
        SERVER_MORE_RESULTS_EXISTS status flag upon an error, so in case of
        a multi-query like SELECT 1; SELECT syntax_error; SELECT 2; 
        the client has no way to know that the server won't ever come to 
        execution of the third query and won't return any result sets for it.
        For now, fix it in cli_safe_read, as a proper fix requires extension
        of the client-server protocol.
      sql/protocol.cc:
        Remove a name that is never used.
      sql/slave.cc:
        net_safe_read -> cli_safe_read
      tests/mysql_client_test.c:
        Make 'query' a local variable to avoid name clash.
        Add a test case for Bug#15752 "Lost connection to MySQL server when
        calling an SP from C API"
      36510232
  6. 21 Jul, 2006 1 commit
  7. 20 Jul, 2006 1 commit
    • unknown's avatar
      Fix for BUG#20716: SHOW INSTANCES statement causes races in IM tests. · d8180d44
      unknown authored
        
      Fix for the bug in mysql-test-run.pl which prevents other tests succeed
      after IM-test failure.
        
      The idea of the fix of BUG#20716 is to:
        1. Check each SHOW INSTANCES statement, add necessary "sleep" instruction before;
        2. Move all environment checkings into the one file and include it everywhere.
      
      
      mysql-test/mysql-test-run.pl:
        Fix bug in mysql-test-run.pl -- kill leftovers if some
        guarded mysqld-instance is still alive after IM shutdown.
      mysql-test/r/im_daemon_life_cycle.result:
        Updated result file.
      mysql-test/r/im_life_cycle.result:
        Updated result file.
      mysql-test/r/im_options_set.result:
        Updated result file.
      mysql-test/r/im_options_unset.result:
        Updated result file.
      mysql-test/r/im_utils.result:
        Updated result file.
      mysql-test/t/im_daemon_life_cycle.imtest:
        Include im_check_env.inc for the checking of environment.
      mysql-test/t/im_life_cycle.imtest:
        Include im_check_env.inc for the checking of environment.
      mysql-test/t/im_options_set.imtest:
        Include im_check_env.inc for the checking of environment.
      mysql-test/t/im_options_unset.imtest:
        Include im_check_env.inc for the checking of environment.
      mysql-test/t/im_utils.imtest:
        Include im_check_env.inc for the checking of environment.
      mysql-test/include/im_check_env.inc:
        A new file to be included in each IM-test.
        The statements in the file ensure that starting
        conditions (environment) are as expected.
      d8180d44
  8. 17 Jul, 2006 2 commits
    • unknown's avatar
      Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0 · ec4a7522
      unknown authored
      into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-bug21013
      
      
      ec4a7522
    • unknown's avatar
      Bug#21013: Performance Degrades when importing data that uses Trigger · ca00a985
      unknown authored
                 and Stored Procedure
      
      The essence of the bug was that for every re-execution of stored
      routine or prepared statement new items for character set conversions
      were created, thus increasing the number of items and the time of their
      processing, and creating memory leak.
      
      No test case is provided since current test suite can't cover such type
      of bugs.
      
      
      mysql-test/r/sp.result:
        Add result for bug#21013: Performance Degrades when importing data
        that uses Trigger and Stored Procedure.
      mysql-test/t/sp.test:
        Add test case for bug#21013: Performance Degrades when importing data
        that uses Trigger and Stored Procedure.
      sql/item.cc:
        Switch arena only when in statement prepare mode.  Subsequent executions
        will use cached item tree.
      ca00a985
  9. 13 Jul, 2006 2 commits
    • unknown's avatar
      Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0 · 51dddb3a
      unknown authored
      into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-bug18630
      
      
      sql/item_func.cc:
        Auto merged
      sql/item_func.h:
        Auto merged
      sql/sql_parse.cc:
        Auto merged
      sql/sql_trigger.cc:
        Auto merged
      51dddb3a
    • unknown's avatar
      Bug#18630: Arguments of suid routine calculated in wrong security · 06bf59ad
      unknown authored
                 context.
      
      Routine arguments were evaluated in the security context of the routine
      itself, not in the caller's context.
      
      The bug is fixed the following way:
      
        - Item_func_sp::find_and_check_access() has been split into two
          functions: Item_func_sp::find_and_check_access() itself only
          finds the function and check that the caller have EXECUTE privilege
          on it.  New function set_routine_security_ctx() changes security
          context for SUID routines and checks that definer have EXECUTE
          privilege too.
      
        - new function sp_head::execute_trigger() is called from
          Table_triggers_list::process_triggers() instead of
          sp_head::execute_function(), and is effectively just as the
          sp_head::execute_function() is, with all non-trigger related code
          removed, and added trigger-specific security context switch.
      
        - call to Item_func_sp::find_and_check_access() stays outside
          of sp_head::execute_function(), and there is a code in
          sql_parse.cc before the call to sp_head::execute_procedure() that
          checks that the caller have EXECUTE privilege, but both
          sp_head::execute_function() and sp_head::execute_procedure() call
          set_routine_security_ctx() after evaluating their parameters,
          and restore the context after the body is executed.
      
      
      mysql-test/r/sp-security.result:
        Add test case for bug#18630: Arguments of suid routine calculated
        in wrong security context.
      mysql-test/t/sp-security.test:
        Add result for bug#18630: Arguments of suid routine calculated
        in wrong security context.
      sql/item_func.cc:
        Do not change security context before executing the function, as it
        will be changed after argument evaluation.
        Do not change security context in Item_func_sp::find_and_check_access().
      sql/item_func.h:
        Change prototype for Item_func_sp::find_and_check_access().
      sql/sp_head.cc:
        Add set_routine_security_ctx() function.
        Add sp_head::execute_trigger() method.
        Change security context in sp_head::execute_trigger(), and in
        sp_head::execute_function() and sp_head::execute_procedure()
        after argument evaluation.
        Move pop_all_cursors() call to sp_head::execute().
      sql/sp_head.h:
        Add declaration for sp_head::execute_trigger() and
        set_routine_security_ctx().
      sql/sql_parse.cc:
        Do not change security context before executing the procedure, as it
        will be changed after argument evaluation.
      sql/sql_trigger.cc:
        Call new sp_head::execute_trigger() instead of
        sp_head::execute_function(), which is responsible to switch
        security context.
      06bf59ad
  10. 12 Jul, 2006 3 commits
    • unknown's avatar
      Merge bk-internal.mysql.com:/home/bk/mysql-5.0 · f60d9a3e
      unknown authored
      into  bodhi.local:/opt/local/work/mysql-5.0-runtime
      
      
      f60d9a3e
    • unknown's avatar
      Fix a valgrind warning in type_date test. · a7dddd3b
      unknown authored
      
      sql/item_timefunc.cc:
        Fix a valgrind warning in type_date test.	
      a7dddd3b
    • unknown's avatar
      Merge dl145k.mysql.com:/data0/mkindahl/bkroot/mysql-5.0 · a08a6f9f
      unknown authored
      into  dl145k.mysql.com:/data0/mkindahl/bk/mysql-5.0-rpl
      
      
      ndb/include/kernel/GlobalSignalNumbers.h:
        Auto merged
      ndb/src/kernel/blocks/dbdict/Dbdict.cpp:
        Auto merged
      ndb/src/kernel/blocks/dbdict/Dbdict.hpp:
        Auto merged
      ndb/src/kernel/blocks/dbdih/DbdihMain.cpp:
        Auto merged
      ndb/src/ndbapi/ndberror.c:
        Auto merged
      sql/ha_ndbcluster.cc:
        Auto merged
      sql/handler.h:
        Auto merged
      sql/sql_base.cc:
        Auto merged
      sql/sql_insert.cc:
        Auto merged
      a08a6f9f
  11. 11 Jul, 2006 8 commits
    • unknown's avatar
      Post-merge fixes for Bug#19399 "Stored Procedures 'Lost Connection' · 3ff08ab8
      unknown authored
      when dropping/creating tables"
      
      
      mysql-test/r/ps.result:
        A post-merge fix.
      mysql-test/t/ps.test:
        A post-merge fix: all 5.0 tests should go after 4.1 tests.
      sql/sql_lex.cc:
        auxilliary -> auxiliary
      sql/sql_prepare.cc:
        auxilliary -> auxiliary
      sql/table.cc:
        Update st_table_list::reinit_before_use in 5.0 to include 5.0-specific
        cleanups.
      sql/table.h:
        st_table_list::reinit_before_use is public.
      3ff08ab8
    • unknown's avatar
      Merge bodhi.local:/opt/local/work/tmp_merge · d8b447a1
      unknown authored
      into  bodhi.local:/opt/local/work/mysql-5.0-runtime-merge-41
      
      
      ndb/src/mgmsrv/ConfigInfo.cpp:
        Auto merged
      sql/table.cc:
        Auto merged
      mysql-test/r/ps.result:
        Manual merge: use local.
      mysql-test/t/ps.test:
        Manual merge: remove duplicate test cases from ps.test.
      sql/sql_lex.cc:
        Manual merge.
      sql/sql_prepare.cc:
        Manual merge.
      sql/table.h:
        Manual merge.
      d8b447a1
    • unknown's avatar
      Merge bk-internal.mysql.com:/home/bk/mysql-5.0 · 67d53e36
      unknown authored
      into  bodhi.local:/opt/local/work/mysql-5.0-runtime-merge-41
      
      
      sql/sql_table.cc:
        Auto merged
      67d53e36
    • unknown's avatar
      Merge chilla.local:/home/mydev/mysql-5.0-release · 034522f4
      unknown authored
      into  chilla.local:/home/mydev/mysql-5.0-amerge
      
      
      sql/handler.h:
        Auto merged
      sql/sql_table.cc:
        Auto merged
      034522f4
    • unknown's avatar
      Raise the version number. · 0859819a
      unknown authored
      0859819a
    • unknown's avatar
      Merge jbruehe@bk-internal.mysql.com:/home/bk/mysql-5.0 · 0e694880
      unknown authored
      into  trift2.:/M50/mysql-5.0
      
      
      0e694880
    • unknown's avatar
      Merge dl145k.mysql.com:/data0/mkindahl/bkroot/mysql-5.0-rpl · fabab792
      unknown authored
      into  dl145k.mysql.com:/data0/mkindahl/bk/MERGE/mysql-5.0-merge
      
      
      ndb/include/kernel/GlobalSignalNumbers.h:
        Auto merged
      ndb/src/kernel/blocks/dbdict/Dbdict.cpp:
        Auto merged
      ndb/src/kernel/blocks/dbdict/Dbdict.hpp:
        Auto merged
      ndb/src/kernel/blocks/dbdih/DbdihMain.cpp:
        Auto merged
      ndb/src/ndbapi/ndberror.c:
        Auto merged
      fabab792
    • unknown's avatar
      Merge bk-internal.mysql.com:/home/bk/mysql-5.0 · aedfd072
      unknown authored
      into  bodhi.local:/opt/local/work/mysql-5.0-runtime-merge-41
      
      
      sql/opt_range.cc:
        Auto merged
      support-files/mysql.spec.sh:
        Auto merged
      mysql-test/Makefile.am:
        Manual merge.
      aedfd072
  12. 10 Jul, 2006 12 commits