Re: hstore parser incorrectly handles malformed input - Mailing list pgsql-bugs

From Alex Hunsaker
Subject Re: hstore parser incorrectly handles malformed input
Date
Msg-id CAFaPBrSBpeQNkr+r5COMrE83ukWEY5+icp-=o2Sr4cZJjr3EXg@mail.gmail.com
Whole thread Raw
In response to Re: hstore parser incorrectly handles malformed input  (Ryan Kelly <rpkelly22@gmail.com>)
List pgsql-bugs
On Sat, Apr 28, 2012 at 17:20, Ryan Kelly <rpkelly22@gmail.com> wrote:

> I don't think any language supports the empty key edge case in this way.
> The only language I know of that will let you get away with it is Perl,
> and in that case you get undef, not the empty string, and it's a warning
> if you have warnings on:
>
> $ use warnings;
> $ my $h = { 1 => };
> Odd number of elements in anonymous hash

Well... kind of but not really, perl (as usual) is a bit funky here.
Try it with more than one key. What ends up happening is the 2nd key
is used as the first keys value... Surprise! You also don't get the
warning, it sees 1=>2,(void) or something.

$ perl -E 'my $h = {1=>,2=>}; say $h->{1};'
2

Anyway, +1 for what tom proposed.

pgsql-bugs by date:

Previous
From: Ryan Kelly
Date:
Subject: Re: hstore parser incorrectly handles malformed input
Next
From: Jeff Frost
Date:
Subject: Re: 9.1.3 backends getting stuck in 'startup'