aboutsummaryrefslogtreecommitdiff
path: root/doc/src/sgml/json.sgml
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-09-19 11:22:21 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2019-09-19 11:22:21 -0400
commit0a97edb12ec44f8d2d8828cbca6dd7639408ac88 (patch)
tree07d17ceefd31724792b0ab4cd90c67195626312d /doc/src/sgml/json.sgml
parente1c8743e6ccd262df84fa2d80bf21d72115ac0d6 (diff)
downloadpostgresql-0a97edb12ec44f8d2d8828cbca6dd7639408ac88.tar.gz
postgresql-0a97edb12ec44f8d2d8828cbca6dd7639408ac88.zip
Doc: improve documentation around jsonpath regular expressions.
Provide some documentation about the differences between XQuery regular expressions and those supported by Spencer's regex engine. Since SQL now exposes XQuery regexps with the LIKE_REGEX operator, I made this a standalone section designed to help somebody who has to translate a LIKE_REGEX query to Postgres. (Eventually we might extend Spencer's engine to allow precise implementation of XQuery, but not today.) Reference that in the jsonpath docs, provide definitions of the XQuery flag letters, and add a description of the JavaScript-inspired string literal syntax used within jsonpath. Also point out explicitly that backslashes used within like_regex patterns will need to be doubled. This also syncs the docs with the decision implemented in commit d5b90cd64 to desupport XQuery's 'x' flag for now. Jonathan Katz and Tom Lane Discussion: https://postgr.es/m/CAPpHfdvDci4iqNF9fhRkTqhe-5_8HmzeLt56drH%2B_Rv2rNRqfg@mail.gmail.com
Diffstat (limited to 'doc/src/sgml/json.sgml')
-rw-r--r--doc/src/sgml/json.sgml33
1 files changed, 26 insertions, 7 deletions
diff --git a/doc/src/sgml/json.sgml b/doc/src/sgml/json.sgml
index 4f566a4c8d6..45b22b6e2d2 100644
--- a/doc/src/sgml/json.sgml
+++ b/doc/src/sgml/json.sgml
@@ -666,13 +666,32 @@ SELECT jdoc-&gt;'guid', jdoc-&gt;'name' FROM api WHERE jdoc @&gt; '{"tags": ["qu
</itemizedlist>
<para>
- An SQL/JSON path expression is an SQL character string literal,
- so it must be enclosed in single quotes when passed to an SQL/JSON
- query function. Following the JavaScript
- conventions, character string literals within the path expression
- must be enclosed in double quotes. Any single quotes within this
- character string literal must be escaped with a single quote
- by the SQL convention.
+ An SQL/JSON path expression is typically written in an SQL query as an
+ SQL character string literal, so it must be enclosed in single quotes,
+ and any single quotes desired within the value must be doubled
+ (see <xref linkend="sql-syntax-strings"/>).
+ Some forms of path expressions require string literals within them.
+ These embedded string literals follow JavaScript/ECMAScript conventions:
+ they must be surrounded by double quotes, and backslash escapes may be
+ used within them to represent otherwise-hard-to-type characters.
+ In particular, the way to write a double quote within an embedded string
+ literal is <literal>\"</literal>, and to write a backslash itself, you
+ must write <literal>\\</literal>. Other special backslash sequences
+ include those recognized in JSON strings:
+ <literal>\b</literal>,
+ <literal>\f</literal>,
+ <literal>\n</literal>,
+ <literal>\r</literal>,
+ <literal>\t</literal>,
+ <literal>\v</literal>
+ for various ASCII control characters, and
+ <literal>\u<replaceable>NNNN</replaceable></literal> for a Unicode
+ character identified by its 4-hex-digit code point. The backslash
+ syntax also includes two cases not allowed by JSON:
+ <literal>\x<replaceable>NN</replaceable></literal> for a character code
+ written with only two hex digits, and
+ <literal>\u{<replaceable>N...</replaceable>}</literal> for a character
+ code written with 1 to 6 hex digits.
</para>
<para>