diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/commands/typecmds.h | 2 | ||||
-rw-r--r-- | src/include/nodes/execnodes.h | 5 | ||||
-rw-r--r-- | src/include/utils/typcache.h | 37 |
3 files changed, 40 insertions, 4 deletions
diff --git a/src/include/commands/typecmds.h b/src/include/commands/typecmds.h index e18a71463e3..0a638002c3c 100644 --- a/src/include/commands/typecmds.h +++ b/src/include/commands/typecmds.h @@ -39,8 +39,6 @@ extern Oid AlterDomainDropConstraint(List *names, const char *constrName, extern void checkDomainOwner(HeapTuple tup); -extern List *GetDomainConstraints(Oid typeOid); - extern Oid RenameType(RenameStmt *stmt); extern Oid AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype); extern void AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId, diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 41288eda6e3..59b17f3c993 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -942,8 +942,9 @@ typedef struct CoerceToDomainState { ExprState xprstate; ExprState *arg; /* input expression */ - /* Cached list of constraints that need to be checked */ - List *constraints; /* list of DomainConstraintState nodes */ + /* Cached set of constraints that need to be checked */ + /* use struct pointer to avoid including typcache.h here */ + struct DomainConstraintRef *constraint_ref; } CoerceToDomainState; /* diff --git a/src/include/utils/typcache.h b/src/include/utils/typcache.h index b544180b460..1a9befb9d7a 100644 --- a/src/include/utils/typcache.h +++ b/src/include/utils/typcache.h @@ -20,6 +20,9 @@ #include "fmgr.h" +/* DomainConstraintCache is an opaque struct known only within typcache.c */ +typedef struct DomainConstraintCache DomainConstraintCache; + /* TypeCacheEnumData is an opaque struct known only within typcache.c */ struct TypeCacheEnumData; @@ -84,6 +87,12 @@ typedef struct TypeCacheEntry FmgrInfo rng_canonical_finfo; /* canonicalization function, if any */ FmgrInfo rng_subdiff_finfo; /* difference function, if any */ + /* + * Domain constraint data if it's a domain type. NULL if not domain, or + * if domain has no constraints, or if information hasn't been requested. + */ + DomainConstraintCache *domainData; + /* Private data, for internal use of typcache.c only */ int flags; /* flags about what we've computed */ @@ -92,6 +101,9 @@ typedef struct TypeCacheEntry * information hasn't been requested. */ struct TypeCacheEnumData *enumData; + + /* We also maintain a list of all known domain-type cache entries */ + struct TypeCacheEntry *nextDomain; } TypeCacheEntry; /* Bit flags to indicate which fields a given caller needs to have set */ @@ -107,9 +119,34 @@ typedef struct TypeCacheEntry #define TYPECACHE_BTREE_OPFAMILY 0x0200 #define TYPECACHE_HASH_OPFAMILY 0x0400 #define TYPECACHE_RANGE_INFO 0x0800 +#define TYPECACHE_DOMAIN_INFO 0x1000 + +/* + * Callers wishing to maintain a long-lived reference to a domain's constraint + * set must store it in one of these. Use InitDomainConstraintRef() and + * UpdateDomainConstraintRef() to manage it. Note: DomainConstraintState is + * considered an executable expression type, so it's defined in execnodes.h. + */ +typedef struct DomainConstraintRef +{ + List *constraints; /* list of DomainConstraintState nodes */ + + /* Management data --- treat these fields as private to typcache.c */ + TypeCacheEntry *tcache; /* owning typcache entry */ + DomainConstraintCache *dcc; /* current constraints, or NULL if none */ + MemoryContextCallback callback; /* used to release refcount when done */ +} DomainConstraintRef; + extern TypeCacheEntry *lookup_type_cache(Oid type_id, int flags); +extern void InitDomainConstraintRef(Oid type_id, DomainConstraintRef *ref, + MemoryContext refctx); + +extern void UpdateDomainConstraintRef(DomainConstraintRef *ref); + +extern bool DomainHasConstraints(Oid type_id); + extern TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod); extern TupleDesc lookup_rowtype_tupdesc_noerror(Oid type_id, int32 typmod, |