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

View is created with invalid definition which causes ERROR 1241 (21000): Operand should contain 1 column(s)

    XMLWordPrintable

    Details

    • Sprint:
      10.2.4-1, 10.2.4-2

      Description

      MariaDB [test]> CREATE OR REPLACE VIEW v1 AS SELECT (2, 3) NOT IN ( SELECT i, j FROM t1 );
      Query OK, 0 rows affected (0.10 sec)
       
      MariaDB [test]> SELECT * FROM v1;
      ERROR 1241 (21000): Operand should contain 1 column(s)
      MariaDB [test]> SHOW CREATE VIEW v1;
      ERROR 1241 (21000): Operand should contain 1 column(s)
      

      The problem was introduced with this commit in 10.2:

      commit 180065ebb0db78ea5c955b54c9f7997dbcba3121
      Author: Sergei Golubchik <serg@mariadb.org>
      Date:   Sun Nov 27 19:50:10 2016 +0100
       
          Item::print(): remove redundant parentheses
          
          by introducing new Item::precedence() method and using it
          to decide whether parentheses are required
      

      The view is created with this definition in the frm file:

      query=select !(2,3) in (select `test`.`t1`.`i`,`test`.`t1`.`j` from `test`.`t1`) AS `(2, 3) NOT IN ( SELECT i, j FROM t1 )`
      

      Before the change, it was

      query=select (not((2,3) in (select `test`.`t1`.`i`,`test`.`t1`.`j` from `test`.`t1`))) AS `(2, 3) NOT IN ( SELECT i, j FROM t1 )`
      

      Test case

      CREATE TABLE t1 (i INT, j INT);
      INSERT INTO t1 VALUES (1,1),(2,2);
      CREATE OR REPLACE VIEW v1 AS SELECT (2, 3) NOT IN ( SELECT i, j FROM t1 );
      SELECT * FROM v1;
      DROP VIEW v1;
      DROP TABLE t1;
      

        Attachments

          Activity

            People

            Assignee:
            serg Sergei Golubchik
            Reporter:
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: