575{
576 FuncCallContext *funcctx;
577 MemoryContext oldcontext;
580
581
582
583
584
585
586
587 if (SRF_IS_FIRSTCALL())
588 {
589 funcctx = SRF_FIRSTCALL_INIT();
590 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
591
592
593
594
595
596
601
602
603
604
605
606
607 if (get_call_result_type(fcinfo, 0, &funcctx->tuple_desc) != TYPEFUNC_COMPOSITE)
608 {
609 ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
610 errmsg("%s called with incompatible return type", __func__)));
611 }
612
613 BlessTupleDesc(funcctx->tuple_desc);
614 funcctx->user_fctx = state;
615 MemoryContextSwitchTo(oldcontext);
616 }
617
618
619 funcctx = SRF_PERCALL_SETUP();
620 state = funcctx->user_fctx;
621
622
624 {
625 SRF_RETURN_DONE(funcctx);
626 }
627
628
631 funcctx->tuple_desc);
632
634 SRF_RETURN_NEXT(funcctx,
result);
635
636
637 SRF_RETURN_DONE(funcctx);
638}
char result[OUT_DOUBLE_BUFFER_SIZE]
static void srs_state_codes(const char *auth_name, struct srs_data *state)
static struct srs_data * srs_state_init()
static Datum srs_tuple_from_entry(const struct srs_entry *entry, TupleDesc tuple_desc)
struct srs_entry * entries