Header And Logo

PostgreSQL
| The world's most advanced open source database.

windowapi.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * windowapi.h
00004  *    API for window functions to extract data from their window
00005  *
00006  * A window function does not receive its arguments in the normal way
00007  * (and therefore the concept of strictness is irrelevant).  Instead it
00008  * receives a "WindowObject", which it can fetch with PG_WINDOW_OBJECT()
00009  * (note V1 calling convention must be used).  Correct call context can
00010  * be tested with WindowObjectIsValid().  Although argument values are
00011  * not passed, the call is correctly set up so that PG_NARGS() can be
00012  * used and argument type information can be obtained with
00013  * get_fn_expr_argtype(), get_fn_expr_arg_stable(), etc.
00014  *
00015  * Operations on the WindowObject allow the window function to find out
00016  * the current row number, total number of rows in the partition, etc
00017  * and to evaluate its argument expression(s) at various rows in the
00018  * window partition.  See the header comments for each WindowObject API
00019  * function in nodeWindowAgg.c for details.
00020  *
00021  *
00022  * Portions Copyright (c) 2000-2013, PostgreSQL Global Development Group
00023  *
00024  * src/include/windowapi.h
00025  *
00026  *-------------------------------------------------------------------------
00027  */
00028 #ifndef WINDOWAPI_H
00029 #define WINDOWAPI_H
00030 
00031 /* values of "seektype" */
00032 #define WINDOW_SEEK_CURRENT 0
00033 #define WINDOW_SEEK_HEAD 1
00034 #define WINDOW_SEEK_TAIL 2
00035 
00036 /* this struct is private in nodeWindowAgg.c */
00037 typedef struct WindowObjectData *WindowObject;
00038 
00039 #define PG_WINDOW_OBJECT() ((WindowObject) fcinfo->context)
00040 
00041 #define WindowObjectIsValid(winobj) \
00042     ((winobj) != NULL && IsA(winobj, WindowObjectData))
00043 
00044 extern void *WinGetPartitionLocalMemory(WindowObject winobj, Size sz);
00045 
00046 extern int64 WinGetCurrentPosition(WindowObject winobj);
00047 extern int64 WinGetPartitionRowCount(WindowObject winobj);
00048 
00049 extern void WinSetMarkPosition(WindowObject winobj, int64 markpos);
00050 
00051 extern bool WinRowsArePeers(WindowObject winobj, int64 pos1, int64 pos2);
00052 
00053 extern Datum WinGetFuncArgInPartition(WindowObject winobj, int argno,
00054                          int relpos, int seektype, bool set_mark,
00055                          bool *isnull, bool *isout);
00056 
00057 extern Datum WinGetFuncArgInFrame(WindowObject winobj, int argno,
00058                      int relpos, int seektype, bool set_mark,
00059                      bool *isnull, bool *isout);
00060 
00061 extern Datum WinGetFuncArgCurrent(WindowObject winobj, int argno,
00062                      bool *isnull);
00063 
00064 #endif   /* WINDOWAPI_H */