You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by je...@apache.org on 2014/11/12 21:20:05 UTC
phoenix git commit: PHOENIX-1442: Alter Index double normalize Index
Table Name
Repository: phoenix
Updated Branches:
refs/heads/4.2 3e99349b7 -> bbdd9e06d
PHOENIX-1442: Alter Index double normalize Index Table Name
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/bbdd9e06
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/bbdd9e06
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/bbdd9e06
Branch: refs/heads/4.2
Commit: bbdd9e06d3eaaf2a29af4846141b83a8e8bf8470
Parents: 3e99349
Author: Jeffrey Zhong <je...@apache.org>
Authored: Wed Nov 12 11:47:40 2014 -0800
Committer: Jeffrey Zhong <je...@apache.org>
Committed: Wed Nov 12 11:47:40 2014 -0800
----------------------------------------------------------------------
.../phoenix/end2end/index/IndexMetadataIT.java | 33 ++++++++++++++++++++
phoenix-core/src/main/antlr3/PhoenixSQL.g | 2 +-
2 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/bbdd9e06/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
index 2547844..fb4b827 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
@@ -342,6 +342,39 @@ public class IndexMetadataIT extends BaseHBaseManagedTimeIT {
conn.close();
}
}
+
+ @Test
+ public void testAlterIndexWithLowerCaseName() throws Exception {
+ Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+ Connection conn = DriverManager.getConnection(getUrl(), props);
+ conn.setAutoCommit(false);
+ String indexName = "\"lowerCaseIndex\"";
+ try {
+ ensureTableCreated(getUrl(), INDEX_DATA_TABLE);
+ String ddl = "CREATE INDEX " + indexName + " ON " + INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + INDEX_DATA_TABLE
+ + " (char_col1 ASC, int_col2 ASC, long_col2 DESC)"
+ + " INCLUDE (int_col1)";
+ PreparedStatement stmt = conn.prepareStatement(ddl);
+ stmt.execute();
+
+ ddl = "ALTER INDEX " + indexName + " ON " + INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + INDEX_DATA_TABLE + " UNUSABLE";
+ conn.createStatement().execute(ddl);
+ // Verify the metadata for index is correct.
+ ResultSet rs = conn.getMetaData().getTables(null, StringUtil.escapeLike(INDEX_DATA_SCHEMA), "lowerCaseIndex", new String[] {PTableType.INDEX.toString()});
+ assertTrue(rs.next());
+ assertEquals("lowerCaseIndex", rs.getString(3));
+
+ ddl = "DROP INDEX " + indexName + " ON " + INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + INDEX_DATA_TABLE;
+ stmt = conn.prepareStatement(ddl);
+ stmt.execute();
+
+ // Assert the rows for index table is completely removed.
+ rs = conn.getMetaData().getIndexInfo(null, INDEX_DATA_SCHEMA, INDEX_DATA_TABLE, false, false);
+ assertFalse(rs.next());
+ } finally {
+ conn.close();
+ }
+ }
@Test
public void testIndexDefinitionWithRepeatedColumns() throws Exception {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/bbdd9e06/phoenix-core/src/main/antlr3/PhoenixSQL.g
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/antlr3/PhoenixSQL.g b/phoenix-core/src/main/antlr3/PhoenixSQL.g
index e2636fb..01db4b6 100644
--- a/phoenix-core/src/main/antlr3/PhoenixSQL.g
+++ b/phoenix-core/src/main/antlr3/PhoenixSQL.g
@@ -488,7 +488,7 @@ drop_index_node returns [DropIndexStatement ret]
// Parse a alter index statement
alter_index_node returns [AlterIndexStatement ret]
: ALTER INDEX (IF ex=EXISTS)? i=index_name ON t=from_table_name s=(USABLE | UNUSABLE | REBUILD | DISABLE)
- {ret = factory.alterIndex(factory.namedTable(null,factory.table(t.getSchemaName(),i.getName())), t.getTableName(), ex!=null, PIndexState.valueOf(SchemaUtil.normalizeIdentifier(s.getText()))); }
+ {ret = factory.alterIndex(factory.namedTable(null, TableName.create(t.getSchemaName(), i.getName())), t.getTableName(), ex!=null, PIndexState.valueOf(SchemaUtil.normalizeIdentifier(s.getText()))); }
;
// Parse an alter table statement.