From: Tom Lane <tgl@sss.pgh.pa.us>
To: sbasurto@soft-gator.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #7520: regexp_matches does not work as expected
Date: Wed, 05 Sep 2012 00:35:48 -0400
Message-ID: <4119.1346819748@sss.pgh.pa.us> (raw)
In-Reply-To: <E1T94Ss-0003Bc-WF@wrigleys.postgresql.org>
References: <E1T94Ss-0003Bc-WF@wrigleys.postgresql.org>
sbasurto@soft-gator.com writes:
> 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');
> 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
As per David Johnston's response on pgsql-general, this isn't a bug:
simple assignments in plpgsql expect a simple source value, not a rowset.
Personally I'd just iterate over the regexp_matches result directly and
not bother trying to store it into a variable, for example
for string_var in select regexp_matches(...) loop ...
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, sbasurto@soft-gator.com
Subject: Re: BUG #7520: regexp_matches does not work as expected
In-Reply-To: <4119.1346819748@sss.pgh.pa.us>
References: <E1T94Ss-0003Bc-WF@wrigleys.postgresql.org> <4119.1346819748@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox