What are you trying to apply it to? I see array_append() in src/backend/utils/adt/array_userfuncs.c in HEAD. Also, are you checking the 1.1 version of the patch?
I tested old version. 1.1. looks well.
It is hard to believe how it is fast
I use buble sort for plpgsql benchmarking. Following variant is suboptimal (but it is perfect for this test)
CREATE OR REPLACE FUNCTION public.buble(a anyarray, OUT r anyarray) RETURNS anyarray LANGUAGE plpgsql AS $function$ DECLARE aux r%type; sorted bool := false; BEGIN r := a; WHILE NOT sorted LOOP sorted := true; FOR i IN array_lower(a,1) .. array_upper(a,1) - 1 LOOP IF r[i] > r[i+1] THEN sorted := false; aux[1] := r[i]; r[i] := r[i+1]; r[i+1] := aux[1]; END IF; END LOOP; END LOOP; END; $function$
CREATE OR REPLACE FUNCTION public.array_generator(integer, anyelement, OUT r anyarray) RETURNS anyarray LANGUAGE plpgsql AS $function$ BEGIN r := (SELECT ARRAY(SELECT random()*$2 FROM generate_series(1,$1))); END; $function$
Test for 3000 elements:
Original Patch
Integer 55sec 8sec
Numeric 341sec 8sec
Quicksort is about 3x faster -- so a benefit of this patch is clear.