Re: BUG #5225: create table: cast necessary for constant??

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: BUG #5225: create table: cast necessary for constant??
Дата
Msg-id 4B177D5C020000250002D02A@gw.wicourts.gov
обсуждение исходный текст
Ответ на Re: BUG #5225: create table: cast necessary for constant??  ("Wagner, Kurt" <kurt.wagnerextern@leoni.com>)
Ответы Re: BUG #5225: create table: cast necessary for constant??  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Список pgsql-bugs
"Wagner, Kurt" <kurt.wagnerextern@leoni.com> wrote:

> when writing a character constant elsewhere
> then at first it is interpreted as character constant - right?
> then it is casted to the desired type

No.  It was confusing for me, too; but the PostgreSQL behavior is to
treat what the standard calls a <character string literal> as being
of type UNKNOWN -- just like the behavior described in the spec for
NULL.  When it is used in some context where the type must be
resolved, it then tries to pick an appropriate type.  (I believe
there is some slight preference for type TEXT when there are
multiple possibilities.)  This is helpful for those wanting to use
literals of non-standard types.  (Many people use PostgreSQL
specifically because of the ability to define custom types and
operators.)

There is an understandable tendency of those who work deep in the
guts of the PostgreSQL software, making all this custom type code
work, that those coming into PostgreSQL from other environments come
with the assumption that these literals will be treated as character
strings.  From their perspective there is nothing more natural than
to view such a literal as lacking any type information, with the
obvious implication that you should explicitly give it a type.

Once you shake out any problems from code you are migrating, you'll
find it's not hard to write new code in a way which will work in
either environment.

-Kevin

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

Предыдущее
От: "Kevin Grittner"
Дата:
Сообщение: Re: BUG #5225: create table: cast necessary for constant??
Следующее
От: "Kevin Grittner"
Дата:
Сообщение: Re: BUG #5225: create table: cast necessary for constant??