| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | sbasurto(at)soft-gator(dot)com |
| Cc: | pgsql-bugs(at)postgresql(dot)org |
| Subject: | Re: BUG #7520: regexp_matches does not work as expected |
| Date: | 2012-09-05 04:35:48 |
| Message-ID: | 4119.1346819748@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
sbasurto(at)soft-gator(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | boy | 2012-09-05 13:57:12 | BUG #7521: Cannot disable WAL log while using pg_dump |
| Previous Message | Dave Vitek | 2012-09-05 03:45:47 | windows 8 RTM compatibility issue (could not reserve shared memory region for child) |