Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-5305

Character literals with C-style escapes

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.33.0
    • core

    Description

      Support string constants with c-style escapes. Example:

      select e'\u0061\x61\141' as col1;
       col1 
      ------
       aaa
      (1 row)
      

      From PostgreSQL documentation 4.1.2.2. String Constants With C-Style Escapes:

      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) represent a special byte value, as shown in Table:

      Backslash Escape Sequence Interpretation
      \b backspace
      \f form feed
      \n newline
      \r carriage return
      \t tab
      \o, \oo, \ooo (o = 0–7) octal byte value
      \xh, \xhh (h = 0–9, A–F) hexadecimal byte value
      \uxxxx, \Uxxxxxxxx (x = 0–9, A–F) 16 or 32-bit hexadecimal Unicode character value

      I suggest to not introduce any configuration flags for this feature because it seems like it does not contradict with any SQL dialect and it shouldn't slow down queries parsing.

      Attachments

        Issue Links

          Activity

            People

              dmsysolyatin Dmitry Sysolyatin
              dmsysolyatin Dmitry Sysolyatin
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m