Re: time for catalog/pg_cast.c? - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: time for catalog/pg_cast.c?
Date
Msg-id 20200309211444.GA24535@alvherre.pgsql
Whole thread Raw
In response to time for catalog/pg_cast.c?  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: time for catalog/pg_cast.c?  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers
On 2020-Mar-09, Alvaro Herrera wrote:

> I extracted from the latest multirange patch a bit that creates a new
> routine CastCreate() in src/backend/catalog/pg_cast.c.  It contains the
> catalog-accessing bits to create a new cast.  It seems harmless, so I
> thought I'd apply it to get rid of a couple of hunks in the large patch.

I forgot to "git add" this comment addition before sending:

/*
 * ----------------------------------------------------------------
 *        CastCreate
 *
 * Forms and inserts catalog tuples for a new cast being created.
 * Caller must have already checked privileges, and done consistency
 * checks on the given datatypes and cast function (if applicable).
 *
 * 'behavior' indicates the dependency that the new cast will have on
 * its input and output types and the cast function.
 * ----------------------------------------------------------------
 */
ObjectAddress
CastCreate(Oid sourcetypeid, Oid targettypeid, Oid funcid, char castcontext,
           char castmethod, DependencyType behavior)


I think the only API consideration here is for 'castcontext', which we
pass here as the pg_type.h symbol, but could alternatively be passed as
CoercionContext enum values (from primnodes.h).  I think the pg_cast.h
char is okay, but maybe somebody has a different opinion.
We could also add some trivial asserts (like if procoid is not invalid,
then method is function, etc.), but it doesn't seem worth fussing too
much over.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: time for catalog/pg_cast.c?
Next
From: Tom Lane
Date:
Subject: Re: Support external parameters in EXECUTE command