[MDEV-16427] dual table is implemented a bit flaky Created: 2018-06-07  Updated: 2018-06-21

Status: Open
Project: MariaDB Server
Component/s: Server
Fix Version/s: None

Type: Task Priority: Major
Reporter: Oli Sennhauser Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: Compatibility, dual, pl/sql


 Description   

SELECT * FROM dual;
ERROR 1096 (HY000): No tables used

The DUAL table has one column, DUMMY, defined to be VARCHAR2(1), and contains one row with a value X
https://docs.oracle.com/cd/B19306_01/server.102/b14200/queries009.htm

select * from test join dual;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'dual' at line 1
 
select * from dual join test;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'join test' at line 1

So the "correct" results in oracle terms should be:

select * from `DUAL`;
+-------+
| DUMMY |
+-------+
| X     |
+-------+
 
select * from test join `DUAL`;
+----+--------------+---------------------+-------+
| id | data         | ts                  | DUMMY |
+----+--------------+---------------------+-------+
|  1 | Some bla bla | 2018-06-07 22:03:52 | X     |
+----+--------------+---------------------+-------+
 
select * from `DUAL` join test;
+-------+----+--------------+---------------------+
| DUMMY | id | data         | ts                  |
+-------+----+--------------+---------------------+
| X     |  1 | Some bla bla | 2018-06-07 22:03:52 |
+-------+----+--------------+---------------------+

This could matter because the dual table is fundamental in Oracle world and many internal and external queries may rely on exactly this behaviour...



 Comments   
Comment by Elena Stepanova [ 2018-06-08 ]

While documentation on DUAL is scarce both in MariaDB KB and MySQL manual, it appears that it currently works as initially intended:

DUAL is purely for the convenience of people who require that all SELECT statements should have FROM and possibly other clauses. MariaDB ignores the clauses. MariaDB does not require FROM DUAL if no tables are referenced.

FROM DUAL could be used when you only SELECT computed values, but require a WHERE clause,

So, I'm converting this to a feature request.

Generated at Thu Feb 08 08:28:50 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.