BUG #7520: regexp_matches does not work as expected

From: sbasurto(at)soft-gator(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #7520: regexp_matches does not work as expected
Date: 2012-09-05 01:31:34
Message-ID: E1T94Ss-0003Bc-WF@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 7520
Logged by: Sergio Basurto
Email address: sbasurto(at)soft-gator(dot)com
PostgreSQL version: 9.1.4
Operating system: Gentoo
Description:

I am using regexp_matches in a function like this
create or replace function test (v_string in text)
returns varchar as $$
declare
i_strings text[];
i_string text[];

i_strings :=
regexp_matches(v_string,E'[a-zA-Z0-9:\\s\\-\\.#%]*:[A-Za-z0-9\\s\\-\\.#%]+','g');

The I use the results
foreach i_string slice 1 in array i_strings
loop
raise notice 'row = %',i_string;
end loop;

when I run the function like this
select test('1:Warehouse1;2:Warehouse2;');

postgresql complains:
ERROR: query "SELECT
regexp_matches(v_string,E'[a-zA-Z0-9:\\s\\-\\.#%]*:[A-Za-z0-9\\s\\-\\.#%]+','g')"
returned more than one row

Off course I am expecting more than one row!

If I run:
select
regexp_matches('1:Warehouse1;2:Warehouse2;',E'[a-zA-Z0-9:\\s\\-\\.#%]*:[A-Za-z0-9\\s\\-\\.#%]+','g');
regexp_matches
----------------
{1:Warehouse1}
{2:Warehouse2}
(2 rows)

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Dave Vitek 2012-09-05 03:45:47 windows 8 RTM compatibility issue (could not reserve shared memory region for child)
Previous Message Kevin Grittner 2012-09-04 22:08:42 Re: BUG #7519: incresed data base size and query performance lost