[MDEV-7822] PostgreSQL compatible E-strings Created: 2015-03-23  Updated: 2022-03-24

Status: Open
Project: MariaDB Server
Component/s: None
Fix Version/s: None

Type: Task Priority: Minor
Reporter: Alexander Barkov Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: Compatibility


 Description   

Implement PostgreSQL compatible escaped strings, which will depend neither on the current NO_BACKSLASH_ESCAPE flag in sql_mode nor on the current character_set_client setting.

Example:

SELECT E'some string with C-alike escapes, e.g. \r\n \t \123 \xFF';

The returned data type should be BLOB.
We'll support only sinlge-quoted string.
This should return a syntax error:

SELECT E"a string in double quotes"

The syntax rules are described here:
http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS

PostgreSQL also accepts "escape" string constants, which are an extension to the SQL standard. An escape string constant is specified by writing the letter E (upper or lower case) just before the opening single quote, e.g. E'foo'. (When continuing an escape string constant across lines, write E only before the first opening quote.) Within an escape string, a backslash character () begins a C-like backslash escape sequence, in which the combination of backslash and following character(s) represents a special byte value. \b is a backspace, \f is a form feed, \n is a newline, \r is a carriage return, \t is a tab. Also supported are \digits, where digits represents an octal byte value, and \xhexdigits, where hexdigits represents a hexadecimal byte value. (It is your responsibility that the byte sequences you create are valid characters in the server character set encoding.) Any other character following a backslash is taken literally. Thus, to include a backslash character, write two backslashes (
). Also, a single quote can be included in an escape string by writing \', in addition to the normal way of ''.


Generated at Thu Feb 08 07:22:31 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.