支持keep函数
This commit is contained in:
@ -195,6 +195,8 @@ typedef struct AggStatePerAggData {
|
||||
ProjectionInfo *evalproj; /* projection machinery */
|
||||
ProjectionInfo *combinedproj; /* projection machinery */
|
||||
TupleTableSlot *evalslot; /* current input tuple */
|
||||
TupleTableSlot **keep_slot;
|
||||
bool is_keep;
|
||||
} AggStatePerAggData;
|
||||
|
||||
/*
|
||||
|
||||
@ -161,6 +161,7 @@ extern const uint32 MINMAXEXPR_CMPTYPE_VERSION_NUM;
|
||||
extern const uint32 CHARBYTE_SEMANTIC_VERSION_NUMBER;
|
||||
extern const uint32 APPLY_JOIN_VERSION_NUMBER;
|
||||
extern const uint32 PUBLIC_SYNONYM_VERSION_NUMBER;
|
||||
extern const uint32 KEEP_FUNC_VERSION_NUMBER;
|
||||
|
||||
extern void register_backend_version(uint32 backend_version);
|
||||
extern bool contain_backend_version(uint32 version_number);
|
||||
|
||||
@ -909,6 +909,8 @@ typedef struct WindowFuncExprState {
|
||||
// Vectorized aggregation fields
|
||||
//
|
||||
ScalarVector* m_resultVector;
|
||||
List *keep_args;
|
||||
bool keep_first;
|
||||
} WindowFuncExprState;
|
||||
|
||||
|
||||
|
||||
@ -915,7 +915,8 @@ typedef enum NodeTag {
|
||||
T_RotateClause = 6000,
|
||||
T_UnrotateClause,
|
||||
T_RotateInCell,
|
||||
T_UnrotateInCell
|
||||
T_UnrotateInCell,
|
||||
T_KeepClause
|
||||
|
||||
} NodeTag;
|
||||
|
||||
|
||||
@ -1702,6 +1702,14 @@ typedef struct CommonTableExpr {
|
||||
StartWithOptions *swoptions; /* START WITH CONNECT BY options */
|
||||
} CommonTableExpr;
|
||||
|
||||
typedef struct KeepClause
|
||||
{
|
||||
NodeTag type;
|
||||
bool rank_first;
|
||||
List *keep_order;
|
||||
int location;
|
||||
} KeepClause;
|
||||
|
||||
/*
|
||||
* FuncCall - a function or aggregate invocation
|
||||
*
|
||||
@ -1719,6 +1727,7 @@ typedef struct FuncCall {
|
||||
List *args; /* the arguments (list of exprs) */
|
||||
List *agg_order; /* ORDER BY (list of SortBy) */
|
||||
Node *agg_filter;
|
||||
KeepClause *aggKeep;
|
||||
bool agg_within_group;
|
||||
bool agg_star; /* argument was really '*' */
|
||||
bool agg_distinct; /* arguments were labeled DISTINCT */
|
||||
|
||||
@ -295,6 +295,8 @@ typedef struct Aggref {
|
||||
List* args; /* arguments and sort expressions */
|
||||
List* aggorder; /* ORDER BY (list of SortGroupClause) */
|
||||
List* aggdistinct; /* DISTINCT (list of SortGroupClause) */
|
||||
bool aggiskeep;
|
||||
bool aggkpfirst;
|
||||
bool aggstar; /* TRUE if argument list was really '*' */
|
||||
bool aggvariadic; /* true if variadic arguments have been
|
||||
* combined into an array last argument */
|
||||
@ -359,6 +361,9 @@ typedef struct WindowFunc {
|
||||
bool winstar; /* TRUE if argument list was really '*' */
|
||||
bool winagg; /* is function a simple aggregate? */
|
||||
int location; /* token location, or -1 if unknown */
|
||||
List* keep_args;
|
||||
List* winkporder;
|
||||
bool winkpfirst;
|
||||
#ifdef USE_SPQ
|
||||
bool windistinct; /* TRUE if it's agg(DISTINCT ...) */
|
||||
#endif
|
||||
|
||||
@ -205,6 +205,7 @@ PG_KEYWORD("delimiter", DELIMITER, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("delimiters", DELIMITERS, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("delta", DELTA, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("deltamerge", DELTAMERGE, TYPE_FUNC_NAME_KEYWORD)
|
||||
PG_KEYWORD("dense_rank", DENSE_RANK, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("desc", DESC, RESERVED_KEYWORD)
|
||||
PG_KEYWORD("deterministic", DETERMINISTIC, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("diagnostics", DIAGNOSTICS, UNRESERVED_KEYWORD)
|
||||
@ -352,6 +353,7 @@ PG_KEYWORD("is", IS, RESERVED_KEYWORD)
|
||||
PG_KEYWORD("isnull", ISNULL, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("isolation", ISOLATION, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("join", JOIN, TYPE_FUNC_NAME_KEYWORD)
|
||||
PG_KEYWORD("keep", KEEP, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("key", KEY, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("key_path", KEY_PATH, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("key_store", KEY_STORE, UNRESERVED_KEYWORD)
|
||||
|
||||
@ -190,5 +190,6 @@ extern void UpdateUniqueSQLSortStats(Tuplesortstate* state, TimestampTz* start_t
|
||||
extern int64 tuplesort_get_peak_memory(Tuplesortstate* state);
|
||||
|
||||
extern void tuplesort_workerfinish(Sharedsort *shared);
|
||||
|
||||
extern void* TuplesortGetSortkeys(Tuplesortstate* state);
|
||||
extern int TuplesortGetNsortkey(Tuplesortstate* state);
|
||||
#endif /* TUPLESORT_H */
|
||||
|
||||
@ -94,6 +94,13 @@ typedef struct WindowStatePerFuncData {
|
||||
|
||||
} WindowStatePerFuncData;
|
||||
|
||||
typedef struct KeepRank {
|
||||
bool keeptypeByVal;
|
||||
bool keepValueIsNull;
|
||||
int16 keeptypeLen;
|
||||
Datum keepValue;
|
||||
SortSupportData keepSort;
|
||||
} KeepRank;
|
||||
/*
|
||||
* For plain aggregate window functions, we also have one of these.
|
||||
*/
|
||||
@ -136,6 +143,10 @@ typedef struct WindowStatePerAggData {
|
||||
bool transValueIsNull;
|
||||
|
||||
bool noTransValue; /* true if transValue not set yet */
|
||||
int numKeepCols;
|
||||
bool keep_first;
|
||||
bool keep_init;
|
||||
KeepRank* keepRank;
|
||||
} WindowStatePerAggData;
|
||||
|
||||
#define PG_WINDOW_OBJECT() ((WindowObject)fcinfo->context)
|
||||
|
||||
Reference in New Issue
Block a user