]> granicus.if.org Git - postgresql/commitdiff
Don't crash when a rowtype argument to a plpgsql function is NULL.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 24 Feb 2004 01:44:47 +0000 (01:44 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 24 Feb 2004 01:44:47 +0000 (01:44 +0000)
Per report from Chris Campbell.

src/pl/plpgsql/src/pl_exec.c

index a69af302306155610d536883dc1fffc31796c745..0f42d04823612f94b1f4546d48713073fad9bccb 100644 (file)
@@ -3,7 +3,7 @@
  *                       procedural language
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.93 2003/10/01 21:47:42 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.93.2.1 2004/02/24 01:44:47 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;