Re: string_to_array, array_to_string function without separator

From: Chapman Flack <chap(at)anastigmatix(dot)net>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, David Fetter <david(at)fetter(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: string_to_array, array_to_string function without separator
Date: 2019-03-15 17:29:54
Message-ID: 2c9413cf-acb3-0aa9-97f1-1fe9d3db671c@anastigmatix.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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:

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2019-03-15 18:01:53 Re: [HACKERS] PATCH: multivariate histograms and MCV lists
Previous Message Pavel Stehule 2019-03-15 16:59:06 Re: string_to_array, array_to_string function without separator