From: hubert depesz lubaczewski <depesz@depesz.com>
To: Karthik K L V <venkata.karthik4u@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: operator does not exist: text = bytea
Date: Wed, 20 Jul 2022 13:59:46 +0200
Message-ID: <20220720115946.GB28445@depesz.com> (raw)
In-Reply-To: <CAGpQzhyp+Jfvz1BveXupEzw48gofzwy=xHW143z50ouJHu-4jw@mail.gmail.com>
References: <CAGpQzhyp+Jfvz1BveXupEzw48gofzwy=xHW143z50ouJHu-4jw@mail.gmail.com>
On Wed, Jul 20, 2022 at 03:02:13PM +0530, Karthik K L V wrote:
> *Caused by: org.postgresql.util.PSQLException: ERROR: operator does not
> exist: text = bytea Hint: No operator matches the given name and argument
> types. You might need to add explicit type casts. Position: 1037*
> Could you please let me know how I can resolve this issue without making
> changes to the query?
I don't think it's possible.
bytea is basically array of bytes.
text on the other hand is array of characters.
Do the bytes "\xbf\xf3\xb3\x77" equal text "żółw"?
They actually kinda do, if we assume the bytes are text in encoding
Windows-1252 - in which case the bytes mean "żółw".
But if we'd assume the encoding to be, for example, iso8859-1, then the
same sequence of bytes means "¿ó³w"
That's why you can't compare bytes to characters.
You have to either convert bytes to text using convert or convert_from
functions, or change text into bytea using convert_to.
In some cases you can simply cast text to bytea:
$ select 'depesz'::text::bytea;
bytea
────────────────
\x64657065737a
(1 row)
which will work using current server encoding, afair.
depesz
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: depesz@depesz.com, venkata.karthik4u@gmail.com
Subject: Re: operator does not exist: text = bytea
In-Reply-To: <20220720115946.GB28445@depesz.com>
References: <CAGpQzhyp+Jfvz1BveXupEzw48gofzwy=xHW143z50ouJHu-4jw@mail.gmail.com> <20220720115946.GB28445@depesz.com>
* 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