Without this, the syntax-tree-dumping functions in pl_funcs.c crash,
and there are other places that might be at risk too. Per report
from Pavel Stehule.
Looks like I broke this in commit
f9263006d, so back-patch to v11.
Discussion: https://postgr.es/m/CAFj8pRA+3f5n4642q2g8BXCKjbTd7yU9JMYAgDyHgozk6cQ-VA@mail.gmail.com
row = palloc0(sizeof(PLpgSQL_row));
row->dtype = PLPGSQL_DTYPE_ROW;
+ row->refname = "(unnamed row)";
+ row->lineno = -1;
row->rowtupdesc = CreateTemplateTupleDesc(numvars, false);
row->nfields = numvars;
row->fieldnames = palloc(numvars * sizeof(char *));
row = palloc0(sizeof(*row));
row->dtype = PLPGSQL_DTYPE_ROW;
+ row->refname = "(unnamed row)";
row->lineno = -1;
row->varnos = palloc(sizeof(int) * FUNC_MAX_ARGS);
new = palloc0(sizeof(PLpgSQL_row));
new->dtype = PLPGSQL_DTYPE_ROW;
+ new->refname = "(unnamed row)";
new->lineno = plpgsql_location_to_lineno(@1);
new->rowtupdesc = NULL;
new->nfields = list_length($2);
row = palloc0(sizeof(PLpgSQL_row));
row->dtype = PLPGSQL_DTYPE_ROW;
+ row->refname = "(unnamed row)";
row->lineno = plpgsql_location_to_lineno(initial_location);
row->rowtupdesc = NULL;
row->nfields = nfields;
row = palloc0(sizeof(PLpgSQL_row));
row->dtype = PLPGSQL_DTYPE_ROW;
+ row->refname = "(unnamed row)";
row->lineno = lineno;
row->rowtupdesc = NULL;
row->nfields = 1;
* Note that there's no way to name the row as such from PL/pgSQL code,
* so many functions don't need to support these.
*
- * refname, isconst, notnull, and default_val are unsupported (and hence
+ * That also means that there's no real name for the row variable, so we
+ * conventionally set refname to "(unnamed row)". We could leave it NULL,
+ * but it's too convenient to be able to assume that refname is valid in
+ * all variants of PLpgSQL_variable.
+ *
+ * isconst, notnull, and default_val are unsupported (and hence
* always zero/null) for a row. The member variables of a row should have
* been checked to be writable at compile time, so isconst is correctly set
* to false. notnull and default_val aren't applicable.