v1-absorb-any-rw-input-parameter.patch
text/x-diff
Filename: v1-absorb-any-rw-input-parameter.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/pl/plpgsql/src/pl_exec.c | 11 | 10 |
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index ea9740e3f8..80b8654fc8 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -532,21 +532,22 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo,
false);
/*
- * Force any array-valued parameter to be stored in
- * expanded form in our local variable, in hopes of
- * improving efficiency of uses of the variable. (This is
- * a hack, really: why only arrays? Need more thought
- * about which cases are likely to win. See also
- * typisarray-specific heuristic in exec_assign_value.)
- *
- * Special cases: If passed a R/W expanded pointer, assume
+ * If it's a pass-by-reference type, check to see if we
+ * received a R/W expanded-object pointer. If so, assume
* we can commandeer the object rather than having to copy
* it. If passed a R/O expanded pointer, just keep it as
* the value of the variable for the moment. (We'll force
* it to R/W if the variable gets modified, but that may
* very well never happen.)
+ *
+ * Also, force any flat array value to be stored in
+ * expanded form in our local variable, in hopes of
+ * improving efficiency of uses of the variable. (This is
+ * a hack, really: why only arrays? Need more thought
+ * about which cases are likely to win. See also
+ * typisarray-specific heuristic in exec_assign_value.)
*/
- if (!var->isnull && var->datatype->typisarray)
+ if (!var->isnull && var->datatype->typlen == -1)
{
if (VARATT_IS_EXTERNAL_EXPANDED_RW(DatumGetPointer(var->value)))
{
@@ -561,7 +562,7 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo,
{
/* R/O pointer, keep it as-is until assigned to */
}
- else
+ else if (var->datatype->typisarray)
{
/* flat array, so force to expanded form */
assign_simple_var(&estate, var,