Re: string_to_array, array_to_string function without separator - Mailing list pgsql-hackers

From Chapman Flack
Subject Re: string_to_array, array_to_string function without separator
Date
Msg-id c16e7666-76b3-4078-0553-ae9ed0206dfb@anastigmatix.net
Whole thread Raw
In response to Re: string_to_array, array_to_string function without separator  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: string_to_array, array_to_string function without separator
Re: string_to_array, array_to_string function without separator
List pgsql-hackers
On 3/15/19 11:46 AM, Pavel Stehule wrote:
> pá 15. 3. 2019 v 15:03 odesílatel David Fetter <david@fetter.org> napsal:
>> Whatever optimizations you have in mind for this, could they also work
>> for string_to_array() and array_to_string() when they get an empty
>> string handed to them?
> 
> my idea is use string_to_array('AHOJ') --> {A,H,O,J}
> 
> empty input means empty result --> {}

I thought the question was maybe about an empty /delimiter/ string.

It seems that string_to_array already has this behavior if NULL is
passed as the delimiter:

> select string_to_array('AHOJ', null);
 string_to_array
-----------------
 {A,H,O,J}

and array_to_string has the proposed behavior if passed an
empty string as the delimiter (as one would naturally expect)
... but not null for a delimiter (that just makes the result null).

So the proposal seems roughly equivalent to making string_to_array's
second parameter optional default null, and array_to_string's second
parameter optional default ''.

Does that sound right?

Regards,
-Chap


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Ordered Partitioned Table Scans
Next
From: Pavel Stehule
Date:
Subject: Re: string_to_array, array_to_string function without separator