openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Hastie (Commented) (JIRA)" <>
Subject [jira] [Commented] (OPENJPA-2056) Postgres V9.1 issue with LIKE clause and Escape Strings
Date Tue, 04 Oct 2011 10:54:33 GMT


Andrew Hastie commented on OPENJPA-2056:

I think there are several solutions to this problem, but ideally we need something that is
backwards compatible with previous Postgres releases. I'm no expect on the internals of OpenJPA,
but here are some suggestions:

1. Determine from the current connection the setting of "standard_conforming_strings" (Needs
SQL statement "SHOW standard_conforming_strings;"). This can then be used to influence the
escape string to being either "\\" or "\\\\" in the Dictionary impl as required. ASFAIK Postgres
at V9.1 returns "ON" and earlier releases return "OFF".

Here are some links to the Postgres documentation covering this topic:-

2. Use an explicitly escaped string like E'\\' to force escape interpretation, making the
string independent of the standards_conforming_strings param.

Until this is fixed, there are several workarounds for the problem:-

1. Set a property in the persistence.xml as follows to override the default PGDictionary setting:-
    <property name="openjpa.jdbc.DBDictionary" value="postgres(SearchStringEscape=\)"/>
2. In the Postgres configuration file (postgresql.conf) make the setting under "VERSION/PLATFORM
  standard_conforming_strings = off

Option 1 is preferred as not all users may have access to the Postgres configuration files.

> Postgres V9.1 issue with LIKE clause and Escape Strings
> -------------------------------------------------------
>                 Key: OPENJPA-2056
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 2.0.0, 2.0.1, 2.1.1
>         Environment: Running against a Postgres database at version 9.1
>            Reporter: Andrew Hastie
> Noticed an issue with the Postgres DBDictionary definition after updating Postgres from
version 8.4 to 9.1:-
> Here's what you get in the Postgres trace file when executing some JPA driven queries
where an SQL LIKE is involved:-
> 2011-09-30 14:29:41 BST ERROR:  invalid escape string
> 2011-09-30 14:29:41 BST HINT:  Escape string must be empty or one character.
> 2011-09-30 14:29:41 BST STATEMENT:  SELECT, t0.identificationMask, t0.productName
FROM DBTYPE t0 WHERE (t0.identificationMask LIKE $1 ESCAPE '\\')
> 2011-09-30 14:29:41 BST ERROR:  current transaction is aborted, commands ignored until
end of transaction block
> This appears to be down to a change the Postgres project have made to escape string handling:-
> (see section E.2.2.1)
> You appear to be able to override the default DBDictionary setting for this as follows
to get things working again:-
> <property name="openjpa.jdbc.DBDictionary" value="postgres(SearchStringEscape=\)"/>
> So, does this mean OpenJPA needs a version dependent dictionary definition for Postgres
from now on? Anybody got any better solutions or care to confirm what I'm seeing?
> I've also posted this to the Postgres JDBC mailing list in case they have any comments.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message