Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-3810

Item in condition with destroyed virtual table

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 5.5.27, 5.3.9
    • Fix Version/s: 5.5.28a, 5.3.10
    • Component/s: None
    • Labels:
      None

      Description

      If add to setup_without_group call of condition virtual method it will kill server during virew.test:

      --- sql/sql_select.cc	2012-08-31 22:23:30 +0000
      +++ sql/sql_select.cc	2012-10-15 12:36:35 +0000
      @@ -564,6 +564,7 @@ inline int setup_without_group(THD *thd,
       
         thd->lex->allow_sum_func&= ~(1 << thd->lex->current_select->nest_level);
         res= setup_conds(thd, tables, leaves, conds);
      +  DBUG_PRINT("info", ("type %u", (uint)((*conds) ? (*conds)->type(): 0)));
       
         /* it's not wrong to have non-aggregated columns in a WHERE */
         thd->lex->current_select->set_non_agg_field_used(saved_non_agg_field_used);
      

      The problematic test suite is

      --echo #
      --echo # LP bug #793386: unexpected 'Duplicate column name ''' error
      --echo #                 at the second execution of a PS using a view 
      --echo #
      
      CREATE TABLE t1 (f1 int, f2 int, f3 int, f4 int);
      
      CREATE VIEW v1 AS
        SELECT t.f1, t.f2, s.f3, s.f4 FROM t1 t, t1 s
          WHERE t.f4 >= s.f2 AND s.f3 < 0;
      
      PREPARE stmt1 FROM 
       "SELECT s.f1 AS f1, s.f2 AS f2, s.f3 AS f3, t.f4 AS f4
          FROM v1 AS t LEFT JOIN v1 AS s ON t.f4=s.f4 WHERE t.f2 <> 1225";
      EXECUTE stmt1;
      EXECUTE stmt1;
      
      DEALLOCATE PREPARE stmt1;
      
      DROP VIEW v1;
      DROP TABLE t1;
      

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            sanja Oleksandr Byelkin added a comment -

            SELECT_LEX::first_execution is correct.
            So it could be wrong memory to allocate the copy of AND/OR...

            Show
            sanja Oleksandr Byelkin added a comment - SELECT_LEX::first_execution is correct. So it could be wrong memory to allocate the copy of AND/OR...
            Hide
            sanja Oleksandr Byelkin added a comment -

            Real problem is that every reinit_stmt_before_use should copy WHERE, but on second execution lex->all_select_list changed by mysql_derived_merge (of first execution), so second reinit_stmt_before_use reinit only one SELECT when then used non reinited one.

            Show
            sanja Oleksandr Byelkin added a comment - Real problem is that every reinit_stmt_before_use should copy WHERE, but on second execution lex->all_select_list changed by mysql_derived_merge (of first execution), so second reinit_stmt_before_use reinit only one SELECT when then used non reinited one.
            Hide
            sanja Oleksandr Byelkin added a comment -

            mysql_derived_prepare() prepare finds removed SELECT_LEX via derived table reference.

            Show
            sanja Oleksandr Byelkin added a comment - mysql_derived_prepare() prepare finds removed SELECT_LEX via derived table reference.
            Hide
            sanja Oleksandr Byelkin added a comment -

            fix commited, all tests passed.

            Show
            sanja Oleksandr Byelkin added a comment - fix commited, all tests passed.
            Hide
            timour Timour Katchaounov added a comment -

            Sanja confirmed that the patch was reviewed by Igor.
            Pushed to 5.3 by Timour.

            Show
            timour Timour Katchaounov added a comment - Sanja confirmed that the patch was reviewed by Igor. Pushed to 5.3 by Timour.

              People

              • Assignee:
                sanja Oleksandr Byelkin
                Reporter:
                sanja Oleksandr Byelkin
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: