825{
827
828 TupleDesc tupdesc;
829 HeapTuple tuple;
833
835
836
837 if (!AggCheckCallContext(fcinfo, NULL)) {
838 elog(ERROR, "RASTER_summaryStats_finalfn: Cannot be called in a non-aggregate context");
839 PG_RETURN_NULL();
840 }
841
842
843 if (PG_ARGISNULL(0))
844 PG_RETURN_NULL();
845
847
848 if (NULL == state) {
849 elog(ERROR, "RASTER_summaryStats_finalfn: Cannot compute coverage summary stats");
850 PG_RETURN_NULL();
851 }
852
853
856
859
860 else
862 }
863
864
865 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) {
867 ereport(ERROR, (
868 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
869 errmsg(
870 "function returning record called in context "
871 "that cannot accept type record"
872 )
873 ));
874 }
875
876 BlessTupleDesc(tupdesc);
877
879
880 values[0] = Int64GetDatum(state->
stats->
count);
882 values[1] = Float8GetDatum(state->
stats->
sum);
883 values[2] = Float8GetDatum(state->
stats->
mean);
885 values[4] = Float8GetDatum(state->
stats->
min);
886 values[5] = Float8GetDatum(state->
stats->
max);
887 }
888 else {
894 }
895
896
897 tuple = heap_form_tuple(tupdesc, values, nulls);
898
899
900 result = HeapTupleGetDatum(tuple);
901
902
903
904
905
906
907
908
910}
char result[OUT_DOUBLE_BUFFER_SIZE]
struct rtpg_summarystats_arg_t * rtpg_summarystats_arg
static void rtpg_summarystats_arg_destroy(rtpg_summarystats_arg arg)
#define POSTGIS_RT_DEBUG(level, msg)