Re: Invalid YAML output from EXPLAIN

From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Invalid YAML output from EXPLAIN
Date: 2010-06-07 13:59:59
Message-ID: c7eb14d5c80bd09b647e3143e0d7a77d@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

Dean Rasheed wrote:
...
> So the current code in escape_yaml() is inadequate for producing valid
> YAML. I think it would have to also consider at least the following
> characters as special "-" ":" "[" "]" "{" "}" "," "\"" "'"
> "|" "*" "&". Technically, it would also need to trap empty strings,
> and strings with leading or trailing whitespace.
>
> Making escape_yaml() completely bulletproof with this approach would
> be quite difficult, and (IMO) not worth the effort
...

Doesn't seem like a lot of effort to me. You've already laid out most of
the exceptions above, although they require a few tweaks.
The rules should be:

Requires quoting only if the first character:
& * ! | > ' " % @ ` #

Same as above, but no quoting if the second character is "safe":
- ? :

Always requires quoting:
":<space>" "<space>#" aka ': ' ' #'

Always requires quoting:
, [ ] { }

Always require quoting:
(leading space) (trailing space) (empty string)

See:
http://yaml.org/spec/1.2/spec.html section 5.3 and 7.3.3

- --
Greg Sabino Mullane greg(at)turnstep(dot)com
End Point Corporation http://www.endpoint.com/
PGP Key: 0x14964AC8 201006070943
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAkwM+wAACgkQvJuQZxSWSsgWZACcCgb0rDvA6ZVhHId/q568gBGo
sjgAoLY7HbkI7sRpO45vi0jSRJ2Fiytk
=v7T/
-----END PGP SIGNATURE-----

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2010-06-07 14:18:00 Re: Invalid YAML output from EXPLAIN
Previous Message Farid Zidan 2010-06-07 11:32:05 Re: BUG #5490: Using distinct for select list causes insert of timestamp string literal to fail

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-06-07 14:18:00 Re: Invalid YAML output from EXPLAIN
Previous Message Fujii Masao 2010-06-07 13:35:10 Re: [COMMITTERS] pgsql: Add current WAL end (as seen by walsender, ie, GetWriteRecPtr()