[
https://issues.apache.org/jira/browse/DERBY-6825?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Rick Hillegas updated DERBY-6825:
---------------------------------
Attachment: derby-6825-01-ab-optionalTool.diff
Thanks, Bryan. Attaching derby-6825-01-ab-optionalTool.diff, the second rev of
the simple json optional tool. This patch makes the following improvements:
1) Improves how oddball types are serialized to strings for inclusion in JSON
documents. Here is the javadoc for how Derby's types serialize when they are
included in JSON documents (from the method header comment for
org.apache.derby.optional.api.SimpleJsonUtils.toJSON()):
{noformat}
public static org.json.simple.JSONArray toJSON(ResultSet rs)
throws SQLException
Pack a ResultSet into a JSONArray. This method could be called client-side on
any query result from any DBMS. Each row is converted into a JSONObject whose
keys are the corresponding column names from the ResultSet. Closes the
ResultSet once it has been drained. Datatypes map to JSON values as follows:
NULL - The JSON null literal.
SMALLINT, INT, BIGINT - JSON integer values.
DOUBLE, FLOAT, REAL, DECIMAL, NUMERIC - JSON floating point values.
CHAR, VARCHAR, LONG VARCHAR, CLOB - JSON string values.
BLOB, VARCHAR FOR BIT DATA, LONG VARCHAR FOR BIT DATA - The byte array is
turned into a hex string (2 hex digits per byte) and the result is returned as
a JSON string.
All other types - Converted to JSON string values via their toString()
methods.
Throws:
SQLException
{noformat}
2) Adds tests.
I have run the full regression tests in 3 variations:
a) With the json-simple jar file on the classpath. The tests (including the new
simple json tests) ran cleanly except for the old heisenbugs listed below.
b) Without the json-simple jar file. The JUnit language suite blew up because
simple json classes could not be resolved. This is expected.
c) Without the json-simple jar file on the classpath and with
-Dderby.tests.omitJson=true specified on the command line. That setting causes
the language suite to skip the simple json tests. The tests ran cleanly except
for the old heisenbugs listed below.
I believe that this patch is ready to be committed.
Here are the heisenbugs I saw when I ran the full regression tests on my
macbook pro:
{noformat}
There were 2 failures:
1)
testPingWithWrongHost(org.apache.derbyTesting.functionTests.tests.derbynet.NetworkServerControlClientCommandTest)junit.framework.AssertionFailedError:
Could not find expectedString:Unable to find host in output:<STDOUT>Sat Jul 11
07:28:12 PDT 2015 : Could not connect to Derby Network Server on host
nothere.invalid, port 1527: Operation timed out
<END STDOUT>
<STDERR><END STDERR>
at
org.apache.derbyTesting.junit.BaseTestCase.assertExecJavaCmdAsExpected(BaseTestCase.java:609)
at
org.apache.derbyTesting.functionTests.tests.derbynet.NetworkServerControlClientCommandTest.assertFailedPing(NetworkServerControlClientCommandTest.java:147)
at
org.apache.derbyTesting.functionTests.tests.derbynet.NetworkServerControlClientCommandTest.testPingWithWrongHost(NetworkServerControlClientCommandTest.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at
org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:120)
at
org.apache.derbyTesting.junit.BaseJDBCTestCase.runBareOverridable(BaseJDBCTestCase.java:443)
at
org.apache.derbyTesting.junit.BaseJDBCTestCase.runBare(BaseJDBCTestCase.java:460)
at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
at junit.extensions.TestSetup.run(TestSetup.java:25)
at
org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:58)
at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
at junit.extensions.TestSetup.run(TestSetup.java:25)
at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
at junit.extensions.TestSetup.run(TestSetup.java:25)
2)
testInvalidLDAPServerConnectionError(org.apache.derbyTesting.functionTests.tests.jdbcapi.InvalidLDAPServerAuthenticationTest)junit.framework.AssertionFailedError
at
org.apache.derbyTesting.functionTests.tests.jdbcapi.InvalidLDAPServerAuthenticationTest.testInvalidLDAPServerConnectionError(InvalidLDAPServerAuthenticationTest.java:126)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at
org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:120)
at
org.apache.derbyTesting.junit.BaseJDBCTestCase.runBareOverridable(BaseJDBCTestCase.java:443)
at
org.apache.derbyTesting.junit.BaseJDBCTestCase.runBare(BaseJDBCTestCase.java:460)
at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
at junit.extensions.TestSetup.run(TestSetup.java:25)
at
org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:58)
at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
at junit.extensions.TestSetup.run(TestSetup.java:25)
at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
at junit.extensions.TestSetup.run(TestSetup.java:25)
FAILURES!!!
Tests run: 13845, Failures: 2, Errors: 0
{noformat}
In addition, test run (a) showed the following error from the non-JUnit tests.
The error did not reproduce when I ran the test standalone. I do not think this
instability is caused by this patch:
{noformat}
********* Diff file derbyall/derbylang/refActions.diff
*** Start: refActions jdk1.8.0 derbyall:derbylang 2015-07-10 11:56:48 ***
747a748
> ERROR 40XL1: A lock could not be obtained within the time requested
Test Failed.
*** End: refActions jdk1.8.0 derbyall:derbylang 2015-07-10 11:57:02 ***
{noformat}
Touches the following files in addition to those touched by the previous rev of
the patch:
-------------------------------
A
java/testing/org/apache/derbyTesting/functionTests/tests/lang/JsonSuite.java
M
java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
M java/testing/org/apache/derbyTesting/junit/JDBC.java
M java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
M build.xml
Adds test cases for the simple json optional tool. Adds a new debug system
property: derby.tests.omitJson. When this property is set, the language suite
skips the simple json tests.
> Add basic JSON support to Derby.
> --------------------------------
>
> Key: DERBY-6825
> URL: https://issues.apache.org/jira/browse/DERBY-6825
> Project: Derby
> Issue Type: Improvement
> Components: SQL
> Affects Versions: 10.12.0.0
> Reporter: Rick Hillegas
> Attachments: SimpleJsonVTI.java, derby-6825-01-aa-optionalTool.diff,
> derby-6825-01-ab-optionalTool.diff
>
>
> Other database are adding support for the popular JSON data interchange
> format defined by https://www.ietf.org/rfc/rfc4627.txt. We could add a VTI to
> Derby which would unpack a JSON document into a set of rows. We could also
> add a reverse transformation, which turns a query result into a JSON document.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)