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

Prepare statement with select from view fails with ER_BAD_FIELD_ERROR when view definition has ORDER BY in UNION

Details

    Description

      Test case:

      create table t1 (c1 int, c2 int, c3 int);
      insert into t1 values (1,2,3),(4,5,6);
      create table t2 like t1;
      insert into t2 values (7,8,9),(10,11,12);
       
      create view v1 as
      select * from (
          select *, a1 from (
              select c1, c2, c3 from t1 where c1 > 1
              ) as d1 (a1, a2, a3)
          union 
          select *, 1 as c4 from t2 order by a2
      ) d2 (o1, o2, o3, o4);
       
      prepare stmt from "select * from v1";
      execute stmt;
       
      drop view v1;
      drop tables t1, t2;
      

      Result:

      query 'execute stmt' failed: ER_BAD_FIELD_ERROR (1054): Unknown column 'a2' in 'ORDER BY'
      

      Attachments

        Issue Links

          Activity

            Johnston Rex Johnston added a comment -

            issue fixed in bb-11.8-MDEV-36474

            Johnston Rex Johnston added a comment - issue fixed in bb-11.8- MDEV-36474

            People

              Johnston Rex Johnston
              lstartseva Lena Startseva
              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.