StarRocks, a Linux Foundation project, is a next-generation sub-second MPP OLAP database for full analytics scenarios, including multi-dimensional analytics, real-time analytics, and ad-hoc queries.
When I prepare a statement that defines a CTE that selects from a table with where clauses and I then select from that CTE with additional where clauses, it seems the placeholder is not replaced with the provided value, leading to an empty result when it shouldn't.
Steps to reproduce the behavior (Required)
CREATE TABLE cte_issue ( id varchar(36), name varchar(36) ) engine=olap primary key(`id`);
INSERT INTO cte_issue (id, name) VALUES (1, 'StarRocks');
PREPARE q_cte FROM WITH my_cte AS ( SELECT id, name FROM cte_issue where id = ? ) SELECT name from my_cte where name = ?;
PREPARE q_cte_nowhere FROM WITH my_cte AS ( SELECT id, name FROM cte_issue where id = ? ) SELECT name from my_cte;
PREPARE q_no_cte FROM SELECT name from cte_issue where id = ? and name = ?;
SET @id = 1, @name = 'StarRocks';
EXECUTE q_no_cte USING @id, @name;
EXECUTE q_cte USING @id, @name;
EXECUTE q_cte_nowhere USING @id;
Expected behavior (Required)
mysql> EXECUTE q_cte USING @id, @name;
+-----------+
| name |
+-----------+
| StarRocks |
+-----------+
1 row in set (0,03 sec)
mysql> EXECUTE q_no_cte USING @id, @name;
+-----------+
| name |
+-----------+
| StarRocks |
+-----------+
1 row in set (0,02 sec)
Real behavior (Required)
mysql> EXECUTE q_cte USING @id, @name;
Empty set (0,02 sec)
mysql> EXECUTE q_no_cte USING @id, @name;
+-----------+
| name |
+-----------+
| StarRocks |
+-----------+
1 row in set (0,02 sec)
Non-prepared version:
mysql> WITH my_cte AS ( SELECT id, name FROM cte_issue where id = 1 ) SELECT name from my_cte where name = 'StarRocks';
+-----------+
| name |
+-----------+
| StarRocks |
+-----------+
1 row in set (0,02 sec)
StarRocks version (Required)
mysql> select current_version();
+-------------------+
| current_version() |
+-------------------+
| 3.3.0-19a3f66 |
+-------------------+
1 row in set (0,03 sec)
When I prepare a statement that defines a CTE that selects from a table with where clauses and I then select from that CTE with additional where clauses, it seems the placeholder is not replaced with the provided value, leading to an empty result when it shouldn't.
Steps to reproduce the behavior (Required)
Expected behavior (Required)
Real behavior (Required)
Non-prepared version:
StarRocks version (Required)