From: | Alexander Korotkov <aekorotkov(at)gmail(dot)com> |
---|---|
To: | jian he <jian(dot)universality(at)gmail(dot)com> |
Cc: | Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, John Naylor <johncnaylorls(at)gmail(dot)com>, Steve Chavez <steve(at)supabase(dot)io>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Add pg_basetype() function to obtain a DOMAIN base type |
Date: | 2024-03-18 11:24:47 |
Message-ID: | CAPpHfduS-nQ5pFpJ5q+UP4Apxu4RV7oAeww4oJUO_Pb+sog18g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Mar 18, 2024 at 2:01 AM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> 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.
Looks good to me. But should it be named pg_basetypeof()?
------
Regards,
Alexander Korotkov
From | Date | Subject | |
---|---|---|---|
Next Message | Tomas Vondra | 2024-03-18 11:34:23 | Re: BitmapHeapScan streaming read user and prelim refactoring |
Previous Message | Peter Eisentraut | 2024-03-18 11:15:16 | Re: speed up a logical replica setup |