diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-02-12 19:38:00 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-02-12 19:38:00 +0000 |
commit | c53917dc66bb1df640636f96d7803e8ace2889d3 (patch) | |
tree | 7d5243b12e4226bff7a0aae6ac694723aac7dc79 /src | |
parent | 51e24cc249381ba09bd885296bb1db677d1f2bdf (diff) | |
download | postgresql-c53917dc66bb1df640636f96d7803e8ace2889d3.tar.gz postgresql-c53917dc66bb1df640636f96d7803e8ace2889d3.zip |
Don't choke when exec_move_row assigns a synthesized null to a column
that happens to be composite itself. Per bug #5314 from Oleg Serov.
Backpatch to 8.0 --- 7.4 has got too many other shortcomings in
composite-type support to make this worth worrying about in that branch.
Diffstat (limited to 'src')
-rw-r--r-- | src/pl/plpgsql/src/pl_exec.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index fd62d73174e..560639a87d3 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.180.2.11 2009/12/29 17:41:25 heikki Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.180.2.12 2010/02/12 19:38:00 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -3303,12 +3303,6 @@ exec_assign_value(PLpgSQL_execstate *estate, */ PLpgSQL_row *row = (PLpgSQL_row *) target; - /* Source must be of RECORD or composite type */ - if (!(valtype == RECORDOID || - get_typtype(valtype) == 'c')) - ereport(ERROR, - (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("cannot assign non-composite value to a row variable"))); if (*isNull) { /* If source is null, just assign nulls to the row */ @@ -3322,7 +3316,13 @@ exec_assign_value(PLpgSQL_execstate *estate, TupleDesc tupdesc; HeapTupleData tmptup; - /* Else source is a tuple Datum, safe to do this: */ + /* Source must be of RECORD or composite type */ + if (!(valtype == RECORDOID || + get_typtype(valtype) == 'c')) + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("cannot assign non-composite value to a row variable"))); + /* So source is a tuple Datum, safe to do this: */ td = DatumGetHeapTupleHeader(value); /* Extract rowtype info and find a tupdesc */ tupType = HeapTupleHeaderGetTypeId(td); @@ -3346,12 +3346,6 @@ exec_assign_value(PLpgSQL_execstate *estate, */ PLpgSQL_rec *rec = (PLpgSQL_rec *) target; - /* Source must be of RECORD or composite type */ - if (!(valtype == RECORDOID || - get_typtype(valtype) == 'c')) - ereport(ERROR, - (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("cannot assign non-composite value to a record variable"))); if (*isNull) { /* If source is null, just assign nulls to the record */ @@ -3365,7 +3359,13 @@ exec_assign_value(PLpgSQL_execstate *estate, TupleDesc tupdesc; HeapTupleData tmptup; - /* Else source is a tuple Datum, safe to do this: */ + /* Source must be of RECORD or composite type */ + if (!(valtype == RECORDOID || + get_typtype(valtype) == 'c')) + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("cannot assign non-composite value to a record variable"))); + /* So source is a tuple Datum, safe to do this: */ td = DatumGetHeapTupleHeader(value); /* Extract rowtype info and find a tupdesc */ tupType = HeapTupleHeaderGetTypeId(td); |