codekingpro/portable-devtools
116k
1/*-------------------------------------------------------------------------2 *3 * windowapi.h4 * API for window functions to extract data from their window5 *6 * A window function does not receive its arguments in the normal way7 * (and therefore the concept of strictness is irrelevant). Instead it8 * receives a "WindowObject", which it can fetch with PG_WINDOW_OBJECT()9 * (note V1 calling convention must be used). Correct call context can10 * be tested with WindowObjectIsValid(). Although argument values are11 * not passed, the call is correctly set up so that PG_NARGS() can be12 * used and argument type information can be obtained with13 * get_fn_expr_argtype(), get_fn_expr_arg_stable(), etc.14 *15 * Operations on the WindowObject allow the window function to find out16 * the current row number, total number of rows in the partition, etc17 * and to evaluate its argument expression(s) at various rows in the18 * window partition. See the header comments for each WindowObject API19 * function in nodeWindowAgg.c for details.20 *21 *22 * Portions Copyright (c) 2000-2023, PostgreSQL Global Development Group23 *24 * src/include/windowapi.h25 *26 *-------------------------------------------------------------------------27 */28#ifndef WINDOWAPI_H29#define WINDOWAPI_H30 31/* values of "seektype" */32#define WINDOW_SEEK_CURRENT 033#define WINDOW_SEEK_HEAD 134#define WINDOW_SEEK_TAIL 235 36/* this struct is private in nodeWindowAgg.c */37typedef struct WindowObjectData *WindowObject;38 39#define PG_WINDOW_OBJECT() ((WindowObject) fcinfo->context)40 41#define WindowObjectIsValid(winobj) \42 ((winobj) != NULL && IsA(winobj, WindowObjectData))43 44extern void *WinGetPartitionLocalMemory(WindowObject winobj, Size sz);45 46extern int64 WinGetCurrentPosition(WindowObject winobj);47extern int64 WinGetPartitionRowCount(WindowObject winobj);48 49extern void WinSetMarkPosition(WindowObject winobj, int64 markpos);50 51extern bool WinRowsArePeers(WindowObject winobj, int64 pos1, int64 pos2);52 53extern Datum WinGetFuncArgInPartition(WindowObject winobj, int argno,54 int relpos, int seektype, bool set_mark,55 bool *isnull, bool *isout);56 57extern Datum WinGetFuncArgInFrame(WindowObject winobj, int argno,58 int relpos, int seektype, bool set_mark,59 bool *isnull, bool *isout);60 61extern Datum WinGetFuncArgCurrent(WindowObject winobj, int argno,62 bool *isnull);63 64#endif /* WINDOWAPI_H */65 