Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-4411

Scalar subquery erroneously rejected for not returning exactly one row

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 10.5.3.1, 10.6.1.0
    • 10.5.3.1, 10.6.1.0
    • SQL
    • None
    • Repro attached

    Description

      This sequence of statements causes an error because the scalar sub-query supposedly doesn't return exactly one row, even though it does return exactly one row:

      ij> create table t (x int unique, y int);
      0 rows inserted/updated/deleted
      ij> insert into t values (1,2);
      1 row inserted/updated/deleted
      ij> select * from t where x > (values 1 union select y from t where 1=0);
      ERROR 21000: Scalar subquery is only allowed to return a single row.
      ij> values 1 union select y from t where 1=0;
      1
      -----------
      1

      1 row selected

      Before DERBY-4391, the problematic statement would have caused a NullPointerException.

      Attachments

        1. constantRestriction.diff
          0.6 kB
          Knut Anders Hatlen
        2. derby-4411-1a.diff
          3 kB
          Knut Anders Hatlen

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            knutanders Knut Anders Hatlen
            knutanders Knut Anders Hatlen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment