Re: Using POSIX Regular Expressions on xml type fields gives inconsistent results

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Denis Papathanasiou <denis(dot)papathanasiou(at)banrai(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Using POSIX Regular Expressions on xml type fields gives inconsistent results
Date: 2012-12-21 16:08:11
Message-ID: 16085.1356106091@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Denis Papathanasiou <denis(dot)papathanasiou(at)banrai(dot)com> writes:
> I did realize that ANY() must be a right-hand operator, but what I
> didn't understand (and admittedly still don't understand) is why regex
> operations that are normally right-side work from the left.

All regex operators in Postgres have the pattern on the right. This
follows the lead of the SQL standard's LIKE operator, which has its
pattern on the right. You might be used to some other language that
puts the pattern on the left, but that isn't some kind of natural law.
And it most certainly isn't the case that the operator will look at the
two text strings and try to guess which one is meant as a pattern. That
would be impossibly unreliable.

> If you look at the four examples which follow the posix match table in
> the docs
> (http://www.postgresql.org/docs/9.1/static/functions-matching.html#FUNCTIONS-POSIX-TABLE)
> some of them work from the left side, e.g.:

Not to my eyes ...

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Angelico 2012-12-21 16:11:56 Re: Coalesce bug ?
Previous Message David Johnston 2012-12-21 16:04:03 Re: Using POSIX Regular Expressions on xml type fields gives inconsistent results