Re: IMMUTABLE function to cast enum to/from text?

Поиск
Список
Период
Сортировка
От Philip Semanchuk
Тема Re: IMMUTABLE function to cast enum to/from text?
Дата
Msg-id 26B23DE4-1D92-4201-94B9-1E7FE243EB4B@americanefficient.com
обсуждение исходный текст
Ответ на Re: IMMUTABLE function to cast enum to/from text?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general

> On Nov 10, 2022, at 3:39 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Joe Conway <mail@joeconway.com> writes:
>>
>> CREATE OR REPLACE FUNCTION mood2text(mood)
>> RETURNS text AS
>> $$
>>  select $1
>> $$ STRICT IMMUTABLE LANGUAGE sql;
>
> Of course, what this is doing is using a SQL-function wrapper to
> lie about the mutability of the expression.  Whether you consider
> that elegant is up to you ;-) ... but it should work, as long as
> you don't break things by renaming the enum's values.


Thanks Joe and Tom,
I’m comfortable lying to Postgres occasionally — never for evil, only for good of course. :-)


Cheers
Philip


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: IMMUTABLE function to cast enum to/from text?
Следующее
От: 黄宁
Дата:
Сообщение: get table oid in GIN extracequery function