2
0

prepare.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*-------------------------------------------------------------------------
  2. *
  3. * prepare.h
  4. * PREPARE, EXECUTE and DEALLOCATE commands, and prepared-stmt storage
  5. *
  6. *
  7. * Copyright (c) 2002-2022, PostgreSQL Global Development Group
  8. *
  9. * src/include/commands/prepare.h
  10. *
  11. *-------------------------------------------------------------------------
  12. */
  13. #ifndef PREPARE_H
  14. #define PREPARE_H
  15. #include "commands/explain.h"
  16. #include "datatype/timestamp.h"
  17. #include "utils/plancache.h"
  18. /*
  19. * The data structure representing a prepared statement. This is now just
  20. * a thin veneer over a plancache entry --- the main addition is that of
  21. * a name.
  22. *
  23. * Note: all subsidiary storage lives in the referenced plancache entry.
  24. */
  25. typedef struct
  26. {
  27. /* dynahash.c requires key to be first field */
  28. char stmt_name[NAMEDATALEN];
  29. CachedPlanSource *plansource; /* the actual cached plan */
  30. bool from_sql; /* prepared via SQL, not FE/BE protocol? */
  31. TimestampTz prepare_time; /* the time when the stmt was prepared */
  32. } PreparedStatement;
  33. /* Utility statements PREPARE, EXECUTE, DEALLOCATE, EXPLAIN EXECUTE */
  34. extern void PrepareQuery(ParseState *pstate, PrepareStmt *stmt,
  35. int stmt_location, int stmt_len);
  36. extern void ExecuteQuery(ParseState *pstate,
  37. ExecuteStmt *stmt, IntoClause *intoClause,
  38. ParamListInfo params,
  39. DestReceiver *dest, QueryCompletion *qc);
  40. extern void DeallocateQuery(DeallocateStmt *stmt);
  41. extern void ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into,
  42. ExplainState *es, const char *queryString,
  43. ParamListInfo params, QueryEnvironment *queryEnv);
  44. /* Low-level access to stored prepared statements */
  45. extern void StorePreparedStatement(const char *stmt_name,
  46. CachedPlanSource *plansource,
  47. bool from_sql);
  48. extern PreparedStatement *FetchPreparedStatement(const char *stmt_name,
  49. bool throwError);
  50. extern void DropPreparedStatement(const char *stmt_name, bool showError);
  51. extern TupleDesc FetchPreparedStatementResultDesc(PreparedStatement *stmt);
  52. extern List *FetchPreparedStatementTargetList(PreparedStatement *stmt);
  53. extern void DropAllPreparedStatements(void);
  54. #endif /* PREPARE_H */