summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-02-12 19:38:08 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-02-12 19:38:08 +0000
commit38a7ddc5f7d241a162a0aa57d0ba768f97d17264 (patch)
treed6d525acfb439335250a81a61e0913dc798f7aa8 /src
parent7b537a85408bdec6fad2ef21038e159173f54cea (diff)
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.c30
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 1b400341af4..3064c906bd5 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.154.2.9 2009/12/29 17:41:35 heikki Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.154.2.10 2010/02/12 19:38:08 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -3104,12 +3104,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 */
@@ -3123,7 +3117,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);
@@ -3148,12 +3148,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 */
@@ -3167,7 +3161,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);