|
33 | 33 | * ENHANCEMENTS, OR MODIFICATIONS.
|
34 | 34 | *
|
35 | 35 | * IDENTIFICATION
|
36 |
| - * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.70 2005/03/29 00:17:20 tgl Exp $ |
| 36 | + * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.71 2005/04/01 19:34:06 tgl Exp $ |
37 | 37 | *
|
38 | 38 | **********************************************************************/
|
39 | 39 |
|
@@ -409,21 +409,16 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo)
|
409 | 409 | * NB: copy the result if needed for any great length of time
|
410 | 410 | */
|
411 | 411 | static TupleDesc
|
412 |
| -get_function_tupdesc(Oid result_type, ReturnSetInfo *rsinfo) |
| 412 | +get_function_tupdesc(FunctionCallInfo fcinfo) |
413 | 413 | {
|
414 |
| - if (result_type == RECORDOID) |
415 |
| - { |
416 |
| - /* We must get the information from call context */ |
417 |
| - if (!rsinfo || !IsA(rsinfo, ReturnSetInfo) || |
418 |
| - rsinfo->expectedDesc == NULL) |
419 |
| - ereport(ERROR, |
420 |
| - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
421 |
| - errmsg("function returning record called in context " |
422 |
| - "that cannot accept type record"))); |
423 |
| - return rsinfo->expectedDesc; |
424 |
| - } |
425 |
| - else /* ordinary composite type */ |
426 |
| - return lookup_rowtype_tupdesc(result_type, -1); |
| 414 | + TupleDesc result; |
| 415 | + |
| 416 | + if (get_call_result_type(fcinfo, NULL, &result) != TYPEFUNC_COMPOSITE) |
| 417 | + ereport(ERROR, |
| 418 | + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
| 419 | + errmsg("function returning record called in context " |
| 420 | + "that cannot accept type record"))); |
| 421 | + return result; |
427 | 422 | }
|
428 | 423 |
|
429 | 424 | /**********************************************************************
|
@@ -897,8 +892,7 @@ plperl_func_handler(PG_FUNCTION_ARGS)
|
897 | 892 |
|
898 | 893 | /* Cache a copy of the result's tupdesc and attinmeta */
|
899 | 894 | oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
|
900 |
| - tupdesc = get_function_tupdesc(prodesc->result_oid, |
901 |
| - (ReturnSetInfo *) fcinfo->resultinfo); |
| 895 | + tupdesc = get_function_tupdesc(fcinfo); |
902 | 896 | tupdesc = CreateTupleDescCopy(tupdesc);
|
903 | 897 | funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);
|
904 | 898 | MemoryContextSwitchTo(oldcontext);
|
@@ -1003,8 +997,7 @@ plperl_func_handler(PG_FUNCTION_ARGS)
|
1003 | 997 | /*
|
1004 | 998 | * XXX should cache the attinmeta data instead of recomputing
|
1005 | 999 | */
|
1006 |
| - td = get_function_tupdesc(prodesc->result_oid, |
1007 |
| - (ReturnSetInfo *) fcinfo->resultinfo); |
| 1000 | + td = get_function_tupdesc(fcinfo); |
1008 | 1001 | /* td = CreateTupleDescCopy(td); */
|
1009 | 1002 | attinmeta = TupleDescGetAttInMetadata(td);
|
1010 | 1003 |
|
|
0 commit comments