📄 pg_type.h
字号:
/*------------------------------------------------------------------------- * * pg_type.h * definition of the system "type" relation (pg_type) * along with the relation's initial contents. * * * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.166.2.1 2005/11/22 18:23:27 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki * information from the DATA() statements. * *------------------------------------------------------------------------- */#ifndef PG_TYPE_H#define PG_TYPE_H#include "nodes/nodes.h"/* ---------------- * postgres.h contains the system type definitions and the * CATALOG(), BKI_BOOTSTRAP and DATA() sugar words so this file * can be read by both genbki.sh and the C compiler. * ---------------- *//* ---------------- * pg_type definition. cpp turns this into * typedef struct FormData_pg_type * * Some of the values in a pg_type instance are copied into * pg_attribute instances. Some parts of Postgres use the pg_type copy, * while others use the pg_attribute copy, so they must match. * See struct FormData_pg_attribute for details. * ---------------- */#define TypeRelationId 1247CATALOG(pg_type,1247) BKI_BOOTSTRAP{ NameData typname; /* type name */ Oid typnamespace; /* OID of namespace containing this type */ Oid typowner; /* type owner */ /* * For a fixed-size type, typlen is the number of bytes we use to * represent a value of this type, e.g. 4 for an int4. But for a * variable-length type, typlen is negative. We use -1 to indicate a * "varlena" type (one that has a length word), -2 to indicate a * null-terminated C string. */ int2 typlen; /* * typbyval determines whether internal Postgres routines pass a value of * this type by value or by reference. typbyval had better be FALSE if * the length is not 1, 2, or 4 (or 8 on 8-byte-Datum machines). * Variable-length types are always passed by reference. Note that * typbyval can be false even if the length would allow pass-by-value; * this is currently true for type float4, for example. */ bool typbyval; /* * typtype is 'b' for a basic type, 'c' for a complex type (ie a table's * rowtype), 'd' for a domain type, or 'p' for a pseudo type. * * If typtype is 'c', typrelid is the OID of the class' entry in pg_class. */ char typtype; /* * If typisdefined is false, the entry is only a placeholder (forward * reference). We know the type name, but not yet anything else about it. */ bool typisdefined; char typdelim; /* delimiter for arrays of this type */ Oid typrelid; /* 0 if not a complex type */ /* * If typelem is not 0 then it identifies another row in pg_type. The * current type can then be subscripted like an array yielding values of * type typelem. A non-zero typelem does not guarantee this type to be a * "real" array type; some ordinary fixed-length types can also be * subscripted (e.g., name, point). Variable-length types can *not* be * turned into pseudo-arrays like that. Hence, the way to determine * whether a type is a "true" array type is if: * * typelem != 0 and typlen == -1. */ Oid typelem; /* * I/O conversion procedures for the datatype. */ regproc typinput; /* text format (required) */ regproc typoutput; regproc typreceive; /* binary format (optional) */ regproc typsend; /* * Custom ANALYZE procedure for the datatype (0 selects the default). */ regproc typanalyze; /* ---------------- * typalign is the alignment required when storing a value of this * type. It applies to storage on disk as well as most * representations of the value inside Postgres. When multiple values * are stored consecutively, such as in the representation of a * complete row on disk, padding is inserted before a datum of this * type so that it begins on the specified boundary. The alignment * reference is the beginning of the first datum in the sequence. * * 'c' = CHAR alignment, ie no alignment needed. * 's' = SHORT alignment (2 bytes on most machines). * 'i' = INT alignment (4 bytes on most machines). * 'd' = DOUBLE alignment (8 bytes on many machines, but by no means all). * * See include/utils/memutils.h for the macros that compute these * alignment requirements. * * NOTE: for types used in system tables, it is critical that the * size and alignment defined in pg_type agree with the way that the * compiler will lay out the field in a struct representing a table row. * ---------------- */ char typalign; /* ---------------- * typstorage tells if the type is prepared for toasting and what * the default strategy for attributes of this type should be. * * 'p' PLAIN type not prepared for toasting * 'e' EXTERNAL external storage possible, don't try to compress * 'x' EXTENDED try to compress and store external if required * 'm' MAIN like 'x' but try to keep in main tuple * ---------------- */ char typstorage; /* * This flag represents a "NOT NULL" constraint against this datatype. * * If true, the attnotnull column for a corresponding table column using * this datatype will always enforce the NOT NULL constraint. * * Used primarily for domain types. */ bool typnotnull; /* * Domains use typbasetype to show the base (or complex) type that the * domain is based on. Zero if the type is not a domain. */ Oid typbasetype; /* * Domains use typtypmod to record the typmod to be applied to their base * type (-1 if base type does not use a typmod). -1 if this type is not a * domain. */ int4 typtypmod; /* * typndims is the declared number of dimensions for an array domain type * (i.e., typbasetype is an array type; the domain's typelem will match * the base type's typelem). Otherwise zero. */ int4 typndims; /* * If typdefaultbin is not NULL, it is the nodeToString representation of * a default expression for the type. Currently this is only used for * domains. */ text typdefaultbin; /* VARIABLE LENGTH FIELD */ /* * typdefault is NULL if the type has no associated default value. If * typdefaultbin is not NULL, typdefault must contain a human-readable * version of the default expression represented by typdefaultbin. If * typdefaultbin is NULL and typdefault is not, then typdefault is the * external representation of the type's default value, which may be fed * to the type's input converter to produce a constant. */ text typdefault; /* VARIABLE LENGTH FIELD */} FormData_pg_type;/* ---------------- * Form_pg_type corresponds to a pointer to a row with * the format of pg_type relation. * ---------------- */typedef FormData_pg_type *Form_pg_type;/* ---------------- * compiler constants for pg_type * ---------------- */#define Natts_pg_type 23#define Anum_pg_type_typname 1#define Anum_pg_type_typnamespace 2#define Anum_pg_type_typowner 3#define Anum_pg_type_typlen 4#define Anum_pg_type_typbyval 5#define Anum_pg_type_typtype 6#define Anum_pg_type_typisdefined 7#define Anum_pg_type_typdelim 8#define Anum_pg_type_typrelid 9#define Anum_pg_type_typelem 10#define Anum_pg_type_typinput 11#define Anum_pg_type_typoutput 12#define Anum_pg_type_typreceive 13#define Anum_pg_type_typsend 14#define Anum_pg_type_typanalyze 15#define Anum_pg_type_typalign 16#define Anum_pg_type_typstorage 17#define Anum_pg_type_typnotnull 18#define Anum_pg_type_typbasetype 19#define Anum_pg_type_typtypmod 20#define Anum_pg_type_typndims 21#define Anum_pg_type_typdefaultbin 22#define Anum_pg_type_typdefault 23/* ---------------- * initial contents of pg_type * ---------------- *//* keep the following ordered by OID so that later changes can be made easier*//* Make sure the typlen, typbyval, and typalign values here match the initial values for attlen, attbyval, and attalign in both places in pg_attribute.h for every instance.*//* OIDS 1 - 99 */DATA(insert OID = 16 ( bool PGNSP PGUID 1 t b t \054 0 0 boolin boolout boolrecv boolsend - c p f 0 -1 0 _null_ _null_ ));DESCR("boolean, 'true'/'false'");#define BOOLOID 16DATA(insert OID = 17 ( bytea PGNSP PGUID -1 f b t \054 0 0 byteain byteaout bytearecv byteasend - i x f 0 -1 0 _null_ _null_ ));DESCR("variable-length string, binary values escaped");#define BYTEAOID 17DATA(insert OID = 18 ( char PGNSP PGUID 1 t b t \054 0 0 charin charout charrecv charsend - c p f 0 -1 0 _null_ _null_ ));DESCR("single character");#define CHAROID 18DATA(insert OID = 19 ( name PGNSP PGUID NAMEDATALEN f b t \054 0 18 namein nameout namerecv namesend - i p f 0 -1 0 _null_ _null_ ));DESCR("63-character type for storing system identifiers");#define NAMEOID 19DATA(insert OID = 20 ( int8 PGNSP PGUID 8 f b t \054 0 0 int8in int8out int8recv int8send - d p f 0 -1 0 _null_ _null_ ));DESCR("~18 digit integer, 8-byte storage");#define INT8OID 20DATA(insert OID = 21 ( int2 PGNSP PGUID 2 t b t \054 0 0 int2in int2out int2recv int2send - s p f 0 -1 0 _null_ _null_ ));DESCR("-32 thousand to 32 thousand, 2-byte storage");#define INT2OID 21DATA(insert OID = 22 ( int2vector PGNSP PGUID -1 f b t \054 0 21 int2vectorin int2vectorout int2vectorrecv int2vectorsend - i p f 0 -1 0 _null_ _null_ ));DESCR("array of int2, used in system tables");#define INT2VECTOROID 22DATA(insert OID = 23 ( int4 PGNSP PGUID 4 t b t \054 0 0 int4in int4out int4recv int4send - i p f 0 -1 0 _null_ _null_ ));DESCR("-2 billion to 2 billion integer, 4-byte storage");#define INT4OID 23DATA(insert OID = 24 ( regproc PGNSP PGUID 4 t b t \054 0 0 regprocin regprocout regprocrecv regprocsend - i p f 0 -1 0 _null_ _null_ ));DESCR("registered procedure");#define REGPROCOID 24DATA(insert OID = 25 ( text PGNSP PGUID -1 f b t \054 0 0 textin textout textrecv textsend - i x f 0 -1 0 _null_ _null_ ));DESCR("variable-length string, no limit specified");#define TEXTOID 25DATA(insert OID = 26 ( oid PGNSP PGUID 4 t b t \054 0 0 oidin oidout oidrecv oidsend - i p f 0 -1 0 _null_ _null_ ));DESCR("object identifier(oid), maximum 4 billion");#define OIDOID 26DATA(insert OID = 27 ( tid PGNSP PGUID 6 f b t \054 0 0 tidin tidout tidrecv tidsend - s p f 0 -1 0 _null_ _null_ ));DESCR("(Block, offset), physical location of tuple");#define TIDOID 27DATA(insert OID = 28 ( xid PGNSP PGUID 4 t b t \054 0 0 xidin xidout xidrecv xidsend - i p f 0 -1 0 _null_ _null_ ));DESCR("transaction id");#define XIDOID 28DATA(insert OID = 29 ( cid PGNSP PGUID 4 t b t \054 0 0 cidin cidout cidrecv cidsend - i p f 0 -1 0 _null_ _null_ ));DESCR("command identifier type, sequence in transaction id");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -