Merge lp:~mmcm/akiban-sql-parser/explain-verbose into lp:~akiban-technologies/akiban-sql-parser/trunk

Proposed by Mike McMahon
Status: Merged
Approved by: Nathan Williams
Approved revision: 280
Merged at revision: 280
Proposed branch: lp:~mmcm/akiban-sql-parser/explain-verbose
Merge into: lp:~akiban-technologies/akiban-sql-parser/trunk
Diff against target: 156 lines (+51/-4)
5 files modified
src/main/java/com/akiban/sql/parser/ExplainStatementNode.java (+14/-1)
src/main/java/com/akiban/sql/unparser/NodeToString.java (+14/-1)
src/main/javacc/SQLGrammar.jj (+21/-2)
src/test/resources/com/akiban/sql/unparser/explain-2.expected (+1/-0)
src/test/resources/com/akiban/sql/unparser/explain-2.sql (+1/-0)
To merge this branch: bzr merge lp:~mmcm/akiban-sql-parser/explain-verbose
Reviewer Review Type Date Requested Status
Nathan Williams Approve
Review via email: mp+142209@code.launchpad.net

Description of the change

Add VERBOSE and BRIEF qualifiers for EXPLAIN.

To post a comment you must log in.
Revision history for this message
Nathan Williams (nwilliams) wrote :

As described.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/main/java/com/akiban/sql/parser/ExplainStatementNode.java'
2--- src/main/java/com/akiban/sql/parser/ExplainStatementNode.java 2012-12-13 23:01:21 +0000
3+++ src/main/java/com/akiban/sql/parser/ExplainStatementNode.java 2013-01-07 22:52:21 +0000
4@@ -26,16 +26,24 @@
5
6 public class ExplainStatementNode extends StatementNode
7 {
8+ public enum Detail {
9+ BRIEF, NORMAL, VERBOSE
10+ }
11+
12 private StatementNode statement;
13+ private Detail detail;
14
15 /**
16 * Initializer for an ExplainStatementNode
17 *
18 * @param statement The statement to be explained.
19+ * @param detail Level of detail.
20 */
21
22- public void init(Object statement) {
23+ public void init(Object statement,
24+ Object detail) {
25 this.statement = (StatementNode)statement;
26+ this.detail = (Detail)detail;
27 }
28
29 /**
30@@ -47,6 +55,7 @@
31 ExplainStatementNode other = (ExplainStatementNode)node;
32 this.statement = (StatementNode)getNodeFactory().copyNode(other.statement,
33 getParserContext());
34+ this.detail = other.detail;
35 }
36
37 /**
38@@ -95,4 +104,8 @@
39 return statement;
40 }
41
42+ public Detail getDetail() {
43+ return detail;
44+ }
45+
46 }
47
48=== modified file 'src/main/java/com/akiban/sql/unparser/NodeToString.java'
49--- src/main/java/com/akiban/sql/unparser/NodeToString.java 2012-12-30 01:38:37 +0000
50+++ src/main/java/com/akiban/sql/unparser/NodeToString.java 2013-01-07 22:52:21 +0000
51@@ -981,7 +981,20 @@
52
53 protected String explainStatementNode(ExplainStatementNode node)
54 throws StandardException {
55- return "EXPLAIN " + toString(node.getStatement());
56+ String detail;
57+ switch (node.getDetail()) {
58+ case BRIEF:
59+ detail = "BRIEF ";
60+ break;
61+ case VERBOSE:
62+ detail = "VERBOSE ";
63+ break;
64+ case NORMAL:
65+ default:
66+ detail = "";
67+ break;
68+ }
69+ return "EXPLAIN " + detail + toString(node.getStatement());
70 }
71
72 protected String transactionControlNode(TransactionControlNode node)
73
74=== modified file 'src/main/javacc/SQLGrammar.jj'
75--- src/main/javacc/SQLGrammar.jj 2012-12-30 20:08:04 +0000
76+++ src/main/javacc/SQLGrammar.jj 2013-01-07 22:52:21 +0000
77@@ -2406,6 +2406,7 @@
78 { /* Additional non-SQL92 non-reserved keywords */
79 <AFTER: "after">
80 | <BEFORE: "before">
81+| <BRIEF: "brief">
82 | <BTREE: "btree">
83 | <CLASS: "class">
84 | <COMPRESS: "compress">
85@@ -2495,6 +2496,7 @@
86 | <UNSIGNED: "unsigned">
87 | <UR: "ur">
88 | <USE: "use">
89+| <VERBOSE: "verbose">
90 | <WEEK: "week">
91 | <WHITESPACE: "whitespace">
92 | <YEAR_MONTH: "year_month">
93@@ -14225,16 +14227,31 @@
94 {
95 StatementNode stmt;
96 Token[] tokenHolder = new Token[1];
97+ ExplainStatementNode.Detail detail = ExplainStatementNode.Detail.NORMAL;
98 }
99 {
100- <EXPLAIN> stmt = declarableStatement(tokenHolder)
101+ <EXPLAIN>
102+ [ detail = explainDetail() ]
103+ stmt = declarableStatement(tokenHolder)
104 {
105 return (StatementNode)nodeFactory.getNode(NodeTypes.EXPLAIN_STATEMENT_NODE,
106- stmt,
107+ stmt, detail,
108 parserContext);
109 }
110 }
111
112+ExplainStatementNode.Detail
113+explainDetail() throws StandardException :
114+{
115+}
116+{
117+ <BRIEF>
118+ { return ExplainStatementNode.Detail.BRIEF; }
119+|
120+ <VERBOSE>
121+ { return ExplainStatementNode.Detail.VERBOSE; }
122+}
123+
124 StatementNode
125 copyStatement() throws StandardException :
126 {
127@@ -14699,6 +14716,7 @@
128 | tok = <BEFORE>
129 | tok = <BINARY>
130 | tok = <BLOB>
131+| tok = <BRIEF>
132 | tok = <BTREE>
133 | tok = <C>
134 | tok = <CALLED>
135@@ -14883,6 +14901,7 @@
136 | tok = <VALUE>
137 | tok = <VARBINARY>
138 | tok = <PARAMETER>
139+| tok = <VERBOSE>
140 | tok = <WEEK>
141 | tok = <WHEN>
142 | tok = <WHITESPACE>
143
144=== added file 'src/test/resources/com/akiban/sql/unparser/explain-2.expected'
145--- src/test/resources/com/akiban/sql/unparser/explain-2.expected 1970-01-01 00:00:00 +0000
146+++ src/test/resources/com/akiban/sql/unparser/explain-2.expected 2013-01-07 22:52:21 +0000
147@@ -0,0 +1,1 @@
148+EXPLAIN VERBOSE SELECT x, y FROM t
149\ No newline at end of file
150
151=== added file 'src/test/resources/com/akiban/sql/unparser/explain-2.sql'
152--- src/test/resources/com/akiban/sql/unparser/explain-2.sql 1970-01-01 00:00:00 +0000
153+++ src/test/resources/com/akiban/sql/unparser/explain-2.sql 2013-01-07 22:52:21 +0000
154@@ -0,0 +1,1 @@
155+EXPLAIN VERBOSE SELECT x,y FROM t
156\ No newline at end of file

Subscribers

People subscribed via source and target branches