PostgreSQL Source Code git master
Loading...
Searching...
No Matches
windowapi.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * windowapi.h
4 * API for window functions to extract data from their window
5 *
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.
14 *
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.
20 *
21 *
22 * Portions Copyright (c) 2000-2026, PostgreSQL Global Development Group
23 *
24 * src/include/windowapi.h
25 *
26 *-------------------------------------------------------------------------
27 */
28#ifndef WINDOWAPI_H
29#define WINDOWAPI_H
30
31#include "fmgr.h"
32
33/* values of "seektype" */
34#define WINDOW_SEEK_CURRENT 0
35#define WINDOW_SEEK_HEAD 1
36#define WINDOW_SEEK_TAIL 2
37
38/* this struct is private in nodeWindowAgg.c */
40
41#define PG_WINDOW_OBJECT() ((WindowObject) fcinfo->context)
42
43#define WindowObjectIsValid(winobj) \
44 ((winobj) != NULL && IsA(winobj, WindowObjectData))
45
48 FunctionCallInfo fcinfo);
49
51
54
55extern void WinSetMarkPosition(WindowObject winobj, int64 markpos);
56
57extern bool WinRowsArePeers(WindowObject winobj, int64 pos1, int64 pos2);
58
60 int relpos, int seektype, bool set_mark,
61 bool *isnull, bool *isout);
62
64 int relpos, int seektype, bool set_mark,
65 bool *isnull, bool *isout);
66
68 bool *isnull);
69
70#endif /* WINDOWAPI_H */
int64_t int64
Definition c.h:543
size_t Size
Definition c.h:619
uint64_t Datum
Definition postgres.h:70
static int fb(int x)
Datum WinGetFuncArgInPartition(WindowObject winobj, int argno, int relpos, int seektype, bool set_mark, bool *isnull, bool *isout)
void * WinGetPartitionLocalMemory(WindowObject winobj, Size sz)
Datum WinGetFuncArgInFrame(WindowObject winobj, int argno, int relpos, int seektype, bool set_mark, bool *isnull, bool *isout)
int64 WinGetCurrentPosition(WindowObject winobj)
bool WinRowsArePeers(WindowObject winobj, int64 pos1, int64 pos2)
void WinSetMarkPosition(WindowObject winobj, int64 markpos)
void WinCheckAndInitializeNullTreatment(WindowObject winobj, bool allowNullTreatment, FunctionCallInfo fcinfo)
Datum WinGetFuncArgCurrent(WindowObject winobj, int argno, bool *isnull)
int64 WinGetPartitionRowCount(WindowObject winobj)
struct WindowObjectData * WindowObject
Definition windowapi.h:39