Re: [HACKERS] string_to_array with empty input

From: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Steve Crawford <scrawford(at)pinpointresearch(dot)com>, pgsql-general(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] string_to_array with empty input
Date: 2009-03-31 04:21:29
Message-ID: 1E6E35DF-4260-4559-8E68-3A7775A2D324@kineticode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Mar 30, 2009, at 8:26 PM, Tom Lane wrote:

> Does anyone want to argue for keeping it the same? Or perhaps
> argue that a zero-element array is a more sensible result than
> a one-element array with one empty string? (It doesn't seem
> like it to me, but maybe somebody thinks so.)

Hrm. There seems to be some disagreement about this among some
languages:

% perl -le '@r = split /-/, ""; print length @r; print qq{"$r[0]"}'
1
""

% irb
>> puts ''.split('-')
=> nil

So Perl returns a single element as Steve had been expecting, while
Ruby returns nil. I'm used to the Perl way, but I guess there's room
for various interpretations, including the current implementation,
with which Ruby would seem to agree.

Best,

David

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stuart Bishop 2009-03-31 04:26:24 Re: pgstattuple triggered checkpoint failure and database outage?
Previous Message Tom Lane 2009-03-31 04:20:20 Re: [GENERAL] pgstattuple triggered checkpoint failure and database outage?

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-03-31 04:22:55 Re: can't load plpython
Previous Message Tom Lane 2009-03-31 04:20:20 Re: [GENERAL] pgstattuple triggered checkpoint failure and database outage?