[ 
https://issues.apache.org/jira/browse/DERBY-6266?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rick Hillegas updated DERBY-6266:
---------------------------------

    Attachment: z.sql
                derby-6266-01-aa-toXML.diff

Attaching derby-6266-01-aa-toXML.diff. This patch adds an xml-printing method 
to the Derby execution ResultSet interface. I am running tests now.

This patch makes the following changes:

1) Adds a toXML() method to org.apache.derby.iapi.sql.ResultSet. The caller is 
responsible for creating a document and passing in a root Element to which xml 
sub-nodes can be appended.

2) Adds a default implementation of toXML() to BasicNoPutResultSetImpl. The 
default implementation uses reflection to loop through all of the fields of a 
ResultSet which are also ResultSets. For each field, an element is created 
whose tag is the field name. The child element has a type attribute whose value 
is the refined type of the child ResultSet (e.g., "ProjectRestrictResultSet").

3) Makes ScanResultSet add extra tableName and indexName information to the 
childElement.

I am attaching z.java, a little program which exercises this code. The program 
compiles the following query:

select tablename from sys.systables t, sys.syscolumns c, sys.sysaliases a, 
sys.syssequences s
where t.tablename = c.columnname and c.columnname = a.alias and a.alias = 
s.sequencename;

...and extracts the following xml printout of the ResultSet graph:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<planTrace>
    <top type="ProjectRestrictResultSet">
        <source type="HashJoinResultSet">
            <leftResultSet type="HashJoinResultSet">
                <leftResultSet type="HashJoinResultSet">
                    <leftResultSet tableName="SYSCOLUMNS" 
type="BulkTableScanResultSet"/>
                    <rightResultSet indexName="SYSTABLES_INDEX1" 
tableName="SYSTABLES" type="HashScanResultSet"/>
                </leftResultSet>
                <rightResultSet indexName="SYSALIASES_INDEX1" 
tableName="SYSALIASES" type="HashScanResultSet"/>
            </leftResultSet>
            <rightResultSet indexName="SYSSEQUENCES_INDEX2" 
tableName="SYSSEQUENCES" type="HashScanResultSet"/>
        </source>
    </top>
</planTrace>


Touches the following files:

---------------

M       java/engine/org/apache/derby/iapi/sql/ResultSet.java

One new debug/testing method added to the Derby execution ResultSet interface.

---------------

M       java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
M       
java/engine/org/apache/derby/impl/sql/execute/BasicNoPutResultSetImpl.java
M       
java/engine/org/apache/derby/impl/sql/execute/TemporaryRowHolderResultSet.java

The default implementation of ResultSet.toXML(). The real logic is in 
BasicNoPutResultSetImpl. The other two classes just forward toXML() to the 
static machinery in BasicNoPutResultSetImpl.

---------------

M       java/engine/org/apache/derby/impl/sql/execute/ScanResultSet.java

Adds indexName and tableName attributes to the scan elements.

---------------

M       java/engine/org/apache/derby/impl/sql/execute/LastIndexKeyResultSet.java
M       java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java
M       java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
M       java/engine/org/apache/derby/impl/sql/execute/DependentResultSet.java

All of the subclasses of ScanResultSet have public indexName and tableName 
fields. These were moved into ScanResultSet so that a single toXML() 
implementation could handle all scan nodes.

                
> Add ability to print a Derby execution ResultSet as xml.
> --------------------------------------------------------
>
>                 Key: DERBY-6266
>                 URL: https://issues.apache.org/jira/browse/DERBY-6266
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 10.11.0.0
>            Reporter: Rick Hillegas
>         Attachments: derby-6266-01-aa-toXML.diff, z.sql
>
>
> Add a method for printing an org.apache.derby.iapi.sql.ResultSet as xml. The 
> idea is to get a quick snapshot of a plan shape without all of the overhead 
> of PlanExporter and runtimestatistics. This method could be used by our tests 
> to verify plan shapes.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to