aboutsummaryrefslogtreecommitdiff
path: root/src/include/optimizer/optimizer.h
diff options
context:
space:
mode:
authorTomas Vondra <tomas.vondra@postgresql.org>2020-12-21 18:58:32 +0100
committerTomas Vondra <tomas.vondra@postgresql.org>2020-12-21 19:36:03 +0100
commitd0167631e8b7388b78203c6798621f98beed93d5 (patch)
tree81259e3de996059f7f1e11126263e40fdf4b4ece /src/include/optimizer/optimizer.h
parent38d30a14b05e0cc2996fd311d94d7ae4fe2122aa (diff)
downloadpostgresql-d0167631e8b7388b78203c6798621f98beed93d5.tar.gz
postgresql-d0167631e8b7388b78203c6798621f98beed93d5.zip
Disallow SRFs when considering sorts below Gather Merge
While we do allow SRFs in ORDER BY, scan/join processing should not consider such cases - such sorts should only happen via final Sort atop a ProjectSet. So make sure we don't try adding such sorts below Gather Merge, just like we do for expressions that are volatile and/or not parallel safe. Backpatch to PostgreSQL 13, where this code was introduced as part of the Incremental Sort patch. Author: James Coleman Reviewed-by: Tomas Vondra Backpatch-through: 13 Discussion: https://postgr.es/m/CAAaqYe8cK3g5CfLC4w7bs=hC0mSksZC=H5M8LSchj5e5OxpTAg@mail.gmail.com Discussion: https://postgr.es/m/295524.1606246314%40sss.pgh.pa.us
Diffstat (limited to 'src/include/optimizer/optimizer.h')
-rw-r--r--src/include/optimizer/optimizer.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/include/optimizer/optimizer.h b/src/include/optimizer/optimizer.h
index 3e4171056e8..1e135652b97 100644
--- a/src/include/optimizer/optimizer.h
+++ b/src/include/optimizer/optimizer.h
@@ -24,6 +24,11 @@
#include "nodes/parsenodes.h"
+/* Test if an expression node represents a SRF call. Beware multiple eval! */
+#define IS_SRF_CALL(node) \
+ ((IsA(node, FuncExpr) && ((FuncExpr *) (node))->funcretset) || \
+ (IsA(node, OpExpr) && ((OpExpr *) (node))->opretset))
+
/*
* We don't want to include nodes/pathnodes.h here, because non-planner
* code should generally treat PlannerInfo as an opaque typedef.