1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-21 05:21:08 +03:00

Add reverse(bytea).

This commit introduces a function for reversing the order of the
bytes in binary strings.

Bumps catversion.

Author: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CAJ7c6TMe0QVRuNssUArbMi0bJJK32%2BzNA3at5m3osrBQ25MHuw%40mail.gmail.com
This commit is contained in:
Nathan Bossart
2025-03-13 11:20:53 -05:00
parent bb25276205
commit 0697b23906
6 changed files with 64 additions and 1 deletions

View File

@@ -236,6 +236,24 @@ SELECT E'De\\678dBeEf'::bytea;
ERROR: invalid input syntax for type bytea
LINE 1: SELECT E'De\\678dBeEf'::bytea;
^
SELECT reverse(''::bytea);
reverse
---------
\x
(1 row)
SELECT reverse('\xaa'::bytea);
reverse
---------
\xaa
(1 row)
SELECT reverse('\xabcd'::bytea);
reverse
---------
\xcdab
(1 row)
SET bytea_output TO escape;
SELECT E'\\xDeAdBeEf'::bytea;
bytea

View File

@@ -77,6 +77,10 @@ SELECT E'De\123dBeEf'::bytea;
SELECT E'De\\123dBeEf'::bytea;
SELECT E'De\\678dBeEf'::bytea;
SELECT reverse(''::bytea);
SELECT reverse('\xaa'::bytea);
SELECT reverse('\xabcd'::bytea);
SET bytea_output TO escape;
SELECT E'\\xDeAdBeEf'::bytea;
SELECT E'\\x De Ad Be Ef '::bytea;