From: Tom Lane <tgl@sss.pgh.pa.us>
To: Matthias Apitz <guru@unixarea.de>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: PG SQL and LIKE clause
Date: Fri, 13 Sep 2019 10:24:35 -0400
Message-ID: <20804.1568384675@sss.pgh.pa.us> (raw)
In-Reply-To: <20190913052846.GA3070@c720-r342378>
References: <20190913052846.GA3070@c720-r342378>
Matthias Apitz <guru@unixarea.de> writes:
> We got to know that in CHAR columns with trailing blanks a
> SELECT ... FROM ... WHERE name LIKE 'Ali'
> does not match in 'name' having 'Ali '.
> I glanced through our code with grep pipelines and found some hundred
> places which would be affected by this problem. I'm not interested in a
> religious discussion if or if not this behaviour of PG is correcter or
> better than in Sybase. It's just different to Sybase.
> Any hints to address this problem?
Don't use char(n) for anything more complicated than cases like
it-must-be-a-2-character-state-abbreviation. You can use varchar(n)
if you must have an upper limit on the field length. Or text.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, guru@unixarea.de
Subject: Re: PG SQL and LIKE clause
In-Reply-To: <20804.1568384675@sss.pgh.pa.us>
References: <20190913052846.GA3070@c720-r342378> <20804.1568384675@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox