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

Different result header when using CTE

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Not a Bug
    • 10.2.3
    • 10.2.4
    • Optimizer - CTE
    • None

    Description

      CREATE TABLE transactions (timestamp int, customer_id int, amount int);
       
      SELECT timestamp, customer_id, amount, (
           SELECT sum(amount) from transactions as t2 where t2.customer_id = t1.customer_id and t2.timestamp <= t1.timestamp)
      FROM transactions AS t1
      ORDER BY customer_id, timestamp;
      

      Header results looks like this:

      +-----------+-------------+--------+------------+
      | timestamp | customer_id | amount | SELECT sum(amount) from transactions as t2 where t2.customer_id = t1.customer_id and t2.timestamp <= t1.timestamp |
      +-----------+-------------+--------+------------+
      

      WITH result as (
          SELECT timestamp, customer_id, amount, (
                  SELECT sum(amount) from transactions as t2 where t2.customer_id = t1.customer_id and t2.timestamp <= t1.timestamp)
          FROM transactions AS t1
          ORDER BY customer_id, timestamp)
      SELECT * from result;
      

      Header result looks different for the same definition.

       +-----------+-------------+--------+------------+
      | timestamp | customer_id | amount | Name_exp_4 |
      +-----------+-------------+--------+------------+
      

      Attachments

        Activity

          People

            igor Igor Babaev
            cvicentiu Vicențiu Ciorbaru
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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