SIMILAR TO bug?

Started by David Fetteralmost 18 years ago3 messageshackers
Jump to latest
#1Alvaro Herrera
alvherre@commandprompt.com
In reply to: David Fetter (#2)
Re: SIMILAR TO bug?

David Fetter wrote:

Folks,

Perhaps I've misunderstood this, but in PostgreSQL 8.3.5, I get
disparate results from ~ and SIMILAR TO. For example:

Did you read the docs? ^ is not an anchor.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#2David Fetter
david@fetter.org

Folks,

Perhaps I've misunderstood this, but in PostgreSQL 8.3.5, I get
disparate results from ~ and SIMILAR TO. For example:

This gives an unexpected result:

davidfetter@davidfetter=# SELECT 'abc' SIMILAR TO '^[a]';
?column?
----------
f
(1 row)

This one is what I expected.

davidfetter@davidfetter=# SELECT 'abc' ~ '^[a]';
?column?
----------
t
(1 row)

Did I misunderstand what SIMILAR TO does, or...?

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

#3Peter Eisentraut
peter_e@gmx.net
In reply to: David Fetter (#2)
Re: SIMILAR TO bug?

David Fetter wrote:

Folks,

Perhaps I've misunderstood this, but in PostgreSQL 8.3.5, I get
disparate results from ~ and SIMILAR TO. For example:

This gives an unexpected result:

davidfetter@davidfetter=# SELECT 'abc' SIMILAR TO '^[a]';
?column?
----------
f
(1 row)

This one is what I expected.

davidfetter@davidfetter=# SELECT 'abc' ~ '^[a]';
?column?
----------
t
(1 row)

Did I misunderstand what SIMILAR TO does, or...?

Well, SIMILAR TO is not the same thing as ~. For example, ^ is not a
special character in its pattern language.