Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
Implement SUBSTRING with support for byte and character (UTF-8) sequences.
SUBSTRING ( expression , start, length )
Types:
expression: VARCHAR or VARBINARY
start: Literal BIGINT
length: Literal BIGINT
Returns: Same type as the expression argument
Arguments:
start: position within the expression value the return value will start from
length: number of subsequent characters or bytes to return.
Aliases:
SUBSTR
BYTE_SUBSTR
Return Value:
Returns the specified portion of the input string.
Notes on behavior:
- If the start position is negative, start from abs(start) characters from the end of the buffer.
- If no length is specified, continue to the end of the string.
- BYTE_SUBSTR always assumes a character is 8 bits, while SUBSTR accounts for UTF-8 character sequences.
- If the substring expression's length exceeds the value's upward bound, the
value's length will be used. - If the substring is invalid (e.g. negative length), return an empty string.