PostgreSQL Source Code  git master
pg_type.h File Reference
#include "catalog/genbki.h"
#include "catalog/objectaddress.h"
#include "catalog/pg_type_d.h"
#include "nodes/nodes.h"
Include dependency graph for pg_type.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef FormData_pg_typeForm_pg_type
 

Functions

 CATALOG (pg_type, 1247, TypeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71
 
Oid typnamespace BKI_DEFAULT (PGNSP)
 
Oid typowner BKI_DEFAULT (PGUID)
 
int16 typlen BKI_ARRAY_DEFAULT (-1)
 
bool typbyval BKI_ARRAY_DEFAULT (f)
 
char typtype BKI_DEFAULT (b) BKI_ARRAY_DEFAULT(b)
 
char typcategory BKI_ARRAY_DEFAULT (A)
 
bool typispreferred BKI_DEFAULT (f) BKI_ARRAY_DEFAULT(f)
 
bool typisdefined BKI_DEFAULT (t)
 
char typdelim BKI_DEFAULT (',')
 
Oid typrelid BKI_DEFAULT (0) BKI_ARRAY_DEFAULT(0) BKI_LOOKUP(pg_class)
 
regproc typinput BKI_ARRAY_DEFAULT (array_in) BKI_LOOKUP(pg_proc)
 
regproc typoutput BKI_ARRAY_DEFAULT (array_out) BKI_LOOKUP(pg_proc)
 
regproc typreceive BKI_ARRAY_DEFAULT (array_recv) BKI_LOOKUP(pg_proc)
 
regproc typsend BKI_ARRAY_DEFAULT (array_send) BKI_LOOKUP(pg_proc)
 
regproc typmodin BKI_DEFAULT (-) BKI_LOOKUP(pg_proc)
 
char typstorage BKI_DEFAULT (p) BKI_ARRAY_DEFAULT(x)
 
ObjectAddress TypeShellMake (const char *typeName, Oid typeNamespace, Oid ownerId)
 
ObjectAddress TypeCreate (Oid newTypeOid, const char *typeName, Oid typeNamespace, Oid relationOid, char relationKind, Oid ownerId, int16 internalSize, char typeType, char typeCategory, bool typePreferred, char typDelim, Oid inputProcedure, Oid outputProcedure, Oid receiveProcedure, Oid sendProcedure, Oid typmodinProcedure, Oid typmodoutProcedure, Oid analyzeProcedure, Oid elementType, bool isImplicitArray, Oid arrayType, Oid baseType, const char *defaultTypeValue, char *defaultTypeBin, bool passedByValue, char alignment, char storage, int32 typeMod, int32 typNDims, bool typeNotNull, Oid typeCollation)
 
void GenerateTypeDependencies (HeapTuple typeTuple, Relation typeCatalog, Node *defaultExpr, void *typacl, char relationKind, bool isImplicitArray, bool isDependentType, bool rebuild)
 
void RenameTypeInternal (Oid typeOid, const char *newTypeName, Oid typeNamespace)
 
char * makeArrayTypeName (const char *typeName, Oid typeNamespace)
 
bool moveArrayTypeName (Oid typeOid, const char *typeName, Oid typeNamespace)
 

Variables

TypeRelation_Rowtype_Id BKI_SCHEMA_MACRO
 
NameData typname
 
char typalign
 
 FormData_pg_type
 

Typedef Documentation

◆ Form_pg_type

Definition at line 255 of file pg_type.h.

Function Documentation

◆ BKI_ARRAY_DEFAULT() [1/7]

int16 typlen BKI_ARRAY_DEFAULT ( 1)

◆ BKI_ARRAY_DEFAULT() [2/7]

bool typbyval BKI_ARRAY_DEFAULT ( )

◆ BKI_ARRAY_DEFAULT() [3/7]

char typcategory BKI_ARRAY_DEFAULT ( )

◆ BKI_ARRAY_DEFAULT() [4/7]

regproc typinput BKI_ARRAY_DEFAULT ( array_in  )

◆ BKI_ARRAY_DEFAULT() [5/7]

regproc typoutput BKI_ARRAY_DEFAULT ( array_out  )

◆ BKI_ARRAY_DEFAULT() [6/7]

regproc typreceive BKI_ARRAY_DEFAULT ( array_recv  )

◆ BKI_ARRAY_DEFAULT() [7/7]

regproc typsend BKI_ARRAY_DEFAULT ( array_send  )

◆ BKI_DEFAULT() [1/9]

Oid typnamespace BKI_DEFAULT ( PGNSP  )

◆ BKI_DEFAULT() [2/9]

Oid typowner BKI_DEFAULT ( PGUID  )

◆ BKI_DEFAULT() [3/9]

char typtype BKI_DEFAULT ( )

◆ BKI_DEFAULT() [4/9]

bool typispreferred BKI_DEFAULT ( )

◆ BKI_DEFAULT() [5/9]

bool typisdefined BKI_DEFAULT ( )

◆ BKI_DEFAULT() [6/9]

char typdelim BKI_DEFAULT ( ,
 
)

◆ BKI_DEFAULT() [7/9]

Oid typrelid BKI_DEFAULT ( )

◆ BKI_DEFAULT() [8/9]

regproc typmodin BKI_DEFAULT ( )

◆ BKI_DEFAULT() [9/9]

char typstorage BKI_DEFAULT ( )

◆ CATALOG()

CATALOG ( pg_type  ,
1247  ,
TypeRelationId   
)

◆ GenerateTypeDependencies()

void GenerateTypeDependencies ( HeapTuple  typeTuple,
Relation  typeCatalog,
Node defaultExpr,
void *  typacl,
char  relationKind,
bool  isImplicitArray,
bool  isDependentType,
bool  rebuild 
)

Definition at line 542 of file pg_type.c.

References ObjectAddress::classId, DatumGetAclPCopy, deleteDependencyRecordsFor(), deleteSharedDependencyRecordsFor(), DEPENDENCY_INTERNAL, DEPENDENCY_NORMAL, GETSTRUCT, heap_getattr, NIL, ObjectAddress::objectId, ObjectAddress::objectSubId, OidIsValid, recordDependencyOn(), recordDependencyOnCurrentExtension(), recordDependencyOnExpr(), recordDependencyOnNewAcl(), recordDependencyOnOwner(), RelationGetDescr, stringToNode(), and TextDatumGetCString.

Referenced by AlterDomainDefault(), AlterTypeRecurse(), TypeCreate(), and TypeShellMake().

550 {
551  Form_pg_type typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
552  Oid typeObjectId = typeForm->oid;
553  Datum datum;
554  bool isNull;
555  ObjectAddress myself,
556  referenced;
557 
558  /* Extract defaultExpr if caller didn't pass it */
559  if (defaultExpr == NULL)
560  {
561  datum = heap_getattr(typeTuple, Anum_pg_type_typdefaultbin,
562  RelationGetDescr(typeCatalog), &isNull);
563  if (!isNull)
564  defaultExpr = stringToNode(TextDatumGetCString(datum));
565  }
566  /* Extract typacl if caller didn't pass it */
567  if (typacl == NULL)
568  {
569  datum = heap_getattr(typeTuple, Anum_pg_type_typacl,
570  RelationGetDescr(typeCatalog), &isNull);
571  if (!isNull)
572  typacl = DatumGetAclPCopy(datum);
573  }
574 
575  /* If rebuild, first flush old dependencies, except extension deps */
576  if (rebuild)
577  {
578  deleteDependencyRecordsFor(TypeRelationId, typeObjectId, true);
579  deleteSharedDependencyRecordsFor(TypeRelationId, typeObjectId, 0);
580  }
581 
582  myself.classId = TypeRelationId;
583  myself.objectId = typeObjectId;
584  myself.objectSubId = 0;
585 
586  /*
587  * Make dependencies on namespace, owner, ACL, extension.
588  *
589  * Skip these for a dependent type, since it will have such dependencies
590  * indirectly through its depended-on type or relation.
591  */
592  if (!isDependentType)
593  {
594  referenced.classId = NamespaceRelationId;
595  referenced.objectId = typeForm->typnamespace;
596  referenced.objectSubId = 0;
597  recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
598 
599  recordDependencyOnOwner(TypeRelationId, typeObjectId,
600  typeForm->typowner);
601 
602  recordDependencyOnNewAcl(TypeRelationId, typeObjectId, 0,
603  typeForm->typowner, typacl);
604 
605  recordDependencyOnCurrentExtension(&myself, rebuild);
606  }
607 
608  /* Normal dependencies on the I/O functions */
609  if (OidIsValid(typeForm->typinput))
610  {
611  referenced.classId = ProcedureRelationId;
612  referenced.objectId = typeForm->typinput;
613  referenced.objectSubId = 0;
614  recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
615  }
616 
617  if (OidIsValid(typeForm->typoutput))
618  {
619  referenced.classId = ProcedureRelationId;
620  referenced.objectId = typeForm->typoutput;
621  referenced.objectSubId = 0;
622  recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
623  }
624 
625  if (OidIsValid(typeForm->typreceive))
626  {
627  referenced.classId = ProcedureRelationId;
628  referenced.objectId = typeForm->typreceive;
629  referenced.objectSubId = 0;
630  recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
631  }
632 
633  if (OidIsValid(typeForm->typsend))
634  {
635  referenced.classId = ProcedureRelationId;
636  referenced.objectId = typeForm->typsend;
637  referenced.objectSubId = 0;
638  recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
639  }
640 
641  if (OidIsValid(typeForm->typmodin))
642  {
643  referenced.classId = ProcedureRelationId;
644  referenced.objectId = typeForm->typmodin;
645  referenced.objectSubId = 0;
646  recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
647  }
648 
649  if (OidIsValid(typeForm->typmodout))
650  {
651  referenced.classId = ProcedureRelationId;
652  referenced.objectId = typeForm->typmodout;
653  referenced.objectSubId = 0;
654  recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
655  }
656 
657  if (OidIsValid(typeForm->typanalyze))
658  {
659  referenced.classId = ProcedureRelationId;
660  referenced.objectId = typeForm->typanalyze;
661  referenced.objectSubId = 0;
662  recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
663  }
664 
665  /*
666  * If the type is a rowtype for a relation, mark it as internally
667  * dependent on the relation, *unless* it is a stand-alone composite type
668  * relation. For the latter case, we have to reverse the dependency.
669  *
670  * In the former case, this allows the type to be auto-dropped when the
671  * relation is, and not otherwise. And in the latter, of course we get the
672  * opposite effect.
673  */
674  if (OidIsValid(typeForm->typrelid))
675  {
676  referenced.classId = RelationRelationId;
677  referenced.objectId = typeForm->typrelid;
678  referenced.objectSubId = 0;
679 
680  if (relationKind != RELKIND_COMPOSITE_TYPE)
681  recordDependencyOn(&myself, &referenced, DEPENDENCY_INTERNAL);
682  else
683  recordDependencyOn(&referenced, &myself, DEPENDENCY_INTERNAL);
684  }
685 
686  /*
687  * If the type is an implicitly-created array type, mark it as internally
688  * dependent on the element type. Otherwise, if it has an element type,
689  * the dependency is a normal one.
690  */
691  if (OidIsValid(typeForm->typelem))
692  {
693  referenced.classId = TypeRelationId;
694  referenced.objectId = typeForm->typelem;
695  referenced.objectSubId = 0;
696  recordDependencyOn(&myself, &referenced,
697  isImplicitArray ? DEPENDENCY_INTERNAL : DEPENDENCY_NORMAL);
698  }
699 
700  /* Normal dependency from a domain to its base type. */
701  if (OidIsValid(typeForm->typbasetype))
702  {
703  referenced.classId = TypeRelationId;
704  referenced.objectId = typeForm->typbasetype;
705  referenced.objectSubId = 0;
706  recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
707  }
708 
709  /* Normal dependency from a domain to its collation. */
710  /* We know the default collation is pinned, so don't bother recording it */
711  if (OidIsValid(typeForm->typcollation) &&
712  typeForm->typcollation != DEFAULT_COLLATION_OID)
713  {
714  referenced.classId = CollationRelationId;
715  referenced.objectId = typeForm->typcollation;
716  referenced.objectSubId = 0;
717  recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
718  }
719 
720  /* Normal dependency on the default expression. */
721  if (defaultExpr)
722  recordDependencyOnExpr(&myself, defaultExpr, NIL, DEPENDENCY_NORMAL);
723 }
#define NIL
Definition: pg_list.h:65
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define RelationGetDescr(relation)
Definition: rel.h:482
long deleteDependencyRecordsFor(Oid classId, Oid objectId, bool skipExtensionDeps)
Definition: pg_depend.c:190
void * stringToNode(const char *str)
Definition: read.c:89
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
Definition: pg_depend.c:43
void recordDependencyOnOwner(Oid classId, Oid objectId, Oid owner)
Definition: pg_shdepend.c:164
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:644
void recordDependencyOnExpr(const ObjectAddress *depender, Node *expr, List *rtable, DependencyType behavior)
Definition: dependency.c:1587
void deleteSharedDependencyRecordsFor(Oid classId, Oid objectId, int32 objectSubId)
Definition: pg_shdepend.c:907
#define heap_getattr(tup, attnum, tupleDesc, isnull)
Definition: htup_details.h:762
#define TextDatumGetCString(d)
Definition: builtins.h:88
uintptr_t Datum
Definition: postgres.h:367
void recordDependencyOnCurrentExtension(const ObjectAddress *object, bool isReplace)
Definition: pg_depend.c:138
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255
void recordDependencyOnNewAcl(Oid classId, Oid objectId, int32 objsubId, Oid ownerId, Acl *acl)
Definition: aclchk.c:5532
#define DatumGetAclPCopy(X)
Definition: acl.h:121

◆ makeArrayTypeName()

char* makeArrayTypeName ( const char *  typeName,
Oid  typeNamespace 
)

Definition at line 810 of file pg_type.c.

References CStringGetDatum, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errmsg(), ERROR, i, NAMEDATALEN, ObjectIdGetDatum, palloc(), SearchSysCacheExists2, truncate_identifier(), and TYPENAMENSP.

Referenced by DefineDomain(), DefineEnum(), DefineRange(), DefineType(), heap_create_with_catalog(), moveArrayTypeName(), and RenameTypeInternal().

811 {
812  char *arr = (char *) palloc(NAMEDATALEN);
813  int namelen = strlen(typeName);
814  int i;
815 
816  /*
817  * The idea is to prepend underscores as needed until we make a name that
818  * doesn't collide with anything...
819  */
820  for (i = 1; i < NAMEDATALEN - 1; i++)
821  {
822  arr[i - 1] = '_';
823  if (i + namelen < NAMEDATALEN)
824  strcpy(arr + i, typeName);
825  else
826  {
827  memcpy(arr + i, typeName, NAMEDATALEN - i);
828  truncate_identifier(arr, NAMEDATALEN, false);
829  }
831  CStringGetDatum(arr),
832  ObjectIdGetDatum(typeNamespace)))
833  break;
834  }
835 
836  if (i >= NAMEDATALEN - 1)
837  ereport(ERROR,
839  errmsg("could not form array type name for type \"%s\"",
840  typeName)));
841 
842  return arr;
843 }
int errcode(int sqlerrcode)
Definition: elog.c:610
#define NAMEDATALEN
void truncate_identifier(char *ident, int len, bool warn)
Definition: scansup.c:186
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
#define CStringGetDatum(X)
Definition: postgres.h:578
#define ereport(elevel,...)
Definition: elog.h:144
#define SearchSysCacheExists2(cacheId, key1, key2)
Definition: syscache.h:185
void * palloc(Size size)
Definition: mcxt.c:949
int errmsg(const char *fmt,...)
Definition: elog.c:824
int i
#define ERRCODE_DUPLICATE_OBJECT
Definition: streamutil.c:31

◆ moveArrayTypeName()

bool moveArrayTypeName ( Oid  typeOid,
const char *  typeName,
Oid  typeNamespace 
)

Definition at line 871 of file pg_type.c.

References CommandCounterIncrement(), get_array_type(), get_element_type(), get_typisdefined(), makeArrayTypeName(), OidIsValid, pfree(), and RenameTypeInternal().

Referenced by DefineCompositeType(), DefineDomain(), DefineEnum(), DefineRange(), DefineType(), heap_create_with_catalog(), and RenameTypeInternal().

872 {
873  Oid elemOid;
874  char *newname;
875 
876  /* We need do nothing if it's a shell type. */
877  if (!get_typisdefined(typeOid))
878  return true;
879 
880  /* Can't change it if it's not an autogenerated array type. */
881  elemOid = get_element_type(typeOid);
882  if (!OidIsValid(elemOid) ||
883  get_array_type(elemOid) != typeOid)
884  return false;
885 
886  /*
887  * OK, use makeArrayTypeName to pick an unused modification of the name.
888  * Note that since makeArrayTypeName is an iterative process, this will
889  * produce a name that it might have produced the first time, had the
890  * conflicting type we are about to create already existed.
891  */
892  newname = makeArrayTypeName(typeName, typeNamespace);
893 
894  /* Apply the rename */
895  RenameTypeInternal(typeOid, newname, typeNamespace);
896 
897  /*
898  * We must bump the command counter so that any subsequent use of
899  * makeArrayTypeName sees what we just did and doesn't pick the same name.
900  */
902 
903  pfree(newname);
904 
905  return true;
906 }
char * makeArrayTypeName(const char *typeName, Oid typeNamespace)
Definition: pg_type.c:810
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2587
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2615
bool get_typisdefined(Oid typid)
Definition: lsyscache.c:2012
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:644
void pfree(void *pointer)
Definition: mcxt.c:1056
void RenameTypeInternal(Oid typeOid, const char *newTypeName, Oid typeNamespace)
Definition: pg_type.c:735
void CommandCounterIncrement(void)
Definition: xact.c:1005

◆ RenameTypeInternal()

void RenameTypeInternal ( Oid  typeOid,
const char *  newTypeName,
Oid  typeNamespace 
)

Definition at line 735 of file pg_type.c.

References Assert, CatalogTupleUpdate(), CStringGetDatum, elog, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errmsg(), ERROR, get_typisdefined(), GETSTRUCT, GetSysCacheOid2, heap_freetuple(), HeapTupleIsValid, InvokeObjectPostAlterHook, makeArrayTypeName(), moveArrayTypeName(), namestrcpy(), ObjectIdGetDatum, OidIsValid, pfree(), RenameTypeInternal(), RowExclusiveLock, SearchSysCacheCopy1, HeapTupleData::t_self, table_close(), table_open(), TYPENAMENSP, and TYPEOID.

Referenced by moveArrayTypeName(), RenameRelationInternal(), RenameType(), and RenameTypeInternal().

736 {
737  Relation pg_type_desc;
738  HeapTuple tuple;
739  Form_pg_type typ;
740  Oid arrayOid;
741  Oid oldTypeOid;
742 
743  pg_type_desc = table_open(TypeRelationId, RowExclusiveLock);
744 
745  tuple = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
746  if (!HeapTupleIsValid(tuple))
747  elog(ERROR, "cache lookup failed for type %u", typeOid);
748  typ = (Form_pg_type) GETSTRUCT(tuple);
749 
750  /* We are not supposed to be changing schemas here */
751  Assert(typeNamespace == typ->typnamespace);
752 
753  arrayOid = typ->typarray;
754 
755  /* Check for a conflicting type name. */
756  oldTypeOid = GetSysCacheOid2(TYPENAMENSP, Anum_pg_type_oid,
757  CStringGetDatum(newTypeName),
758  ObjectIdGetDatum(typeNamespace));
759 
760  /*
761  * If there is one, see if it's an autogenerated array type, and if so
762  * rename it out of the way. (But we must skip that for a shell type
763  * because moveArrayTypeName will do the wrong thing in that case.)
764  * Otherwise, we can at least give a more friendly error than unique-index
765  * violation.
766  */
767  if (OidIsValid(oldTypeOid))
768  {
769  if (get_typisdefined(oldTypeOid) &&
770  moveArrayTypeName(oldTypeOid, newTypeName, typeNamespace))
771  /* successfully dodged the problem */ ;
772  else
773  ereport(ERROR,
775  errmsg("type \"%s\" already exists", newTypeName)));
776  }
777 
778  /* OK, do the rename --- tuple is a copy, so OK to scribble on it */
779  namestrcpy(&(typ->typname), newTypeName);
780 
781  CatalogTupleUpdate(pg_type_desc, &tuple->t_self, tuple);
782 
783  InvokeObjectPostAlterHook(TypeRelationId, typeOid, 0);
784 
785  heap_freetuple(tuple);
786  table_close(pg_type_desc, RowExclusiveLock);
787 
788  /*
789  * If the type has an array type, recurse to handle that. But we don't
790  * need to do anything more if we already renamed that array type above
791  * (which would happen when, eg, renaming "foo" to "_foo").
792  */
793  if (OidIsValid(arrayOid) && arrayOid != oldTypeOid)
794  {
795  char *arrname = makeArrayTypeName(newTypeName, typeNamespace);
796 
797  RenameTypeInternal(arrayOid, arrname, typeNamespace);
798  pfree(arrname);
799  }
800 }
char * makeArrayTypeName(const char *typeName, Oid typeNamespace)
Definition: pg_type.c:810
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:133
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
bool get_typisdefined(Oid typid)
Definition: lsyscache.c:2012
int errcode(int sqlerrcode)
Definition: elog.c:610
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1338
unsigned int Oid
Definition: postgres_ext.h:31
int namestrcpy(Name name, const char *str)
Definition: name.c:250
#define OidIsValid(objectId)
Definition: c.h:644
void pfree(void *pointer)
Definition: mcxt.c:1056
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
ItemPointerData t_self
Definition: htup.h:65
bool moveArrayTypeName(Oid typeOid, const char *typeName, Oid typeNamespace)
Definition: pg_type.c:871
#define RowExclusiveLock
Definition: lockdefs.h:38
#define CStringGetDatum(X)
Definition: postgres.h:578
#define InvokeObjectPostAlterHook(classId, objectId, subId)
Definition: objectaccess.h:175
void RenameTypeInternal(Oid typeOid, const char *newTypeName, Oid typeNamespace)
Definition: pg_type.c:735
#define ereport(elevel,...)
Definition: elog.h:144
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:738
#define GetSysCacheOid2(cacheId, oidcol, key1, key2)
Definition: syscache.h:194
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
Definition: indexing.c:224
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255
#define SearchSysCacheCopy1(cacheId, key1)
Definition: syscache.h:174
int errmsg(const char *fmt,...)
Definition: elog.c:824
#define elog(elevel,...)
Definition: elog.h:214
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:39
#define ERRCODE_DUPLICATE_OBJECT
Definition: streamutil.c:31

◆ TypeCreate()

ObjectAddress TypeCreate ( Oid  newTypeOid,
const char *  typeName,
Oid  typeNamespace,
Oid  relationOid,
char  relationKind,
Oid  ownerId,
int16  internalSize,
char  typeType,
char  typeCategory,
bool  typePreferred,
char  typDelim,
Oid  inputProcedure,
Oid  outputProcedure,
Oid  receiveProcedure,
Oid  sendProcedure,
Oid  typmodinProcedure,
Oid  typmodoutProcedure,
Oid  analyzeProcedure,
Oid  elementType,
bool  isImplicitArray,
Oid  arrayType,
Oid  baseType,
const char *  defaultTypeValue,
char *  defaultTypeBin,
bool  passedByValue,
char  alignment,
char  storage,
int32  typeMod,
int32  typNDims,
bool  typeNotNull,
Oid  typeCollation 
)

Definition at line 192 of file pg_type.c.

References aclcheck_error(), ACLCHECK_NOT_OWNER, binary_upgrade_next_pg_type_oid, BoolGetDatum, CatalogTupleInsert(), CatalogTupleUpdate(), CharGetDatum, CStringGetDatum, CStringGetTextDatum, elog, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errmsg(), ERROR, GenerateTypeDependencies(), get_user_default_acl(), GetNewOidWithIndex(), GETSTRUCT, heap_form_tuple(), heap_modify_tuple(), HeapTupleIsValid, i, Int16GetDatum, Int32GetDatum, InvalidOid, InvokeObjectPostCreateHook, IsBinaryUpgrade, IsBootstrapProcessingMode, name, NameGetDatum, namestrcpy(), OBJECT_TYPE, ObjectAddressSet, ObjectIdGetDatum, OidIsValid, PointerGetDatum, RelationGetDescr, RowExclusiveLock, SearchSysCacheCopy2, stringToNode(), HeapTupleData::t_self, table_close(), table_open(), TYPENAMENSP, TypeOidIndexId, and values.

Referenced by AddNewRelationType(), DefineDomain(), DefineEnum(), DefineRange(), DefineType(), and heap_create_with_catalog().

223 {
224  Relation pg_type_desc;
225  Oid typeObjectId;
226  bool isDependentType;
227  bool rebuildDeps = false;
228  Acl *typacl;
229  HeapTuple tup;
230  bool nulls[Natts_pg_type];
231  bool replaces[Natts_pg_type];
232  Datum values[Natts_pg_type];
233  NameData name;
234  int i;
235  ObjectAddress address;
236 
237  /*
238  * We assume that the caller validated the arguments individually, but did
239  * not check for bad combinations.
240  *
241  * Validate size specifications: either positive (fixed-length) or -1
242  * (varlena) or -2 (cstring).
243  */
244  if (!(internalSize > 0 ||
245  internalSize == -1 ||
246  internalSize == -2))
247  ereport(ERROR,
248  (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
249  errmsg("invalid type internal size %d",
250  internalSize)));
251 
252  if (passedByValue)
253  {
254  /*
255  * Pass-by-value types must have a fixed length that is one of the
256  * values supported by fetch_att() and store_att_byval(); and the
257  * alignment had better agree, too. All this code must match
258  * access/tupmacs.h!
259  */
260  if (internalSize == (int16) sizeof(char))
261  {
262  if (alignment != TYPALIGN_CHAR)
263  ereport(ERROR,
264  (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
265  errmsg("alignment \"%c\" is invalid for passed-by-value type of size %d",
266  alignment, internalSize)));
267  }
268  else if (internalSize == (int16) sizeof(int16))
269  {
270  if (alignment != TYPALIGN_SHORT)
271  ereport(ERROR,
272  (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
273  errmsg("alignment \"%c\" is invalid for passed-by-value type of size %d",
274  alignment, internalSize)));
275  }
276  else if (internalSize == (int16) sizeof(int32))
277  {
278  if (alignment != TYPALIGN_INT)
279  ereport(ERROR,
280  (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
281  errmsg("alignment \"%c\" is invalid for passed-by-value type of size %d",
282  alignment, internalSize)));
283  }
284 #if SIZEOF_DATUM == 8
285  else if (internalSize == (int16) sizeof(Datum))
286  {
287  if (alignment != TYPALIGN_DOUBLE)
288  ereport(ERROR,
289  (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
290  errmsg("alignment \"%c\" is invalid for passed-by-value type of size %d",
291  alignment, internalSize)));
292  }
293 #endif
294  else
295  ereport(ERROR,
296  (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
297  errmsg("internal size %d is invalid for passed-by-value type",
298  internalSize)));
299  }
300  else
301  {
302  /* varlena types must have int align or better */
303  if (internalSize == -1 &&
304  !(alignment == TYPALIGN_INT || alignment == TYPALIGN_DOUBLE))
305  ereport(ERROR,
306  (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
307  errmsg("alignment \"%c\" is invalid for variable-length type",
308  alignment)));
309  /* cstring must have char alignment */
310  if (internalSize == -2 && !(alignment == TYPALIGN_CHAR))
311  ereport(ERROR,
312  (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
313  errmsg("alignment \"%c\" is invalid for variable-length type",
314  alignment)));
315  }
316 
317  /* Only varlena types can be toasted */
318  if (storage != TYPSTORAGE_PLAIN && internalSize != -1)
319  ereport(ERROR,
320  (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
321  errmsg("fixed-size types must have storage PLAIN")));
322 
323  /*
324  * This is a dependent type if it's an implicitly-created array type, or
325  * if it's a relation rowtype that's not a composite type. For such types
326  * we'll leave the ACL empty, and we'll skip creating some dependency
327  * records because there will be a dependency already through the
328  * depended-on type or relation. (Caution: this is closely intertwined
329  * with some behavior in GenerateTypeDependencies.)
330  */
331  isDependentType = isImplicitArray ||
332  (OidIsValid(relationOid) && relationKind != RELKIND_COMPOSITE_TYPE);
333 
334  /*
335  * initialize arrays needed for heap_form_tuple or heap_modify_tuple
336  */
337  for (i = 0; i < Natts_pg_type; ++i)
338  {
339  nulls[i] = false;
340  replaces[i] = true;
341  values[i] = (Datum) 0;
342  }
343 
344  /*
345  * insert data values
346  */
347  namestrcpy(&name, typeName);
348  values[Anum_pg_type_typname - 1] = NameGetDatum(&name);
349  values[Anum_pg_type_typnamespace - 1] = ObjectIdGetDatum(typeNamespace);
350  values[Anum_pg_type_typowner - 1] = ObjectIdGetDatum(ownerId);
351  values[Anum_pg_type_typlen - 1] = Int16GetDatum(internalSize);
352  values[Anum_pg_type_typbyval - 1] = BoolGetDatum(passedByValue);
353  values[Anum_pg_type_typtype - 1] = CharGetDatum(typeType);
354  values[Anum_pg_type_typcategory - 1] = CharGetDatum(typeCategory);
355  values[Anum_pg_type_typispreferred - 1] = BoolGetDatum(typePreferred);
356  values[Anum_pg_type_typisdefined - 1] = BoolGetDatum(true);
357  values[Anum_pg_type_typdelim - 1] = CharGetDatum(typDelim);
358  values[Anum_pg_type_typrelid - 1] = ObjectIdGetDatum(relationOid);
359  values[Anum_pg_type_typelem - 1] = ObjectIdGetDatum(elementType);
360  values[Anum_pg_type_typarray - 1] = ObjectIdGetDatum(arrayType);
361  values[Anum_pg_type_typinput - 1] = ObjectIdGetDatum(inputProcedure);
362  values[Anum_pg_type_typoutput - 1] = ObjectIdGetDatum(outputProcedure);
363  values[Anum_pg_type_typreceive - 1] = ObjectIdGetDatum(receiveProcedure);
364  values[Anum_pg_type_typsend - 1] = ObjectIdGetDatum(sendProcedure);
365  values[Anum_pg_type_typmodin - 1] = ObjectIdGetDatum(typmodinProcedure);
366  values[Anum_pg_type_typmodout - 1] = ObjectIdGetDatum(typmodoutProcedure);
367  values[Anum_pg_type_typanalyze - 1] = ObjectIdGetDatum(analyzeProcedure);
368  values[Anum_pg_type_typalign - 1] = CharGetDatum(alignment);
369  values[Anum_pg_type_typstorage - 1] = CharGetDatum(storage);
370  values[Anum_pg_type_typnotnull - 1] = BoolGetDatum(typeNotNull);
371  values[Anum_pg_type_typbasetype - 1] = ObjectIdGetDatum(baseType);
372  values[Anum_pg_type_typtypmod - 1] = Int32GetDatum(typeMod);
373  values[Anum_pg_type_typndims - 1] = Int32GetDatum(typNDims);
374  values[Anum_pg_type_typcollation - 1] = ObjectIdGetDatum(typeCollation);
375 
376  /*
377  * initialize the default binary value for this type. Check for nulls of
378  * course.
379  */
380  if (defaultTypeBin)
381  values[Anum_pg_type_typdefaultbin - 1] = CStringGetTextDatum(defaultTypeBin);
382  else
383  nulls[Anum_pg_type_typdefaultbin - 1] = true;
384 
385  /*
386  * initialize the default value for this type.
387  */
388  if (defaultTypeValue)
389  values[Anum_pg_type_typdefault - 1] = CStringGetTextDatum(defaultTypeValue);
390  else
391  nulls[Anum_pg_type_typdefault - 1] = true;
392 
393  /*
394  * Initialize the type's ACL, too. But dependent types don't get one.
395  */
396  if (isDependentType)
397  typacl = NULL;
398  else
399  typacl = get_user_default_acl(OBJECT_TYPE, ownerId,
400  typeNamespace);
401  if (typacl != NULL)
402  values[Anum_pg_type_typacl - 1] = PointerGetDatum(typacl);
403  else
404  nulls[Anum_pg_type_typacl - 1] = true;
405 
406  /*
407  * open pg_type and prepare to insert or update a row.
408  *
409  * NOTE: updating will not work correctly in bootstrap mode; but we don't
410  * expect to be overwriting any shell types in bootstrap mode.
411  */
412  pg_type_desc = table_open(TypeRelationId, RowExclusiveLock);
413 
415  CStringGetDatum(typeName),
416  ObjectIdGetDatum(typeNamespace));
417  if (HeapTupleIsValid(tup))
418  {
419  Form_pg_type typform = (Form_pg_type) GETSTRUCT(tup);
420 
421  /*
422  * check that the type is not already defined. It may exist as a
423  * shell type, however.
424  */
425  if (typform->typisdefined)
426  ereport(ERROR,
428  errmsg("type \"%s\" already exists", typeName)));
429 
430  /*
431  * shell type must have been created by same owner
432  */
433  if (typform->typowner != ownerId)
435 
436  /* trouble if caller wanted to force the OID */
437  if (OidIsValid(newTypeOid))
438  elog(ERROR, "cannot assign new OID to existing shell type");
439 
440  replaces[Anum_pg_type_oid - 1] = false;
441 
442  /*
443  * Okay to update existing shell type tuple
444  */
445  tup = heap_modify_tuple(tup,
446  RelationGetDescr(pg_type_desc),
447  values,
448  nulls,
449  replaces);
450 
451  CatalogTupleUpdate(pg_type_desc, &tup->t_self, tup);
452 
453  typeObjectId = typform->oid;
454 
455  rebuildDeps = true; /* get rid of shell type's dependencies */
456  }
457  else
458  {
459  /* Force the OID if requested by caller */
460  if (OidIsValid(newTypeOid))
461  typeObjectId = newTypeOid;
462  /* Use binary-upgrade override for pg_type.oid, if supplied. */
463  else if (IsBinaryUpgrade)
464  {
466  ereport(ERROR,
467  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
468  errmsg("pg_type OID value not set when in binary upgrade mode")));
469 
470  typeObjectId = binary_upgrade_next_pg_type_oid;
472  }
473  else
474  {
475  typeObjectId = GetNewOidWithIndex(pg_type_desc, TypeOidIndexId,
476  Anum_pg_type_oid);
477  }
478 
479  values[Anum_pg_type_oid - 1] = ObjectIdGetDatum(typeObjectId);
480 
481  tup = heap_form_tuple(RelationGetDescr(pg_type_desc),
482  values, nulls);
483 
484  CatalogTupleInsert(pg_type_desc, tup);
485  }
486 
487  /*
488  * Create dependencies. We can/must skip this in bootstrap mode.
489  */
492  pg_type_desc,
493  (defaultTypeBin ?
494  stringToNode(defaultTypeBin) :
495  NULL),
496  typacl,
497  relationKind,
498  isImplicitArray,
499  isDependentType,
500  rebuildDeps);
501 
502  /* Post creation hook for new type */
503  InvokeObjectPostCreateHook(TypeRelationId, typeObjectId, 0);
504 
505  ObjectAddressSet(address, TypeRelationId, typeObjectId);
506 
507  /*
508  * finish up
509  */
510  table_close(pg_type_desc, RowExclusiveLock);
511 
512  return address;
513 }
signed short int16
Definition: c.h:354
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
Definition: catalog.c:317
#define NameGetDatum(X)
Definition: postgres.h:595
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:133
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define InvokeObjectPostCreateHook(classId, objectId, subId)
Definition: objectaccess.h:151
#define RelationGetDescr(relation)
Definition: rel.h:482
#define PointerGetDatum(X)
Definition: postgres.h:556
#define Int16GetDatum(X)
Definition: postgres.h:451
int errcode(int sqlerrcode)
Definition: elog.c:610
void * stringToNode(const char *str)
Definition: read.c:89
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1020
unsigned int Oid
Definition: postgres_ext.h:31
int namestrcpy(Name name, const char *str)
Definition: name.c:250
#define OidIsValid(objectId)
Definition: c.h:644
bool IsBinaryUpgrade
Definition: globals.c:110
signed int int32
Definition: c.h:355
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
Definition: aclchk.c:3352
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
ItemPointerData t_self
Definition: htup.h:65
Definition: c.h:609
#define RowExclusiveLock
Definition: lockdefs.h:38
#define CStringGetDatum(X)
Definition: postgres.h:578
Oid binary_upgrade_next_pg_type_oid
Definition: pg_type.c:40
uintptr_t Datum
Definition: postgres.h:367
#define BoolGetDatum(X)
Definition: postgres.h:402
#define InvalidOid
Definition: postgres_ext.h:36
#define ereport(elevel,...)
Definition: elog.h:144
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
void GenerateTypeDependencies(HeapTuple typeTuple, Relation typeCatalog, Node *defaultExpr, void *typacl, char relationKind, bool isImplicitArray, bool isDependentType, bool rebuild)
Definition: pg_type.c:542
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
Definition: indexing.c:224
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255
const char * name
Definition: encode.c:521
#define ObjectAddressSet(addr, class_id, object_id)
Definition: objectaddress.h:40
#define CharGetDatum(X)
Definition: postgres.h:416
static Datum values[MAXATTR]
Definition: bootstrap.c:167
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:392
#define Int32GetDatum(X)
Definition: postgres.h:479
int errmsg(const char *fmt,...)
Definition: elog.c:824
#define elog(elevel,...)
Definition: elog.h:214
int i
#define CStringGetTextDatum(s)
Definition: builtins.h:87
#define SearchSysCacheCopy2(cacheId, key1, key2)
Definition: syscache.h:176
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:39
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *replValues, bool *replIsnull, bool *doReplace)
Definition: heaptuple.c:1113
#define ERRCODE_DUPLICATE_OBJECT
Definition: streamutil.c:31
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
Definition: indexing.c:183
#define TypeOidIndexId
Definition: indexing.h:286
Acl * get_user_default_acl(ObjectType objtype, Oid ownerId, Oid nsp_oid)
Definition: aclchk.c:5456

◆ TypeShellMake()

ObjectAddress TypeShellMake ( const char *  typeName,
Oid  typeNamespace,
Oid  ownerId 
)

Definition at line 56 of file pg_type.c.

References Assert, binary_upgrade_next_pg_type_oid, BoolGetDatum, CatalogTupleInsert(), CharGetDatum, DEFAULT_TYPDELIM, ereport, errcode(), errmsg(), ERROR, GenerateTypeDependencies(), GetNewOidWithIndex(), heap_form_tuple(), heap_freetuple(), i, Int16GetDatum, Int32GetDatum, InvalidOid, InvokeObjectPostCreateHook, IsBinaryUpgrade, IsBootstrapProcessingMode, name, NameGetDatum, namestrcpy(), ObjectAddressSet, ObjectIdGetDatum, OidIsValid, PointerIsValid, RelationData::rd_att, RowExclusiveLock, table_close(), table_open(), TypeOidIndexId, and values.

Referenced by compute_return_type(), and DefineType().

57 {
58  Relation pg_type_desc;
59  TupleDesc tupDesc;
60  int i;
61  HeapTuple tup;
62  Datum values[Natts_pg_type];
63  bool nulls[Natts_pg_type];
64  Oid typoid;
65  NameData name;
66  ObjectAddress address;
67 
68  Assert(PointerIsValid(typeName));
69 
70  /*
71  * open pg_type
72  */
73  pg_type_desc = table_open(TypeRelationId, RowExclusiveLock);
74  tupDesc = pg_type_desc->rd_att;
75 
76  /*
77  * initialize our *nulls and *values arrays
78  */
79  for (i = 0; i < Natts_pg_type; ++i)
80  {
81  nulls[i] = false;
82  values[i] = (Datum) NULL; /* redundant, but safe */
83  }
84 
85  /*
86  * initialize *values with the type name and dummy values
87  *
88  * The representational details are the same as int4 ... it doesn't really
89  * matter what they are so long as they are consistent. Also note that we
90  * give it typtype = TYPTYPE_PSEUDO as extra insurance that it won't be
91  * mistaken for a usable type.
92  */
93  namestrcpy(&name, typeName);
94  values[Anum_pg_type_typname - 1] = NameGetDatum(&name);
95  values[Anum_pg_type_typnamespace - 1] = ObjectIdGetDatum(typeNamespace);
96  values[Anum_pg_type_typowner - 1] = ObjectIdGetDatum(ownerId);
97  values[Anum_pg_type_typlen - 1] = Int16GetDatum(sizeof(int32));
98  values[Anum_pg_type_typbyval - 1] = BoolGetDatum(true);
99  values[Anum_pg_type_typtype - 1] = CharGetDatum(TYPTYPE_PSEUDO);
100  values[Anum_pg_type_typcategory - 1] = CharGetDatum(TYPCATEGORY_PSEUDOTYPE);
101  values[Anum_pg_type_typispreferred - 1] = BoolGetDatum(false);
102  values[Anum_pg_type_typisdefined - 1] = BoolGetDatum(false);
103  values[Anum_pg_type_typdelim - 1] = CharGetDatum(DEFAULT_TYPDELIM);
104  values[Anum_pg_type_typrelid - 1] = ObjectIdGetDatum(InvalidOid);
105  values[Anum_pg_type_typelem - 1] = ObjectIdGetDatum(InvalidOid);
106  values[Anum_pg_type_typarray - 1] = ObjectIdGetDatum(InvalidOid);
107  values[Anum_pg_type_typinput - 1] = ObjectIdGetDatum(F_SHELL_IN);
108  values[Anum_pg_type_typoutput - 1] = ObjectIdGetDatum(F_SHELL_OUT);
109  values[Anum_pg_type_typreceive - 1] = ObjectIdGetDatum(InvalidOid);
110  values[Anum_pg_type_typsend - 1] = ObjectIdGetDatum(InvalidOid);
111  values[Anum_pg_type_typmodin - 1] = ObjectIdGetDatum(InvalidOid);
112  values[Anum_pg_type_typmodout - 1] = ObjectIdGetDatum(InvalidOid);
113  values[Anum_pg_type_typanalyze - 1] = ObjectIdGetDatum(InvalidOid);
114  values[Anum_pg_type_typalign - 1] = CharGetDatum(TYPALIGN_INT);
115  values[Anum_pg_type_typstorage - 1] = CharGetDatum(TYPSTORAGE_PLAIN);
116  values[Anum_pg_type_typnotnull - 1] = BoolGetDatum(false);
117  values[Anum_pg_type_typbasetype - 1] = ObjectIdGetDatum(InvalidOid);
118  values[Anum_pg_type_typtypmod - 1] = Int32GetDatum(-1);
119  values[Anum_pg_type_typndims - 1] = Int32GetDatum(0);
120  values[Anum_pg_type_typcollation - 1] = ObjectIdGetDatum(InvalidOid);
121  nulls[Anum_pg_type_typdefaultbin - 1] = true;
122  nulls[Anum_pg_type_typdefault - 1] = true;
123  nulls[Anum_pg_type_typacl - 1] = true;
124 
125  /* Use binary-upgrade override for pg_type.oid? */
126  if (IsBinaryUpgrade)
127  {
129  ereport(ERROR,
130  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
131  errmsg("pg_type OID value not set when in binary upgrade mode")));
132 
135  }
136  else
137  {
138  typoid = GetNewOidWithIndex(pg_type_desc, TypeOidIndexId,
139  Anum_pg_type_oid);
140  }
141 
142  values[Anum_pg_type_oid - 1] = ObjectIdGetDatum(typoid);
143 
144  /*
145  * create a new type tuple
146  */
147  tup = heap_form_tuple(tupDesc, values, nulls);
148 
149  /*
150  * insert the tuple in the relation and get the tuple's oid.
151  */
152  CatalogTupleInsert(pg_type_desc, tup);
153 
154  /*
155  * Create dependencies. We can/must skip this in bootstrap mode.
156  */
159  pg_type_desc,
160  NULL,
161  NULL,
162  0,
163  false,
164  false,
165  false);
166 
167  /* Post creation hook for new shell type */
168  InvokeObjectPostCreateHook(TypeRelationId, typoid, 0);
169 
170  ObjectAddressSet(address, TypeRelationId, typoid);
171 
172  /*
173  * clean up and return the type-oid
174  */
175  heap_freetuple(tup);
176  table_close(pg_type_desc, RowExclusiveLock);
177 
178  return address;
179 }
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
Definition: catalog.c:317
#define NameGetDatum(X)
Definition: postgres.h:595
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:133
#define InvokeObjectPostCreateHook(classId, objectId, subId)
Definition: objectaccess.h:151
#define Int16GetDatum(X)
Definition: postgres.h:451
int errcode(int sqlerrcode)
Definition: elog.c:610
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1020
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1338
unsigned int Oid
Definition: postgres_ext.h:31
int namestrcpy(Name name, const char *str)
Definition: name.c:250
#define OidIsValid(objectId)
Definition: c.h:644
bool IsBinaryUpgrade
Definition: globals.c:110
signed int int32
Definition: c.h:355
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
Definition: c.h:609
#define RowExclusiveLock
Definition: lockdefs.h:38
Oid binary_upgrade_next_pg_type_oid
Definition: pg_type.c:40
uintptr_t Datum
Definition: postgres.h:367
TupleDesc rd_att
Definition: rel.h:110
#define BoolGetDatum(X)
Definition: postgres.h:402
#define InvalidOid
Definition: postgres_ext.h:36
#define ereport(elevel,...)
Definition: elog.h:144
#define DEFAULT_TYPDELIM
Definition: typecmds.h:22
#define Assert(condition)
Definition: c.h:738
void GenerateTypeDependencies(HeapTuple typeTuple, Relation typeCatalog, Node *defaultExpr, void *typacl, char relationKind, bool isImplicitArray, bool isDependentType, bool rebuild)
Definition: pg_type.c:542
const char * name
Definition: encode.c:521
#define ObjectAddressSet(addr, class_id, object_id)
Definition: objectaddress.h:40
#define CharGetDatum(X)
Definition: postgres.h:416
static Datum values[MAXATTR]
Definition: bootstrap.c:167
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:392
#define Int32GetDatum(X)
Definition: postgres.h:479
int errmsg(const char *fmt,...)
Definition: elog.c:824
int i
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:39
#define PointerIsValid(pointer)
Definition: c.h:632
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
Definition: indexing.c:183
#define TypeOidIndexId
Definition: indexing.h:286

Variable Documentation

◆ BKI_SCHEMA_MACRO

TypeRelation_Rowtype_Id BKI_SCHEMA_MACRO
Initial value:
{
Oid oid
unsigned int Oid
Definition: postgres_ext.h:31

Definition at line 37 of file pg_type.h.

◆ FormData_pg_type

FormData_pg_type

Definition at line 248 of file pg_type.h.

◆ typalign

◆ typname