enough, there isn't a C-based reverse() function.
A search turns up pl/pgsql and SQL implementations:
create or replace function reverse_string(text) returns text as $$
incoming alias for $1;
reversed_string = '''';
for i in reverse char_length(incoming)..1 loop
reversed_string = reversed_string || substring(incoming from i for 1);
CREATE OR REPLACE FUNCTION reverse(TEXT) RETURNS TEXT AS $$
( SELECT substring($1, s.i,1) FROM generate_series(length($1), 1, -1) AS s(i) ),
$$ LANGUAGE SQL IMMUTABLE;
Unfortunately, neither is particularly fast. This should be
"blinding-quick" in C, in comparison; reversing a set of bytes should
be able to be done mighty quick!
(Aside: presumably we could walk thru the string destructively,
in-place, swapping bytes; I think that would be theoretically
I could probably add this in as an SPI() function; is there a good
reason to try to avoid doing so?
output = reverse("ofni.sesabatadxunil" "@" "enworbbc")
"Consistency is the single most important aspect of *ideology.*
Reality is not nearly so consistent." - <email@example.com>