title: Postgres subquery has access to column in a higher level table. Is this a bug? or a feature I don't understand?
body: <p>I don't understand why the following doesn't fail. How does the subquery have access to a column from a different table at the higher level?</p>
  
  <pre><code>drop table if exists temp_a;
  create temp table temp_a as
  (
      select 1 as col_a
  );
  
  drop table if exists temp_b;
  create temp table temp_b as
  (
      select 2 as col_b
  );
  
  select col_a from temp_a where col_a in (select col_a from temp_b); 
  /*why doesn't this fail?*/
  </code></pre>
  
  <p>The following fail, as I would expect them to.</p>
  
  <pre><code>select col_a from temp_b; 
  /*ERROR:  column "col_a" does not exist*/
  
  select * from temp_a cross join (select col_a from temp_b) as sq;   
  /*ERROR:  column "col_a" does not exist 
   *HINT:  There is a column named "col_a" in table "temp_a", but it cannot be referenced from this part of the query.*/
  </code></pre>
  
  <p>I know about the LATERAL keyword (<a href="http://www.postgresql.org/docs/current/static/queries-table-expressions.html#QUERIES-LATERAL" rel="nofollow">link</a>, <a href="https://wiki.postgresql.org/wiki/What%27s_new_in_PostgreSQL_9.3#LATERAL_JOIN" rel="nofollow">link</a>) but I'm not using LATERAL here. Also, this query succeeds even in pre-9.3 versions of Postgres (when the LATERAL keyword was introduced.)</p>
  
  <p>Here's a sqlfiddle: <a href="http://sqlfiddle.com/#!10/09f62/5/0" rel="nofollow">http://sqlfiddle.com/#!10/09f62/5/0</a></p>
  
  <p>Thank you for any insights.</p>