like operator bug - Mailing list pgsql-bugs

From jfaith
Subject like operator bug
Date
Msg-id 37D50698.246E4627@cemsys.com
Whole thread Raw
Responses Re: [BUGS] like operator bug
Re: [BUGS] like operator bug
List pgsql-bugs
Your name       :   Jeremy Faith
Your email address  :jfaith@cemsys.com


System Configuration
---------------------
  Architecture (example: Intel Pentium)     :Intel Pentium

  Operating System (example: Linux 2.0.26 ELF)  : Linux 2.0.36

  PostgreSQL version (example: PostgreSQL-6.5.1):   PostgreSQL-6.5.1

  Compiler used (example:  gcc 2.8.0)       : gcc 2.7.2.3


Please enter a FULL description of your problem:
------------------------------------------------
The percent charater(%) is not functioning correctly in arguments to the
like(~~) operator. Many matches are being missed.
Also the bug tracking system at
  http://www.PostgreSQL.ORG/bugs/visitor.php3
is not functioning(I reported this like bug about 2 weeks ago slip 72 I
think).
The output I get now starts with
  Warning: PostgresSQL query failed: ERROR: status: Permission denied.
in ./postgres.php3 on line 40.


Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------
create table tst(addr char(4));
insert into tst values('1000');
insert into tst values('1010');
insert into tst values('1120');
select * from tst where addr like '1%0';

produces

addr
----
1120(1 row)

where it should return all of the example rows.


If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------
In the file ./src/backend/utils/adt/like.c

The function DoMatch appears to have been optimised to return LIKE_ABORT
when
the pattern cannot be matched. However in the above instance it
incorrectly
aborts causing the like function to return FALSE. I think this could be
fixed
by changing the recursuve call from
  (matched=DoMatch(text,p))!=LIKE_FALSE
to
  (matched=DoMatch(text,p))==LIKE_TRUE
at the expense of some speed, there may be a more efficient solution,
but it
needs a fix.
It may be that the aborting concept is flawed.

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: [BUGS] temp tables failes in transaction mode
Next
From: Tom Lane
Date:
Subject: Re: [BUGS] like operator bug