summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/catversion.h2
-rw-r--r--src/include/catalog/pg_proc.dat81
-rw-r--r--src/include/catalog/pg_proc.h5
-rw-r--r--src/include/nodes/nodes.h3
-rw-r--r--src/include/nodes/supportnodes.h70
-rw-r--r--src/include/parser/kwlist.h1
-rw-r--r--src/include/utils/datetime.h2
7 files changed, 113 insertions, 51 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 5eb4f6f172a..9233fb934e8 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 201902081
+#define CATALOG_VERSION_NO 201902091
#endif
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 93e3e16f01c..1f5352ce543 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -1326,11 +1326,11 @@
{ oid => '668', descr => 'adjust char() to typmod length',
proname => 'bpchar', prorettype => 'bpchar',
proargtypes => 'bpchar int4 bool', prosrc => 'bpchar' },
-{ oid => '3097', descr => 'transform a varchar length coercion',
- proname => 'varchar_transform', prorettype => 'internal',
- proargtypes => 'internal', prosrc => 'varchar_transform' },
+{ oid => '3097', descr => 'planner support for varchar length coercion',
+ proname => 'varchar_support', prorettype => 'internal',
+ proargtypes => 'internal', prosrc => 'varchar_support' },
{ oid => '669', descr => 'adjust varchar() to typmod length',
- proname => 'varchar', protransform => 'varchar_transform',
+ proname => 'varchar', prosupport => 'varchar_support',
prorettype => 'varchar', proargtypes => 'varchar int4 bool',
prosrc => 'varchar' },
@@ -1954,13 +1954,9 @@
# OIDS 1000 - 1999
-{ oid => '3994', descr => 'transform a time zone adjustment',
- proname => 'timestamp_izone_transform', prorettype => 'internal',
- proargtypes => 'internal', prosrc => 'timestamp_izone_transform' },
{ oid => '1026', descr => 'adjust timestamp to new time zone',
- proname => 'timezone', protransform => 'timestamp_izone_transform',
- prorettype => 'timestamp', proargtypes => 'interval timestamptz',
- prosrc => 'timestamptz_izone' },
+ proname => 'timezone', prorettype => 'timestamp',
+ proargtypes => 'interval timestamptz', prosrc => 'timestamptz_izone' },
{ oid => '1031', descr => 'I/O',
proname => 'aclitemin', provolatile => 's', prorettype => 'aclitem',
@@ -2190,13 +2186,9 @@
{ oid => '1158', descr => 'convert UNIX epoch to timestamptz',
proname => 'to_timestamp', prorettype => 'timestamptz',
proargtypes => 'float8', prosrc => 'float8_timestamptz' },
-{ oid => '3995', descr => 'transform a time zone adjustment',
- proname => 'timestamp_zone_transform', prorettype => 'internal',
- proargtypes => 'internal', prosrc => 'timestamp_zone_transform' },
{ oid => '1159', descr => 'adjust timestamp to new time zone',
- proname => 'timezone', protransform => 'timestamp_zone_transform',
- prorettype => 'timestamp', proargtypes => 'text timestamptz',
- prosrc => 'timestamptz_zone' },
+ proname => 'timezone', prorettype => 'timestamp',
+ proargtypes => 'text timestamptz', prosrc => 'timestamptz_zone' },
{ oid => '1160', descr => 'I/O',
proname => 'interval_in', provolatile => 's', prorettype => 'interval',
@@ -2301,11 +2293,11 @@
# OIDS 1200 - 1299
-{ oid => '3918', descr => 'transform an interval length coercion',
- proname => 'interval_transform', prorettype => 'internal',
- proargtypes => 'internal', prosrc => 'interval_transform' },
+{ oid => '3918', descr => 'planner support for interval length coercion',
+ proname => 'interval_support', prorettype => 'internal',
+ proargtypes => 'internal', prosrc => 'interval_support' },
{ oid => '1200', descr => 'adjust interval precision',
- proname => 'interval', protransform => 'interval_transform',
+ proname => 'interval', prosupport => 'interval_support',
prorettype => 'interval', proargtypes => 'interval int4',
prosrc => 'interval_scale' },
@@ -3713,13 +3705,12 @@
{ oid => '1685', descr => 'adjust bit() to typmod length',
proname => 'bit', prorettype => 'bit', proargtypes => 'bit int4 bool',
prosrc => 'bit' },
-{ oid => '3158', descr => 'transform a varbit length coercion',
- proname => 'varbit_transform', prorettype => 'internal',
- proargtypes => 'internal', prosrc => 'varbit_transform' },
+{ oid => '3158', descr => 'planner support for varbit length coercion',
+ proname => 'varbit_support', prorettype => 'internal',
+ proargtypes => 'internal', prosrc => 'varbit_support' },
{ oid => '1687', descr => 'adjust varbit() to typmod length',
- proname => 'varbit', protransform => 'varbit_transform',
- prorettype => 'varbit', proargtypes => 'varbit int4 bool',
- prosrc => 'varbit' },
+ proname => 'varbit', prosupport => 'varbit_support', prorettype => 'varbit',
+ proargtypes => 'varbit int4 bool', prosrc => 'varbit' },
{ oid => '1698', descr => 'position of sub-bitstring',
proname => 'position', prorettype => 'int4', proargtypes => 'bit bit',
@@ -4081,11 +4072,11 @@
{ oid => '2918', descr => 'I/O typmod',
proname => 'numerictypmodout', prorettype => 'cstring', proargtypes => 'int4',
prosrc => 'numerictypmodout' },
-{ oid => '3157', descr => 'transform a numeric length coercion',
- proname => 'numeric_transform', prorettype => 'internal',
- proargtypes => 'internal', prosrc => 'numeric_transform' },
+{ oid => '3157', descr => 'planner support for numeric length coercion',
+ proname => 'numeric_support', prorettype => 'internal',
+ proargtypes => 'internal', prosrc => 'numeric_support' },
{ oid => '1703', descr => 'adjust numeric to typmod precision/scale',
- proname => 'numeric', protransform => 'numeric_transform',
+ proname => 'numeric', prosupport => 'numeric_support',
prorettype => 'numeric', proargtypes => 'numeric int4', prosrc => 'numeric' },
{ oid => '1704',
proname => 'numeric_abs', prorettype => 'numeric', proargtypes => 'numeric',
@@ -5448,15 +5439,15 @@
proname => 'bytea_sortsupport', prorettype => 'void',
proargtypes => 'internal', prosrc => 'bytea_sortsupport' },
-{ oid => '3917', descr => 'transform a timestamp length coercion',
- proname => 'timestamp_transform', prorettype => 'internal',
- proargtypes => 'internal', prosrc => 'timestamp_transform' },
-{ oid => '3944', descr => 'transform a time length coercion',
- proname => 'time_transform', prorettype => 'internal',
- proargtypes => 'internal', prosrc => 'time_transform' },
+{ oid => '3917', descr => 'planner support for timestamp length coercion',
+ proname => 'timestamp_support', prorettype => 'internal',
+ proargtypes => 'internal', prosrc => 'timestamp_support' },
+{ oid => '3944', descr => 'planner support for time length coercion',
+ proname => 'time_support', prorettype => 'internal',
+ proargtypes => 'internal', prosrc => 'time_support' },
{ oid => '1961', descr => 'adjust timestamp precision',
- proname => 'timestamp', protransform => 'timestamp_transform',
+ proname => 'timestamp', prosupport => 'timestamp_support',
prorettype => 'timestamp', proargtypes => 'timestamp int4',
prosrc => 'timestamp_scale' },
@@ -5468,14 +5459,14 @@
prosrc => 'oidsmaller' },
{ oid => '1967', descr => 'adjust timestamptz precision',
- proname => 'timestamptz', protransform => 'timestamp_transform',
+ proname => 'timestamptz', prosupport => 'timestamp_support',
prorettype => 'timestamptz', proargtypes => 'timestamptz int4',
prosrc => 'timestamptz_scale' },
{ oid => '1968', descr => 'adjust time precision',
- proname => 'time', protransform => 'time_transform', prorettype => 'time',
+ proname => 'time', prosupport => 'time_support', prorettype => 'time',
proargtypes => 'time int4', prosrc => 'time_scale' },
{ oid => '1969', descr => 'adjust time with time zone precision',
- proname => 'timetz', protransform => 'time_transform', prorettype => 'timetz',
+ proname => 'timetz', prosupport => 'time_support', prorettype => 'timetz',
proargtypes => 'timetz int4', prosrc => 'timetz_scale' },
{ oid => '2003',
@@ -5662,13 +5653,11 @@
prosrc => 'select pg_catalog.age(cast(current_date as timestamp without time zone), $1)' },
{ oid => '2069', descr => 'adjust timestamp to new time zone',
- proname => 'timezone', protransform => 'timestamp_zone_transform',
- prorettype => 'timestamptz', proargtypes => 'text timestamp',
- prosrc => 'timestamp_zone' },
+ proname => 'timezone', prorettype => 'timestamptz',
+ proargtypes => 'text timestamp', prosrc => 'timestamp_zone' },
{ oid => '2070', descr => 'adjust timestamp to new time zone',
- proname => 'timezone', protransform => 'timestamp_izone_transform',
- prorettype => 'timestamptz', proargtypes => 'interval timestamp',
- prosrc => 'timestamp_izone' },
+ proname => 'timezone', prorettype => 'timestamptz',
+ proargtypes => 'interval timestamp', prosrc => 'timestamp_izone' },
{ oid => '2071',
proname => 'date_pl_interval', prorettype => 'timestamp',
proargtypes => 'date interval', prosrc => 'date_pl_interval' },
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index c2bb9516dc3..e5270d2ff11 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -53,8 +53,8 @@ CATALOG(pg_proc,1255,ProcedureRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81,Proce
/* element type of variadic array, or 0 */
Oid provariadic BKI_DEFAULT(0) BKI_LOOKUP(pg_type);
- /* transforms calls to it during planning */
- regproc protransform BKI_DEFAULT(0) BKI_LOOKUP(pg_proc);
+ /* planner support function for this function, or 0 if none */
+ regproc prosupport BKI_DEFAULT(0) BKI_LOOKUP(pg_proc);
/* see PROKIND_ categories below */
char prokind BKI_DEFAULT(f);
@@ -201,6 +201,7 @@ extern ObjectAddress ProcedureCreate(const char *procedureName,
List *parameterDefaults,
Datum trftypes,
Datum proconfig,
+ Oid prosupport,
float4 procost,
float4 prorows);
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index 3c003b06906..0d2d1889e9d 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -506,7 +506,8 @@ typedef enum NodeTag
T_IndexAmRoutine, /* in access/amapi.h */
T_TsmRoutine, /* in access/tsmapi.h */
T_ForeignKeyCacheInfo, /* in utils/rel.h */
- T_CallContext /* in nodes/parsenodes.h */
+ T_CallContext, /* in nodes/parsenodes.h */
+ T_SupportRequestSimplify /* in nodes/supportnodes.h */
} NodeTag;
/*
diff --git a/src/include/nodes/supportnodes.h b/src/include/nodes/supportnodes.h
new file mode 100644
index 00000000000..1f7d02b5ee2
--- /dev/null
+++ b/src/include/nodes/supportnodes.h
@@ -0,0 +1,70 @@
+/*-------------------------------------------------------------------------
+ *
+ * supportnodes.h
+ * Definitions for planner support functions.
+ *
+ * This file defines the API for "planner support functions", which
+ * are SQL functions (normally written in C) that can be attached to
+ * another "target" function to give the system additional knowledge
+ * about the target function. All the current capabilities have to do
+ * with planning queries that use the target function, though it is
+ * possible that future extensions will add functionality to be invoked
+ * by the parser or executor.
+ *
+ * A support function must have the SQL signature
+ * supportfn(internal) returns internal
+ * The argument is a pointer to one of the Node types defined in this file.
+ * The result is usually also a Node pointer, though its type depends on
+ * which capability is being invoked. In all cases, a NULL pointer result
+ * (that's PG_RETURN_POINTER(NULL), not PG_RETURN_NULL()) indicates that
+ * the support function cannot do anything useful for the given request.
+ * Support functions must return a NULL pointer, not fail, if they do not
+ * recognize the request node type or cannot handle the given case; this
+ * allows for future extensions of the set of request cases.
+ *
+ *
+ * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/nodes/supportnodes.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef SUPPORTNODES_H
+#define SUPPORTNODES_H
+
+#include "nodes/primnodes.h"
+
+struct PlannerInfo; /* avoid including relation.h here */
+
+
+/*
+ * The Simplify request allows the support function to perform plan-time
+ * simplification of a call to its target function. For example, a varchar
+ * length coercion that does not decrease the allowed length of its argument
+ * could be replaced by a RelabelType node, or "x + 0" could be replaced by
+ * "x". This is invoked during the planner's constant-folding pass, so the
+ * function's arguments can be presumed already simplified.
+ *
+ * The planner's PlannerInfo "root" is typically not needed, but can be
+ * consulted if it's necessary to obtain info about Vars present in
+ * the given node tree. Beware that root could be NULL in some usages.
+ *
+ * "fcall" will be a FuncExpr invoking the support function's target
+ * function. (This is true even if the original parsetree node was an
+ * operator call; a FuncExpr is synthesized for this purpose.)
+ *
+ * The result should be a semantically-equivalent transformed node tree,
+ * or NULL if no simplification could be performed. Do *not* return or
+ * modify *fcall, as it isn't really a separately allocated Node. But
+ * it's okay to use fcall->args, or parts of it, in the result tree.
+ */
+typedef struct SupportRequestSimplify
+{
+ NodeTag type;
+
+ struct PlannerInfo *root; /* Planner's infrastructure */
+ FuncExpr *fcall; /* Function call to be simplified */
+} SupportRequestSimplify;
+
+#endif /* SUPPORTNODES_H */
diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h
index adeb834ce82..f05444008c4 100644
--- a/src/include/parser/kwlist.h
+++ b/src/include/parser/kwlist.h
@@ -387,6 +387,7 @@ PG_KEYWORD("strict", STRICT_P, UNRESERVED_KEYWORD)
PG_KEYWORD("strip", STRIP_P, UNRESERVED_KEYWORD)
PG_KEYWORD("subscription", SUBSCRIPTION, UNRESERVED_KEYWORD)
PG_KEYWORD("substring", SUBSTRING, COL_NAME_KEYWORD)
+PG_KEYWORD("support", SUPPORT, UNRESERVED_KEYWORD)
PG_KEYWORD("symmetric", SYMMETRIC, RESERVED_KEYWORD)
PG_KEYWORD("sysid", SYSID, UNRESERVED_KEYWORD)
PG_KEYWORD("system", SYSTEM_P, UNRESERVED_KEYWORD)
diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h
index f5ec9bbd7e0..87f819e76e0 100644
--- a/src/include/utils/datetime.h
+++ b/src/include/utils/datetime.h
@@ -330,7 +330,7 @@ extern int DecodeUnits(int field, char *lowtoken, int *val);
extern int j2day(int jd);
-extern Node *TemporalTransform(int32 max_precis, Node *node);
+extern Node *TemporalSimplify(int32 max_precis, Node *node);
extern bool CheckDateTokenTables(void);