Merge lp:~tjoneslo/akiban-sql-parser/fix-bug-1053091 into lp:~akiban-technologies/akiban-sql-parser/trunk

Proposed by Thomas Jones-Low
Status: Merged
Approved by: Nathan Williams
Approved revision: 292
Merged at revision: 291
Proposed branch: lp:~tjoneslo/akiban-sql-parser/fix-bug-1053091
Merge into: lp:~akiban-technologies/akiban-sql-parser/trunk
Diff against target: 223 lines (+97/-18)
7 files modified
src/main/java/com/akiban/sql/parser/ConstraintDefinitionNode.java (+1/-1)
src/main/java/com/akiban/sql/parser/CreateIndexNode.java (+4/-1)
src/main/java/com/akiban/sql/parser/IndexConstraintDefinitionNode.java (+26/-6)
src/main/java/com/akiban/sql/parser/IndexDefinition.java (+26/-0)
src/test/resources/com/akiban/sql/parser/create-table-add-geo-index-1.expected (+17/-6)
src/test/resources/com/akiban/sql/parser/create-table-add-index-1.expected (+14/-2)
src/test/resources/com/akiban/sql/parser/create-table-add-index-2.expected (+9/-2)
To merge this branch: bzr merge lp:~tjoneslo/akiban-sql-parser/fix-bug-1053091
Reviewer Review Type Date Requested Status
Nathan Williams Approve
Review via email: mp+152217@code.launchpad.net

Description of the change

Fix for bug 1152175 and 1053091 -

Add an IndexDefinition interface so the two methods of defining indexes (CreateIndexNode and IndexConstraintDefinitionNode) have a consistent interface to allow the server to create the same indexes from both sets of definitions.

Update the IndexConstraintDefinitionNode output of the IndexColumns so they can be verified.

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

Looks good.

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/ConstraintDefinitionNode.java'
2--- src/main/java/com/akiban/sql/parser/ConstraintDefinitionNode.java 2012-11-07 17:49:31 +0000
3+++ src/main/java/com/akiban/sql/parser/ConstraintDefinitionNode.java 2013-03-07 17:31:22 +0000
4@@ -56,7 +56,7 @@
5 NOT_NULL, PRIMARY_KEY, UNIQUE, CHECK, DROP, FOREIGN_KEY, INDEX
6 }
7
8- private TableName constraintName;
9+ protected TableName constraintName;
10 protected ConstraintType constraintType;
11 protected Properties properties;
12 private ResultColumnList columnList;
13
14=== modified file 'src/main/java/com/akiban/sql/parser/CreateIndexNode.java'
15--- src/main/java/com/akiban/sql/parser/CreateIndexNode.java 2012-11-07 17:49:31 +0000
16+++ src/main/java/com/akiban/sql/parser/CreateIndexNode.java 2013-03-07 17:31:22 +0000
17@@ -52,7 +52,7 @@
18 *
19 */
20
21-public class CreateIndexNode extends DDLStatementNode
22+public class CreateIndexNode extends DDLStatementNode implements IndexDefinition
23 {
24 boolean unique;
25 String indexType;
26@@ -160,6 +160,9 @@
27 public IndexColumnList getColumnList() {
28 return columnList;
29 }
30+ public IndexColumnList getIndexColumnList() {
31+ return columnList;
32+ }
33 public JoinType getJoinType() {
34 return joinType;
35 }
36
37=== modified file 'src/main/java/com/akiban/sql/parser/IndexConstraintDefinitionNode.java'
38--- src/main/java/com/akiban/sql/parser/IndexConstraintDefinitionNode.java 2012-11-07 17:49:31 +0000
39+++ src/main/java/com/akiban/sql/parser/IndexConstraintDefinitionNode.java 2013-03-07 17:31:22 +0000
40@@ -20,7 +20,7 @@
41 import com.akiban.sql.StandardException;
42 import com.akiban.sql.parser.JoinNode.JoinType;
43
44-public class IndexConstraintDefinitionNode extends ConstraintDefinitionNode
45+public class IndexConstraintDefinitionNode extends ConstraintDefinitionNode implements IndexDefinition
46 {
47 private String indexName;
48 private IndexColumnList indexColumnList;
49@@ -36,10 +36,10 @@
50 {
51 super.init(tableName,
52 ConstraintType.INDEX,
53- null, // properties : don't need
54 null, // column list? don't need. Use indexColumnList instead
55- null, // constrainText ?
56- null, // conditionCheck ?
57+ null, // properties - none
58+ null, // constrainText - none
59+ null, // conditionCheck - none
60 StatementType.UNKNOWN, // behaviour?
61 ConstraintType.INDEX);
62
63@@ -58,7 +58,7 @@
64 {
65 return indexColumnList;
66 }
67-
68+
69 public JoinType getJoinType()
70 {
71 return joinType;
72@@ -69,6 +69,17 @@
73 return location;
74 }
75
76+ // This is used for the non-unique "INDEX" defintions only
77+ public boolean getUniqueness()
78+ {
79+ return false;
80+ }
81+
82+ public TableName getObjectName()
83+ {
84+ return constraintName;
85+ }
86+
87 @Override
88 public void copyFrom(QueryTreeNode node) throws StandardException
89 {
90@@ -86,9 +97,18 @@
91 {
92 return super.toString()
93 + "\nindexName: " + indexName
94- + "\nindexColumnList: " + indexColumnList
95 + "\njoinType: " + joinType
96 + "\nlocation: " + location
97 ;
98 }
99+
100+ @Override
101+ public void printSubNodes(int depth) {
102+ super.printSubNodes(depth);
103+ if (indexColumnList != null) {
104+ printLabel(depth, "indexColumnList: ");
105+ indexColumnList.treePrint(depth + 1);
106+ }
107+ }
108+
109 }
110
111=== added file 'src/main/java/com/akiban/sql/parser/IndexDefinition.java'
112--- src/main/java/com/akiban/sql/parser/IndexDefinition.java 1970-01-01 00:00:00 +0000
113+++ src/main/java/com/akiban/sql/parser/IndexDefinition.java 2013-03-07 17:31:22 +0000
114@@ -0,0 +1,26 @@
115+/**
116+ * Copyright © 2012 Akiban Technologies, Inc. All rights
117+ * reserved.
118+ *
119+ * This program and the accompanying materials are made available
120+ * under the terms of the Eclipse Public License v1.0 which
121+ * accompanies this distribution, and is available at
122+ * http://www.eclipse.org/legal/epl-v10.html
123+ *
124+ * This program may also be available under different license terms.
125+ * For more information, see www.akiban.com or contact
126+ * licensing@akiban.com.
127+ *
128+ * Contributors:
129+ * Akiban Technologies, Inc.
130+ */
131+package com.akiban.sql.parser;
132+
133+import com.akiban.sql.parser.JoinNode.JoinType;
134+
135+public interface IndexDefinition {
136+ public boolean getUniqueness();
137+ public JoinType getJoinType();
138+ public IndexColumnList getIndexColumnList();
139+ public TableName getObjectName();
140+}
141
142=== modified file 'src/test/resources/com/akiban/sql/parser/create-table-add-geo-index-1.expected'
143--- src/test/resources/com/akiban/sql/parser/create-table-add-geo-index-1.expected 2012-10-12 17:42:18 +0000
144+++ src/test/resources/com/akiban/sql/parser/create-table-add-geo-index-1.expected 2013-03-07 17:31:22 +0000
145@@ -30,10 +30,21 @@
146 elementType: AT_DROP_CONSTRAINT
147
148 indexName: indx1
149- indexColumnList:
150- methodName: Z_ORDER_LAT_LON
151- firstArg: 0
152- lastArg: 1
153-
154 joinType: null
155- location: null
156\ No newline at end of file
157+ location: null
158+ indexColumnList:
159+ com.akiban.sql.parser.IndexColumnList@63deebc8
160+
161+ methodName: Z_ORDER_LAT_LON
162+ firstArg: 0
163+ lastArg: 1
164+ [0]:
165+ com.akiban.sql.parser.IndexColumn@4049cab1
166+ columnName: c1
167+ tableName: null
168+ ascending
169+ [1]:
170+ com.akiban.sql.parser.IndexColumn@2c9a4b70
171+ columnName: c2
172+ tableName: null
173+ ascending
174\ No newline at end of file
175
176=== modified file 'src/test/resources/com/akiban/sql/parser/create-table-add-index-1.expected'
177--- src/test/resources/com/akiban/sql/parser/create-table-add-index-1.expected 2012-08-15 00:17:14 +0000
178+++ src/test/resources/com/akiban/sql/parser/create-table-add-index-1.expected 2013-03-07 17:31:22 +0000
179@@ -25,6 +25,18 @@
180 elementType: AT_DROP_CONSTRAINT
181
182 indexName: indx1
183- indexColumnList:
184 joinType: null
185- location: null
186\ No newline at end of file
187+ location: null
188+ indexColumnList:
189+ com.akiban.sql.parser.IndexColumnList@3138554d
190+
191+ [0]:
192+ com.akiban.sql.parser.IndexColumn@69684b79
193+ columnName: c1
194+ tableName: null
195+ ascending
196+ [1]:
197+ com.akiban.sql.parser.IndexColumn@3e332aff
198+ columnName: c2
199+ tableName: null
200+ ascending
201\ No newline at end of file
202
203=== modified file 'src/test/resources/com/akiban/sql/parser/create-table-add-index-2.expected'
204--- src/test/resources/com/akiban/sql/parser/create-table-add-index-2.expected 2012-08-15 00:17:14 +0000
205+++ src/test/resources/com/akiban/sql/parser/create-table-add-index-2.expected 2013-03-07 17:31:22 +0000
206@@ -25,6 +25,13 @@
207 elementType: AT_DROP_CONSTRAINT
208
209 indexName: indx1
210- indexColumnList:
211 joinType: null
212- location: BTREE
213\ No newline at end of file
214+ location: BTREE
215+ indexColumnList:
216+ com.akiban.sql.parser.IndexColumnList@114beb40
217+
218+ [0]:
219+ com.akiban.sql.parser.IndexColumn@f41bf9f
220+ columnName: c1
221+ tableName: null
222+ descending
223\ No newline at end of file

Subscribers

People subscribed via source and target branches