Bug 60066

Summary: JDBC Sampler: Provide Support for CLOB
Product: JMeter - Now in Github Reporter: Jacob Zwiers <apache_bugzilla>
Component: MainAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: enhancement CC: ra0077
Priority: P2    
Version: 3.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: Quick hack of AbstractJDBCTestElement to support CLOB OUT
Handle BLOBs and CLOBs

Description Jacob Zwiers 2016-08-30 11:34:29 UTC

    
Comment 1 Jacob Zwiers 2016-08-30 11:42:42 UTC
Created attachment 34184 [details]
Quick hack of AbstractJDBCTestElement to support CLOB OUT

Intended for hints/guidance only.
Comment 2 Jacob Zwiers 2016-08-30 11:43:58 UTC
A discussion on the mailing list (http://jmeter.512774.n5.nabble.com/CLOB-Supported-in-JDBC-Sampler-tt5724712.html) highlighted that a CLOB OUT / INOUT parameter does not have it's content returned by the JDBC Sampler.

The cause is that AbstractJDBCTestElement.resultSetsToString() loops through the declared variables and (if not an instance of java.sql.ResultSet) simply calls o.toString().  This is not sufficient to get content from a CLOB (at least not from an Oracle DB).

The mailing list item points out that there may be nuances to different DB / JDBC Driver implementations around CLOB.

A patch is provided and attached here with the caveat that it was simply "good enough" to get the data I was looking for.  There is no attempt to validate / support IN CLOB parameters, integrate code style with JMeter, validate that all Java features are provided in the JMeter supported version of Java, etc. and and there was very little testing / validation of the code.

Provided simply as a hint to anyone stumbling across this looking for a hint or quick implementation.
Comment 3 Felix Schumacher 2016-09-06 19:24:53 UTC
Do you think it would be helpful, to use the resultSetHandler variable to decide, whether we want the clob as an object, or a string representation? 

And would it be a good idea, to specify an upper limit for the string representation that is lower than Integer.MAX_VALUE?
Comment 4 Jacob Zwiers 2016-09-07 12:02:42 UTC
Not sure if those questions were for me or for more general discussion... but I'll take a stab.

re/ resultSetHandler I'll leave it to you.  I'm generally a user of JMeter and this is only my second time looking into the code in any detail. I'm sure there are preferences and/or conventions that I'm not aware or and therefore don't feel qualified to comment here.

re/ Integer.MAX_VALUE   That's only used if the CLOB itself provides a length (type long) which is larger than the Integer.MAX_VALUE which the CharBuffer accepts.  Otherwise, the upper limit is the declared .length() of the CLOB.  Maybe that's what you're asking... after you get to 2GB of text you've probably got other issues.  A lower threshold would likely be advisable.  Either way, a warning if data is truncated.

As other comments indicate, the implementation was designed to get only what I need and to do it quickly.  The code is likely problematic in other areas.  For example, the value of totalRead is incorrect and doesn't get propagated.  Provided for inspiration rather than as a claim of solid implementation.
Comment 5 Felix Schumacher 2016-09-10 19:23:40 UTC
Created attachment 34229 [details]
Handle BLOBs and CLOBs

Another patch for converting CLOBs and CLOBs.

This one limits the results stored in the sampler to the value of jdbcsampler.max_retain_result_size (which defaults to 64k).

Could you try it out?
Comment 6 Felix Schumacher 2016-09-20 19:20:35 UTC
Date: Tue Sep 20 18:55:08 2016
New Revision: 1761614

URL: http://svn.apache.org/viewvc?rev=1761614&view=rev
Log:
Handle CLOBs and BLOBs and limit them if necessary when storing them in result sampler.

Bugzilla Id: 60085

Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/component_reference.xml
    jmeter/trunk/xdocs/usermanual/properties_reference.xml

Date: Tue Sep 20 19:19:52 2016
New Revision: 1761624

URL: http://svn.apache.org/viewvc?rev=1761624&view=rev
Log:
Followup to r1761614. The correct bugzilla id is 60066.

Modified:
    jmeter/trunk/xdocs/changes.xml
Comment 7 The ASF infrastructure team 2022-09-24 20:38:05 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/4082