6.11. Binary Functions and Operators
Binary Operators
The ||
operator performs concatenation.
Binary Functions
length
(binary) → bigintReturns the length of
binary
in bytes.concat
(binary1, …, binaryN) → varbinaryReturns the concatenation of
binary1
,binary2
,…
,binaryN
.This function provides the same functionality as theSQL-standard concatenation operator (||
).substr
(binary, start) → varbinaryReturns the rest of
binary
from the starting positionstart
,measured in bytes. Positions start with1
. A negative starting positionis interpreted as being relative to the end of the string.substr
(binary, start, length) → varbinaryReturns a substring from
binary
of lengthlength
from the startingpositionstart
, measured in bytes. Positions start with1
. Anegative starting position is interpreted as being relative to the end ofthe string.tobase64
(_binary) → varcharEncodes
binary
into a base64 string representation.frombase64
(_string) → varbinaryDecodes binary data from the base64 encoded
string
.tobase64url
(_binary) → varcharEncodes
binary
into a base64 string representation using the URL safe alphabet.frombase64url
(_string) → varbinaryDecodes binary data from the base64 encoded
string
using the URL safe alphabet.tohex
(_binary) → varcharEncodes
binary
into a hex string representation.fromhex
(_string) → varbinaryDecodes binary data from the hex encoded
string
.tobig_endian_64
(_bigint) → varbinaryEncodes
bigint
in a 64-bit 2’s complement big endian format.frombig_endian_64
(_binary) → bigintDecodes
bigint
value from a 64-bit 2’s complement big endianbinary
.tobig_endian_32
(_integer) → varbinaryEncodes
integer
in a 32-bit 2’s complement big endian format.frombig_endian_32
(_binary) → integerDecodes
integer
value from a 32-bit 2’s complement big endianbinary
.toieee754_32
(_real) → varbinaryEncodes
real
in a 32-bit big-endian binary according to IEEE 754 single-precision floating-point format.fromieee754_32
(_binary) → realDecodes the 32-bit big-endian
binary
in IEEE 754 single-precision floating-point format.toieee754_64
(_double) → varbinaryEncodes
double
in a 64-bit big-endian binary according to IEEE 754 double-precision floating-point format.fromieee754_64
(_binary) → doubleDecodes the 64-bit big-endian
binary
in IEEE 754 double-precision floating-point format.lpad
(binary, size, padbinary) → varbinaryLeft pads
binary
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) → varbinaryRight pads
binary
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) → bigintComputes the CRC-32 of
binary
. For general purpose hashing, usexxhash64()
, as it is much faster and produces a better quality hash.md5
(binary) → varbinaryComputes the md5 hash of
binary
.sha1
(binary) → varbinaryComputes the sha1 hash of
binary
.sha256
(binary) → varbinaryComputes the sha256 hash of
binary
.sha512
(binary) → varbinaryComputes the sha512 hash of
binary
.xxhash64
(binary) → varbinaryComputes the xxhash64 hash of
binary
.spookyhash_v2_32
(_binary) → varbinaryComputes the 32-bit SpookyHashV2 hash of
binary
.spookyhash_v2_64
(_binary) → varbinaryComputes the 64-bit SpookyHashV2 hash of
binary
.hmacmd5
(_binary, key) → varbinaryComputes HMAC with md5 of
binary
with the givenkey
.hmacsha1
(_binary, key) → varbinaryComputes HMAC with sha1 of
binary
with the givenkey
.hmacsha256
(_binary, key) → varbinaryComputes HMAC with sha256 of
binary
with the givenkey
.hmacsha512
(_binary, key) → varbinary- Computes HMAC with sha512 of
binary
with the givenkey
.