|
3 | 3 | * procedural language |
4 | 4 | * |
5 | 5 | * IDENTIFICATION |
6 | | - * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.151 2005/07/28 07:51:13 neilc Exp $ |
| 6 | + * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.152 2005/09/13 16:16:17 tgl Exp $ |
7 | 7 | * |
8 | 8 | * This software is copyrighted by Jan Wieck - Hamburg. |
9 | 9 | * |
@@ -3388,11 +3388,12 @@ exec_assign_value(PLpgSQL_execstate *estate, |
3388 | 3388 | * |
3389 | 3389 | * If expectedtypeid isn't InvalidOid, it is checked against the actual type. |
3390 | 3390 | * |
3391 | | - * This obviously only handles scalar datums (not whole records or rows); |
3392 | | - * at present it doesn't need to handle PLpgSQL_expr datums, either. |
| 3391 | + * At present this doesn't handle PLpgSQL_expr or PLpgSQL_arrayelem datums. |
3393 | 3392 | * |
3394 | 3393 | * NOTE: caller must not modify the returned value, since it points right |
3395 | | - * at the stored value in the case of pass-by-reference datatypes. |
| 3394 | + * at the stored value in the case of pass-by-reference datatypes. In some |
| 3395 | + * cases we have to palloc a return value, and in such cases we put it into |
| 3396 | + * the estate's short-term memory context. |
3396 | 3397 | */ |
3397 | 3398 | staticvoid |
3398 | 3399 | exec_eval_datum(PLpgSQL_execstate*estate, |
@@ -3997,34 +3998,34 @@ make_tuple_from_row(PLpgSQL_execstate *estate, |
3997 | 3998 | intnatts=tupdesc->natts; |
3998 | 3999 | HeapTupletuple; |
3999 | 4000 | Datum*dvalues; |
4000 | | -char*nulls; |
| 4001 | +bool*nulls; |
4001 | 4002 | inti; |
4002 | 4003 |
|
4003 | 4004 | if (natts!=row->nfields) |
4004 | 4005 | returnNULL; |
4005 | 4006 |
|
4006 | 4007 | dvalues= (Datum*)palloc0(natts*sizeof(Datum)); |
4007 | | -nulls= (char*)palloc(natts*sizeof(char)); |
4008 | | -MemSet(nulls,'n',natts); |
| 4008 | +nulls= (bool*)palloc(natts*sizeof(bool)); |
4009 | 4009 |
|
4010 | 4010 | for (i=0;i<natts;i++) |
4011 | 4011 | { |
4012 | | -PLpgSQL_var*var; |
| 4012 | +Oidfieldtypeid; |
4013 | 4013 |
|
4014 | 4014 | if (tupdesc->attrs[i]->attisdropped) |
4015 | | -continue;/* leave the column as null */ |
| 4015 | +{ |
| 4016 | +nulls[i]= true;/* leave the column as null */ |
| 4017 | +continue; |
| 4018 | +} |
4016 | 4019 | if (row->varnos[i]<0)/* should not happen */ |
4017 | 4020 | elog(ERROR,"dropped rowtype entry for non-dropped column"); |
4018 | 4021 |
|
4019 | | -var= (PLpgSQL_var*) (estate->datums[row->varnos[i]]); |
4020 | | -if (var->datatype->typoid!=tupdesc->attrs[i]->atttypid) |
| 4022 | +exec_eval_datum(estate,estate->datums[row->varnos[i]], |
| 4023 | +InvalidOid,&fieldtypeid,&dvalues[i],&nulls[i]); |
| 4024 | +if (fieldtypeid!=tupdesc->attrs[i]->atttypid) |
4021 | 4025 | returnNULL; |
4022 | | -dvalues[i]=var->value; |
4023 | | -if (!var->isnull) |
4024 | | -nulls[i]=' '; |
4025 | 4026 | } |
4026 | 4027 |
|
4027 | | -tuple=heap_formtuple(tupdesc,dvalues,nulls); |
| 4028 | +tuple=heap_form_tuple(tupdesc,dvalues,nulls); |
4028 | 4029 |
|
4029 | 4030 | pfree(dvalues); |
4030 | 4031 | pfree(nulls); |
|