diff options
| author | Tom Lane | 2007-04-02 03:49:42 +0000 |
|---|---|---|
| committer | Tom Lane | 2007-04-02 03:49:42 +0000 |
| commit | 57690c6803525f879fe96920a05e979ece073e71 (patch) | |
| tree | 42e82eaa1e9c8247b39a2ad783bf190b5001acfe /src/include | |
| parent | a482a3e58b3e5830899560c555e57e4184b8e6be (diff) | |
Support enum data types. Along the way, use macros for the values of
pg_type.typtype whereever practical. Tom Dunstan, with some kibitzing
from Tom Lane.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/access/hash.h | 3 | ||||
| -rw-r--r-- | src/include/catalog/catversion.h | 4 | ||||
| -rw-r--r-- | src/include/catalog/indexing.h | 7 | ||||
| -rw-r--r-- | src/include/catalog/pg_aggregate.h | 4 | ||||
| -rw-r--r-- | src/include/catalog/pg_amop.h | 16 | ||||
| -rw-r--r-- | src/include/catalog/pg_amproc.h | 4 | ||||
| -rw-r--r-- | src/include/catalog/pg_cast.h | 8 | ||||
| -rw-r--r-- | src/include/catalog/pg_enum.h | 72 | ||||
| -rw-r--r-- | src/include/catalog/pg_opclass.h | 8 | ||||
| -rw-r--r-- | src/include/catalog/pg_operator.h | 10 | ||||
| -rw-r--r-- | src/include/catalog/pg_opfamily.h | 4 | ||||
| -rw-r--r-- | src/include/catalog/pg_proc.h | 42 | ||||
| -rw-r--r-- | src/include/catalog/pg_type.h | 33 | ||||
| -rw-r--r-- | src/include/commands/typecmds.h | 3 | ||||
| -rw-r--r-- | src/include/nodes/nodes.h | 3 | ||||
| -rw-r--r-- | src/include/nodes/parsenodes.h | 13 | ||||
| -rw-r--r-- | src/include/parser/parse_type.h | 3 | ||||
| -rw-r--r-- | src/include/utils/builtins.h | 23 | ||||
| -rw-r--r-- | src/include/utils/lsyscache.h | 3 | ||||
| -rw-r--r-- | src/include/utils/syscache.h | 38 |
20 files changed, 255 insertions, 46 deletions
diff --git a/src/include/access/hash.h b/src/include/access/hash.h index baed9fdb4b7..7ba8fbfc2f2 100644 --- a/src/include/access/hash.h +++ b/src/include/access/hash.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/hash.h,v 1.76 2007/01/30 01:33:36 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/hash.h,v 1.77 2007/04/02 03:49:40 tgl Exp $ * * NOTES * modeled after Margo Seltzer's hash implementation for unix. @@ -258,6 +258,7 @@ extern Datum hashint2(PG_FUNCTION_ARGS); extern Datum hashint4(PG_FUNCTION_ARGS); extern Datum hashint8(PG_FUNCTION_ARGS); extern Datum hashoid(PG_FUNCTION_ARGS); +extern Datum hashenum(PG_FUNCTION_ARGS); extern Datum hashfloat4(PG_FUNCTION_ARGS); extern Datum hashfloat8(PG_FUNCTION_ARGS); extern Datum hashoidvector(PG_FUNCTION_ARGS); diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index d31dce2a0cf..9525a198fee 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.398 2007/04/01 09:56:02 petere Exp $ + * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.399 2007/04/02 03:49:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200704011 +#define CATALOG_VERSION_NO 200704012 #endif diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h index baa650a8edb..71970d48f74 100644 --- a/src/include/catalog/indexing.h +++ b/src/include/catalog/indexing.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/indexing.h,v 1.98 2007/02/14 01:58:58 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/indexing.h,v 1.99 2007/04/02 03:49:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -146,6 +146,11 @@ DECLARE_UNIQUE_INDEX(pg_description_o_c_o_index, 2675, on pg_description using b DECLARE_UNIQUE_INDEX(pg_shdescription_o_c_index, 2397, on pg_shdescription using btree(objoid oid_ops, classoid oid_ops)); #define SharedDescriptionObjIndexId 2397 +DECLARE_UNIQUE_INDEX(pg_enum_oid_index, 3502, on pg_enum using btree(oid oid_ops)); +#define EnumOidIndexId 3502 +DECLARE_UNIQUE_INDEX(pg_enum_typid_label_index, 3503, on pg_enum using btree(enumtypid oid_ops, enumlabel name_ops)); +#define EnumTypIdLabelIndexId 3503 + /* This following index is not used for a cache and is not unique */ DECLARE_INDEX(pg_index_indrelid_index, 2678, on pg_index using btree(indrelid oid_ops)); #define IndexIndrelidIndexId 2678 diff --git a/src/include/catalog/pg_aggregate.h b/src/include/catalog/pg_aggregate.h index 9036b1d4a6c..0ee798b356e 100644 --- a/src/include/catalog/pg_aggregate.h +++ b/src/include/catalog/pg_aggregate.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_aggregate.h,v 1.61 2007/02/17 00:55:57 momjian Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_aggregate.h,v 1.62 2007/04/02 03:49:40 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -118,6 +118,7 @@ DATA(insert ( 2130 numeric_larger - 1756 1700 _null_ )); DATA(insert ( 2050 array_larger - 1073 2277 _null_ )); DATA(insert ( 2244 bpchar_larger - 1060 1042 _null_ )); DATA(insert ( 2797 tidlarger - 2800 27 _null_ )); +DATA(insert ( 3526 enum_larger - 3519 3500 _null_ )); /* min */ DATA(insert ( 2131 int8smaller - 412 20 _null_ )); @@ -139,6 +140,7 @@ DATA(insert ( 2146 numeric_smaller - 1754 1700 _null_ )); DATA(insert ( 2051 array_smaller - 1072 2277 _null_ )); DATA(insert ( 2245 bpchar_smaller - 1058 1042 _null_ )); DATA(insert ( 2798 tidsmaller - 2799 27 _null_ )); +DATA(insert ( 3527 enum_smaller - 3518 3500 _null_ )); /* count */ DATA(insert ( 2147 int8inc_any - 0 20 "0" )); diff --git a/src/include/catalog/pg_amop.h b/src/include/catalog/pg_amop.h index c1023df6ea9..2b852645998 100644 --- a/src/include/catalog/pg_amop.h +++ b/src/include/catalog/pg_amop.h @@ -29,7 +29,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_amop.h,v 1.79 2007/02/06 02:59:12 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_amop.h,v 1.80 2007/04/02 03:49:40 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -636,4 +636,18 @@ DATA(insert ( 2745 2277 2277 2 f 2751 2742 )); DATA(insert ( 2745 2277 2277 3 t 2752 2742 )); DATA(insert ( 2745 2277 2277 4 t 1070 2742 )); +/* + * btree enum_ops + */ +DATA(insert ( 3522 3500 3500 1 f 3518 403 )); +DATA(insert ( 3522 3500 3500 2 f 3520 403 )); +DATA(insert ( 3522 3500 3500 3 f 3516 403 )); +DATA(insert ( 3522 3500 3500 4 f 3521 403 )); +DATA(insert ( 3522 3500 3500 5 f 3519 403 )); + +/* + * hash enum_ops + */ +DATA(insert ( 3523 3500 3500 1 f 3516 405 )); + #endif /* PG_AMOP_H */ diff --git a/src/include/catalog/pg_amproc.h b/src/include/catalog/pg_amproc.h index 64db6483417..d535e615c81 100644 --- a/src/include/catalog/pg_amproc.h +++ b/src/include/catalog/pg_amproc.h @@ -22,7 +22,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_amproc.h,v 1.63 2007/01/28 16:16:52 neilc Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_amproc.h,v 1.64 2007/04/02 03:49:40 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -128,6 +128,7 @@ DATA(insert ( 2233 703 703 1 380 )); DATA(insert ( 2234 704 704 1 381 )); DATA(insert ( 2789 27 27 1 2794 )); DATA(insert ( 2968 2950 2950 1 2960 )); +DATA(insert ( 3522 3500 3500 1 3514 )); /* hash */ @@ -162,6 +163,7 @@ DATA(insert ( 2231 1042 1042 1 456 )); DATA(insert ( 2232 19 19 1 455 )); DATA(insert ( 2235 1033 1033 1 329 )); DATA(insert ( 2969 2950 2950 1 2963 )); +DATA(insert ( 3523 3500 3500 1 3515 )); /* gist */ diff --git a/src/include/catalog/pg_cast.h b/src/include/catalog/pg_cast.h index 0047f865af2..bc558b82e9e 100644 --- a/src/include/catalog/pg_cast.h +++ b/src/include/catalog/pg_cast.h @@ -10,7 +10,7 @@ * * Copyright (c) 2002-2007, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.31 2007/02/03 14:06:55 petere Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.32 2007/04/02 03:49:40 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -403,4 +403,10 @@ DATA(insert ( 2950 25 2965 a )); DATA(insert ( 1043 2950 2964 a )); DATA(insert ( 2950 1043 2965 a )); +/* + * enums + */ +DATA(insert ( 3500 25 3532 e )); +DATA(insert ( 25 3500 3533 e )); + #endif /* PG_CAST_H */ diff --git a/src/include/catalog/pg_enum.h b/src/include/catalog/pg_enum.h new file mode 100644 index 00000000000..1196e435a40 --- /dev/null +++ b/src/include/catalog/pg_enum.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------------------- + * + * pg_enum.h + * definition of the system "enum" relation (pg_enum) + * along with the relation's initial contents. + * + * + * Copyright (c) 2006-2007, PostgreSQL Global Development Group + * + * $PostgreSQL: pgsql/src/include/catalog/pg_enum.h,v 1.1 2007/04/02 03:49:40 tgl Exp $ + * + * NOTES + * the genbki.sh script reads this file and generates .bki + * information from the DATA() statements. + * + * XXX do NOT break up DATA() statements into multiple lines! + * the scripts are not as smart as you might think... + * + *------------------------------------------------------------------------- + */ +#ifndef PG_ENUM_H +#define PG_ENUM_H + +#include "nodes/pg_list.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_enum definition. cpp turns this into + * typedef struct FormData_pg_enum + * ---------------- + */ +#define EnumRelationId 3501 + +CATALOG(pg_enum,3501) +{ + Oid enumtypid; /* OID of owning enum type */ + NameData enumlabel; /* text representation of enum value */ +} FormData_pg_enum; + +/* ---------------- + * Form_pg_enum corresponds to a pointer to a tuple with + * the format of pg_enum relation. + * ---------------- + */ +typedef FormData_pg_enum *Form_pg_enum; + +/* ---------------- + * compiler constants for pg_enum + * ---------------- + */ +#define Natts_pg_enum 2 +#define Anum_pg_enum_enumtypid 1 +#define Anum_pg_enum_enumlabel 2 + +/* ---------------- + * pg_enum has no initial contents + * ---------------- + */ + +/* + * prototypes for functions in pg_enum.c + */ +extern void EnumValuesCreate(Oid enumTypeOid, List *vals); +extern void EnumValuesDelete(Oid enumTypeOid); + +#endif /* PG_ENUM_H */ diff --git a/src/include/catalog/pg_opclass.h b/src/include/catalog/pg_opclass.h index 148f02db2a9..2df9b8241a8 100644 --- a/src/include/catalog/pg_opclass.h +++ b/src/include/catalog/pg_opclass.h @@ -28,7 +28,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_opclass.h,v 1.74 2007/01/28 16:16:52 neilc Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_opclass.h,v 1.75 2007/04/02 03:49:40 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -200,7 +200,9 @@ DATA(insert ( 2742 _timestamp_ops PGNSP PGUID 2745 1115 t 1114 )); DATA(insert ( 2742 _money_ops PGNSP PGUID 2745 791 t 790 )); DATA(insert ( 2742 _reltime_ops PGNSP PGUID 2745 1024 t 703 )); DATA(insert ( 2742 _tinterval_ops PGNSP PGUID 2745 1025 t 704 )); -DATA(insert ( 403 uuid_ops PGNSP PGUID 2968 2950 t 0 )); -DATA(insert ( 405 uuid_ops PGNSP PGUID 2969 2950 t 0 )); +DATA(insert ( 403 uuid_ops PGNSP PGUID 2968 2950 t 0 )); +DATA(insert ( 405 uuid_ops PGNSP PGUID 2969 2950 t 0 )); +DATA(insert ( 403 enum_ops PGNSP PGUID 3522 3500 t 0 )); +DATA(insert ( 405 enum_ops PGNSP PGUID 3523 3500 t 0 )); #endif /* PG_OPCLASS_H */ diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h index e53f74b5193..2591b1ff7b1 100644 --- a/src/include/catalog/pg_operator.h +++ b/src/include/catalog/pg_operator.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_operator.h,v 1.150 2007/02/06 02:59:12 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_operator.h,v 1.151 2007/04/02 03:49:40 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -903,6 +903,14 @@ DATA(insert OID = 2975 ( ">" PGNSP PGUID b f f 2950 2950 16 2974 2976 uuid_g DATA(insert OID = 2976 ( "<=" PGNSP PGUID b f f 2950 2950 16 2977 2975 uuid_le scalarltsel scalarltjoinsel )); DATA(insert OID = 2977 ( ">=" PGNSP PGUID b f f 2950 2950 16 2976 2974 uuid_ge scalargtsel scalargtjoinsel )); +/* enum operators */ +DATA(insert OID = 3516 ( "=" PGNSP PGUID b t t 3500 3500 16 3516 3517 enum_eq eqsel eqjoinsel )); +DATA(insert OID = 3517 ( "<>" PGNSP PGUID b f f 3500 3500 16 3517 3516 enum_ne neqsel neqjoinsel )); +DATA(insert OID = 3518 ( "<" PGNSP PGUID b f f 3500 3500 16 3519 3521 enum_lt scalarltsel scalarltjoinsel )); +DATA(insert OID = 3519 ( ">" PGNSP PGUID b f f 3500 3500 16 3518 3520 enum_gt scalargtsel scalargtjoinsel )); +DATA(insert OID = 3520 ( "<=" PGNSP PGUID b f f 3500 3500 16 3521 3519 enum_le scalarltsel scalarltjoinsel )); +DATA(insert OID = 3521 ( ">=" PGNSP PGUID b f f 3500 3500 16 3520 3518 enum_ge scalargtsel scalargtjoinsel )); + /* * function prototypes diff --git a/src/include/catalog/pg_opfamily.h b/src/include/catalog/pg_opfamily.h index 63d1b277643..3d4c0a41d0a 100644 --- a/src/include/catalog/pg_opfamily.h +++ b/src/include/catalog/pg_opfamily.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_opfamily.h,v 1.3 2007/01/28 16:16:52 neilc Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_opfamily.h,v 1.4 2007/04/02 03:49:40 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -136,6 +136,8 @@ DATA(insert OID = 2595 ( 783 circle_ops PGNSP PGUID )); DATA(insert OID = 2745 ( 2742 array_ops PGNSP PGUID )); DATA(insert OID = 2968 ( 403 uuid_ops PGNSP PGUID )); DATA(insert OID = 2969 ( 405 uuid_ops PGNSP PGUID )); +DATA(insert OID = 3522 ( 403 enum_ops PGNSP PGUID )); +DATA(insert OID = 3523 ( 405 enum_ops PGNSP PGUID )); #endif /* PG_OPFAMILY_H */ diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 252d7460ac7..d7b048b07f7 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.453 2007/04/01 09:00:25 petere Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.454 2007/04/02 03:49:40 tgl Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -4149,6 +4149,46 @@ DESCR("convert text to uuid"); DATA(insert OID = 2965 ( text PGNSP PGUID 12 1 0 f f t f i 1 25 "2950" _null_ _null_ _null_ uuid_text - _null_ )); DESCR("convert uuid to text"); +/* enum related procs */ +DATA(insert OID = 3504 ( anyenum_in PGNSP PGUID 12 1 0 f f t f i 1 3500 "2275" _null_ _null_ _null_ anyenum_in - _null_ )); +DESCR("I/O"); +DATA(insert OID = 3505 ( anyenum_out PGNSP PGUID 12 1 0 f f t f s 1 2275 "3500" _null_ _null_ _null_ anyenum_out - _null_ )); +DESCR("I/O"); +DATA(insert OID = 3506 ( enum_in PGNSP PGUID 12 1 0 f f t f s 2 3500 "2275 26" _null_ _null_ _null_ enum_in - _null_ )); +DESCR("I/O"); +DATA(insert OID = 3507 ( enum_out PGNSP PGUID 12 1 0 f f t f s 1 2275 "3500" _null_ _null_ _null_ enum_out - _null_ )); +DESCR("I/O"); +DATA(insert OID = 3508 ( enum_eq PGNSP PGUID 12 1 0 f f t f i 2 16 "3500 3500" _null_ _null_ _null_ enum_eq - _null_ )); +DESCR("equal"); +DATA(insert OID = 3509 ( enum_ne PGNSP PGUID 12 1 0 f f t f i 2 16 "3500 3500" _null_ _null_ _null_ enum_ne - _null_ )); +DESCR("not equal"); +DATA(insert OID = 3510 ( enum_lt PGNSP PGUID 12 1 0 f f t f i 2 16 "3500 3500" _null_ _null_ _null_ enum_lt - _null_ )); +DESCR("less-than"); +DATA(insert OID = 3511 ( enum_gt PGNSP PGUID 12 1 0 f f t f i 2 16 "3500 3500" _null_ _null_ _null_ enum_gt - _null_ )); +DESCR("greater-than"); +DATA(insert OID = 3512 ( enum_le PGNSP PGUID 12 1 0 f f t f i 2 16 "3500 3500" _null_ _null_ _null_ enum_le - _null_ )); +DESCR("less-than-or-equal"); +DATA(insert OID = 3513 ( enum_ge PGNSP PGUID 12 1 0 f f t f i 2 16 "3500 3500" _null_ _null_ _null_ enum_ge - _null_ )); +DESCR("greater-than-or-equal"); +DATA(insert OID = 3514 ( enum_cmp PGNSP PGUID 12 1 0 f f t f i 2 23 "3500 3500" _null_ _null_ _null_ enum_cmp - _null_ )); +DESCR("btree-less-equal-greater"); +DATA(insert OID = 3515 ( hashenum PGNSP PGUID 12 1 0 f f t f i 1 23 "3500" _null_ _null_ _null_ hashenum - _null_ )); +DESCR("hash"); +DATA(insert OID = 3524 ( enum_smaller PGNSP PGUID 12 1 0 f f t f i 2 3500 "3500 3500" _null_ _null_ _null_ enum_smaller - _null_ )); +DESCR("smaller of two"); +DATA(insert OID = 3525 ( enum_larger PGNSP PGUID 12 1 0 f f t f i 2 3500 "3500 3500" _null_ _null_ _null_ enum_larger - _null_ )); +DESCR("larger of two"); +DATA(insert OID = 3526 ( max PGNSP PGUID 12 1 0 t f f f i 1 3500 "3500" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 3527 ( min PGNSP PGUID 12 1 0 t f f f i 1 3500 "3500" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 3528 ( enum_first PGNSP PGUID 12 1 0 f f f f s 1 3500 "3500" _null_ _null_ _null_ enum_first - _null_ )); +DATA(insert OID = 3529 ( enum_last PGNSP PGUID 12 1 0 f f f f s 1 3500 "3500" _null_ _null_ _null_ enum_last - _null_ )); +DATA(insert OID = 3530 ( enum_range PGNSP PGUID 12 1 0 f f f f s 2 2277 "3500 3500" _null_ _null_ _null_ enum_range_bounds - _null_ )); +DATA(insert OID = 3531 ( enum_range PGNSP PGUID 12 1 0 f f f f s 1 2277 "3500" _null_ _null_ _null_ enum_range_all - _null_ )); +DATA(insert OID = 3532 ( text PGNSP PGUID 12 1 0 f f t f s 1 25 "3500" _null_ _null_ _null_ enum_text - _null_ )); +DESCR("convert enum to text"); +DATA(insert OID = 3533 ( enum PGNSP PGUID 12 1 0 f f t f s 1 3500 "25" _null_ _null_ _null_ text_enum - _null_ )); +DESCR("convert text to enum"); + /* * Symbolic values for provolatile column: these indicate whether the result * of a function is dependent *only* on the values of its explicit arguments, diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index 89849c25fcb..69713196000 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.180 2007/01/28 16:16:54 neilc Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.181 2007/04/02 03:49:41 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -66,8 +66,9 @@ CATALOG(pg_type,1247) BKI_BOOTSTRAP 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. + * typtype is 'b' for a base type, 'c' for a composite type (e.g., + * a table's rowtype), 'd' for a domain type, 'e' for an enum type, + * or 'p' for a pseudo-type. (Use the TYPTYPE macros below.) * * If typtype is 'c', typrelid is the OID of the class' entry in pg_class. */ @@ -531,6 +532,11 @@ DATA(insert OID = 2210 ( _regclass PGNSP PGUID -1 f b t \054 0 2205 array_in DATA(insert OID = 2211 ( _regtype PGNSP PGUID -1 f b t \054 0 2206 array_in array_out array_recv array_send - - - i x f 0 -1 0 _null_ _null_ )); #define REGTYPEARRAYOID 2211 +/* uuid */ +DATA(insert OID = 2950 ( uuid PGNSP PGUID 16 f b t \054 0 0 uuid_in uuid_out uuid_recv uuid_send - - - c p f 0 -1 0 _null_ _null_ )); +DESCR("UUID datatype"); +DATA(insert OID = 2951 ( _uuid PGNSP PGUID -1 f b t \054 0 2950 array_in array_out array_recv array_send - - - i x f 0 -1 0 _null_ _null_ )); + /* * pseudo-types * @@ -560,11 +566,24 @@ DATA(insert OID = 2282 ( opaque PGNSP PGUID 4 t p t \054 0 0 opaque_in opaque #define OPAQUEOID 2282 DATA(insert OID = 2283 ( anyelement PGNSP PGUID 4 t p t \054 0 0 anyelement_in anyelement_out - - - - - i p f 0 -1 0 _null_ _null_ )); #define ANYELEMENTOID 2283 +DATA(insert OID = 3500 ( anyenum PGNSP PGUID 4 t p t \054 0 0 anyenum_in anyenum_out - - - - - i p f 0 -1 0 _null_ _null_ )); +#define ANYENUMOID 3500 -/* uuid */ -DATA(insert OID = 2950 ( uuid PGNSP PGUID 16 f b t \054 0 0 uuid_in uuid_out uuid_recv uuid_send - - - c p f 0 -1 0 _null_ _null_ )); -DESCR("UUID datatype"); -DATA(insert OID = 2951 ( _uuid PGNSP PGUID -1 f b t \054 0 2950 array_in array_out array_recv array_send - - - i x f 0 -1 0 _null_ _null_ )); + +/* + * macros + */ +#define TYPTYPE_BASE 'b' /* base type (ordinary scalar type) */ +#define TYPTYPE_COMPOSITE 'c' /* composite (e.g., table's rowtype) */ +#define TYPTYPE_DOMAIN 'd' /* domain over another type */ +#define TYPTYPE_ENUM 'e' /* enumerated type */ +#define TYPTYPE_PSEUDO 'p' /* pseudo-type */ + +/* Is a type OID a polymorphic pseudotype? (Beware of multiple evaluation) */ +#define IsPolymorphicType(typid) \ + ((typid) == ANYELEMENTOID || \ + (typid) == ANYARRAYOID || \ + (typid) == ANYENUMOID) /* * prototypes for functions in pg_type.c diff --git a/src/include/commands/typecmds.h b/src/include/commands/typecmds.h index 97196a062e2..91e56e12cb0 100644 --- a/src/include/commands/typecmds.h +++ b/src/include/commands/typecmds.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/typecmds.h,v 1.17 2007/01/05 22:19:54 momjian Exp $ + * $PostgreSQL: pgsql/src/include/commands/typecmds.h,v 1.18 2007/04/02 03:49:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -24,6 +24,7 @@ extern void RemoveType(List *names, DropBehavior behavior, bool missing_ok); extern void RemoveTypeById(Oid typeOid); extern void DefineDomain(CreateDomainStmt *stmt); extern void RemoveDomain(List *names, DropBehavior behavior, bool missing_ok); +extern void DefineEnum(CreateEnumStmt *stmt); extern Oid DefineCompositeType(const RangeVar *typevar, List *coldeflist); extern void AlterDomainDefault(List *names, Node *defaultRaw); diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index f344e3f5d10..305be462e10 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.197 2007/03/27 23:21:12 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.198 2007/04/02 03:49:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -307,6 +307,7 @@ typedef enum NodeTag T_DropOwnedStmt, T_ReassignOwnedStmt, T_CompositeTypeStmt, + T_CreateEnumStmt, /* * TAGS FOR PARSE TREE NODES (parsenodes.h) diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index c3a2bebca68..8552620be3c 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.343 2007/03/19 23:38:32 wieck Exp $ + * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.344 2007/04/02 03:49:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1706,6 +1706,17 @@ typedef struct CompositeTypeStmt List *coldeflist; /* list of ColumnDef nodes */ } CompositeTypeStmt; +/* ---------------------- + * Create Type Statement, enum types + * ---------------------- + */ +typedef struct CreateEnumStmt +{ + NodeTag type; + List *typename; /* qualified name (list of Value strings) */ + List *vals; /* enum values (list of Value strings) */ +} CreateEnumStmt; + /* ---------------------- * Create View Statement diff --git a/src/include/parser/parse_type.h b/src/include/parser/parse_type.h index 3fff9ba33d2..3d07b085793 100644 --- a/src/include/parser/parse_type.h +++ b/src/include/parser/parse_type.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/parser/parse_type.h,v 1.35 2007/01/05 22:19:57 momjian Exp $ + * $PostgreSQL: pgsql/src/include/parser/parse_type.h,v 1.36 2007/04/02 03:49:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -33,7 +33,6 @@ extern Type typeidType(Oid id); extern Oid typeTypeId(Type tp); extern int16 typeLen(Type t); extern bool typeByVal(Type t); -extern char typeTypType(Type t); extern char *typeTypeName(Type t); extern Oid typeTypeRelid(Type typ); extern Datum stringTypeDatum(Type tp, char *string, int32 atttypmod); diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index b2a55bbbb98..d93599a9ae5 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.290 2007/03/20 05:45:00 neilc Exp $ + * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.291 2007/04/02 03:49:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -103,6 +103,25 @@ extern Datum char_text(PG_FUNCTION_ARGS); extern Datum domain_in(PG_FUNCTION_ARGS); extern Datum domain_recv(PG_FUNCTION_ARGS); +/* enum.c */ +extern Datum enum_in(PG_FUNCTION_ARGS); +extern Datum enum_out(PG_FUNCTION_ARGS); +extern Datum enum_lt(PG_FUNCTION_ARGS); +extern Datum enum_le(PG_FUNCTION_ARGS); +extern Datum enum_eq(PG_FUNCTION_ARGS); +extern Datum enum_ne(PG_FUNCTION_ARGS); +extern Datum enum_ge(PG_FUNCTION_ARGS); +extern Datum enum_gt(PG_FUNCTION_ARGS); +extern Datum enum_cmp(PG_FUNCTION_ARGS); +extern Datum enum_text(PG_FUNCTION_ARGS); +extern Datum text_enum(PG_FUNCTION_ARGS); +extern Datum enum_smaller(PG_FUNCTION_ARGS); +extern Datum enum_larger(PG_FUNCTION_ARGS); +extern Datum enum_first(PG_FUNCTION_ARGS); +extern Datum enum_last(PG_FUNCTION_ARGS); +extern Datum enum_range_bounds(PG_FUNCTION_ARGS); +extern Datum enum_range_all(PG_FUNCTION_ARGS); + /* int.c */ extern Datum int2in(PG_FUNCTION_ARGS); extern Datum int2out(PG_FUNCTION_ARGS); @@ -450,6 +469,8 @@ extern Datum anyarray_in(PG_FUNCTION_ARGS); extern Datum anyarray_out(PG_FUNCTION_ARGS); extern Datum anyarray_recv(PG_FUNCTION_ARGS); extern Datum anyarray_send(PG_FUNCTION_ARGS); +extern Datum anyenum_in(PG_FUNCTION_ARGS); +extern Datum anyenum_out(PG_FUNCTION_ARGS); extern Datum void_in(PG_FUNCTION_ARGS); extern Datum void_out(PG_FUNCTION_ARGS); extern Datum trigger_in(PG_FUNCTION_ARGS); diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h index 78c45891fa4..25782e322e9 100644 --- a/src/include/utils/lsyscache.h +++ b/src/include/utils/lsyscache.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.117 2007/02/14 01:58:58 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.118 2007/04/02 03:49:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -105,6 +105,7 @@ extern char get_typstorage(Oid typid); extern Node *get_typdefault(Oid typid); extern char get_typtype(Oid typid); extern bool type_is_rowtype(Oid typid); +extern bool type_is_enum(Oid typid); extern Oid get_typ_typrelid(Oid typid); extern Oid get_element_type(Oid typid); extern Oid get_array_type(Oid typid); diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h index c6967251ce1..12cd9a72f22 100644 --- a/src/include/utils/syscache.h +++ b/src/include/utils/syscache.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/syscache.h,v 1.68 2007/02/14 01:58:58 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/syscache.h,v 1.69 2007/04/02 03:49:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -48,23 +48,25 @@ #define CONSTROID 17 #define CONVOID 18 #define DATABASEOID 19 -#define INDEXRELID 20 -#define LANGNAME 21 -#define LANGOID 22 -#define NAMESPACENAME 23 -#define NAMESPACEOID 24 -#define OPERNAMENSP 25 -#define OPEROID 26 -#define OPFAMILYAMNAMENSP 27 -#define OPFAMILYOID 28 -#define PROCNAMEARGSNSP 29 -#define PROCOID 30 -#define RELNAMENSP 31 -#define RELOID 32 -#define RULERELNAME 33 -#define STATRELATT 34 -#define TYPENAMENSP 35 -#define TYPEOID 36 +#define ENUMOID 20 +#define ENUMTYPOIDNAME 21 +#define INDEXRELID 22 +#define LANGNAME 23 +#define LANGOID 24 +#define NAMESPACENAME 25 +#define NAMESPACEOID 26 +#define OPERNAMENSP 27 +#define OPEROID 28 +#define OPFAMILYAMNAMENSP 29 +#define OPFAMILYOID 30 +#define PROCNAMEARGSNSP 31 +#define PROCOID 32 +#define RELNAMENSP 33 +#define RELOID 34 +#define RULERELNAME 35 +#define STATRELATT 36 +#define TYPENAMENSP 37 +#define TYPEOID 38 extern void InitCatalogCache(void); extern void InitCatalogCachePhase2(void); |
