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

View is created with wrong column name if there are more than one same column name or column name is empty

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 10.3(EOL), 10.4(EOL), 10.5, 10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL)
    • N/A
    • Views

    Description

      According standard "If a <view column list> is" not "specified ... the <column name>s of the view are the <column name>s of the table specified by the <query expression>"

      In simple select is everything good:

      select null, null, null;
      NULL	NULL	NULL
      NULL	NULL	NULL
      

      But if column name is NULL and there are more than one such column name in select for creating view, than columns have names like "My_exp_NULL", "My_exp_1_NULL" and etc.

      Test:

      create view v1 as select null, null, null;
      select * from v1;
      drop view v1;
      

      Actual result:

      create view v1 as select null, null, null;
      select * from v1;
      NULL	My_exp_NULL	My_exp_1_NULL
      NULL	NULL	NULL
      drop view v1;
      

      Expected result:

      create view v1 as select null, null, null;
      select * from v1;
      NULL	NULL	NULL
      NULL	NULL	NULL
      drop view v1;
      

      =============================================================================================================================

      The same problem is with aggregate functions:

      Test 2:

      CREATE TABLE t1 (a int(11));
      INSERT INTO t1 VALUES (1),(2);
       
      select a, SUM(a), SUM(a)+1, SUM(a) from t1;
       
      create view v1 as select a, SUM(a), SUM(a)+1, SUM(a) from t1;
      select * from v1;
       
      drop view v1;
      drop tables t1;
      

      Actual result 2:

      select a, SUM(a), SUM(a)+1, SUM(a) from t1;
      a	SUM(a)	SUM(a)+1	SUM(a)
      1	3	4	3
       
      create view v1 as select a, SUM(a), SUM(a)+1, SUM(a) from t1;
      select * from v1;
      a	SUM(a)	SUM(a)+1	My_exp_SUM(a)
      1	3	4	3
      

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              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.