Re: [HACKERS] what standard say ...

From: "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>
To: "Vadim B(dot) Mikheev" <vadim(at)sable(dot)krasnoyarsk(dot)su>
Cc: hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] what standard say ...
Date: 1998-02-06 07:23:22
Message-ID: 34DABA6A.4CC8637E@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Vadim B. Mikheev wrote:

> vac=> \d test
>
> Table = test
> +----------------------------------+----------------------------------+-------+
> | Field | Type | Length|
> +----------------------------------+----------------------------------+-------+
> | x | int4 | 4 |
> | y | int4 | 4 |
> +----------------------------------+----------------------------------+-------+
> vac=> select count(*) from test where exists (select t1.y from test t1 where t1.y = x);
> ^
> Is this correlated subquery or not ?
> (Note, that I don't use x with t1. prefix here)
> With current parser this works as un-correlated subquery...
> Is this Ok and I have to re-write query as
>
> vac=> select count(*) from test t2 where exists
> ^^
> (select t1.y from test t1 where t1.y = t2.x);
> ^^^
> to get correlated one ?

>From "The SQL Standard", 3rd ed., Date and Darwen:

"... each unqualified column name is _implicitly_ qualified by a range variable name
defined (explicitly or implicitly) in the nearest applicable FROM clause." (the emphasis
is from the book, not me)

It goes on to recommend reading the standard for full understanding, but it is pretty
clear that your interpretation is correct; in the example above x is implicitly equivalent
to t1.x.

- Tom

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Julia Anne Case 1998-02-06 07:27:46 [BUG?] Frontend Protocol...
Previous Message Vadim B. Mikheev 1998-02-06 05:02:33 Query->hasSubLinks is always FALSE...