Re: Add pg_basetype() function to obtain a DOMAIN base type

Поиск
Список
Период
Сортировка
От jian he
Тема Re: Add pg_basetype() function to obtain a DOMAIN base type
Дата
Msg-id CACJufxEGe6w6RKE4T18OoQ=0JCRCRgL4W-g_Dau5scZFR2axNQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Add pg_basetype() function to obtain a DOMAIN base type  (jian he <jian.universality@gmail.com>)
Ответы Re: Add pg_basetype() function to obtain a DOMAIN base type  (Alexander Korotkov <aekorotkov@gmail.com>)
Список pgsql-hackers
looking at it again.
I found out we can just simply do
`
Datum
pg_basetype(PG_FUNCTION_ARGS)
{
Oid oid;

oid =  get_fn_expr_argtype(fcinfo->flinfo, 0);
PG_RETURN_OID(getBaseType(oid));
}
`

if the type is not a domain, work the same as  pg_typeof.
if the type is domain,  pg_typeof return as is, pg_basetype return the
base type.
so it only diverges when the argument type is a type of domain.

the doc:
        <function>pg_basetype</function> ( <type>"any"</type> )
        <returnvalue>regtype</returnvalue>
       </para>
       <para>
       Returns the OID of the base type of a domain. If the argument
is not a type of domain,
       return the OID of the data type of the argument just like <link
linkend="function-pg-typeof"><function>pg_typeof()</function></link>.
       If there's a chain of domain dependencies, it will recurse
until finding the base type.
       </para>


also, I think this way, we only do one syscache lookup.

Вложения

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

Предыдущее
От: Daniel Gustafsson
Дата:
Сообщение: Re: Support json_errdetail in FRONTEND builds
Следующее
От: Erik Wienhold
Дата:
Сообщение: Re: Q: Escapes in jsonpath Idents