db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Hillegas (JIRA)" <j...@apache.org>
Subject [jira] Updated: (DERBY-791) Expose api for printing Abstract Syntax Trees in production (non-debug) servers
Date Fri, 30 Jan 2009 20:56:59 GMT

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

Rick Hillegas updated DERBY-791:
--------------------------------

    Attachment: XmlTreeWalker.java

Attaching XmlTreeWalker.java. This is a simple Visitor which prints out the parsed AST in
xml. You invoke it like so:

   java XmlTreeWalker "select r.a from r, s where r.b = s.c"

The program prints out an xml representation of the AST to standard out. Here's the output
from the above command:

<?xml version="1.0" encoding="UTF-8"?>
<queryTree>
    <queryText>select r.a from r, s where r.b = s.c</queryText>
    <node>
        <nodeType>org.apache.derby.impl.sql.compile.CursorNode</nodeType>
        <contents>
            <member>name: null</member>
            <member>updateMode: UNSPECIFIED (0)</member>
            <member>statementType: SELECT</member>
        </contents>
        <node>
            <nodeType>org.apache.derby.impl.sql.compile.SelectNode</nodeType>
            <contents>
                <member>isDistinct: false</member>
                <member>groupByList: null</member>
                <member>orderByList: null</member>
                <member>resultSetNumber: 0</member>
                <member>referencedTableMap: null</member>
                <member>statementResultSet: false</member>
            </contents>
            <node>
                <nodeType>org.apache.derby.impl.sql.compile.ResultColumnList</nodeType>
                <contents>
                    <member>exposedName: A</member>
                    <member>name: A</member>
                    <member>tableName: null</member>
                    <member>isDefaultColumn: false</member>
                    <member>wasDefaultColumn: false</member>
                    <member>isNameGenerated: false</member>
                    <member>sourceTableName: null</member>
                    <member>type: null</member>
                    <member>columnDescriptor: null</member>
                    <member>isGenerated: false</member>
                    <member>isGeneratedForUnmatchedColumnInInsert: false</member>
                    <member>isGroupingColumn: false</member>
                    <member>isReferenced: false</member>
                    <member>isRedundant: false</member>
                    <member>virtualColumnId: 1</member>
                    <member>resultSetNumber: -1</member>
                    <member>dataTypeServices: null</member>
                    <member>; </member>
                </contents>
                <node>
                    <nodeType>org.apache.derby.impl.sql.compile.ResultColumn</nodeType>
                    <contents>
                        <member>exposedName: A</member>
                        <member>name: A</member>
                        <member>tableName: null</member>
                        <member>isDefaultColumn: false</member>
                        <member>wasDefaultColumn: false</member>
                        <member>isNameGenerated: false</member>
                        <member>sourceTableName: null</member>
                        <member>type: null</member>
                        <member>columnDescriptor: null</member>
                        <member>isGenerated: false</member>
                        <member>isGeneratedForUnmatchedColumnInInsert: false</member>
                        <member>isGroupingColumn: false</member>
                        <member>isReferenced: false</member>
                        <member>isRedundant: false</member>
                        <member>virtualColumnId: 1</member>
                        <member>resultSetNumber: -1</member>
                        <member>dataTypeServices: null</member>
                    </contents>
                    <node>
                        <nodeType>org.apache.derby.impl.sql.compile.ColumnReference</nodeType>
                        <contents>
                            <member>columnName: A</member>
                            <member>tableNumber: -1</member>
                            <member>columnNumber: 0</member>
                            <member>replacesAggregate: false</member>
                            <member>tableName: R</member>
                            <member>nestingLevel: -1</member>
                            <member>sourceLevel: -1</member>
                            <member>dataTypeServices: null</member>
                        </contents>
                    </node>
                </node>
            </node>
            <node>
                <nodeType>org.apache.derby.impl.sql.compile.FromBaseTable</nodeType>
                <contents>
                    <member>tableName: R</member>
                    <member>tableDescriptor: null</member>
                    <member>updateOrDelete: 0</member>
                    <member>null</member>
                    <member>existsBaseTable: false</member>
                    <member>dependencyMap: null</member>
                    <member>correlation Name: null</member>
                    <member>null</member>
                    <member>tableNumber -1</member>
                    <member>level 0</member>
                    <member>resultSetNumber: 0</member>
                    <member>referencedTableMap: null</member>
                    <member>statementResultSet: false</member>
                </contents>
            </node>
            <node>
                <nodeType>org.apache.derby.impl.sql.compile.FromBaseTable</nodeType>
                <contents>
                    <member>tableName: S</member>
                    <member>tableDescriptor: null</member>
                    <member>updateOrDelete: 0</member>
                    <member>null</member>
                    <member>existsBaseTable: false</member>
                    <member>dependencyMap: null</member>
                    <member>correlation Name: null</member>
                    <member>null</member>
                    <member>tableNumber -1</member>
                    <member>level 0</member>
                    <member>resultSetNumber: 0</member>
                    <member>referencedTableMap: null</member>
                    <member>statementResultSet: false</member>
                </contents>
            </node>
            <node>
                <nodeType>org.apache.derby.impl.sql.compile.BinaryRelationalOperatorNode</nodeType>
                <contents>
                    <member>operator: =</member>
                    <member>methodName: equals</member>
                    <member>dataTypeServices: null</member>
                </contents>
                <node>
                    <nodeType>org.apache.derby.impl.sql.compile.ColumnReference</nodeType>
                    <contents>
                        <member>columnName: B</member>
                        <member>tableNumber: -1</member>
                        <member>columnNumber: 0</member>
                        <member>replacesAggregate: false</member>
                        <member>tableName: R</member>
                        <member>nestingLevel: -1</member>
                        <member>sourceLevel: -1</member>
                        <member>dataTypeServices: null</member>
                    </contents>
                </node>
                <node>
                    <nodeType>org.apache.derby.impl.sql.compile.ColumnReference</nodeType>
                    <contents>
                        <member>columnName: C</member>
                        <member>tableNumber: -1</member>
                        <member>columnNumber: 0</member>
                        <member>replacesAggregate: false</member>
                        <member>tableName: S</member>
                        <member>nestingLevel: -1</member>
                        <member>sourceLevel: -1</member>
                        <member>dataTypeServices: null</member>
                    </contents>
                </node>
            </node>
        </node>
    </node>
</queryTree>


> Expose api for printing Abstract Syntax Trees in production (non-debug) servers
> -------------------------------------------------------------------------------
>
>                 Key: DERBY-791
>                 URL: https://issues.apache.org/jira/browse/DERBY-791
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>            Reporter: Rick Hillegas
>         Attachments: XmlTreeWalker.java
>
>
> Currently you can print Abstract Syntax Trees to derby.log by setting the DumpParseTree
tracepoint at server startup. E.g.:
> java -cp $CLASSPATH -Dderby.debug.true=DumpParseTree -Dderby.stream.error.logSeverityLevel=0
org.apache.derby.tools.ij  z.sql
> This can be a useful debugging tool. However, it only works on debug servers built with
the following flags:
> sanity=true
> debug=true
> We should provide some mechanism for printing these trees in production (non-debug) servers.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message