unable to understand query result

From: Stefan Froehlich <postgresql(at)froehlich(dot)priv(dot)at>
To: pgsql-general(at)postgresql(dot)org
Subject: unable to understand query result
Date: 2022-07-06 09:31:20
Message-ID: 20220706093120.GA11952@static.231.150.9.176.clients.your-server.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a database returing these result sets for two almost
identical queries:

#v+
$ select id, pid, length(pid), md5(pid) from product where pid like '8000000';
id | pid | length | md5
------+---------+--------+----------------------------------
3594 | 8000000 | 7 | 60b5792913f4acbccf45c281fa9e3c9f
(1 row)

$ select id, pid, length(pid), md5(pid) from product where pid like '%8000000';
id | pid | length | md5
------+---------+--------+----------------------------------
3594 | 8000000 | 7 | 60b5792913f4acbccf45c281fa9e3c9f
722 | 8000000 | 7 | 60b5792913f4acbccf45c281fa9e3c9f
(2 rows)
#v-

There should be only one product with this id (no unique key,
because this is not a general constraint but just the current
situation), but there are two. Looking for it with query 1 I got
only one result, suspecting leading or trailing blanks I found the
other one using the wildcard.

But: What is wrong here? There must be some difference between the
two product ids, but with the same md5-hash there seems to be none.

This is by far too trivial to be a postgresql-bug, but what exactly
am I missing here?

Bye,
Stefan

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2022-07-06 09:38:22 Re: ADD COLUMN ts tsvector GENERATED too slow
Previous Message Florents Tselai 2022-07-06 08:42:47 ADD COLUMN ts tsvector GENERATED too slow