Re: Converting to identity columns with domains on PK columns

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Converting to identity columns with domains on PK columns
Дата
Msg-id 5124.1562365951@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Converting to identity columns with domains on PK columns  (Adrian Klaver <adrian.klaver@aklaver.com>)
Ответы Re: Converting to identity columns with domains on PK columns  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
Adrian Klaver <adrian.klaver@aklaver.com> writes:
> On 7/5/19 1:49 PM, PegoraroF10 wrote:
>> Sorry, the example I was thinking was this one, which works on Firebird,
>> using its way of writing, obviously.
>> create function myproc(id integer) returns I32 language sql as 'select $1';
>> 
>> On postgres ERROR: return type mismatch in function declared to return i32
>> What I mean is that Firebird sees I32 and integer as the same, Postgres
>> doesn´t.

> Yeah, but if you reverse the casting you did in your first example it works:
> create function myproc(id integer) returns I32 language sql as 'select 
> $1::i32';
> CREATE FUNCTION

Yeah.  This isn't an inherent property of Postgres, it's just that
SQL-language functions aren't defined to provide any implicit casting
of their results.  The given expression must yield exactly the declared
function result type.

Most other places in PG are laxer and will automatically perform
implicit (and maybe assignment) casts for you.  I don't remember
offhand whether there are good reasons for SQL functions to be
picky about this or it's just a shortage of round tuits.  I have
a vague feeling that there might be some compatibility issues
in there, though.

            regards, tom lane



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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Converting to identity columns with domains on PK columns
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Converting to identity columns with domains on PK columns