Derby
  1. Derby
  2. DERBY-3478

Simple column names specified as part of "AS" clause in a table expression are ignored if the table expression is a view.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 10.0.2.1, 10.1.1.0, 10.1.2.1, 10.1.3.1, 10.2.1.6, 10.2.2.0, 10.3.1.4, 10.3.2.1
    • Fix Version/s: 10.5.3.1, 10.6.1.0
    • Component/s: SQL
    • Labels:
      None
    • Urgency:
      Normal
    • Issue & fix info:
      High Value Fix
    • Bug behavior facts:
      Wrong query result

      Description

      Simple repro as follows:

      create table t1 (i int, j int);
      insert into t1 values (1, 1), (1, -1), (2, 2), (3, -3), (4, 4);

      create view v1 as select j, i from t1;
      create view v2 (x,y,z) as select j, i, i+j from t1;

      – OK: Returns column names specified in AS clause.
      select * from t1 as x(a,b);

      – OK: Returns column names for the views
      select * from v1;
      select * from v2;

      – WRONG: Ignores column names specified in AS clause for the views.
      select * from v1 x(a,b);
      select * from v2 as x(a,b,c);

      I observed this as far back as 10.0.2.1, so this is not a regression.

      1. derby-3478.diff
        5 kB
        Dag H. Wanvik
      2. derby-3478.stat
        0.2 kB
        Dag H. Wanvik

        Activity

        Hide
        Dag H. Wanvik added a comment -

        Backported to 10.5 branch as svn 808504, resolving.

        If somebody wants it backported further, let me know, or feel free!

        Show
        Dag H. Wanvik added a comment - Backported to 10.5 branch as svn 808504, resolving. If somebody wants it backported further, let me know, or feel free!
        Hide
        Dag H. Wanvik added a comment -

        Committed on trunk as svn 808494.

        Show
        Dag H. Wanvik added a comment - Committed on trunk as svn 808494.
        Hide
        Dag H. Wanvik added a comment -

        Regressions ran ok. Thanks for looking at this Bryan!

        Show
        Dag H. Wanvik added a comment - Regressions ran ok. Thanks for looking at this Bryan!
        Hide
        Bryan Pendleton added a comment -

        Thanks for picking up the bug, Dag.

        I read through the diff and did some simple confirmation:

        • the code change seems reasonable
        • the new test fails as expected without the code change
        • the new test passes as expected with the code change

        I think this is a solid fix: +1 to commit from me, assuming no
        surprises arose during your regression run.

        Show
        Bryan Pendleton added a comment - Thanks for picking up the bug, Dag. I read through the diff and did some simple confirmation: the code change seems reasonable the new test fails as expected without the code change the new test passes as expected with the code change I think this is a solid fix: +1 to commit from me, assuming no surprises arose during your regression run.
        Hide
        Dag H. Wanvik added a comment -

        Uploading a patch which fixes this and adds a test case to ViewTests which exposes the
        bug if not fixed. Running regressions.

        Show
        Dag H. Wanvik added a comment - Uploading a patch which fixes this and adds a test case to ViewTests which exposes the bug if not fixed. Running regressions.
        Hide
        Tiago R. Espinha added a comment -

        Triaged for 10.5.2.

        Assigned Normal urgency.

        Show
        Tiago R. Espinha added a comment - Triaged for 10.5.2. Assigned Normal urgency.

          People

          • Assignee:
            Dag H. Wanvik
            Reporter:
            A B
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development