2
0

tuplestore.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*-------------------------------------------------------------------------
  2. *
  3. * tuplestore.h
  4. * Generalized routines for temporary tuple storage.
  5. *
  6. * This module handles temporary storage of tuples for purposes such
  7. * as Materialize nodes, hashjoin batch files, etc. It is essentially
  8. * a dumbed-down version of tuplesort.c; it does no sorting of tuples
  9. * but can only store and regurgitate a sequence of tuples. However,
  10. * because no sort is required, it is allowed to start reading the sequence
  11. * before it has all been written. This is particularly useful for cursors,
  12. * because it allows random access within the already-scanned portion of
  13. * a query without having to process the underlying scan to completion.
  14. * Also, it is possible to support multiple independent read pointers.
  15. *
  16. * A temporary file is used to handle the data if it exceeds the
  17. * space limit specified by the caller.
  18. *
  19. * Beginning in Postgres 8.2, what is stored is just MinimalTuples;
  20. * callers cannot expect valid system columns in regurgitated tuples.
  21. * Also, we have changed the API to return tuples in TupleTableSlots,
  22. * so that there is a check to prevent attempted access to system columns.
  23. *
  24. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  25. * Portions Copyright (c) 1994, Regents of the University of California
  26. *
  27. * src/include/utils/tuplestore.h
  28. *
  29. *-------------------------------------------------------------------------
  30. */
  31. #ifndef TUPLESTORE_H
  32. #define TUPLESTORE_H
  33. #include "executor/tuptable.h"
  34. /* Tuplestorestate is an opaque type whose details are not known outside
  35. * tuplestore.c.
  36. */
  37. typedef struct Tuplestorestate Tuplestorestate;
  38. /*
  39. * Currently we only need to store MinimalTuples, but it would be easy
  40. * to support the same behavior for IndexTuples and/or bare Datums.
  41. */
  42. extern Tuplestorestate *tuplestore_begin_heap(bool randomAccess,
  43. bool interXact,
  44. int maxKBytes);
  45. extern void tuplestore_set_eflags(Tuplestorestate *state, int eflags);
  46. extern void tuplestore_puttupleslot(Tuplestorestate *state,
  47. TupleTableSlot *slot);
  48. extern void tuplestore_puttuple(Tuplestorestate *state, HeapTuple tuple);
  49. extern void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc,
  50. Datum *values, bool *isnull);
  51. /* Backwards compatibility macro */
  52. #define tuplestore_donestoring(state) ((void) 0)
  53. extern int tuplestore_alloc_read_pointer(Tuplestorestate *state, int eflags);
  54. extern void tuplestore_select_read_pointer(Tuplestorestate *state, int ptr);
  55. extern void tuplestore_copy_read_pointer(Tuplestorestate *state,
  56. int srcptr, int destptr);
  57. extern void tuplestore_trim(Tuplestorestate *state);
  58. extern bool tuplestore_in_memory(Tuplestorestate *state);
  59. extern bool tuplestore_gettupleslot(Tuplestorestate *state, bool forward,
  60. bool copy, TupleTableSlot *slot);
  61. extern bool tuplestore_advance(Tuplestorestate *state, bool forward);
  62. extern bool tuplestore_skiptuples(Tuplestorestate *state,
  63. int64 ntuples, bool forward);
  64. extern int64 tuplestore_tuple_count(Tuplestorestate *state);
  65. extern bool tuplestore_ateof(Tuplestorestate *state);
  66. extern void tuplestore_rescan(Tuplestorestate *state);
  67. extern void tuplestore_clear(Tuplestorestate *state);
  68. extern void tuplestore_end(Tuplestorestate *state);
  69. #endif /* TUPLESTORE_H */