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