1/*-------------------------------------------------------------------------
4 * routines to support manipulation of the pg_cast relation
6 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * src/backend/catalog/pg_cast.c
13 *-------------------------------------------------------------------------
31 * ----------------------------------------------------------------
34 * Forms and inserts catalog tuples for a new cast being created.
35 * Caller must have already checked privileges, and done consistency
36 * checks on the given datatypes and cast function (if applicable).
38 * Since we allow binary coercibility of the datatypes to the cast
39 * function's input and result, there could be one or two WITHOUT FUNCTION
40 * casts that this one depends on. We don't record that explicitly
41 * in pg_cast, but we still need to make dependencies on those casts.
43 * 'behavior' indicates the types of the dependencies that the new
44 * cast will have on its input and output types, the cast function,
45 * and the other casts if any.
46 * ----------------------------------------------------------------
57 bool nulls[Natts_pg_cast] = {0};
65 * Check for duplicate. This is just to give a friendly error message,
66 * the unique index would catch it anyway (so no need to sweat about race
75 errmsg(
"cast from type %s to type %s already exists",
94 /* make dependency entries */
97 /* dependency on source type */
101 /* dependency on target type */
105 /* dependency on function */
112 /* dependencies on casts required for function */
127 /* dependency on extension */
130 /* Post creation hook for new cast */
static Datum values[MAXATTR]
#define OidIsValid(objectId)
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
void record_object_address_dependencies(const ObjectAddress *depender, ObjectAddresses *referenced, DependencyType behavior)
void add_exact_object_address(const ObjectAddress *object, ObjectAddresses *addrs)
ObjectAddresses * new_object_addresses(void)
void free_object_addresses(ObjectAddresses *addrs)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
#define InvokeObjectPostCreateHook(classId, objectId, subId)
#define ObjectAddressSet(addr, class_id, object_id)
ObjectAddress CastCreate(Oid sourcetypeid, Oid targettypeid, Oid funcid, Oid incastid, Oid outcastid, char castcontext, char castmethod, DependencyType behavior)
void recordDependencyOnCurrentExtension(const ObjectAddress *object, bool isReplace)
static Datum ObjectIdGetDatum(Oid X)
static Datum CharGetDatum(char X)
#define RelationGetDescr(relation)
#define ERRCODE_DUPLICATE_OBJECT
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)