[MDEV-10029] UNION + OUTFILE is confusing Created: 2016-05-05  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Parser
Affects Version/s: 5.5, 10.0, 10.1, 10.2
Fix Version/s: 10.4

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-10028 Syntax error on ((SELECT ...) UNION (... Closed

 Description   

If I run this query:

SELECT 1 UNION SELECT 2 INTO OUTFILE 'test.txt';

It correctly creates a file 'test.txt' with two lines:

1
2

Now if I do "rm test.txt" and execute another query (with parentheses):

(SELECT 1) UNION (SELECT 2 INTO OUTFILE 'test.txt');

it still puts the same two lines from both UNION parts.

This looks confusing, as parentheses a kind of assume that only the right UNION part is to be exported.

We could introduce a less confusing syntax to export UNION queries, for example:

((SELECT 1) UNION (SELECT 2)) INTO OUTFILE 'test.txt';

But "MDEV-10028 Syntax error on ((SELECT ...) UNION (SELECT ...))" should be fixed first.

Note, one can write something like this:

SELECT * INTO OUTFILE 'test.txt'
FROM ((SELECT ...) UNION (SELECT ...)) AS t1;

But it looks longer.

Sergei thinks that even if we add a less confusing syntax, we should not disallow the confusing syntax not to break existing applications.
https://lists.launchpad.net/maria-developers/msg09599.html

But at least just sending a warning suggesting a better syntax would probably be fine.


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