File tree Expand file tree Collapse file tree 3 files changed +76
-0
lines changed
Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Original file line number Diff line number Diff line change @@ -175,3 +175,52 @@ SELECT * FROM LONG_TEXT ORDER BY II DESC;
175175(3 rows)
176176
177177DROP TABLE LONG_TEXT;
178+
179+ -- rawtohex
180+ SELECT sys.rawtohex('\xDEADBEEF'::bytea);
181+ rawtohex
182+ ----------
183+ DEADBEEF
184+ (1 row)
185+
186+ SELECT sys.rawtohex('\xFF'::raw);
187+ rawtohex
188+ ----------
189+ FF
190+ (1 row)
191+
192+ SELECT sys.rawtohex('hello'::text);
193+ rawtohex
194+ ------------
195+ 68656C6C6F
196+ (1 row)
197+
198+ SELECT sys.rawtohex('hello'::varchar2);
199+ rawtohex
200+ ------------
201+ 68656C6C6F
202+ (1 row)
203+
204+ SELECT sys.rawtohex(sys.hextoraw('DEADBEEF'));
205+ rawtohex
206+ ----------
207+ DEADBEEF
208+ (1 row)
209+
210+ SELECT sys.rawtohex(NULL) IS NULL;
211+ ?column?
212+ ----------
213+ t
214+ (1 row)
215+
216+ SELECT sys.rawtohex('') IS NULL;
217+ ?column?
218+ ----------
219+ t
220+ (1 row)
221+
222+ SELECT sys.rawtohex('\x'::bytea) IS NULL;
223+ ?column?
224+ ----------
225+ t
226+ (1 row)
Original file line number Diff line number Diff line change @@ -44,3 +44,13 @@ SELECT * FROM LONG_TEXT ORDER BY II DESC;
4444
4545DROP TABLE LONG_TEXT;
4646
47+ -- rawtohex
48+ SELECT sys .rawtohex (' \x DEADBEEF' ::bytea );
49+ SELECT sys .rawtohex (' \x FF' ::raw);
50+ SELECT sys .rawtohex (' hello' ::text );
51+ SELECT sys .rawtohex (' hello' ::varchar2 );
52+ SELECT sys .rawtohex (sys .hextoraw (' DEADBEEF' ));
53+ SELECT sys .rawtohex (NULL ) IS NULL ;
54+ SELECT sys .rawtohex (' ' ) IS NULL ;
55+ SELECT sys .rawtohex (' \x ' ::bytea ) IS NULL ;
56+
Original file line number Diff line number Diff line change @@ -952,6 +952,23 @@ PARALLEL SAFE
952952STRICT
953953IMMUTABLE;
954954
955+ /* support rawtohex function for oracle compatibility */
956+ CREATE OR REPLACE FUNCTION sys .rawtohex(bytea )
957+ RETURNS varchar2
958+ AS $$ SELECT CASE WHEN pg_catalog .octet_length ($1 ) > 0 THEN upper (pg_catalog .encode ($1 , ' hex' ))::varchar2 END; $$
959+ LANGUAGE SQL
960+ PARALLEL SAFE
961+ STRICT
962+ IMMUTABLE;
963+
964+ CREATE OR REPLACE FUNCTION sys .rawtohex(text )
965+ RETURNS varchar2
966+ AS $$ SELECT CASE WHEN pg_catalog .octet_length ($1 ) > 0 THEN upper (pg_catalog .encode ($1 ::bytea , ' hex' ))::varchar2 END; $$
967+ LANGUAGE SQL
968+ PARALLEL SAFE
969+ STRICT
970+ IMMUTABLE;
971+
955972
956973/* **************************************************************
957974 *
You can’t perform that action at this time.
0 commit comments