chaingraph icon indicating copy to clipboard operation
chaingraph copied to clipboard

Postgres: add a native `reverse(bytea)` function

Open bitjson opened this issue 4 years ago • 0 comments

It would be nice if Postgres supported a native reverse(bytea) function. Currently we're manually reversing byteas with this plpgsql function (which is presumably somewhat slower than a native option?):

https://github.com/bitauth/chaingraph/blob/cbebedefea908957b0373d77a60ec17fdff2050b/images/hasura/hasura-data/migrations/default/1616195337538_init/up.sql#L719-L732

There doesn't seem to be a good reason why Postgres wouldn't support reversing bytea types natively. We might want to submit a patch. Looks like we'd need to add it to src/backend/utils/adt/varlena.c (see text_reverse).

bitjson avatar Nov 24 '21 07:11 bitjson