v1-dont-fail-in-early-examine_variable.patch
text/x-diff
Filename: v1-dont-fail-in-early-examine_variable.patch
Type: text/x-diff
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
Series: patch v1
| File | + | − |
|---|---|---|
| src/backend/utils/adt/selfuncs.c | 14 | 0 |
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 1c480cfaaf7..1a6db244c94 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -5309,6 +5309,20 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid,
/* Save the exposed type of the expression */
vardata->vartype = exprType(node);
+ /*
+ * It's possible to get here during SubLink planning, before we have
+ * constructed any RelOptInfos for the parent query level. In that case
+ * we have to punt by pretending the node is variable-free, since we
+ * cannot satisfy the API expectation of passing back a RelOptInfo.
+ */
+ if (root->simple_rel_array == NULL)
+ {
+ vardata->var = node;
+ vardata->atttype = vardata->vartype;
+ vardata->atttypmod = exprTypmod(node);
+ return;
+ }
+
/* Look inside any binary-compatible relabeling */
if (IsA(node, RelabelType))