Skip site navigation (1) Skip section navigation (2)

Re: Splitting text column to multiple rows

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrus <kobruleht2(at)hot(dot)ee>, pgsql-general(at)postgresql(dot)org
Subject: Re: Splitting text column to multiple rows
Date: 2010-03-29 15:18:30
Message-ID: 162867791003290818h61c04b3cu21a08c644c77394b@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-general
2010/3/29 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> "Andrus" <kobruleht2(at)hot(dot)ee> writes:
>> I changed unction name and tried:
>> CREATE OR REPLACE FUNCTION unnest21(anyarray)
>> RETURNS SETOF anyelement as $$
>>   SELECT $1[i] FROM generate_series(1,4) g(i)
>> $$ LANGUAGE sql;
>
>> select unnest21(string_to_array('23,2,3,4,5',','));
>
>> In this case it returns only 4 rows.
>> No idea what is happening.
>
> Well, the generate_series call is wrong for this use ...
>
> I think if it appeared to work before it was because the built-in
> unnest() function was capturing the call.

he uses 8.1. the bug is in "generate_series(1,>>>4<<<)"

Pavel
>
>                        regards, tom lane
>

In response to

Responses

pgsql-general by date

Next:From: Tom LaneDate: 2010-03-29 15:29:20
Subject: Re: Splitting text column to multiple rows
Previous:From: Pavel StehuleDate: 2010-03-29 15:17:35
Subject: Re: Splitting text column to multiple rows

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group