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

Wrong result with aggregate function in uncorrelated SELECT subquery in view definition

    XMLWordPrintable

Details

    Description

      Expected that "select from table" and "select from view" give the same result:
      Test:

      CREATE TABLE t1 (f1 INT);
      INSERT INTO t1 VALUES (1),(2);
       
      CREATE TABLE t2 (f2 int);
      INSERT INTO t2 VALUES (3);
       
      SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
      CREATE VIEW v1 AS SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
      SELECT * FROM v1;
       
      DROP VIEW v1;
      DROP TABLES t1,t2;
      

      Actual result:

      SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
      ( SELECT MAX(f1) FROM t2 )
      2
      CREATE VIEW v1 AS SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
      SELECT * FROM v1;
      ( SELECT MAX(f1) FROM t2 )
      1
      2
      

      Expected result:

      SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
      ( SELECT MAX(f1) FROM t2 )
      2
      CREATE VIEW v1 AS SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
      SELECT * FROM v1;
      ( SELECT MAX(f1) FROM t2 )
      2
      

      Attachments

        Issue Links

          Activity

            People

              igor Igor Babaev
              lstartseva Lena Startseva
              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.