2
0

tablefunc.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*-------------------------------------------------------------------------
  2. *
  3. * tablefunc.h
  4. * interface for TableFunc executor node
  5. *
  6. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  7. * Portions Copyright (c) 1994, Regents of the University of California
  8. *
  9. * src/include/executor/tablefunc.h
  10. *
  11. *-------------------------------------------------------------------------
  12. */
  13. #ifndef _TABLEFUNC_H
  14. #define _TABLEFUNC_H
  15. /* Forward-declare this to avoid including execnodes.h here */
  16. struct TableFuncScanState;
  17. /*
  18. * TableFuncRoutine holds function pointers used for generating content of
  19. * table-producer functions, such as XMLTABLE.
  20. *
  21. * InitOpaque initializes table builder private objects. The output tuple
  22. * descriptor, input functions for the columns, and typioparams are passed
  23. * from executor state.
  24. *
  25. * SetDocument is called to define the input document. The table builder may
  26. * apply additional transformations not exposed outside the table builder
  27. * context.
  28. *
  29. * SetNamespace is called to pass namespace declarations from the table
  30. * expression. This function may be NULL if namespaces are not supported by
  31. * the table builder. Namespaces must be given before setting the row and
  32. * column filters. If the name is given as NULL, the entry shall be for the
  33. * default namespace.
  34. *
  35. * SetRowFilter is called do define the row-generating filter, which shall be
  36. * used to extract each row from the input document.
  37. *
  38. * SetColumnFilter is called once for each column, to define the column-
  39. * generating filter for the given column.
  40. *
  41. * FetchRow shall be called repeatedly until it returns that no more rows are
  42. * found in the document. On each invocation it shall set state in the table
  43. * builder context such that each subsequent GetValue call returns the values
  44. * for the indicated column for the row being processed.
  45. *
  46. * DestroyOpaque shall release all resources associated with a table builder
  47. * context. It may be called either because all rows have been consumed, or
  48. * because an error occurred while processing the table expression.
  49. */
  50. typedef struct TableFuncRoutine
  51. {
  52. void (*InitOpaque) (struct TableFuncScanState *state, int natts);
  53. void (*SetDocument) (struct TableFuncScanState *state, Datum value);
  54. void (*SetNamespace) (struct TableFuncScanState *state, const char *name,
  55. const char *uri);
  56. void (*SetRowFilter) (struct TableFuncScanState *state, const char *path);
  57. void (*SetColumnFilter) (struct TableFuncScanState *state,
  58. const char *path, int colnum);
  59. bool (*FetchRow) (struct TableFuncScanState *state);
  60. Datum (*GetValue) (struct TableFuncScanState *state, int colnum,
  61. Oid typid, int32 typmod, bool *isnull);
  62. void (*DestroyOpaque) (struct TableFuncScanState *state);
  63. } TableFuncRoutine;
  64. #endif /* _TABLEFUNC_H */