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

From Pavel Stehule
Subject Re: string_to_array, array_to_string function without separator
Date
Msg-id CAFj8pRB1-An+7KNPwjvRnz2-qtXJ6nMaZFYqgk3xEYOqnHzZ9Q@mail.gmail.com
Whole thread Raw
In response to Re: string_to_array, array_to_string function without separator  (Chapman Flack <chap@anastigmatix.net>)
List pgsql-hackers


pá 15. 3. 2019 v 18:30 odesílatel Chapman Flack <chap@anastigmatix.net> napsal:
On 3/15/19 12:59 PM, Pavel Stehule wrote:
> for this proposal "char" != byte
>
> result[n] = substring(str FROM n FOR 1)

I think that's what string_to_array(..., null) already does:

sure. My proposal is +/- just reduction about null parameter.



SHOW server_encoding;
server_encoding
UTF8

WITH
 t0(s) AS (SELECT text 'verlorn ist daz slüzzelîn'),
 t1(a) AS (SELECT string_to_array(s, null) FROM t0)
SELECT
 char_length(s), octet_length(convert_to(s, 'UTF8')),
 array_length(a,1), a
FROM
 t0, t1;

char_length|octet_length|array_length|a
25|27|25|{v,e,r,l,o,r,n," ",i,s,t," ",d,a,z," ",s,l,ü,z,z,e,l,î,n}


Regards,
-Chap

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: hyrax vs. RelationBuildPartitionDesc
Next
From: Andrey Borodin
Date:
Subject: Re: GiST VACUUM