List:Commits« Previous MessageNext Message »
From:Roy Lyseng Date:February 9 2012 10:38am
Subject:bzr push into mysql-trunk branch (roy.lyseng:3814 to 3864) Bug#13354910
View as plain text  
 3864 Jorgen Loland	2012-02-09
      BUG#13354910 - MAKE_JOIN_STATISTICS() INVOKES 
                     RECORDS_IN_RANGE(MIN_KEY=0X0, MAX_KEY=0X0)
      
      Preparation patch: improve readability of key_or() by using more
      descriptive variable names.
     @ sql/opt_range.cc
        Improve readability of key_or() by using more descriptive
        variable names.

    modified:
      sql/opt_range.cc
 3863 Nuno Carvalho	2012-02-08 [merge]
      BUG#13680651 - RPL_CORRUPTION TEST FAILS WITH SLAVE STOPPED WITH WRONG ERROR CODE ON VALGRIND
      
      rpl.rpl_corruption test fails with slave stopped with wrong error code:
      1721 (expected 1595,1722) on rhel5-x86-64bit-valgrind on daily trunk.
      
      Changed error code to the correct one, 1721 SQLSTATE: HY000
      (ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE).

    modified:
      mysql-test/suite/rpl/r/rpl_corruption.result
      mysql-test/suite/rpl/t/rpl_corruption.test
 3862 Jon Olav Hauglid	2012-02-08
      Bug#13417754 ASSERT IN ROW_DROP_DATABASE_FOR_MYSQL DURING DROP SCHEMA
      
      This assert could be triggered if an InnoDB table was being moved
      to a different database using ALTER TABLE ... RENAME, while this
      database concurrently was being dropped by DROP DATABASE.
      
      The reason for the problem was that no metadata lock was taken
      on the target database by ALTER TABLE ... RENAME.
      DROP DATABASE was therefore not blocked and could remove
      the database while ALTER TABLE ... RENAME was executing. This
      could cause the assert in InnoDB to be triggered.
      
      This patch fixes the problem by taking a IX metadata lock on
      the target database before ALTER TABLE ... RENAME starts
      moving a table to a different database.
      
      Note that this problem did not occur with RENAME TABLE which
      already takes the correct metadata locks.
      
      Also note that this patch slightly changes the behavior of
      ALTER TABLE ... RENAME. Before, the statement would abort and
      return an error if a lock on the target table name could not
      be taken immediately. With this patch, ALTER TABLE ... RENAME
      will instead block and wait until the lock can be taken 
      (or until we get a lock timeout). This also means that it is
      possible to get ER_LOCK_DEADLOCK errors in this situation
      since we allow ALTER TABLE ... RENAME to wait and not just
      abort immediately.
      
      Test case added to innodb_mysql_sync.test.

    modified:
      mysql-test/r/innodb_mysql_sync.result
      mysql-test/t/innodb_mysql_sync.test
      sql/sql_table.cc
      storage/innobase/handler/ha_innodb.cc
 3861 Vasil Dimov	2012-02-08
      Fix compilation warning with GCC 4.6:
      
      sql_show.cc: In function 'int store_create_info(THD*, TABLE_LIST*, String*, HA_CREATE_INFO*, bool)':
      sql_show.cc:1429:8: error: variable 'show_table_options' set but not used [-Werror=unused-but-set-variable]

    modified:
      sql/sql_show.cc
 3860 Roy Lyseng	2012-02-08
      Refactoring: Remove member and_tables_cache of Item_cond.
      
      The Item_cond class maintains both not_null_tables_cache
      and and_tables_cache to implement the not_null_tables()
      interface. and_tables_cache is only used for conditions of
      type AND, but it is simple to replace its use with
      not_null_tables_cache.
      
      sql/item.h:
        Deleted Item_name_const::const_item() and
        Item_sp_variable::const_item(), as they are the same as for the
        base class.
      
      sql/item_cmpfunc.cc:
        Maintain not_null_tables_cache instead of and_tables_cache.
      
      sql/item_cmpfunc.h:
        Remove member and_tables_cache, remove function not_null_tables()
        for class Item_cond.

    modified:
      sql/item.h
      sql/item_cmpfunc.cc
      sql/item_cmpfunc.h
 3859 Vasil Dimov	2012-02-08
      Fix compilation failure when compiling with partitioning disabled.
      partition_names is not defined in this case.
      
      Reviewed by:	mattiasj (via IM)

    modified:
      sql/sql_lex.cc
 3858 Rohit Kalhans	2012-02-08 [merge]
      null merge from mysql-5.5 -> mysql-trunk

 3857 Rohit Kalhans	2012-02-08
      reverting changes for the last push for bug#11758263 and the followup patch for the same.

    modified:
      mysql-test/extra/rpl_tests/rpl_insert_id_pk.test
      mysql-test/extra/rpl_tests/rpl_multi_update.test
      mysql-test/extra/rpl_tests/rpl_multi_update2.test
      mysql-test/extra/rpl_tests/rpl_multi_update3.test
      mysql-test/r/ps.result
      mysql-test/suite/binlog/r/binlog_unsafe.result
      mysql-test/suite/binlog/t/binlog_unsafe.test
      mysql-test/suite/rpl/r/rpl_auto_increment_11932.result
      mysql-test/suite/rpl/r/rpl_insert_id_pk.result
      mysql-test/suite/rpl/r/rpl_multi_update.result
      mysql-test/suite/rpl/r/rpl_multi_update2.result
      mysql-test/suite/rpl/r/rpl_multi_update3.result
      mysql-test/suite/rpl/r/rpl_rotate_logs.result
      mysql-test/suite/rpl/t/rpl_auto_increment_11932.test
      mysql-test/suite/rpl/t/rpl_multi_update2.test
      mysql-test/suite/rpl/t/rpl_multi_update3.test
      mysql-test/suite/rpl/t/rpl_optimize.test
      mysql-test/suite/rpl/t/rpl_rotate_logs.test
      mysql-test/suite/rpl/t/rpl_semi_sync_event.test
      mysql-test/suite/rpl/t/rpl_timezone.test
      mysql-test/t/multi_update.test
      mysql-test/t/ps.test
      sql/share/errmsg-utf8.txt
      sql/sql_base.cc
      sql/sql_lex.cc
      sql/sql_lex.h
      sql/sql_parse.cc
 3856 kevin.lewis@oracle.com	2012-02-07
      WL#6145 - This patch moves to the storage engine the code that
      determines whether DATA DIRECTORY and INDEX DIRECTORY on a
      CREATE TABLE command is ignored.  It affects Archive and MyISAM
      storage engines where these clauses are used, and it affects the
      Partition engine where these clauses are passed through to the
      lower engine.  In the future, WL5980, InnoDB will also use these
      clauses.

    modified:
      mysql-test/r/partition_windows.result
      sql/log_event.cc
      sql/partition_info.cc
      sql/sql_parse.cc
      sql/sql_table.cc
      storage/archive/ha_archive.cc
      storage/myisam/ha_myisam.cc
 3855 Guilhem Bichot	2012-02-07 [merge]
      merge from trunk

    modified:
      mysql-test/r/ps.result
      mysql-test/t/ps.test
 3854 Guilhem Bichot	2012-02-07
      Temporarily revert fix for
      Bug#13623473 MISSING ROWS ON SELECT AND JOIN WITH TIME/DATETIME COMPARE
      until the failure of ps_2myisam on Windows non-debug builds
      in pb2 is fixed.

    modified:
      mysql-test/r/ps_2myisam.result
      mysql-test/r/ps_3innodb.result
      mysql-test/r/ps_4heap.result
      mysql-test/r/ps_5merge.result
      mysql-test/r/type_temporal_fractional.result
      mysql-test/r/type_time.result
      mysql-test/t/type_time.test
      sql/field.cc
      sql/opt_range.cc
      sql/sql_optimizer.cc
      sql/sql_optimizer.h
 3853 Rohit Kalhans	2012-02-08 [merge]
      merge from mysql-5.5 to trunk after the patch for bug#11758263.

    modified:
      mysql-test/extra/rpl_tests/rpl_insert_id_pk.test
      mysql-test/extra/rpl_tests/rpl_multi_update.test
      mysql-test/extra/rpl_tests/rpl_multi_update2.test
      mysql-test/extra/rpl_tests/rpl_multi_update3.test
      mysql-test/r/ps.result
      mysql-test/suite/binlog/r/binlog_unsafe.result
      mysql-test/suite/binlog/t/binlog_unsafe.test
      mysql-test/suite/rpl/r/rpl_auto_increment_11932.result
      mysql-test/suite/rpl/r/rpl_insert_id_pk.result
      mysql-test/suite/rpl/r/rpl_multi_update.result
      mysql-test/suite/rpl/r/rpl_multi_update2.result
      mysql-test/suite/rpl/r/rpl_multi_update3.result
      mysql-test/suite/rpl/r/rpl_rotate_logs.result
      mysql-test/suite/rpl/t/rpl_auto_increment_11932.test
      mysql-test/suite/rpl/t/rpl_multi_update2.test
      mysql-test/suite/rpl/t/rpl_multi_update3.test
      mysql-test/suite/rpl/t/rpl_optimize.test
      mysql-test/suite/rpl/t/rpl_rotate_logs.test
      mysql-test/suite/rpl/t/rpl_semi_sync_event.test
      mysql-test/suite/rpl/t/rpl_timezone.test
      mysql-test/t/multi_update.test
      mysql-test/t/ps.test
      sql/share/errmsg-utf8.txt
      sql/sql_base.cc
      sql/sql_lex.cc
      sql/sql_lex.h
      sql/sql_parse.cc
 3852 Guilhem Bichot	2012-02-07
      Fix for Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY HAS AN EMPTY RESULT
      Empty const table didn't cause the query to have an empty result set.
     @ mysql-test/include/subquery.inc
        Though the bug isn't exactly about subqueries (does not require
        a subquery, only a derived table), I put the testcase here
        because I want it tested with subquery materialization when
        merged in the wl6095 tree - it used to cause an assert in
        the wl6095 code).
        Without the code fix, both SELECTs using derived tables
        would return a row full of zeroes ("0" for int,
        "00:00:00" for time...), and "SELECT @var3" would
        return 12.
     @ sql/sql_executor.cc
        comments
     @ sql/sql_optimizer.cc
        Scenario of the bug follows (for the queries in subquery.inc).
        All tables are one-or-zero-row MyISAM tables.
        $subq is of the form:
          SELECT ... FROM t1 WHERE ... ,
        When run as a standalone query, it returns zero rows (because t1 is
        empty).
        But when $subq is put inside the definition of a derived table:
          SELECT ... FROM ($subq) AS alias3;
        then one row is returned, wrongly. Here is how it happens.
        * When we are materializing alias3, we start evaluating $subq; this
        finds that t1 is "an empty const table".
        * We thus come to this place in JOIN::optimize():
          if (const_table_map != found_const_table_map &&
              !(select_options & SELECT_DESCRIBE) &&
              (!conds ||
               !(conds->used_tables() & RAND_TABLE_BIT) ||
               select_lex->master_unit() == &thd->lex->unit))
          {
            zero_result_cause= "no matching row in const table";
            DBUG_PRINT("error",("Error: %s", zero_result_cause));
            goto setup_subq_exit;
          }
        * const_table_map != found_const_table_map (because there is an empty
        const table, which is in const_table_map and not in
        found_const_table_map)
        * this isn't EXPLAIN
        * this isn't the top query (we are inside a derived table)
        * the WHERE clause has RAND_TABLE_BIT because it uses a "random"
        construct, indeed:
        ** in the first testcase of subquery.inc, the trick of writing and
        reading @var3 in the same statement makes the optimizer correctly
        believe that @var3 is a changing value (thus, "random" - unpredictable
        for the optimizer)
        ** in the second testcase, both user variables and "NOT IN
        (inner subquery)" do the same trick.
        So, we don't enter the if() block. No short-circuit. Query is not
        marked as "empty result" in the optimization phase. t1's record buffer
        has been filled with NULLs (see mark_as_null_row() in
        join_read_system()).
        We then reach this place in do_select():
          if (join->tables == join->const_tables)
          {
            if (!join->conds || join->conds->val_int())
        We evaluate the WHERE (remember: on a pseudo-row of t1 filled with
        NULLs). In the first testcase, the WHERE is satisfied by the NULL
        row, so this row is written into the materialized derived temporary
        table. In the second testcase, in all logic the WHERE should not be
        satisfied (NULLs NOT IN (non-empty-inner-subq) should be UNKNOWN), but
        because columns of t1 are not NULLable, triggered conditions are not
        created in the inner subquery (see
        Item_in_subselect::row_value_transformer()), so things go further
        wrong.
        
        Afterwards, this temporary one-NULL-row table is read, and bad data is
        output (zeroes: there is conversion from NULL to zeroes at some stage,
        because columns of t1 are not NULLable; if I declare columns as
        NULLable I get NULLs in the output).
        
        The bugfix: in this code
          if (const_table_map != found_const_table_map &&
              !(select_options & SELECT_DESCRIBE) &&
              (!conds ||
               !(conds->used_tables() & RAND_TABLE_BIT) ||
               select_lex->master_unit() == &thd->lex->unit))
          {
            zero_result_cause= "no matching row in const table";
            DBUG_PRINT("error",("Error: %s", zero_result_cause));
            goto setup_subq_exit;
          }
        the two last conditions are wrong.
        If "const_table_map != found_const_table_map" it means that one empty
        const table has been found. It may have been found in two ways:
        * join_read_system() i.e. it's a table which has really zero rows
        (case of t1, in our scenario). In that case, the result of this query
        specification is guaranteed empty, no matter the WHERE condition, no
        matter if this query specification is a subquery or a top query.
        * join_read_const() i.e. it's a table which has a unique index, and we
        have in the WHERE something like unique_index=constant, and there is
        no match for "constant" in the index. Again, there is no need to check
        any other condition in the if(). make_join_statistics(), which
        extracts const tables, takes proper precautions to detect that "we
        have all information" to mark a table const. For example, if we have
        "unique_index=outer_table.column", where outer_table is outer to this
        query specification, then we won't mark as constant because we know
        that this equality depends on OUTER_REF_TABLE_BIT, which is "not an
        available table" at this stage (search for "// Found everything for
         ref"). Same for "unique_index=RAND()": RAND_TABLE_BIT is not
        available. So there is no need for the test on RAND_TABLE_BIT and
        on the placement of the query specification. By the way, those two
        conditions were added in 2004 with commit comment "af"...
        
        By deleting those wrong extra conditions, we don't let the NULL row go
        out.
        It would also be possible to delete '!(select_options &
        SELECT_DESCRIBE)' but it has been found that this condition
        - causes no wrong query result (it's only in EXPLAIN)
        - leads to a clearer EXPLAIN output: indeed, if we shortcut at this
        stage, EXPLAIN does not contain information about what table was found
        constant.
        - so it was decided to not touch this condition.

    modified:
      mysql-test/include/subquery.inc
      mysql-test/r/subquery_all.result
      mysql-test/r/subquery_all_bka.result
      mysql-test/r/subquery_all_bka_nixbnl.result
      mysql-test/r/subquery_nomat_nosj.result
      mysql-test/r/subquery_nomat_nosj_bka.result
      mysql-test/r/subquery_nomat_nosj_bka_nixbnl.result
      mysql-test/r/subquery_none.result
      mysql-test/r/subquery_none_bka.result
      mysql-test/r/subquery_none_bka_nixbnl.result
      sql/sql_executor.cc
      sql/sql_optimizer.cc
 3851 Guilhem Bichot	2012-02-07 [merge]
      merge from trunk

    modified:
      storage/myisam/mi_dbug.c
 3850 Guilhem Bichot	2012-02-07
      Bug #13623473 	MISSING ROWS ON SELECT AND JOIN WITH TIME/DATETIME COMPARE
      Cannot use index for indexed_time=datetime.
     @ mysql-test/r/ps_2myisam.result
        We are inserting @arg00 (this string: '1991-01-01 01:01:01') into a TIME
        so we now get a warning that the date part is lost.
     @ mysql-test/r/type_temporal_fractional.result
        when inserting '20020323065409.039577' the TIME column gets
        06:54:09 so we warn that the date part is lost.
     @ mysql-test/r/type_time.result
        Warn that the date part of "1999-02-03 20:33:34" is lost.
        
        Without the code fix in add_key_field(), all ref access on
        t1.col_time_key would return only 2012-01-31 00:00:00 and
        miss rows. You can see the new warning "Cannot use ref access".
        
        Without the code fix in get_mm_leaf(), queries with
        "range checked for each record" used the index on t1.col_time_key
        and missed rows. For example:
        SELECT * FROM
        t2 ignore INDEX (col_datetime_key)
        STRAIGHT_JOIN
        t1 force INDEX (col_time_key)
        WHERE col_time_key <= col_datetime_key;
        missed:
        2012-02-01 00:00:00	24:00:00
        2012-02-02 00:00:00	24:00:00
        2012-02-02 00:00:00	48:00:00
        And:
        SELECT * FROM t2 STRAIGHT_JOIN t3 FORCE INDEX (col_time_key)
        ON t3.col_time_key > t2.col_datetime_key;
        returned only:
        1	2001-11-04 19:07:55	k	19:22:21
        1	2001-11-04 19:07:55	k	19:47:59
        1	2001-11-04 19:07:55	k	21:22:34
        You cannot see the new warning "Cannot use range access" because:
        * when the range optimizer is tried for indexed_time=datetime_column,
        it is the "range checked for each record" case: range optimizer
        is called for each outer row during execution; that does not happen
        in EXPLAIN, and the warning may be raised only in EXPLAIN.
        * To see the warning in EXPLAIN, range optimizer would have
        to be called during optimization, which would require
        indexed_time=datetime_constant, in which case we are
        not in the same conversion rules...
     @ mysql-test/t/type_time.test
        test of col_time_key OP col_datetime_key, where OP is =,>=,>,<=,<,
        and index is forced/ignored. Exercises ref access and range scan.
        Plus the original testcase of the bug report.
     @ sql/field.cc
        When inserting a date/datetime/timestamp into a TIME column,
        warn that the date part is lost.
        We already did so when inserting datetime/timestamp
        into a DATE column.
        Note that we fix Field_timef but not Field_time:
        - Field_time is used only when reading a pre-5.6 table
        - so making Field_time raise a warning when the date
        part is chopped, is not worth it.
     @ sql/opt_range.cc
        "indexed_time OP temporal_expression_with_date"
        does not use index anymore (OP = any comparison operator)
     @ sql/sql_optimizer.cc
        "indexed_time = temporal_expression_with_date"
        does not use index anymore.
        A comment in code explains why "ref" access is impossible.

    modified:
      mysql-test/r/ps_2myisam.result
      mysql-test/r/ps_3innodb.result
      mysql-test/r/ps_4heap.result
      mysql-test/r/ps_5merge.result
      mysql-test/r/type_temporal_fractional.result
      mysql-test/r/type_time.result
      mysql-test/t/type_time.test
      sql/field.cc
      sql/opt_range.cc
      sql/sql_optimizer.cc
      sql/sql_optimizer.h
 3849 Guilhem Bichot	2012-02-07
      fix for pb2 failure: use lowercase table names and aliases, or EXPLAIN output differs per platform.

    modified:
      mysql-test/include/subquery.inc
      mysql-test/r/subquery_all.result
      mysql-test/r/subquery_all_bka.result
      mysql-test/r/subquery_all_bka_nixbnl.result
      mysql-test/r/subquery_nomat_nosj.result
      mysql-test/r/subquery_nomat_nosj_bka.result
      mysql-test/r/subquery_nomat_nosj_bka_nixbnl.result
      mysql-test/r/subquery_none.result
      mysql-test/r/subquery_none_bka.result
      mysql-test/r/subquery_none_bka_nixbnl.result
 3848 Tor Didriksen	2012-02-07
      WL#6160 filesort optimization: use std::stable_sort rather than quicksort
      
      Filesort currently uses either radixsort or quicksort when sorting records.
      Radixsort is very fast, but only for certain data sets (short keys).
      For *most* cases when my_qsort2() is used, it turns out that std::stable_sort()
      is faster.
      
      This worklog will extend the choice of sorting algorithms, preferring
      std::stable_sort() when that is assumed to be better than the other two.
     @ include/my_sys.h
        Declare my_bool radixsort_is_appliccable()
     @ mysql-test/r/ctype_many.result
        Replace result set: it depended on myisam/qsort output.
     @ mysql-test/r/mix2_myisam.result
        Replace result set: it depended on myisam/qsort output.
     @ mysql-test/r/myisam.result
        Replace result set: it depended on myisam/qsort output.
     @ mysql-test/r/type_temporal_fractional.result
        stable_sort produced a slightly different permutation
        (note that we're sorting on the second column, and the two permuted rows
        have equal value for this field)
     @ mysql-test/suite/funcs_1/r/innodb_views.result
        Extend the query to be deterministic: sort on all columns.
     @ mysql-test/suite/funcs_1/r/memory_views.result
        Extend the query to be deterministic: sort on all columns.
     @ mysql-test/suite/funcs_1/views/views_master.inc
        Extend the query to be deterministic: sort on all columns.
     @ mysql-test/suite/innodb/r/innodb.result
        Replace result set: it depended on myisam/qsort output.
     @ mysql-test/valgrind.supp
        New function signature for write_keys()
     @ mysys/mf_radix.c
        Add my_bool radixsort_is_appliccable()
     @ mysys/mf_sort.c
        Use my_bool radixsort_is_appliccable()
     @ sql/filesort.cc
        Let Filesort_buffer determine how to do the sorting,
        rather than calling a global function my_string_ptr_sort()
     @ sql/filesort_utils.cc
        Add Filesort_buffer::sort_buffer() which determines the best sorting strategy.
     @ sql/filesort_utils.h
        Add Filesort_buffer::sort_buffer() which determines the best sorting strategy.
     @ unittest/gunit/CMakeLists.txt
        New unit/benchmarking test.
     @ unittest/gunit/dynarray-t.cc
        Reduce num_iterations when not doing actual benchmarking.
     @ unittest/gunit/filesort_compare-t.cc
        New unit test.

    added:
      unittest/gunit/filesort_compare-t.cc
    modified:
      include/my_sys.h
      mysql-test/r/ctype_many.result
      mysql-test/r/mix2_myisam.result
      mysql-test/r/myisam.result
      mysql-test/r/type_temporal_fractional.result
      mysql-test/suite/funcs_1/r/innodb_views.result
      mysql-test/suite/funcs_1/r/memory_views.result
      mysql-test/suite/funcs_1/views/views_master.inc
      mysql-test/suite/innodb/r/innodb.result
      mysql-test/valgrind.supp
      mysys/mf_radix.c
      mysys/mf_sort.c
      sql/filesort.cc
      sql/filesort_utils.cc
      sql/filesort_utils.h
      sql/table.h
      unittest/gunit/CMakeLists.txt
      unittest/gunit/dynarray-t.cc
 3847 Ashish Agarwal	2012-02-07
      BUG#11748748: Failing testcase on mysql-trunk. Patch to correct it.

    modified:
      storage/archive/ha_archive.cc
 3846 Guilhem Bichot	2012-02-07
      Fix for Bug #13595212 	EXTRA ROWS RETURNED ON RIGHT JOIN WITH VIEW AND IN-SUBQUERY IN WHERE:
      LEFT JOIN was wrongly converted to inner join because table maps were
      used incorrectly.
     @ mysql-test/r/subquery_all.result
        without the code fix, the last two SELECTs would return only 'j'.
     @ sql/item.h
        Scenario of the bug follows.
        Query is:
        SELECT alias2.col_varchar_nokey
        FROM t1 AS alias2
          LEFT JOIN view_D AS alias1 ON 1
        WHERE alias2.col_varchar_key IN (
          SELECT SQ2_alias1.col_varchar_nokey
          FROM view_D AS SQ2_alias1
            LEFT JOIN t1 AS SQ2_alias2
            ON (SQ2_alias2.col_int_key = SQ2_alias1.pk)
          WHERE SQ2_alias1.pk != alias1.col_int_key
            AND SQ2_alias1.col_varchar_key > alias1.col_varchar_key
        ) /* LEFT JOIN variant */;
        We merge the view. Then the subquery's LEFT JOIN is wrongly
        converted to inner join, leading to a wrong result.
        
        Why this conversion?
        
        simplify_joins() analyzes this subquery's LEFT JOIN,
        looks at its WHERE, for example at this piece of WHERE:
        "SQ2_alias1.pk != alias1.col_int_key".
        not_null_tables() is called on the left and right
        members of the "!=" (Item_func_ne)
        (not_null_tables() is defined as a map: if a table is
        in this map and has a NULL row then the item is surely
        false/unknown and thus the WHERE won't be satisfied)
        
        The left member is Item_field for SQL2_alias1.pk, i.e.
        a column of a table in the subquery's FROM clause;
        if it's NULL, the WHERE will be false; so
        not_null_tables() should return the map of "SQ2_alias1";
        and that's what it does, in this code:
        table_map Item_field::used_tables() const
        {
          if (field->table->const_table)
            return 0;					// const item
          return (depended_from ? OUTER_REF_TABLE_BIT : field->table->map);
        }
        
        The right member is, due to view merging, an Item_direct_view_ref
        wrapping an Item_field for alias1.col_int_key; the Item_direct_view_ref
        has 'depended_from'!=NULL (it belongs to a table which is "external
        to the subquery": "alias1"). But the Item_field has depended_from==NULL.
        Item_direct_view_ref::not_null_tables() is
        Item_ref::not_null_tables(), and this function calls
        not_null_tables() on the wrapped (a.k.a. "referenced")
        Item_field; and Item_field::not_null_tables() (see code copied above)
        returns the map of alias1.col_int_key because Item_field::depended_from
        is NULL.
        Returning this map is wrong: "alias1" is outside of the subquery's
        JOIN; OUTER_REF_TABLE_BIT should have been returned.
        Returning the map of alias1 confuses the code in simplify_joins(),
        which, in this test:
            if (!table->outer_join || (used_tables & not_null_tables))
        ends up comparing subquery's maps (used_tables)
        with outer query's maps (not_null_tables)! As "alias1"
        (in the outer JOIN) and "SQ2_alias2" (in the subquery) happen
        to have the same map (maps are unique *only inside the same JOIN*),
        simplify_joins() works as if the subquery's WHERE had
        SQ2_alias1.pk != SQ2_alias2.col_int_key
        and, "logically", concludes that a NULL-complemented row
        of SQ2_alias2 cannot match this, so the LEFT JOIN can be changed to an
        inner join.
        The fix is to make Item_ref::not_null_tables() work like
        its twin Item_ref::used_tables() already does (since 2004): test
        the Item_ref's depended_from too.
        
        Why did this bug happen for LEFT JOIN, and not with RIGHT JOIN?
        Maps are assigned based on the order in TABLE_LIST, and this order
        is the "parse order". Thus, with RIGHT JOIN, alias1 didn't have the
        same map as SQ2_alias2, thus the outer join was not converted;
        but it was pure luck.
        Same when the SELECT RIGHT JOIN was wrapped into a view: during parsing
        we convert RIGHT JOIN to LEFT JOIN (in the JOIN's FROM clause,
        not in TABLE_LIST) and write LEFT JOIN to the view's definition
        file, hitting the "LEFT JOIN" case.

    modified:
      mysql-test/include/subquery.inc
      mysql-test/r/subquery_all.result
      mysql-test/r/subquery_all_bka.result
      mysql-test/r/subquery_all_bka_nixbnl.result
      mysql-test/r/subquery_nomat_nosj.result
      mysql-test/r/subquery_nomat_nosj_bka.result
      mysql-test/r/subquery_nomat_nosj_bka_nixbnl.result
      mysql-test/r/subquery_none.result
      mysql-test/r/subquery_none_bka.result
      mysql-test/r/subquery_none_bka_nixbnl.result
      sql/item.h
 3845 Roy Lyseng	2012-02-07
      Bug #11829691: Pure virtual method called in Item_bool_func2::fix...()
      
      Added a test that used to crash the server.
      
      mysql-test/include/subquery.inc
        New test case for bug#11829691.
      
      mysql-test/r/subquery_all.result
      mysql-test/r/subquery_all_bka.result
      mysql-test/r/subquery_all_bka_nixbnl.result
      mysql-test/r/subquery_nomat_nosj.result
      mysql-test/r/subquery_nomat_nosj_bka.result
      mysql-test/r/subquery_nomat_nosj_bka_nixbnl.result
      mysql-test/r/subquery_none.result
      mysql-test/r/subquery_none_bka.result
      mysql-test/r/subquery_none_bka_nixbnl.result
        New test case results for bug#11829691.

    modified:
      mysql-test/include/subquery.inc
      mysql-test/r/subquery_all.result
      mysql-test/r/subquery_all_bka.result
      mysql-test/r/subquery_all_bka_nixbnl.result
      mysql-test/r/subquery_nomat_nosj.result
      mysql-test/r/subquery_nomat_nosj_bka.result
      mysql-test/r/subquery_nomat_nosj_bka_nixbnl.result
      mysql-test/r/subquery_none.result
      mysql-test/r/subquery_none_bka.result
      mysql-test/r/subquery_none_bka_nixbnl.result
 3844 Norvald H. Ryeng	2012-02-06
      Bug#13464334 SAME QUERY PRODUCES DIFFERENT RESULTS WHEN USED WITH AND
      WITHOUT UNION ALL
      
      Problem: Some outer join queries using views as inner tables do not
      evaluate conditions correctly.
      
      Inner tables of outer joins are tagged by setting the outer_join flag
      in the TABLE_LIST structure for the table. However, if the inner table
      is a view, the tables of the view are not tagged unless they are inner
      tables of a view defined as an outer join query. This means that
      tables referenced by views should some times be treated as inner
      tables of an outer join even if they are not tagged as such.
      
      In JOIN::optimize(), calls to list_contains_unique_index(), are used
      to check if GROUP BY or DISTINCT can be skipped. The function checks
      that enough columns to make it a unique key are mentioned and that
      none of the columns can return NULL. The check for NULL fails since it
      only checks the outer_join flag, which may not be set because of view
      usage. The result is the erroneous conclusion that GROUP BY or
      DISTINCT can be skipped, which in the end causes the query to return
      too many or too few rows.
      
      Fix: In list_contains_unique_index(), check if the table in question
      is in the inner part of an outer join (directly or nested) and
      therefore may return NULL values.
      
      This patch also adds checks for nested outer joins in
      Item_field::is_outer_field() and internal_remove_eq_conds().
     @ mysql-test/r/group_by.result
        Fix erroneous result.
     @ mysql-test/r/join_outer.result
        Add test case for bug #13464334.
     @ mysql-test/r/join_outer_bka.result
        Add test case for bug #13464334.
     @ mysql-test/r/join_outer_bka_nixbnl.result
        Add test case for bug #13464334.
     @ mysql-test/t/join_outer.test
        Add test case for bug #13464334.
     @ sql/item.h
        Include nested outer joins in check for outer join.
     @ sql/sql_optimizer.cc
        Include nested outer joins in checks for outer join.

    modified:
      mysql-test/r/group_by.result
      mysql-test/r/join_outer.result
      mysql-test/r/join_outer_bka.result
      mysql-test/r/join_outer_bka_nixbnl.result
      mysql-test/t/join_outer.test
      sql/item.h
      sql/sql_optimizer.cc
 3843 Vasil Dimov	2012-02-06 [merge]
      Merge mysql-5.5 -> mysql-trunk

    added:
      mysql-test/suite/innodb/r/innodb_bug11754376.result
      mysql-test/suite/innodb/t/innodb_bug11754376.test
    modified:
      storage/innobase/handler/ha_innodb.cc
 3842 Ashish Agarwal	2012-02-05 [merge]
      BUG#11754145: Merge from mysql-5.5 to mysql-trunk

    modified:
      mysql-test/include/have_64bit.inc
 3841 Nuno Carvalho	2012-02-03
      BUG#11758581 - 50801: CHANGE MASTER ACCEPTS BOGUS VARIABLES
            
      CHANGE MASTER command did not check invalid characters on its
      parameters. Also on server restart, invalid values were trimmed causing
      the loss of part of the variables value.
      
      Ensure that servers have a clean state before bogus variables tests.

    modified:
      mysql-test/suite/rpl/r/rpl_change_master.result
      mysql-test/suite/rpl/t/rpl_change_master.test
 3840 Nuno Carvalho	2012-02-03
      BUG#11758581 - 50801: CHANGE MASTER ACCEPTS BOGUS VARIABLES
      
      CHANGE MASTER command did not check invalid characters on its
      parameters. Also on server restart, invalid values were trimmed causing
      the loss of part of the variables value.
      
      SQL parser was improved to prohibit the use of new line characters on 
      CHANGE MASTER variables, throwing a ER_WRONG_VALUE error when such 
      character is used.

    modified:
      mysql-test/suite/rpl/r/rpl_change_master.result
      mysql-test/suite/rpl/t/rpl_change_master.test
      sql/sql_yacc.yy
 3839 Tor Didriksen	2012-02-03
      All the subquery_sj_xxx tests can get thread stack overrun on solaris

    modified:
      mysql-test/collections/default.experimental
 3838 Ashish Agarwal	2012-02-03
      BUG#11748748 - 37280: CHECK AND REPAIR TABLE REPORT TABLE
                            CORRUPTED WHEN RUN CONCURRENTLY WITH
      
      ISSUE: Concurrent queries in archive causes table
             corruption. Running repair and check query
             concurrently with insert query causes table
             corruption. Improper locking.
      
      SOLUTION: Locks are properly aquired.
                Initial lock is aquired and number of
                rows are remembered. Inserting
                remembered rows to new file. Locks
                are again aquired to process the
                remaining rows. Concurrent optimization
                on a same table not allowed.

    modified:
      storage/archive/ha_archive.cc
      storage/archive/ha_archive.h
 3837 Nuno Carvalho	2012-02-03 [merge]
      Merge from mysql-5.5 to mysql-trunk.
      
      Conflicts:
       mysql-test/collections/default.experimental

    modified:
      mysql-test/collections/default.experimental
 3836 Ashish Agarwal	2012-02-03 [merge]
      BUG#11748748: Null merge from mysql-5.5 to mysql-trunk

 3835 Ashish Agarwal	2012-02-03 [merge]
      BUG#11754145: Merge from mysql-5.5 to mysql-trunk

    modified:
      mysql-test/include/have_32bit.inc
      mysql-test/include/have_64bit.inc
 3834 Jorgen Loland	2012-02-03
      Assertion that selectivity does not increase by adding another 
      scan to a ROR intersect triggers. Temporarily remove it.

    modified:
      sql/opt_range.cc
 3833 Jorgen Loland	2012-02-03
      opt_trace.eq_range_statistics must only be run in debug builds.

    modified:
      mysql-test/suite/opt_trace/t/eq_range_statistics.test
 3832 Jorgen Loland	2012-02-02
      WL#5957 followup: use index statistics in ror_scan_selectivity()
                        as well if the optimizer requests it.
     @ mysql-test/r/eq_range_idx_stat.result
        Add test file for WL#5957
     @ mysql-test/r/mysqld--help-notwin.result
        Better description of eq-range-index-dive-limit
     @ mysql-test/r/mysqld--help-win.result
        Better description of eq-range-index-dive-limit
     @ mysql-test/suite/opt_trace/r/eq_range_statistics.result
        Added more checks that records_in_range is not called
     @ mysql-test/suite/opt_trace/t/eq_range_statistics.test
        Added more checks that records_in_range is not called
     @ mysql-test/t/eq_range_idx_stat.test
        Add test file for WL#5957
     @ sql/handler.cc
        Added DBUG_EXECUTE_IF that crashes server if records_in_range
        is called
     @ sql/opt_range.cc
        Use index statistics in ror_scan_selectivity() if the optimizer
        requests it.
        Added DBUG_EXECUTE_IF that crashes server if records_in_range
        is called
     @ sql/sys_vars.cc
        Better description of eq-range-index-dive-limit

    added:
      mysql-test/r/eq_range_idx_stat.result
      mysql-test/t/eq_range_idx_stat.test
    modified:
      mysql-test/r/mysqld--help-notwin.result
      mysql-test/r/mysqld--help-win.result
      mysql-test/suite/opt_trace/r/eq_range_statistics.result
      mysql-test/suite/opt_trace/t/eq_range_statistics.test
      sql/handler.cc
      sql/opt_range.cc
      sql/sys_vars.cc
 3831 Ashish Agarwal	2012-02-02 [merge]
      BUG#11754145: merge from mysql-5.5 to mysql-trunk

    modified:
      include/myisam.h
      storage/myisam/ha_myisam.cc
      storage/myisam/ha_myisam.h
      storage/myisam/mi_check.c
      storage/myisam/myisamchk.c
      storage/myisam/myisamdef.h
      storage/myisam/sort.c
 3830 Alexander Barkov	2012-02-02
      Post-fix for BUG#13458237.
      Recording correct test results.

    modified:
      mysql-test/suite/engines/funcs/r/date_function.result
 3829 Alexander Barkov	2012-02-02 [merge]
      Merging from mysql-trunk

    modified:
      mysql-test/suite/sys_vars/r/innodb_monitor_disable_basic.result
      mysql-test/suite/sys_vars/r/innodb_monitor_enable_basic.result
      mysql-test/suite/sys_vars/r/innodb_monitor_reset_all_basic.result
      mysql-test/suite/sys_vars/r/innodb_monitor_reset_basic.result
 3828 Alexander Barkov	2012-02-02 [merge]
      Merging from 5.5

    modified:
      mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result
      mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result
 3827 Marko Mäkelä	2012-02-02 [merge]
      Merge mysql-5.5 to mysql-trunk.

    modified:
      mysql-test/suite/innodb/r/innodb-index.result
      mysql-test/suite/innodb/t/innodb-index.test
      storage/innobase/row/row0merge.cc
 3826 Alexander Barkov	2012-02-02
       Bug#13616434 ASSERTION FAILED: NANOSECONDS<  1000000000
      
       Problem:
      
       negative lldiv_t values with zero integer part and non-zero fractional part
       (e.g. -0.1111)  were not detected, so negative fractional part was
       later casted to a big unsigned number, which made the assertion crash.
      
       Fix:
      
       Return error if lld.rem is negative.
      
       modified:
        mysql-test/r/type_temporal_fractional.result
        mysql-test/t/type_temporal_fractional.test
        sql/sql_time.cc 

    modified:
      mysql-test/r/type_temporal_fractional.result
      mysql-test/t/type_temporal_fractional.test
      sql/sql_time.cc
 3825 Marko Mäkelä	2012-02-02
      Fix results after fixing typo in trx_rseg_current_size.

    modified:
      mysql-test/suite/innodb/r/innodb_monitor.result
 3824 Marko Mäkelä	2012-02-02 [merge]
      Merge mysql-5.5 to mysql-trunk.

    modified:
      storage/innobase/btr/btr0btr.cc
      storage/innobase/btr/btr0sea.cc
      storage/innobase/buf/buf0buf.cc
      storage/innobase/buf/buf0dblwr.cc
      storage/innobase/ibuf/ibuf0ibuf.cc
      storage/innobase/include/btr0btr.ic
      storage/innobase/include/buf0buf.h
      storage/innobase/include/page0page.ic
      storage/innobase/lock/lock0lock.cc
      storage/innobase/page/page0cur.cc
      storage/innobase/page/page0page.cc
      storage/innobase/row/row0sel.cc
 3823 Marko Mäkelä	2012-02-02 [merge]
      Merge mysql-5.5 to mysql-trunk.

    modified:
      mysql-test/suite/innodb/t/innodb_bug34300.test
 3822 Jimmy Yang	2012-02-02
      Nonfunctional fix for a typo on a monitor counter name.
      
      Approved by Sunny Bains

    modified:
      storage/innobase/srv/srv0mon.cc
 3821 Ashish Agarwal	2012-02-02 [merge]
      BUG#11756869: Merge from mysql-5.5 to mysql-trunk

    modified:
      mysql-test/r/myisam.result
      mysql-test/t/myisam.test
      storage/myisam/mi_check.c
 3820 Hemant Kumar	2012-02-02
      Adding remaining Engine related tests to daily-trunk run.

    modified:
      mysql-test/collections/default.daily
 3819 Marko Mäkel
    modified:
      storage/innobase/ibuf/ibuf0ibuf.cc
      storage/innobase/include/univ.i
 3818 Ole John Aske	2012-02-01
      Fix for bug#13528826  TEST_IF_CHEAPER_ORDERING(): CALCULATES INCORRECT 'SELECT_LIMIT
      
      An incorrect 'adjusted select_limit' was returned from test_if_cheaper_ordering()
      if no excplicit limit-clause was specified in the query.
      
      This fix detect when a limit-clause was not specified, and returns the
      full 'table_records' when no limit-clause was used.
      
      Furthermore, this fix caused the testcase for bug #12838420 
      to change beyond what was required as a testcase for that bug.
            
      Fixed that by forcing correct query plan for testcase by
      introducing 'USE INDEX' and 'STRAIGHT_JOIN'.
     @ mysql-test/include/icp_tests.inc
        Slightly changed syntax of testcase in order to force required query plan
        for this testcase.
     @ mysql-test/include/order_by.inc
        New testcase for this bug
     @ mysql-test/r/innodb_icp.result
        Result should report the full number of records in table wo/ any limit clause.
        Also slightly changed syntax of testcase in order to force required query plan
        for this testcase.
     @ mysql-test/r/innodb_icp_all.result
        Result should report the full number of records in table wo/ any limit clause.
        Also slightly changed syntax of testcase in order to force required query plan
        for this testcase.
     @ mysql-test/r/innodb_icp_none.result
        Result should report the full number of records in table wo/ any limit clause.
        Also slightly changed syntax of testcase in order to force required query plan
        for this testcase.
     @ mysql-test/r/join_cache_nojb.result
        Result should report the full number of records in table wo/ any limit clause.
     @ mysql-test/r/myisam_icp.result
        Slightly changed syntax of testcase in order to force required query plan
        for this testcase.
     @ mysql-test/r/myisam_icp_all.result
        Slightly changed syntax of testcase in order to force required query plan
        for this testcase.
     @ mysql-test/r/myisam_icp_none.result
        Slightly changed syntax of testcase in order to force required query plan
        for this testcase.
     @ mysql-test/r/order_by_all.result
        Accept result for new testcase
     @ mysql-test/r/order_by_icp_mrr.result
        Accept result for new testcase
     @ mysql-test/r/order_by_none.result
        Accept result for new testcase

    modified:
      mysql-test/include/icp_tests.inc
      mysql-test/include/order_by.inc
      mysql-test/r/innodb_icp.result
      mysql-test/r/innodb_icp_all.result
      mysql-test/r/innodb_icp_none.result
      mysql-test/r/join_cache_nojb.result
      mysql-test/r/myisam_icp.result
      mysql-test/r/myisam_icp_all.result
      mysql-test/r/myisam_icp_none.result
      mysql-test/r/order_by_all.result
      mysql-test/r/order_by_icp_mrr.result
      mysql-test/r/order_by_none.result
      sql/sql_select.cc
 3817 Tor Didriksen	2012-02-01
      All the subquery_sj_xxx tests can get thread stack overrun on solaris

    modified:
      mysql-test/collections/default.experimental
 3816 Tor Didriksen	2012-02-01
      re-enable test for Bug#13536661, but not for embedded

    modified:
      mysql-test/r/optimizer_debug_sync.result
      mysql-test/t/optimizer_debug_sync.test
 3815 Tor Didriksen	2012-02-01
      WL#6159 post-push fix: adding a new directory was not such a good idea

    removed:
      include/byteorder/
    renamed:
      include/byteorder/big_endian.h => include/big_endian.h
      include/byteorder/byte_order_generic.h => include/byte_order_generic.h
      include/byteorder/byte_order_generic_x86.h => include/byte_order_generic_x86.h
      include/byteorder/byte_order_generic_x86_64.h => include/byte_order_generic_x86_64.h
      include/byteorder/little_endian.h => include/little_endian.h
    modified:
      include/CMakeLists.txt
      include/my_byteorder.h
 3814 Hemant Kumar	2012-02-01
      Added engine independent tests to default.daily collection.

    modified:
      mysql-test/collections/default.daily
=== modified file 'include/CMakeLists.txt'
--- a/include/CMakeLists.txt	2012-01-11 09:33:52 +0000
+++ b/include/CMakeLists.txt	2012-02-01 08:31:03 +0000
@@ -56,10 +56,11 @@ SET(HEADERS 
   my_compiler.h
   mysql_com_server.h
   my_byteorder.h
-  byteorder/byte_order_generic_x86.h
-  byteorder/little_endian.h
-  byteorder/byte_order_generic.h
-  byteorder/big_endian.h
+  byte_order_generic.h
+  byte_order_generic_x86.h
+  byte_order_generic_x86_64.h
+  little_endian.h
+  big_endian.h
   ${HEADERS_GEN_CONFIGURE}
 )
 

=== renamed file 'include/byteorder/big_endian.h' => 'include/big_endian.h'
=== renamed file 'include/byteorder/byte_order_generic.h' => 'include/byte_order_generic.h'
=== renamed file 'include/byteorder/byte_order_generic_x86.h' => 'include/byte_order_generic_x86.h'
=== renamed file 'include/byteorder/byte_order_generic_x86_64.h' => 'include/byte_order_generic_x86_64.h'
=== removed directory 'include/byteorder'
=== renamed file 'include/byteorder/little_endian.h' => 'include/little_endian.h'
=== modified file 'include/my_byteorder.h'
--- a/include/my_byteorder.h	2012-01-11 09:33:52 +0000
+++ b/include/my_byteorder.h	2012-02-01 08:31:03 +0000
@@ -33,11 +33,11 @@
 */
 #if defined(__i386__) || defined(_WIN32)
 #define MY_BYTE_ORDER_ARCH_OPTIMIZED
-#include "byteorder/byte_order_generic_x86.h"
+#include "byte_order_generic_x86.h"
 #elif defined(__x86_64__)
-#include "byteorder/byte_order_generic_x86_64.h"
+#include "byte_order_generic_x86_64.h"
 #else
-#include "byteorder/byte_order_generic.h"
+#include "byte_order_generic.h"
 #endif
 
 /*
@@ -46,9 +46,9 @@
   a register) and M a pointer to byte.
 */
 #ifdef WORDS_BIGENDIAN
-#include "byteorder/big_endian.h"
+#include "big_endian.h"
 #else
-#include "byteorder/little_endian.h"
+#include "little_endian.h"
 #endif
 
 #endif /* MY_BYTEORDER_INCLUDED */

=== modified file 'include/my_sys.h'
--- a/include/my_sys.h	2011-11-28 07:13:03 +0000
+++ b/include/my_sys.h	2012-02-07 11:56:30 +0000
@@ -719,6 +719,7 @@ extern int flush_write_cache(RECORD_CACH
 extern void handle_recived_signals(void);
 
 extern sig_handler my_set_alarm_variable(int signo);
+extern my_bool radixsort_is_appliccable(uint n_items, size_t size_of_element);
 extern void my_string_ptr_sort(uchar *base,uint items,size_t size);
 extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
 				  size_t size_of_element,uchar *buffer[]);

=== modified file 'include/myisam.h'
--- a/include/myisam.h	2011-07-04 00:25:46 +0000
+++ b/include/myisam.h	2012-02-02 12:48:48 +0000
@@ -401,14 +401,14 @@ typedef struct st_mi_check_param
   ulonglong max_data_file_length;
   ulonglong keys_in_use;
   ulonglong max_record_length;
+  ulonglong sort_buffer_length;
   my_off_t search_after_block;
   my_off_t new_file_pos,key_file_blocks;
   my_off_t keydata,totaldata,key_blocks,start_check_pos;
   ha_rows total_records,total_deleted;
   ha_checksum record_checksum,glob_crc;
   ulonglong use_buffers;
-  ulong read_buffer_length,write_buffer_length,
-	sort_buffer_length,sort_key_blocks;
+  ulong read_buffer_length, write_buffer_length, sort_key_blocks;
   uint out_flag,warning_printed,error_printed,verbose;
   uint opt_sort_key,total_files,max_level;
   uint testflag, key_cache_block_size;

=== modified file 'mysql-test/collections/default.daily'
--- a/mysql-test/collections/default.daily	2012-02-01 06:03:43 +0000
+++ b/mysql-test/collections/default.daily	2012-02-02 04:38:55 +0000
@@ -33,3 +33,5 @@ perl mysql-test-run.pl --timer --force -
 perl mysql-test-run.pl --timer --force --debug-server --parallel=auto  --comment=eits-rpl-binlog-mixed-tests-myisam-engine-debug --experimental=collections/default.experimental --vardir=var-binlog-mixed-eits-tests-myisam-engine-debug --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam --do-test=rpl --mysqld=--binlog-format=mixed --skip-test-list=collections/disabled-daily.list
 perl mysql-test-run.pl --timer --force --debug-server --parallel=auto --comment=eits-rpl-binlog-row-tests-innodb-engine-debug --experimental=collections/default.experimental --vardir=var-binlog-row-eits-tests-innodb-engine-debug --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --do-test=rpl --mysqld=--binlog-format=row --skip-test-list=collections/disabled-daily.list
 perl mysql-test-run.pl --timer --force --debug-server --parallel=auto --comment=eits-rpl-binlog-mixed-tests-innodb-engine-debug --experimental=collections/default.experimental --vardir=var-binlog-mixed-eits-tests-innodb-engine-debug --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --do-test=rpl --mysqld=--binlog-format=mixed --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --timer --force  --debug-server --parallel=auto  --comment=eits-tests-myisam-engine-debug --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-myisam-engine-debug --suite=engines/iuds,engines/funcs --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam  --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --timer --force --debug-server --parallel=auto --comment=eits-tests-innodb-engine-debug --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-innodb-engine-debug --suite=engines/iuds,engines/funcs  --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --skip-test-list=collections/disabled-daily.list

=== modified file 'mysql-test/collections/default.experimental'
--- a/mysql-test/collections/default.experimental	2012-01-12 13:22:52 +0000
+++ b/mysql-test/collections/default.experimental	2012-02-03 15:16:35 +0000
@@ -9,17 +9,47 @@ main.func_math @freebsd                 
 main.mysqlslap @windows                  # Bug#11761520 2010-08-10 alik mysqlslap fails sporadically starting from Dahlia
 main.signal_demo3 @solaris               # Bug#11753919 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
 main.sp @solaris                         # Bug#11753919 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
-main.subquery_sj_none @solaris           # Bug#11753919 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
-main.subquery_sj_none_bka @solaris       # Bug#11753919 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrunbzr rename 
-main.subquery_sj_none_bkaunique @solaris # Bug#11753919 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
-main.subquery_sj_none_bka_nixbnl @solaris # Bug#11753919 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
+
+main.subquery_sj_all_bka_nixbnl @solaris         # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_all_bka @solaris                # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_all_bkaunique @solaris          # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_all @solaris                    # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_dupsweed_bka_nixbnl @solaris    # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_dupsweed_bka @solaris           # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_dupsweed_bkaunique @solaris     # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_dupsweed @solaris               # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_firstmatch_bka_nixbnl @solaris  # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_firstmatch_bka @solaris         # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_firstmatch_bkaunique @solaris   # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_firstmatch @solaris             # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_innodb_all_bka_nixbnl @solaris  # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_innodb_all_bka @solaris         # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_innodb_all_bkaunique @solaris   # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_innodb_all @solaris             # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_innodb_none_bka_nixbnl @solaris # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_innodb_none_bka @solaris        # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_innodb_none_bkaunique @solaris  # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_innodb_none @solaris            # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_loosescan_bka_nixbnl @solaris   # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_loosescan_bka @solaris          # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_loosescan_bkaunique @solaris    # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_loosescan @solaris              # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_mat_bka_nixbnl @solaris         # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_mat_bka @solaris                # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_mat_bkaunique @solaris          # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_mat_nosj @solaris               # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_mat @solaris                    # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_none_bka_nixbnl @solaris        # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_none_bka @solaris               # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_none_bkaunique @solaris         # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+main.subquery_sj_none @solaris                   # Bug#11753919 2012-02-03 didrik Several test cases fail on Solaris with error Thread stack overrun
+
 main.kill @freebsd                       # Bug#12619719 2011-08-04 Occasional failure in PB2
 
 innodb.innodb_monitor                    # Bug#12320827 2011-08-04 Occasional failure in PB2
 
 rpl.rpl_change_master_dbug               # BUG#11933491 2011-06-13 Anitha  Test fails on redhat 
 rpl.rpl_delayed_slave                    # BUG#11764654 rpl_delayed_slave fails sporadically in pb
-rpl.rpl_heartbeat_basic                  # BUG#12403008 2011-04-27 sven fails sporadically
 rpl.rpl_innodb_bug28430                  # Bug#11754425
 rpl.rpl_row_sp011  @solaris              # Bug#11753919 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
 rpl.rpl_seconds_behind_master            # BUG#11765124 2010-11-24 luis fails sporadically on pb2

=== modified file 'mysql-test/include/have_32bit.inc'
--- a/mysql-test/include/have_32bit.inc	2009-01-08 18:13:57 +0000
+++ b/mysql-test/include/have_32bit.inc	2012-02-03 13:49:32 +0000
@@ -3,10 +3,10 @@
 
 --disable_query_log
 --disable_warnings
-let $save = `SELECT @@global.sort_buffer_size`;
-SET @@global.sort_buffer_size = 4294967296;
-let $mach32 = `SELECT @@global.sort_buffer_size <= 4294967295`;
-eval SET @@global.sort_buffer_size = $save;
+let $save = `SELECT @@global.myisam_sort_buffer_size`;
+SET @@global.myisam_sort_buffer_size = 4294967296;
+let $mach32 = `SELECT @@global.myisam_sort_buffer_size <= 4294967295`;
+eval SET @@global.myisam_sort_buffer_size = $save;
 --enable_warnings
 --enable_query_log
 if (!$mach32)

=== modified file 'mysql-test/include/icp_tests.inc'
--- a/mysql-test/include/icp_tests.inc	2011-10-05 13:16:38 +0000
+++ b/mysql-test/include/icp_tests.inc	2012-02-01 09:59:13 +0000
@@ -1043,7 +1043,7 @@ INSERT INTO t2 VALUES (0,9),(3,10),(4,6)
 
 let $query=
 SELECT t2.col_int_key AS field1
-FROM t2 JOIN t1 ON t2.col_int_key
+FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key
 WHERE t2.pk < 7 AND t2.col_int_key <> 7
 GROUP BY field1;
 

=== modified file 'mysql-test/include/order_by.inc'
--- a/mysql-test/include/order_by.inc	2012-01-25 14:52:00 +0000
+++ b/mysql-test/include/order_by.inc	2012-02-01 09:59:13 +0000
@@ -1781,3 +1781,33 @@ SELECT c FROM t1 WHERE a=2 AND (c=10 OR 
 SELECT c FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c DESC;
 
 DROP TABLE t1;
+
+--echo #
+--echo # Bug #13528826 
+--echo # TEST_IF_CHEAPER_ORDERING(): CALCULATES INCORRECT 'SELECT_LIMIT'
+--echo # 
+--echo #
+
+CREATE TABLE t1(a int PRIMARY KEY, b int) ENGINE=myisam;
+INSERT INTO t1 VALUES
+  (5, 10), (2, 70), (7, 80), (6, 20), (1, 50), (9, 40), (8, 30), (3, 60);
+CREATE TABLE t2 (p int, a int, INDEX i_a(a)) ENGINE=myisam;
+INSERT INTO t2 VALUES
+  (103, 7), (109, 3), (102, 3), (108, 1), (106, 3),
+  (107, 7), (105, 1), (101, 3), (100, 7), (110, 1);
+
+--echo # number of rows in t1 was incorrectly used as an 
+--echo # implicit limit-clause if not explicit specified
+EXPLAIN
+SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a;
+
+--echo # Query above used to be explained identical to this:
+EXPLAIN
+SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 8;
+
+-- echo # A really high limit was required to give the correct explain
+EXPLAIN
+SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 1000;
+
+DROP TABLE t1, t2;
+

=== modified file 'mysql-test/include/subquery.inc'
--- a/mysql-test/include/subquery.inc	2011-09-29 12:47:32 +0000
+++ b/mysql-test/include/subquery.inc	2012-02-07 14:50:31 +0000
@@ -5643,3 +5643,164 @@ WHERE (col_varchar_nokey, 'x') IN
 
 --echo
 DROP TABLE it, ot;
+
+--echo #
+--echo # Bug #11829691: Pure virtual method called in Item_bool_func2::fix...()
+--echo #
+
+CREATE TABLE t1(a INTEGER);
+CREATE TABLE t2(b INTEGER);
+
+PREPARE stmt FROM "
+SELECT SUM(b) FROM t2 GROUP BY b HAVING b IN (SELECT b FROM t1)";
+
+EXECUTE stmt;
+EXECUTE stmt;
+
+DEALLOCATE PREPARE stmt;
+
+DROP TABLE t1, t2;
+
+--echo #
+--echo # Bug #13595212 EXTRA ROWS RETURNED ON RIGHT JOIN WITH VIEW AND
+--echo # IN-SUBQUERY IN WHERE
+--echo #
+
+CREATE TABLE t1 (
+  pk int(11) NOT NULL AUTO_INCREMENT,
+  col_int_key int(11) NOT NULL,
+  col_varchar_key varchar(1) NOT NULL,
+  col_varchar_nokey varchar(1) NOT NULL,
+  PRIMARY KEY (pk),
+  KEY col_int_key (col_int_key),
+  KEY col_varchar_key (col_varchar_key,col_int_key)
+);
+
+INSERT INTO t1 VALUES (1,0,'j','j'),(2,8,'v','v'),
+(3,1,'c','c'),(4,8,'m','m'),(5,9,'d','d');
+
+CREATE VIEW v1 AS SELECT * FROM t1;
+
+# RIGHT JOIN
+
+let $query=
+SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+  RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+  SELECT sq2_alias1.col_varchar_nokey
+  FROM v1 AS sq2_alias1
+    LEFT JOIN t1 AS sq2_alias2
+    ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+  WHERE sq2_alias1.pk != alias1.col_int_key
+    AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+
+eval EXPLAIN EXTENDED $query;
+--sorted_result
+eval $query;
+
+# Same, but in view:
+
+eval CREATE VIEW v2 AS $query;
+
+EXPLAIN EXTENDED SELECT * FROM v2;
+--sorted_result
+SELECT * FROM v2;
+
+# Same, with LEFT JOIN
+
+let $query=SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+  LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+  SELECT sq2_alias1.col_varchar_nokey
+  FROM v1 AS sq2_alias1
+    LEFT JOIN t1 AS sq2_alias2
+    ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+  WHERE sq2_alias1.pk != alias1.col_int_key
+    AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+
+eval EXPLAIN EXTENDED $query;
+--sorted_result
+eval $query;
+
+DROP TABLE t1;
+DROP VIEW v1,v2;
+
+--echo #
+--echo # Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY
+--echo # HAS AN EMPTY RESULT
+--echo #
+
+CREATE TABLE t1 (
+  pk int NOT NULL,
+  col_int_nokey int NOT NULL,
+  col_int_key int NOT NULL,
+  col_time_key time NOT NULL,
+  col_varchar_key varchar(1) NOT NULL,
+  col_varchar_nokey varchar(1) NOT NULL,
+  PRIMARY KEY (pk),
+  KEY col_int_key (col_int_key),
+  KEY col_time_key (col_time_key),
+  KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+
+CREATE TABLE t2 (
+  pk int NOT NULL AUTO_INCREMENT,
+  col_int_nokey int NOT NULL,
+  col_int_key int NOT NULL,
+  col_time_key time NOT NULL,
+  col_varchar_key varchar(1) NOT NULL,
+  col_varchar_nokey varchar(1) NOT NULL,
+  PRIMARY KEY (pk),
+  KEY col_int_key (col_int_key),
+  KEY col_time_key (col_time_key),
+  KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+
+INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b');
+
+SET @var2:=4, @var3:=8;
+
+--echo
+--echo Testcase without inner subquery
+
+let $subq=
+SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+      sq4_alias1.col_varchar_key = @var3;
+
+eval EXPLAIN $subq;
+eval $subq;
+SELECT @var3;
+
+# Now as derived table:
+eval EXPLAIN SELECT * FROM ( $subq ) AS alias3;
+eval SELECT * FROM ( $subq ) AS alias3;
+SELECT @var3;
+
+--echo
+--echo Testcase with inner subquery; crashed WL#6095
+SET @var3=8;
+let $subq=
+SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+      NOT IN
+      (SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+              c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+       FROM t2 AS c_sq1_alias1
+       WHERE (c_sq1_alias1.col_int_nokey != @var2
+              OR c_sq1_alias1.pk != @var3));
+
+eval EXPLAIN $subq;
+eval $subq;
+# Now as derived table:
+eval EXPLAIN SELECT * FROM ( $subq ) AS alias3;
+eval SELECT * FROM ( $subq ) AS alias3;
+
+DROP TABLE t1,t2;

=== modified file 'mysql-test/r/ctype_many.result'
--- a/mysql-test/r/ctype_many.result	2012-01-16 09:01:53 +0000
+++ b/mysql-test/r/ctype_many.result	2012-02-07 11:56:30 +0000
@@ -753,10 +753,10 @@ lower(utf8_f)
 �
 �
 �
-�
 �
 �
 �
+�
 �
 esult'
--- a/mysql-test/r/eq_range_idx_stat.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/eq_range_idx_stat.result	2012-02-02 16:56:36 +0000
@@ -0,0 +1,125 @@
+SET eq_range_index_dive_limit=default;
+SELECT @@eq_range_index_dive_limit;
+@@eq_range_index_dive_limit
+10
+CREATE TABLE t1
+(
+/* Field names reflect value(rowid) distribution, st=STairs, swt= SaWTooth */
+st_a int,
+swt1a int,
+swt2a int,
+st_b int,
+swt1b int,
+swt2b int,
+key sta_swt12a(st_a,swt1a,swt2a),
+key sta_swt1a(st_a,swt1a),
+key sta_swt2a(st_a,swt2a),
+key sta_swt21a(st_a,swt2a,swt1a),
+key st_a(st_a),
+key stb_swt1a_2b(st_b,swt1b,swt2a),
+key stb_swt1b(st_b,swt1b),
+key st_b(st_b)
+) ;
+ALTER TABLE t1 DISABLE KEYS;
+#
+# Printing of many insert into t1 disabled.
+#
+ALTER TABLE t1 ENABLE KEYS;
+ANALYZE TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	status	Table is already up to date
+#
+# Run index_merge queries two times: 1) with index dives
+#                                    2) with index statistics
+#
+
+explain 
+select * from t1 
+where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1 limit 5;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index_merge	sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b	sta_swt12a,stb_swt1a_2b	15,15	NULL	3	Using intersect(sta_swt12a,stb_swt1a_2b); Using where
+select * from t1 
+where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1 limit 5;
+st_a	swt1a	swt2a	st_b	swt1b	swt2b
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+
+explain 
+select * from t1
+where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 limit 5;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index_merge	sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b	sta_swt12a,stb_swt1a_2b	15,15	NULL	3	Using intersect(sta_swt12a,stb_swt1a_2b); Using where
+select * from t1
+where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 limit 5;
+st_a	swt1a	swt2a	st_b	swt1b	swt2b
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+
+explain 
+select * from t1
+where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1 limit 5;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b	sta_swt12a	10	const,const	89	Using where
+select * from t1
+where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1 limit 5;
+st_a	swt1a	swt2a	st_b	swt1b	swt2b
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+
+SET eq_range_index_dive_limit=1;
+SET SESSION DEBUG="+d,crash_records_in_range";
+
+explain 
+select * from t1 
+where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1 limit 5;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index_merge	sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b	sta_swt12a,stb_swt1a_2b	15,15	NULL	3	Using intersect(sta_swt12a,stb_swt1a_2b); Using where
+select * from t1 
+where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1 limit 5;
+st_a	swt1a	swt2a	st_b	swt1b	swt2b
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+
+explain 
+select * from t1
+where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 limit 5;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index_merge	sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b	sta_swt12a,stb_swt1a_2b	15,15	NULL	3	Using intersect(sta_swt12a,stb_swt1a_2b); Using where
+select * from t1
+where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 limit 5;
+st_a	swt1a	swt2a	st_b	swt1b	swt2b
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+
+explain 
+select * from t1
+where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1 limit 5;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b	sta_swt12a	10	const,const	90	Using where
+select * from t1
+where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1 limit 5;
+st_a	swt1a	swt2a	st_b	swt1b	swt2b
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+1	1	1	1	1	1
+
+SET eq_range_index_dive_limit=1;
+SET SESSION DEBUG="+d,crash_records_in_range";
+DROP TABLE t1;

=== modified file 'mysql-test/r/group_by.result'
--- a/mysql-test/r/group_by.result	2012-01-30 13:57:08 +0000
+++ b/mysql-test/r/group_by.result	2012-02-06 12:47:30 +0000
@@ -2110,6 +2110,7 @@ SELECT v1.pk
 FROM t1 LEFT JOIN v1 ON t1.i = v1.pk 
 GROUP BY v1.pk;
 pk
+NULL
 DROP VIEW v1;
 DROP TABLE t1,t2;
 # End of Bug#12798270

=== modified file 'mysql-test/r/innodb_icp.result'
--- a/mysql-test/r/innodb_icp.result	2012-01-25 12:45:56 +0000
+++ b/mysql-test/r/innodb_icp.result	2012-02-01 09:59:13 +0000
@@ -988,14 +988,14 @@ INSERT INTO t2 VALUES (0,9),(3,10),(4,6)
 set @old_opt_switch=@@optimizer_switch;
 SET optimizer_switch="block_nested_loop=off";
 EXPLAIN SELECT t2.col_int_key AS field1
-FROM t2 JOIN t1 ON t2.col_int_key
+FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key
 WHERE t2.pk < 7 AND t2.col_int_key <> 7
 GROUP BY field1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	range	PRIMARY,col_int_key	col_int_key	5	NULL	5	Using where; Using index
+1	SIMPLE	t2	range	col_int_key	col_int_key	5	NULL	5	Using where; Using index
 1	SIMPLE	t1	index	NULL	col_int_key	5	NULL	4	Using index
 SELECT t2.col_int_key AS field1
-FROM t2 JOIN t1 ON t2.col_int_key
+FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key
 WHERE t2.pk < 7 AND t2.col_int_key <> 7
 GROUP BY field1;
 field1

=== modified file 'mysql-test/r/innodb_icp_all.result'
--- a/mysql-test/r/innodb_icp_all.result	2012-01-30 13:08:34 +0000
+++ b/mysql-test/r/innodb_icp_all.result	2012-02-01 09:59:13 +0000
@@ -988,14 +988,14 @@ INSERT INTO t2 VALUES (0,9),(3,10),(4,6)
 set @old_opt_switch=@@optimizer_switch;
 SET optimizer_switch="block_nested_loop=off";
 EXPLAIN SELECT t2.col_int_key AS field1
-FROM t2 JOIN t1 ON t2.col_int_key
+FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key
 WHERE t2.pk < 7 AND t2.col_int_key <> 7
 GROUP BY field1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	range	PRIMARY,col_int_key	col_int_key	5	NULL	5	Using where; Using index
+1	SIMPLE	t2	range	col_int_key	col_int_key	5	NULL	5	Using where; Using index
 1	SIMPLE	t1	index	NULL	col_int_key	5	NULL	4	Using index
 SELECT t2.col_int_key AS field1
-FROM t2 JOIN t1 ON t2.col_int_key
+FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key
 WHERE t2.pk < 7 AND t2.col_int_key <> 7
 GROUP BY field1;
 field1

=== modified file 'mysql-test/r/innodb_icp_none.result'
--- a/mysql-test/r/innodb_icp_none.result	2012-01-25 12:45:56 +0000
+++ b/mysql-test/r/innodb_icp_none.result	2012-02-01 09:59:13 +0000
@@ -987,14 +987,14 @@ INSERT INTO t2 VALUES (0,9),(3,10),(4,6)
 set @old_opt_switch=@@optimizer_switch;
 SET optimizer_switch="block_nested_loop=off";
 EXPLAIN SELECT t2.col_int_key AS field1
-FROM t2 JOIN t1 ON t2.col_int_key
+FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key
 WHERE t2.pk < 7 AND t2.col_int_key <> 7
 GROUP BY field1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	range	PRIMARY,col_int_key	col_int_key	5	NULL	5	Using where; Using index
+1	SIMPLE	t2	range	col_int_key	col_int_key	5	NULL	5	Using where; Using index
 1	SIMPLE	t1	index	NULL	col_int_key	5	NULL	4	Using index
 SELECT t2.col_int_key AS field1
-FROM t2 JOIN t1 ON t2.col_int_key
+FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key
 WHERE t2.pk < 7 AND t2.col_int_key <> 7
 GROUP BY field1;
 field1

=== modified file 'mysql-test/r/innodb_mysql_sync.result'
--- a/mysql-test/r/innodb_mysql_sync.result	2011-06-01 12:24:51 +0000
+++ b/mysql-test/r/innodb_mysql_sync.result	2012-02-08 13:10:23 +0000
@@ -186,3 +186,29 @@ a	b
 1	12345
 2	23456
 DROP TABLE t1;
+#
+# Bug#13417754 ASSERT IN ROW_DROP_DATABASE_FOR_MYSQL DURING DROP SCHEMA
+#
+DROP TABLE IF EXISTS t1;
+DROP DATABASE IF EXISTS db1;
+CREATE TABLE t1(a int) engine=InnoDB;
+CREATE DATABASE db1;
+# Connection con1
+SET DEBUG_SYNC= 'after_innobase_rename_table SIGNAL locked WAIT_FOR continue';
+# Sending:
+ALTER TABLE t1 RENAME db1.t1;
+# Connection con2
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+# DROP DATABASE db1 should now be blocked by ALTER TABLE
+# Sending:
+DROP DATABASE db1;
+# Connection default
+# Check that DROP DATABASE is blocked by IX lock on db1
+# Resume ALTER TABLE
+SET DEBUG_SYNC= 'now SIGNAL continue';
+# Connection con1
+# Reaping: ALTER TABLE t1 RENAME db1.t1;
+# Connection con2
+# Reaping: DROP DATABASE db1
+# Connection default;
+SET DEBUG_SYNC= 'RESET';

=== modified file 'mysql-test/r/join_cache_nojb.result'
--- a/mysql-test/r/join_cache_nojb.result	2012-01-30 13:13:15 +0000
+++ b/mysql-test/r/join_cache_nojb.result	2012-02-01 09:59:13 +0000
@@ -1445,7 +1445,7 @@ explain
 select t1.a, count(t2.p) as count
 from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	4	Using index
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	8	Using index
 1	SIMPLE	t2	ref	i_a	i_a	5	test.t1.a	2	Using where
 select t1.a, count(t2.p) as count
 from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a;

=== modified file 'mysql-test/r/join_outer.result'
--- a/mysql-test/r/join_outer.result	2012-01-03 11:04:14 +0000
+++ b/mysql-test/r/join_outer.result	2012-02-06 12:47:30 +0000
@@ -1996,3 +1996,19 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t6b	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 drop table t1,t2,t3,t4,t5,t6;
+#
+# Bug#13464334 SAME QUERY PRODUCES DIFFERENT RESULTS WHEN USED WITH AND
+# WITHOUT UNION ALL
+#
+CREATE TABLE t1 (p1 INT PRIMARY KEY, a CHAR(1));
+CREATE TABLE t2 (p2 INT PRIMARY KEY, b CHAR(1));
+INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
+INSERT INTO t2 VALUES (1,'h'),(2,'i'),(3,'j'),(4,'k');
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE VIEW v2 AS SELECT * FROM t2;
+(SELECT p1 FROM v2 LEFT JOIN v1 ON b = a WHERE p2 = 1 GROUP BY p1 ORDER BY p1)
+UNION (SELECT NULL LIMIT 0);
+p1
+NULL
+DROP VIEW v1, v2;
+DROP TABLE t1, t2;

=== modified file 'mysql-test/r/join_outer_bka.result'
--- a/mysql-test/r/join_outer_bka.result	2012-01-03 11:04:14 +0000
+++ b/mysql-test/r/join_outer_bka.result	2012-02-06 12:47:30 +0000
@@ -1997,4 +1997,20 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t6b	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 drop table t1,t2,t3,t4,t5,t6;
+#
+# Bug#13464334 SAME QUERY PRODUCES DIFFERENT RESULTS WHEN USED WITH AND
+# WITHOUT UNION ALL
+#
+CREATE TABLE t1 (p1 INT PRIMARY KEY, a CHAR(1));
+CREATE TABLE t2 (p2 INT PRIMARY KEY, b CHAR(1));
+INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
+INSERT INTO t2 VALUES (1,'h'),(2,'i'),(3,'j'),(4,'k');
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE VIEW v2 AS SELECT * FROM t2;
+(SELECT p1 FROM v2 LEFT JOIN v1 ON b = a WHERE p2 = 1 GROUP BY p1 ORDER BY p1)
+UNION (SELECT NULL LIMIT 0);
+p1
+NULL
+DROP VIEW v1, v2;
+DROP TABLE t1, t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/join_outer_bka_nixbnl.result'
--- a/mysql-test/r/join_outer_bka_nixbnl.result	2012-01-03 11:04:14 +0000
+++ b/mysql-test/r/join_outer_bka_nixbnl.result	2012-02-06 12:47:30 +0000
@@ -1997,4 +1997,20 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t6b	ALL	NULL	NULL	NULL	NULL	1	Using where
 drop table t1,t2,t3,t4,t5,t6;
+#
+# Bug#13464334 SAME QUERY PRODUCES DIFFERENT RESULTS WHEN USED WITH AND
+# WITHOUT UNION ALL
+#
+CREATE TABLE t1 (p1 INT PRIMARY KEY, a CHAR(1));
+CREATE TABLE t2 (p2 INT PRIMARY KEY, b CHAR(1));
+INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
+INSERT INTO t2 VALUES (1,'h'),(2,'i'),(3,'j'),(4,'k');
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE VIEW v2 AS SELECT * FROM t2;
+(SELECT p1 FROM v2 LEFT JOIN v1 ON b = a WHERE p2 = 1 GROUP BY p1 ORDER BY p1)
+UNION (SELECT NULL LIMIT 0);
+p1
+NULL
+DROP VIEW v1, v2;
+DROP TABLE t1, t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/mix2_myisam.result'
--- a/mysql-test/r/mix2_myisam.result	2010-12-06 13:12:51 +0000
+++ b/mysql-test/r/mix2_myisam.result	2012-02-07 11:56:30 +0000
@@ -1611,15 +1611,15 @@ i	10
 select sql_big_result v,count(c) from t1 group by v limit 10;
 v	count(c)
 a	1
-a 	10
-b     	10
-c    	10
-d   	10
-e  	10
-f     	10
-g    	10
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
 h	10
-i     	10
+i	10
 select c,count(*) from t1 group by c limit 10;
 c	count(*)
 a	1

=== modified file 'mysql-test/r/myisam.result'
--- a/mysql-test/r/myisam.result	2011-10-21 05:42:01 +0000
+++ b/mysql-test/r/myisam.result	2012-02-07 11:56:30 +0000
@@ -1286,15 +1286,15 @@ i	10
 select sql_big_result v,count(c) from t1 group by v limit 10;
 v	count(c)
 a	1
-a 	10
-b     	10
-c    	10
-d   	10
-e  	10
-f     	10
-g    	10
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
 h	10
-i     	10
+i	10
 select c,count(*) from t1 group by c limit 10;
 c	count(*)
 a	1
@@ -2442,6 +2442,19 @@ Table	Op	Msg_type	Msg_text
 test.t1	check	status	OK
 DROP TABLE t1;
 SET GLOBAL myisam_use_mmap=default;
+#
+# BUG 11756869 - 48848: MYISAMCHK DOING SORT RECOVER IN CERTAIN
+#                       CASES RESETS DATA POINTER TO SMAL
+#
+CREATE TABLE t1(a INT, KEY(a));
+ALTER TABLE t1 DISABLE KEYS;
+SET @before:= (SELECT MAX_DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test');
+FLUSH TABLES;
+SET @after:= (SELECT MAX_DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test');
+SELECT @before=@after;
+@before=@after
+1
+DROP TABLE t1;
 End of 5.1 tests
 #
 # Bug#43600: Incorrect type conversion caused wrong result.

=== modified file 'mysql-test/r/myisam_icp.result'
--- a/mysql-test/r/myisam_icp.result	2012-01-03 11:04:14 +0000
+++ b/mysql-test/r/myisam_icp.result	2012-02-01 09:59:13 +0000
@@ -983,14 +983,14 @@ INSERT INTO t2 VALUES (0,9),(3,10),(4,6)
 set @old_opt_switch=@@optimizer_switch;
 SET optimizer_switch="block_nested_loop=off";
 EXPLAIN SELECT t2.col_int_key AS field1
-FROM t2 JOIN t1 ON t2.col_int_key
+FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key
 WHERE t2.pk < 7 AND t2.col_int_key <> 7
 GROUP BY field1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	4	Using index; Using temporary; Using filesort
-1	SIMPLE	t2	ALL	PRIMARY,col_int_key	NULL	NULL	NULL	6	Using where
+1	SIMPLE	t2	ALL	col_int_key	NULL	NULL	NULL	6	Using where; Using temporary; Using filesort
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	4	Using index
 SELECT t2.col_int_key AS field1
-FROM t2 JOIN t1 ON t2.col_int_key
+FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key
 WHERE t2.pk < 7 AND t2.col_int_key <> 7
 GROUP BY field1;
 field1

=== modified file 'mysql-test/r/myisam_icp_all.result'
--- a/mysql-test/r/myisam_icp_all.result	2012-01-03 11:04:14 +0000
+++ b/mysql-test/r/myisam_icp_all.result	2012-02-01 09:59:13 +0000
@@ -983,14 +983,14 @@ INSERT INTO t2 VALUES (0,9),(3,10),(4,6)
 set @old_opt_switch=@@optimizer_switch;
 SET optimizer_switch="block_nested_loop=off";
 EXPLAIN SELECT t2.col_int_key AS field1
-FROM t2 JOIN t1 ON t2.col_int_key
+FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key
 WHERE t2.pk < 7 AND t2.col_int_key <> 7
 GROUP BY field1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	4	Using index; Using temporary; Using filesort
-1	SIMPLE	t2	ALL	PRIMARY,col_int_key	NULL	NULL	NULL	6	Using where
+1	SIMPLE	t2	ALL	col_int_key	NULL	NULL	NULL	6	Using where; Using temporary; Using filesort
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	4	Using index
 SELECT t2.col_int_key AS field1
-FROM t2 JOIN t1 ON t2.col_int_key
+FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key
 WHERE t2.pk < 7 AND t2.col_int_key <> 7
 GROUP BY field1;
 field1

=== modified file 'mysql-test/r/myisam_icp_none.result'
--- a/mysql-test/r/myisam_icp_none.result	2012-01-03 11:04:14 +0000
+++ b/mysql-test/r/myisam_icp_none.result	2012-02-01 09:59:13 +0000
@@ -982,14 +982,14 @@ INSERT INTO t2 VALUES (0,9),(3,10),(4,6)
 set @old_opt_switch=@@optimizer_switch;
 SET optimizer_switch="block_nested_loop=off";
 EXPLAIN SELECT t2.col_int_key AS field1
-FROM t2 JOIN t1 ON t2.col_int_key
+FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key
 WHERE t2.pk < 7 AND t2.col_int_key <> 7
 GROUP BY field1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	4	Using index; Using temporary; Using filesort
-1	SIMPLE	t2	ALL	PRIMARY,col_int_key	NULL	NULL	NULL	6	Using where
+1	SIMPLE	t2	ALL	col_int_key	NULL	NULL	NULL	6	Using where; Using temporary; Using filesort
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	4	Using index
 SELECT t2.col_int_key AS field1
-FROM t2 JOIN t1 ON t2.col_int_key
+FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key
 WHERE t2.pk < 7 AND t2.col_int_key <> 7
 GROUP BY field1;
 field1

=== modified file 'mysql-test/r/mysqld--help-notwin.result'
--- a/mysql-test/r/mysqld--help-notwin.result	2012-01-31 10:40:02 +0000
+++ b/mysql-test/r/mysqld--help-notwin.result	2012-02-02 16:56:36 +0000
@@ -154,7 +154,8 @@ The following options may be given as th
  --eq-range-index-dive-limit=# 
  The optimizer will use existing index statistics instead
  of doing index dives for equality ranges if the number of
- equality ranges is larger than or equal to this number.
+ equality ranges for the index is larger than or equal to
+ this number.
  --event-scheduler[=name] 
  Enable the event scheduler. Possible values are ON, OFF,
  and DISABLED (keep the event scheduler completely

=== modified file 'mysql-test/r/mysqld--help-win.result'
--- a/mysql-test/r/mysqld--help-win.result	2012-01-31 10:40:02 +0000
+++ b/mysql-test/r/mysqld--help-win.result	2012-02-02 16:56:36 +0000
@@ -154,7 +154,8 @@ The following options may be given as th
  --eq-range-index-dive-limit=# 
  The optimizer will use existing index statistics instead
  of doing index dives for equality ranges if the number of
- equality ranges is larger than or equal to this number.
+ equality ranges for the index is larger than or equal to
+ this number.
  --event-scheduler[=name] 
  Enable the event scheduler. Possible values are ON, OFF,
  and DISABLED (keep the event scheduler completely

=== modified file 'mysql-test/r/optimizer_debug_sync.result'
--- a/mysql-test/r/optimizer_debug_sync.result	2012-01-31 06:42:46 +0000
+++ b/mysql-test/r/optimizer_debug_sync.result	2012-02-01 08:32:05 +0000
@@ -21,3 +21,21 @@ MAX(i)
 MAX(i)
 2
 DROP TABLE t;
+# End of BUG#56080
+#
+# Bug #13536661: VALGRIND: DEFINITELY LOST: 552 BYTES IN 1 BLOCKS IN
+# CREATE_TMP_TABLE AND HIGHER
+#
+CREATE TABLE t1 ( a INT, b INT );
+INSERT INTO t1 VALUES (4, 40), (1, 10), (2, 20), (2, 20), (3, 30);
+SET debug_sync = "tmp_table_created SIGNAL parked WAIT_FOR go";
+# This should not leak memory.
+SELECT b, COUNT(DISTINCT b) FROM t1 GROUP BY b ORDER BY -b;
+SET debug_sync = "now WAIT_FOR parked";
+# Set locally to shadow the global variable.
+SET debug = '';
+SET GLOBAL debug = '+d,simulate_out_of_memory';
+SET debug_sync = "now SIGNAL go";
+ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
+SET GLOBAL debug = '';
+DROP TABLE t1;

=== modified file 'mysql-test/r/order_by_all.result'
--- a/mysql-test/r/order_by_all.result	2012-01-30 13:08:34 +0000
+++ b/mysql-test/r/order_by_all.result	2012-02-01 09:59:13 +0000
@@ -2639,4 +2639,36 @@ c
 10
 NULL
 DROP TABLE t1;
+#
+# Bug #13528826 
+# TEST_IF_CHEAPER_ORDERING(): CALCULATES INCORRECT 'SELECT_LIMIT'
+# 
+#
+CREATE TABLE t1(a int PRIMARY KEY, b int) ENGINE=myisam;
+INSERT INTO t1 VALUES
+(5, 10), (2, 70), (7, 80), (6, 20), (1, 50), (9, 40), (8, 30), (3, 60);
+CREATE TABLE t2 (p int, a int, INDEX i_a(a)) ENGINE=myisam;
+INSERT INTO t2 VALUES
+(103, 7), (109, 3), (102, 3), (108, 1), (106, 3),
+(107, 7), (105, 1), (101, 3), (100, 7), (110, 1);
+# number of rows in t1 was incorrectly used as an 
+# implicit limit-clause if not explicit specified
+EXPLAIN
+SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	8	Using index
+1	SIMPLE	t2	ref	i_a	i_a	5	test.t1.a	2	Using index
+# Query above used to be explained identical to this:
+EXPLAIN
+SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 8;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	4	Using index
+1	SIMPLE	t2	ref	i_a	i_a	5	test.t1.a	2	Using index
+# A really high limit was required to give the correct explain
+EXPLAIN
+SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 1000;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	8	Using index
+1	SIMPLE	t2	ref	i_a	i_a	5	test.t1.a	2	Using index
+DROP TABLE t1, t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/order_by_icp_mrr.result'
--- a/mysql-test/r/order_by_icp_mrr.result	2012-01-25 14:52:00 +0000
+++ b/mysql-test/r/order_by_icp_mrr.result	2012-02-01 09:59:13 +0000
@@ -2639,4 +2639,36 @@ c
 10
 NULL
 DROP TABLE t1;
+#
+# Bug #13528826 
+# TEST_IF_CHEAPER_ORDERING(): CALCULATES INCORRECT 'SELECT_LIMIT'
+# 
+#
+CREATE TABLE t1(a int PRIMARY KEY, b int) ENGINE=myisam;
+INSERT INTO t1 VALUES
+(5, 10), (2, 70), (7, 80), (6, 20), (1, 50), (9, 40), (8, 30), (3, 60);
+CREATE TABLE t2 (p int, a int, INDEX i_a(a)) ENGINE=myisam;
+INSERT INTO t2 VALUES
+(103, 7), (109, 3), (102, 3), (108, 1), (106, 3),
+(107, 7), (105, 1), (101, 3), (100, 7), (110, 1);
+# number of rows in t1 was incorrectly used as an 
+# implicit limit-clause if not explicit specified
+EXPLAIN
+SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	8	Using index
+1	SIMPLE	t2	ref	i_a	i_a	5	test.t1.a	2	Using index
+# Query above used to be explained identical to this:
+EXPLAIN
+SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 8;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	4	Using index
+1	SIMPLE	t2	ref	i_a	i_a	5	test.t1.a	2	Using index
+# A really high limit was required to give the correct explain
+EXPLAIN
+SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 1000;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	8	Using index
+1	SIMPLE	t2	ref	i_a	i_a	5	test.t1.a	2	Using index
+DROP TABLE t1, t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/order_by_none.result'
--- a/mysql-test/r/order_by_none.result	2012-01-25 14:52:00 +0000
+++ b/mysql-test/r/order_by_none.result	2012-02-01 09:59:13 +0000
@@ -2638,4 +2638,36 @@ c
 10
 NULL
 DROP TABLE t1;
+#
+# Bug #13528826 
+# TEST_IF_CHEAPER_ORDERING(): CALCULATES INCORRECT 'SELECT_LIMIT'
+# 
+#
+CREATE TABLE t1(a int PRIMARY KEY, b int) ENGINE=myisam;
+INSERT INTO t1 VALUES
+(5, 10), (2, 70), (7, 80), (6, 20), (1, 50), (9, 40), (8, 30), (3, 60);
+CREATE TABLE t2 (p int, a int, INDEX i_a(a)) ENGINE=myisam;
+INSERT INTO t2 VALUES
+(103, 7), (109, 3), (102, 3), (108, 1), (106, 3),
+(107, 7), (105, 1), (101, 3), (100, 7), (110, 1);
+# number of rows in t1 was incorrectly used as an 
+# implicit limit-clause if not explicit specified
+EXPLAIN
+SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	8	Using index
+1	SIMPLE	t2	ref	i_a	i_a	5	test.t1.a	2	Using index
+# Query above used to be explained identical to this:
+EXPLAIN
+SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 8;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	4	Using index
+1	SIMPLE	t2	ref	i_a	i_a	5	test.t1.a	2	Using index
+# A really high limit was required to give the correct explain
+EXPLAIN
+SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 1000;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	8	Using index
+1	SIMPLE	t2	ref	i_a	i_a	5	test.t1.a	2	Using index
+DROP TABLE t1, t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/partition_windows.result'
--- a/mysql-test/r/partition_windows.result	2008-10-26 17:05:24 +0000
+++ b/mysql-test/r/partition_windows.result	2012-02-07 23:33:54 +0000
@@ -26,5 +26,9 @@ ALTER TABLE t1 ADD PARTITION (PARTITION 
 Warnings:
 Warning	1618	<DATA DIRECTORY> option ignored
 Warning	1618	<INDEX DIRECTORY> option ignored
+Warning	1618	<DATA DIRECTORY> option ignored
+Warning	1618	<INDEX DIRECTORY> option ignored
+Warning	1618	<DATA DIRECTORY> option ignored
+Warning	1618	<INDEX DIRECTORY> option ignored
 INSERT INTO t1 VALUES (NULL, "last", 4);
 DROP TABLE t1;

=== modified file 'mysql-test/r/subquery_all.result'
--- a/mysql-test/r/subquery_all.result	2012-01-30 13:13:15 +0000
+++ b/mysql-test/r/subquery_all.result	2012-02-07 14:50:31 +0000
@@ -6822,4 +6822,262 @@ Warnings:
 Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from (`test`.`it`) where ((`test`.`it`.`col_varchar_key2` = 'x') and (`test`.`it`.`col_varchar_key` = 'x') and isnull(`test`.`it`.`col_int_key`))
 
 DROP TABLE it, ot;
+#
+# Bug #11829691: Pure virtual method called in Item_bool_func2::fix...()
+#
+CREATE TABLE t1(a INTEGER);
+CREATE TABLE t2(b INTEGER);
+PREPARE stmt FROM "
+SELECT SUM(b) FROM t2 GROUP BY b HAVING b IN (SELECT b FROM t1)";
+EXECUTE stmt;
+SUM(b)
+EXECUTE stmt;
+SUM(b)
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1, t2;
+#
+# Bug #13595212 EXTRA ROWS RETURNED ON RIGHT JOIN WITH VIEW AND
+# IN-SUBQUERY IN WHERE
+#
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+col_int_key int(11) NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+);
+INSERT INTO t1 VALUES (1,0,'j','j'),(2,8,'v','v'),
+(3,1,'c','c'),(4,8,'m','m'),(5,9,'d','d');
+CREATE VIEW v1 AS SELECT * FROM t1;
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`test`.`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `test`.`t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `test`.`t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+CREATE VIEW v2 AS SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+EXPLAIN EXTENDED SELECT * FROM v2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+3	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+3	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #3 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #3 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#3 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT * FROM v2;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+DROP TABLE t1;
+DROP VIEW v1,v2;
+#
+# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY
+# HAS AN EMPTY RESULT
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+CREATE TABLE t2 (
+pk int NOT NULL AUTO_INCREMENT,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b');
+SET @var2:=4, @var3:=8;
+
+Testcase without inner subquery
+EXPLAIN SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+
+Testcase with inner subquery; crashed WL#6095
+SET @var3=8;
+EXPLAIN SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+2	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+EXPLAIN SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+3	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+DROP TABLE t1,t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_all_bka.result'
--- a/mysql-test/r/subquery_all_bka.result	2012-01-30 13:13:15 +0000
+++ b/mysql-test/r/subquery_all_bka.result	2012-02-07 14:50:31 +0000
@@ -6823,5 +6823,263 @@ Warnings:
 Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from (`test`.`it`) where ((`test`.`it`.`col_varchar_key2` = 'x') and (`test`.`it`.`col_varchar_key` = 'x') and isnull(`test`.`it`.`col_int_key`))
 
 DROP TABLE it, ot;
+#
+# Bug #11829691: Pure virtual method called in Item_bool_func2::fix...()
+#
+CREATE TABLE t1(a INTEGER);
+CREATE TABLE t2(b INTEGER);
+PREPARE stmt FROM "
+SELECT SUM(b) FROM t2 GROUP BY b HAVING b IN (SELECT b FROM t1)";
+EXECUTE stmt;
+SUM(b)
+EXECUTE stmt;
+SUM(b)
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1, t2;
+#
+# Bug #13595212 EXTRA ROWS RETURNED ON RIGHT JOIN WITH VIEW AND
+# IN-SUBQUERY IN WHERE
+#
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+col_int_key int(11) NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+);
+INSERT INTO t1 VALUES (1,0,'j','j'),(2,8,'v','v'),
+(3,1,'c','c'),(4,8,'m','m'),(5,9,'d','d');
+CREATE VIEW v1 AS SELECT * FROM t1;
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`test`.`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `test`.`t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `test`.`t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+CREATE VIEW v2 AS SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+EXPLAIN EXTENDED SELECT * FROM v2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+3	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+3	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #3 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #3 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#3 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT * FROM v2;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+DROP TABLE t1;
+DROP VIEW v1,v2;
+#
+# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY
+# HAS AN EMPTY RESULT
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+CREATE TABLE t2 (
+pk int NOT NULL AUTO_INCREMENT,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b');
+SET @var2:=4, @var3:=8;
+
+Testcase without inner subquery
+EXPLAIN SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+
+Testcase with inner subquery; crashed WL#6095
+SET @var3=8;
+EXPLAIN SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+2	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+EXPLAIN SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+3	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+DROP TABLE t1,t2;
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_all_bka_nixbnl.result'
--- a/mysql-test/r/subquery_all_bka_nixbnl.result	2011-12-01 11:30:35 +0000
+++ b/mysql-test/r/subquery_all_bka_nixbnl.result	2012-02-07 14:50:31 +0000
@@ -6823,5 +6823,263 @@ Warnings:
 Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from (`test`.`it`) where ((`test`.`it`.`col_varchar_key2` = 'x') and (`test`.`it`.`col_varchar_key` = 'x') and isnull(`test`.`it`.`col_int_key`))
 
 DROP TABLE it, ot;
+#
+# Bug #11829691: Pure virtual method called in Item_bool_func2::fix...()
+#
+CREATE TABLE t1(a INTEGER);
+CREATE TABLE t2(b INTEGER);
+PREPARE stmt FROM "
+SELECT SUM(b) FROM t2 GROUP BY b HAVING b IN (SELECT b FROM t1)";
+EXECUTE stmt;
+SUM(b)
+EXECUTE stmt;
+SUM(b)
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1, t2;
+#
+# Bug #13595212 EXTRA ROWS RETURNED ON RIGHT JOIN WITH VIEW AND
+# IN-SUBQUERY IN WHERE
+#
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+col_int_key int(11) NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+);
+INSERT INTO t1 VALUES (1,0,'j','j'),(2,8,'v','v'),
+(3,1,'c','c'),(4,8,'m','m'),(5,9,'d','d');
+CREATE VIEW v1 AS SELECT * FROM t1;
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	ref	col_int_key	col_int_key	4	test.t1.pk	2	100.00	Using index
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`test`.`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `test`.`t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `test`.`t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+CREATE VIEW v2 AS SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+EXPLAIN EXTENDED SELECT * FROM v2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index
+3	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+3	DEPENDENT SUBQUERY	sq2_alias2	ref	col_int_key	col_int_key	4	test.t1.pk	2	100.00	Using index
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #3 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #3 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#3 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT * FROM v2;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	ref	col_int_key	col_int_key	4	test.t1.pk	2	100.00	Using index
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+DROP TABLE t1;
+DROP VIEW v1,v2;
+#
+# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY
+# HAS AN EMPTY RESULT
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+CREATE TABLE t2 (
+pk int NOT NULL AUTO_INCREMENT,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b');
+SET @var2:=4, @var3:=8;
+
+Testcase without inner subquery
+EXPLAIN SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+
+Testcase with inner subquery; crashed WL#6095
+SET @var3=8;
+EXPLAIN SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+2	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+EXPLAIN SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+3	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+DROP TABLE t1,t2;
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_nomat_nosj.result'
--- a/mysql-test/r/subquery_nomat_nosj.result	2011-11-01 11:52:24 +0000
+++ b/mysql-test/r/subquery_nomat_nosj.result	2012-02-07 14:50:31 +0000
@@ -6822,4 +6822,262 @@ Warnings:
 Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from dual where <in_optimizer>(('x','x'),<exists>(<index_lookup>(<cache>('x') in it on idx_cvk_cvk2_cik where (isnull(`test`.`it`.`col_int_key`) and (<cache>('x') = `test`.`it`.`col_varchar_key`) and (<cache>('x') = `test`.`it`.`col_varchar_key2`)))))
 
 DROP TABLE it, ot;
+#
+# Bug #11829691: Pure virtual method called in Item_bool_func2::fix...()
+#
+CREATE TABLE t1(a INTEGER);
+CREATE TABLE t2(b INTEGER);
+PREPARE stmt FROM "
+SELECT SUM(b) FROM t2 GROUP BY b HAVING b IN (SELECT b FROM t1)";
+EXECUTE stmt;
+SUM(b)
+EXECUTE stmt;
+SUM(b)
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1, t2;
+#
+# Bug #13595212 EXTRA ROWS RETURNED ON RIGHT JOIN WITH VIEW AND
+# IN-SUBQUERY IN WHERE
+#
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+col_int_key int(11) NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+);
+INSERT INTO t1 VALUES (1,0,'j','j'),(2,8,'v','v'),
+(3,1,'c','c'),(4,8,'m','m'),(5,9,'d','d');
+CREATE VIEW v1 AS SELECT * FROM t1;
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`test`.`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `test`.`t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `test`.`t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+CREATE VIEW v2 AS SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+EXPLAIN EXTENDED SELECT * FROM v2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+3	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+3	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #3 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #3 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#3 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT * FROM v2;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+DROP TABLE t1;
+DROP VIEW v1,v2;
+#
+# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY
+# HAS AN EMPTY RESULT
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+CREATE TABLE t2 (
+pk int NOT NULL AUTO_INCREMENT,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b');
+SET @var2:=4, @var3:=8;
+
+Testcase without inner subquery
+EXPLAIN SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+
+Testcase with inner subquery; crashed WL#6095
+SET @var3=8;
+EXPLAIN SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+2	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+EXPLAIN SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+3	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+DROP TABLE t1,t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_nomat_nosj_bka.result'
--- a/mysql-test/r/subquery_nomat_nosj_bka.result	2011-11-01 11:52:24 +0000
+++ b/mysql-test/r/subquery_nomat_nosj_bka.result	2012-02-07 14:50:31 +0000
@@ -6823,5 +6823,263 @@ Warnings:
 Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from dual where <in_optimizer>(('x','x'),<exists>(<index_lookup>(<cache>('x') in it on idx_cvk_cvk2_cik where (isnull(`test`.`it`.`col_int_key`) and (<cache>('x') = `test`.`it`.`col_varchar_key`) and (<cache>('x') = `test`.`it`.`col_varchar_key2`)))))
 
 DROP TABLE it, ot;
+#
+# Bug #11829691: Pure virtual method called in Item_bool_func2::fix...()
+#
+CREATE TABLE t1(a INTEGER);
+CREATE TABLE t2(b INTEGER);
+PREPARE stmt FROM "
+SELECT SUM(b) FROM t2 GROUP BY b HAVING b IN (SELECT b FROM t1)";
+EXECUTE stmt;
+SUM(b)
+EXECUTE stmt;
+SUM(b)
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1, t2;
+#
+# Bug #13595212 EXTRA ROWS RETURNED ON RIGHT JOIN WITH VIEW AND
+# IN-SUBQUERY IN WHERE
+#
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+col_int_key int(11) NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+);
+INSERT INTO t1 VALUES (1,0,'j','j'),(2,8,'v','v'),
+(3,1,'c','c'),(4,8,'m','m'),(5,9,'d','d');
+CREATE VIEW v1 AS SELECT * FROM t1;
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`test`.`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `test`.`t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `test`.`t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+CREATE VIEW v2 AS SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+EXPLAIN EXTENDED SELECT * FROM v2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+3	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+3	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #3 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #3 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#3 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT * FROM v2;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+DROP TABLE t1;
+DROP VIEW v1,v2;
+#
+# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY
+# HAS AN EMPTY RESULT
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+CREATE TABLE t2 (
+pk int NOT NULL AUTO_INCREMENT,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b');
+SET @var2:=4, @var3:=8;
+
+Testcase without inner subquery
+EXPLAIN SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+
+Testcase with inner subquery; crashed WL#6095
+SET @var3=8;
+EXPLAIN SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+2	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+EXPLAIN SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+3	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+DROP TABLE t1,t2;
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_nomat_nosj_bka_nixbnl.result'
--- a/mysql-test/r/subquery_nomat_nosj_bka_nixbnl.result	2011-11-01 11:52:24 +0000
+++ b/mysql-test/r/subquery_nomat_nosj_bka_nixbnl.result	2012-02-07 14:50:31 +0000
@@ -6823,5 +6823,263 @@ Warnings:
 Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from dual where <in_optimizer>(('x','x'),<exists>(<index_lookup>(<cache>('x') in it on idx_cvk_cvk2_cik where (isnull(`test`.`it`.`col_int_key`) and (<cache>('x') = `test`.`it`.`col_varchar_key`) and (<cache>('x') = `test`.`it`.`col_varchar_key2`)))))
 
 DROP TABLE it, ot;
+#
+# Bug #11829691: Pure virtual method called in Item_bool_func2::fix...()
+#
+CREATE TABLE t1(a INTEGER);
+CREATE TABLE t2(b INTEGER);
+PREPARE stmt FROM "
+SELECT SUM(b) FROM t2 GROUP BY b HAVING b IN (SELECT b FROM t1)";
+EXECUTE stmt;
+SUM(b)
+EXECUTE stmt;
+SUM(b)
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1, t2;
+#
+# Bug #13595212 EXTRA ROWS RETURNED ON RIGHT JOIN WITH VIEW AND
+# IN-SUBQUERY IN WHERE
+#
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+col_int_key int(11) NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+);
+INSERT INTO t1 VALUES (1,0,'j','j'),(2,8,'v','v'),
+(3,1,'c','c'),(4,8,'m','m'),(5,9,'d','d');
+CREATE VIEW v1 AS SELECT * FROM t1;
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	ref	col_int_key	col_int_key	4	test.t1.pk	2	100.00	Using index
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`test`.`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `test`.`t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `test`.`t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+CREATE VIEW v2 AS SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+EXPLAIN EXTENDED SELECT * FROM v2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index
+3	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+3	DEPENDENT SUBQUERY	sq2_alias2	ref	col_int_key	col_int_key	4	test.t1.pk	2	100.00	Using index
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #3 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #3 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#3 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT * FROM v2;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	ref	col_int_key	col_int_key	4	test.t1.pk	2	100.00	Using index
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+DROP TABLE t1;
+DROP VIEW v1,v2;
+#
+# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY
+# HAS AN EMPTY RESULT
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+CREATE TABLE t2 (
+pk int NOT NULL AUTO_INCREMENT,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b');
+SET @var2:=4, @var3:=8;
+
+Testcase without inner subquery
+EXPLAIN SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+
+Testcase with inner subquery; crashed WL#6095
+SET @var3=8;
+EXPLAIN SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+2	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+EXPLAIN SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+3	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+DROP TABLE t1,t2;
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_none.result'
--- a/mysql-test/r/subquery_none.result	2011-11-01 11:52:24 +0000
+++ b/mysql-test/r/subquery_none.result	2012-02-07 14:50:31 +0000
@@ -6821,4 +6821,262 @@ Warnings:
 Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from dual where <in_optimizer>(('x','x'),<exists>(<index_lookup>(<cache>('x') in it on idx_cvk_cvk2_cik where (isnull(`test`.`it`.`col_int_key`) and (<cache>('x') = `test`.`it`.`col_varchar_key`) and (<cache>('x') = `test`.`it`.`col_varchar_key2`)))))
 
 DROP TABLE it, ot;
+#
+# Bug #11829691: Pure virtual method called in Item_bool_func2::fix...()
+#
+CREATE TABLE t1(a INTEGER);
+CREATE TABLE t2(b INTEGER);
+PREPARE stmt FROM "
+SELECT SUM(b) FROM t2 GROUP BY b HAVING b IN (SELECT b FROM t1)";
+EXECUTE stmt;
+SUM(b)
+EXECUTE stmt;
+SUM(b)
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1, t2;
+#
+# Bug #13595212 EXTRA ROWS RETURNED ON RIGHT JOIN WITH VIEW AND
+# IN-SUBQUERY IN WHERE
+#
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+col_int_key int(11) NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+);
+INSERT INTO t1 VALUES (1,0,'j','j'),(2,8,'v','v'),
+(3,1,'c','c'),(4,8,'m','m'),(5,9,'d','d');
+CREATE VIEW v1 AS SELECT * FROM t1;
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`test`.`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `test`.`t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `test`.`t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+CREATE VIEW v2 AS SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+EXPLAIN EXTENDED SELECT * FROM v2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+3	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+3	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #3 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #3 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#3 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT * FROM v2;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+DROP TABLE t1;
+DROP VIEW v1,v2;
+#
+# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY
+# HAS AN EMPTY RESULT
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+CREATE TABLE t2 (
+pk int NOT NULL AUTO_INCREMENT,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b');
+SET @var2:=4, @var3:=8;
+
+Testcase without inner subquery
+EXPLAIN SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+
+Testcase with inner subquery; crashed WL#6095
+SET @var3=8;
+EXPLAIN SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+2	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+EXPLAIN SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+3	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+DROP TABLE t1,t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_none_bka.result'
--- a/mysql-test/r/subquery_none_bka.result	2011-11-01 11:52:24 +0000
+++ b/mysql-test/r/subquery_none_bka.result	2012-02-07 14:50:31 +0000
@@ -6822,5 +6822,263 @@ Warnings:
 Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from dual where <in_optimizer>(('x','x'),<exists>(<index_lookup>(<cache>('x') in it on idx_cvk_cvk2_cik where (isnull(`test`.`it`.`col_int_key`) and (<cache>('x') = `test`.`it`.`col_varchar_key`) and (<cache>('x') = `test`.`it`.`col_varchar_key2`)))))
 
 DROP TABLE it, ot;
+#
+# Bug #11829691: Pure virtual method called in Item_bool_func2::fix...()
+#
+CREATE TABLE t1(a INTEGER);
+CREATE TABLE t2(b INTEGER);
+PREPARE stmt FROM "
+SELECT SUM(b) FROM t2 GROUP BY b HAVING b IN (SELECT b FROM t1)";
+EXECUTE stmt;
+SUM(b)
+EXECUTE stmt;
+SUM(b)
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1, t2;
+#
+# Bug #13595212 EXTRA ROWS RETURNED ON RIGHT JOIN WITH VIEW AND
+# IN-SUBQUERY IN WHERE
+#
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+col_int_key int(11) NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+);
+INSERT INTO t1 VALUES (1,0,'j','j'),(2,8,'v','v'),
+(3,1,'c','c'),(4,8,'m','m'),(5,9,'d','d');
+CREATE VIEW v1 AS SELECT * FROM t1;
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`test`.`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `test`.`t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `test`.`t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+CREATE VIEW v2 AS SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+EXPLAIN EXTENDED SELECT * FROM v2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+3	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+3	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #3 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #3 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#3 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT * FROM v2;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; Using join buffer (Block Nested Loop)
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+DROP TABLE t1;
+DROP VIEW v1,v2;
+#
+# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY
+# HAS AN EMPTY RESULT
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+CREATE TABLE t2 (
+pk int NOT NULL AUTO_INCREMENT,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b');
+SET @var2:=4, @var3:=8;
+
+Testcase without inner subquery
+EXPLAIN SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+
+Testcase with inner subquery; crashed WL#6095
+SET @var3=8;
+EXPLAIN SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+2	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+EXPLAIN SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+3	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+DROP TABLE t1,t2;
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_none_bka_nixbnl.result'
--- a/mysql-test/r/subquery_none_bka_nixbnl.result	2011-11-01 11:52:24 +0000
+++ b/mysql-test/r/subquery_none_bka_nixbnl.result	2012-02-07 14:50:31 +0000
@@ -6822,5 +6822,263 @@ Warnings:
 Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from dual where <in_optimizer>(('x','x'),<exists>(<index_lookup>(<cache>('x') in it on idx_cvk_cvk2_cik where (isnull(`test`.`it`.`col_int_key`) and (<cache>('x') = `test`.`it`.`col_varchar_key`) and (<cache>('x') = `test`.`it`.`col_varchar_key2`)))))
 
 DROP TABLE it, ot;
+#
+# Bug #11829691: Pure virtual method called in Item_bool_func2::fix...()
+#
+CREATE TABLE t1(a INTEGER);
+CREATE TABLE t2(b INTEGER);
+PREPARE stmt FROM "
+SELECT SUM(b) FROM t2 GROUP BY b HAVING b IN (SELECT b FROM t1)";
+EXECUTE stmt;
+SUM(b)
+EXECUTE stmt;
+SUM(b)
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1, t2;
+#
+# Bug #13595212 EXTRA ROWS RETURNED ON RIGHT JOIN WITH VIEW AND
+# IN-SUBQUERY IN WHERE
+#
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+col_int_key int(11) NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+);
+INSERT INTO t1 VALUES (1,0,'j','j'),(2,8,'v','v'),
+(3,1,'c','c'),(4,8,'m','m'),(5,9,'d','d');
+CREATE VIEW v1 AS SELECT * FROM t1;
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	ref	col_int_key	col_int_key	4	test.t1.pk	2	100.00	Using index
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`test`.`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `test`.`t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `test`.`t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+CREATE VIEW v2 AS SELECT alias2.col_varchar_nokey
+FROM v1 AS alias1
+RIGHT JOIN t1 AS alias2 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+)
+;
+EXPLAIN EXTENDED SELECT * FROM v2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index
+3	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+3	DEPENDENT SUBQUERY	sq2_alias2	ref	col_int_key	col_int_key	4	test.t1.pk	2	100.00	Using index
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #3 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #3 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#3 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT * FROM v2;
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+EXPLAIN EXTENDED SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	5	100.00	
+1	PRIMARY	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index
+2	DEPENDENT SUBQUERY	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Using where
+2	DEPENDENT SUBQUERY	sq2_alias2	ref	col_int_key	col_int_key	4	test.t1.pk	2	100.00	Using index
+Warnings:
+Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
+Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` left join (`test`.`t1`) on(1) where <in_optimizer>(`test`.`alias2`.`col_varchar_key`,<exists>(/* select#2 */ select 1 from `test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`) and (<cache>(`test`.`alias2`.`col_varchar_key`) = `test`.`t1`.`col_varchar_nokey`))))
+SELECT alias2.col_varchar_nokey
+FROM t1 AS alias2
+LEFT JOIN v1 AS alias1 ON 1
+WHERE alias2.col_varchar_key IN (
+SELECT sq2_alias1.col_varchar_nokey
+FROM v1 AS sq2_alias1
+LEFT JOIN t1 AS sq2_alias2
+ON (sq2_alias2.col_int_key = sq2_alias1.pk)
+WHERE sq2_alias1.pk != alias1.col_int_key
+AND sq2_alias1.col_varchar_key > alias1.col_varchar_key
+);
+col_varchar_nokey
+d
+j
+m
+m
+m
+v
+v
+v
+v
+DROP TABLE t1;
+DROP VIEW v1,v2;
+#
+# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY
+# HAS AN EMPTY RESULT
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+CREATE TABLE t2 (
+pk int NOT NULL AUTO_INCREMENT,
+col_int_nokey int NOT NULL,
+col_int_key int NOT NULL,
+col_time_key time NOT NULL,
+col_varchar_key varchar(1) NOT NULL,
+col_varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_time_key (col_time_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b');
+SET @var2:=4, @var3:=8;
+
+Testcase without inner subquery
+EXPLAIN SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
+sq4_alias1.col_varchar_key = @var3 ) AS alias3;
+@var3:=12	pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+SELECT @var3;
+@var3
+8
+
+Testcase with inner subquery; crashed WL#6095
+SET @var3=8;
+EXPLAIN SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+2	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3));
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+EXPLAIN SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	0	const row not found
+2	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
+3	DEPENDENT SUBQUERY	c_sq1_alias1	system	PRIMARY,col_varchar_key	NULL	NULL	NULL	1	
+SELECT * FROM ( SELECT sq4_alias1.*
+FROM t1 AS sq4_alias1
+WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
+NOT IN
+(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
+c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
+FROM t2 AS c_sq1_alias1
+WHERE (c_sq1_alias1.col_int_nokey != @var2
+OR c_sq1_alias1.pk != @var3)) ) AS alias3;
+pk	col_int_nokey	col_int_key	col_time_key	col_varchar_key	col_varchar_nokey
+DROP TABLE t1,t2;
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/type_temporal_fractional.result'
--- a/mysql-test/r/type_temporal_fractional.result	2012-01-31 15:16:16 +0000
+++ b/mysql-test/r/type_temporal_fractional.result	2012-02-07 20:32:47 +0000
@@ -1014,8 +1014,8 @@ a6	t6	HEX(WEIGHT_STRING(t6))
 -00:00:00.000003	-00:00:00.000003	7FFFFFFFFFFD
 -00:00:00.000002	-00:00:00.000002	7FFFFFFFFFFE
 -00:00:00.000001	-00:00:00.000001	7FFFFFFFFFFF
--00:00:00.000000	00:00:00.000000	800000000000
 00:00:00.000000	00:00:00.000000	800000000000
+-00:00:00.000000	00:00:00.000000	800000000000
 00:00:00.000001	00:00:00.000001	800000000001
 00:00:00.000002	00:00:00.000002	800000000002
 00:00:00.000003	00:00:00.000003	800000000003
@@ -17130,4 +17130,49 @@ SELECT 1 FROM t1 WHERE CASE WHEN 0 then 
 SELECT 1 FROM t1 WHERE (SELECT a FROM t1) / a;
 1
 DROP TABLE t1;
+#
+# BUG#13616434 ASSERTION FAILED: NANOSECONDS < 1000000000
+#
+SELECT
+EXTRACT(DAY FROM (-0.1111111111)),
+EXTRACT(YEAR FROM (-0.1111111)),
+EXTRACT(YEAR_MONTH FROM (-0.1111111111)),
+EXTRACT(DAY FROM (-0.1111111)),
+EXTRACT(QUARTER FROM (-0.1111111111)),
+EXTRACT(MONTH FROM (-0.1111111)),
+EXTRACT(WEEK FROM (-0.1111111)),
+DATE(-0.1111111),
+QUARTER(-0.1111111111),
+TIMESTAMP(-0.1111111111),
+LAST_DAY(-0.1111111111),
+DAY(-0.1111111111),
+MONTH(-0.1111111111),
+YEAR(-0.1111111),
+DAYOFMONTH(-0.1111111111),
+TIMESTAMP((-0.1111111111),'{$x'),
+DATE_FORMAT(-0.1111111111,'+'),
+CONVERT(-0.1111111,DATE),
+CAST(-0.1111111111 AS DATE);
+EXTRACT(DAY FROM (-0.1111111111))	EXTRACT(YEAR FROM (-0.1111111))	EXTRACT(YEAR_MONTH FROM (-0.1111111111))	EXTRACT(DAY FROM (-0.1111111))	EXTRACT(QUARTER FROM (-0.1111111111))	EXTRACT(MONTH FROM (-0.1111111))	EXTRACT(WEEK FROM (-0.1111111))	DATE(-0.1111111)	QUARTER(-0.1111111111)	TIMESTAMP(-0.1111111111)	LAST_DAY(-0.1111111111)	DAY(-0.1111111111)	MONTH(-0.1111111111)	YEAR(-0.1111111)	DAYOFMONTH(-0.1111111111)	TIMESTAMP((-0.1111111111),'{$x')	DATE_FORMAT(-0.1111111111,'+')	CONVERT(-0.1111111,DATE)	CAST(-0.1111111111 AS DATE)
+NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+Warnings:
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111'
+Warning	1292	Incorrect datetime value: '-0.1111111'
+Warning	1292	Incorrect datetime value: '-0.1111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
 # End of 5.6 tests

=== modified file 'mysql-test/suite/engines/funcs/r/date_function.result'
--- a/mysql-test/suite/engines/funcs/r/date_function.result	2010-03-18 06:42:07 +0000
+++ b/mysql-test/suite/engines/funcs/r/date_function.result	2012-02-02 12:37:31 +0000
@@ -306,6 +306,8 @@ NULL
 2000-01-31
 2006-12-31
 2008-02-29
+Warnings:
+Warning	1292	Incorrect datetime value: '0000-00-00'
 DROP TABLE t3;
 CREATE TABLE t3(c1 DATE NOT NULL);
 INSERT INTO t3 VALUES('1000-01-01');

=== modified file 'mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result'
--- a/mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result	2011-01-05 08:43:46 +0000
+++ b/mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result	2012-02-02 12:29:12 +0000
@@ -81,6 +81,7 @@ utf8_german2_ci	utf8	212		#	#
 utf8_croatian_ci	utf8	213		#	#
 utf8_unicode_520_ci	utf8	214		#	#
 utf8_vietnamese_ci	utf8	215		#	#
+utf8_general_mysql500_ci	utf8	223		#	#
 ucs2_general_ci	ucs2	35	Yes	#	#
 ucs2_bin	ucs2	90		#	#
 ucs2_unicode_ci	ucs2	128		#	#
@@ -107,6 +108,7 @@ ucs2_german2_ci	ucs2	148		#	#
 ucs2_croatian_ci	ucs2	149		#	#
 ucs2_unicode_520_ci	ucs2	150		#	#
 ucs2_vietnamese_ci	ucs2	151		#	#
+ucs2_general_mysql500_ci	ucs2	159		#	#
 cp866_general_ci	cp866	36	Yes	#	#
 cp866_bin	cp866	68		#	#
 keybcs2_general_ci	keybcs2	37	Yes	#	#

=== modified file 'mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result'
--- a/mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result	2011-01-05 08:43:46 +0000
+++ b/mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result	2012-02-02 12:29:12 +0000
@@ -81,6 +81,7 @@ utf8_german2_ci	utf8	212		#	#
 utf8_croatian_ci	utf8	213		#	#
 utf8_unicode_520_ci	utf8	214		#	#
 utf8_vietnamese_ci	utf8	215		#	#
+utf8_general_mysql500_ci	utf8	223		#	#
 ucs2_general_ci	ucs2	35	Yes	#	#
 ucs2_bin	ucs2	90		#	#
 ucs2_unicode_ci	ucs2	128		#	#
@@ -107,6 +108,7 @@ ucs2_german2_ci	ucs2	148		#	#
 ucs2_croatian_ci	ucs2	149		#	#
 ucs2_unicode_520_ci	ucs2	150		#	#
 ucs2_vietnamese_ci	ucs2	151		#	#
+ucs2_general_mysql500_ci	ucs2	159		#	#
 cp866_general_ci	cp866	36	Yes	#	#
 cp866_bin	cp866	68		#	#
 keybcs2_general_ci	keybcs2	37	Yes	#	#

=== modified file 'mysql-test/suite/funcs_1/r/innodb_views.result'
--- a/mysql-test/suite/funcs_1/r/innodb_views.result	2010-08-31 06:28:15 +0000
+++ b/mysql-test/suite/funcs_1/r/innodb_views.result	2012-02-07 11:56:30 +0000
@@ -15222,456 +15222,456 @@ DELETE FROM t1;
 DROP VIEW v3;
 DROP VIEW v2;
 DROP VIEW v1;
-SELECT * FROM t1_results ORDER BY v3_to_v1_options;
+SELECT * FROM t1_results ORDER BY v3_to_v1_options, statement, v3_to_v1_violation, errno;
 v3_to_v1_options	statement	v3_to_v1_violation	errno
-        <nothing>          -         <nothing>          -         <nothing>         	UPDATE	  _v2_  	0
-        <nothing>          -         <nothing>          -         <nothing>         	INSERT	  _v2_  	0
+        <nothing>          -         <nothing>          -         <nothing>         	INSERT	  _  _  	0
         <nothing>          -         <nothing>          -         <nothing>         	INSERT	  _  _v1	0
+        <nothing>          -         <nothing>          -         <nothing>         	INSERT	  _v2_  	0
         <nothing>          -         <nothing>          -         <nothing>         	UPDATE	  _  _  	0
         <nothing>          -         <nothing>          -         <nothing>         	UPDATE	  _  _v1	0
+        <nothing>          -         <nothing>          -         <nothing>         	UPDATE	  _v2_  	0
         <nothing>          -         <nothing>          -         <nothing>         	UPDATE	v3_  _  	0
-        <nothing>          -         <nothing>          -         <nothing>         	INSERT	  _  _  	0
-        <nothing>          -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _v2_  	0
         <nothing>          -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _  	0
-        <nothing>          -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _v1	0
+        <nothing>          -         <nothing>          - WITH          CHECK OPTION	INSERT	  _v2_  	0
         <nothing>          -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _  	0
+        <nothing>          -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _v2_  	0
         <nothing>          -         <nothing>          - WITH          CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          -         <nothing>          - WITH          CHECK OPTION	INSERT	  _v2_  	0
-        <nothing>          -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _v1	0
-        <nothing>          -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
         <nothing>          -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
         <nothing>          -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
+        <nothing>          -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
         <nothing>          -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
         <nothing>          -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
         <nothing>          -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
         <nothing>          -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
-        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
-        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
         <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
+        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
+        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
         <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
-        <nothing>          - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	0
+        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
+        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	0
+        <nothing>          - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
+        <nothing>          - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _v1	0
         <nothing>          - WITH          CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
-        <nothing>          - WITH          CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	0
-        <nothing>          - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	0
         <nothing>          - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
-        <nothing>          - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _v1	0
-        <nothing>          - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
-        <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
-        <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+        <nothing>          - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	0
+        <nothing>          - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	0
+        <nothing>          - WITH          CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	0
+        <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
         <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	0
         <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
-        <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
+        <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
         <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
+        <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	0
         <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
-        <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
-        <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
-        <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
         <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
         <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
+        <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
+        <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
         <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	0
         <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-        <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
         <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
+        <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
         <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
         <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
         <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
+        <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	0
+        <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
         <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _v1	0
+        <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
+        <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
         <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	0
         <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	0
-        <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
         <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	0
-        <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
-        <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	0
         <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
         <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _v1	0
+        <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
         <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
         <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	0
         <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
-WITH          CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	v3_  _  	1369
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	0
 WITH          CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _  _  	0
-WITH          CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _v2_  	1369
 WITH          CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _  _v1	1369
-WITH          CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _v1	1369
+WITH          CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _v2_  	1369
 WITH          CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _  	0
-WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _v2_  	1369
+WITH          CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _v1	1369
+WITH          CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _  	0
 WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _v1	1369
+WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _v2_  	1369
 WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _  	0
 WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
 WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
-WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
 WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
+WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
 WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
 WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
+WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
 WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
 WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
+WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
+WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
+WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
 WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
+WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _v1	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _v2_  	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
+WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
 WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _v1	1369
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _v2_  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	1369
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _v1	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _v2_  	1369
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _v2_  	1369
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
-WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _v2_  	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _  _  	0
+WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _  _v1	1369
+WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _  	0
 WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _v2_  	1369
 WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _  _v1	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _  	0
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _v2_  	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _  	0
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _v1	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _v1	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _v1	0
-WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _  _v1	0
 WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _v2_  	0
+WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _  	0
+WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _  	0
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _v1	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _v2_  	0
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _  	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _v2_  	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
 
 Plausibility checks for INSERTs and UPDATEs ( 4. and 5. above).
 All following SELECTs must give ROW NOT FOUND 

=== modified file 'mysql-test/suite/funcs_1/r/memory_views.result'
--- a/mysql-test/suite/funcs_1/r/memory_views.result	2010-08-31 06:28:15 +0000
+++ b/mysql-test/suite/funcs_1/r/memory_views.result	2012-02-07 11:56:30 +0000
@@ -15224,456 +15224,456 @@ DELETE FROM t1;
 DROP VIEW v3;
 DROP VIEW v2;
 DROP VIEW v1;
-SELECT * FROM t1_results ORDER BY v3_to_v1_options;
+SELECT * FROM t1_results ORDER BY v3_to_v1_options, statement, v3_to_v1_violation, errno;
 v3_to_v1_options	statement	v3_to_v1_violation	errno
-        <nothing>          -         <nothing>          -         <nothing>         	UPDATE	  _v2_  	0
-        <nothing>          -         <nothing>          -         <nothing>         	INSERT	  _v2_  	0
+        <nothing>          -         <nothing>          -         <nothing>         	INSERT	  _  _  	0
         <nothing>          -         <nothing>          -         <nothing>         	INSERT	  _  _v1	0
+        <nothing>          -         <nothing>          -         <nothing>         	INSERT	  _v2_  	0
         <nothing>          -         <nothing>          -         <nothing>         	UPDATE	  _  _  	0
         <nothing>          -         <nothing>          -         <nothing>         	UPDATE	  _  _v1	0
+        <nothing>          -         <nothing>          -         <nothing>         	UPDATE	  _v2_  	0
         <nothing>          -         <nothing>          -         <nothing>         	UPDATE	v3_  _  	0
-        <nothing>          -         <nothing>          -         <nothing>         	INSERT	  _  _  	0
-        <nothing>          -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _v2_  	0
         <nothing>          -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _  	0
-        <nothing>          -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _v1	0
+        <nothing>          -         <nothing>          - WITH          CHECK OPTION	INSERT	  _v2_  	0
         <nothing>          -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _  	0
+        <nothing>          -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _v2_  	0
         <nothing>          -         <nothing>          - WITH          CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          -         <nothing>          - WITH          CHECK OPTION	INSERT	  _v2_  	0
-        <nothing>          -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _v1	0
-        <nothing>          -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
         <nothing>          -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
         <nothing>          -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
+        <nothing>          -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
         <nothing>          -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
         <nothing>          -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
         <nothing>          -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
         <nothing>          -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
-        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
-        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
         <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
+        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
+        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
         <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
-        <nothing>          - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	0
+        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
+        <nothing>          -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	0
+        <nothing>          - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
+        <nothing>          - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _v1	0
         <nothing>          - WITH          CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
-        <nothing>          - WITH          CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	0
-        <nothing>          - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	0
         <nothing>          - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
-        <nothing>          - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _v1	0
-        <nothing>          - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
-        <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
-        <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+        <nothing>          - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	0
+        <nothing>          - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	0
+        <nothing>          - WITH          CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	0
+        <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
         <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	0
         <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
-        <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
+        <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
         <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
+        <nothing>          - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	0
         <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
-        <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
-        <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
-        <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
         <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
         <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
+        <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
+        <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
         <nothing>          - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	0
         <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-        <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
         <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
+        <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
         <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
         <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
         <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
+        <nothing>          - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	0
+        <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
         <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _v1	0
+        <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
+        <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
         <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	0
         <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	0
-        <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
         <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	0
-        <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
-        <nothing>          - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
+        <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
         <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	0
         <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
         <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _v1	0
+        <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
         <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
         <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	0
         <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
-        <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
         <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
-WITH          CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	v3_  _  	1369
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
+        <nothing>          - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	0
 WITH          CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _  _  	0
-WITH          CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _v2_  	1369
 WITH          CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _  _v1	1369
-WITH          CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _v1	1369
+WITH          CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _v2_  	1369
 WITH          CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _  	0
-WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _v2_  	1369
+WITH          CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _v1	1369
+WITH          CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _  	0
 WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _v1	1369
+WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _v2_  	1369
 WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _  	0
 WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
 WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
-WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
 WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
+WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
 WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
 WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
+WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
 WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
 WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
+WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
+WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
+WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
 WITH          CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
+WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _v1	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _v2_  	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
+WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
 WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
+WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
 WITH          CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _v1	1369
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _v2_  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	1369
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
 WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
-WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _v1	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _v2_  	1369
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _v2_  	1369
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
-WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
-WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _v2_  	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
+WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _  _  	0
+WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _  _v1	1369
+WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _  	0
 WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _v2_  	1369
 WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _  _v1	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _  	0
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _v2_  	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _  	0
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _v1	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
 WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _v1	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
-WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	1369
 WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	1369
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	1369
+WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _v1	0
-WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _  _v1	0
 WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	INSERT	  _v2_  	0
+WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _  	0
+WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          -         <nothing>         	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _  	0
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _v1	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _v2_  	0
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _  	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	  _v2_  	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION -         <nothing>          - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
-WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _  	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION -         <nothing>         	INSERT	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	INSERT	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _  	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH          CHECK OPTION	UPDATE	v3_  _  	1369
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	INSERT	  _v2_  	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH CASCADED CHECK OPTION	UPDATE	v3_  _  	1369
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _  	0
-WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _  _v1	0
 WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	INSERT	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _  	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _  _v1	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	  _v2_  	0
+WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION - WITH LOCAL    CHECK OPTION	UPDATE	v3_  _  	1369
 
 Plausibility checks for INSERTs and UPDATEs ( 4. and 5. above).
 All following SELECTs must give ROW NOT FOUND 

=== modified file 'mysql-test/suite/funcs_1/views/views_master.inc'
--- a/mysql-test/suite/funcs_1/views/views_master.inc	2010-11-29 13:04:34 +0000
+++ b/mysql-test/suite/funcs_1/views/views_master.inc	2012-02-07 11:56:30 +0000
@@ -2262,7 +2262,7 @@ while ($num1)
   dec $num1;
 }
 
-SELECT * FROM t1_results ORDER BY v3_to_v1_options;
+SELECT * FROM t1_results ORDER BY v3_to_v1_options, statement, v3_to_v1_violation, errno;
 
 let $message=
 Plausibility checks for INSERTs and UPDATEs ( 4. and 5. above).

=== modified file 'mysql-test/suite/innodb/r/innodb-index.result'
--- a/mysql-test/suite/innodb/r/innodb-index.result	2011-11-28 07:42:18 +0000
+++ b/mysql-test/suite/innodb/r/innodb-index.result	2012-02-02 12:00:50 +0000
@@ -1,5 +1,9 @@
 set global innodb_file_per_table=on;
 set global innodb_file_format='Barracuda';
+create table t1(a varchar(2) primary key) engine=innodb;
+insert into t1 values('');
+create index t1a1 on t1(a(1));
+drop table t1;
 create table t1(a int not null, b int, c char(10) not null, d varchar(20)) engine = innodb;
 insert into t1 values (5,5,'oo','oo'),(4,4,'tr','tr'),(3,4,'ad','ad'),(2,3,'ak','ak');
 commit;

=== modified file 'mysql-test/suite/innodb/r/innodb.result'
--- a/mysql-test/suite/innodb/r/innodb.result	2011-12-13 11:44:15 +0000
+++ b/mysql-test/suite/innodb/r/innodb.result	2012-02-07 11:56:30 +0000
@@ -1974,15 +1974,15 @@ i	10
 select sql_big_result v,count(c) from t1 group by v limit 10;
 v	count(c)
 a	1
-a 	10
-b     	10
-c    	10
-d   	10
-e  	10
-f     	10
-g    	10
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
 h	10
-i     	10
+i	10
 select c,count(*) from t1 group by c limit 10;
 c	count(*)
 a	1

=== added file 'mysql-test/suite/innodb/r/innodb_bug11754376.result'
--- a/mysql-test/suite/innodb/r/innodb_bug11754376.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb_bug11754376.result	2012-02-06 11:00:41 +0000
@@ -0,0 +1,4 @@
+CREATE TABLE bug11754376 (c INT) ENGINE=INNODB;
+SET SESSION DEBUG='+d,test_normalize_table_name_low';
+DROP TABLE bug11754376;
+SET SESSION DEBUG='-d,test_normalize_table_name_low';

=== modified file 'mysql-test/suite/innodb/r/innodb_monitor.result'
--- a/mysql-test/suite/innodb/r/innodb_monitor.result	2011-11-20 20:25:39 +0000
+++ b/mysql-test/suite/innodb/r/innodb_monitor.result	2012-02-02 10:48:36 +0000
@@ -132,7 +132,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -336,7 +336,7 @@ trx_active_transactions	enabled
 trx_rseg_history_len	enabled
 trx_undo_slots_used	enabled
 trx_undo_slots_cached	enabled
-trx_rseg_curent_size	enabled
+trx_rseg_current_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
 purge_invoked	enabled
@@ -542,7 +542,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -746,7 +746,7 @@ trx_active_transactions	0	disabled
 trx_rseg_history_len	0	disabled
 trx_undo_slots_used	0	disabled
 trx_undo_slots_cached	0	disabled
-trx_rseg_curent_size	0	disabled
+trx_rseg_current_size	0	disabled
 purge_del_mark_records	0	disabled
 purge_upd_exist_or_extern_records	0	disabled
 purge_invoked	0	disabled
@@ -1004,7 +1004,7 @@ trx_active_transactions	enabled
 trx_rseg_history_len	enabled
 trx_undo_slots_used	enabled
 trx_undo_slots_cached	enabled
-trx_rseg_curent_size	enabled
+trx_rseg_current_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
 purge_invoked	enabled
@@ -1208,7 +1208,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -1412,7 +1412,7 @@ trx_active_transactions	enabled
 trx_rseg_history_len	enabled
 trx_undo_slots_used	enabled
 trx_undo_slots_cached	enabled
-trx_rseg_curent_size	enabled
+trx_rseg_current_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
 purge_invoked	enabled
@@ -1616,7 +1616,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -1820,7 +1820,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled

=== modified file 'mysql-test/suite/innodb/t/innodb-index.test'
--- a/mysql-test/suite/innodb/t/innodb-index.test	2011-11-20 21:00:25 +0000
+++ b/mysql-test/suite/innodb/t/innodb-index.test	2012-02-02 12:00:50 +0000
@@ -7,6 +7,12 @@ let $format=`select @@innodb_file_format
 set global innodb_file_per_table=on;
 set global innodb_file_format='Barracuda';
 
+# Bug#13654923 BOGUS DEBUG ASSERTION IN INDEX CREATION FOR ZERO-LENGTH RECORD
+create table t1(a varchar(2) primary key) engine=innodb;
+insert into t1 values('');
+create index t1a1 on t1(a(1));
+drop table t1;
+
 create table t1(a int not null, b int, c char(10) not null, d varchar(20)) engine = innodb;
 insert into t1 values (5,5,'oo','oo'),(4,4,'tr','tr'),(3,4,'ad','ad'),(2,3,'ak','ak');
 commit;

=== added file 'mysql-test/suite/innodb/t/innodb_bug11754376.test'
--- a/mysql-test/suite/innodb/t/innodb_bug11754376.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug11754376.test	2012-02-06 11:00:41 +0000
@@ -0,0 +1,16 @@
+#
+# Bug#11754376 45976: INNODB LOST FILES FOR TEMPORARY TABLES ON GRACEFUL SHUTDOWN
+#
+
+-- source include/have_debug.inc
+-- source include/have_innodb.inc
+
+CREATE TABLE bug11754376 (c INT) ENGINE=INNODB;
+
+# This will invoke test_normalize_table_name_low() in debug builds
+
+SET SESSION DEBUG='+d,test_normalize_table_name_low';
+
+DROP TABLE bug11754376;
+
+SET SESSION DEBUG='-d,test_normalize_table_name_low';

=== modified file 'mysql-test/suite/innodb/t/innodb_bug34300.test'
--- a/mysql-test/suite/innodb/t/innodb_bug34300.test	2011-11-20 21:00:25 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug34300.test	2012-02-02 10:27:45 +0000
@@ -5,12 +5,10 @@
 
 -- source include/have_innodb.inc
 
-# BLOB support is too slow for smaller page sizes.
-# Some PB2 platforms can get a long semephore wait.
--- source include/have_innodb_16k.inc
-
 -- disable_query_log
 -- disable_result_log
+
+call mtr.add_suppression("InnoDB: Warning: a long semaphore wait:");
 
 # set packet size and reconnect 
 let $max_packet=`select @@global.max_allowed_packet`;

=== modified file 'mysql-test/suite/opt_trace/r/eq_range_statistics.result'
--- a/mysql-test/suite/opt_trace/r/eq_range_statistics.result	2012-01-26 13:09:59 +0000
+++ b/mysql-test/suite/opt_trace/r/eq_range_statistics.result	2012-02-02 16:56:36 +0000
@@ -36,10 +36,17 @@ SET eq_range_index_dive_limit=3;
 SELECT @@eq_range_index_dive_limit;
 @@eq_range_index_dive_limit
 3
+SET SESSION DEBUG="+d,crash_records_in_range";
 # Index statistics kicks in, giving incorrect estimate of 3x2=6 records
 EXPLAIN SELECT * FROM t1 WHERE a IN (1,2,3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	range	a	a	5	NULL	6	Using where; Using index
+SELECT * FROM t1 WHERE a IN (1,2,3);
+a	b
+1	1
+2	2
+3	3
+SET SESSION DEBUG="-d,crash_records_in_range";
 #####
 # Below: A number of tests to verify that the number of equality ranges
 # are counted correctly
@@ -422,6 +429,7 @@ EXPLAIN SELECT * FROM t1 WHERE a=5 OR a>
 }	0	0
 
 # 3 equality ranges: should use index statistics
+SET SESSION DEBUG="+d,crash_records_in_range";
 EXPLAIN SELECT * FROM t1 WHERE a=5 AND (b=2 OR b=3 OR b=4);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	range	a	a	10	NULL	3	Using where; Using index
@@ -631,6 +639,7 @@ EXPLAIN SELECT * FROM t1 WHERE a=5 AND (
     }
   ] /* steps */
 }	0	0
+SET SESSION DEBUG="-d,crash_records_in_range";
 
 # 2 equality ranges: should not use index statistics
 EXPLAIN SELECT * FROM t1 WHERE a=5 AND (b=2 OR b=3 OR b>4);

=== modified file 'mysql-test/suite/opt_trace/t/eq_range_statistics.test'
--- a/mysql-test/suite/opt_trace/t/eq_range_statistics.test	2012-01-26 13:09:59 +0000
+++ b/mysql-test/suite/opt_trace/t/eq_range_statistics.test	2012-02-03 07:36:30 +0000
@@ -5,6 +5,7 @@
 #   predicate
 
 --source include/have_optimizer_trace.inc
+--source include/have_debug.inc
 
 SET optimizer_trace_max_mem_size=1048576; # 1MB
 SET optimizer_trace="enabled=on,end_marker=on,one_line=off";
@@ -38,8 +39,12 @@ EXPLAIN SELECT * FROM t1 WHERE a IN (1,2
 SET eq_range_index_dive_limit=3;
 SELECT @@eq_range_index_dive_limit;
 
+# Crash server if records_in_range() is called
+SET SESSION DEBUG="+d,crash_records_in_range";
 --echo # Index statistics kicks in, giving incorrect estimate of 3x2=6 records
 EXPLAIN SELECT * FROM t1 WHERE a IN (1,2,3);
+SELECT * FROM t1 WHERE a IN (1,2,3);
+SET SESSION DEBUG="-d,crash_records_in_range";
 
 --echo #####
 --echo # Below: A number of tests to verify that the number of equality ranges
@@ -53,15 +58,21 @@ EXPLAIN SELECT * FROM t1 WHERE a IN (1,2
 EXPLAIN SELECT * FROM t1 WHERE a=5 OR a>10 OR a IN (1);
 SELECT * FROM information_schema.OPTIMIZER_TRACE;
 
+# This query will use index statistics (as shown in trace) but
+# we cannot make it crash if records_in_range() is called
+# because the "a>10" range will correctly call records_in_range()
 --echo
 --echo # 3 equality ranges: should use index statistics
 EXPLAIN SELECT * FROM t1 WHERE a=5 OR a>10 OR a IN (1,2);
 SELECT * FROM information_schema.OPTIMIZER_TRACE;
 
+# Crash server if records_in_range() is called
 --echo
 --echo # 3 equality ranges: should use index statistics
+SET SESSION DEBUG="+d,crash_records_in_range";
 EXPLAIN SELECT * FROM t1 WHERE a=5 AND (b=2 OR b=3 OR b=4);
 SELECT * FROM information_schema.OPTIMIZER_TRACE;
+SET SESSION DEBUG="-d,crash_records_in_range";
 
 --echo
 --echo # 2 equality ranges: should not use index statistics

=== modified file 'mysql-test/suite/rpl/r/rpl_change_master.result'
--- a/mysql-test/suite/rpl/r/rpl_change_master.result	2011-11-19 08:08:03 +0000
+++ b/mysql-test/suite/rpl/r/rpl_change_master.result	2012-02-03 23:52:29 +0000
@@ -96,4 +96,27 @@ drop table t1;
 include/stop_slave.inc
 CHANGE MASTER TO master_host='SAVE_MASTER_HOST';
 include/start_slave.inc
+include/rpl_reset.inc
+include/stop_slave.inc
+CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='', MASTER_PORT=MASTER_PORT;
+ERROR HY000: Incorrect arguments to MASTER_HOST
+CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='127.0.0.1\n127.0.0.1', MASTER_PORT=MASTER_PORT;
+ERROR HY000: Incorrect argument contains not-allowed LF value: '127.0.0.1
+127.0.0.1'
+CHANGE MASTER TO MASTER_USER='root\n', MASTER_HOST='master2.mycompany.com', MASTER_PORT=MASTER_PORT, MASTER_USER='replication', MASTER_PASSWORD='bigs3cret', MASTER_LOG_FILE='master2-bin.001', MASTER_LOG_POS=4;
+ERROR HY000: Incorrect argument contains not-allowed LF value: 'root
+'
+CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='master2.mycompany.com', MASTER_PORT=MASTER_PORT, MASTER_USER='repli\ncation', MASTER_PASSWORD='bigs3cret', MASTER_LOG_FILE='master2-bin.001', MASTER_LOG_POS=4;
+ERROR HY000: Incorrect argument contains not-allowed LF value: 'repli
+cation'
+CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='master2.mycompany.com', MASTER_PORT=MASTER_PORT, MASTER_USER='replication', MASTER_PASSWORD='bigs3cret', MASTER_LOG_FILE='master2-bin.\n001', MASTER_LOG_POS=4;
+ERROR HY000: Incorrect argument contains not-allowed LF value: 'master2-bin.
+001'
+CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT;
+Warnings:
+Note	1756	Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note	1757	Storing MySQL user name or password information in the master.info repository is not secure and is therefore not recommended. Please see the MySQL Manual for more about this issue and possible alternatives.
+include/start_slave.inc
+Master_Host = '127.0.0.1'
+include/rpl_reset.inc
 include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/r/rpl_corruption.result'
--- a/mysql-test/suite/rpl/r/rpl_corruption.result	2011-11-19 08:08:03 +0000
+++ b/mysql-test/suite/rpl/r/rpl_corruption.result	2012-02-06 11:55:44 +0000
@@ -32,7 +32,7 @@ SET GLOBAL master_verify_checksum=1;
 # 5. Slave. Corruption in network
 SET GLOBAL debug="d,corrupt_queue_event";
 START SLAVE IO_THREAD;
-include/wait_for_slave_io_error.inc [errno=1595,1722]
+include/wait_for_slave_io_error.inc [errno=1595,1721]
 # 6. Slave. Corruption in relay log
 SET GLOBAL debug="d,corrupt_read_log_event_char";
 START SLAVE SQL_THREAD;

=== modified file 'mysql-test/suite/rpl/t/rpl_change_master.test'
--- a/mysql-test/suite/rpl/t/rpl_change_master.test	2010-12-19 17:25:42 +0000
+++ b/mysql-test/suite/rpl/t/rpl_change_master.test	2012-02-03 23:52:29 +0000
@@ -11,4 +11,51 @@
 
 --source include/master-slave.inc
 --source extra/rpl_tests/rpl_change_master.test
+
+
+# BUG#11758581 - 50801: CHANGE MASTER ACCEPTS BOGUS VARIABLES
+# We want to check if CHANGE MASTER values have newline characters.
+--source include/rpl_reset.inc
+connection slave;
+
+###
+### This should fail with error ER_WRONG_ARGUMENTS due to empty MASTER_HOST
+### value.
+###
+--source include/stop_slave.inc
+--replace_result $MASTER_MYPORT MASTER_PORT
+--error ER_WRONG_ARGUMENTS
+eval CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='', MASTER_PORT=$MASTER_MYPORT;
+
+###
+### This should fail with error ER_SYNTAX_ERROR due to newline
+### in string values.
+###
+--replace_result $MASTER_MYPORT MASTER_PORT
+--error ER_WRONG_VALUE
+eval CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='127.0.0.1\n127.0.0.1', MASTER_PORT=$MASTER_MYPORT;
+
+--replace_result $MASTER_MYPORT MASTER_PORT
+--error ER_WRONG_VALUE
+eval CHANGE MASTER TO MASTER_USER='root\n', MASTER_HOST='master2.mycompany.com', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='replication', MASTER_PASSWORD='bigs3cret', MASTER_LOG_FILE='master2-bin.001', MASTER_LOG_POS=4;
+
+--replace_result $MASTER_MYPORT MASTER_PORT
+--error ER_WRONG_VALUE
+eval CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='master2.mycompany.com', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='repli\ncation', MASTER_PASSWORD='bigs3cret', MASTER_LOG_FILE='master2-bin.001', MASTER_LOG_POS=4;
+
+--replace_result $MASTER_MYPORT MASTER_PORT
+--error ER_WRONG_VALUE
+eval CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='master2.mycompany.com', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='replication', MASTER_PASSWORD='bigs3cret', MASTER_LOG_FILE='master2-bin.\n001', MASTER_LOG_POS=4;
+
+###
+### This should be accepted.
+###
+--replace_result $MASTER_MYPORT MASTER_PORT
+eval CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT;
+
+--source include/start_slave.inc
+--let $status_items= Master_Host
+--source include/show_slave_status.inc
+--source include/rpl_reset.inc
+
 --source include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_corruption.test'
--- a/mysql-test/suite/rpl/t/rpl_corruption.test	2011-08-19 13:04:28 +0000
+++ b/mysql-test/suite/rpl/t/rpl_corruption.test	2012-02-06 11:55:44 +0000
@@ -102,7 +102,7 @@ SET GLOBAL master_verify_checksum=1;
 --connection slave
 SET GLOBAL debug="d,corrupt_queue_event";
 START SLAVE IO_THREAD;
-let $slave_io_errno= 1595,1722;
+let $slave_io_errno= 1595,1721;
 --source include/wait_for_slave_io_error.inc
 
 # Emulate corruption in relay log

=== modified file 'mysql-test/suite/sys_vars/r/innodb_monitor_disable_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_monitor_disable_basic.result	2011-11-20 20:25:39 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_monitor_disable_basic.result	2012-02-02 12:26:05 +0000
@@ -132,7 +132,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -336,7 +336,7 @@ trx_active_transactions	enabled
 trx_rseg_history_len	enabled
 trx_undo_slots_used	enabled
 trx_undo_slots_cached	enabled
-trx_rseg_curent_size	enabled
+trx_rseg_current_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
 purge_invoked	enabled
@@ -542,7 +542,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -746,7 +746,7 @@ trx_active_transactions	0	disabled
 trx_rseg_history_len	0	disabled
 trx_undo_slots_used	0	disabled
 trx_undo_slots_cached	0	disabled
-trx_rseg_curent_size	0	disabled
+trx_rseg_current_size	0	disabled
 purge_del_mark_records	0	disabled
 purge_upd_exist_or_extern_records	0	disabled
 purge_invoked	0	disabled
@@ -1004,7 +1004,7 @@ trx_active_transactions	enabled
 trx_rseg_history_len	enabled
 trx_undo_slots_used	enabled
 trx_undo_slots_cached	enabled
-trx_rseg_curent_size	enabled
+trx_rseg_current_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
 purge_invoked	enabled
@@ -1208,7 +1208,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -1412,7 +1412,7 @@ trx_active_transactions	enabled
 trx_rseg_history_len	enabled
 trx_undo_slots_used	enabled
 trx_undo_slots_cached	enabled
-trx_rseg_curent_size	enabled
+trx_rseg_current_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
 purge_invoked	enabled
@@ -1616,7 +1616,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -1820,7 +1820,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled

=== modified file 'mysql-test/suite/sys_vars/r/innodb_monitor_enable_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_monitor_enable_basic.result	2011-11-20 20:25:39 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_monitor_enable_basic.result	2012-02-02 12:26:05 +0000
@@ -132,7 +132,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -336,7 +336,7 @@ trx_active_transactions	enabled
 trx_rseg_history_len	enabled
 trx_undo_slots_used	enabled
 trx_undo_slots_cached	enabled
-trx_rseg_curent_size	enabled
+trx_rseg_current_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
 purge_invoked	enabled
@@ -542,7 +542,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -746,7 +746,7 @@ trx_active_transactions	0	disabled
 trx_rseg_history_len	0	disabled
 trx_undo_slots_used	0	disabled
 trx_undo_slots_cached	0	disabled
-trx_rseg_curent_size	0	disabled
+trx_rseg_current_size	0	disabled
 purge_del_mark_records	0	disabled
 purge_upd_exist_or_extern_records	0	disabled
 purge_invoked	0	disabled
@@ -1004,7 +1004,7 @@ trx_active_transactions	enabled
 trx_rseg_history_len	enabled
 trx_undo_slots_used	enabled
 trx_undo_slots_cached	enabled
-trx_rseg_curent_size	enabled
+trx_rseg_current_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
 purge_invoked	enabled
@@ -1208,7 +1208,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -1412,7 +1412,7 @@ trx_active_transactions	enabled
 trx_rseg_history_len	enabled
 trx_undo_slots_used	enabled
 trx_undo_slots_cached	enabled
-trx_rseg_curent_size	enabled
+trx_rseg_current_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
 purge_invoked	enabled
@@ -1616,7 +1616,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -1820,7 +1820,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled

=== modified file 'mysql-test/suite/sys_vars/r/innodb_monitor_reset_all_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_monitor_reset_all_basic.result	2011-11-20 20:25:39 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_monitor_reset_all_basic.result	2012-02-02 12:26:05 +0000
@@ -132,7 +132,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -336,7 +336,7 @@ trx_active_transactions	enabled
 trx_rseg_history_len	enabled
 trx_undo_slots_used	enabled
 trx_undo_slots_cached	enabled
-trx_rseg_curent_size	enabled
+trx_rseg_current_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
 purge_invoked	enabled
@@ -542,7 +542,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -746,7 +746,7 @@ trx_active_transactions	0	disabled
 trx_rseg_history_len	0	disabled
 trx_undo_slots_used	0	disabled
 trx_undo_slots_cached	0	disabled
-trx_rseg_curent_size	0	disabled
+trx_rseg_current_size	0	disabled
 purge_del_mark_records	0	disabled
 purge_upd_exist_or_extern_records	0	disabled
 purge_invoked	0	disabled
@@ -1004,7 +1004,7 @@ trx_active_transactions	enabled
 trx_rseg_history_len	enabled
 trx_undo_slots_used	enabled
 trx_undo_slots_cached	enabled
-trx_rseg_curent_size	enabled
+trx_rseg_current_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
 purge_invoked	enabled
@@ -1208,7 +1208,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -1412,7 +1412,7 @@ trx_active_transactions	enabled
 trx_rseg_history_len	enabled
 trx_undo_slots_used	enabled
 trx_undo_slots_cached	enabled
-trx_rseg_curent_size	enabled
+trx_rseg_current_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
 purge_invoked	enabled
@@ -1616,7 +1616,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -1820,7 +1820,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled

=== modified file 'mysql-test/suite/sys_vars/r/innodb_monitor_reset_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_monitor_reset_basic.result	2011-11-20 20:25:39 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_monitor_reset_basic.result	2012-02-02 12:26:05 +0000
@@ -132,7 +132,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -336,7 +336,7 @@ trx_active_transactions	enabled
 trx_rseg_history_len	enabled
 trx_undo_slots_used	enabled
 trx_undo_slots_cached	enabled
-trx_rseg_curent_size	enabled
+trx_rseg_current_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
 purge_invoked	enabled
@@ -542,7 +542,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -746,7 +746,7 @@ trx_active_transactions	0	disabled
 trx_rseg_history_len	0	disabled
 trx_undo_slots_used	0	disabled
 trx_undo_slots_cached	0	disabled
-trx_rseg_curent_size	0	disabled
+trx_rseg_current_size	0	disabled
 purge_del_mark_records	0	disabled
 purge_upd_exist_or_extern_records	0	disabled
 purge_invoked	0	disabled
@@ -1004,7 +1004,7 @@ trx_active_transactions	enabled
 trx_rseg_history_len	enabled
 trx_undo_slots_used	enabled
 trx_undo_slots_cached	enabled
-trx_rseg_curent_size	enabled
+trx_rseg_current_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
 purge_invoked	enabled
@@ -1208,7 +1208,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -1412,7 +1412,7 @@ trx_active_transactions	enabled
 trx_rseg_history_len	enabled
 trx_undo_slots_used	enabled
 trx_undo_slots_cached	enabled
-trx_rseg_curent_size	enabled
+trx_rseg_current_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
 purge_invoked	enabled
@@ -1616,7 +1616,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled
@@ -1820,7 +1820,7 @@ trx_active_transactions	disabled
 trx_rseg_history_len	disabled
 trx_undo_slots_used	disabled
 trx_undo_slots_cached	disabled
-trx_rseg_curent_size	disabled
+trx_rseg_current_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
 purge_invoked	disabled

=== added file 'mysql-test/t/eq_range_idx_stat.test'
--- a/mysql-test/t/eq_range_idx_stat.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/eq_range_idx_stat.test	2012-02-02 16:56:36 +0000
@@ -0,0 +1,101 @@
+# Tests for eq_range_index_dive_limit variable: 
+#   test that index dives are not done when index 
+#   statistics is requested
+
+--source include/have_debug.inc
+
+SET eq_range_index_dive_limit=default;
+SELECT @@eq_range_index_dive_limit;
+
+CREATE TABLE t1
+(
+  /* Field names reflect value(rowid) distribution, st=STairs, swt= SaWTooth */
+  st_a int,
+  swt1a int,
+  swt2a int,
+
+  st_b int,
+  swt1b int,
+  swt2b int,
+
+  key sta_swt12a(st_a,swt1a,swt2a),
+  key sta_swt1a(st_a,swt1a),
+  key sta_swt2a(st_a,swt2a),
+  key sta_swt21a(st_a,swt2a,swt1a),
+
+  key st_a(st_a),
+  key stb_swt1a_2b(st_b,swt1b,swt2a),
+  key stb_swt1b(st_b,swt1b),
+  key st_b(st_b)
+) ;
+
+ALTER TABLE t1 DISABLE KEYS;
+
+--disable_query_log
+--echo #
+--echo # Printing of many insert into t1 disabled.
+--echo #
+let $1=3;
+while ($1)
+{
+  let $2=3;
+  while ($2)
+  {
+    let $3=3;
+    while ($3)
+    {
+      let $equal_records=30;
+      while ($equal_records)
+      {
+        eval insert into t1 select $1, $2, $3, $1 ,$2, $3;
+        dec $equal_records;
+      }
+      dec $3;
+    }
+    dec $2;
+  }
+ dec $1;
+}
+--enable_query_log
+ALTER TABLE t1 ENABLE KEYS;
+ANALYZE TABLE t1;
+
+--echo #
+--echo # Run index_merge queries two times: 1) with index dives
+--echo #                                    2) with index statistics
+--echo #
+let $iterations=2;
+while ($iterations)
+{
+  dec $iterations;
+
+  --echo
+  explain 
+  select * from t1 
+  where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1 limit 5;
+
+  select * from t1 
+  where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1 limit 5;
+
+  --echo
+  explain 
+  select * from t1
+  where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 limit 5;
+
+  select * from t1
+  where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 limit 5;
+
+  --echo
+  explain 
+  select * from t1
+  where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1 limit 5;
+
+  select * from t1
+  where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1 limit 5;
+
+  --echo
+  SET eq_range_index_dive_limit=1;
+  SET SESSION DEBUG="+d,crash_records_in_range";
+}
+
+DROP TABLE t1;

=== modified file 'mysql-test/t/innodb_mysql_sync.test'
--- a/mysql-test/t/innodb_mysql_sync.test	2011-06-01 12:24:51 +0000
+++ b/mysql-test/t/innodb_mysql_sync.test	2012-02-08 13:10:23 +0000
@@ -304,6 +304,62 @@ DROP TABLE t1;
 disconnect con1;
 
 
+--echo #
+--echo # Bug#13417754 ASSERT IN ROW_DROP_DATABASE_FOR_MYSQL DURING DROP SCHEMA
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP DATABASE IF EXISTS db1;
+--enable_warnings
+
+CREATE TABLE t1(a int) engine=InnoDB;
+CREATE DATABASE db1;
+
+connect(con1, localhost, root);
+connect(con2, localhost, root);
+
+--echo # Connection con1
+connection con1;
+SET DEBUG_SYNC= 'after_innobase_rename_table SIGNAL locked WAIT_FOR continue';
+--echo # Sending:
+--send ALTER TABLE t1 RENAME db1.t1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # DROP DATABASE db1 should now be blocked by ALTER TABLE
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection default
+connection default;
+--echo # Check that DROP DATABASE is blocked by IX lock on db1
+let $wait_condition=
+  SELECT COUNT(*) = 1 FROM information_schema.processlist
+  WHERE state = "Waiting for schema metadata lock" and
+        info = "DROP DATABASE db1";
+--source include/wait_condition.inc
+--echo # Resume ALTER TABLE
+SET DEBUG_SYNC= 'now SIGNAL continue';
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping: ALTER TABLE t1 RENAME db1.t1;
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Connection default;
+connection default;
+SET DEBUG_SYNC= 'RESET';
+disconnect con1;
+disconnect con2;
+
+
 # Check that all connections opened by test cases in this file are really
 # gone so execution of other tests won't be affected by their presence.
 --source include/wait_until_count_sessions.inc

=== modified file 'mysql-test/t/join_outer.test'
--- a/mysql-test/t/join_outer.test	2012-01-03 11:04:14 +0000
+++ b/mysql-test/t/join_outer.test	2012-02-06 12:47:30 +0000
@@ -1489,3 +1489,19 @@ eval SELECT $rest_of_query;
 eval EXPLAIN SELECT $rest_of_query;
 
 drop table t1,t2,t3,t4,t5,t6;
+
+--echo #
+--echo # Bug#13464334 SAME QUERY PRODUCES DIFFERENT RESULTS WHEN USED WITH AND
+--echo # WITHOUT UNION ALL
+--echo #
+
+CREATE TABLE t1 (p1 INT PRIMARY KEY, a CHAR(1));
+CREATE TABLE t2 (p2 INT PRIMARY KEY, b CHAR(1));
+INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
+INSERT INTO t2 VALUES (1,'h'),(2,'i'),(3,'j'),(4,'k');
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE VIEW v2 AS SELECT * FROM t2;
+(SELECT p1 FROM v2 LEFT JOIN v1 ON b = a WHERE p2 = 1 GROUP BY p1 ORDER BY p1)
+UNION (SELECT NULL LIMIT 0);
+DROP VIEW v1, v2;
+DROP TABLE t1, t2;

=== modified file 'mysql-test/t/myisam.test'
--- a/mysql-test/t/myisam.test	2011-10-21 05:42:01 +0000
+++ b/mysql-test/t/myisam.test	2012-02-02 09:03:02 +0000
@@ -1665,6 +1665,20 @@ CHECK TABLE t1;
 DROP TABLE t1;
 SET GLOBAL myisam_use_mmap=default;
 
+--echo #
+--echo # BUG 11756869 - 48848: MYISAMCHK DOING SORT RECOVER IN CERTAIN
+--echo #                       CASES RESETS DATA POINTER TO SMAL
+--echo #
+CREATE TABLE t1(a INT, KEY(a));
+ALTER TABLE t1 DISABLE KEYS;
+let $MYSQLD_DATADIR= `select @@datadir`;
+SET @before:= (SELECT MAX_DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test');
+FLUSH TABLES;
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+--exec $MYISAMCHK -sn $MYSQLD_DATADIR/test/t1
+SET @after:= (SELECT MAX_DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test');
+SELECT @before=@after;
+DROP TABLE t1;
 --echo End of 5.1 tests
 
 --echo #

=== modified file 'mysql-test/t/optimizer_debug_sync.test'
--- a/mysql-test/t/optimizer_debug_sync.test	2012-01-31 06:42:46 +0000
+++ b/mysql-test/t/optimizer_debug_sync.test	2012-02-01 08:32:05 +0000
@@ -4,6 +4,7 @@
 --source include/have_debug_sync.inc
 --source include/have_innodb.inc
 --source include/have_materialization.inc
+--source include/not_embedded.inc
 
 --echo
 --echo BUG#11763382 Assertion 'inited==INDEX' on SELECT MAX(...)
@@ -54,9 +55,12 @@ SET DEBUG_SYNC='RESET';
 --connection con3
 --reap
 
+--connection default
 DROP TABLE t;
+--disconnect con1
+--disconnect con2
+--disconnect con3
 
---exit
 
 --echo # End of BUG#56080
 --echo #

=== modified file 'mysql-test/t/type_temporal_fractional.test'
--- a/mysql-test/t/type_temporal_fractional.test	2012-01-31 15:16:16 +0000
+++ b/mysql-test/t/type_temporal_fractional.test	2012-02-02 10:58:18 +0000
@@ -7610,5 +7610,29 @@ SELECT 1 FROM t1 WHERE (SELECT a FROM t1
 DROP TABLE t1;
 
 
+--echo #
+--echo # BUG#13616434 ASSERTION FAILED: NANOSECONDS < 1000000000
+--echo #
+SELECT
+  EXTRACT(DAY FROM (-0.1111111111)),
+  EXTRACT(YEAR FROM (-0.1111111)),
+  EXTRACT(YEAR_MONTH FROM (-0.1111111111)),
+  EXTRACT(DAY FROM (-0.1111111)),
+  EXTRACT(QUARTER FROM (-0.1111111111)),
+  EXTRACT(MONTH FROM (-0.1111111)),
+  EXTRACT(WEEK FROM (-0.1111111)),
+  DATE(-0.1111111),
+  QUARTER(-0.1111111111),
+  TIMESTAMP(-0.1111111111),
+  LAST_DAY(-0.1111111111),
+  DAY(-0.1111111111),
+  MONTH(-0.1111111111),
+  YEAR(-0.1111111),
+  DAYOFMONTH(-0.1111111111),
+  TIMESTAMP((-0.1111111111),'{$x'),
+  DATE_FORMAT(-0.1111111111,'+'),
+  CONVERT(-0.1111111,DATE),
+  CAST(-0.1111111111 AS DATE);
+
 
 --echo # End of 5.6 tests

=== modified file 'mysql-test/valgrind.supp'
--- a/mysql-test/valgrind.supp	2012-01-29 00:57:40 +0000
+++ b/mysql-test/valgrind.supp	2012-02-07 11:56:30 +0000
@@ -985,7 +985,7 @@
    ...
    fun:my_b_flush_io_cache
    fun:_my_b_write
-   fun:_Z*10write_keysP10Sort_paramPPhjP11st_io_cacheS4_
+   fun:_Z*10write_keysP10Sort_paramP13Filesort_infojP11st_io_cacheS4_
    fun:_Z*13find_all_keysP10Sort_paramP10SQL_SELECTP13Filesort_infoP11st_io_cacheS6_P13Bounded_queueIhhEPy
    fun:_Z8filesortP3THDP5TABLEP13st_sort_fieldjP10SQL_SELECTybPyS7_
 }
@@ -1022,6 +1022,6 @@
    ...
    fun:my_b_flush_io_cache
    fun:_my_b_write
-   fun:_Z*10write_keysP10Sort_paramPPhjP11st_io_cacheS4_
+   fun:_Z*10write_keysP10Sort_paramP13Filesort_infojP11st_io_cacheS4_
    fun:_Z8filesortP3THDP5TABLEP13st_sort_fieldjP10SQL_SELECTybPyS7_
 }

=== modified file 'mysys/mf_radix.c'
--- a/mysys/mf_radix.c	2011-06-30 15:50:45 +0000
+++ b/mysys/mf_radix.c	2012-02-07 11:56:30 +0000
@@ -25,6 +25,11 @@
 
 	/* Radixsort */
 
+my_bool radixsort_is_appliccable(uint n_items, size_t size_of_element)
+{
+  return size_of_element <= 20 && n_items >= 1000 && n_items < 100000;
+}
+
 void radixsort_for_str_ptr(uchar **base, uint number_of_elements, size_t size_of_element, uchar **buffer)
 {
   uchar **end,**ptr,**buffer_ptr;

=== modified file 'mysys/mf_sort.c'
--- a/mysys/mf_sort.c	2011-06-30 15:46:53 +0000
+++ b/mysys/mf_sort.c	2012-02-07 11:56:30 +0000
@@ -23,7 +23,7 @@ void my_string_ptr_sort(uchar *base, uin
 #if INT_MAX > 65536L
   uchar **ptr=0;
 
-  if (size <= 20 && items >= 1000 && items < 100000 &&
+  if (radixsort_is_appliccable(items, size) &&
       (ptr= (uchar**) my_malloc(items*sizeof(char*),MYF(0))))
   {
     radixsort_for_str_ptr((uchar**) base,items,size,ptr);

=== modified file 'sql/filesort.cc'
--- a/sql/filesort.cc	2012-01-18 14:42:16 +0000
+++ b/sql/filesort.cc	2012-02-07 11:56:30 +0000
@@ -52,7 +52,7 @@ static ha_rows find_all_keys(Sort_param 
                              IO_CACHE *tempfile,
                              Bounded_queue<uchar, uchar> *pq,
                              ha_rows *found_rows);
-static int write_keys(Sort_param *param,uchar * *sort_keys,
+static int write_keys(Sort_param *param, Filesort_info *fs_info,
                       uint count, IO_CACHE *buffer_file, IO_CACHE *tempfile);
 static void make_sortkey(Sort_param *param,uchar *to, uchar *ref_pos);
 static void register_used_fields(Sort_param *param);
@@ -60,7 +60,7 @@ static int merge_index(Sort_param *param
                        BUFFPEK *buffpek,
                        uint maxbuffer,IO_CACHE *tempfile,
                        IO_CACHE *outfile);
-static bool save_index(Sort_param *param,uchar **sort_keys, uint count, 
+static bool save_index(Sort_param *param, uint count,
                        Filesort_info *table_sort);
 static uint suffix_length(ulong string_length);
 static uint sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length,
@@ -346,8 +346,7 @@ ha_rows filesort(THD *thd, TABLE *table,
 
   if (maxbuffer == 0)			// The whole set is in memory
   {
-    if (save_index(&param, table_sort.get_sort_keys(),
-                   (uint) num_rows, &table_sort))
+    if (save_index(&param, (uint) num_rows, &table_sort))
       goto err;
   }
   else
@@ -742,8 +741,7 @@ static ha_rows find_all_keys(Sort_param 
       {
         if (idx == param->max_keys_per_buffer)
         {
-          if (write_keys(param, fs_info->get_sort_keys(),
-                         idx, buffpek_pointers, tempfile))
+          if (write_keys(param, fs_info, idx, buffpek_pointers, tempfile))
              DBUG_RETURN(HA_POS_ERROR);
           idx= 0;
           indexpos++;
@@ -777,8 +775,7 @@ static ha_rows find_all_keys(Sort_param 
     DBUG_RETURN(HA_POS_ERROR);			/* purecov: inspected */
   }
   if (indexpos && idx &&
-      write_keys(param, fs_info->get_sort_keys(),
-                 idx, buffpek_pointers, tempfile))
+      write_keys(param, fs_info, idx, buffpek_pointers, tempfile))
     DBUG_RETURN(HA_POS_ERROR);			/* purecov: inspected */
   const ha_rows retval= 
     my_b_inited(tempfile) ?
@@ -811,21 +808,19 @@ static ha_rows find_all_keys(Sort_param 
 */
 
 static int
-write_keys(Sort_param *param, register uchar **sort_keys, uint count,
+write_keys(Sort_param *param, Filesort_info *fs_info, uint count,
            IO_CACHE *buffpek_pointers, IO_CACHE *tempfile)
 {
-  size_t sort_length, rec_length;
+  size_t rec_length;
   uchar **end;
   BUFFPEK buffpek;
   DBUG_ENTER("write_keys");
 
-  sort_length= param->sort_length;
   rec_length= param->rec_length;
-#ifdef MC68000
-  quicksort(sort_keys,count,sort_length);
-#else
-  my_string_ptr_sort((uchar*) sort_keys, (uint) count, sort_length);
-#endif
+  uchar **sort_keys= fs_info->get_sort_keys();
+
+  fs_info->sort_buffer(param, count);
+
   if (!my_b_inited(tempfile) &&
       open_cached_file(tempfile, mysql_tmpdir, TEMP_PREFIX, DISK_BUFFER_SIZE,
                        MYF(MY_WME)))
@@ -1157,20 +1152,19 @@ static void register_used_fields(Sort_pa
   }
 }
 
-
-static bool save_index(Sort_param *param, uchar **sort_keys, uint count, 
-                       Filesort_info *table_sort)
+static bool save_index(Sort_param *param, uint count, Filesort_info *table_sort)
 {
   uint offset,res_length;
   uchar *to;
   DBUG_ENTER("save_index");
 
-  my_string_ptr_sort((uchar*) sort_keys, count, param->sort_length);
+  table_sort->sort_buffer(param, count);
   res_length= param->res_length;
   offset= param->rec_length-res_length;
   if (!(to= table_sort->record_pointers= 
         (uchar*) my_malloc(res_length*count, MYF(MY_WME))))
     DBUG_RETURN(1);                 /* purecov: inspected */
+  uchar **sort_keys= table_sort->get_sort_keys();
   for (uchar **end= sort_keys+count ; sort_keys != end ; sort_keys++)
   {
     memcpy(to, *sort_keys+offset, res_length);

=== modified file 'sql/filesort_utils.cc'
--- a/sql/filesort_utils.cc	2011-11-07 15:32:36 +0000
+++ b/sql/filesort_utils.cc	2012-02-07 11:56:30 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 
+/* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. 
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -18,6 +18,9 @@
 #include "sql_sort.h"
 #include "table.h"
 
+#include <algorithm>
+#include <functional>
+#include <vector>
 
 namespace {
 /**
@@ -115,4 +118,85 @@ void Filesort_buffer::free_sort_buffer()
   m_idx_array= Idx_array();
   m_record_length= 0;
   m_start_of_data= NULL;
+}
+
+
+namespace {
+
+/*
+  An inline function which does memcmp().
+  This one turns out to be pretty fast on all platforms, except sparc.
+  See the accompanying unit tests, which measure various implementations.
+ */
+inline bool my_mem_compare(const uchar *s1, const uchar *s2, size_t len)
+{
+  DBUG_ASSERT(len > 0);
+  DBUG_ASSERT(s1 != NULL);
+  DBUG_ASSERT(s2 != NULL);
+  do {
+    if (*s1++ != *s2++)
+      return *--s1 < *--s2;
+  } while (--len != 0);
+  return false;
+}
+
+
+class Mem_compare :
+  public std::binary_function<const uchar*, const uchar*, bool>
+{
+public:
+  Mem_compare(size_t n) : m_size(n) {}
+  bool operator()(const uchar *s1, const uchar *s2) const
+  {
+#ifdef __sun
+    // Usually faster on SUN, see comment for native_compare()
+    return memcmp(s1, s2, m_size) < 0;
+#else
+    return my_mem_compare(s1, s2, m_size);
+#endif
+  }
+private:
+  size_t m_size;
+};
+
+template <typename type>
+size_t try_reserve(std::pair<type*, ptrdiff_t> *buf, ptrdiff_t size)
+{
+  *buf= std::get_temporary_buffer<type>(size);
+  if (buf->second != size)
+  {
+    std::return_temporary_buffer(buf->first);
+    return 0;
+  }
+  return buf->second;
+}
+
+} // namespace
+
+void Filesort_buffer::sort_buffer(const Sort_param *param, uint count)
+{
+  if (count <= 1)
+    return;
+  uchar **keys= get_sort_keys();
+  std::pair<uchar**, ptrdiff_t> buffer;
+  if (radixsort_is_appliccable(count, param->sort_length) &&
+      try_reserve(&buffer, count))
+  {
+    radixsort_for_str_ptr(keys, count, param->sort_length, buffer.first);
+    std::return_temporary_buffer(buffer.first);
+    return;
+  }
+  /*
+    std::stable_sort has some extra overhead in allocating the temp buffer,
+    which takes some time. The cutover point where it starts to get faster
+    than quicksort seems to be somewhere around 10 to 40 records.
+    So we're a bit conservative, and stay with quicksort up to 100 records.
+  */
+  if (count < 100)
+  {
+    size_t size= param->sort_length;
+    my_qsort2(keys, count, sizeof(uchar*), get_ptr_compare(size), &size);
+    return;
+  }
+  std::stable_sort(keys, keys + count, Mem_compare(param->sort_length));
 }

=== modified file 'sql/filesort_utils.h'
--- a/sql/filesort_utils.h	2012-01-18 14:42:16 +0000
+++ b/sql/filesort_utils.h	2012-02-07 11:56:30 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -22,6 +22,7 @@
 
 #include <utility>
 
+class Sort_param;
 /*
   Calculate cost of merge sort
 
@@ -64,6 +65,9 @@ public:
   Filesort_buffer() :
     m_idx_array(), m_record_length(0), m_start_of_data(NULL)
   {}
+
+  /** Sort me... */
+  void sort_buffer(const Sort_param *param, uint count);
 
   /// Initializes a record pointer.
   uchar *get_record_buffer(uint idx)

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2012-01-31 07:45:59 +0000
+++ b/sql/handler.cc	2012-02-02 16:56:36 +0000
@@ -4616,6 +4616,7 @@ handler::multi_range_read_info_const(uin
       rows= table->key_info[keyno].rec_per_key[keyparts_used-1];
     else
     {
+      DBUG_EXECUTE_IF("crash_records_in_range", DBUG_SUICIDE(););
       if (HA_POS_ERROR == (rows= this->records_in_range(keyno, min_endp, 
                                                         max_endp)))
       {

=== modified file 'sql/item.h'
--- a/sql/item.h	2012-01-31 15:16:16 +0000
+++ b/sql/item.h	2012-02-08 10:33:37 +0000
@@ -1045,6 +1045,8 @@ public:
   /* 
     Returns true if this is constant (during query execution, i.e. its value
     will not change until next fix_fields) and its value is known.
+    When the default implementation of used_tables() is effective, this
+    function will always return true (because used_tables() is empty).
   */
   virtual bool const_item() const { return used_tables() == 0; }
   /* 
@@ -1548,10 +1550,7 @@ public:
   bool is_null();
 
 public:
-  inline void make_field(Send_field *field);
-  
-  inline bool const_item() const;
-  
+  inline void make_field(Send_field *field);  
   inline int save_in_field(Field *field, bool no_conversions);
   inline bool send(Protocol *protocol, String *str);
 }; 
@@ -1571,11 +1570,6 @@ inline void Item_sp_variable::make_field
   it->make_field(field);
 }
 
-inline bool Item_sp_variable::const_item() const
-{
-  return TRUE;
-}
-
 inline int Item_sp_variable::save_in_field(Field *field, bool no_conversions)
 {
   return this_item()->save_in_field(field, no_conversions);
@@ -1767,11 +1761,6 @@ public:
     return value_item->result_type();
   }
 
-  bool const_item() const
-  {
-    return TRUE;
-  }
-
   int save_in_field(Field *field, bool no_conversions)
   {
     return  value_item->save_in_field(field, no_conversions);
@@ -2034,7 +2023,8 @@ public:
   bool is_outer_field() const
   {
     DBUG_ASSERT(fixed);
-    return field->table->pos_in_table_list->outer_join;
+    return field->table->pos_in_table_list->outer_join ||
+           field->table->pos_in_table_list->in_outer_join_nest();
   }
   Field::geometry_type get_geometry_type() const
   {
@@ -2922,7 +2912,16 @@ public:
       (*ref)->update_used_tables(); 
   }
   virtual table_map resolved_used_tables() const;
-  table_map not_null_tables() const { return (*ref)->not_null_tables(); }
+  table_map not_null_tables() const
+  {
+    /*
+      It can happen that our 'depended_from' member is set but the
+      'depended_from' member of the referenced item is not (example: if a
+      field in a subquery belongs to an outer merged view), so we first test
+      ours:
+    */
+    return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->not_null_tables();
+  }
   void set_result_field(Field *field)	{ result_field= field; }
   bool is_result_field() { return 1; }
   void save_in_result_field(bool no_conversions)

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2012-01-25 09:57:22 +0000
+++ b/sql/item_cmpfunc.cc	2012-02-08 10:33:37 +0000
@@ -4722,8 +4722,7 @@ longlong Item_func_bit_and::val_int()
 
 Item_cond::Item_cond(THD *thd, Item_cond *item)
   :Item_bool_func(thd, item),
-   abort_on_null(item->abort_on_null),
-   and_tables_cache(item->and_tables_cache)
+   abort_on_null(item->abort_on_null)
 {
   /*
     item->list will be copied by copy_andor_arguments() call
@@ -4748,16 +4747,16 @@ Item_cond::fix_fields(THD *thd, Item **r
   st_select_lex::Resolve_place save_resolve=
     thd->lex->current_select->resolve_place;
   uchar buff[sizeof(char*)];			// Max local vars in function
-  not_null_tables_cache= used_tables_cache= 0;
-  const_item_cache= 1;
+  used_tables_cache= 0;
+  const_item_cache= true;
 
   if (functype() != COND_AND_FUNC)
     thd->lex->current_select->resolve_place= st_select_lex::RESOLVE_NONE;
-  /*
-    and_table_cache is the value that Item_cond_or() returns for
-    not_null_tables()
-  */
-  and_tables_cache= ~(table_map) 0;
+
+  if (functype() == COND_AND_FUNC && abort_on_null)
+    not_null_tables_cache= 0;
+  else
+    not_null_tables_cache= ~(table_map) 0;
 
   if (check_stack_overrun(thd, STACK_MIN_SIZE, buff))
     return TRUE;				// Fatal error flag is set!
@@ -4778,7 +4777,6 @@ Item_cond::fix_fields(THD *thd, Item **r
   */
   while ((item=li++))
   {
-    table_map tmp_table_map;
     while (item->type() == Item::COND_ITEM &&
 	   ((Item_cond*) item)->functype() == functype() &&
            !((Item_cond*) item)->list.is_empty())
@@ -4795,26 +4793,26 @@ Item_cond::fix_fields(THD *thd, Item **r
 	 item->fix_fields(thd, li.ref())) ||
 	(item= *li.ref())->check_cols(1))
       return TRUE; /* purecov: inspected */
-    used_tables_cache|=     item->used_tables();
-    if (item->const_item())
-      and_tables_cache= (table_map) 0;
+    used_tables_cache|= item->used_tables();
+    const_item_cache&=  item->const_item();
+
+    // Old code assumed that not_null_tables() was 0 when const_item() was true
+    DBUG_ASSERT(!item->const_item() || !item->not_null_tables());
+
+    if (functype() == COND_AND_FUNC && abort_on_null)
+      not_null_tables_cache|= item->not_null_tables();
     else
-    {
-      tmp_table_map= item->not_null_tables();
-      not_null_tables_cache|= tmp_table_map;
-      and_tables_cache&= tmp_table_map;
-      const_item_cache= FALSE;
-    }  
-    with_sum_func=	    with_sum_func || item->with_sum_func;
-    with_subselect|=        item->has_subquery();
+      not_null_tables_cache&= item->not_null_tables();
+    with_sum_func|=  item->with_sum_func;
+    with_subselect|= item->has_subquery();
     if (item->maybe_null)
-      maybe_null=1;
+      maybe_null= true;
   }
   thd->lex->current_select->cond_count+= list.elements;
   thd->lex->current_select->resolve_place= save_resolve;
   fix_length_and_dec();
-  fixed= 1;
-  return FALSE;
+  fixed= true;
+  return false;
 }
 
 
@@ -4825,29 +4823,24 @@ void Item_cond::fix_after_pullout(st_sel
   List_iterator<Item> li(list);
   Item *item;
 
-  used_tables_cache=0;
-  const_item_cache=1;
+  used_tables_cache= 0;
+  const_item_cache= true;
 
-  and_tables_cache= ~(table_map) 0; // Here and below we do as fix_fields does
-  not_null_tables_cache= 0;
+  if (functype() == COND_AND_FUNC && abort_on_null)
+    not_null_tables_cache= 0;
+  else
+    not_null_tables_cache= ~(table_map) 0;
 
   while ((item=li++))
   {
-    table_map tmp_table_map;
     item->fix_after_pullout(parent_select, removed_select, li.ref());
     item= *li.ref();
     used_tables_cache|= item->used_tables();
     const_item_cache&= item->const_item();
-
-    if (item->const_item())
-      and_tables_cache= (table_map) 0;
+    if (functype() == COND_AND_FUNC && abort_on_null)
+      not_null_tables_cache|= item->not_null_tables();
     else
-    {
-      tmp_table_map= item->not_null_tables();
-      not_null_tables_cache|= tmp_table_map;
-      and_tables_cache&= tmp_table_map;
-      const_item_cache= FALSE;
-    }  
+      not_null_tables_cache&= item->not_null_tables();
   }
 }
 
@@ -5000,13 +4993,6 @@ void Item_cond::split_sum_func(THD *thd,
   Item *item;
   while ((item= li++))
     item->split_sum_func2(thd, ref_pointer_array, fields, li.ref(), TRUE);
-}
-
-
-table_map
-Item_cond::used_tables() const
-{						// This caches used_tables
-  return used_tables_cache;
 }
 
 

=== modified file 'sql/item_cmpfunc.h'
--- a/sql/item_cmpfunc.h	2012-01-30 06:39:02 +0000
+++ b/sql/item_cmpfunc.h	2012-02-08 10:33:37 +0000
@@ -1596,7 +1596,6 @@ class Item_cond :public Item_bool_func
 protected:
   List<Item> list;
   bool abort_on_null;
-  table_map and_tables_cache;
 
 public:
   /* Item_cond() is only used to create top level items */
@@ -1632,7 +1631,7 @@ public:
 
   enum Type type() const { return COND_ITEM; }
   List<Item>* argument_list() { return &list; }
-  table_map used_tables() const;
+  table_map used_tables() const { return used_tables_cache; }
   void update_used_tables();
   virtual void print(String *str, enum_query_type query_type);
   void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array,
@@ -1821,8 +1820,6 @@ public:
   enum Functype functype() const { return COND_AND_FUNC; }
   longlong val_int();
   const char *func_name() const { return "and"; }
-  table_map not_null_tables() const
-  { return abort_on_null ? not_null_tables_cache: and_tables_cache; }
   Item* copy_andor_structure(THD *thd)
   {
     Item_cond_and *item;
@@ -1852,7 +1849,6 @@ public:
   enum Functype functype() const { return COND_OR_FUNC; }
   longlong val_int();
   const char *func_name() const { return "or"; }
-  table_map not_null_tables() const { return and_tables_cache; }
   Item* copy_andor_structure(THD *thd)
   {
     Item_cond_or *item;

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2012-01-31 15:16:16 +0000
+++ b/sql/log_event.cc	2012-02-07 23:33:54 +0000
@@ -4316,11 +4316,11 @@ int Query_log_event::do_apply_event(Rela
         nothing to do.
       */
       /*
-        We do not replicate IGNORE_DIR_IN_CREATE. That is, if the master is a
-        slave which runs with SQL_MODE=IGNORE_DIR_IN_CREATE, this should not
+        We do not replicate MODE_NO_DIR_IN_CREATE. That is, if the master is a
+        slave which runs with SQL_MODE=MODE_NO_DIR_IN_CREATE, this should not
         force us to ignore the dir too. Imagine you are a ring of machines, and
         one has a disk problem so that you temporarily need
-        IGNORE_DIR_IN_CREATE on this machine; you don't want it to propagate
+        MODE_NO_DIR_IN_CREATE on this machine; you don't want it to propagate
         elsewhere (you don't want all slaves to start ignoring the dirs).
       */
       if (sql_mode_inited)

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	2012-01-31 07:45:59 +0000
+++ b/sql/opt_range.cc	2012-02-09 09:09:58 +0000
@@ -4654,22 +4654,26 @@ void ror_intersect_cpy(ROR_INTERSECT_INF
 
 
 /*
-  Get selectivity of a ROR scan wrt ROR-intersection.
+  Get selectivity of adding a ROR scan to the ROR-intersection.
 
   SYNOPSIS
     ror_scan_selectivity()
-      info  ROR-interection 
-      scan  ROR scan
+      info  ROR-interection, an intersection of ROR index scans 
+      scan  ROR scan that may or may not improve the selectivity
+            of 'info'
       
   NOTES
-    Suppose we have a condition on several keys
-    cond=k_11=c_11 AND k_12=c_12 AND ...  // parts of first key
-         k_21=c_21 AND k_22=c_22 AND ...  // parts of second key
+    Suppose we have conditions on several keys
+    cond=k_11=c_11 AND k_12=c_12 AND ...  // key_parts of first key in 'info'
+         k_21=c_21 AND k_22=c_22 AND ...  // key_parts of second key in 'info'
           ...
-         k_n1=c_n1 AND k_n3=c_n3 AND ...  (1) //parts of the key used by *scan
+         k_n1=c_n1 AND k_n3=c_n3 AND ...  (1) //key_parts of 'scan'
 
     where k_ij may be the same as any k_pq (i.e. keys may have common parts).
 
+    Note that for ROR retrieval, only equality conditions are usable so there
+    are no open ranges (e.g., k_ij > c_ij) in 'scan' or 'info'
+
     A full row is retrieved if entire condition holds.
 
     The recursive procedure for finding P(cond) is as follows:
@@ -4736,19 +4740,30 @@ void ror_intersect_cpy(ROR_INTERSECT_INF
 
     where i1,i2, .. are key parts that were already marked as fixed.
 
-    In order to minimize number of expensive records_in_range calls we group
-    and reduce adjacent fractions.
+    In order to minimize number of expensive records_in_range calls we
+    group and reduce adjacent fractions. Note that on the optimizer's
+    request, index statistics may be used instead of records_in_range
+    @see RANGE_OPT_PARAM::use_index_statistics.
 
   RETURN
-    Selectivity of given ROR scan.
+    Selectivity of given ROR scan, a number between 0 and 1. 1 means that
+    adding 'scan' to the intersection does not improve the selectivity.
 */
 
 static double ror_scan_selectivity(const ROR_INTERSECT_INFO *info, 
                                    const ROR_SCAN_INFO *scan)
 {
   double selectivity_mult= 1.0;
-  KEY_PART_INFO *key_part= info->param->table->key_info[scan->keynr].key_part;
-  uchar key_val[MAX_KEY_LENGTH+MAX_FIELD_WIDTH]; /* key values tuple */
+  const TABLE * const table= info->param->table;
+  const KEY_PART_INFO * const key_part= table->key_info[scan->keynr].key_part;
+  /**
+    key values tuple, used to store both min_range.key and
+    max_range.key. This function is only called for equality ranges;
+    open ranges (e.g. "min_value < X < max_value") cannot be used for
+    rowid ordered retrieval, so in this function we know that
+    min_range.key == max_range.key
+  */
+  uchar key_val[MAX_KEY_LENGTH+MAX_FIELD_WIDTH];
   uchar *key_ptr= key_val;
   SEL_ARG *sel_arg, *tuple_arg= NULL;
   key_part_map keypart_map= 0;
@@ -4761,7 +4776,7 @@ static double ror_scan_selectivity(const
   min_range.flag= HA_READ_KEY_EXACT;
   max_range.key= key_val;
   max_range.flag= HA_READ_AFTER_KEY;
-  ha_rows prev_records= info->param->table->file->stats.records;
+  ha_rows prev_records= table->file->stats.records;
   DBUG_ENTER("ror_scan_selectivity");
 
   for (sel_arg= scan->sel_arg; sel_arg;
@@ -4773,12 +4788,14 @@ static double ror_scan_selectivity(const
     if (cur_covered != prev_covered)
     {
       /* create (part1val, ..., part{n-1}val) tuple. */
+      bool is_null_range= false;
       ha_rows records;
       if (!tuple_arg)
       {
         tuple_arg= scan->sel_arg;
         /* Here we use the length of the first key part */
-        tuple_arg->store_min(key_part->store_length, &key_ptr, 0);
+        tuple_arg->store_min(key_part[0].store_length, &key_ptr, 0);
+        is_null_range|= tuple_arg->is_null_interval();
         keypart_map= 1;
       }
       while (tuple_arg->next_key_part != sel_arg)
@@ -4786,12 +4803,33 @@ static double ror_scan_selectivity(const
         tuple_arg= tuple_arg->next_key_part;
         tuple_arg->store_min(key_part[tuple_arg->part].store_length,
                              &key_ptr, 0);
+        is_null_range|= tuple_arg->is_null_interval();
         keypart_map= (keypart_map << 1) | 1;
       }
       min_range.length= max_range.length= (size_t) (key_ptr - key_val);
       min_range.keypart_map= max_range.keypart_map= keypart_map;
-      records= (info->param->table->file->
-                records_in_range(scan->keynr, &min_range, &max_range));
+
+      /* 
+        Get the number of rows in this range. This is done by calling
+        records_in_range() unless all these are true:
+          1) The user has requested that index statistics should be used
+             for equality ranges to avoid the incurred overhead of 
+             index dives in records_in_range()
+          2) The range is not on the form "x IS NULL". The reason is
+             that the number of rows with this value are likely to be
+             very different than the values in the index statistics
+          3) Index statistics is available.
+        @see key_val
+      */
+      if (!info->param->use_index_statistics ||        // (1)
+          is_null_range ||                             // (2)
+          !(records= table->key_info[scan->keynr].
+                     rec_per_key[tuple_arg->part]))    // (3)
+      {
+        DBUG_EXECUTE_IF("crash_records_in_range", DBUG_SUICIDE(););
+        records= (table->file->
+                  records_in_range(scan->keynr, &min_range, &max_range));
+      }
       if (cur_covered)
       {
         /* uncovered -> covered */
@@ -4810,11 +4848,13 @@ static double ror_scan_selectivity(const
   }
   if (!prev_covered)
   {
-    double tmp= rows2double(info->param->table->quick_rows[scan->keynr]) /
+    double tmp= rows2double(table->quick_rows[scan->keynr]) /
                 rows2double(prev_records);
     DBUG_PRINT("info", ("Selectivity multiplier: %g", tmp));
     selectivity_mult *= tmp;
   }
+  // Todo: This assert fires in PB sysqa RQG tests.
+  // DBUG_ASSERT(selectivity_mult <= 1.0);
   DBUG_PRINT("info", ("Returning multiplier: %g", selectivity_mult));
   DBUG_RETURN(selectivity_mult);
 }
@@ -7267,9 +7307,13 @@ get_range(SEL_ARG **e1,SEL_ARG **e2,SEL_
    ( 1  <  kp1 <= 2 AND 1 < kp2 < 10 ) OR
    ( 2  <  kp1 < 10 AND 1 < kp2 < 20 ) OR
    ( 10 <= kp1 < 20 AND 4 < kp2 < 20 )
+
+   @param param    PARAM from SQL_SELECT::test_quick_select
+   @param key1     Root of RB-tree of SEL_ARGs to be ORed with key2
+   @param key2     Root of RB-tree of SEL_ARGs to be ORed with key1
 */
 static SEL_ARG *
-key_or(RANGE_OPT_PARAM *param, SEL_ARG *key1,SEL_ARG *key2)
+key_or(RANGE_OPT_PARAM *param, SEL_ARG *key1, SEL_ARG *key2)
 {
   if (!key1)
   {
@@ -7322,8 +7366,8 @@ key_or(RANGE_OPT_PARAM *param, SEL_ARG *
   }
 
   // Add tree at key2 to tree at key1
-  bool key2_shared=key2->use_count != 0;
-  key1->maybe_flag|=key2->maybe_flag;
+  const bool key2_shared= (key2->use_count != 0);
+  key1->maybe_flag|= key2->maybe_flag;
 
   /*
     Notation for illustrations used in the rest of this function: 
@@ -7348,21 +7392,22 @@ key_or(RANGE_OPT_PARAM *param, SEL_ARG *
         b:      [----
    */
 
-  for (key2=key2->first(); key2; )
+  SEL_ARG *cur_key2= key2->first();
+  while (cur_key2)
   {
     /*
-      key1 consists of one or more ranges. tmp is the range currently
-      being handled.
+      key1 consists of one or more ranges. cur_key1 is the
+      range currently being handled.
 
-      initialize tmp to the latest range in key1 that starts the same
-      place or before the range in key2 starts
+      initialize cur_key1 to the latest range in key1 that starts the
+      same place or before the range in cur_key2 starts
 
-      key2:           [------]
-      key1: [---] [-----] [----]
-                  ^
-                  tmp
+      cur_key2:            [------]
+      key1:      [---] [-----] [----]
+                       ^
+                       cur_key1
     */
-    SEL_ARG *tmp=key1->find_range(key2);
+    SEL_ARG *cur_key1= key1->find_range(cur_key2);
 
     /*
       Used to describe how two key values are positioned compared to
@@ -7374,71 +7419,77 @@ key_or(RANGE_OPT_PARAM *param, SEL_ARG *
          1: key_value_a is bigger than key_value_b (not adjacent)
         -2: key_value_a is bigger than key_value_b, and they are adjacent
 
-      Example: "cmp= tmp->cmp_max_to_min(key2)"
+      Example: "cmp= cur_key1->cmp_max_to_min(cur_key2)"
 
-      key2:         [--------            (10 <= x ...)
-      tmp:    -----]                      (... x <  10) => cmp==-2
-      tmp:    ----]                       (... x <=  9) => cmp==-1
-      tmp:    ------]                     (... x  = 10) => cmp== 0
-      tmp:    --------]                   (... x <= 12) => cmp== 1
+      cur_key2:          [--------           (10 <= x ...  )
+      cur_key1:    -----]                    (  ... x <  10) => cmp==-2
+      cur_key1:    ----]                     (  ... x <   9) => cmp==-1
+      cur_key1:    ------]                   (  ... x <= 10) => cmp== 0
+      cur_key1:    --------]                 (  ... x <= 12) => cmp== 1
       (cmp == 2 does not make sense for cmp_max_to_min())
      */
     int cmp= 0;
 
-    if (!tmp)
+    if (!cur_key1)
     {
       /*
-        The range in key2 starts before the first range in key1. Use
-        the first range in key1 as tmp.
+        The range in cur_key2 starts before the first range in key1. Use
+        the first range in key1 as cur_key1.
 
-        key2:     [--------]
+        cur_key2: [--------]
         key1:            [****--] [----]   [-------]
                          ^
-                         tmp
+                         cur_key1
       */
-      tmp=key1->first();
+      cur_key1= key1->first();
       cmp= -1;
     }
-    else if ((cmp= tmp->cmp_max_to_min(key2)) < 0)
+    else if ((cmp= cur_key1->cmp_max_to_min(cur_key2)) < 0)
     {
       /*
         This is the case:
-        key2:          [-------]
-        tmp:   [----**]
+        cur_key2:           [-------]
+        cur_key1:   [----**]
        */
-      SEL_ARG *next=tmp->next;
-      if (cmp == -2 && eq_tree(tmp->next_key_part,key2->next_key_part))
+      SEL_ARG *next_key1= cur_key1->next;
+      if (cmp == -2 && 
+          eq_tree(cur_key1->next_key_part, cur_key2->next_key_part))
       {
         /*
           Adjacent (cmp==-2) and equal next_key_parts => ranges can be merged
 
           This is the case:
-          key2:          [-------]
-          tmp:     [----]
+          cur_key2:           [-------]
+          cur_key1:     [----]
 
           Result:
-          key2:    [-------------]     => inserted into key1 below
-          tmp:                         => deleted
+          cur_key2:     [-------------]     => inserted into key1 below
+          cur_key1:                         => deleted
         */
-        SEL_ARG *key2_next=key2->next;
+        SEL_ARG *next_key2= cur_key2->next;
         if (key2_shared)
         {
-          if (!(key2=new SEL_ARG(*key2)))
+          if (!(cur_key2= new SEL_ARG(*cur_key2)))
             return 0;           // out of memory
-          key2->increment_use_count(key1->use_count+1);
-          key2->next=key2_next;                 // New copy of key2
+          cur_key2->increment_use_count(key1->use_count+1);
+          cur_key2->next= next_key2;                 // New copy of cur_key2
         }
 
-        key2->copy_min(tmp);
-        if (!(key1=key1->tree_delete(tmp)))
-        {                                       // Only one key in tree
-          key1=key2;
+        cur_key2->copy_min(cur_key1);
+        if (!(key1= key1->tree_delete(cur_key1)))
+        {
+          /*
+            cur_key1 was the last range in key1; move the cur_key2
+            range that was merged above to key1
+          */
+          key1= cur_key2;
           key1->make_root();
-          key2=key2_next;
+          cur_key2= next_key2;
           break;
         }
       }
-      if (!(tmp=next)) // Move to next range in key1. Now tmp.min > key2.min
+      // Move to next range in key1. Now cur_key1.min > cur_key2.min
+      if (!(cur_key1= next_key1)) 
         break;         // No more ranges in key1. Copy rest of key2
     }
 
@@ -7446,185 +7497,186 @@ key_or(RANGE_OPT_PARAM *param, SEL_ARG *
     {
       /*
         This is the case:
-        key2:  [--***]
-        tmp:       [----]
+        cur_key2:   [--***]
+        cur_key1:       [----]
       */
-      int tmp_cmp;
-      if ((tmp_cmp=tmp->cmp_min_to_max(key2)) > 0)
+      int cur_key1_cmp;
+      if ((cur_key1_cmp= cur_key1->cmp_min_to_max(cur_key2)) > 0)
       {
         /*
           This is the case:
-          key2:  [------**]
-          tmp:             [----]
+          cur_key2:  [------**]
+          cur_key1:            [----]
         */
-        if (tmp_cmp == 2 && eq_tree(tmp->next_key_part,key2->next_key_part))
+        if (cur_key1_cmp == 2 && 
+            eq_tree(cur_key1->next_key_part, cur_key2->next_key_part))
         {
           /*
             Adjacent ranges with equal next_key_part. Merge like this:
 
             This is the case:
-            key2:    [------]
-            tmp:             [-----]
+            cur_key2:    [------]
+            cur_key1:            [-----]
 
             Result:
-            key2:    [------]
-            tmp:     [-------------]
+            cur_key2:    [------]
+            cur_key1:    [-------------]
 
             Then move on to next key2 range.
           */
-          tmp->copy_min_to_min(key2);
-          key1->merge_flags(key2);
-          if (tmp->min_flag & NO_MIN_RANGE &&
-              tmp->max_flag & NO_MAX_RANGE)
+          cur_key1->copy_min_to_min(cur_key2);
+          key1->merge_flags(cur_key2); //should be cur_key1->merge...() ?
+          if (cur_key1->min_flag & NO_MIN_RANGE &&
+              cur_key1->max_flag & NO_MAX_RANGE)
           {
             if (key1->maybe_flag)
               return new SEL_ARG(SEL_ARG::MAYBE_KEY);
             return 0;
           }
-          key2->increment_use_count(-1);        // Free not used tree
-          key2=key2->next;
+          cur_key2->increment_use_count(-1);        // Free not used tree
+          cur_key2=cur_key2->next;
           continue;
         }
         else
         {
           /*
-            key2 not adjacent to tmp or has different next_key_part.
+            cur_key2 not adjacent to cur_key1 or has different next_key_part.
             Insert into key1 and move to next range in key2
             
             This is the case:
-            key2:  [------**]
-            tmp:             [----]
+            cur_key2:   [------**]
+            cur_key1:             [----]
 
             Result:
-            key1_  [------**][----]
-                   ^         ^
-                   insert    tmp
+            key1:       [------**][----]
+                        ^         ^
+                        insert    cur_key1
           */
-          SEL_ARG *next=key2->next;
+          SEL_ARG *next_key2= cur_key2->next;
           if (key2_shared)
           {
-            SEL_ARG *cpy= new SEL_ARG(*key2);   // Must make copy
+            SEL_ARG *cpy= new SEL_ARG(*cur_key2);   // Must make copy
             if (!cpy)
               return 0;                         // OOM
-            key1=key1->insert(cpy);
-            key2->increment_use_count(key1->use_count+1);
+            key1= key1->insert(cpy);
+            cur_key2->increment_use_count(key1->use_count+1);
           }
           else
-            key1=key1->insert(key2);            // Will destroy key2_root
-          key2=next;
+            key1= key1->insert(cur_key2); // Will destroy key2_root
+          cur_key2= next_key2;
           continue;
         }
       }
     }
 
     /*
-      The ranges in tmp and key2 are overlapping:
+      The ranges in cur_key1 and cur_key2 are overlapping:
 
-      key2:          [----------] 
-      tmp:        [*****-----*****]
+      cur_key2:       [----------] 
+      cur_key1:    [*****-----*****]
 
-      Corollary: tmp.min <= key2.max
+      Corollary: cur_key1.min <= cur_key2.max
     */
-    if (eq_tree(tmp->next_key_part,key2->next_key_part))
+    if (eq_tree(cur_key1->next_key_part, cur_key2->next_key_part))
     {
       // Merge overlapping ranges with equal next_key_part
-      if (tmp->is_same(key2))
+      if (cur_key1->is_same(cur_key2))
       {
         /*
-          Found exact match of key2 inside key1.
+          cur_key1 covers exactly the same range as cur_key2
           Use the relevant range in key1.
         */
-        tmp->merge_flags(key2);                 // Copy maybe flags
-        key2->increment_use_count(-1);          // Free not used tree
+        cur_key1->merge_flags(cur_key2);        // Copy maybe flags
+        cur_key2->increment_use_count(-1);      // Free not used tree
       }
       else
       {
-        SEL_ARG *last= tmp;
-        SEL_ARG *first= tmp;
+        SEL_ARG *last= cur_key1;
+        SEL_ARG *first= cur_key1;
 
         /*
-          Find the last range in key1 that overlaps key2 and
+          Find the last range in key1 that overlaps cur_key2 and
           where all ranges first...last have the same next_key_part as
-          key2.
+          cur_key2.
 
-          key2:  [****----------------------*******]
-          key1:     [--]  [----] [---]  [-----] [xxxx]
-                    ^                   ^       ^
-                    first               last    different next_key_part
+          cur_key2:  [****----------------------*******]
+          key1:         [--]  [----] [---]  [-----] [xxxx]
+                        ^                   ^       ^
+                        first               last    different next_key_part
 
-          Since key2 covers them, the ranges between first and last
+          Since cur_key2 covers them, the ranges between first and last
           are merged into one range by deleting first...last-1 from
           the key1 tree. In the figure, this applies to first and the
           two consecutive ranges. The range of last is then extended:
-            * last.min: Set to min(key2.min, first.min)
-            * last.max: If there is a last->next that overlaps key2 (i.e.,
-                        last->next has a different next_key_part):
+            * last.min: Set to min(cur_key2.min, first.min)
+            * last.max: If there is a last->next that overlaps cur_key2 
+                        (i.e., last->next has a different next_key_part):
                                         Set adjacent to last->next.min
-                        Otherwise:      Set to max(key2.max, last.max)
+                        Otherwise:      Set to max(cur_key2.max, last.max)
 
           Result:
-          key2:  [****----------------------*******]
-                    [--]  [----] [---]                   => deleted from key1
-          key1:  [**------------------------***][xxxx]
-                 ^                              ^
-                 tmp=last                       different next_key_part
+          cur_key2:  [****----------------------*******]
+                        [--]  [----] [---]                 => deleted from key1
+          key1:      [**------------------------***][xxxx]
+                     ^                              ^
+                     cur_key1=last                  different next_key_part
         */
-        while (last->next && last->next->cmp_min_to_max(key2) <= 0 &&
-               eq_tree(last->next->next_key_part,key2->next_key_part))
+        while (last->next && last->next->cmp_min_to_max(cur_key2) <= 0 &&
+               eq_tree(last->next->next_key_part, cur_key2->next_key_part))
         {
           /*
-            last->next is covered by key2 and has same next_key_part.
+            last->next is covered by cur_key2 and has same next_key_part.
             last can be deleted
           */
           SEL_ARG *save=last;
           last=last->next;
-          key1=key1->tree_delete(save);
+          key1= key1->tree_delete(save);
         }
-        // Redirect tmp to last which will cover the entire range
-        tmp= last;
+        // Redirect cur_key1 to last which will cover the entire range
+        cur_key1= last;
 
         /*
           We need the minimum endpoint of first so we can compare it
-          with the minimum endpoint of the enclosing key2 range.
+          with the minimum endpoint of the enclosing cur_key2 range.
         */
         last->copy_min(first);
-        bool full_range= last->copy_min(key2);
+        bool full_range= last->copy_min(cur_key2);
         if (!full_range)
         {
-          if (last->next && key2->cmp_max_to_min(last->next) >= 0)
+          if (last->next && cur_key2->cmp_max_to_min(last->next) >= 0)
           {
             /*
               This is the case:
-              key2:    [-------------]
-              key1:  [***------]  [xxxx]
-                     ^            ^
-                     last         different next_key_part
+              cur_key2:   [-------------]
+              key1:     [***------]  [xxxx]
+                        ^            ^
+                        last         different next_key_part
 
               Extend range of last up to last->next:
-              key2:    [-------------]
-              key1:  [***--------][xxxx]
+              cur_key2:   [-------------]
+              key1:     [***--------][xxxx]
             */
             last->copy_min_to_max(last->next);
           }
           else
             /*
               This is the case:
-              key2:    [--------*****]
-              key1:  [***---------]    [xxxx]
-                     ^                 ^
-                     last              different next_key_part
-
-              Extend range of last up to max(last.max, key2.max):
-              key2:    [--------*****]
-              key1:  [***----------**] [xxxx]
+              cur_key2:   [--------*****]
+              key1:     [***---------]    [xxxx]
+                        ^                 ^
+                        last              different next_key_part
+
+              Extend range of last up to max(last.max, cur_key2.max):
+              cur_key2:   [--------*****]
+              key1:     [***----------**] [xxxx]
              */
-            full_range= last->copy_max(key2);
+            full_range= last->copy_max(cur_key2);
         }
         if (full_range)
         {                                       // Full range
           key1->free_tree();
-          for (; key2 ; key2=key2->next)
-            key2->increment_use_count(-1);      // Free not used tree
+          for (; cur_key2 ; cur_key2= cur_key2->next)
+            cur_key2->increment_use_count(-1);  // Free not used tree
           if (key1->maybe_flag)
             return new SEL_ARG(SEL_ARG::MAYBE_KEY);
           return 0;
@@ -7632,161 +7684,164 @@ key_or(RANGE_OPT_PARAM *param, SEL_ARG *
       }
     }
 
-    if (cmp >= 0 && tmp->cmp_min_to_min(key2) < 0)
+    if (cmp >= 0 && cur_key1->cmp_min_to_min(cur_key2) < 0)
     {
       /*
-        This is the case ("cmp>=0" means that tmp.max >= key2.min):
-        key2:              [----]
-        tmp:     [------------*****]
+        This is the case ("cmp>=0" means that cur_key1.max >= cur_key2.min):
+        cur_key2:                [-------]
+        cur_key1:         [----------*******]
       */
 
-      if (!tmp->next_key_part)
+      if (!cur_key1->next_key_part)
       {
         /*
-          tmp->next_key_part is empty: cut the range that is covered
-          by tmp from key2. 
-          Reason: (key2->next_key_part OR tmp->next_key_part) will be
-          empty and therefore equal to tmp->next_key_part. Thus, this
-          part of the key2 range is completely covered by tmp.
+          cur_key1->next_key_part is empty: cut the range that
+          is covered by cur_key1 from cur_key2.
+          Reason: (cur_key2->next_key_part OR
+          cur_key1->next_key_part) will be empty and therefore
+          equal to cur_key1->next_key_part. Thus, this part of
+          the cur_key2 range is completely covered by cur_key1.
         */
-        if (tmp->cmp_max_to_max(key2) >= 0)
+        if (cur_key1->cmp_max_to_max(cur_key2) >= 0)
         {
           /*
-            tmp covers the entire range in key2. 
-            key2:              [----]
-            tmp:     [-----------------]
+            cur_key1 covers the entire range in cur_key2.
+            cur_key2:            [-------]
+            cur_key1:     [-----------------]
 
             Move on to next range in key2
           */
-          key2->increment_use_count(-1); // Free not used tree
-          key2=key2->next;
+          cur_key2->increment_use_count(-1); // Free not used tree
+          cur_key2= cur_key2->next;
           continue;
         }
         else
         {
           /*
             This is the case:
-            key2:           [-------]
-            tmp:     [---------]
+            cur_key2:            [-------]
+            cur_key1:     [---------]
 
             Result:
-            key2:               [---]
-            tmp:     [---------]
+            cur_key2:                [---]
+            cur_key1:     [---------]
           */
-          key2->copy_max_to_min(tmp);
+          cur_key2->copy_max_to_min(cur_key1);
           continue;
         }
       }
 
       /*
         The ranges are overlapping but have not been merged because
-        next_key_part of tmp and key2 differ. 
-        key2:              [----]
-        tmp:     [------------*****]
-
-        Split tmp in two where key2 starts:
-        key2:              [----]
-        key1:    [--------][--*****]
-                 ^         ^
-                 insert    tmp
+        next_key_part of cur_key1 and cur_key2 differ. 
+        cur_key2:               [----]
+        cur_key1:     [------------*****]
+
+        Split cur_key1 in two where cur_key2 starts:
+        cur_key2:               [----]
+        key1:         [--------][--*****]
+                      ^         ^
+                      insert    cur_key1
       */
-      SEL_ARG *new_arg=tmp->clone_first(key2);
+      SEL_ARG *new_arg= cur_key1->clone_first(cur_key2);
       if (!new_arg)
         return 0;                               // OOM
-      if ((new_arg->next_key_part= tmp->next_key_part))
+      if ((new_arg->next_key_part= cur_key1->next_key_part))
         new_arg->increment_use_count(key1->use_count+1);
-      tmp->copy_min_to_min(key2);
-      key1=key1->insert(new_arg);
-    } // tmp.min >= key2.min due to this if()
+      cur_key1->copy_min_to_min(cur_key2);
+      key1= key1->insert(new_arg);
+    } // cur_key1.min >= cur_key2.min due to this if()
 
     /*
-      Now key2.min <= tmp.min <= key2.max:
-      key2:   [---------]
-      tmp:    [****---*****]
+      Now cur_key2.min <= cur_key1.min <= cur_key2.max:
+      cur_key2:    [---------]
+      cur_key1:    [****---*****]
      */
-    SEL_ARG key2_cpy(*key2); // Get copy we can modify
+    SEL_ARG key2_cpy(*cur_key2); // Get copy we can modify
     for (;;)
     {
-      if (tmp->cmp_min_to_min(&key2_cpy) > 0)
+      if (cur_key1->cmp_min_to_min(&key2_cpy) > 0)
       {
         /*
           This is the case:
           key2_cpy:    [------------]
           key1:                 [-*****]
                                 ^
-                                tmp
+                                cur_key1
                              
           Result:
           key2_cpy:             [---]
           key1:        [-------][-*****]
                        ^        ^
-                       insert   tmp
+                       insert   cur_key1
          */
-        SEL_ARG *new_arg=key2_cpy.clone_first(tmp);
+        SEL_ARG *new_arg=key2_cpy.clone_first(cur_key1);
         if (!new_arg)
           return 0; // OOM
         if ((new_arg->next_key_part=key2_cpy.next_key_part))
           new_arg->increment_use_count(key1->use_count+1);
-        key1=key1->insert(new_arg);
-        key2_cpy.copy_min_to_min(tmp);
+        key1= key1->insert(new_arg);
+        key2_cpy.copy_min_to_min(cur_key1);
       } 
-      // Now key2_cpy.min == tmp.min
+      // Now key2_cpy.min == cur_key1.min
 
-      if ((cmp= tmp->cmp_max_to_max(&key2_cpy)) <= 0)
+      if ((cmp= cur_key1->cmp_max_to_max(&key2_cpy)) <= 0)
       {
         /*
-          tmp.max <= key2_cpy.max:
-          key2_cpy:   a)  [-------]    or b)     [----]
-          tmp:            [----]                 [----]
+          cur_key1.max <= key2_cpy.max:
+          key2_cpy:       a)  [-------]    or b)     [----]
+          cur_key1:           [----]                 [----]
 
           Steps:
-           1) Update next_key_part of tmp: OR it with key2_cpy->next_key_part.
-           2) If case a: Insert range [tmp.max, key2_cpy.max] into key1 using
-                         next_key_part of key2_cpy
+
+           1) Update next_key_part of cur_key1: OR it with
+              key2_cpy->next_key_part.
+           2) If case a: Insert range [cur_key1.max, key2_cpy.max] 
+              into key1 using next_key_part of key2_cpy
 
            Result:
-           key1:      a)  [----][-]    or b)     [----]
+           key1:          a)  [----][-]    or b)     [----]
          */
-        tmp->maybe_flag|= key2_cpy.maybe_flag;
+        cur_key1->maybe_flag|= key2_cpy.maybe_flag;
         key2_cpy.increment_use_count(key1->use_count+1);
-        tmp->next_key_part= key_or(param, tmp->next_key_part,
-                                   key2_cpy.next_key_part);
+        cur_key1->next_key_part= 
+          key_or(param, cur_key1->next_key_part, key2_cpy.next_key_part);
 
         if (!cmp)
           break;                     // case b: done with this key2 range
 
-        // Make key2_cpy the range [tmp.max, key2_cpy.max]
-        key2_cpy.copy_max_to_min(tmp);
-        if (!(tmp=tmp->next))
+        // Make key2_cpy the range [cur_key1.max, key2_cpy.max]
+        key2_cpy.copy_max_to_min(cur_key1);
+        if (!(cur_key1= cur_key1->next))
         {
           /*
             No more ranges in key1. Insert key2_cpy and go to "end"
             label to insert remaining ranges in key2 if any.
           */
-          SEL_ARG *tmp2= new SEL_ARG(key2_cpy);
-          if (!tmp2)
+          SEL_ARG *new_key1_range= new SEL_ARG(key2_cpy);
+          if (!new_key1_range)
             return 0; // OOM
-          key1=key1->insert(tmp2);
-          key2=key2->next;
+          key1= key1->insert(new_key1_range);
+          cur_key2= cur_key2->next;
           goto end;
         }
-        if (tmp->cmp_min_to_max(&key2_cpy) > 0)
+        if (cur_key1->cmp_min_to_max(&key2_cpy) > 0)
         {
           /*
             The next range in key1 does not overlap with key2_cpy.
             Insert this range into key1 and move on to the next range
             in key2.
           */
-          SEL_ARG *tmp2= new SEL_ARG(key2_cpy);
-          if (!tmp2)
+          SEL_ARG *new_key1_range= new SEL_ARG(key2_cpy);
+          if (!new_key1_range)
             return 0;                           // OOM
-          key1=key1->insert(tmp2);
+          key1= key1->insert(new_key1_range);
           break;
         }
         /*
           key2_cpy overlaps with the next range in key1 and the case
-          is now "key2.min <= tmp.min <= key2.max". Go back to for(;;)
-          to handle this situation.
+          is now "cur_key2.min <= cur_key1.min <= cur_key2.max". Go back
+          to for(;;) to handle this situation.
         */
         continue;
       }
@@ -7794,44 +7849,47 @@ key_or(RANGE_OPT_PARAM *param, SEL_ARG *
       {
         /*
           This is the case:
-          key2_cpy:   [-------]
-          tmp:        [------------]
+          key2_cpy:        [-------]
+          cur_key1:        [------------]
 
           Result:
-          key1:       [-------][---]
-                      ^        ^
-                      new_arg  tmp
+          key1:            [-------][---]
+                           ^        ^
+                           new_arg  cur_key1
           Steps:
-           0) If tmp->next_key_part is empty: do nothing. Reason:
-              (key2_cpy->next_key_part OR tmp->next_key_part) will be
-              empty and therefore equal to tmp->next_key_part. Thus,
-              the range in key2_cpy is completely covered by tmp
-           1) Make new_arg with range [tmp.min, key2_cpy.max].
-              new_arg->next_key_part is OR between next_key_part
-              of tmp and key2_cpy
-           2) Make tmp the range [key2.max, tmp.max]
+
+           0) If cur_key1->next_key_part is empty: do nothing.
+              Reason: (key2_cpy->next_key_part OR
+              cur_key1->next_key_part) will be empty and
+              therefore equal to cur_key1->next_key_part. Thus,
+              the range in key2_cpy is completely covered by
+              cur_key1
+           1) Make new_arg with range [cur_key1.min, key2_cpy.max]. 
+              new_arg->next_key_part is OR between next_key_part of 
+              cur_key1 and key2_cpy
+           2) Make cur_key1 the range [key2_cpy.max, cur_key1.max]
            3) Insert new_arg into key1
         */
-        if (!tmp->next_key_part) // Step 0
+        if (!cur_key1->next_key_part) // Step 0
         {
           key2_cpy.increment_use_count(-1);     // Free not used tree
           break;
         }
-        SEL_ARG *new_arg=tmp->clone_last(&key2_cpy);
+        SEL_ARG *new_arg= cur_key1->clone_last(&key2_cpy);
         if (!new_arg)
           return 0; // OOM
-        tmp->copy_max_to_min(&key2_cpy);
-        tmp->increment_use_count(key1->use_count+1);
+        cur_key1->copy_max_to_min(&key2_cpy);
+        cur_key1->increment_use_count(key1->use_count+1);
         /* Increment key count as it may be used for next loop */
         key2_cpy.increment_use_count(1);
-        new_arg->next_key_part= key_or(param, tmp->next_key_part,
+        new_arg->next_key_part= key_or(param, cur_key1->next_key_part,
                                        key2_cpy.next_key_part);
-        key1=key1->insert(new_arg);
+        key1= key1->insert(new_arg);
         break;
       }
     }
     // Move on to next range in key2
-    key2=key2->next;                            
+    cur_key2= cur_key2->next;                            
   }
 
 end:
@@ -7839,20 +7897,20 @@ end:
     Add key2 ranges that are non-overlapping with and higher than the
     highest range in key1.
   */
-  while (key2)
+  while (cur_key2)
   {
-    SEL_ARG *next=key2->next;
+    SEL_ARG *next= cur_key2->next;
     if (key2_shared)
     {
-      SEL_ARG *tmp=new SEL_ARG(*key2);          // Must make copy
-      if (!tmp)
+      SEL_ARG *key2_cpy=new SEL_ARG(*cur_key2);  // Must make copy
+      if (!key2_cpy)
         return 0;
-      key2->increment_use_count(key1->use_count+1);
-      key1=key1->insert(tmp);
+      cur_key2->increment_use_count(key1->use_count+1);
+      key1= key1->insert(key2_cpy);
     }
     else
-      key1=key1->insert(key2);                  // Will destroy key2_root
-    key2=next;
+      key1= key1->insert(cur_key2);   // Will destroy key2_root
+    cur_key2= next;
   }
   key1->use_count++;
 

=== modified file 'sql/partition_info.cc'
--- a/sql/partition_info.cc	2011-12-19 12:53:11 +0000
+++ b/sql/partition_info.cc	2012-02-07 23:33:54 +0000
@@ -1233,9 +1233,7 @@ end:
 */
 static void warn_if_dir_in_part_elem(THD *thd, partition_element *part_elem)
 {
-#ifdef HAVE_READLINK
-  if (!my_use_symdir || (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE))
-#endif
+  if (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)
   {
     if (part_elem->data_file_name)
       push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,

=== modified file 'sql/sql_executor.cc'
--- a/sql/sql_executor.cc	2012-01-31 11:19:25 +0000
+++ b/sql/sql_executor.cc	2012-02-07 14:50:31 +0000
@@ -2564,9 +2564,9 @@ test_if_quick_select(JOIN_TAB *tab)
    Reads content of constant table
    @param tab  table
    @param pos  position of table in query plan
-   @retval 0   ok
-   @retval >0  error
-   @retval <0  ??
+   @retval 0   ok, one row was found or one NULL-complemented row was created
+   @retval -1  ok, no row was found and no NULL-complemented row was created
+   @retval 1   error
 */
 
 int
@@ -2687,6 +2687,16 @@ join_read_const_table(JOIN_TAB *tab, POS
 }
 
 
+/**
+  Read a constant table when there is at most one matching row, using a table
+  scan.
+
+  @param tab			Table to read
+
+  @retval  0  Row was found
+  @retval  -1 Row was not found
+  @retval  1  Got an error (other than row not found) during read
+*/
 static int
 join_read_system(JOIN_TAB *tab)
 {
@@ -2713,16 +2723,14 @@ join_read_system(JOIN_TAB *tab)
 
 
 /**
-  Read a [constant] table when there is at most one matching row.
+  Read a constant table when there is at most one matching row, using an
+  index lookup.
 
   @param tab			Table to read
 
-  @retval
-    0	Row was found
-  @retval
-    -1   Row was not found
-  @retval
-    1   Got an error (other than row not found) during read
+  @retval 0  Row was found
+  @retval -1 Row was not found
+  @retval 1  Got an error (other than row not found) during read
 */
 
 static int

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2012-01-20 14:44:16 +0000
+++ b/sql/sql_lex.cc	2012-02-08 09:44:42 +0000
@@ -2494,6 +2494,7 @@ void TABLE_LIST::print(THD *thd, String 
         append_identifier(thd, str, table_name, table_name_length);
         cmp_name= table_name;
       }
+#ifdef WITH_PARTITION_STORAGE_ENGINE
       if (partition_names && partition_names->elements)
       {
         int i, num_parts= partition_names->elements;
@@ -2508,6 +2509,7 @@ void TABLE_LIST::print(THD *thd, String 
         }
         str->append(')');
       }
+#endif /* WITH_PARTITION_STORAGE_ENGINE */
     }
     if (my_strcasecmp(table_alias_charset, cmp_name, alias))
     {

=== modified file 'sql/sql_optimizer.cc'
--- a/sql/sql_optimizer.cc	2012-01-27 14:22:35 +0000
+++ b/sql/sql_optimizer.cc	2012-02-07 20:32:47 +0000
@@ -55,7 +55,7 @@ static Item *optimize_cond(JOIN *join, I
                            List<TABLE_LIST> *join_list,
 			   bool build_equalities,
                            Item::cond_result *cond_value);
-static bool list_contains_unique_index(TABLE *table,
+static bool list_contains_unique_index(JOIN_TAB *tab,
                           bool (*find_func) (Field *, void *), void *data);
 static bool find_field_in_item_list (Field *field, void *data);
 static bool find_field_in_order_list (Field *field, void *data);
@@ -377,11 +377,9 @@ JOIN::optimize()
   }
 
   if (const_table_map != found_const_table_map &&
-      !(select_options & SELECT_DESCRIBE) &&
-      (!conds ||
-       !(conds->used_tables() & RAND_TABLE_BIT) ||
-       select_lex->master_unit() == &thd->lex->unit)) // upper level SELECT
+      !(select_options & SELECT_DESCRIBE))
   {
+    // There is at least one empty const table
     zero_result_cause= "no matching row in const table";
     DBUG_PRINT("error",("Error: %s", zero_result_cause));
     goto setup_subq_exit;
@@ -522,7 +520,7 @@ JOIN::optimize()
        QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX))
   {
     if (group_list && rollup.state == ROLLUP::STATE_NONE &&
-       list_contains_unique_index(join_tab[const_tables].table,
+       list_contains_unique_index(&join_tab[const_tables],
                                  find_field_in_order_list,
                                  (void *) group_list))
     {
@@ -560,7 +558,7 @@ JOIN::optimize()
       group= 0;
     }
     if (select_distinct &&
-       list_contains_unique_index(join_tab[const_tables].table,
+       list_contains_unique_index(&join_tab[const_tables],
                                  find_field_in_item_list,
                                  (void *) &fields_list))
     {
@@ -8069,7 +8067,7 @@ internal_remove_eq_conds(THD *thd, Item 
         if (!eq_cond)
           return cond;
 
-        if (field->table->pos_in_table_list->outer_join)
+        if (args[0]->is_outer_field())
         {
           // outer join: transform "col IS NULL" to "col IS NULL or col=0"
           Item *or_cond= new(thd->mem_root) Item_cond_or(eq_cond, cond);
@@ -8223,7 +8221,7 @@ remove_eq_conds(THD *thd, Item *cond, It
     can safely remove the GROUP BY/DISTINCT,
     as no result set can be more distinct than an unique key.
 
-  @param table                The table to operate on.
+  @param tab                  The join table to operate on.
   @param find_func            function to iterate over the list and search
                               for a field
 
@@ -8231,13 +8229,19 @@ remove_eq_conds(THD *thd, Item *cond, It
     1                    found
   @retval
     0                    not found.
+
+  @note
+    The function assumes that make_outerjoin_info() has been called in
+    order for the check for outer tables to work.
 */
 
 static bool
-list_contains_unique_index(TABLE *table,
+list_contains_unique_index(JOIN_TAB *tab,
                           bool (*find_func) (Field *, void *), void *data)
 {
-  if (table->pos_in_table_list->outer_join)
+  TABLE *table= tab->table;
+
+  if (tab->is_inner_table_of_outer_join())
     return 0;
   for (uint keynr= 0; keynr < table->s->keys; keynr++)
   {

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2012-01-31 15:16:16 +0000
+++ b/sql/sql_parse.cc	2012-02-08 06:45:31 +0000
@@ -2603,14 +2603,13 @@ case SQLCOM_PREPARE:
     /* Might have been updated in create_table_precheck */
     create_info.alias= create_table->alias;
 
-#ifdef HAVE_READLINK
-    /* Fix names if symlinked tables */
+    /* Fix names if symlinked or relocated tables */
     if (append_file_to_dir(thd, &create_info.data_file_name,
 			   create_table->table_name) ||
 	append_file_to_dir(thd, &create_info.index_file_name,
 			   create_table->table_name))
       goto end_with_restore_list;
-#endif
+
     /*
       If no engine type was given, work out the default now
       rather than at parse-time.

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2012-01-31 07:45:59 +0000
+++ b/sql/sql_select.cc	2012-02-01 09:59:13 +0000
@@ -4684,7 +4684,7 @@ bool JOIN::change_result(select_result *
   @param          ref_key             
                 * 0 <= key < MAX_KEY   - key number (hint) to start the search
                 * -1                   - no key number provided
-  @param          select_limit        LIMIT value
+  @param          select_limit        LIMIT value, or HA_POS_ERROR if no limit
   @param [out]    new_key             Key number if success, otherwise undefined
   @param [out]    new_key_direction   Return -1 (reverse) or +1 if success,
                                       otherwise undefined
@@ -4732,6 +4732,7 @@ test_if_cheaper_ordering(const JOIN_TAB 
   ha_rows table_records= table->file->stats.records;
   bool group= join && join->group && order == join->group_list;
   ha_rows ref_key_quick_rows= HA_POS_ERROR;
+  const bool has_limit= (select_limit != HA_POS_ERROR);
 
   /*
     If not used with LIMIT, only use keys if the whole query can be
@@ -4824,7 +4825,7 @@ test_if_cheaper_ordering(const JOIN_TAB 
             be included into the result set.
           */  
           if (select_limit > table_records/rec_per_key)
-              select_limit= table_records;
+            select_limit= table_records;
           else
             select_limit= (ha_rows) (select_limit*rec_per_key);
         }
@@ -4905,7 +4906,7 @@ test_if_cheaper_ordering(const JOIN_TAB 
   
   *new_key= best_key;
   *new_key_direction= best_key_direction;
-  *new_select_limit= best_select_limit;
+  *new_select_limit= has_limit ? best_select_limit : table_records;
   if (new_used_key_parts != NULL)
     *new_used_key_parts= best_key_parts;
 

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2012-01-31 15:16:16 +0000
+++ b/sql/sql_show.cc	2012-02-08 12:49:33 +0000
@@ -1426,7 +1426,9 @@ int store_create_info(THD *thd, TABLE_LI
   handler *file= table->file;
   TABLE_SHARE *share= table->s;
   HA_CREATE_INFO create_info;
+#ifdef WITH_PARTITION_STORAGE_ENGINE
   bool show_table_options= FALSE;
+#endif /* WITH_PARTITION_STORAGE_ENGINE */
   bool foreign_db_mode=  (thd->variables.sql_mode & (MODE_POSTGRESQL |
                                                      MODE_ORACLE |
                                                      MODE_MSSQL |
@@ -1639,7 +1641,9 @@ int store_create_info(THD *thd, TABLE_LI
   packet->append(STRING_WITH_LEN("\n)"));
   if (!(thd->variables.sql_mode & MODE_NO_TABLE_OPTIONS) && !foreign_db_mode)
   {
+#ifdef WITH_PARTITION_STORAGE_ENGINE
     show_table_options= TRUE;
+#endif /* WITH_PARTITION_STORAGE_ENGINE */
 
     /* TABLESPACE and STORAGE */
     if (share->tablespace ||

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2012-01-31 15:16:16 +0000
+++ b/sql/sql_table.cc	2012-02-08 13:10:23 +0000
@@ -4431,7 +4431,6 @@ bool mysql_create_table_no_lock(THD *thd
 
   THD_STAGE_INFO(thd, stage_creating_table);
 
-#ifdef HAVE_READLINK
   {
     size_t dirlen;
     char   dirpath[FN_REFLEN];
@@ -4478,8 +4477,7 @@ bool mysql_create_table_no_lock(THD *thd
   }
 #endif /* WITH_PARTITION_STORAGE_ENGINE */
 
-  if (!my_use_symdir || (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE))
-#endif /* HAVE_READLINK */
+  if (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)
   {
     if (create_info->data_file_name)
       push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
@@ -6208,8 +6206,26 @@ bool mysql_alter_table(THD *thd,char *ne
       }
       else
       {
+        MDL_request_list mdl_requests;
+        MDL_request target_db_mdl_request;
+
         target_mdl_request.init(MDL_key::TABLE, new_db, new_name,
                                 MDL_EXCLUSIVE, MDL_TRANSACTION);
+        mdl_requests.push_front(&target_mdl_request);
+
+        /*
+          If we are moving the table to a different database, we also
+          need IX lock on the database name so that the target database
+          is protected by MDL while the table is moved.
+        */
+        if (new_db != db)
+        {
+          target_db_mdl_request.init(MDL_key::SCHEMA, new_db, "",
+                                     MDL_INTENTION_EXCLUSIVE,
+                                     MDL_TRANSACTION);
+          mdl_requests.push_front(&target_db_mdl_request);
+        }
+
         /*
           Global intention exclusive lock must have been already acquired when
           table to be altered was open, so there is no need to do it here.
@@ -6218,14 +6234,10 @@ bool mysql_alter_table(THD *thd,char *ne
                                                    "", "",
                                                    MDL_INTENTION_EXCLUSIVE));
 
-        if (thd->mdl_context.try_acquire_lock(&target_mdl_request))
+        if (thd->mdl_context.acquire_locks(&mdl_requests,
+                                           thd->variables.lock_wait_timeout))
           DBUG_RETURN(TRUE);
-        if (target_mdl_request.ticket == NULL)
-        {
-          /* Table exists and is locked by some thread. */
-	  my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
-	  DBUG_RETURN(TRUE);
-        }
+
         DEBUG_SYNC(thd, "locked_table_name");
         /*
           Table maybe does not exist, but we got an exclusive lock

=== modified file 'sql/sql_time.cc'
--- a/sql/sql_time.cc	2011-11-24 12:31:44 +0000
+++ b/sql/sql_time.cc	2012-02-02 10:58:18 +0000
@@ -409,13 +409,14 @@ str_to_datetime_with_warn(String *str, M
 static bool
 lldiv_t_to_datetime(lldiv_t lld, MYSQL_TIME *ltime, uint flags, int *warnings)
 {
-  bool rc= number_to_datetime(lld.quot, ltime, flags, warnings) == LL(-1);
-  if (rc)
+  if (lld.rem < 0 || // Catch negative numbers with zero int part, e.g: -0.1
+      number_to_datetime(lld.quot, ltime, flags, warnings) == LL(-1))
   {
     /* number_to_datetime does not clear ltime in case of ZERO DATE */
     set_zero_time(ltime, MYSQL_TIMESTAMP_ERROR);
     if (!*warnings) /* Neither sets warnings in case of ZERO DATE */
       *warnings|= MYSQL_TIME_WARN_TRUNCATED;
+    return true;
   }
   else if (ltime->time_type == MYSQL_TIMESTAMP_DATE)
   {
@@ -430,9 +431,9 @@ lldiv_t_to_datetime(lldiv_t lld, MYSQL_T
   else if (!(flags & TIME_NO_NSEC_ROUNDING))
   {
     ltime->second_part= lld.rem / 1000;
-    rc= datetime_add_nanoseconds_with_round(ltime, lld.rem % 1000, warnings);
+    return datetime_add_nanoseconds_with_round(ltime, lld.rem % 1000, warnings);
   }
-  return rc;
+  return false;
 }
 
 

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2011-12-19 12:53:11 +0000
+++ b/sql/sql_yacc.yy	2012-02-03 18:09:00 +0000
@@ -1504,7 +1504,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
         IDENT_sys TEXT_STRING_sys TEXT_STRING_literal
         NCHAR_STRING opt_component key_cache_name
         sp_opt_label BIN_NUM label_ident TEXT_STRING_filesystem ident_or_empty
-        opt_constraint constraint opt_ident
+        opt_constraint constraint opt_ident TEXT_STRING_sys_nonewline
 
 %type <lex_str_ptr>
         opt_table_alias
@@ -1983,19 +1983,19 @@ master_defs:
         ;
 
 master_def:
-          MASTER_HOST_SYM EQ TEXT_STRING_sys
+          MASTER_HOST_SYM EQ TEXT_STRING_sys_nonewline
           {
             Lex->mi.host = $3.str;
           }
-        | MASTER_BIND_SYM EQ TEXT_STRING_sys
+        | MASTER_BIND_SYM EQ TEXT_STRING_sys_nonewline
           {
             Lex->mi.bind_addr = $3.str;
           }
-        | MASTER_USER_SYM EQ TEXT_STRING_sys
+        | MASTER_USER_SYM EQ TEXT_STRING_sys_nonewline
           {
             Lex->mi.user = $3.str;
           }
-        | MASTER_PASSWORD_SYM EQ TEXT_STRING_sys
+        | MASTER_PASSWORD_SYM EQ TEXT_STRING_sys_nonewline
           {
             Lex->mi.password = $3.str;
           }
@@ -2027,23 +2027,23 @@ master_def:
             Lex->mi.ssl= $3 ? 
               LEX_MASTER_INFO::LEX_MI_ENABLE : LEX_MASTER_INFO::LEX_MI_DISABLE;
           }
-        | MASTER_SSL_CA_SYM EQ TEXT_STRING_sys
+        | MASTER_SSL_CA_SYM EQ TEXT_STRING_sys_nonewline
           {
             Lex->mi.ssl_ca= $3.str;
           }
-        | MASTER_SSL_CAPATH_SYM EQ TEXT_STRING_sys
+        | MASTER_SSL_CAPATH_SYM EQ TEXT_STRING_sys_nonewline
           {
             Lex->mi.ssl_capath= $3.str;
           }
-        | MASTER_SSL_CERT_SYM EQ TEXT_STRING_sys
+        | MASTER_SSL_CERT_SYM EQ TEXT_STRING_sys_nonewline
           {
             Lex->mi.ssl_cert= $3.str;
           }
-        | MASTER_SSL_CIPHER_SYM EQ TEXT_STRING_sys
+        | MASTER_SSL_CIPHER_SYM EQ TEXT_STRING_sys_nonewline
           {
             Lex->mi.ssl_cipher= $3.str;
           }
-        | MASTER_SSL_KEY_SYM EQ TEXT_STRING_sys
+        | MASTER_SSL_KEY_SYM EQ TEXT_STRING_sys_nonewline
           {
             Lex->mi.ssl_key= $3.str;
           }
@@ -2052,11 +2052,11 @@ master_def:
             Lex->mi.ssl_verify_server_cert= $3 ?
               LEX_MASTER_INFO::LEX_MI_ENABLE : LEX_MASTER_INFO::LEX_MI_DISABLE;
           }
-        | MASTER_SSL_CRL_SYM EQ TEXT_STRING_sys
+        | MASTER_SSL_CRL_SYM EQ TEXT_STRING_sys_nonewline
           {
             Lex->mi.ssl_crl= $3.str;
           }
-        | MASTER_SSL_CRLPATH_SYM EQ TEXT_STRING_sys
+        | MASTER_SSL_CRLPATH_SYM EQ TEXT_STRING_sys_nonewline
           {
             Lex->mi.ssl_crlpath= $3.str;
           }
@@ -2121,7 +2121,7 @@ ignore_server_id:
           }
 
 master_file_def:
-          MASTER_LOG_FILE_SYM EQ TEXT_STRING_sys
+          MASTER_LOG_FILE_SYM EQ TEXT_STRING_sys_nonewline
           {
             Lex->mi.log_file_name = $3.str;
           }
@@ -2141,7 +2141,7 @@ master_file_def:
             */
             Lex->mi.pos = max<ulonglong>(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
           }
-        | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
+        | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys_nonewline
           {
             Lex->mi.relay_log_name = $3.str;
           }
@@ -12811,6 +12811,19 @@ IDENT_sys:
               if (thd->convert_string(&$$, system_charset_info,
                                   $1.str, $1.length, thd->charset()))
                 MYSQL_YYABORT;
+            }
+          }
+        ;
+
+TEXT_STRING_sys_nonewline:
+          TEXT_STRING_sys
+          {
+            if (!strcont($1.str, "\n"))
+              $$= $1;
+            else
+            {
+              my_error(ER_WRONG_VALUE, MYF(0), "argument contains not-allowed LF", $1.str);
+              MYSQL_YYABORT;
             }
           }
         ;

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2012-01-31 10:40:02 +0000
+++ b/sql/sys_vars.cc	2012-02-02 16:56:36 +0000
@@ -2114,7 +2114,7 @@ static Sys_var_uint Sys_eq_range_index_d
        "eq_range_index_dive_limit",
        "The optimizer will use existing index statistics instead of "
        "doing index dives for equality ranges if the number of equality "
-       "ranges is larger than or equal to this number.",
+       "ranges for the index is larger than or equal to this number.",
        SESSION_VAR(eq_range_index_dive_limit), CMD_LINE(REQUIRED_ARG),
        VALID_RANGE(0, UINT_MAX32), DEFAULT(10), BLOCK_SIZE(1));
 

=== modified file 'sql/table.h'
--- a/sql/table.h	2012-01-31 15:16:16 +0000
+++ b/sql/table.h	2012-02-07 11:56:30 +0000
@@ -325,6 +325,10 @@ public:
   uchar     *record_pointers;    /* If sorted in memory */
   ha_rows   found_records;      /* How many records in sort */
 
+  /** Sort filesort_buffer */
+  void sort_buffer(Sort_param *param, uint count)
+  { filesort_buffer.sort_buffer(param, count); }
+
   /**
      Accessors for Filesort_buffer (which @c).
   */

=== modified file 'storage/archive/ha_archive.cc'
--- a/storage/archive/ha_archive.cc	2012-01-31 15:16:16 +0000
+++ b/storage/archive/ha_archive.cc	2012-02-07 23:33:54 +0000
@@ -294,6 +294,15 @@ err:
   DBUG_RETURN(1);
 }
 
+static void save_auto_increment(TABLE *table, ulonglong *value)
+{
+  Field *field= table->found_next_number_field;
+  ulonglong auto_value=
+    (ulonglong) field->val_int(table->record[0] +
+                               field->offset(table->record[0]));
+  if (*value <= auto_value)
+    *value= auto_value + 1;
+}
 
 /**
   @brief Read version 1 meta file (5.0 compatibility routine).
@@ -476,6 +485,7 @@ ARCHIVE_SHARE *ha_archive::get_share(con
     share->table_name= tmp_name;
     share->crashed= FALSE;
     share->archive_write_open= FALSE;
+    share->in_optimize= false;
     fn_format(share->data_file_name, table_name, "",
               ARZ, MY_REPLACE_EXT | MY_UNPACK_FILENAME);
     strmov(share->table_name, table_name);
@@ -727,12 +737,12 @@ void ha_archive::frm_load(const char *na
   {
     if (!mysql_file_fstat(frm_file, &file_stat, MYF(MY_WME)))
     {
-      frm_ptr= (uchar *) my_malloc(sizeof(uchar) * file_stat.st_size, MYF(0));
+      frm_ptr= (uchar *) my_malloc(sizeof(uchar) * (size_t) file_stat.st_size, MYF(0));
       if (frm_ptr)
       {
-        if (my_read(frm_file, frm_ptr, file_stat.st_size, MYF(0)) ==
+        if (my_read(frm_file, frm_ptr, (size_t) file_stat.st_size, MYF(0)) ==
             (size_t) file_stat.st_size)
-          azwrite_frm(dst, (char *) frm_ptr, file_stat.st_size);
+          azwrite_frm(dst, (char *) frm_ptr, (size_t) file_stat.st_size);
         my_free(frm_ptr);
       }
     }
@@ -821,7 +831,10 @@ int ha_archive::create(const char *name,
   /* 
     We reuse name_buff since it is available.
   */
-  if (create_info->data_file_name && create_info->data_file_name[0] != '#')
+#ifdef HAVE_READLINK
+  if (my_use_symdir &&
+      create_info->data_file_name &&
+      create_info->data_file_name[0] != '#')
   {
     DBUG_PRINT("ha_archive", ("archive will create stream file %s", 
                         create_info->data_file_name));
@@ -832,12 +845,29 @@ int ha_archive::create(const char *name,
               MY_REPLACE_EXT | MY_UNPACK_FILENAME);
   }
   else
+#endif /* HAVE_READLINK */
   {
+    if (create_info->data_file_name)
+    {
+      push_warning_printf(table_arg->in_use, Sql_condition::WARN_LEVEL_WARN,
+                          WARN_OPTION_IGNORED,
+                          ER_DEFAULT(WARN_OPTION_IGNORED),
+                          "DATA DIRECTORY");
+    }
     fn_format(name_buff, name, "", ARZ,
               MY_REPLACE_EXT | MY_UNPACK_FILENAME);
     linkname[0]= 0;
   }
 
+  /* Archive engine never uses INDEX DIRECTORY. */
+  if (create_info->index_file_name)
+  {
+    push_warning_printf(table_arg->in_use, Sql_condition::WARN_LEVEL_WARN,
+                        WARN_OPTION_IGNORED,
+                        ER_DEFAULT(WARN_OPTION_IGNORED),
+                        "INDEX DIRECTORY");
+  }
+
   /*
     There is a chance that the file was "discovered". In this case
     just use whatever file is there.
@@ -1506,34 +1536,45 @@ int ha_archive::optimize(THD* thd, HA_CH
 {
   int rc= 0;
   azio_stream writer;
+  ha_rows count;
+  my_bitmap_map *org_bitmap;
   char writer_filename[FN_REFLEN];
   DBUG_ENTER("ha_archive::optimize");
 
-  init_archive_reader();
-
-  // now we close both our writer and our reader for the rename
-  if (share->archive_write_open)
+  mysql_mutex_lock(&share->mutex);
+  if (share->in_optimize)
   {
-    if (share->archive_write.version == 1)
-      write_v1_metafile();
-    azclose(&(share->archive_write));
-    share->archive_write_open= FALSE;
+    mysql_mutex_unlock(&share->mutex);
+    DBUG_RETURN(HA_ADMIN_FAILED);
   }
+  share->in_optimize= true;
+  /* remember the number of rows */
+  count= share->rows_recorded;
+  if (share->archive_write_open)
+    azflush(&share->archive_write, Z_SYNC_FLUSH);
+  mysql_mutex_unlock(&share->mutex);
+
+  init_archive_reader();
 
   /* Lets create a file to contain the new data */
   fn_format(writer_filename, share->table_name, "", ARN, 
             MY_REPLACE_EXT | MY_UNPACK_FILENAME);
 
   if (!(azopen(&writer, writer_filename, O_CREAT|O_RDWR|O_BINARY)))
-    DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); 
+  {
+    share->in_optimize= false;
+    DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
+  }
 
   /*
     Transfer the embedded FRM so that the file can be discoverable.
     Write file offset is set to the end of the file.
   */
   if ((rc= frm_copy(&archive, &writer)))
+  {
+    share->in_optimize= false;
     goto error;
-
+  }
   /* 
     An extended rebuild is a lot more effort. We open up each row and re-record it. 
     Any dead rows are removed (aka rows that may have been partially recorded). 
@@ -1541,75 +1582,85 @@ int ha_archive::optimize(THD* thd, HA_CH
     As of Archive format 3, this is the only type that is performed, before this
     version it was just done on T_EXTEND
   */
-  if (1)
-  {
-    DBUG_PRINT("ha_archive", ("archive extended rebuild"));
 
-    /*
-      Now we will rewind the archive file so that we are positioned at the 
-      start of the file.
-    */
-    rc= read_data_header(&archive);
+  DBUG_PRINT("ha_archive", ("archive extended rebuild"));
 
-    /* 
-      On success of writing out the new header, we now fetch each row and
-      insert it into the new archive file. 
-    */
-    if (!rc)
-    {
-      share->rows_recorded= 0;
-      stats.auto_increment_value= 1;
-      share->archive_write.auto_increment= 0;
-      my_bitmap_map *org_bitmap= tmp_use_all_columns(table, table->read_set);
+  /*
+    Now we will rewind the archive file so that we are positioned at the 
+    start of the file.
+  */
+  if ((rc= read_data_header(&archive)))
+  {
+    share->in_optimize= false;
+    goto error;
+  }
 
-      while (!(rc= get_row(&archive, table->record[0])))
-      {
-        real_write_row(table->record[0], &writer);
-        /*
-          Long term it should be possible to optimize this so that
-          it is not called on each row.
-        */
-        if (table->found_next_number_field)
-        {
-          Field *field= table->found_next_number_field;
-          ulonglong auto_value=
-            (ulonglong) field->val_int(table->record[0] +
-                                       field->offset(table->record[0]));
-          if (share->archive_write.auto_increment < auto_value)
-            stats.auto_increment_value=
-              (share->archive_write.auto_increment= auto_value) + 1;
-        }
-      }
+  stats.auto_increment_value= 1;
+  org_bitmap= tmp_use_all_columns(table, table->read_set);
+  /* read rows upto the remembered rows */ 
+  for (ha_rows cur_count= count; cur_count; cur_count--)
+  {
+    if ((rc= get_row(&archive, table->record[0])))
+      break;
+    real_write_row(table->record[0], &writer);
+    if (table->found_next_number_field)
+      save_auto_increment(table, &stats.auto_increment_value);
+  }
+
+  mysql_mutex_lock(&share->mutex);
 
-      tmp_restore_column_map(table->read_set, org_bitmap);
-      share->rows_recorded= (ha_rows)writer.rows;
+  if (share->archive_write_open)
+  {
+    if (share->archive_write.version == 1)
+      write_v1_metafile();
+    azclose(&share->archive_write);
+    share->archive_write_open= FALSE;
+  }
+  if (!rc)
+  {
+    /* read the remaining rows */
+    for (count= share->rows_recorded - count; count; count--)
+    {
+      if ((rc= get_row(&archive, table->record[0])))
+        break;
+      real_write_row(table->record[0], &writer);
+      if (table->found_next_number_field)
+        save_auto_increment(table, &stats.auto_increment_value);
     }
+  }
 
-    DBUG_PRINT("info", ("recovered %llu archive rows", 
-                        (unsigned long long)share->rows_recorded));
+  tmp_restore_column_map(table->read_set, org_bitmap);
+  share->rows_recorded= (ha_rows) writer.rows;
+  share->archive_write.auto_increment= stats.auto_increment_value - 1;
+  DBUG_PRINT("info", ("recovered %llu archive rows", 
+                      (unsigned long long)share->rows_recorded));
 
-    DBUG_PRINT("ha_archive", ("recovered %llu archive rows", 
-                        (unsigned long long)share->rows_recorded));
+  DBUG_PRINT("ha_archive", ("recovered %llu archive rows", 
+                      (unsigned long long)share->rows_recorded));
 
-    /*
-      If REPAIR ... EXTENDED is requested, try to recover as much data
-      from data file as possible. In this case if we failed to read a
-      record, we assume EOF. This allows massive data loss, but we can
-      hardly do more with broken zlib stream. And this is the only way
-      to restore at least what is still recoverable.
-    */
-    if (rc && rc != HA_ERR_END_OF_FILE && !(check_opt->flags & T_EXTEND))
-      goto error;
-  } 
+  /*
+    If REPAIR ... EXTENDED is requested, try to recover as much data
+    from data file as possible. In this case if we failed to read a
+    record, we assume EOF. This allows massive data loss, but we can
+    hardly do more with broken zlib stream. And this is the only way
+    to restore at least what is still recoverable.
+  */
+  if (rc && rc != HA_ERR_END_OF_FILE && !(check_opt->flags & T_EXTEND))
+  {
+    share->in_optimize= false;
+    mysql_mutex_unlock(&share->mutex);
+    goto error;
+  }
 
   azclose(&writer);
   share->dirty= FALSE;
-  
   azclose(&archive);
+  archive_reader_open= FALSE;
 
   // make the file we just wrote be our data file
   rc= my_rename(writer_filename, share->data_file_name, MYF(0));
-
+  share->in_optimize= false;
+  mysql_mutex_unlock(&share->mutex);
 
   DBUG_RETURN(rc);
 error:

=== modified file 'storage/archive/ha_archive.h'
--- a/storage/archive/ha_archive.h	2011-10-07 06:03:14 +0000
+++ b/storage/archive/ha_archive.h	2012-02-03 14:37:46 +0000
@@ -35,6 +35,7 @@ typedef struct st_archive_share {
   mysql_mutex_t mutex;
   THR_LOCK lock;
   azio_stream archive_write;     /* Archive file we are working with */
+  bool in_optimize;
   bool archive_write_open;
   bool dirty;               /* Flag for if a flush should occur */
   bool crashed;             /* Meta file is crashed */

=== modified file 'storage/innobase/btr/btr0btr.cc'
--- a/storage/innobase/btr/btr0btr.cc	2012-01-26 11:57:53 +0000
+++ b/storage/innobase/btr/btr0btr.cc	2012-02-02 10:44:07 +0000
@@ -57,11 +57,12 @@ btr_corruption_report(
 		(unsigned) buf_block_get_space(block),
 		(unsigned) buf_block_get_page_no(block),
 		index->name, index->table_name);
-	buf_page_print(buf_block_get_frame(block), 0);
 	if (block->page.zip.data) {
 		buf_page_print(block->page.zip.data,
-			       buf_block_get_zip_size(block));
+			       buf_block_get_zip_size(block),
+			       BUF_PAGE_PRINT_NO_CRASH);
 	}
+	buf_page_print(buf_block_get_frame(block), 0, 0);
 }
 
 #ifdef UNIV_BLOB_DEBUG
@@ -1396,9 +1397,11 @@ btr_page_get_father_node_ptr_func(
 	if (btr_node_ptr_get_child_page_no(node_ptr, offsets) != page_no) {
 		rec_t*	print_rec;
 		fputs("InnoDB: Dump of the child page:\n", stderr);
-		buf_page_print(page_align(user_rec), 0);
+		buf_page_print(page_align(user_rec), 0,
+			       BUF_PAGE_PRINT_NO_CRASH);
 		fputs("InnoDB: Dump of the parent page:\n", stderr);
-		buf_page_print(page_align(node_ptr), 0);
+		buf_page_print(page_align(node_ptr), 0,
+			       BUF_PAGE_PRINT_NO_CRASH);
 
 		fputs("InnoDB: Corruption of an index tree: table ", stderr);
 		ut_print_name(stderr, NULL, TRUE, index->table_name);
@@ -1836,8 +1839,9 @@ btr_page_reorganize_low(
 	max_ins_size2 = page_get_max_insert_size_after_reorganize(page, 1);
 
 	if (data_size1 != data_size2 || max_ins_size1 != max_ins_size2) {
-		buf_page_print(page, 0);
-		buf_page_print(temp_page, 0);
+		buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH);
+		buf_page_print(temp_page, 0, BUF_PAGE_PRINT_NO_CRASH);
+
 		fprintf(stderr,
 			"InnoDB: Error: page old data size %lu"
 			" new data size %lu\n"
@@ -1848,6 +1852,7 @@ btr_page_reorganize_low(
 			(unsigned long) data_size1, (unsigned long) data_size2,
 			(unsigned long) max_ins_size1,
 			(unsigned long) max_ins_size2);
+		ut_ad(0);
 	} else {
 		success = TRUE;
 	}
@@ -4063,7 +4068,7 @@ btr_index_rec_validate(
 			(ulong) rec_get_n_fields_old(rec), (ulong) n);
 
 		if (dump_on_error) {
-			buf_page_print(page, 0);
+			buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH);
 
 			fputs("InnoDB: corrupt record ", stderr);
 			rec_print_old(stderr, rec);
@@ -4101,7 +4106,8 @@ btr_index_rec_validate(
 				(ulong) i, (ulong) len, (ulong) fixed_size);
 
 			if (dump_on_error) {
-				buf_page_print(page, 0);
+				buf_page_print(page, 0,
+					       BUF_PAGE_PRINT_NO_CRASH);
 
 				fputs("InnoDB: corrupt record ", stderr);
 				rec_print_new(stderr, rec, offsets);
@@ -4312,8 +4318,8 @@ loop:
 			btr_validate_report2(index, level, block, right_block);
 			fputs("InnoDB: broken FIL_PAGE_NEXT"
 			      " or FIL_PAGE_PREV links\n", stderr);
-			buf_page_print(page, 0);
-			buf_page_print(right_page, 0);
+			buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH);
+			buf_page_print(right_page, 0, BUF_PAGE_PRINT_NO_CRASH);
 
 			ret = FALSE;
 		}
@@ -4321,8 +4327,8 @@ loop:
 		if (page_is_comp(right_page) != page_is_comp(page)) {
 			btr_validate_report2(index, level, block, right_block);
 			fputs("InnoDB: 'compact' flag mismatch\n", stderr);
-			buf_page_print(page, 0);
-			buf_page_print(right_page, 0);
+			buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH);
+			buf_page_print(right_page, 0, BUF_PAGE_PRINT_NO_CRASH);
 
 			ret = FALSE;
 
@@ -4344,8 +4350,8 @@ loop:
 			fputs("InnoDB: records in wrong order"
 			      " on adjacent pages\n", stderr);
 
-			buf_page_print(page, 0);
-			buf_page_print(right_page, 0);
+			buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH);
+			buf_page_print(right_page, 0, BUF_PAGE_PRINT_NO_CRASH);
 
 			fputs("InnoDB: record ", stderr);
 			rec = page_rec_get_prev(page_get_supremum_rec(page));
@@ -4393,8 +4399,8 @@ loop:
 			fputs("InnoDB: node pointer to the page is wrong\n",
 			      stderr);
 
-			buf_page_print(father_page, 0);
-			buf_page_print(page, 0);
+			buf_page_print(father_page, 0, BUF_PAGE_PRINT_NO_CRASH);
+			buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH);
 
 			fputs("InnoDB: node ptr ", stderr);
 			rec_print(stderr, node_ptr, index);
@@ -4426,8 +4432,10 @@ loop:
 
 				btr_validate_report1(index, level, block);
 
-				buf_page_print(father_page, 0);
-				buf_page_print(page, 0);
+				buf_page_print(father_page, 0,
+					       BUF_PAGE_PRINT_NO_CRASH);
+				buf_page_print(page, 0,
+					       BUF_PAGE_PRINT_NO_CRASH);
 
 				fputs("InnoDB: Error: node ptrs differ"
 				      " on levels > 0\n"
@@ -4472,9 +4480,15 @@ loop:
 					btr_validate_report1(index, level,
 							     block);
 
-					buf_page_print(father_page, 0);
-					buf_page_print(page, 0);
-					buf_page_print(right_page, 0);
+					buf_page_print(
+						father_page, 0,
+						BUF_PAGE_PRINT_NO_CRASH);
+					buf_page_print(
+						page, 0,
+						BUF_PAGE_PRINT_NO_CRASH);
+					buf_page_print(
+						right_page, 0,
+						BUF_PAGE_PRINT_NO_CRASH);
 				}
 			} else {
 				page_t*	right_father_page
@@ -4492,10 +4506,18 @@ loop:
 					btr_validate_report1(index, level,
 							     block);
 
-					buf_page_print(father_page, 0);
-					buf_page_print(right_father_page, 0);
-					buf_page_print(page, 0);
-					buf_page_print(right_page, 0);
+					buf_page_print(
+						father_page, 0,
+						BUF_PAGE_PRINT_NO_CRASH);
+					buf_page_print(
+						right_father_page, 0,
+						BUF_PAGE_PRINT_NO_CRASH);
+					buf_page_print(
+						page, 0,
+						BUF_PAGE_PRINT_NO_CRASH);
+					buf_page_print(
+						right_page, 0,
+						BUF_PAGE_PRINT_NO_CRASH);
 				}
 
 				if (page_get_page_no(right_father_page)
@@ -4509,10 +4531,18 @@ loop:
 					btr_validate_report1(index, level,
 							     block);
 
-					buf_page_print(father_page, 0);
-					buf_page_print(right_father_page, 0);
-					buf_page_print(page, 0);
-					buf_page_print(right_page, 0);
+					buf_page_print(
+						father_page, 0,
+						BUF_PAGE_PRINT_NO_CRASH);
+					buf_page_print(
+						right_father_page, 0,
+						BUF_PAGE_PRINT_NO_CRASH);
+					buf_page_print(
+						page, 0,
+						BUF_PAGE_PRINT_NO_CRASH);
+					buf_page_print(
+						right_page, 0,
+						BUF_PAGE_PRINT_NO_CRASH);
 				}
 			}
 		}

=== modified file 'storage/innobase/btr/btr0sea.cc'
--- a/storage/innobase/btr/btr0sea.cc	2011-11-08 10:32:23 +0000
+++ b/storage/innobase/btr/btr0sea.cc	2012-02-02 10:44:07 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, Google Inc.
 
 Portions of this file contain modifications contributed and copyrighted by
@@ -1216,7 +1216,7 @@ cleanup:
 			index->name, (ulong) block->n_pointers);
 		rw_lock_x_unlock(&btr_search_latch);
 
-		btr_search_validate();
+		ut_ad(btr_search_validate());
 	} else {
 		rw_lock_x_unlock(&btr_search_latch);
 	}
@@ -1959,7 +1959,9 @@ btr_search_validate(void)
 					(ulong) block->curr_left_side);
 
 				if (n_page_dumps < 20) {
-					buf_page_print(page, 0);
+					buf_page_print(
+						page, 0,
+						BUF_PAGE_PRINT_NO_CRASH);
 					n_page_dumps++;
 				}
 			}

=== modified file 'storage/innobase/buf/buf0buf.cc'
--- a/storage/innobase/buf/buf0buf.cc	2012-01-26 11:57:53 +0000
+++ b/storage/innobase/buf/buf0buf.cc	2012-02-02 10:44:07 +0000
@@ -682,25 +682,30 @@ void
 buf_page_print(
 /*===========*/
 	const byte*	read_buf,	/*!< in: a database page */
-	ulint		zip_size)	/*!< in: compressed page size, or
-				0 for uncompressed pages */
+	ulint		zip_size,	/*!< in: compressed page size, or
+					0 for uncompressed pages */
+	ulint		flags)		/*!< in: 0 or
+					BUF_PAGE_PRINT_NO_CRASH or
+					BUF_PAGE_PRINT_NO_FULL */
+
 {
 #ifndef UNIV_HOTBACKUP
 	dict_index_t*	index;
 #endif /* !UNIV_HOTBACKUP */
 	ulint		size = zip_size;
 
-	ut_ad(0);
-
 	if (!size) {
 		size = UNIV_PAGE_SIZE;
 	}
 
-	ut_print_timestamp(stderr);
-	fprintf(stderr, " InnoDB: Page dump in ascii and hex (%lu bytes):\n",
-		(ulong) size);
-	ut_print_buf(stderr, read_buf, size);
-	fputs("\nInnoDB: End of page dump\n", stderr);
+	if (!(flags & BUF_PAGE_PRINT_NO_FULL)) {
+		ut_print_timestamp(stderr);
+		fprintf(stderr,
+			" InnoDB: Page dump in ascii and hex (%lu bytes):\n",
+			(ulong) size);
+		ut_print_buf(stderr, read_buf, size);
+		fputs("\nInnoDB: End of page dump\n", stderr);
+	}
 
 	if (zip_size) {
 		/* Print compressed page. */
@@ -850,6 +855,8 @@ buf_page_print(
 		      stderr);
 		break;
 	}
+
+	ut_ad(flags & BUF_PAGE_PRINT_NO_CRASH);
 }
 
 #ifndef UNIV_HOTBACKUP
@@ -3952,7 +3959,8 @@ corrupt:
 				"InnoDB: You may have to recover"
 				" from a backup.\n",
 				(ulong) bpage->offset);
-			buf_page_print(frame, buf_page_get_zip_size(bpage));
+			buf_page_print(frame, buf_page_get_zip_size(bpage),
+				       BUF_PAGE_PRINT_NO_CRASH);
 			fprintf(stderr,
 				"InnoDB: Database page corruption on disk"
 				" or a failed\n"

=== modified file 'storage/innobase/buf/buf0dblwr.cc'
--- a/storage/innobase/buf/buf0dblwr.cc	2012-01-25 15:07:48 +0000
+++ b/storage/innobase/buf/buf0dblwr.cc	2012-02-02 10:44:07 +0000
@@ -512,12 +512,16 @@ buf_dblwr_init_or_restore_pages(
 				if (buf_page_is_corrupted(page, zip_size)) {
 					fprintf(stderr,
 						"InnoDB: Dump of the page:\n");
-					buf_page_print(read_buf, zip_size);
+					buf_page_print(
+						read_buf, zip_size,
+						BUF_PAGE_PRINT_NO_CRASH);
 					fprintf(stderr,
 						"InnoDB: Dump of"
 						" corresponding page"
 						" in doublewrite buffer:\n");
-					buf_page_print(page, zip_size);
+					buf_page_print(
+						page, zip_size,
+						BUF_PAGE_PRINT_NO_CRASH);
 
 					fprintf(stderr,
 						"InnoDB: Also the page in the"
@@ -531,7 +535,7 @@ buf_dblwr_init_or_restore_pages(
 						"InnoDB: option:\n"
 						"InnoDB:"
 						" innodb_force_recovery=6\n");
-					exit(1);
+					ut_error;
 				}
 
 				/* Write the good page from the
@@ -654,7 +658,7 @@ buf_dblwr_assert_on_corrupt_block(
 /*==============================*/
 	const buf_block_t*	block)	/*!< in: block to check */
 {
-	buf_page_print(block->frame, 0);
+	buf_page_print(block->frame, 0, BUF_PAGE_PRINT_NO_CRASH);
 
 	ut_print_timestamp(stderr);
 	fprintf(stderr,

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	2012-01-31 15:16:16 +0000
+++ b/storage/innobase/handler/ha_innodb.cc	2012-02-08 13:10:23 +0000
@@ -35,6 +35,7 @@ this program; if not, write to the Free 
 			// EXPLAIN_FILENAME_MAX_EXTRA_LENGTH
 
 #include <sql_acl.h>	// PROCESS_ACL
+#include <debug_sync.h> // DEBUG_SYNC
 #include <mysys_err.h>
 #include <mysql/innodb_priv.h>
 
@@ -3810,37 +3811,114 @@ normalize_table_name_low(
 {
 	char*	name_ptr;
 	char*	db_ptr;
+	ulint	db_len;
 	char*	ptr;
 
 	/* Scan name from the end */
 
-	ptr = strend(name)-1;
+	ptr = strend(name) - 1;
 
+	/* seek to the last path separator */
 	while (ptr >= name && *ptr != '\\' && *ptr != '/') {
 		ptr--;
 	}
 
 	name_ptr = ptr + 1;
 
-	DBUG_ASSERT(ptr > name);
+	/* skip any number of path separators */
+	while (ptr >= name && (*ptr == '\\' || *ptr == '/')) {
+		ptr--;
+	}
 
-	ptr--;
+	DBUG_ASSERT(ptr >= name);
 
+	/* seek to the last but one path separator or one char before
+	the beginning of name */
+	db_len = 0;
 	while (ptr >= name && *ptr != '\\' && *ptr != '/') {
 		ptr--;
+		db_len++;
 	}
 
 	db_ptr = ptr + 1;
 
-	memcpy(norm_name, db_ptr, strlen(name) + 1 - (db_ptr - name));
+	memcpy(norm_name, db_ptr, db_len);
+
+	norm_name[db_len] = '/';
 
-	norm_name[name_ptr - db_ptr - 1] = '/';
+	memcpy(norm_name + db_len + 1, name_ptr, strlen(name_ptr) + 1);
 
 	if (set_lower_case) {
 		innobase_casedn_str(norm_name);
 	}
 }
 
+#if !defined(DBUG_OFF)
+/*********************************************************************
+Test normalize_table_name_low(). */
+static
+void
+test_normalize_table_name_low()
+/*===========================*/
+{
+	char		norm_name[128];
+	const char*	test_data[][2] = {
+		/* input, expected result */
+		{"./mysqltest/t1", "mysqltest/t1"},
+		{"./test/#sql-842b_2", "test/#sql-842b_2"},
+		{"./test/#sql-85a3_10", "test/#sql-85a3_10"},
+		{"./test/#sql2-842b-2", "test/#sql2-842b-2"},
+		{"./test/bug29807", "test/bug29807"},
+		{"./test/foo", "test/foo"},
+		{"./test/innodb_bug52663", "test/innodb_bug52663"},
+		{"./test/t", "test/t"},
+		{"./test/t1", "test/t1"},
+		{"./test/t10", "test/t10"},
+		{"/a/b/db/table", "db/table"},
+		{"/a/b/db///////table", "db/table"},
+		{"/a/b////db///////table", "db/table"},
+		{"/var/tmp/mysqld.1/#sql842b_2_10", "mysqld.1/#sql842b_2_10"},
+		{"db/table", "db/table"},
+		{"ddd/t", "ddd/t"},
+		{"d/ttt", "d/ttt"},
+		{"d/t", "d/t"},
+		{".\\mysqltest\\t1", "mysqltest/t1"},
+		{".\\test\\#sql-842b_2", "test/#sql-842b_2"},
+		{".\\test\\#sql-85a3_10", "test/#sql-85a3_10"},
+		{".\\test\\#sql2-842b-2", "test/#sql2-842b-2"},
+		{".\\test\\bug29807", "test/bug29807"},
+		{".\\test\\foo", "test/foo"},
+		{".\\test\\innodb_bug52663", "test/innodb_bug52663"},
+		{".\\test\\t", "test/t"},
+		{".\\test\\t1", "test/t1"},
+		{".\\test\\t10", "test/t10"},
+		{"C:\\a\\b\\db\\table", "db/table"},
+		{"C:\\a\\b\\db\\\\\\\\\\\\\\table", "db/table"},
+		{"C:\\a\\b\\\\\\\\db\\\\\\\\\\\\\\table", "db/table"},
+		{"C:\\var\\tmp\\mysqld.1\\#sql842b_2_10", "mysqld.1/#sql842b_2_10"},
+		{"db\\table", "db/table"},
+		{"ddd\\t", "ddd/t"},
+		{"d\\ttt", "d/ttt"},
+		{"d\\t", "d/t"},
+	};
+
+	for (size_t i = 0; i < UT_ARR_SIZE(test_data); i++) {
+		printf("test_normalize_table_name_low(): "
+		       "testing \"%s\", expected \"%s\"... ",
+		       test_data[i][0], test_data[i][1]);
+
+		normalize_table_name_low(norm_name, test_data[i][0], FALSE);
+
+		if (strcmp(norm_name, test_data[i][1]) == 0) {
+			printf("ok\n");
+		} else {
+			printf("got \"%s\"\n", norm_name);
+			ut_error;
+		}
+	}
+}
+#endif /* !DBUG_OFF */
+
 /********************************************************************//**
 Get the upper limit of the MySQL integral and floating-point type.
 @return maximum allowed value for the field */
@@ -9084,6 +9162,11 @@ ha_innobase::delete_table(
 
 	DBUG_ENTER("ha_innobase::delete_table");
 
+	DBUG_EXECUTE_IF(
+		"test_normalize_table_name_low",
+		test_normalize_table_name_low();
+	);
+
 	/* Strangely, MySQL passes the table name without the '.frm'
 	extension, in contrast to ::create */
 	normalize_table_name(norm_name, name);
@@ -9392,6 +9475,8 @@ ha_innobase::rename_table(
 	trx = innobase_trx_allocate(thd);
 
 	error = innobase_rename_table(trx, from, to, TRUE);
+
+	DEBUG_SYNC(thd, "after_innobase_rename_table");
 
 	/* Tell the InnoDB server that there might be work for
 	utility threads: */

=== modified file 'storage/innobase/ibuf/ibuf0ibuf.cc'
--- a/storage/innobase/ibuf/ibuf0ibuf.cc	2012-01-26 12:31:26 +0000
+++ b/storage/innobase/ibuf/ibuf0ibuf.cc	2012-02-02 10:44:07 +0000
@@ -2423,7 +2423,8 @@ ibuf_get_merge_page_nos_func(
 			smallest possible secondary index leaf page
 			(and that only after DROP INDEX). */
 			ut_ad(rec_page_no
-			      > IBUF_TREE_ROOT_PAGE_NO - (rec_space_id != 0));
+			      > (ulint) IBUF_TREE_ROOT_PAGE_NO
+			      - (rec_space_id != 0));
 		}
 
 #ifdef UNIV_IBUF_DEBUG
@@ -3804,9 +3805,10 @@ ibuf_insert_to_index_page(
 		      "InnoDB: but the number of fields does not match!\n",
 		      stderr);
 dump:
-		buf_page_print(page, 0);
+		buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH);
 
 		dtuple_print(stderr, entry);
+		ut_ad(0);
 
 		fputs("InnoDB: The table where where"
 		      " this index record belongs\n"
@@ -4373,12 +4375,14 @@ ibuf_merge_or_delete_for_page(
 
 			bitmap_page = ibuf_bitmap_get_map_page(space, page_no,
 							       zip_size, &mtr);
-			buf_page_print(bitmap_page, 0);
+			buf_page_print(bitmap_page, 0,
+				       BUF_PAGE_PRINT_NO_CRASH);
 			ibuf_mtr_commit(&mtr);
 
 			fputs("\nInnoDB: Dump of the page:\n", stderr);
 
-			buf_page_print(block->frame, 0);
+			buf_page_print(block->frame, 0,
+				       BUF_PAGE_PRINT_NO_CRASH);
 
 			fprintf(stderr,
 				"InnoDB: Error: corruption in the tablespace."
@@ -4398,6 +4402,7 @@ ibuf_merge_or_delete_for_page(
 				(ulong) page_no,
 				(ulong)
 				fil_page_get_type(block->frame));
+			ut_ad(0);
 		}
 	}
 

=== modified file 'storage/innobase/include/btr0btr.ic'
--- a/storage/innobase/include/btr0btr.ic	2011-11-09 02:40:33 +0000
+++ b/storage/innobase/include/btr0btr.ic	2012-02-02 10:44:07 +0000
@@ -277,7 +277,7 @@ btr_node_ptr_get_child_page_no(
 			"InnoDB: a nonsensical page number 0"
 			" in a node ptr record at offset %lu\n",
 			(ulong) page_offset(rec));
-		buf_page_print(page_align(rec), 0);
+		buf_page_print(page_align(rec), 0, 0);
 	}
 
 	return(page_no);

=== modified file 'storage/innobase/include/buf0buf.h'
--- a/storage/innobase/include/buf0buf.h	2011-12-12 12:55:18 +0000
+++ b/storage/innobase/include/buf0buf.h	2012-02-02 10:44:07 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -694,6 +694,13 @@ buf_print(void);
 /*============*/
 #endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
 #endif /* !UNIV_HOTBACKUP */
+enum buf_page_print_flags {
+	/** Do not crash at the end of buf_page_print(). */
+	BUF_PAGE_PRINT_NO_CRASH	= 1,
+	/** Do not print the full page dump. */
+	BUF_PAGE_PRINT_NO_FULL = 2
+};
+
 /********************************************************************//**
 Prints a page to stderr. */
 UNIV_INTERN
@@ -701,8 +708,11 @@ void
 buf_page_print(
 /*===========*/
 	const byte*	read_buf,	/*!< in: a database page */
-	ulint		zip_size)	/*!< in: compressed page size, or
+	ulint		zip_size,	/*!< in: compressed page size, or
 					0 for uncompressed pages */
+	ulint		flags)		/*!< in: 0 or
+					BUF_PAGE_PRINT_NO_CRASH or
+					BUF_PAGE_PRINT_NO_FULL */
 	UNIV_COLD __attribute__((nonnull));
 /********************************************************************//**
 Decompress a block.

=== modified file 'storage/innobase/include/page0page.ic'
--- a/storage/innobase/include/page0page.ic	2011-11-30 10:27:10 +0000
+++ b/storage/innobase/include/page0page.ic	2012-02-02 10:44:07 +0000
@@ -740,7 +740,7 @@ page_rec_get_next_low(
 			(void*) rec,
 			(ulong) page_get_space_id(page),
 			(ulong) page_get_page_no(page));
-		buf_page_print(page, 0);
+		buf_page_print(page, 0, 0);
 
 		ut_error;
 	} else if (offs == 0) {

=== modified file 'storage/innobase/include/univ.i'
--- a/storage/innobase/include/univ.i	2011-12-28 10:40:55 +0000
+++ b/storage/innobase/include/univ.i	2012-02-01 20:59:15 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, Google Inc.
 
 Portions of this file contain modifications contributed and copyrighted by
@@ -155,7 +155,7 @@ be excluded from instrumentation. */
 #endif /* HAVE_PSI_INTERFACE */
 
 #ifdef __WIN__
-# define YY_NO_UNISTD_H
+# define YY_NO_UNISTD_H 1
 #endif /* __WIN__ */
 
 /*			DEBUG VERSION CONTROL

=== modified file 'storage/innobase/lock/lock0lock.cc'
--- a/storage/innobase/lock/lock0lock.cc	2012-01-27 04:18:55 +0000
+++ b/storage/innobase/lock/lock0lock.cc	2012-02-02 10:44:07 +0000
@@ -1671,7 +1671,7 @@ lock_sec_rec_some_has_impl(
 
 	} else if (!lock_check_trx_id_sanity(max_trx_id, rec, index, offsets)) {
 
-		buf_page_print(page, 0);
+		buf_page_print(page, 0, 0);
 
 		/* The page is corrupt: try to avoid a crash by returning 0 */
 		trx_id = 0;

=== modified file 'storage/innobase/page/page0cur.cc'
--- a/storage/innobase/page/page0cur.cc	2011-11-20 20:17:41 +0000
+++ b/storage/innobase/page/page0cur.cc	2012-02-02 10:44:07 +0000
@@ -901,7 +901,7 @@ page_cur_parse_insert_rec(
 		ut_print_buf(stderr, ptr2, 300);
 		putc('\n', stderr);
 
-		buf_page_print(page, 0);
+		buf_page_print(page, 0, 0);
 
 		ut_error;
 	}

=== modified file 'storage/innobase/page/page0page.cc'
--- a/storage/innobase/page/page0page.cc	2012-01-26 11:57:53 +0000
+++ b/storage/innobase/page/page0page.cc	2012-02-02 10:44:07 +0000
@@ -148,7 +148,7 @@ page_dir_find_owner_slot(
 			fputs("\n"
 			      "InnoDB: on that page!\n", stderr);
 
-			buf_page_print(page, 0);
+			buf_page_print(page, 0, 0);
 
 			ut_error;
 		}
@@ -569,8 +569,10 @@ page_copy_rec_list_end_no_locks(
 			/* Track an assertion failure reported on the mailing
 			list on June 18th, 2003 */
 
-			buf_page_print(new_page, 0);
-			buf_page_print(page_align(rec), 0);
+			buf_page_print(new_page, 0,
+				       BUF_PAGE_PRINT_NO_CRASH);
+			buf_page_print(page_align(rec), 0,
+				       BUF_PAGE_PRINT_NO_CRASH);
 			ut_print_timestamp(stderr);
 
 			fprintf(stderr,
@@ -1831,7 +1833,7 @@ page_check_dir(
 		fprintf(stderr,
 			"InnoDB: Page directory corruption:"
 			" infimum not pointed to\n");
-		buf_page_print(page, 0);
+		buf_page_print(page, 0, 0);
 	}
 
 	if (UNIV_UNLIKELY(!page_rec_is_supremum_low(supremum_offs))) {
@@ -1839,7 +1841,7 @@ page_check_dir(
 		fprintf(stderr,
 			"InnoDB: Page directory corruption:"
 			" supremum not pointed to\n");
-		buf_page_print(page, 0);
+		buf_page_print(page, 0, 0);
 	}
 }
 #endif /* !UNIV_HOTBACKUP */
@@ -2543,7 +2545,7 @@ func_exit2:
 			(ulong) page_get_space_id(page),
 			(ulong) page_get_page_no(page),
 			index->name);
-		buf_page_print(page, 0);
+		buf_page_print(page, 0, 0);
 	}
 
 	return(ret);

=== modified file 'storage/innobase/row/row0merge.cc'
--- a/storage/innobase/row/row0merge.cc	2012-01-18 15:39:14 +0000
+++ b/storage/innobase/row/row0merge.cc	2012-02-02 12:00:50 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 2005, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -664,7 +664,7 @@ row_merge_buf_write(
 						   REC_STATUS_ORDINARY,
 						   entry, n_fields,
 						   &extra_size);
-		ut_ad(size > extra_size);
+		ut_ad(size >= extra_size);
 		ut_ad(extra_size >= REC_N_NEW_EXTRA_BYTES);
 		extra_size -= REC_N_NEW_EXTRA_BYTES;
 		size -= REC_N_NEW_EXTRA_BYTES;

=== modified file 'storage/innobase/row/row0sel.cc'
--- a/storage/innobase/row/row0sel.cc	2012-01-26 11:57:53 +0000
+++ b/storage/innobase/row/row0sel.cc	2012-02-02 10:44:07 +0000
@@ -4286,7 +4286,8 @@ rec_loop:
 wrong_offs:
 		if (srv_force_recovery == 0 || moves_up == FALSE) {
 			ut_print_timestamp(stderr);
-			buf_page_print(page_align(rec), 0);
+			buf_page_print(page_align(rec), 0,
+				       BUF_PAGE_PRINT_NO_CRASH);
 			fprintf(stderr,
 				"\nInnoDB: rec address %p,"
 				" buf block fix count %lu\n",
@@ -4305,7 +4306,7 @@ wrong_offs:
 			      "InnoDB: restore from a backup, or"
 			      " dump + drop + reimport the table.\n",
 			      stderr);
-
+			ut_ad(0);
 			err = DB_CORRUPTION;
 
 			goto lock_wait_or_error;

=== modified file 'storage/innobase/srv/srv0mon.cc'
--- a/storage/innobase/srv/srv0mon.cc	2011-12-19 08:43:28 +0000
+++ b/storage/innobase/srv/srv0mon.cc	2012-02-02 09:23:51 +0000
@@ -720,7 +720,7 @@ static monitor_info_t	innodb_counter_inf
 	 MONITOR_NONE,
 	 MONITOR_DEFAULT_START, MONITOR_NUM_UNDO_SLOT_CACHED},
 
-	{"trx_rseg_curent_size", "transaction",
+	{"trx_rseg_current_size", "transaction",
 	 "Current rollback segment size in pages",
 	 static_cast<monitor_type_t>(
 	 MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),

=== modified file 'storage/myisam/ha_myisam.cc'
--- a/storage/myisam/ha_myisam.cc	2012-01-31 15:16:16 +0000
+++ b/storage/myisam/ha_myisam.cc	2012-02-07 23:33:54 +0000
@@ -78,10 +78,10 @@ static MYSQL_THDVAR_ULONG(repair_threads
   "disables parallel repair", NULL, NULL,
   1, 1, ULONG_MAX, 1);
 
-static MYSQL_THDVAR_ULONG(sort_buffer_size, PLUGIN_VAR_RQCMDARG,
+static MYSQL_THDVAR_ULONGLONG(sort_buffer_size, PLUGIN_VAR_RQCMDARG,
   "The buffer that is allocated when sorting the index when doing "
   "a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE", NULL, NULL,
-  8192*1024, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD), ULONG_MAX, 1);
+  8192 * 1024, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD), SIZE_T_MAX, 1);
 
 static MYSQL_SYSVAR_BOOL(use_mmap, opt_myisam_use_mmap, PLUGIN_VAR_NOCMDARG,
   "Use memory mapping for reading and writing MyISAM tables", NULL, NULL, FALSE);
@@ -1942,9 +1942,26 @@ int ha_myisam::create(const char *name, 
                                (ulonglong) 0);
   create_info.data_file_length= ((ulonglong) share->max_rows *
                                  share->avg_row_length);
-  create_info.data_file_name= ha_create_info->data_file_name;
-  create_info.index_file_name= ha_create_info->index_file_name;
   create_info.language= share->table_charset->number;
+
+#ifdef HAVE_READLINK
+  if (my_use_symdir)
+  {
+    create_info.data_file_name= ha_create_info->data_file_name;
+    create_info.index_file_name= ha_create_info->index_file_name;
+  }
+  else
+#endif /* HAVE_READLINK */
+  {
+    if (ha_create_info->data_file_name)
+      push_warning_printf(table_arg->in_use, Sql_condition::WARN_LEVEL_WARN,
+                          WARN_OPTION_IGNORED, ER(WARN_OPTION_IGNORED),
+                          "DATA DIRECTORY");
+    if (ha_create_info->index_file_name)
+      push_warning_printf(table_arg->in_use, Sql_condition::WARN_LEVEL_WARN,
+                          WARN_OPTION_IGNORED, ER(WARN_OPTION_IGNORED),
+                          "INDEX DIRECTORY");
+  }
 
   if (ha_create_info->options & HA_LEX_CREATE_TMP_TABLE)
     create_flags|= HA_CREATE_TMP_TABLE;

=== modified file 'storage/myisam/ha_myisam.h'
--- a/storage/myisam/ha_myisam.h	2011-11-08 11:37:54 +0000
+++ b/storage/myisam/ha_myisam.h	2012-02-02 12:48:48 +0000
@@ -31,7 +31,6 @@ typedef struct st_ha_create_information 
 #define HA_RECOVER_QUICK	8	/* Don't check rows in data file */
 #define HA_RECOVER_OFF         16	/* No automatic recover */
 
-extern ulong myisam_sort_buffer_size;
 extern TYPELIB myisam_recover_typelib;
 extern const char *myisam_recover_names[];
 extern ulonglong myisam_recover_options;

=== modified file 'storage/myisam/mi_check.c'
--- a/storage/myisam/mi_check.c	2011-09-26 12:42:12 +0000
+++ b/storage/myisam/mi_check.c	2012-02-02 12:48:48 +0000
@@ -2429,7 +2429,7 @@ int mi_repair_by_sort(MI_CHECK *param, r
 
     if (_create_index_by_sort(&sort_param,
 			      (my_bool) (!(param->testflag & T_VERBOSE)),
-			      (uint) param->sort_buffer_length))
+                              param->sort_buffer_length))
     {
       param->retry_repair=1;
       goto err;
@@ -4303,14 +4303,6 @@ int recreate_table(MI_CHECK *param, MI_I
     u_ptr->seg=keyseg;
     keyseg+=u_ptr->keysegs+1;
   }
-  if (share.options & HA_OPTION_COMPRESS_RECORD)
-    share.base.records=max_records=info.state->records;
-  else if (share.base.min_pack_length)
-    max_records=(ha_rows) (mysql_file_seek(info.dfile, 0L, MY_SEEK_END,
-                                           MYF(0)) /
-			   (ulong) share.base.min_pack_length);
-  else
-    max_records=0;
   unpack= (share.options & HA_OPTION_COMPRESS_RECORD) &&
     (param->testflag & T_UNPACK);
   share.options&= ~HA_OPTION_TEMP_COMPRESS_RECORD;
@@ -4320,10 +4312,17 @@ int recreate_table(MI_CHECK *param, MI_I
   set_if_bigger(file_length,param->max_data_file_length);
   set_if_bigger(file_length,tmp_length);
   set_if_bigger(file_length,(ulonglong) share.base.max_data_file_length);
+ 
+  if (share.options & HA_OPTION_COMPRESS_RECORD)
+    share.base.records= max_records= info.state->records;
+  else if (!(share.options & HA_OPTION_PACK_RECORD))
+    max_records= (ha_rows) (file_length / share.base.pack_reclength);
+  else
+    max_records= 0;
 
   (void) mi_close(*org_info);
   memset(&create_info, 0, sizeof(create_info));
-  create_info.max_rows= MY_MAX(max_records, share.base.records);
+  create_info.max_rows= max_records;
   create_info.reloc_rows=share.base.reloc;
   create_info.old_options=(share.options |
 			   (unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0));

=== modified file 'storage/myisam/mi_dbug.c'
--- a/storage/myisam/mi_dbug.c	2011-06-30 15:46:53 +0000
+++ b/storage/myisam/mi_dbug.c	2012-02-07 13:06:27 +0000
@@ -36,7 +36,6 @@ void _mi_print_key(FILE *stream, registe
   {
     if (flag++)
       (void) putc('-',stream);
-    end= key+ keyseg->length;
     if (keyseg->flag & HA_NULL_PART)
     {
       /* A NULL value is encoded by a 1-byte flag. Zero means NULL. */
@@ -46,6 +45,7 @@ void _mi_print_key(FILE *stream, registe
 	continue;
       }
     }
+    end= key + keyseg->length;
 
     switch (keyseg->type) {
     case HA_KEYTYPE_BINARY:

=== modified file 'storage/myisam/myisamchk.c'
--- a/storage/myisam/myisamchk.c	2011-06-30 15:50:45 +0000
+++ b/storage/myisam/myisamchk.c	2012-02-02 12:48:48 +0000
@@ -297,9 +297,9 @@ static struct my_option my_long_options[
     INT_MAX32, (long) MALLOC_OVERHEAD, (long) 1L, 0},
   { "sort_buffer_size", OPT_SORT_BUFFER_SIZE, "",
     &check_param.sort_buffer_length,
-    &check_param.sort_buffer_length, 0, GET_ULONG, REQUIRED_ARG,
+    &check_param.sort_buffer_length, 0, GET_ULL, REQUIRED_ARG,
     (long) SORT_BUFFER_INIT, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD),
-    ULONG_MAX, (long) MALLOC_OVERHEAD, (long) 1L, 0},
+    SIZE_T_MAX, (long) MALLOC_OVERHEAD, (long) 1L, 0},
   { "sort_key_blocks", OPT_SORT_KEY_BLOCKS, "",
     &check_param.sort_key_blocks,
     &check_param.sort_key_blocks, 0, GET_ULONG, REQUIRED_ARG,

=== modified file 'storage/myisam/myisamdef.h'
--- a/storage/myisam/myisamdef.h	2011-07-04 00:25:46 +0000
+++ b/storage/myisam/myisamdef.h	2012-02-02 12:48:48 +0000
@@ -326,9 +326,10 @@ typedef struct st_mi_sort_param
   */
   ulonglong unique[MI_MAX_KEY_SEG+1];
   ulonglong notnull[MI_MAX_KEY_SEG+1];
+  ulonglong sortbuff_size;
 
   my_off_t pos,max_pos,filepos,start_recpos;
-  uint key, key_length,real_key_length,sortbuff_size;
+  uint key, key_length,real_key_length;
   uint maxbuffers, keys, find_length, sort_keys_length;
   my_bool fix_datafile, master;
   my_bool calc_checksum;                /* calculate table checksum */
@@ -779,7 +780,7 @@ pthread_handler_t thr_find_all_keys(void
 int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file);
 
 int sort_write_record(MI_SORT_PARAM *sort_param);
-int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong);
+int _create_index_by_sort(MI_SORT_PARAM *info, my_bool no_messages, ulonglong);
 
 extern void mi_set_index_cond_func(MI_INFO *info, index_cond_func_t func,
                                    void *func_arg);

=== modified file 'storage/myisam/sort.c'
--- a/storage/myisam/sort.c	2011-08-29 12:08:58 +0000
+++ b/storage/myisam/sort.c	2012-02-02 12:48:48 +0000
@@ -99,10 +99,11 @@ my_var_write(MI_SORT_PARAM *info, IO_CAC
 */
 
 int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
-			  ulong sortbuff_size)
+			  ulonglong sortbuff_size)
 {
   int error,maxbuffer,skr;
-  uint memavl,old_memavl,keys,sort_length;
+  uint sort_length, keys;
+  ulonglong memavl, old_memavl;
   DYNAMIC_ARRAY buffpek;
   ha_rows records;
   uchar **sort_keys;
@@ -134,6 +135,9 @@ int _create_index_by_sort(MI_SORT_PARAM 
   sort_length=	info->key_length;
   LINT_INIT(keys);
 
+  if ((memavl - sizeof(BUFFPEK)) / (sort_length + sizeof(char *)) > UINT_MAX32)
+    memavl= sizeof(BUFFPEK) + UINT_MAX32 * (sort_length + sizeof(char *));
+
   while (memavl >= MIN_SORT_BUFFER)
   {
     if ((records < UINT_MAX32) && 
@@ -308,7 +312,8 @@ pthread_handler_t thr_find_all_keys(void
 {
   MI_SORT_PARAM *sort_param= (MI_SORT_PARAM*) arg;
   int error;
-  uint memavl,old_memavl,keys,sort_length;
+  ulonglong memavl, old_memavl;
+  uint keys, sort_length;
   uint idx, maxbuffer;
   uchar **sort_keys=0;
 
@@ -348,6 +353,10 @@ pthread_handler_t thr_find_all_keys(void
     idx=          (uint)sort_param->sort_info->max_records;
     sort_length=  sort_param->key_length;
     maxbuffer=    1;
+
+    if ((memavl - sizeof(BUFFPEK)) / (sort_length +
+                                      sizeof(char *)) > UINT_MAX32)
+      memavl= sizeof(BUFFPEK) + UINT_MAX32 * (sort_length + sizeof(char *));    
 
     while (memavl >= MIN_SORT_BUFFER)
     {

=== modified file 'unittest/gunit/CMakeLists.txt'
--- a/unittest/gunit/CMakeLists.txt	2012-01-31 15:16:16 +0000
+++ b/unittest/gunit/CMakeLists.txt	2012-02-07 11:56:30 +0000
@@ -233,6 +233,7 @@ SET(TESTS
   decimal
   dynarray
   filesort_buffer
+  filesort_compare
   mdl
   mdl_mytap
   my_bitmap

=== modified file 'unittest/gunit/dynarray-t.cc'
--- a/unittest/gunit/dynarray-t.cc	2011-12-20 09:51:05 +0000
+++ b/unittest/gunit/dynarray-t.cc	2012-02-07 11:56:30 +0000
@@ -148,7 +148,7 @@ void generate_test_data(Key_use *keys, T
 
 // Play around with these constants to see std::sort speedup vs. my_qsort.
 const int num_elements= 200;
-const int num_iterations= 10;
+const int num_iterations= 1000;
 
 /*
   This class is used for comparing performance of

=== added file 'unittest/gunit/filesort_compare-t.cc'
--- a/unittest/gunit/filesort_compare-t.cc	1970-01-01 00:00:00 +0000
+++ b/unittest/gunit/filesort_compare-t.cc	2012-02-07 11:56:30 +0000
@@ -0,0 +1,466 @@
+/* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA */
+
+// First include (the generated) my_config.h, to get correct platform defines.
+#include "my_config.h"
+#include <gtest/gtest.h>
+
+#include "filesort_utils.h"
+
+#include <algorithm>
+#include <memory>
+#include <vector>
+
+namespace {
+
+/*
+  Below are some performance microbenchmarks in order to compare our sorting
+  options: 
+  my_qsort2        - requires no extra memory, uses insert sort on small ranges,
+                     uses quicksort on larger ranges
+  radixsort -        requires extra memory: array of n pointers,
+                     seems to be quite fast on intel *when it is appliccable*:
+                     if (size <= 20 && items >= 1000 && items < 100000)
+  std::sort -        requires no extra memory,
+                     typically implemented with introsort/insertion sort
+  std::stable_sort - requires extra memory: array of n pointers,
+                     typically implemented with mergesort
+
+  The record format for filesort is constructed in such a way that we can
+  compare records byte-by-byte, without knowing the data types.
+  Nullable fields (maybe_null()) are pre-pended with an extra byte.
+  If we are sorting in descending mode, all the bytes are simply flipped.
+
+  This means that any variant of memcmp() can be used for comparing record.
+  Below we test different variants, including memcmp() itself.
+*/
+
+// A simple helper function to determine array size.
+template <class T, int size>
+int array_size(const T (&)[size])
+{
+  return size;
+}
+
+inline int bytes_to_int(const uchar *s)
+{
+  int val;
+  longget(val, s);
+  return val ^ 0x80000000;
+}
+
+inline void int_to_bytes(uchar *s, int val)
+{
+  val= val ^ 0x80000000;
+  longstore(s, val);
+}
+
+
+TEST(AlignmentTest, IntsToBytesToInt)
+{
+  uchar buf[10];
+  memset(buf, 0, sizeof(buf));
+  for (int ix= 0; ix < 6; ++ix)
+  {
+    int test_data[]= { INT_MIN32, -42, -1, 0, 1, 42, INT_MAX32 };
+    for (int iy= 0; iy < array_size(test_data); ++iy)
+    {
+      int val= test_data[iy];
+      int_to_bytes(buf+ix, val);
+      EXPECT_EQ(val, bytes_to_int(buf+ix));
+    }
+  }
+}
+
+
+class FileSortCompareTest : public ::testing::Test
+{
+protected:
+  // Do each sort algorithm this many times. Increase value for benchmarking!
+  static const int num_iterations= 1;
+  // Number of records.
+  static const int num_records= 100 * 1000;
+  // Number of keys in each record.
+  static const int keys_per_record= 4;
+  // Size of each record.
+  static const int record_size= keys_per_record * sizeof(int);
+
+  // Static buffer containing data to be sorted.
+  // (actually: we only sort the sort_keys below, data is stable).
+  static std::vector<int> test_data;
+
+  static void SetUpTestCase()
+  {
+    test_data.reserve(num_records * keys_per_record);
+    union { int val; uchar buf[sizeof(int)]; } sort_str;
+
+    for (int ix= 0; ix < num_records * keys_per_record; ++ix)
+    {
+      int val= ix / (10 * keys_per_record);
+      if (ix % 10 == 0) val= -val;
+      int_to_bytes(sort_str.buf, val);
+      test_data.push_back(sort_str.val);
+    }
+    // Comment away shuffling for testing partially pre-sorted data.
+    std::random_shuffle(test_data.begin(), test_data.end());
+  }
+
+  static void TearDownTestCase()
+  {
+    // Delete the data now, rather than during exit().
+    std::vector<int>().swap(test_data);
+  }
+
+  virtual void SetUp()
+  {
+    sort_keys= new uchar* [num_records];
+    for (int ix= 0; ix < num_records; ++ix)
+      sort_keys[ix]=
+        static_cast<uchar*>(static_cast<void*>(&test_data[keys_per_record*ix]));
+  }
+
+  virtual void TearDown()
+  {
+    delete[] sort_keys;
+  }
+
+  uchar **sort_keys;
+};
+std::vector<int> FileSortCompareTest::test_data;
+
+/*
+  Some different mem_compare functions.
+  The first one seems to win on all platforms, except sparc,
+  where the builtin memcmp() wins.
+ */
+inline bool mem_compare_1(const uchar *s1, const uchar *s2, size_t len)
+{
+  do {
+    if (*s1++ != *s2++)
+      return *--s1 < *--s2;
+  } while (--len != 0);
+  return false;
+}
+
+inline bool mem_compare_2(const uchar *s1, const uchar *s2, size_t len)
+{
+  int v= 0;
+  while (len-- > 0 && v == 0)
+  {
+    v= *(s1++) - *(s2++);
+  }
+  return v < 0;
+}
+
+inline bool mem_compare_3(const uchar *s1, const uchar *s2, size_t len)
+{
+  while (--len && (s1[0] == s2[0]))
+  {
+    ++s1; ++s2;
+  }
+  return s1[0] < s2[0];
+}
+
+#if defined(__WIN__)
+#pragma intrinsic(memcmp)
+#endif
+// For gcc, __builtin_memcmp is actually *slower* than the library call:
+// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
+
+
+class Mem_compare_memcmp :
+  public std::binary_function<const uchar*, const uchar*, bool>
+{
+public:
+  Mem_compare_memcmp(size_t n) : m_size(n) {}
+  bool operator()(const uchar *s1, const uchar *s2)
+  {
+    return memcmp(s1, s2, m_size) < 0;
+  }
+  size_t m_size;
+};
+
+
+class Mem_compare_1 :
+  public std::binary_function<const uchar*, const uchar*, bool>
+{
+public:
+  Mem_compare_1(size_t n) : m_size(n) {}
+  bool operator()(const uchar *s1, const uchar *s2)
+  {
+    return mem_compare_1(s1, s2, m_size);
+  }
+  size_t m_size;
+};
+
+
+class Mem_compare_2 :
+  public std::binary_function<const uchar*, const uchar*, bool>
+{
+public:
+  Mem_compare_2(size_t n) : m_size(n) {}
+  bool operator()(const uchar *s1, const uchar *s2)
+  {
+    return mem_compare_2(s1, s2, m_size);
+  }
+  size_t m_size;
+};
+
+
+class Mem_compare_3 :
+  public std::binary_function<const uchar*, const uchar*, bool>
+{
+public:
+  Mem_compare_3(size_t n) : m_size(n) {}
+  bool operator()(const uchar *s1, const uchar *s2)
+  {
+    return mem_compare_3(s1, s2, m_size);
+  }
+  size_t m_size;
+};
+
+
+#define COMPARE(N) if (s1[N] != s2[N]) return s1[N] < s2[N]
+
+class Mem_compare_0 : 
+  public std::binary_function<const uchar*, const uchar*, bool>
+{
+public:
+  Mem_compare_0(size_t n) : m_size(n) {}
+  bool operator()(const uchar *s1, const uchar *s2)
+  {
+    size_t len= m_size;
+    while(len)
+    {
+      COMPARE(0);
+      COMPARE(1);
+      COMPARE(2);
+      COMPARE(3);
+      len-= 4;
+      s1 += 4;
+      s2 += 4;
+    }
+    return s1[0] < s2[0];
+  }
+  size_t m_size;
+};
+
+
+// This one works for any number of keys.
+// We treat the first key as int, the rest byte-by-byte.
+class Mem_compare_int : 
+  public std::binary_function<const uchar*, const uchar*, bool>
+{
+public:
+  Mem_compare_int(size_t n) : m_size(n), rest(n - sizeof(int)) {}
+  bool operator()(const uchar *s1, const uchar *s2)
+  {
+    int int1= bytes_to_int(s1);
+    int int2= bytes_to_int(s2);
+    if (int1 == int2)
+      return mem_compare_1(s1 + rest, s2 + rest, rest);
+    return int1 < int2;
+  }
+private:
+  size_t m_size;
+  const size_t rest;
+};
+
+class Mem_compare_int_4 :
+  public std::binary_function<const uchar*, const uchar*, bool>
+{
+public:
+  Mem_compare_int_4(size_t) : keyno(1) {}
+  bool operator() (const uchar *s1, const uchar *s2)
+  {
+    int inta1= bytes_to_int(s1);
+    int intb1= bytes_to_int(s2);
+    if (keyno < 4 && inta1 == intb1)
+    {
+      ++keyno;
+      return operator()(s1 + sizeof(int), s2 + sizeof(int));
+    }
+    return inta1 < intb1;
+  }
+  int keyno;
+};
+
+/*
+  Several sorting tests below, each one runs num_iterations.
+  For each iteration we take a copy of the key pointers, and sort the copy.
+  Most of the tests below are run with std::sort and std::stable_sort.
+  Stable sort seems to be faster for all test cases, on all platforms.
+ */
+TEST_F(FileSortCompareTest, SetUpOnly)
+{
+  for (int ix= 0; ix < num_iterations; ++ix)
+  {
+    std::vector<uchar*> keys(sort_keys, sort_keys + num_records);
+  }
+}
+
+TEST_F(FileSortCompareTest, RadixSort)
+{
+  for (int ix= 0; ix < num_iterations; ++ix)
+  {
+    std::vector<uchar*> keys(sort_keys, sort_keys + num_records);
+    std::pair<uchar**, ptrdiff_t> buffer=
+      std::get_temporary_buffer<uchar*>(num_records);
+    radixsort_for_str_ptr(&keys[0], num_records, record_size, buffer.first);
+    std::return_temporary_buffer(buffer.first);
+  }
+}
+
+TEST_F(FileSortCompareTest, MyQsort)
+{
+  size_t size= record_size;
+  for (int ix= 0; ix < num_iterations; ++ix)
+  {
+    std::vector<uchar*> keys(sort_keys, sort_keys + num_records);
+    my_qsort2((uchar*) &keys[0], num_records, sizeof(uchar*),
+              get_ptr_compare(record_size), &size);
+  }
+}
+
+TEST_F(FileSortCompareTest, StdSortmemcmp)
+{
+  for (int ix= 0; ix < num_iterations; ++ix)
+  {
+    std::vector<uchar*> keys(sort_keys, sort_keys + num_records);
+    std::sort(keys.begin(), keys.end(), Mem_compare_memcmp(record_size));
+  }
+}
+
+TEST_F(FileSortCompareTest, StdStableSortmemcmp)
+{
+  for (int ix= 0; ix < num_iterations; ++ix)
+  {
+    std::vector<uchar*> keys(sort_keys, sort_keys + num_records);
+    std::stable_sort(keys.begin(), keys.end(),
+                     Mem_compare_memcmp(record_size));
+  }
+}
+
+TEST_F(FileSortCompareTest, StdSortCompare1)
+{
+  for (int ix= 0; ix < num_iterations; ++ix)
+  {
+    std::vector<uchar*> keys(sort_keys, sort_keys + num_records);
+    std::sort(keys.begin(), keys.end(), Mem_compare_1(record_size));
+  }
+}
+
+TEST_F(FileSortCompareTest, StdStableSortCompare1)
+{
+  for (int ix= 0; ix < num_iterations; ++ix)
+  {
+    std::vector<uchar*> keys(sort_keys, sort_keys + num_records);
+    std::stable_sort(keys.begin(), keys.end(), Mem_compare_1(record_size));
+  }
+}
+
+TEST_F(FileSortCompareTest, StdSortCompare2)
+{
+  for (int ix= 0; ix < num_iterations; ++ix)
+  {
+    std::vector<uchar*> keys(sort_keys, sort_keys + num_records);
+    std::sort(keys.begin(), keys.end(), Mem_compare_2(record_size));
+  }
+}
+
+TEST_F(FileSortCompareTest, StdStableSortCompare2)
+{
+  for (int ix= 0; ix < num_iterations; ++ix)
+  {
+    std::vector<uchar*> keys(sort_keys, sort_keys + num_records);
+    std::stable_sort(keys.begin(), keys.end(), Mem_compare_2(record_size));
+  }
+}
+
+TEST_F(FileSortCompareTest, StdSortCompare3)
+{
+  for (int ix= 0; ix < num_iterations; ++ix)
+  {
+    std::vector<uchar*> keys(sort_keys, sort_keys + num_records);
+    std::sort(keys.begin(), keys.end(), Mem_compare_3(record_size));
+  }
+}
+
+TEST_F(FileSortCompareTest, StdStableSortCompare3)
+{
+  for (int ix= 0; ix < num_iterations; ++ix)
+  {
+    std::vector<uchar*> keys(sort_keys, sort_keys + num_records);
+    std::stable_sort(keys.begin(), keys.end(), Mem_compare_3(record_size));
+  }
+}
+
+TEST_F(FileSortCompareTest, StdSortCompare4)
+{
+  for (int ix= 0; ix < num_iterations; ++ix)
+  {
+    std::vector<uchar*> keys(sort_keys, sort_keys + num_records);
+    std::sort(keys.begin(), keys.end(), Mem_compare_0(record_size));
+  }
+}
+
+TEST_F(FileSortCompareTest, StdStableSortCompare4)
+{
+  for (int ix= 0; ix < num_iterations; ++ix)
+  {
+    std::vector<uchar*> keys(sort_keys, sort_keys + num_records);
+    std::stable_sort(keys.begin(), keys.end(), Mem_compare_0(record_size));
+  }
+}
+
+TEST_F(FileSortCompareTest, StdSortIntCompare)
+{
+  for (int ix= 0; ix < num_iterations; ++ix)
+  {
+    std::vector<uchar*> keys(sort_keys, sort_keys + num_records);
+    std::sort(keys.begin(), keys.end(), Mem_compare_int(record_size));
+  }
+}
+
+TEST_F(FileSortCompareTest, StdStableSortIntCompare)
+{
+  for (int ix= 0; ix < num_iterations; ++ix)
+  {
+    std::vector<uchar*> keys(sort_keys, sort_keys + num_records);
+    std::stable_sort(keys.begin(), keys.end(), Mem_compare_int(record_size));
+  }
+}
+
+TEST_F(FileSortCompareTest, StdSortIntIntIntInt)
+{
+  for (int ix= 0; ix < num_iterations; ++ix)
+  {
+    std::vector<uchar*> keys(sort_keys, sort_keys + num_records);
+    std::sort(keys.begin(), keys.end(),
+              Mem_compare_int_4(record_size));
+  }
+}
+
+TEST_F(FileSortCompareTest, StdStableSortIntIntIntInt)
+{
+  for (int ix= 0; ix < num_iterations; ++ix)
+  {
+    std::vector<uchar*> keys(sort_keys, sort_keys + num_records);
+    std::stable_sort(keys.begin(), keys.end(),
+                     Mem_compare_int_4(record_size));
+  }
+}
+
+}  // namespace

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (roy.lyseng:3814 to 3864) Bug#13354910Roy Lyseng10 Feb