I wrote:
> Pavel Stehule <[email protected]> writes:
>> I found two parts
> Thanks for the report, will push something.
On closer look, I'm not sure that these are the only places that are
assuming that any PLpgSQL_variable struct has a refname. What seems
like a safer answer is to make sure they all do, more or less as
attached.
regards, tom lane
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
index 721234d..59460d2 100644
*** a/src/pl/plpgsql/src/pl_comp.c
--- b/src/pl/plpgsql/src/pl_comp.c
*************** build_row_from_vars(PLpgSQL_variable **v
*** 1896,1901 ****
--- 1896,1903 ----
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 *));
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 574234d..4552638 100644
*** a/src/pl/plpgsql/src/pl_exec.c
--- b/src/pl/plpgsql/src/pl_exec.c
*************** exec_stmt_call(PLpgSQL_execstate *estate
*** 2205,2210 ****
--- 2205,2211 ----
row = palloc0(sizeof(*row));
row->dtype = PLPGSQL_DTYPE_ROW;
+ row->refname = "(unnamed row)";
row->lineno = -1;
row->varnos = palloc(sizeof(int) * FUNC_MAX_ARGS);
diff --git a/src/pl/plpgsql/src/pl_gram.y b/src/pl/plpgsql/src/pl_gram.y
index b59869a..68e399f 100644
*** a/src/pl/plpgsql/src/pl_gram.y
--- b/src/pl/plpgsql/src/pl_gram.y
*************** decl_cursor_args :
*** 613,618 ****
--- 613,619 ----
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);
*************** read_into_scalar_list(char *initial_name
*** 3526,3531 ****
--- 3527,3533 ----
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;
*************** make_scalar_list1(char *initial_name,
*** 3560,3565 ****
--- 3562,3568 ----
row = palloc0(sizeof(PLpgSQL_row));
row->dtype = PLPGSQL_DTYPE_ROW;
+ row->refname = "(unnamed row)";
row->lineno = lineno;
row->rowtupdesc = NULL;
row->nfields = 1;
diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h
index 4a4c7cb..f6c35a5 100644
*** a/src/pl/plpgsql/src/plpgsql.h
--- b/src/pl/plpgsql/src/plpgsql.h
*************** typedef struct PLpgSQL_var
*** 326,332 ****
* 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
* 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.
--- 326,337 ----
* 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.
*
! * 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.