Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-10029

UNION + OUTFILE is confusing

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 5.5, 10.0, 10.1, 10.2
    • 10.4
    • Parser
    • None

    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.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.