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

typedef struct WindowObjectData* WindowObject

Definition at line 37 of file windowapi.h.

Function Documentation

◆ WinGetCurrentPosition()

int64 WinGetCurrentPosition ( WindowObject  winobj)

Definition at line 3042 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().

3043 {
3044  Assert(WindowObjectIsValid(winobj));
3045  return winobj->winstate->currentpos;
3046 }
WindowAggState * winstate
Definition: nodeWindowAgg.c:64
#define WindowObjectIsValid(winobj)
Definition: windowapi.h:41
#define Assert(condition)
Definition: c.h:739
int64 currentpos
Definition: execnodes.h:2108

◆ WinGetFuncArgCurrent()

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

Definition at line 3450 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().

3451 {
3452  WindowAggState *winstate;
3453  ExprContext *econtext;
3454 
3455  Assert(WindowObjectIsValid(winobj));
3456  winstate = winobj->winstate;
3457 
3458  econtext = winstate->ss.ps.ps_ExprContext;
3459 
3460  econtext->ecxt_outertuple = winstate->ss.ss_ScanTupleSlot;
3461  return ExecEvalExpr((ExprState *) list_nth(winobj->argstates, argno),
3462  econtext, isnull);
3463 }
ScanState ss
Definition: execnodes.h:2091
ExprContext * ps_ExprContext
Definition: execnodes.h:978
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1329
PlanState ps
Definition: execnodes.h:1326
static void * list_nth(const List *list, int n)
Definition: pg_list.h:277
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
Definition: executor.h:285
WindowAggState * winstate
Definition: nodeWindowAgg.c:64
#define WindowObjectIsValid(winobj)
Definition: windowapi.h:41
TupleTableSlot * ecxt_outertuple
Definition: execnodes.h:227
#define Assert(condition)
Definition: c.h:739

◆ WinGetFuncArgInFrame()

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

Definition at line 3255 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().

3258 {
3259  WindowAggState *winstate;
3260  ExprContext *econtext;
3261  TupleTableSlot *slot;
3262  int64 abs_pos;
3263  int64 mark_pos;
3264 
3265  Assert(WindowObjectIsValid(winobj));
3266  winstate = winobj->winstate;
3267  econtext = winstate->ss.ps.ps_ExprContext;
3268  slot = winstate->temp_slot_1;
3269 
3270  switch (seektype)
3271  {
3272  case WINDOW_SEEK_CURRENT:
3273  elog(ERROR, "WINDOW_SEEK_CURRENT is not supported for WinGetFuncArgInFrame");
3274  abs_pos = mark_pos = 0; /* keep compiler quiet */
3275  break;
3276  case WINDOW_SEEK_HEAD:
3277  /* rejecting relpos < 0 is easy and simplifies code below */
3278  if (relpos < 0)
3279  goto out_of_frame;
3280  update_frameheadpos(winstate);
3281  abs_pos = winstate->frameheadpos + relpos;
3282  mark_pos = abs_pos;
3283 
3284  /*
3285  * Account for exclusion option if one is active, but advance only
3286  * abs_pos not mark_pos. This prevents changes of the current
3287  * row's peer group from resulting in trying to fetch a row before
3288  * some previous mark position.
3289  *
3290  * Note that in some corner cases such as current row being
3291  * outside frame, these calculations are theoretically too simple,
3292  * but it doesn't matter because we'll end up deciding the row is
3293  * out of frame. We do not attempt to avoid fetching rows past
3294  * end of frame; that would happen in some cases anyway.
3295  */
3296  switch (winstate->frameOptions & FRAMEOPTION_EXCLUSION)
3297  {
3298  case 0:
3299  /* no adjustment needed */
3300  break;
3302  if (abs_pos >= winstate->currentpos &&
3303  winstate->currentpos >= winstate->frameheadpos)
3304  abs_pos++;
3305  break;
3307  update_grouptailpos(winstate);
3308  if (abs_pos >= winstate->groupheadpos &&
3309  winstate->grouptailpos > winstate->frameheadpos)
3310  {
3311  int64 overlapstart = Max(winstate->groupheadpos,
3312  winstate->frameheadpos);
3313 
3314  abs_pos += winstate->grouptailpos - overlapstart;
3315  }
3316  break;
3318  update_grouptailpos(winstate);
3319  if (abs_pos >= winstate->groupheadpos &&
3320  winstate->grouptailpos > winstate->frameheadpos)
3321  {
3322  int64 overlapstart = Max(winstate->groupheadpos,
3323  winstate->frameheadpos);
3324 
3325  if (abs_pos == overlapstart)
3326  abs_pos = winstate->currentpos;
3327  else
3328  abs_pos += winstate->grouptailpos - overlapstart - 1;
3329  }
3330  break;
3331  default:
3332  elog(ERROR, "unrecognized frame option state: 0x%x",
3333  winstate->frameOptions);
3334  break;
3335  }
3336  break;
3337  case WINDOW_SEEK_TAIL:
3338  /* rejecting relpos > 0 is easy and simplifies code below */
3339  if (relpos > 0)
3340  goto out_of_frame;
3341  update_frametailpos(winstate);
3342  abs_pos = winstate->frametailpos - 1 + relpos;
3343 
3344  /*
3345  * Account for exclusion option if one is active. If there is no
3346  * exclusion, we can safely set the mark at the accessed row. But
3347  * if there is, we can only mark the frame start, because we can't
3348  * be sure how far back in the frame the exclusion might cause us
3349  * to fetch in future. Furthermore, we have to actually check
3350  * against frameheadpos here, since it's unsafe to try to fetch a
3351  * row before frame start if the mark might be there already.
3352  */
3353  switch (winstate->frameOptions & FRAMEOPTION_EXCLUSION)
3354  {
3355  case 0:
3356  /* no adjustment needed */
3357  mark_pos = abs_pos;
3358  break;
3360  if (abs_pos <= winstate->currentpos &&
3361  winstate->currentpos < winstate->frametailpos)
3362  abs_pos--;
3363  update_frameheadpos(winstate);
3364  if (abs_pos < winstate->frameheadpos)
3365  goto out_of_frame;
3366  mark_pos = winstate->frameheadpos;
3367  break;
3369  update_grouptailpos(winstate);
3370  if (abs_pos < winstate->grouptailpos &&
3371  winstate->groupheadpos < winstate->frametailpos)
3372  {
3373  int64 overlapend = Min(winstate->grouptailpos,
3374  winstate->frametailpos);
3375 
3376  abs_pos -= overlapend - winstate->groupheadpos;
3377  }
3378  update_frameheadpos(winstate);
3379  if (abs_pos < winstate->frameheadpos)
3380  goto out_of_frame;
3381  mark_pos = winstate->frameheadpos;
3382  break;
3384  update_grouptailpos(winstate);
3385  if (abs_pos < winstate->grouptailpos &&
3386  winstate->groupheadpos < winstate->frametailpos)
3387  {
3388  int64 overlapend = Min(winstate->grouptailpos,
3389  winstate->frametailpos);
3390 
3391  if (abs_pos == overlapend - 1)
3392  abs_pos = winstate->currentpos;
3393  else
3394  abs_pos -= overlapend - 1 - winstate->groupheadpos;
3395  }
3396  update_frameheadpos(winstate);
3397  if (abs_pos < winstate->frameheadpos)
3398  goto out_of_frame;
3399  mark_pos = winstate->frameheadpos;
3400  break;
3401  default:
3402  elog(ERROR, "unrecognized frame option state: 0x%x",
3403  winstate->frameOptions);
3404  mark_pos = 0; /* keep compiler quiet */
3405  break;
3406  }
3407  break;
3408  default:
3409  elog(ERROR, "unrecognized window seek type: %d", seektype);
3410  abs_pos = mark_pos = 0; /* keep compiler quiet */
3411  break;
3412  }
3413 
3414  if (!window_gettupleslot(winobj, abs_pos, slot))
3415  goto out_of_frame;
3416 
3417  /* The code above does not detect all out-of-frame cases, so check */
3418  if (row_is_in_frame(winstate, abs_pos, slot) <= 0)
3419  goto out_of_frame;
3420 
3421  if (isout)
3422  *isout = false;
3423  if (set_mark)
3424  WinSetMarkPosition(winobj, mark_pos);
3425  econtext->ecxt_outertuple = slot;
3426  return ExecEvalExpr((ExprState *) list_nth(winobj->argstates, argno),
3427  econtext, isnull);
3428 
3429 out_of_frame:
3430  if (isout)
3431  *isout = true;
3432  *isnull = true;
3433  return (Datum) 0;
3434 }
#define FRAMEOPTION_EXCLUSION
Definition: parsenodes.h:527
static void update_grouptailpos(WindowAggState *winstate)
static bool window_gettupleslot(WindowObject winobj, int64 pos, TupleTableSlot *slot)
ScanState ss
Definition: execnodes.h:2091
int64 groupheadpos
Definition: execnodes.h:2133
ExprContext * ps_ExprContext
Definition: execnodes.h:978
#define Min(x, y)
Definition: c.h:911
static void update_frametailpos(WindowAggState *winstate)
int64 grouptailpos
Definition: execnodes.h:2134
static void update_frameheadpos(WindowAggState *winstate)
TupleTableSlot * temp_slot_1
Definition: execnodes.h:2161
#define WINDOW_SEEK_TAIL
Definition: windowapi.h:34
PlanState ps
Definition: execnodes.h:1326
int64 frameheadpos
Definition: execnodes.h:2109
#define FRAMEOPTION_EXCLUDE_GROUP
Definition: parsenodes.h:520
#define ERROR
Definition: elog.h:43
static void * list_nth(const List *list, int n)
Definition: pg_list.h:277
static int row_is_in_frame(WindowAggState *winstate, int64 pos, TupleTableSlot *slot)
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
Definition: executor.h:285
#define WINDOW_SEEK_HEAD
Definition: windowapi.h:33
WindowAggState * winstate
Definition: nodeWindowAgg.c:64
uintptr_t Datum
Definition: postgres.h:367
#define FRAMEOPTION_EXCLUDE_CURRENT_ROW
Definition: parsenodes.h:519
#define WindowObjectIsValid(winobj)
Definition: windowapi.h:41
#define Max(x, y)
Definition: c.h:905
TupleTableSlot * ecxt_outertuple
Definition: execnodes.h:227
#define WINDOW_SEEK_CURRENT
Definition: windowapi.h:32
int64 frametailpos
Definition: execnodes.h:2110
#define Assert(condition)
Definition: c.h:739
#define FRAMEOPTION_EXCLUDE_TIES
Definition: parsenodes.h:521
int64 currentpos
Definition: execnodes.h:2108
#define elog(elevel,...)
Definition: elog.h:228
void WinSetMarkPosition(WindowObject winobj, int64 markpos)

◆ WinGetFuncArgInPartition()

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

Definition at line 3167 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().

3170 {
3171  WindowAggState *winstate;
3172  ExprContext *econtext;
3173  TupleTableSlot *slot;
3174  bool gottuple;
3175  int64 abs_pos;
3176 
3177  Assert(WindowObjectIsValid(winobj));
3178  winstate = winobj->winstate;
3179  econtext = winstate->ss.ps.ps_ExprContext;
3180  slot = winstate->temp_slot_1;
3181 
3182  switch (seektype)
3183  {
3184  case WINDOW_SEEK_CURRENT:
3185  abs_pos = winstate->currentpos + relpos;
3186  break;
3187  case WINDOW_SEEK_HEAD:
3188  abs_pos = relpos;
3189  break;
3190  case WINDOW_SEEK_TAIL:
3191  spool_tuples(winstate, -1);
3192  abs_pos = winstate->spooled_rows - 1 + relpos;
3193  break;
3194  default:
3195  elog(ERROR, "unrecognized window seek type: %d", seektype);
3196  abs_pos = 0; /* keep compiler quiet */
3197  break;
3198  }
3199 
3200  gottuple = window_gettupleslot(winobj, abs_pos, slot);
3201 
3202  if (!gottuple)
3203  {
3204  if (isout)
3205  *isout = true;
3206  *isnull = true;
3207  return (Datum) 0;
3208  }
3209  else
3210  {
3211  if (isout)
3212  *isout = false;
3213  if (set_mark)
3214  WinSetMarkPosition(winobj, abs_pos);
3215  econtext->ecxt_outertuple = slot;
3216  return ExecEvalExpr((ExprState *) list_nth(winobj->argstates, argno),
3217  econtext, isnull);
3218  }
3219 }
static bool window_gettupleslot(WindowObject winobj, int64 pos, TupleTableSlot *slot)
ScanState ss
Definition: execnodes.h:2091
ExprContext * ps_ExprContext
Definition: execnodes.h:978
TupleTableSlot * temp_slot_1
Definition: execnodes.h:2161
static void spool_tuples(WindowAggState *winstate, int64 pos)
#define WINDOW_SEEK_TAIL
Definition: windowapi.h:34
PlanState ps
Definition: execnodes.h:1326
#define ERROR
Definition: elog.h:43
static void * list_nth(const List *list, int n)
Definition: pg_list.h:277
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
Definition: executor.h:285
int64 spooled_rows
Definition: execnodes.h:2107
#define WINDOW_SEEK_HEAD
Definition: windowapi.h:33
WindowAggState * winstate
Definition: nodeWindowAgg.c:64
uintptr_t Datum
Definition: postgres.h:367
#define WindowObjectIsValid(winobj)
Definition: windowapi.h:41
TupleTableSlot * ecxt_outertuple
Definition: execnodes.h:227
#define WINDOW_SEEK_CURRENT
Definition: windowapi.h:32
#define Assert(condition)
Definition: c.h:739
int64 currentpos
Definition: execnodes.h:2108
#define elog(elevel,...)
Definition: elog.h:228
void WinSetMarkPosition(WindowObject winobj, int64 markpos)

◆ WinGetPartitionLocalMemory()

void* WinGetPartitionLocalMemory ( WindowObject  winobj,
Size  sz 
)

Definition at line 3027 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().

3028 {
3029  Assert(WindowObjectIsValid(winobj));
3030  if (winobj->localmem == NULL)
3031  winobj->localmem =
3033  return winobj->localmem;
3034 }
WindowAggState * winstate
Definition: nodeWindowAgg.c:64
void * MemoryContextAllocZero(MemoryContext context, Size size)
Definition: mcxt.c:839
#define WindowObjectIsValid(winobj)
Definition: windowapi.h:41
#define Assert(condition)
Definition: c.h:739
MemoryContext partcontext
Definition: execnodes.h:2136

◆ WinGetPartitionRowCount()

int64 WinGetPartitionRowCount ( WindowObject  winobj)

Definition at line 3057 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().

3058 {
3059  Assert(WindowObjectIsValid(winobj));
3060  spool_tuples(winobj->winstate, -1);
3061  return winobj->winstate->spooled_rows;
3062 }
static void spool_tuples(WindowAggState *winstate, int64 pos)
int64 spooled_rows
Definition: execnodes.h:2107
WindowAggState * winstate
Definition: nodeWindowAgg.c:64
#define WindowObjectIsValid(winobj)
Definition: windowapi.h:41
#define Assert(condition)
Definition: c.h:739

◆ WinRowsArePeers()

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

Definition at line 3110 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().

3111 {
3112  WindowAggState *winstate;
3113  WindowAgg *node;
3114  TupleTableSlot *slot1;
3115  TupleTableSlot *slot2;
3116  bool res;
3117 
3118  Assert(WindowObjectIsValid(winobj));
3119  winstate = winobj->winstate;
3120  node = (WindowAgg *) winstate->ss.ps.plan;
3121 
3122  /* If no ORDER BY, all rows are peers; don't bother to fetch them */
3123  if (node->ordNumCols == 0)
3124  return true;
3125 
3126  /*
3127  * Note: OK to use temp_slot_2 here because we aren't calling any
3128  * frame-related functions (those tend to clobber temp_slot_2).
3129  */
3130  slot1 = winstate->temp_slot_1;
3131  slot2 = winstate->temp_slot_2;
3132 
3133  if (!window_gettupleslot(winobj, pos1, slot1))
3134  elog(ERROR, "specified position is out of window: " INT64_FORMAT,
3135  pos1);
3136  if (!window_gettupleslot(winobj, pos2, slot2))
3137  elog(ERROR, "specified position is out of window: " INT64_FORMAT,
3138  pos2);
3139 
3140  res = are_peers(winstate, slot1, slot2);
3141 
3142  ExecClearTuple(slot1);
3143  ExecClearTuple(slot2);
3144 
3145  return res;
3146 }
int ordNumCols
Definition: plannodes.h:834
static bool window_gettupleslot(WindowObject winobj, int64 pos, TupleTableSlot *slot)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:425
ScanState ss
Definition: execnodes.h:2091
TupleTableSlot * temp_slot_1
Definition: execnodes.h:2161
PlanState ps
Definition: execnodes.h:1326
#define ERROR
Definition: elog.h:43
TupleTableSlot * temp_slot_2
Definition: execnodes.h:2162
WindowAggState * winstate
Definition: nodeWindowAgg.c:64
Plan * plan
Definition: execnodes.h:939
#define WindowObjectIsValid(winobj)
Definition: windowapi.h:41
#define Assert(condition)
Definition: c.h:739
#define INT64_FORMAT
Definition: c.h:401
static bool are_peers(WindowAggState *winstate, TupleTableSlot *slot1, TupleTableSlot *slot2)
#define elog(elevel,...)
Definition: elog.h:228

◆ WinSetMarkPosition()

void WinSetMarkPosition ( WindowObject  winobj,
int64  markpos 
)

Definition at line 3075 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().

3076 {
3077  WindowAggState *winstate;
3078 
3079  Assert(WindowObjectIsValid(winobj));
3080  winstate = winobj->winstate;
3081 
3082  if (markpos < winobj->markpos)
3083  elog(ERROR, "cannot move WindowObject's mark position backward");
3084  tuplestore_select_read_pointer(winstate->buffer, winobj->markptr);
3085  if (markpos > winobj->markpos)
3086  {
3087  tuplestore_skiptuples(winstate->buffer,
3088  markpos - winobj->markpos,
3089  true);
3090  winobj->markpos = markpos;
3091  }
3092  tuplestore_select_read_pointer(winstate->buffer, winobj->readptr);
3093  if (markpos > winobj->seekpos)
3094  {
3095  tuplestore_skiptuples(winstate->buffer,
3096  markpos - winobj->seekpos,
3097  true);
3098  winobj->seekpos = markpos;
3099  }
3100 }
#define ERROR
Definition: elog.h:43
Tuplestorestate * buffer
Definition: execnodes.h:2102
WindowAggState * winstate
Definition: nodeWindowAgg.c:64
#define WindowObjectIsValid(winobj)
Definition: windowapi.h:41
#define Assert(condition)
Definition: c.h:739
bool tuplestore_skiptuples(Tuplestorestate *state, int64 ntuples, bool forward)
Definition: tuplestore.c:1135
#define elog(elevel,...)
Definition: elog.h:228
void tuplestore_select_read_pointer(Tuplestorestate *state, int ptr)
Definition: tuplestore.c:473