| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Robert James <srobertjames(at)gmail(dot)com> |
| Cc: | Postgres General <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: argument of AND must not return a set when using regexp_matches |
| Date: | 2013-01-16 23:23:43 |
| Message-ID: | 4897.1358378623@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Robert James <srobertjames(at)gmail(dot)com> writes:
> SELECT (regexp_matches('abc', '(.)b(.)'))[1] IS NOT NULL AND true
> -- Gives this error:
> ERROR: argument of AND must not return a set
> SQL state: 42804
> Can anyone make heads or tails of it? Is it a real bug? Is there a work around?
It's not a bug: regexp_matches returns a set of rows, not a scalar
result.
You might want to stick it into a sub-select as per the trick suggested
in the manual - then you get a NULL rather than zero rows when there's
no match. (Or, in the particular example at hand, it's not very clear
why you're using regexp_matches at all and not a plain old ~ operator.)
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bruce Momjian | 2013-01-16 23:29:11 | Re: pg_upgrade problem from 8.4 to 9.2 problems on OSX |
| Previous Message | Charles Porter | 2013-01-16 23:06:41 | pg_upgrade problem from 8.4 to 9.2 problems on OSX |