Re: Is the subtype_diff function in CREATE TYPE only can be C function?

Поиск
Список
Период
Сортировка
От Ashutosh Bapat
Тема Re: Is the subtype_diff function in CREATE TYPE only can be C function?
Дата
Msg-id CAExHW5vuJpvy7d1B_Uc8AX1r8ZsYrr-tDDjZXxwZ3HYtTRN_Kw@mail.gmail.com
обсуждение исходный текст
Ответ на Is the subtype_diff function in CREATE TYPE only can be C function?  (ddme <ret2ddme@qq.com>)
Ответы Re: Is the subtype_diff function in CREATE TYPE only can be C function?  (ddme <ret2ddme@qq.com>)
Список pgsql-hackers
On Wed, Jan 10, 2024 at 1:49 PM ddme <ret2ddme@qq.com> wrote:
>
> Hi all,
>
> I notice that the CREATE TYPE syntax can specify subtype_diff function
>
> CREATE TYPE name AS RANGE (
>     SUBTYPE = subtype
>     [ , SUBTYPE_OPCLASS = subtype_operator_class ]
>     [ , COLLATION = collation ]
>     [ , CANONICAL = canonical_function ]
>     [ , SUBTYPE_DIFF = subtype_diff_function ] <————— here
>     [ , MULTIRANGE_TYPE_NAME = multirange_type_name ]
> )
>
> And a example is
> ```sql
>
> CREATE TYPE float8_range AS RANGE (subtype = float8, subtype_diff = float8mi);
>
> ```
>
> I notice that float8mi is a C function, and I find the call_subtype_diff() in source code that it seems only can call
Cfunction. 

call_subtype_diff() invokes FunctionCall2Coll() which in turn invokes
the function handler for non-C functions. See
fmgr_info_cxt_security() for example. So subtype_diff can be a SQL
callable function written in any supported language.

>
> I want to know
>
> 1. Can the subtype_diff function in CREATE TYPE be sql or plpgsql function?

I think so.

> 2. How to call subtype_diff function? I know it related with GiST index, I need a example on how to trigger
subtype_difffunction. 

I am not familiar with GiST code enough to answer that question. But
looking at the places where call_subtype_diff() is called, esp. the
comments there might give you hints.
OR somebody more familiar with GiST code will give you a direct answer.

--
Best Wishes,
Ashutosh Bapat



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

Предыдущее
От: Shlok Kyal
Дата:
Сообщение: Re: Extend pgbench partitioning to pgbench_history
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: Documentation to upgrade logical replication cluster