1. 16 Mar, 2007 5 commits
  2. 15 Mar, 2007 2 commits
  3. 14 Mar, 2007 4 commits
    • malff/marcsql@weblab.(none)'s avatar
    • malff/marcsql@weblab.(none)'s avatar
      Merge weblab.(none):/home/marcsql/TREE/mysql-5.0-runtime · 62247621
      malff/marcsql@weblab.(none) authored
      into  weblab.(none):/home/marcsql/TREE/mysql-5.1-26503-merge
      62247621
    • malff/marcsql@weblab.(none)'s avatar
      Merge malff@bk-internal.mysql.com:/home/bk/mysql-5.0-runtime · f87899c5
      malff/marcsql@weblab.(none) authored
      into  weblab.(none):/home/marcsql/TREE/mysql-5.0-26503
      f87899c5
    • malff/marcsql@weblab.(none)'s avatar
      Bug#26503 (Illegal SQL exception handler code causes the server to crash) · bef323b1
      malff/marcsql@weblab.(none) authored
      Before this fix, the parser would accept illegal code in SQL exceptions
      handlers, that later causes the runtime to crash when executing the code,
      due to memory violations in the exception handler stack.
      
      The root cause of the problem is instructions within an exception handler
      that jumps to code located outside of the handler. This is illegal according
      to the SQL 2003 standard, since labels located outside the handler are not
      supposed to be visible (they are "out of scope"), so any instruction that
      jumps to these labels, like ITERATE or LEAVE, should not parse.
      
      The section of the standard that is relevant for this is :
        SQL:2003 SQL/PSM (ISO/IEC 9075-4:2003)
        section 13.1 <compound statement>,
        syntax rule 4
      <quote>
        The scope of the <beginning label> is CS excluding every <SQL schema
        statement> contained in CS and excluding every
        <local handler declaration list> contained in CS. <beginning label> shall
        not be equivalent to any other <beginning label>s within that scope.
      </quote>
      
      With this fix, the C++ class sp_pcontext, which represent the "parsing
      context" tree (a.k.a symbol table) of a stored procedure, has been changed
      as follows:
      - constructors have been cleaned up, so that only building a root node for
      the tree is public; building nodes inside a tree is not public.
      - a new member, m_label_scope, indicates if a given syntactic context
      belongs to a DECLARE HANDLER block,
      - label resolution, in the method find_label(), has been changed to
      implement the restriction of scope regarding labels used in a compound
      statement.
      
      The actions in the parser, when parsing the body of a SQL exception handler,
      have been changed as follows:
      - the implementation of an exception handler (DECLARE HANDLER) now creates
      explicitly a new sp_pcontext, to isolate the code inside the handler from
      the containing compound statement context.
      - registering exception handlers as a result occurs in the parent context,
      see the rule sp_hcond_element
      - the code in sp_hcond_list has been cleaned up, to avoid code duplication
      
      In addition, the flags IN_SIMPLE_CASE and IN_HANDLER, declared in sp_head.h
      have been removed, since they are unused and broken by design (as seen with
      Bug 19194 (Right recursion in parser for CASE causes excessive stack usage,
      limitation), representing a stack in a single flag is not possible.
      
      Tests in sp-error have been added to show that illegal constructs are now
      rejected.
      
      Tests in sp have been added for code coverage, to show that ITERATE or LEAVE
      statements are legal when jumping to a label in scope, inside the body of
      an exception handler.
      bef323b1
  4. 13 Mar, 2007 1 commit
    • kroki/tomash@moonlight.home's avatar
      Fix the bug introduced with the push of the fix for bug#18326: Do not · 53d4592f
      kroki/tomash@moonlight.home authored
      lock table for writing during prepare of statement.
      
      When single call open_normal_and_derived_tables() was used, we never
      set table_count to the right value.  This patch reverts the part of
      the old code that does open_tables() (and sets table_count), then
      checks if table_list->multitable_view is set (and returns if so, using
      table_count value), and only then it does mysql_handle_derived().
      53d4592f
  5. 09 Mar, 2007 8 commits
    • kroki/tomash@moonlight.home's avatar
      Merge moonlight.home:/home/tomash/src/mysql_ab/mysql-5.1 · 09d89e9c
      kroki/tomash@moonlight.home authored
      into  moonlight.home:/home/tomash/src/mysql_ab/mysql-5.1-bug16425
      09d89e9c
    • guilhem@gbichot3.local's avatar
      Fix for BUG#735 "Prepared Statements: there is no support for Query · eaf7728d
      guilhem@gbichot3.local authored
      Cache".
      WL#1569 "Prepared Statements: implement support of Query Cache".
      Prepared SELECTs did not look up in the query cache, and their results
      were not stored in the query cache. This made them slower than
      non-prepared SELECTs in some cases.
      The fix is to re-use the expanded query (the prepared query where
      "?" placeholders are replaced by their values, at execution time)
      for searching/storing in the query cache.
      It works fine for statements prepared via mysql_stmt_prepare(), which
      are the most commonly used and were the scope of this bugfix and WL.
      It works less fine for statements prepared via the SQL command
      PREPARE...FROM, which are still not using the query cache if they
      have at least one parameter (because then the expanded query contains
      names of user variables, and user variables don't work with the
      query cache, even in non-prepared queries).
      Note that results from prepared SELECTs, which are in the binary
      protocol, and results from normal SELECTs, which are in the text
      protocol, ignore each other in the query cache, because a result in the
      binary protocol should never be served to a SELECT expecting the text
      protocol and vice-versa.
      Note, after this patch, bug 25843 starts applying to query cache
      ("changing default database between PREPARE and EXECUTE of statement
      breaks binlog"), we need to fix it.
      eaf7728d
    • guilhem@gbichot3.local's avatar
      manual merge · 8efe1b1f
      guilhem@gbichot3.local authored
      8efe1b1f
    • kroki/tomash@moonlight.home's avatar
      Resolve one shift/reduce conflict introduced with the push of the fix · 8ff2d861
      kroki/tomash@moonlight.home authored
      for bug#16425: Events: no DEFINER clause.  The problem was that there
      were two rules
      
        ALTER view_algorithm_opt definer ... VIEW ...
        ALTER definer EVENT ...
      
      so when there was 'ALTER definer' in the input it was unclear if empty
      view_algorithm_opt should be executed or not.
      
      We solve this by introducing three distinct rules
      
        ALTER view_algorithm definer ... VIEW ...
        ALTER definer ... VIEW ...
        ALTER definer EVENT ...
      
      that remove the ambiguity.
      8ff2d861
    • kroki/tomash@moonlight.home's avatar
      Merge moonlight.home:/home/tomash/src/mysql_ab/mysql-5.1 · 7bbea967
      kroki/tomash@moonlight.home authored
      into  moonlight.home:/home/tomash/src/mysql_ab/mysql-5.1-bug9953
      7bbea967
    • kroki/tomash@moonlight.home's avatar
      BUG#9953: CONVERT_TZ requires mysql.time_zone_name to be locked · c19affef
      kroki/tomash@moonlight.home authored
      The problem was that some facilities (like CONVERT_TZ() function or
      server HELP statement) may require implicit access to some tables in
      'mysql' database.  This access was done by ordinary means of adding
      such tables to the list of tables the query is going to open.
      However, if we issued LOCK TABLES before that, we would get "table
      was not locked" error trying to open such implicit tables.
      
      The solution is to treat certain tables as MySQL system tables, like
      we already do for mysql.proc.  Such tables may be opened for reading
      at any moment regardless of any locks in effect.  The cost of this is
      that system table may be locked for writing only together with other
      system tables, it is disallowed to lock system tables for writing and
      have any other lock on any other table.
      
      After this patch the following tables are treated as MySQL system
      tables:
        mysql.help_category
        mysql.help_keyword
        mysql.help_relation
        mysql.help_topic
        mysql.proc (it already was)
        mysql.time_zone
        mysql.time_zone_leap_second
        mysql.time_zone_name
        mysql.time_zone_transition
        mysql.time_zone_transition_type
      
      These tables are now opened with open_system_tables_for_read() and
      closed with close_system_tables(), or one table may be opened with
      open_system_table_for_update() and closed with close_thread_tables()
      (the latter is used for mysql.proc table, which is updated as part of
      normal MySQL server operation).  These functions may be used when
      some tables were opened and locked already.
      
      NOTE: online update of time zone tables is not possible during
      replication, because there's no time zone cache flush neither on LOCK
      TABLES, nor on FLUSH TABLES, so the master may serve stale time zone
      data from cache, while on slave updated data will be loaded from the
      time zone tables.
      c19affef
    • anozdrin/alik@booka.opbmk's avatar
      Fix typo. · bd5b38d6
      anozdrin/alik@booka.opbmk authored
      bd5b38d6
    • anozdrin/alik@booka.opbmk's avatar
  6. 08 Mar, 2007 3 commits
  7. 07 Mar, 2007 11 commits
    • malff/marcsql@weblab.(none)'s avatar
      Merge weblab.(none):/home/marcsql/TREE/mysql-5.0-runtime · 77f73c83
      malff/marcsql@weblab.(none) authored
      into  weblab.(none):/home/marcsql/TREE/mysql-5.1-8407-cleanup
      77f73c83
    • kroki/tomash@moonlight.home's avatar
    • malff/marcsql@weblab.(none)'s avatar
      · 1f91f47d
      malff/marcsql@weblab.(none) authored
      Bug 8407, post review cleanup: use instr::get_cont_dest() to get the instruction
      continuation instruction, for CONTINUE exception handlers.
      1f91f47d
    • kroki/tomash@moonlight.home's avatar
      Merge moonlight.home:/home/tomash/src/mysql_ab/mysql-5.1 · bfd1c460
      kroki/tomash@moonlight.home authored
      into  moonlight.home:/home/tomash/src/mysql_ab/mysql-5.1-bug18326
      bfd1c460
    • kroki/tomash@moonlight.home's avatar
      BUG#18326: Do not lock table for writing during prepare of statement · 3e8bfc83
      kroki/tomash@moonlight.home authored
      During statement prepare phase the tables were locked as if the
      statement is being executed, however this is not necessary.
      
      The solution is to not lock tables on statement prepare phase.
      Opening tables is enough to prevent DDL on them, and during statement
      prepare we do not access nor modify any data.
      3e8bfc83
    • kostja@bodhi.local's avatar
      A post merge fix. · ba60ccbf
      kostja@bodhi.local authored
      ba60ccbf
    • kostja@bodhi.local's avatar
      Merge bodhi.local:/opt/local/work/mysql-5.0-runtime · 4b879f22
      kostja@bodhi.local authored
      into  bodhi.local:/opt/local/work/mysql-5.1-runtime
      4b879f22
    • kostja@bodhi.local's avatar
      b89b1922
    • kostja@bodhi.local's avatar
      Merge bodhi.local:/opt/local/work/mysql-5.0-26750 · ae978961
      kostja@bodhi.local authored
      into  bodhi.local:/opt/local/work/mysql-5.1-runtime
      ae978961
    • kostja@bodhi.local's avatar
      Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime · c2e0e5af
      kostja@bodhi.local authored
      into  bodhi.local:/opt/local/work/mysql-5.0-26750
      c2e0e5af
    • kostja@bodhi.local's avatar
      A fix for Bug#26750 "valgrind leak in sp_head" (and post-review · 86f02cd3
      kostja@bodhi.local authored
      fixes).
      
      The legend: on a replication slave, in case a trigger creation
      was filtered out because of application of replicate-do-table/
      replicate-ignore-table rule, the parsed definition of a trigger was not 
      cleaned up properly. LEX::sphead member was left around and leaked 
      memory. Until the actual implementation of support of 
      replicate-ignore-table rules for triggers by the patch for Bug 24478 it 
      was never the case that "case SQLCOM_CREATE_TRIGGER"
      was not executed once a trigger was parsed,
      so the deletion of lex->sphead there worked and the memory did not leak.
      
      The fix: 
      
      The real cause of the bug is that there is no 1 or 2 places where
      we can clean up the main LEX after parse. And the reason we 
      can not have just one or two places where we clean up the LEX is
      asymmetric behaviour of MYSQLparse in case of success or error. 
      
      One of the root causes of this behaviour is the code in Item::Item()
      constructor. There, a newly created item adds itself to THD::free_list
      - a single-linked list of Items used in a statement. Yuck. This code
      is unaware that we may have more than one statement active at a time,
      and always assumes that the free_list of the current statement is
      located in THD::free_list. One day we need to be able to explicitly
      allocate an item in a given Query_arena.
      Thus, when parsing a definition of a stored procedure, like
      CREATE PROCEDURE p1() BEGIN SELECT a FROM t1; SELECT b FROM t1; END;
      we actually need to reset THD::mem_root, THD::free_list and THD::lex
      to parse the nested procedure statement (SELECT *).
      The actual reset and restore is implemented in semantic actions
      attached to sp_proc_stmt grammar rule.
      The problem is that in case of a parsing error inside a nested statement
      Bison generated parser would abort immediately, without executing the
      restore part of the semantic action. This would leave THD in an 
      in-the-middle-of-parsing state.
      This is why we couldn't have had a single place where we clean up the LEX
      after MYSQLparse - in case of an error we needed to do a clean up
      immediately, in case of success a clean up could have been delayed.
      This left the door open for a memory leak.
      
      One of the following possibilities were considered when working on a fix:
      - patch the replication logic to do the clean up. Rejected
      as breaks module borders, replication code should not need to know the
      gory details of clean up procedure after CREATE TRIGGER.
      - wrap MYSQLparse with a function that would do a clean up.
      Rejected as ideally we should fix the problem when it happens, not
      adjust for it outside of the problematic code.
      - make sure MYSQLparse cleans up after itself by invoking the clean up
      functionality in the appropriate places before return. Implemented in 
      this patch.
      - use %destructor rule for sp_proc_stmt to restore THD - cleaner
      than the prevoius approach, but rejected
      because needs a careful analysis of the side effects, and this patch is 
      for 5.0, and long term we need to use the next alternative anyway
      - make sure that sp_proc_stmt doesn't juggle with THD - this is a 
      large work that will affect many modules.
      
      Cleanup: move main_lex and main_mem_root from Statement to its
      only two descendants Prepared_statement and THD. This ensures that
      when a Statement instance was created for purposes of statement backup,
      we do not involve LEX constructor/destructor, which is fairly expensive.
      In order to track that the transformation produces equivalent 
      functionality please check the respective constructors and destructors
      of Statement, Prepared_statement and THD - these members were
      used only there.
      This cleanup is unrelated to the patch.
      86f02cd3
  8. 06 Mar, 2007 6 commits