[MCOL-3801] SELECT... LIMIT 0 returns a row Created: 2020-02-18  Updated: 2023-10-25  Resolved: 2023-10-25

Status: Closed
Project: MariaDB ColumnStore
Component/s: MariaDB Server
Affects Version/s: 1.4.2
Fix Version/s: Icebox

Type: Bug Priority: Minor
Reporter: Assen Totin (Inactive) Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: None


 Description   

Accidentally stumbled onto this while testing some machine-generated SQL with ColumnStore from X4.

MariaDB [bookstore]> SELECT trans_date FROM `bookstore`.`transactions` LIMIT 0;
---------------------

trans_date

---------------------

2018-05-07 16:46:50

---------------------
1 row in set (0.032 sec)

As a comparison, with InnoDB:

MariaDB [bookstore]> SELECT trans_date FROM `bookstore`.`Transactions` LIMIT 0;
Empty set (0.000 sec)

"SELECT * ... LIMIT 0" is used by the client software as a generic way to determine columns and datatypes. May not be super smart and a bit to the side of how we do things manually, but is generic and works with many databases.

ColumnStore should respect the LIMIT 0 properly, because the same stanza can also be seen in "CREATE TABLE AS SELECT... LIMIT 0" (again, we would have probably written just "CREATE TABLE LIKE..." manually) - in whcih case we obviously don't want anything going into the newly created table. I have even seen MaxScale used to automatically append "LIMIT 0" to "CREATE TABLE AS SELECT" to prevent performance-sensitive setups (e.g., a Galera cluster) from being hosed for hours by such a query.


Generated at Thu Feb 08 02:45:32 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.