827{
829
830 TupleDesc tupdesc;
831 HeapTuple tuple;
834 Datum result;
835
837
838
839 if (!AggCheckCallContext(fcinfo, NULL)) {
840 elog(ERROR, "RASTER_summaryStats_finalfn: Cannot be called in a non-aggregate context");
841 PG_RETURN_NULL();
842 }
843
844
845 if (PG_ARGISNULL(0))
846 PG_RETURN_NULL();
847
849
850 if (NULL == state) {
851 elog(ERROR, "RASTER_summaryStats_finalfn: Cannot compute coverage summary stats");
852 PG_RETURN_NULL();
853 }
854
855
858
861
862 else
864 }
865
866
867 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) {
869 ereport(ERROR, (
870 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
871 errmsg(
872 "function returning record called in context "
873 "that cannot accept type record"
874 )
875 ));
876 }
877
878 BlessTupleDesc(tupdesc);
879
881
882 values[0] = Int64GetDatum(state->
stats->
count);
884 values[1] = Float8GetDatum(state->
stats->
sum);
885 values[2] = Float8GetDatum(state->
stats->
mean);
887 values[4] = Float8GetDatum(state->
stats->
min);
888 values[5] = Float8GetDatum(state->
stats->
max);
889 }
890 else {
896 }
897
898
899 tuple = heap_form_tuple(tupdesc, values, nulls);
900
901
902 result = HeapTupleGetDatum(tuple);
903
904
905
906
907
908
909
910
911 PG_RETURN_DATUM(result);
912}
struct rtpg_summarystats_arg_t * rtpg_summarystats_arg
static void rtpg_summarystats_arg_destroy(rtpg_summarystats_arg arg)
#define POSTGIS_RT_DEBUG(level, msg)