pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedoperator does not exist: text = bytea
5+ messages / 3 participants
[nested] [flat]
* operator does not exist: text = bytea
@ 2022-07-20 09:32 Karthik K L V <venkata.karthik4u@gmail.com>
0 siblings, 3 replies; 5+ messages in thread
From: Karthik K L V @ 2022-07-20 09:32 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi Team,
I am getting the below error while executing a Select query using Spring
DataJPA and Hibernate framework in Aurora Postgres SQL.
*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*
We have a query with bind value which sometimes gets resolved to null (no
data) depending on the application scenario.
The datatype of the bindvalue and the corresponding column is String.
The same query executes fine when the value of the bindvalue is populated.
Could you please let me know how I can resolve this issue without making
changes to the query?
Is there any configuration available in the Postgres Driver or on the
Postgres DB Server which can be set to resolve null bind values?
Appreciate your help. Thank you.
--
Karthik klv
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: operator does not exist: text = bytea
@ 2022-07-20 09:48 Karthik K L V <venkata.karthik4u@gmail.com>
parent: Karthik K L V <venkata.karthik4u@gmail.com>
2 siblings, 0 replies; 5+ messages in thread
From: Karthik K L V @ 2022-07-20 09:48 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Update:
Followed this thread
PostgreSQL: Re: Null bind variable in where clause
<https://www.postgresql.org/message-id/4906DD3E-322A-4E26-8600-B967AFA8A58F%40fastcrypt.com;
and set *transform_null_equals to ON* in the parameter group on the AWS
Console. But no luck.
We are using Aurora PostgresSQL v13.3
On Wed, Jul 20, 2022 at 3:02 PM Karthik K L V <venkata.karthik4u@gmail.com>
wrote:
> Hi Team,
>
> I am getting the below error while executing a Select query using Spring
> DataJPA and Hibernate framework in Aurora Postgres SQL.
>
>
>
> *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*
>
> We have a query with bind value which sometimes gets resolved to null (no
> data) depending on the application scenario.
> The datatype of the bindvalue and the corresponding column is String.
> The same query executes fine when the value of the bindvalue is populated.
>
> Could you please let me know how I can resolve this issue without making
> changes to the query?
> Is there any configuration available in the Postgres Driver or on the
> Postgres DB Server which can be set to resolve null bind values?
>
> Appreciate your help. Thank you.
>
> --
> Karthik klv
>
--
Karthik klv
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: operator does not exist: text = bytea
@ 2022-07-20 11:59 hubert depesz lubaczewski <depesz@depesz.com>
parent: Karthik K L V <venkata.karthik4u@gmail.com>
2 siblings, 1 reply; 5+ messages in thread
From: hubert depesz lubaczewski @ 2022-07-20 11:59 UTC (permalink / raw)
To: Karthik K L V <venkata.karthik4u@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: operator does not exist: text = bytea
@ 2022-07-20 12:59 Karthik K L V <venkata.karthik4u@gmail.com>
parent: hubert depesz lubaczewski <depesz@depesz.com>
0 siblings, 0 replies; 5+ messages in thread
From: Karthik K L V @ 2022-07-20 12:59 UTC (permalink / raw)
To: depesz@depesz.com; +Cc: pgsql-general@lists.postgresql.org
Hi depesz,
Thanks for your reply. But, this issue is happening only when the bind
value of the query resolves to null. I am not trying to compare text to
bytes.
And the same query works fine when the bind value gets resolves to some
String. So, looking for an option which can tell Postgres Engine to read *=
null* as *is null*.
On Wed, Jul 20, 2022 at 5:29 PM hubert depesz lubaczewski <depesz@depesz.com>
wrote:
> 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
>
--
Karthik klv
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: operator does not exist: text = bytea
@ 2022-07-20 13:59 Tom Lane <tgl@sss.pgh.pa.us>
parent: Karthik K L V <venkata.karthik4u@gmail.com>
2 siblings, 0 replies; 5+ messages in thread
From: Tom Lane @ 2022-07-20 13:59 UTC (permalink / raw)
To: Karthik K L V <venkata.karthik4u@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
Karthik K L V <venkata.karthik4u@gmail.com> writes:
> We have a query with bind value which sometimes gets resolved to null (no
> data) depending on the application scenario.
> The datatype of the bindvalue and the corresponding column is String.
> The same query executes fine when the value of the bindvalue is populated.
> Could you please let me know how I can resolve this issue without making
> changes to the query?
This seems like it depends on the details of how the JDBC driver sends
the bound parameter to the server, so you'd be better off asking in
the pgsql-jdbc mailing list (and supplying some code details).
It's entirely possible that there isn't any solution other than fixing
your app to be more consistent about how it binds the parameter.
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2022-07-20 13:59 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-07-20 09:32 operator does not exist: text = bytea Karthik K L V <venkata.karthik4u@gmail.com>
2022-07-20 09:48 ` Karthik K L V <venkata.karthik4u@gmail.com>
2022-07-20 11:59 ` hubert depesz lubaczewski <depesz@depesz.com>
2022-07-20 12:59 ` Karthik K L V <venkata.karthik4u@gmail.com>
2022-07-20 13:59 ` Tom Lane <tgl@sss.pgh.pa.us>
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