88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.254 2010/01/19 01:35:31 tgl Exp $
11+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.255 2010/02/12 19:37:36 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -3520,11 +3520,6 @@ exec_assign_value(PLpgSQL_execstate *estate,
35203520 */
35213521 PLpgSQL_row * row = (PLpgSQL_row * ) target ;
35223522
3523- /* Source must be of RECORD or composite type */
3524- if (!type_is_rowtype (valtype ))
3525- ereport (ERROR ,
3526- (errcode (ERRCODE_DATATYPE_MISMATCH ),
3527- errmsg ("cannot assign non-composite value to a row variable" )));
35283523 if (* isNull )
35293524 {
35303525 /* If source is null, just assign nulls to the row */
@@ -3538,7 +3533,12 @@ exec_assign_value(PLpgSQL_execstate *estate,
35383533 TupleDesc tupdesc ;
35393534 HeapTupleData tmptup ;
35403535
3541- /* Else source is a tuple Datum, safe to do this: */
3536+ /* Source must be of RECORD or composite type */
3537+ if (!type_is_rowtype (valtype ))
3538+ ereport (ERROR ,
3539+ (errcode (ERRCODE_DATATYPE_MISMATCH ),
3540+ errmsg ("cannot assign non-composite value to a row variable" )));
3541+ /* Source is a tuple Datum, so safe to do this: */
35423542 td = DatumGetHeapTupleHeader (value );
35433543 /* Extract rowtype info and find a tupdesc */
35443544 tupType = HeapTupleHeaderGetTypeId (td );
@@ -3562,11 +3562,6 @@ exec_assign_value(PLpgSQL_execstate *estate,
35623562 */
35633563 PLpgSQL_rec * rec = (PLpgSQL_rec * ) target ;
35643564
3565- /* Source must be of RECORD or composite type */
3566- if (!type_is_rowtype (valtype ))
3567- ereport (ERROR ,
3568- (errcode (ERRCODE_DATATYPE_MISMATCH ),
3569- errmsg ("cannot assign non-composite value to a record variable" )));
35703565 if (* isNull )
35713566 {
35723567 /* If source is null, just assign nulls to the record */
@@ -3580,7 +3575,13 @@ exec_assign_value(PLpgSQL_execstate *estate,
35803575 TupleDesc tupdesc ;
35813576 HeapTupleData tmptup ;
35823577
3583- /* Else source is a tuple Datum, safe to do this: */
3578+ /* Source must be of RECORD or composite type */
3579+ if (!type_is_rowtype (valtype ))
3580+ ereport (ERROR ,
3581+ (errcode (ERRCODE_DATATYPE_MISMATCH ),
3582+ errmsg ("cannot assign non-composite value to a record variable" )));
3583+
3584+ /* Source is a tuple Datum, so safe to do this: */
35843585 td = DatumGetHeapTupleHeader (value );
35853586 /* Extract rowtype info and find a tupdesc */
35863587 tupType = HeapTupleHeaderGetTypeId (td );
@@ -4759,6 +4760,10 @@ exec_move_row(PLpgSQL_execstate *estate,
47594760 {
47604761 value = (Datum ) 0 ;
47614762 isnull = true;
4763+ /*
4764+ * InvalidOid is OK because exec_assign_value doesn't care
4765+ * about the type of a source NULL
4766+ */
47624767 valtype = InvalidOid ;
47634768 }
47644769
0 commit comments