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

2012-12-23 Thread Tom Lane
"David Johnston" writes: >> while it might work to reverse the order in a regex, I have experienced >> severe slowdown when the pattern comes from table data > If it is indeed related to the custom reverse query the fact that you are > going through an SQL wrapper to access a c-level function is

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

2012-12-22 Thread David Johnston
> >> There's a much easier fix to this problem though, which is to invent > >> a "reverse ~" operator that does POSIX comparison with the pattern on > >> the left. The hardest part of doing that for yourself is choosing a > >> name for the reverse operator --- it just goes like > >> > >> create fu

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

2012-12-22 Thread hamann . w
>> >> "David Johnston" writes: >> > [optionally go look at " ~* " in the documentation at this point; or just >> > try a simple flip-flop of the expression] >> >> > SELECT 'Kumar' ~* 'kuma' -> TRUE !!! (ah ha! I had the order reversed) >> >> > SELECT any( ARRAY['Kumar','Gozales']::text ) ... wa

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

2012-12-21 Thread Tom Lane
Denis Papathanasiou 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.

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

2012-12-21 Thread David Johnston
> -Original Message- > From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- > ow...@postgresql.org] On Behalf Of Denis Papathanasiou > Sent: Friday, December 21, 2012 10:43 AM > To: pgsql-general@postgresql.org > Subject: Re: [GENERAL] Using POSIX Regular Expre

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

2012-12-21 Thread Denis Papathanasiou
On 12/21/2012 10:35 AM, David Johnston wrote: 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.: 'abc' ~ '(b|d)' true In my orig

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

2012-12-21 Thread David Johnston
> > 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.: > > 'abc' ~ '(b|d)' true > > In my original example, I found I could

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

2012-12-21 Thread Denis Papathanasiou
] Using POSIX Regular Expressions on xml type fields gives inconsistent results [snip] [At this point I'd confirm or question why ANY hasn't been made to go both ways but also realize that I will have to approach this in a different way to achieve my goal.] I did realize that ANY()

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

2012-12-20 Thread Tom Lane
"David Johnston" writes: > [optionally go look at " ~* " in the documentation at this point; or just > try a simple flip-flop of the expression] > SELECT 'Kumar' ~* 'kuma' -> TRUE !!! (ah ha! I had the order reversed) > SELECT any( ARRAY['Kumar','Gozales']::text ) ... wait...ANY doesn't work on

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

2012-12-20 Thread David Johnston
> -Original Message- > From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- > ow...@postgresql.org] On Behalf Of Denis Papathanasiou > Sent: Thursday, December 20, 2012 7:56 PM > To: pgsql-general@postgresql.org > Subject: [GENERAL] Using POSIX Regular Expre

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

2012-12-20 Thread David Johnston
> > I have a table with an xml type column, and while I can make regex queries > like this successfully: > > => select id from form_d where 'kumar' ~* any( > CAST(xpath('//PersonsList/PersonName/LastName/text()', data) as TEXT[]) > ); It took me way too long to figure this out: SELECT 'text to

[GENERAL] Using POSIX Regular Expressions on xml type fields gives inconsistent results

2012-12-20 Thread Denis Papathanasiou
I have a table with an xml type column, and while I can make regex queries like this successfully: => select id from form_d where 'kumar' ~* any( CAST(xpath('//PersonsList/PersonName/LastName/text()', data) as TEXT[]) ); id -- 97e1541b-27f