Re: LIKE erratic? or unseen DB corruption? - Mailing list pgsql-general

From Richard Huxton
Subject Re: LIKE erratic? or unseen DB corruption?
Date
Msg-id 004401c0e213$18e09000$1001a8c0@archonet.com
Whole thread Raw
In response to LIKE erratic? or unseen DB corruption?  (Frank Miles <fpm@u.washington.edu>)
List pgsql-general
From: "Frank Miles" <fpm@u.washington.edu>

> A direct query gets appropriate rows of data:
>
> dbname=# select * from partdef where shpname = 'IDC16W';
>  pn_id | class | num  | mt | ver | loc_id | unit_id | subptcnt |
shpname      |   value    | descrip
> -------+-------+------+----+-----+--------+---------+----------+----------
--------+------------+---------
>     17 | 328   | 08X2 | 0  | 0   |        |         |        1 | IDC16W
| Header-8x2 |
>     11 | 323   | 08X2 | 0  | 0   |        |         |        1 | IDC16W
| Header-8x2 |
>
> ...while the very same query (substituting LIKE for the '=' sign) gets
nothing!?
>
Is "shpname" char() rather than varchar() or text? If so I think = strips
spaces from the end and LIKE doesn't.

Try a LIKE 'IDC16W%' and see if that works, or try padding the match with
spaces. Then, I'd recommend replacing any char() with varchar() - not
noticably slower (IMHO) and a lot less irritating.

- Richard Huxton


pgsql-general by date:

Previous
From: "Gregory Wood"
Date:
Subject: Re: LIKE erratic? or unseen DB corruption?
Next
From: "Richard Huxton"
Date:
Subject: Re: psql shell problem