For example write encode(sha256('abc'), 'hex') to get a hex-encoded text representation, or decode(md5('abc'), 'hex') to get a bytea value.įunctions for converting strings between different character sets (encodings), and for representing arbitrary binary data in textual form, are shown in Table 9.13. Use the functions encode and decode to convert between the two. Functions get_bit and set_bit number bits from the right within each byte for example bit 0 is the least significant bit of the first byte, and bit 15 is the most significant bit of the second byte.įor historical reasons, the function md5 returns a hex-encoded value of type text whereas the SHA-2 functions return type bytea. Substr('\x1234567890'::bytea, 3, 2) → \x5678įunctions get_byte and set_byte number the first byte of a binary string as byte 0. (Same as substring( bytes from start for count).) Substr ( bytes bytea, start integer ) → byteaĮxtracts the substring of bytes starting at the start'th byte, and extending for count bytes if that is specified. Sets n'th byte in binary string to newvalue. Set_byte ( bytes bytea, n integer, newvalue integer ) → bytea Sets n'th bit in binary string to newvalue. Set_bit ( bytes bytea, n bigint, newvalue integer ) → bytea Returns the number of characters in the binary string, assuming that it is text in the given encoding.Ĭomputes the MD5 hash of the binary string, with the result written in hexadecimal. Length ( bytes bytea, encoding name ) → integer Returns the number of bytes in the binary string. Get_byte ( bytes bytea, n integer ) → integer Get_bit ( bytes bytea, n bigint ) → integer Returns the number of bits set in the binary string (also known as “ popcount”). Some of them are used internally to implement the SQL-standard string functions listed in Table 9.11. Trim(both from '\x1234567890'::bytea, '\x9012'::bytea) → \x345678Īdditional binary string manipulation functions are available and are listed in Table 9.12. This is a non-standard syntax for trim(). Trim ( bytes bytea, bytesremoved bytea ) → bytea Removes the longest string containing only bytes appearing in bytesremoved from the start, end, or both ends ( BOTH is the default) of bytes. Trim ( bytesremoved bytea FROM bytes bytea ) → bytea Substring ( bytes bytea ) → byteaĮxtracts the substring of bytes starting at the start'th byte if that is specified, and stopping after count bytes if that is specified. Removes the longest string containing only bytes appearing in bytesremoved from the end of bytes. Rtrim ( bytes bytea, bytesremoved bytea ) → bytea Returns first starting index of the specified substring within bytes, or zero if it's not present. Position ( substring bytea IN bytes bytea ) → integer If count is omitted, it defaults to the length of newsubstring. Replaces the substring of bytes that starts at the start'th byte and extends for count bytes with newsubstring. Overlay ( bytes bytea PLACING newsubstring bytea FROM start integer ) → bytea Returns number of bytes in the binary string. Removes the longest string containing only bytes appearing in bytesremoved from the start of bytes. Ltrim ( bytes bytea, bytesremoved bytea ) → bytea Removes the longest string containing only bytes appearing in bytesremoved from the start and end of bytes.ītrim('\x1234567890'::bytea, '\x9012'::bytea) → \x345678 Returns number of bits in the binary string (8 times the octet_length).ītrim ( bytes bytea, bytesremoved bytea ) → bytea
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |