[MDEV-11784] View is created with invalid definition which causes ERROR 1241 (21000): Operand should contain 1 column(s) Created: 2017-01-12  Updated: 2017-02-13  Resolved: 2017-02-13

Status: Closed
Project: MariaDB Server
Component/s: Views
Affects Version/s: 10.2.3, 10.2
Fix Version/s: 10.2.4

Type: Bug Priority: Blocker
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: 10.2-rc, regression

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;


Generated at Thu Feb 08 07:52:37 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.