Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5b0fa0c

Browse files
committed
Fix make_tuple_from_row to support nested rowtypes, per gripe from
Roman Neuhauser. Update some obsolete comments for exec_eval_datum, too.
1 parentd6bc885 commit5b0fa0c

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

‎src/pl/plpgsql/src/pl_exec.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* procedural language
44
*
55
* 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 $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -3388,11 +3388,12 @@ exec_assign_value(PLpgSQL_execstate *estate,
33883388
*
33893389
* If expectedtypeid isn't InvalidOid, it is checked against the actual type.
33903390
*
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.
33933392
*
33943393
* 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.
33963397
*/
33973398
staticvoid
33983399
exec_eval_datum(PLpgSQL_execstate*estate,
@@ -3997,34 +3998,34 @@ make_tuple_from_row(PLpgSQL_execstate *estate,
39973998
intnatts=tupdesc->natts;
39983999
HeapTupletuple;
39994000
Datum*dvalues;
4000-
char*nulls;
4001+
bool*nulls;
40014002
inti;
40024003

40034004
if (natts!=row->nfields)
40044005
returnNULL;
40054006

40064007
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));
40094009

40104010
for (i=0;i<natts;i++)
40114011
{
4012-
PLpgSQL_var*var;
4012+
Oidfieldtypeid;
40134013

40144014
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+
}
40164019
if (row->varnos[i]<0)/* should not happen */
40174020
elog(ERROR,"dropped rowtype entry for non-dropped column");
40184021

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)
40214025
returnNULL;
4022-
dvalues[i]=var->value;
4023-
if (!var->isnull)
4024-
nulls[i]=' ';
40254026
}
40264027

4027-
tuple=heap_formtuple(tupdesc,dvalues,nulls);
4028+
tuple=heap_form_tuple(tupdesc,dvalues,nulls);
40284029

40294030
pfree(dvalues);
40304031
pfree(nulls);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp