Re: Do FROM items of different schemas conflict? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Do FROM items of different schemas conflict?
Date
Msg-id 22655.1015630112@sss.pgh.pa.us
Whole thread Raw
In response to Re: Do FROM items of different schemas conflict?  (Fernando Nasser <fnasser@redhat.com>)
List pgsql-hackers
Fernando Nasser <fnasser@redhat.com> writes:
> If you had
>      SELECT * FROM schema1.tab1, schema2.tab2;
> you could abbreviate:
> SELECT tab1.col1, tab2.col5 FROM schema1.tab1, schema2.tab2 WHERE...

> i.e., as long as it is not ambiguous you can omit the schema
> qualification.

What I am wondering about is how you tell whether it is ambiguous.

In particular, if schema1 is not in the search path then I do not
see how the spec can be read to say that "tab1.col1" matches "FROM
schema1.tab1" (note no AS here).  It does seem that everyone agrees that
that is the meaning --- there is a footnote in Date that shows he thinks
so too --- but as far as I can tell this directly contradicts the text
of the spec, because there is noplace that says how to match an
unqualified "tab1" against the qualified "schema1.tab1", except for
5.4-10 which would clearly disallow such a match.  Where am I missing
something?

>> What I would like to do is say the following:
>> 
>> 1. Two FROM-items in the same scope cannot have equal <correlation
>> name>s or <qualified identifier>s.

> Only if the qualified identifiers are exposed.  As soon as you give
> then an alias with AS the original name is hidden.

Right, of course.  Sorry for the imprecision.

>> These rules essentially say that a FROM entry "FROM foo.bar" is exactly
>> equivalent to "FROM foo.bar AS bar",

> A small difference.  With the first you can refer to columns as

> foo.bar.col1

> with the second you cannot.  You must say:  bar.col1

Well, the point is that I would like to allow that, specifically because
I would like to say that the equivalence is exact.  I don't see any
value in enforcing this particular nitpick.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Joe Conway
Date:
Subject: Re: Do FROM items of different schemas conflict?
Next
From: alex@AvengerGear.com (Debian User)
Date:
Subject: Make my question clear.