1/*-------------------------------------------------------------------------
4 * Query environment, to store context-specific values like ephemeral named
5 * relations. Initial use is for named tuplestores for delta information
6 * from "normal" relations.
8 * The initial implementation uses a list because the number of such relations
9 * in any one context is expected to be very small. If that becomes a
10 * performance problem, the implementation can be changed with no other impact
11 * on callers, since this is an opaque structure. This is the reason to
12 * require a create function.
14 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
15 * Portions Copyright (c) 1994, Regents of the University of California
19 * src/backend/utils/misc/queryenvironment.c
21 *-------------------------------------------------------------------------
30 * Private state of a query environment.
54 enr =
get_ENR(queryEnv, refname);
63 * Register a named relation for use in the given environment.
65 * If this is intended exclusively for planning purposes, the tstate field can
78 * Unregister an ephemeral relation by name. This will probably be a rarely
79 * used function, but seems like it should be provided "just in case".
92 * This returns an ENR if there is a name match in the given collection. It
93 * must quietly return NULL if no match is found.
102 if (queryEnv == NULL)
117 * Gets the TupleDesc for a Ephemeral Named Relation, based on which field was
120 * When the TupleDesc is based on a relation from the catalogs, we count on
121 * that relation being used at the same time, so that appropriate locks will
122 * already be held. Locking here would be too late anyway.
129 /* One, and only one, of these fields must be filled. */
139 tupdesc = relation->
rd_att;
Assert(PointerIsAligned(start, uint64))
List * lappend(List *list, void *datum)
List * list_delete(List *list, void *datum)
void * palloc0(Size size)
TupleDesc ENRMetadataGetTupDesc(EphemeralNamedRelationMetadata enrmd)
EphemeralNamedRelation get_ENR(QueryEnvironment *queryEnv, const char *name)
EphemeralNamedRelationMetadata get_visible_ENR_metadata(QueryEnvironment *queryEnv, const char *refname)
void unregister_ENR(QueryEnvironment *queryEnv, const char *name)
QueryEnvironment * create_queryEnv(void)
void register_ENR(QueryEnvironment *queryEnv, EphemeralNamedRelation enr)
EphemeralNamedRelationData * EphemeralNamedRelation
EphemeralNamedRelationMetadataData md
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)