mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
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.
This commit is contained in:
18
src/backend/utils/cache/lsyscache.c
vendored
18
src/backend/utils/cache/lsyscache.c
vendored
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.150 2007/03/19 16:30:31 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.151 2007/04/02 03:49:39 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Eventually, the index information should go through here, too.
|
||||
@ -1770,7 +1770,7 @@ getTypeIOParam(HeapTuple typeTuple)
|
||||
* own type OID as parameter. (As of 8.2, domains must get their own OID
|
||||
* even if their base type is an array.)
|
||||
*/
|
||||
if (typeStruct->typtype == 'b' && OidIsValid(typeStruct->typelem))
|
||||
if (typeStruct->typtype == TYPTYPE_BASE && OidIsValid(typeStruct->typelem))
|
||||
return typeStruct->typelem;
|
||||
else
|
||||
return HeapTupleGetOid(typeTuple);
|
||||
@ -2022,7 +2022,7 @@ getBaseTypeAndTypmod(Oid typid, int32 *typmod)
|
||||
if (!HeapTupleIsValid(tup))
|
||||
elog(ERROR, "cache lookup failed for type %u", typid);
|
||||
typTup = (Form_pg_type) GETSTRUCT(tup);
|
||||
if (typTup->typtype != 'd')
|
||||
if (typTup->typtype != TYPTYPE_DOMAIN)
|
||||
{
|
||||
/* Not a domain, so done */
|
||||
ReleaseSysCache(tup);
|
||||
@ -2128,7 +2128,17 @@ get_typtype(Oid typid)
|
||||
bool
|
||||
type_is_rowtype(Oid typid)
|
||||
{
|
||||
return (typid == RECORDOID || get_typtype(typid) == 'c');
|
||||
return (typid == RECORDOID || get_typtype(typid) == TYPTYPE_COMPOSITE);
|
||||
}
|
||||
|
||||
/*
|
||||
* type_is_enum
|
||||
* Returns true if the given type is an enum type.
|
||||
*/
|
||||
bool
|
||||
type_is_enum(Oid typid)
|
||||
{
|
||||
return (get_typtype(typid) == TYPTYPE_ENUM);
|
||||
}
|
||||
|
||||
/*
|
||||
|
27
src/backend/utils/cache/syscache.c
vendored
27
src/backend/utils/cache/syscache.c
vendored
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.111 2007/02/14 01:58:57 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.112 2007/04/02 03:49:39 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* These routines allow the parser/planner/executor to perform
|
||||
@ -31,6 +31,7 @@
|
||||
#include "catalog/pg_constraint.h"
|
||||
#include "catalog/pg_conversion.h"
|
||||
#include "catalog/pg_database.h"
|
||||
#include "catalog/pg_enum.h"
|
||||
#include "catalog/pg_language.h"
|
||||
#include "catalog/pg_namespace.h"
|
||||
#include "catalog/pg_opclass.h"
|
||||
@ -335,6 +336,30 @@ static const struct cachedesc cacheinfo[] = {
|
||||
},
|
||||
4
|
||||
},
|
||||
{EnumRelationId, /* ENUMOID */
|
||||
EnumOidIndexId,
|
||||
0,
|
||||
1,
|
||||
{
|
||||
ObjectIdAttributeNumber,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
},
|
||||
256
|
||||
},
|
||||
{EnumRelationId, /* ENUMTYPOIDNAME */
|
||||
EnumTypIdLabelIndexId,
|
||||
0,
|
||||
2,
|
||||
{
|
||||
Anum_pg_enum_enumtypid,
|
||||
Anum_pg_enum_enumlabel,
|
||||
0,
|
||||
0
|
||||
},
|
||||
256
|
||||
},
|
||||
{IndexRelationId, /* INDEXRELID */
|
||||
IndexRelidIndexId,
|
||||
Anum_pg_index_indrelid,
|
||||
|
4
src/backend/utils/cache/typcache.c
vendored
4
src/backend/utils/cache/typcache.c
vendored
@ -36,7 +36,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.24 2007/01/05 22:19:43 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.25 2007/04/02 03:49:39 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -275,7 +275,7 @@ lookup_type_cache(Oid type_id, int flags)
|
||||
*/
|
||||
if ((flags & TYPECACHE_TUPDESC) &&
|
||||
typentry->tupDesc == NULL &&
|
||||
typentry->typtype == 'c')
|
||||
typentry->typtype == TYPTYPE_COMPOSITE)
|
||||
{
|
||||
Relation rel;
|
||||
|
||||
|
Reference in New Issue
Block a user