Re: [HACKERS] Invalid YAML output from EXPLAIN

From: Florian Weimer <fweimer(at)bfk(dot)de>
To: Greg Smith <greg(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Sabino Mullane <greg(at)turnstep(dot)com>, pgsql-hackers(at)postgresql(dot)org, pgsql-bugs(at)postgresql(dot)org
Subject: Re: [HACKERS] Invalid YAML output from EXPLAIN
Date: 2010-06-08 08:01:20
Message-ID: 82sk4yneb3.fsf@mid.bfk.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

* Greg Smith:

> Florian Weimer wrote:
>> It has been claimed before that YAML is a superset of JSON, so why
>> can't the YAML folks use the existing JSON output instead?
>>
>
> Because JSON just crosses the line where it feels like there's so much
> markup that people expect a tool is necessary to read it, which has
> always been the issue with XML too--bad human readability.

But YAML is not human-readable. There are human-readable subsets of
it, but the general serializers do not produce them, and specific
serializers are difficult to get right (as we've seen).

> EXPLAIN (FORMAT YAML) SELECT * FROM customers WHERE customerid>1000
> ORDER BY zip;
> QUERY PLAN
> -------------------------------------
> - Plan: +
> Node Type: Sort +
> Startup Cost: 4449.30 +
> Total Cost: 4496.80 +
> Plan Rows: 19000 +
> Plan Width: 268 +
> Sort Key: +
> - zip +
> Plans: +
> - Node Type: Seq Scan +
> Parent Relationship: Outer +
> Relation Name: customers +
> Alias: customers +
> Startup Cost: 0.00 +
> Total Cost: 726.00 +
> Plan Rows: 19000 +
> Plan Width: 268 +
> Filter: (customerid > 1000)

What does your parser do with this (equivalent but shorter) YAML
output?

- Plan: !!map
&0 Node Type: Sort
&1 Startup Cost: 4449.30
&2 Total Cost: 4496.80
&3 Plan Rows: &5 19000
&4 Plan Width: &6 268
Sort Key: ["zip"]
Plans: !!seq
- *0: Seq Scan
Parent Relationship: Outer
Relation Name: &7 customers
Alias: *7
*1: 0.00
*2: 726.00
*3: *5
*4: *6
Filter: (customerid > 1000)

Looking at the spec, it's rather difficult to come up with a readable
subset which can parsed easily and is general in the sense that it can
express empty strings, strings with embedded newlines, and so on.
YAML's rules for dealing with whitespace are fairly complex, but are
probably needed to get a more compact notation than JSON.

--
Florian Weimer <fweimer(at)bfk(dot)de>
BFK edv-consulting GmbH http://www.bfk.de/
Kriegsstraße 100 tel: +49-721-96201-1
D-76133 Karlsruhe fax: +49-721-96201-99

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Ovidiu Tanasiciuc 2010-06-08 11:03:37 BUG #5494: pg_dump dependiences sequence problem
Previous Message Bakkiya 2010-06-08 05:02:28 BUG #5493: Character Encoding is not happenning properly

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2010-06-08 09:32:00 Re: Functional dependencies and GROUP BY
Previous Message Pavel Stehule 2010-06-08 06:56:52 Re: Functional dependencies and GROUP BY