Re: No error when column doesn't exist

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: No error when column doesn't exist
Дата
Msg-id 1902.1221067706@sss.pgh.pa.us
обсуждение исходный текст
Ответ на No error when column doesn't exist  (Dean Rasheed <dean_rasheed@hotmail.com>)
Ответы Re: No error when column doesn't exist  (Artacus <artacus@comcast.net>)
Re: No error when column doesn't exist  (Dean Rasheed <dean_rasheed@hotmail.com>)
Список pgsql-general
Dean Rasheed <dean_rasheed@hotmail.com> writes:
> CREATE TABLE foo(a int, b int);
> INSERT INTO foo VALUES(1,2);
> SELECT foo.text FROM foo;

> I expected that to generate an error: column foo.text does not exist.
> Instead it treats "foo.text" as "foo.*::text AS text":
> Is this a feature or a bug?

Hmm.  It's a feature, but maybe a dangerous one.  The expression is
being treated as text(foo), which is intentional in order to allow
use of functions as if they were virtual columns.  However, then it
decides that what you've got there is a cast request.  There wasn't
any ability to cast composite types to text before 8.3, so this fails
in the expected way in 8.2 and before; but in 8.3 the cast
interpretation succeeds, and away we go.

foo.char and foo.varchar have similarly unexpected behavior; I think
that's probably the end of it, though, since those are the only types
that CoerceViaIO will take as targets.

Maybe we could/should restrict things so that the syntax continues to
fail, but I can't think of any restrictions that don't seem like warts.
What's worse, they might break stuff that used to work.

            regards, tom lane

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

Предыдущее
От: "Markova, Nina"
Дата:
Сообщение: Re: FW: How to upload data to postgres
Следующее
От: Zdenek Kotala
Дата:
Сообщение: Re: 64-bit Compile Failure on Solaris 10 with OpenSSL