add openGauss 3.1.0 feature code

This commit is contained in:
yanghao
2022-09-03 16:22:35 +08:00
parent 801d945a3d
commit b919f404e8
2759 changed files with 521358 additions and 366321 deletions

View File

@ -752,7 +752,7 @@ static bool check_ungrouped_columns_walker(Node* node, check_ungrouped_columns_c
#ifndef ENABLE_MULTIPLE_NODES
/* If There is ROWNUM, it must appear in the GROUP BY clause or be used in an aggregate function. */
if (IsA(node, Rownum)) {
if (IsA(node, Rownum) && context->sublevels_up == 0) {
find_rownum_in_groupby_clauses((Rownum *)node, context);
}
#endif
@ -1502,10 +1502,16 @@ Oid resolve_aggregate_transtype(Oid aggfuncid, Oid aggtranstype, Oid* inputTypes
#ifndef ENABLE_MULTIPLE_NODES
static void find_rownum_in_groupby_clauses(Rownum *rownumVar, check_ungrouped_columns_context *context)
{
bool haveRownum = false;
ListCell *gl = NULL;
if (!context->have_non_var_grouping || context->sublevels_up != 0) {
/*
* have_non_var_grouping makes SQL
* SELECT a + a FROM t GROUP BY a + a having rownum <= 1;
* allowed, but SQL
* SELECT a FROM t GROUP BY a having rownum <= 1;
* not allowed, which is different from O.
*/
if (!context->have_non_var_grouping) {
bool haveRownum = false;
ListCell *gl = NULL;
foreach (gl, context->groupClauses) {
Node *gnode = (Node *)((TargetEntry *)lfirst(gl))->expr;
if (IsA(gnode, Rownum)) {