2
0

queryenvironment.h 2.7 KB

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