Bug 535785 (RHQ-2445) - CLI gives ORA-01425 error when sending criteria to Oracle 10g
Summary: CLI gives ORA-01425 error when sending criteria to Oracle 10g
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: RHQ-2445
Product: RHQ Project
Classification: Other
Component: CLI
Version: 1.3
Hardware: All
OS: All
high
medium
Target Milestone: ---
: ---
Assignee: Jay Shaughnessy
QA Contact: Jeff Weiss
URL: http://jira.rhq-project.org/browse/RH...
Whiteboard: Branch RHQ_1_3_0_GA_CP
Depends On:
Blocks: JON231
TreeView+ depends on / blocked
 
Reported: 2009-10-01 17:56 UTC by dsteigne
Modified: 2018-10-20 04:29 UTC (History)
3 users (show)

Fixed In Version: 2.4
Clone Of:
Environment:
JON Server version 2.3 installed on Oracle 10g
Last Closed: 2010-08-12 16:55:44 UTC
Embargoed:


Attachments (Terms of Use)

Description dsteigne 2009-10-01 17:56:00 UTC
The following CLI commands with give an java.sql.SQLException: ORA-01425: escape character must be character string of length 1.

CLI commands:-
> var criteria = new ResourceCritiera();
> criteria.addFilterResourceTypeName('JBossAS Server');
> var resources = ResourceManager.findResourcesByCriteria(criteria);

It appears that we are escaping the escape character in the Oracle query:
SELECT r
FROM Resource r
WHERE ( r.inventoryStatus = InventoryStatus.COMMITTED
AND LOWER( r.resourceType.name )  like 'JBossAS Server' ESCAPE '\\' )

*Issue tracker ticket#349326


Comment 1 Charles Crouch 2009-10-08 16:31:38 UTC
Needs more investigation

Comment 2 Charles Crouch 2009-10-13 12:13:23 UTC
Jay, first step:can you run the CLI test suite against oracle

Comment 3 James Livingston 2009-10-14 01:42:32 UTC
This issue is mentioned on https://jira.jboss.org/jira/browse/JBPAPP-219 and the related Hibernate JIRA.

Postgres 8.2 and earlier[0], MySQL, and possibly other databases treat a backslash in a regular string as an escape character even though the SQL standard says not to. Escaping the backslash, like the code in CriteriaQueryGenerator.getQueryString() does,  makes it work for those databases but breaks some standard-conforming database like Oracle.

For Postgres 8.2 (not sure about earlier versions), you can use the following to force standard compliance on like in 8.3 and later. Which in theory should make it work with no escaping the backslashes in the query.
   ALTER DATABASE rhq SET standard_conforming_strings='on'


For reference, you can do this in MySQL 5.0.1 too or later with the NO_BACKSLASH_ESCAPES option.


[0] http://www.postgresql.org/docs/8.2/static/runtime-config-compatible.html#GUC-STANDARD-CONFORMING-STRINGS

Comment 4 Charles Crouch 2009-10-14 16:29:21 UTC
Database setups to test:
1) Oracle 10
2) PG with default settings
3) PG with standard_conforming_strings='on'


Comment 5 James Livingston 2009-10-14 23:53:10 UTC
Also, Oracle (10g at least) appears not to support prefixing a string literal with E to indicate that it's backslash escaped when it's part of an escape clause. So "... ESCAPE E'\\'" won't work.

Comment 6 Jay Shaughnessy 2009-10-19 18:06:54 UTC
For reference, coding in this area also relates to: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2674


Comment 7 Jay Shaughnessy 2009-10-19 21:20:22 UTC
Fix provides mechanism for the criteria query generator to perform dbType specific logic.  Add ability to store/retrieve defaultDatabaseType via DatabaseTypeFactory. Add db vendor specific handling of the ESCAPE character and allow property based override. Change behavior to handle Postgres (nonstandard) and Oracle (standard) differences.

Comment 8 Red Hat Bugzilla 2009-11-10 21:04:35 UTC
This bug was previously known as http://jira.rhq-project.org/browse/RHQ-2445


Comment 9 Jay Shaughnessy 2009-12-10 20:02:17 UTC
commit 15c5ab632360523f7ad37112700a1f2220163fb0

Comment 10 Corey Welton 2010-01-25 20:32:44 UTC
qa -> jweiss

Comment 11 Jeff Weiss 2010-01-25 20:50:32 UTC
QA Verified, on build QA-8436:

rhqadmin.redhat.com:7080$ resources
one row
Resource:
	          id: 10003
	        name: jweiss-rhel1.usersys.redhat.com RHQ Server, JBoss AS 4.2.3.GA default (0.0.0.0:2099)
	     version: 4.2.3.GA
	resourceType: JBossAS Server

rhqadmin.redhat.com:7080$

Comment 12 Corey Welton 2010-08-12 16:55:44 UTC
Mass-closure of verified bugs against JON.


Note You need to log in before you can comment on or make changes to this bug.