📄 pg_type.h
字号:
/*------------------------------------------------------------------------- * * pg_type.h * definition of the system "type" relation (pg_type) * along with the relation's initial contents. * * * Copyright (c) 1994, Regents of the University of California * * $Id: pg_type.h,v 1.63 1999/07/09 03:28:52 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 <utils/rel.h>/* ---------------- * postgres.h contains the system type definitions and the * CATALOG(), 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. * ---------------- */CATALOG(pg_type) BOOTSTRAP{ NameData typname; int4 typowner; int2 typlen; /* * 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 -1. */ int2 typprtlen; bool typbyval; /* * typbyval determines whether internal Postgres routines pass a value * of this type by value or by reference. Only char, short, and int- * equivalent items can be passed by value, so if the type is not 1, * 2, or 4 bytes long, Postgres does not have the option of passing by * value and so typbyval had better be FALSE. 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. */ char typtype; /* * typtype is 'b' for a basic type and 'c' for a catalog type (ie a * class). If typtype is 'c', typrelid is the OID of the class' entry * in pg_class. (Why do we need an entry in pg_type for classes, * anyway?) */ bool typisdefined; char typdelim; Oid typrelid; /* 0 if not a class type */ Oid typelem; /* * typelem is 0 if this is not an array type. If this is an array * type, typelem is the OID of the type of the elements of the array * (it identifies another row in Table pg_type). */ regproc typinput; regproc typoutput; regproc typreceive; regproc typsend; char typalign; /* ---------------- * 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. * ---------------- */ 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 16#define Anum_pg_type_typname 1#define Anum_pg_type_typowner 2#define Anum_pg_type_typlen 3#define Anum_pg_type_typprtlen 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_typalign 15#define Anum_pg_type_typdefault 16/* ---------------- * 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 PGUID 1 1 t b t \054 0 0 boolin boolout boolin boolout c _null_ ));DESCR("boolean 'true'/'false'");#define BOOLOID 16DATA(insert OID = 17 ( bytea PGUID -1 -1 f b t \054 0 18 byteain byteaout byteain byteaout i _null_ ));DESCR("variable length array of bytes");#define BYTEAOID 17DATA(insert OID = 18 ( char PGUID 1 1 t b t \054 0 0 charin charout charin charout c _null_ ));DESCR("single character");#define CHAROID 18DATA(insert OID = 19 ( name PGUID NAMEDATALEN NAMEDATALEN f b t \054 0 18 namein nameout namein nameout i _null_ ));DESCR("31-character type for storing system identifiers");#define NAMEOID 19DATA(insert OID = 20 ( int8 PGUID 8 20 f b t \054 0 0 int8in int8out int8in int8out d _null_ ));DESCR("eight-byte integer, >18 digits");#define INT8OID 20DATA(insert OID = 21 ( int2 PGUID 2 5 t b t \054 0 0 int2in int2out int2in int2out s _null_ ));DESCR("two-byte integer, -32k to 32k");#define INT2OID 21DATA(insert OID = 22 ( int28 PGUID 16 50 f b t \054 0 21 int28in int28out int28in int28out i _null_ ));DESCR("8 2-byte integers, used internally");/* * XXX -- the implementation of int28's in postgres is a hack, and will * go away someday. until that happens, there is a case (in the * catalog cache management code) where we need to step gingerly * over piles of int28's on the sidewalk. in order to do so, we * need the OID of the int28 row from pg_type. */#define INT28OID 22DATA(insert OID = 23 ( int4 PGUID 4 10 t b t \054 0 0 int4in int4out int4in int4out i _null_ ));DESCR("4-byte integer, -2B to 2B");#define INT4OID 23DATA(insert OID = 24 ( regproc PGUID 4 16 t b t \054 0 0 regprocin regprocout regprocin regprocout i _null_ ));DESCR("registered procedure");#define REGPROCOID 24DATA(insert OID = 25 ( text PGUID -1 -1 f b t \054 0 18 textin textout textin textout i _null_ ));DESCR("native variable-length string");#define TEXTOID 25DATA(insert OID = 26 ( oid PGUID 4 10 t b t \054 0 0 int4in int4out int4in int4out i _null_ ));DESCR("object identifier type");#define OIDOID 26DATA(insert OID = 27 ( tid PGUID 6 19 f b t \054 0 0 tidin tidout tidin tidout i _null_ ));DESCR("tuple identifier type, physical location of tuple");#define TIDOID 27
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -