Re: Add pg_basetype() function to obtain a DOMAIN base type
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: Tomas Vondra <tomas.vondra@enterprisedb.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, John Naylor <johncnaylorls@gmail.com>, Alexander Korotkov <aekorotkov@gmail.com>, Steve Chavez <steve@supabase.io>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2024-03-18T00:00:00Z
Lists: pgsql-hackers
Attachments
- v4-0001-Add-pg_basetype-any-function-for-querying-basetyp.patch (application/x-patch) patch v4-0001
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.
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Add pg_basetype() function to extract a domain's base type.
- b154d8a6d0e5 17.0 landed