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

Implement an optional list of column names with the derived table name

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: Optimizer, Parser
    • Labels:
      None

      Description

      <table primary> ::=
          ...
          | <derived table> [ AS ] <correlation name>
              [ <left paren> <derived column list> <right paren> ]
          ...
       
      <derived column list> ::= <column name list>
       
      <column name list> ::=
          <column name> [ { <comma> <column name> }... ]
      

      SQL Standard says that with the derived table name an optional list of column names used in this derived table can also be specified. This feature is not implemented in MariaDB.

      The usage of this feature:

      SELECT *
      FROM
      (
        SELECT MAX(a), b
        FROM t1
        GROUP BY b
      ) AS tab(max_a, b);
      

      The most interesting case of using this feature will be with the derived table defined with a table value constructor. In this example there is no possibility to come at 'tab' columns directly.

      SELECT *
      FROM
      (
        VALUES ((1,1),(2,2))
      ) AS tab;
      

      Using the suggested feature it becomes possible:

      SELECT *
      FROM
      (
        VALUES ((1,1),(2,2))
      ) AS tab(a,b)
      SELECT a FROM tab;
      

        Attachments

          Activity

            People

            Assignee:
            igor Igor Babaev
            Reporter:
            shagalla Galina Shalygina (Inactive)
            Votes:
            10 Vote for this issue
            Watchers:
            8 Start watching this issue

              Dates

              Created:
              Updated:

                Git Integration