Update copyright for 2022
[pgsql.git] / src / include / utils / queryenvironment.h
blob23a16a91d8b65bec3b6aa451807ffe0a4019352c
1 /*-------------------------------------------------------------------------
3 * queryenvironment.h
4 * Access to functions to mutate the query environment and retrieve the
5 * actual data related to entries (if any).
7 * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/include/utils/queryenvironment.h
12 *-------------------------------------------------------------------------
14 #ifndef QUERYENVIRONMENT_H
15 #define QUERYENVIRONMENT_H
17 #include "access/tupdesc.h"
20 typedef enum EphemeralNameRelationType
22 ENR_NAMED_TUPLESTORE /* named tuplestore relation; e.g., deltas */
23 } EphemeralNameRelationType;
26 * Some ephemeral named relations must match some relation (e.g., trigger
27 * transition tables), so to properly handle cached plans and DDL, we should
28 * carry the OID of that relation. In other cases an ENR might be independent
29 * of any relation which is stored in the system catalogs, so we need to be
30 * able to directly store the TupleDesc. We never need both.
32 typedef struct EphemeralNamedRelationMetadataData
34 char *name; /* name used to identify the relation */
36 /* only one of the next two fields should be used */
37 Oid reliddesc; /* oid of relation to get tupdesc */
38 TupleDesc tupdesc; /* description of result rows */
40 EphemeralNameRelationType enrtype; /* to identify type of relation */
41 double enrtuples; /* estimated number of tuples */
42 } EphemeralNamedRelationMetadataData;
44 typedef EphemeralNamedRelationMetadataData *EphemeralNamedRelationMetadata;
47 * Ephemeral Named Relation data; used for parsing named relations not in the
48 * catalog, like transition tables in AFTER triggers.
50 typedef struct EphemeralNamedRelationData
52 EphemeralNamedRelationMetadataData md;
53 void *reldata; /* structure for execution-time access to data */
54 } EphemeralNamedRelationData;
56 typedef EphemeralNamedRelationData *EphemeralNamedRelation;
59 * This is an opaque structure outside of queryenvironment.c itself. The
60 * intention is to be able to change the implementation or add new context
61 * features without needing to change existing code for use of existing
62 * features.
64 typedef struct QueryEnvironment QueryEnvironment;
67 extern QueryEnvironment *create_queryEnv(void);
68 extern EphemeralNamedRelationMetadata get_visible_ENR_metadata(QueryEnvironment *queryEnv, const char *refname);
69 extern void register_ENR(QueryEnvironment *queryEnv, EphemeralNamedRelation enr);
70 extern void unregister_ENR(QueryEnvironment *queryEnv, const char *name);
71 extern EphemeralNamedRelation get_ENR(QueryEnvironment *queryEnv, const char *name);
72 extern TupleDesc ENRMetadataGetTupDesc(EphemeralNamedRelationMetadata enrmd);
74 #endif /* QUERYENVIRONMENT_H */