From 55fb17273983d81838ed1280b87fb2ec7b9c775e Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 24 Feb 2004 01:44:33 +0000 Subject: [PATCH] Don't crash when a rowtype argument to a plpgsql function is NULL. Per report from Chris Campbell. --- src/pl/plpgsql/src/pl_exec.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 27142aa2bf..8c104f6363 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.95 2004/02/03 17:34:04 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.96 2004/02/24 01:44:33 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -262,10 +262,18 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo) HeapTuple tup; TupleDesc tupdesc; - Assert(slot != NULL && !fcinfo->argnull[i]); - tup = slot->val; - tupdesc = slot->ttc_tupleDescriptor; - exec_move_row(&estate, NULL, row, tup, tupdesc); + if (!fcinfo->argnull[i]) + { + Assert(slot != NULL); + tup = slot->val; + tupdesc = slot->ttc_tupleDescriptor; + exec_move_row(&estate, NULL, row, tup, tupdesc); + } + else + { + /* If arg is null, treat it as an empty row */ + exec_move_row(&estate, NULL, row, NULL, NULL); + } } break; -- GitLab