Ignore not-yet-defined Portals in pg_cursors view.
[pgsql.git] / src / include / windowapi.h
blob5c39b4f1cbab3d0422770f8de35ea0ba0e243a80
1 /*-------------------------------------------------------------------------
3 * windowapi.h
4 * API for window functions to extract data from their window
6 * A window function does not receive its arguments in the normal way
7 * (and therefore the concept of strictness is irrelevant). Instead it
8 * receives a "WindowObject", which it can fetch with PG_WINDOW_OBJECT()
9 * (note V1 calling convention must be used). Correct call context can
10 * be tested with WindowObjectIsValid(). Although argument values are
11 * not passed, the call is correctly set up so that PG_NARGS() can be
12 * used and argument type information can be obtained with
13 * get_fn_expr_argtype(), get_fn_expr_arg_stable(), etc.
15 * Operations on the WindowObject allow the window function to find out
16 * the current row number, total number of rows in the partition, etc
17 * and to evaluate its argument expression(s) at various rows in the
18 * window partition. See the header comments for each WindowObject API
19 * function in nodeWindowAgg.c for details.
22 * Portions Copyright (c) 2000-2024, PostgreSQL Global Development Group
24 * src/include/windowapi.h
26 *-------------------------------------------------------------------------
28 #ifndef WINDOWAPI_H
29 #define WINDOWAPI_H
31 /* values of "seektype" */
32 #define WINDOW_SEEK_CURRENT 0
33 #define WINDOW_SEEK_HEAD 1
34 #define WINDOW_SEEK_TAIL 2
36 /* this struct is private in nodeWindowAgg.c */
37 typedef struct WindowObjectData *WindowObject;
39 #define PG_WINDOW_OBJECT() ((WindowObject) fcinfo->context)
41 #define WindowObjectIsValid(winobj) \
42 ((winobj) != NULL && IsA(winobj, WindowObjectData))
44 extern void *WinGetPartitionLocalMemory(WindowObject winobj, Size sz);
46 extern int64 WinGetCurrentPosition(WindowObject winobj);
47 extern int64 WinGetPartitionRowCount(WindowObject winobj);
49 extern void WinSetMarkPosition(WindowObject winobj, int64 markpos);
51 extern bool WinRowsArePeers(WindowObject winobj, int64 pos1, int64 pos2);
53 extern Datum WinGetFuncArgInPartition(WindowObject winobj, int argno,
54 int relpos, int seektype, bool set_mark,
55 bool *isnull, bool *isout);
57 extern Datum WinGetFuncArgInFrame(WindowObject winobj, int argno,
58 int relpos, int seektype, bool set_mark,
59 bool *isnull, bool *isout);
61 extern Datum WinGetFuncArgCurrent(WindowObject winobj, int argno,
62 bool *isnull);
64 #endif /* WINDOWAPI_H */