Passing enum Parameters to User-defined C-Language Functions

Поиск
Список
Период
Сортировка
От Albrecht Dreß
Тема Passing enum Parameters to User-defined C-Language Functions
Дата
Msg-id YPWPMG2B.7BAKC2P6.OUTXXAKJ@5ZHNMZGJ.ZUSHUKV4.TDKUFKXK
обсуждение исходный текст
Ответы Re: Passing enum Parameters to User-defined C-Language Functions
Список pgsql-general
Hi,

I have a (I hope not too dumb) question regarding the use of enum parameters in a user-defined function written in C,
e.g.for the example given in [1]: CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy'); 

- How would a “mood” parameter be encoded when it is passed to the function?  “Four bytes on disk” might imply that its
eitheran int4 or a float4? 
- How is the association between enumlabel (e.g. 'happy') and value?  The same as enumsortorder in pg_enum?
- How are NULL values encoded?

Or is it a bad idea to use an enum in this case – actually, an int2 plus a few #define's would do the job, too, but the
dedicatedtype looks cleaner to me. 

Thanks in advance,
Albrecht.


[1] <https://www.postgresql.org/docs/16/datatype-enum.html>
Вложения

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: PostgreSQL inheritance vs https://wiki.postgresql.org/wiki/Don%27t_Do_This
Следующее
От: Achilleas Mantzios
Дата:
Сообщение: Re: PostgreSQL inheritance vs https://wiki.postgresql.org/wiki/Don%27t_Do_This