Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T97LE-0001Us-FM for pgsql-bugs@postgresql.org; Wed, 05 Sep 2012 04:35:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T97LB-00008R-SB for pgsql-bugs@postgresql.org; Wed, 05 Sep 2012 04:35:52 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q854Zmwj004120; Wed, 5 Sep 2012 00:35:48 -0400 (EDT) From: Tom Lane To: sbasurto@soft-gator.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #7520: regexp_matches does not work as expected In-reply-to: References: Comments: In-reply-to sbasurto@soft-gator.com message dated "Wed, 05 Sep 2012 01:31:34 -0000" Date: Wed, 05 Sep 2012 00:35:48 -0400 Message-ID: <4119.1346819748@sss.pgh.pa.us> X-Pg-Spam-Score: -2.1 (--) X-Archive-Number: 201209/33 X-Sequence-Number: 34028 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