prepare.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*-------------------------------------------------------------------------
  2. *
  3. * prepare.h
  4. * PREPARE, EXECUTE and DEALLOCATE commands, and prepared-stmt storage
  5. *
  6. *
  7. * Copyright (c) 2002-2016, 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(PrepareStmt *stmt, const char *queryString);
  35. extern void ExecuteQuery(ExecuteStmt *stmt, IntoClause *intoClause,
  36. const char *queryString, ParamListInfo params,
  37. DestReceiver *dest, char *completionTag);
  38. extern void DeallocateQuery(DeallocateStmt *stmt);
  39. extern void ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into,
  40. ExplainState *es,
  41. const char *queryString, ParamListInfo params);
  42. /* Low-level access to stored prepared statements */
  43. extern void StorePreparedStatement(const char *stmt_name,
  44. CachedPlanSource *plansource,
  45. bool from_sql);
  46. extern PreparedStatement *FetchPreparedStatement(const char *stmt_name,
  47. bool throwError);
  48. extern void DropPreparedStatement(const char *stmt_name, bool showError);
  49. extern TupleDesc FetchPreparedStatementResultDesc(PreparedStatement *stmt);
  50. extern List *FetchPreparedStatementTargetList(PreparedStatement *stmt);
  51. extern void DropAllPreparedStatements(void);
  52. #endif /* PREPARE_H */