Re: Allow an alias to be attached directly to a JOIN ... USING

Поиск
Список
Период
Сортировка
От Wolfgang Walther
Тема Re: Allow an alias to be attached directly to a JOIN ... USING
Дата
Msg-id 88018eae-d949-be66-7fec-924213213b49@technowledgy.de
обсуждение исходный текст
Ответ на Re: Allow an alias to be attached directly to a JOIN ... USING  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Ответы Re: Allow an alias to be attached directly to a JOIN ... USING  (Georgios Kokolatos <gkokolatos@protonmail.com>)
Re: Allow an alias to be attached directly to a JOIN ... USING  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Список pgsql-hackers
Peter Eisentraut:
> On 2019-12-31 00:07, Vik Fearing wrote:
>> One thing I notice is that the joined columns are still accessible from
>> their respective table names when they should not be per spec.  That
>> might be one of those "silly restrictions" that we choose to ignore, but
>> it should probably be noted somewhere, at the very least in a code
>> comment if not in user documentation. (This is my reading of SQL:2016 SR
>> 11.a.i)
> 
> Here is a rebased patch.
> 
> The above comment is valid.  One reason I didn't implement it is that it 
> would create inconsistencies with existing behavior, which is already 
> nonstandard.
> 
> For example,
> 
> create table a (id int, a1 int, a2 int);
> create table b (id int, b2 int, b3 int);
> 
> makes
> 
> select a.id from a join b using (id);
> 
> invalid.  Adding an explicit alias for the common column names doesn't 
> change that semantically, because an implicit alias also exists if an 
> explicit one isn't specified.
I just looked through the patch without applying or testing it - but I 
couldn't find anything that would indicate that this is not going to 
work for e.g. a LEFT JOIN as well. First PG patch I looked at, so tell 
me if I missed something there.

So given this:

SELECT x.id FROM a LEFT JOIN b USING (id) AS x

will this return NULL or a.id for rows that don't match in b? This 
should definitely be mentioned in the docs and I guess a test wouldn't 
be too bad as well?

In any case: If a.id and b.id would not be available anymore, but just 
x.id, either the id value itself or the NULL value (indicating the 
missing row in b) are lost. So this seems like a no-go.

 > I agree that some documentation would be in order if we decide to leave
 > it like this.

Keep it like that!



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Replace remaining StrNCpy() by strlcpy()
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: public schema default ACL