Re: Patch: Improve Boolean Predicate JSON Path Docs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David E(dot) Wheeler" <david(at)justatheory(dot)com>
Cc: Erik Wienhold <ewie(at)ewie(dot)name>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Patch: Improve Boolean Predicate JSON Path Docs
Date: 2024-01-19 21:15:26
Message-ID: 2860460.1705698926@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"David E. Wheeler" <david(at)justatheory(dot)com> writes:
> [ v7-0001-Improve-boolean-predicate-JSON-Path-docs.patch ]

I started to review this, and got bogged down at

@@ -17203,9 +17214,12 @@ array w/o UK? | t

<para>
For example, suppose you have some JSON data from a GPS tracker that you
- would like to parse, such as:
+ would like to parse, such as this JSON, set up as a
+ <link linkend="app-psql-meta-command-set"><application>psql</application>
+ <command>\set</command> variable</link> for use as <literal>:'json'</literal>
+ in the examples below:
<programlisting>
-{
+ \set json '{
"track": {
"segments": [
{

I find the textual change rather unwieldy, but the bigger problem is
that this example doesn't actually work. If you try to copy-and-paste
this into psql, you get "unterminated quoted string", because psql
metacommands can't span line boundaries.

Perhaps we could leave the existing display alone, and then add

To follow the examples below, paste this into psql:
<programlisting>
\set json '{ "track": { "segments": [ { "location": [ 47.763, 13.4034 ], "start time": "2018-10-14 10:05:14", "HR": 73 }, { "location": [ 47.706, 13.2635 ], "start time": "2018-10-14 10:39:21", "HR": 135 } ] }}'
</programlisting>
This will allow <literal>:'json'</literal> to be expanded into the
above JSON value, plus suitable quoting.

However, I'm not sure that's a great solution, because it's going to
line-wrap on most displays, making copy-and-paste a bit iffy.

I experimented with

SELECT '
... multiline json value ...
' AS json
\gexec

but that didn't seem to work either. Anybody have a better idea?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-01-19 21:22:09 Re: Patch: Improve Boolean Predicate JSON Path Docs
Previous Message Nathan Bossart 2024-01-19 20:46:36 Re: introduce dynamic shared memory registry