6.11. Binary Functions and Operators
Binary Operators
The ||
operator performs concatenation.
Binary Functions
length
(binary) → bigint
Returns the length ofbinary
in bytes.
concat
(binary1, …, binaryN) → varbinary
Returns the concatenation ofbinary1
,binary2
,…
,binaryN
.This function provides the same functionality as theSQL-standard concatenation operator (||
).
tobase64
(_binary) → varchar
Encodesbinary
into a base64 string representation.
frombase64
(_string) → varbinary
Decodes binary data from the base64 encodedstring
.
tobase64url
(_binary) → varchar
Encodesbinary
into a base64 string representation using the URL safe alphabet.
frombase64url
(_string) → varbinary
Decodes binary data from the base64 encodedstring
using the URL safe alphabet.
tohex
(_binary) → varchar
Encodesbinary
into a hex string representation.
fromhex
(_string) → varbinary
Decodes binary data from the hex encodedstring
.
tobig_endian_64
(_bigint) → varbinary
Encodesbigint
in a 64-bit 2’s complement big endian format.
frombig_endian_64
(_binary) → bigint
Decodesbigint
value from a 64-bit 2’s complement big endianbinary
.
tobig_endian_32
(_integer) → varbinary
Encodesinteger
in a 32-bit 2’s complement big endian format.
frombig_endian_32
(_binary) → integer
Decodesinteger
value from a 32-bit 2’s complement big endianbinary
.
toieee754_32
(_real) → varbinary
Encodesreal
in a 32-bit big-endian binary according to IEEE 754 single-precision floating-point format.
fromieee754_32
(_binary) → real
Decodes the 32-bit big-endianbinary
in IEEE 754 single-precision floating-point format.
toieee754_64
(_double) → varbinary
Encodesdouble
in a 64-bit big-endian binary according to IEEE 754 double-precision floating-point format.
fromieee754_64
(_binary) → double
Decodes the 64-bit big-endianbinary
in IEEE 754 double-precision floating-point format.
lpad
(binary, size, padbinary) → varbinary
Left padsbinary
tosize
bytes withpadbinary
.Ifsize
is less than the length ofbinary
, the result istruncated tosize
characters.size
must not be negativeandpadbinary
must be non-empty.
rpad
(binary, size, padbinary) → varbinary
Right padsbinary
tosize
bytes withpadbinary
.Ifsize
is less than the length ofbinary
, the result istruncated tosize
characters.size
must not be negativeandpadbinary
must be non-empty.
crc32
(binary) → bigint
Computes the CRC-32 ofbinary
. For general purpose hashing, usexxhash64()
, as it is much faster and produces a better quality hash.
md5
(binary) → varbinary
Computes the md5 hash ofbinary
.
sha1
(binary) → varbinary
Computes the sha1 hash ofbinary
.
sha256
(binary) → varbinary
Computes the sha256 hash ofbinary
.
sha512
(binary) → varbinary
Computes the sha512 hash ofbinary
.
xxhash64
(binary) → varbinary
Computes the xxhash64 hash ofbinary
.
hmacmd5
(_binary, key) → varbinary
Computes HMAC with md5 ofbinary
with the givenkey
.
hmacsha1
(_binary, key) → varbinary
Computes HMAC with sha1 ofbinary
with the givenkey
.
hmacsha256
(_binary, key) → varbinary
Computes HMAC with sha256 ofbinary
with the givenkey
.
hmacsha512
(_binary, key) → varbinary
Computes HMAC with sha512 ofbinary
with the givenkey
.