PostgreSQL Source Code  git master
windowapi.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WINDOW_SEEK_CURRENT   0
 
#define WINDOW_SEEK_HEAD   1
 
#define WINDOW_SEEK_TAIL   2
 
#define PG_WINDOW_OBJECT()   ((WindowObject) fcinfo->context)
 
#define WindowObjectIsValid(winobj)   ((winobj) != NULL && IsA(winobj, WindowObjectData))
 

Typedefs

typedef struct WindowObjectDataWindowObject
 

Functions

void * WinGetPartitionLocalMemory (WindowObject winobj, Size sz)
 
int64 WinGetCurrentPosition (WindowObject winobj)
 
int64 WinGetPartitionRowCount (WindowObject winobj)
 
void WinSetMarkPosition (WindowObject winobj, int64 markpos)
 
bool WinRowsArePeers (WindowObject winobj, int64 pos1, int64 pos2)
 
Datum WinGetFuncArgInPartition (WindowObject winobj, int argno, int relpos, int seektype, bool set_mark, bool *isnull, bool *isout)
 
Datum WinGetFuncArgInFrame (WindowObject winobj, int argno, int relpos, int seektype, bool set_mark, bool *isnull, bool *isout)
 
Datum WinGetFuncArgCurrent (WindowObject winobj, int argno, bool *isnull)
 

Macro Definition Documentation

◆ PG_WINDOW_OBJECT

◆ WINDOW_SEEK_CURRENT

#define WINDOW_SEEK_CURRENT   0

Definition at line 32 of file windowapi.h.

Referenced by leadlag_common(), WinGetFuncArgInFrame(), and WinGetFuncArgInPartition().

◆ WINDOW_SEEK_HEAD

#define WINDOW_SEEK_HEAD   1

◆ WINDOW_SEEK_TAIL

#define WINDOW_SEEK_TAIL   2

Definition at line 34 of file windowapi.h.

Referenced by window_last_value(), WinGetFuncArgInFrame(), and WinGetFuncArgInPartition().

◆ WindowObjectIsValid

#define WindowObjectIsValid (   winobj)    ((winobj) != NULL && IsA(winobj, WindowObjectData))

Typedef Documentation

◆ WindowObject

Definition at line 37 of file windowapi.h.

Function Documentation

◆ WinGetCurrentPosition()

int64 WinGetCurrentPosition ( WindowObject  winobj)

Definition at line 3013 of file nodeWindowAgg.c.

References Assert, WindowAggState::currentpos, WindowObjectIsValid, and WindowObjectData::winstate.

Referenced by rank_up(), window_cume_dist(), window_percent_rank(), window_rank(), and window_row_number().

3014 {
3015  Assert(WindowObjectIsValid(winobj));
3016  return winobj->winstate->currentpos;
3017 }
WindowAggState * winstate
Definition: nodeWindowAgg.c:63
#define WindowObjectIsValid(winobj)
Definition: windowapi.h:41
#define Assert(condition)
Definition: c.h:699
int64 currentpos
Definition: execnodes.h:1970

◆ WinGetFuncArgCurrent()

Datum WinGetFuncArgCurrent ( WindowObject  winobj,
int  argno,
bool isnull 
)

Definition at line 3421 of file nodeWindowAgg.c.

References WindowObjectData::argstates, Assert, ExprContext::ecxt_outertuple, ExecEvalExpr(), list_nth(), ScanState::ps, PlanState::ps_ExprContext, WindowAggState::ss, ScanState::ss_ScanTupleSlot, WindowObjectIsValid, and WindowObjectData::winstate.

Referenced by leadlag_common(), window_nth_value(), and window_ntile().

3422 {
3423  WindowAggState *winstate;
3424  ExprContext *econtext;
3425 
3426  Assert(WindowObjectIsValid(winobj));
3427  winstate = winobj->winstate;
3428 
3429  econtext = winstate->ss.ps.ps_ExprContext;
3430 
3431  econtext->ecxt_outertuple = winstate->ss.ss_ScanTupleSlot;
3432  return ExecEvalExpr((ExprState *) list_nth(winobj->argstates, argno),
3433  econtext, isnull);
3434 }
ScanState ss
Definition: execnodes.h:1953
ExprContext * ps_ExprContext
Definition: execnodes.h:947
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1195
PlanState ps
Definition: execnodes.h:1192
void * list_nth(const List *list, int n)
Definition: list.c:410
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
Definition: executor.h:281
WindowAggState * winstate
Definition: nodeWindowAgg.c:63
#define WindowObjectIsValid(winobj)
Definition: windowapi.h:41
TupleTableSlot * ecxt_outertuple
Definition: execnodes.h:222
#define Assert(condition)
Definition: c.h:699

◆ WinGetFuncArgInFrame()

Datum WinGetFuncArgInFrame ( WindowObject  winobj,
int  argno,
int  relpos,
int  seektype,
bool  set_mark,
bool isnull,
bool isout 
)

Definition at line 3226 of file nodeWindowAgg.c.

References WindowObjectData::argstates, Assert, WindowAggState::currentpos, ExprContext::ecxt_outertuple, elog, ERROR, ExecEvalExpr(), WindowAggState::frameheadpos, FRAMEOPTION_EXCLUDE_CURRENT_ROW, FRAMEOPTION_EXCLUDE_GROUP, FRAMEOPTION_EXCLUDE_TIES, FRAMEOPTION_EXCLUSION, WindowAggState::frameOptions, WindowAggState::frametailpos, WindowAggState::groupheadpos, WindowAggState::grouptailpos, list_nth(), Max, Min, ScanState::ps, PlanState::ps_ExprContext, row_is_in_frame(), WindowAggState::ss, WindowAggState::temp_slot_1, update_frameheadpos(), update_frametailpos(), update_grouptailpos(), window_gettupleslot(), WINDOW_SEEK_CURRENT, WINDOW_SEEK_HEAD, WINDOW_SEEK_TAIL, WindowObjectIsValid, WinSetMarkPosition(), and WindowObjectData::winstate.

Referenced by window_first_value(), window_last_value(), and window_nth_value().

3229 {
3230  WindowAggState *winstate;
3231  ExprContext *econtext;
3232  TupleTableSlot *slot;
3233  int64 abs_pos;
3234  int64 mark_pos;
3235 
3236  Assert(WindowObjectIsValid(winobj));
3237  winstate = winobj->winstate;
3238  econtext = winstate->ss.ps.ps_ExprContext;
3239  slot = winstate->temp_slot_1;
3240 
3241  switch (seektype)
3242  {
3243  case WINDOW_SEEK_CURRENT:
3244  elog(ERROR, "WINDOW_SEEK_CURRENT is not supported for WinGetFuncArgInFrame");
3245  abs_pos = mark_pos = 0; /* keep compiler quiet */
3246  break;
3247  case WINDOW_SEEK_HEAD:
3248  /* rejecting relpos < 0 is easy and simplifies code below */
3249  if (relpos < 0)
3250  goto out_of_frame;
3251  update_frameheadpos(winstate);
3252  abs_pos = winstate->frameheadpos + relpos;
3253  mark_pos = abs_pos;
3254 
3255  /*
3256  * Account for exclusion option if one is active, but advance only
3257  * abs_pos not mark_pos. This prevents changes of the current
3258  * row's peer group from resulting in trying to fetch a row before
3259  * some previous mark position.
3260  *
3261  * Note that in some corner cases such as current row being
3262  * outside frame, these calculations are theoretically too simple,
3263  * but it doesn't matter because we'll end up deciding the row is
3264  * out of frame. We do not attempt to avoid fetching rows past
3265  * end of frame; that would happen in some cases anyway.
3266  */
3267  switch (winstate->frameOptions & FRAMEOPTION_EXCLUSION)
3268  {
3269  case 0:
3270  /* no adjustment needed */
3271  break;
3273  if (abs_pos >= winstate->currentpos &&
3274  winstate->currentpos >= winstate->frameheadpos)
3275  abs_pos++;
3276  break;
3278  update_grouptailpos(winstate);
3279  if (abs_pos >= winstate->groupheadpos &&
3280  winstate->grouptailpos > winstate->frameheadpos)
3281  {
3282  int64 overlapstart = Max(winstate->groupheadpos,
3283  winstate->frameheadpos);
3284 
3285  abs_pos += winstate->grouptailpos - overlapstart;
3286  }
3287  break;
3289  update_grouptailpos(winstate);
3290  if (abs_pos >= winstate->groupheadpos &&
3291  winstate->grouptailpos > winstate->frameheadpos)
3292  {
3293  int64 overlapstart = Max(winstate->groupheadpos,
3294  winstate->frameheadpos);
3295 
3296  if (abs_pos == overlapstart)
3297  abs_pos = winstate->currentpos;
3298  else
3299  abs_pos += winstate->grouptailpos - overlapstart - 1;
3300  }
3301  break;
3302  default:
3303  elog(ERROR, "unrecognized frame option state: 0x%x",
3304  winstate->frameOptions);
3305  break;
3306  }
3307  break;
3308  case WINDOW_SEEK_TAIL:
3309  /* rejecting relpos > 0 is easy and simplifies code below */
3310  if (relpos > 0)
3311  goto out_of_frame;
3312  update_frametailpos(winstate);
3313  abs_pos = winstate->frametailpos - 1 + relpos;
3314 
3315  /*
3316  * Account for exclusion option if one is active. If there is no
3317  * exclusion, we can safely set the mark at the accessed row. But
3318  * if there is, we can only mark the frame start, because we can't
3319  * be sure how far back in the frame the exclusion might cause us
3320  * to fetch in future. Furthermore, we have to actually check
3321  * against frameheadpos here, since it's unsafe to try to fetch a
3322  * row before frame start if the mark might be there already.
3323  */
3324  switch (winstate->frameOptions & FRAMEOPTION_EXCLUSION)
3325  {
3326  case 0:
3327  /* no adjustment needed */
3328  mark_pos = abs_pos;
3329  break;
3331  if (abs_pos <= winstate->currentpos &&
3332  winstate->currentpos < winstate->frametailpos)
3333  abs_pos--;
3334  update_frameheadpos(winstate);
3335  if (abs_pos < winstate->frameheadpos)
3336  goto out_of_frame;
3337  mark_pos = winstate->frameheadpos;
3338  break;
3340  update_grouptailpos(winstate);
3341  if (abs_pos < winstate->grouptailpos &&
3342  winstate->groupheadpos < winstate->frametailpos)
3343  {
3344  int64 overlapend = Min(winstate->grouptailpos,
3345  winstate->frametailpos);
3346 
3347  abs_pos -= overlapend - winstate->groupheadpos;
3348  }
3349  update_frameheadpos(winstate);
3350  if (abs_pos < winstate->frameheadpos)
3351  goto out_of_frame;
3352  mark_pos = winstate->frameheadpos;
3353  break;
3355  update_grouptailpos(winstate);
3356  if (abs_pos < winstate->grouptailpos &&
3357  winstate->groupheadpos < winstate->frametailpos)
3358  {
3359  int64 overlapend = Min(winstate->grouptailpos,
3360  winstate->frametailpos);
3361 
3362  if (abs_pos == overlapend - 1)
3363  abs_pos = winstate->currentpos;
3364  else
3365  abs_pos -= overlapend - 1 - winstate->groupheadpos;
3366  }
3367  update_frameheadpos(winstate);
3368  if (abs_pos < winstate->frameheadpos)
3369  goto out_of_frame;
3370  mark_pos = winstate->frameheadpos;
3371  break;
3372  default:
3373  elog(ERROR, "unrecognized frame option state: 0x%x",
3374  winstate->frameOptions);
3375  mark_pos = 0; /* keep compiler quiet */
3376  break;
3377  }
3378  break;
3379  default:
3380  elog(ERROR, "unrecognized window seek type: %d", seektype);
3381  abs_pos = mark_pos = 0; /* keep compiler quiet */
3382  break;
3383  }
3384 
3385  if (!window_gettupleslot(winobj, abs_pos, slot))
3386  goto out_of_frame;
3387 
3388  /* The code above does not detect all out-of-frame cases, so check */
3389  if (row_is_in_frame(winstate, abs_pos, slot) <= 0)
3390  goto out_of_frame;
3391 
3392  if (isout)
3393  *isout = false;
3394  if (set_mark)
3395  WinSetMarkPosition(winobj, mark_pos);
3396  econtext->ecxt_outertuple = slot;
3397  return ExecEvalExpr((ExprState *) list_nth(winobj->argstates, argno),
3398  econtext, isnull);
3399 
3400 out_of_frame:
3401  if (isout)
3402  *isout = true;
3403  *isnull = true;
3404  return (Datum) 0;
3405 }
#define FRAMEOPTION_EXCLUSION
Definition: parsenodes.h:528
static void update_grouptailpos(WindowAggState *winstate)
static bool window_gettupleslot(WindowObject winobj, int64 pos, TupleTableSlot *slot)
ScanState ss
Definition: execnodes.h:1953
int64 groupheadpos
Definition: execnodes.h:1995
ExprContext * ps_ExprContext
Definition: execnodes.h:947
#define Min(x, y)
Definition: c.h:857
static void update_frametailpos(WindowAggState *winstate)
int64 grouptailpos
Definition: execnodes.h:1996
static void update_frameheadpos(WindowAggState *winstate)
TupleTableSlot * temp_slot_1
Definition: execnodes.h:2023
#define WINDOW_SEEK_TAIL
Definition: windowapi.h:34
PlanState ps
Definition: execnodes.h:1192
int64 frameheadpos
Definition: execnodes.h:1971
#define FRAMEOPTION_EXCLUDE_GROUP
Definition: parsenodes.h:521
#define ERROR
Definition: elog.h:43
void * list_nth(const List *list, int n)
Definition: list.c:410
static int row_is_in_frame(WindowAggState *winstate, int64 pos, TupleTableSlot *slot)
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
Definition: executor.h:281
#define WINDOW_SEEK_HEAD
Definition: windowapi.h:33
WindowAggState * winstate
Definition: nodeWindowAgg.c:63
uintptr_t Datum
Definition: postgres.h:367
#define FRAMEOPTION_EXCLUDE_CURRENT_ROW
Definition: parsenodes.h:520
#define WindowObjectIsValid(winobj)
Definition: windowapi.h:41
#define Max(x, y)
Definition: c.h:851
TupleTableSlot * ecxt_outertuple
Definition: execnodes.h:222
#define WINDOW_SEEK_CURRENT
Definition: windowapi.h:32
int64 frametailpos
Definition: execnodes.h:1972
#define Assert(condition)
Definition: c.h:699
#define FRAMEOPTION_EXCLUDE_TIES
Definition: parsenodes.h:522
int64 currentpos
Definition: execnodes.h:1970
void WinSetMarkPosition(WindowObject winobj, int64 markpos)
#define elog
Definition: elog.h:219

◆ WinGetFuncArgInPartition()

Datum WinGetFuncArgInPartition ( WindowObject  winobj,
int  argno,
int  relpos,
int  seektype,
bool  set_mark,
bool isnull,
bool isout 
)

Definition at line 3138 of file nodeWindowAgg.c.

References WindowObjectData::argstates, Assert, WindowAggState::currentpos, ExprContext::ecxt_outertuple, elog, ERROR, ExecEvalExpr(), list_nth(), ScanState::ps, PlanState::ps_ExprContext, spool_tuples(), WindowAggState::spooled_rows, WindowAggState::ss, WindowAggState::temp_slot_1, window_gettupleslot(), WINDOW_SEEK_CURRENT, WINDOW_SEEK_HEAD, WINDOW_SEEK_TAIL, WindowObjectIsValid, WinSetMarkPosition(), and WindowObjectData::winstate.

Referenced by leadlag_common().

3141 {
3142  WindowAggState *winstate;
3143  ExprContext *econtext;
3144  TupleTableSlot *slot;
3145  bool gottuple;
3146  int64 abs_pos;
3147 
3148  Assert(WindowObjectIsValid(winobj));
3149  winstate = winobj->winstate;
3150  econtext = winstate->ss.ps.ps_ExprContext;
3151  slot = winstate->temp_slot_1;
3152 
3153  switch (seektype)
3154  {
3155  case WINDOW_SEEK_CURRENT:
3156  abs_pos = winstate->currentpos + relpos;
3157  break;
3158  case WINDOW_SEEK_HEAD:
3159  abs_pos = relpos;
3160  break;
3161  case WINDOW_SEEK_TAIL:
3162  spool_tuples(winstate, -1);
3163  abs_pos = winstate->spooled_rows - 1 + relpos;
3164  break;
3165  default:
3166  elog(ERROR, "unrecognized window seek type: %d", seektype);
3167  abs_pos = 0; /* keep compiler quiet */
3168  break;
3169  }
3170 
3171  gottuple = window_gettupleslot(winobj, abs_pos, slot);
3172 
3173  if (!gottuple)
3174  {
3175  if (isout)
3176  *isout = true;
3177  *isnull = true;
3178  return (Datum) 0;
3179  }
3180  else
3181  {
3182  if (isout)
3183  *isout = false;
3184  if (set_mark)
3185  WinSetMarkPosition(winobj, abs_pos);
3186  econtext->ecxt_outertuple = slot;
3187  return ExecEvalExpr((ExprState *) list_nth(winobj->argstates, argno),
3188  econtext, isnull);
3189  }
3190 }
static bool window_gettupleslot(WindowObject winobj, int64 pos, TupleTableSlot *slot)
ScanState ss
Definition: execnodes.h:1953
ExprContext * ps_ExprContext
Definition: execnodes.h:947
TupleTableSlot * temp_slot_1
Definition: execnodes.h:2023
static void spool_tuples(WindowAggState *winstate, int64 pos)
#define WINDOW_SEEK_TAIL
Definition: windowapi.h:34
PlanState ps
Definition: execnodes.h:1192
#define ERROR
Definition: elog.h:43
void * list_nth(const List *list, int n)
Definition: list.c:410
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
Definition: executor.h:281
int64 spooled_rows
Definition: execnodes.h:1969
#define WINDOW_SEEK_HEAD
Definition: windowapi.h:33
WindowAggState * winstate
Definition: nodeWindowAgg.c:63
uintptr_t Datum
Definition: postgres.h:367
#define WindowObjectIsValid(winobj)
Definition: windowapi.h:41
TupleTableSlot * ecxt_outertuple
Definition: execnodes.h:222
#define WINDOW_SEEK_CURRENT
Definition: windowapi.h:32
#define Assert(condition)
Definition: c.h:699
int64 currentpos
Definition: execnodes.h:1970
void WinSetMarkPosition(WindowObject winobj, int64 markpos)
#define elog
Definition: elog.h:219

◆ WinGetPartitionLocalMemory()

void* WinGetPartitionLocalMemory ( WindowObject  winobj,
Size  sz 
)

Definition at line 2998 of file nodeWindowAgg.c.

References Assert, WindowObjectData::localmem, MemoryContextAllocZero(), WindowAggState::partcontext, WindowObjectIsValid, and WindowObjectData::winstate.

Referenced by rank_up(), window_cume_dist(), window_dense_rank(), window_ntile(), window_percent_rank(), and window_rank().

2999 {
3000  Assert(WindowObjectIsValid(winobj));
3001  if (winobj->localmem == NULL)
3002  winobj->localmem =
3004  return winobj->localmem;
3005 }
WindowAggState * winstate
Definition: nodeWindowAgg.c:63
void * MemoryContextAllocZero(MemoryContext context, Size size)
Definition: mcxt.c:814
#define WindowObjectIsValid(winobj)
Definition: windowapi.h:41
#define Assert(condition)
Definition: c.h:699
MemoryContext partcontext
Definition: execnodes.h:1998

◆ WinGetPartitionRowCount()

int64 WinGetPartitionRowCount ( WindowObject  winobj)

Definition at line 3028 of file nodeWindowAgg.c.

References Assert, spool_tuples(), WindowAggState::spooled_rows, WindowObjectIsValid, and WindowObjectData::winstate.

Referenced by window_cume_dist(), window_ntile(), and window_percent_rank().

3029 {
3030  Assert(WindowObjectIsValid(winobj));
3031  spool_tuples(winobj->winstate, -1);
3032  return winobj->winstate->spooled_rows;
3033 }
static void spool_tuples(WindowAggState *winstate, int64 pos)
int64 spooled_rows
Definition: execnodes.h:1969
WindowAggState * winstate
Definition: nodeWindowAgg.c:63
#define WindowObjectIsValid(winobj)
Definition: windowapi.h:41
#define Assert(condition)
Definition: c.h:699

◆ WinRowsArePeers()

bool WinRowsArePeers ( WindowObject  winobj,
int64  pos1,
int64  pos2 
)

Definition at line 3081 of file nodeWindowAgg.c.

References are_peers(), Assert, elog, ERROR, ExecClearTuple(), INT64_FORMAT, WindowAgg::ordNumCols, PlanState::plan, ScanState::ps, WindowAggState::ss, WindowAggState::temp_slot_1, WindowAggState::temp_slot_2, window_gettupleslot(), WindowObjectIsValid, and WindowObjectData::winstate.

Referenced by rank_up(), and window_cume_dist().

3082 {
3083  WindowAggState *winstate;
3084  WindowAgg *node;
3085  TupleTableSlot *slot1;
3086  TupleTableSlot *slot2;
3087  bool res;
3088 
3089  Assert(WindowObjectIsValid(winobj));
3090  winstate = winobj->winstate;
3091  node = (WindowAgg *) winstate->ss.ps.plan;
3092 
3093  /* If no ORDER BY, all rows are peers; don't bother to fetch them */
3094  if (node->ordNumCols == 0)
3095  return true;
3096 
3097  /*
3098  * Note: OK to use temp_slot_2 here because we aren't calling any
3099  * frame-related functions (those tend to clobber temp_slot_2).
3100  */
3101  slot1 = winstate->temp_slot_1;
3102  slot2 = winstate->temp_slot_2;
3103 
3104  if (!window_gettupleslot(winobj, pos1, slot1))
3105  elog(ERROR, "specified position is out of window: " INT64_FORMAT,
3106  pos1);
3107  if (!window_gettupleslot(winobj, pos2, slot2))
3108  elog(ERROR, "specified position is out of window: " INT64_FORMAT,
3109  pos2);
3110 
3111  res = are_peers(winstate, slot1, slot2);
3112 
3113  ExecClearTuple(slot1);
3114  ExecClearTuple(slot2);
3115 
3116  return res;
3117 }
int ordNumCols
Definition: plannodes.h:820
static bool window_gettupleslot(WindowObject winobj, int64 pos, TupleTableSlot *slot)
ScanState ss
Definition: execnodes.h:1953
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:475
TupleTableSlot * temp_slot_1
Definition: execnodes.h:2023
PlanState ps
Definition: execnodes.h:1192
#define ERROR
Definition: elog.h:43
TupleTableSlot * temp_slot_2
Definition: execnodes.h:2024
WindowAggState * winstate
Definition: nodeWindowAgg.c:63
Plan * plan
Definition: execnodes.h:912
#define WindowObjectIsValid(winobj)
Definition: windowapi.h:41
#define Assert(condition)
Definition: c.h:699
#define INT64_FORMAT
Definition: c.h:367
static bool are_peers(WindowAggState *winstate, TupleTableSlot *slot1, TupleTableSlot *slot2)
#define elog
Definition: elog.h:219

◆ WinSetMarkPosition()

void WinSetMarkPosition ( WindowObject  winobj,
int64  markpos 
)

Definition at line 3046 of file nodeWindowAgg.c.

References Assert, WindowAggState::buffer, elog, ERROR, WindowObjectData::markpos, WindowObjectData::markptr, WindowObjectData::readptr, WindowObjectData::seekpos, tuplestore_select_read_pointer(), tuplestore_skiptuples(), WindowObjectIsValid, and WindowObjectData::winstate.

Referenced by eval_windowaggregates(), rank_up(), window_row_number(), WinGetFuncArgInFrame(), and WinGetFuncArgInPartition().

3047 {
3048  WindowAggState *winstate;
3049 
3050  Assert(WindowObjectIsValid(winobj));
3051  winstate = winobj->winstate;
3052 
3053  if (markpos < winobj->markpos)
3054  elog(ERROR, "cannot move WindowObject's mark position backward");
3055  tuplestore_select_read_pointer(winstate->buffer, winobj->markptr);
3056  if (markpos > winobj->markpos)
3057  {
3058  tuplestore_skiptuples(winstate->buffer,
3059  markpos - winobj->markpos,
3060  true);
3061  winobj->markpos = markpos;
3062  }
3063  tuplestore_select_read_pointer(winstate->buffer, winobj->readptr);
3064  if (markpos > winobj->seekpos)
3065  {
3066  tuplestore_skiptuples(winstate->buffer,
3067  markpos - winobj->seekpos,
3068  true);
3069  winobj->seekpos = markpos;
3070  }
3071 }
#define ERROR
Definition: elog.h:43
Tuplestorestate * buffer
Definition: execnodes.h:1964
WindowAggState * winstate
Definition: nodeWindowAgg.c:63
#define WindowObjectIsValid(winobj)
Definition: windowapi.h:41
#define Assert(condition)
Definition: c.h:699
bool tuplestore_skiptuples(Tuplestorestate *state, int64 ntuples, bool forward)
Definition: tuplestore.c:1135
void tuplestore_select_read_pointer(Tuplestorestate *state, int ptr)
Definition: tuplestore.c:473
#define elog
Definition: elog.h:219