mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
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.
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.244.2.2 2009/12/29 17:41:09 heikki Exp $
|
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.244.2.3 2010/02/12 19:37:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -3510,11 +3510,6 @@ exec_assign_value(PLpgSQL_execstate *estate,
|
|||||||
*/
|
*/
|
||||||
PLpgSQL_row *row = (PLpgSQL_row *) target;
|
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 (*isNull)
|
||||||
{
|
{
|
||||||
/* If source is null, just assign nulls to the row */
|
/* If source is null, just assign nulls to the row */
|
||||||
@ -3528,7 +3523,12 @@ exec_assign_value(PLpgSQL_execstate *estate,
|
|||||||
TupleDesc tupdesc;
|
TupleDesc tupdesc;
|
||||||
HeapTupleData tmptup;
|
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);
|
td = DatumGetHeapTupleHeader(value);
|
||||||
/* Extract rowtype info and find a tupdesc */
|
/* Extract rowtype info and find a tupdesc */
|
||||||
tupType = HeapTupleHeaderGetTypeId(td);
|
tupType = HeapTupleHeaderGetTypeId(td);
|
||||||
@ -3552,11 +3552,6 @@ exec_assign_value(PLpgSQL_execstate *estate,
|
|||||||
*/
|
*/
|
||||||
PLpgSQL_rec *rec = (PLpgSQL_rec *) target;
|
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 (*isNull)
|
||||||
{
|
{
|
||||||
/* If source is null, just assign nulls to the record */
|
/* If source is null, just assign nulls to the record */
|
||||||
@ -3570,7 +3565,13 @@ exec_assign_value(PLpgSQL_execstate *estate,
|
|||||||
TupleDesc tupdesc;
|
TupleDesc tupdesc;
|
||||||
HeapTupleData tmptup;
|
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);
|
td = DatumGetHeapTupleHeader(value);
|
||||||
/* Extract rowtype info and find a tupdesc */
|
/* Extract rowtype info and find a tupdesc */
|
||||||
tupType = HeapTupleHeaderGetTypeId(td);
|
tupType = HeapTupleHeaderGetTypeId(td);
|
||||||
@ -4639,6 +4640,10 @@ exec_move_row(PLpgSQL_execstate *estate,
|
|||||||
{
|
{
|
||||||
value = (Datum) 0;
|
value = (Datum) 0;
|
||||||
isnull = true;
|
isnull = true;
|
||||||
|
/*
|
||||||
|
* InvalidOid is OK because exec_assign_value doesn't care
|
||||||
|
* about the type of a source NULL
|
||||||
|
*/
|
||||||
valtype = InvalidOid;
|
valtype = InvalidOid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user