aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-02-12 19:37:36 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-02-12 19:37:36 +0000
commit3ad7dbb1b93e809d882c683b1872620aec391a3c (patch)
tree5f5995e6a46712bbbd42465a3ea14770bcc719f4 /src
parent1b04b8f1bc0d98042f1e35231c55d23c81373090 (diff)
downloadpostgresql-3ad7dbb1b93e809d882c683b1872620aec391a3c.tar.gz
postgresql-3ad7dbb1b93e809d882c683b1872620aec391a3c.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.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index e15076a5a83..a271f57151c 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.254 2010/01/19 01:35:31 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.255 2010/02/12 19:37:36 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -3520,11 +3520,6 @@ exec_assign_value(PLpgSQL_execstate *estate,
*/
PLpgSQL_row *row = (PLpgSQL_row *) target;
- /* Source must be of RECORD or composite type */
- if (!type_is_rowtype(valtype))
- 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 */
@@ -3538,7 +3533,12 @@ 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 (!type_is_rowtype(valtype))
+ ereport(ERROR,
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ errmsg("cannot assign non-composite value to a row variable")));
+ /* Source is a tuple Datum, so safe to do this: */
td = DatumGetHeapTupleHeader(value);
/* Extract rowtype info and find a tupdesc */
tupType = HeapTupleHeaderGetTypeId(td);
@@ -3562,11 +3562,6 @@ exec_assign_value(PLpgSQL_execstate *estate,
*/
PLpgSQL_rec *rec = (PLpgSQL_rec *) target;
- /* Source must be of RECORD or composite type */
- if (!type_is_rowtype(valtype))
- 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 */
@@ -3580,7 +3575,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 (!type_is_rowtype(valtype))
+ ereport(ERROR,
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ errmsg("cannot assign non-composite value to a record variable")));
+
+ /* Source is a tuple Datum, so safe to do this: */
td = DatumGetHeapTupleHeader(value);
/* Extract rowtype info and find a tupdesc */
tupType = HeapTupleHeaderGetTypeId(td);
@@ -4759,6 +4760,10 @@ exec_move_row(PLpgSQL_execstate *estate,
{
value = (Datum) 0;
isnull = true;
+ /*
+ * InvalidOid is OK because exec_assign_value doesn't care
+ * about the type of a source NULL
+ */
valtype = InvalidOid;
}