question about array indexing - Mailing list pgsql-general

From Szymon Lipiński
Subject question about array indexing
Date
Msg-id CAFjNrYspXQpG4H-JHgPzQ3uV=8QytF-Bo1oHZidDVSEozixj_g@mail.gmail.com
Whole thread Raw
Responses Re: question about array indexing  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-general
Hey,
I'm wondering if this isn't a bug somewhere in the parser. I had to add additional parenthesis around the regexp_split_to_array.


$ with x as (select 'a b c' a)
select
    regexp_split_to_array(a, ' ')
from x;

 regexp_split_to_array
-----------------------
 {a,b,c}
(1 row)

$ with x as (select 'a b c' a)
select
    regexp_split_to_array(a, ' ')[1]
from x;

ERROR:  syntax error at or near "["
LINE 3:     regexp_split_to_array(a, ' ')[1]
                                                             ^
$ with x as (select 'a b c' a)
select
    (regexp_split_to_array(a, ' '))[1]
from x;
 regexp_split_to_array
-----------------------
 a
(1 row)



regards,
Szymon

pgsql-general by date:

Previous
From: Ravi Krishna
Date:
Subject: Re: explain plan difference
Next
From: Merlin Moncure
Date:
Subject: Re: question about array indexing