parser_errposition(pstate, location)));
}
+ /*
+ * NULL TREATEMENT is only allowed for window functions per spec.
+ */
+ if (fdresult != FUNCDETAIL_WINDOWFUNC && ignore_nulls != NO_NULLTREATMENT)
+ ereport(ERROR,
+ errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("Only window functions accept RESPECT/IGNORE NULLS"),
+ parser_errposition(pstate, location));
+
/*
* So far so good, so do some fdresult-type-specific processing.
*/
errmsg("%s is not an ordered-set aggregate, so it cannot have WITHIN GROUP",
NameListToString(funcname)),
parser_errposition(pstate, location)));
-
- /* It also can't treat nulls as a window function */
- if (ignore_nulls != NO_NULLTREATMENT)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("aggregate functions do not accept RESPECT/IGNORE NULLS"),
- parser_errposition(pstate, location)));
}
}
else if (fdresult == FUNCDETAIL_WINDOWFUNC)
(10 rows)
SELECT sum(orbit) RESPECT NULLS OVER () FROM planets; -- fails
-ERROR: aggregate functions do not accept RESPECT/IGNORE NULLS
+ERROR: Only window functions accept RESPECT/IGNORE NULLS
LINE 1: SELECT sum(orbit) RESPECT NULLS OVER () FROM planets;
^
SELECT sum(orbit) IGNORE NULLS OVER () FROM planets; -- fails
-ERROR: aggregate functions do not accept RESPECT/IGNORE NULLS
+ERROR: Only window functions accept RESPECT/IGNORE NULLS
LINE 1: SELECT sum(orbit) IGNORE NULLS OVER () FROM planets;
^
SELECT row_number() OVER () FROM planets; -- succeeds