BUG #8830: Query with a subquery failes to execute if this subquery does not contain references to own table - Mailing list pgsql-bugs

From valgog@gmail.com
Subject BUG #8830: Query with a subquery failes to execute if this subquery does not contain references to own table
Date
Msg-id 20140114103219.30126.61565@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #8830: Query with a subquery failes to execute if this subquery does not contain references to own table  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      8830
Logged by:          Query with a subquery failes to execute if a subquery does not contain
references to inner table
Email address:      valgog@gmail.com
PostgreSQL version: 9.3.2
Operating system:   Linux
Description:

select 'key.' || md5( s.i::text ) as key,
       'value.' || ( select string_agg( md5( (s.i + g.j)::text), '' )
                       from generate_series(1, 10) as g(j)
                   ) as value
  from generate_series(1, 100) as s(i);

works fine.

select 'key.' || md5( s.i::text ) as key,
       'value.' || ( select string_agg( md5( (s.i)::text), '' )
                       from generate_series(1, 20) as g(j)
                   ) as value
  from generate_series(1, 100) as s(i);

fails with:

ERROR:  column "s.i" must appear in the GROUP BY clause or be used in an
aggregate function
LINE 2: select 'key.' || md5( s.i::text ) as key,

Is it a bug or a feature?

pgsql-bugs by date:

Previous
From: Jeevan Chalke
Date:
Subject: Re: surprising to_timestamp behavior
Next
From: Oskari Saarenmaa
Date:
Subject: Re: BUG #8470: 9.3 locking/subtransaction performance regression