Return-Path: X-Original-To: apmail-phoenix-commits-archive@minotaur.apache.org Delivered-To: apmail-phoenix-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 22410CA95 for ; Wed, 12 Nov 2014 20:28:25 +0000 (UTC) Received: (qmail 49758 invoked by uid 500); 12 Nov 2014 20:28:25 -0000 Delivered-To: apmail-phoenix-commits-archive@phoenix.apache.org Received: (qmail 49723 invoked by uid 500); 12 Nov 2014 20:28:25 -0000 Mailing-List: contact commits-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list commits@phoenix.apache.org Received: (qmail 49713 invoked by uid 99); 12 Nov 2014 20:28:25 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Nov 2014 20:28:25 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id A962AA11529; Wed, 12 Nov 2014 20:28:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jeffreyz@apache.org To: commits@phoenix.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: phoenix git commit: PHOENIX-1442: Alter Index double normalize Index Table Name Date: Wed, 12 Nov 2014 20:28:24 +0000 (UTC) Repository: phoenix Updated Branches: refs/heads/3.0 b5012d994 -> 9b0bb38d3 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/9b0bb38d Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/9b0bb38d Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/9b0bb38d Branch: refs/heads/3.0 Commit: 9b0bb38d37873c1f0ce6fcedc314d3673e8049c4 Parents: b5012d9 Author: Jeffrey Zhong Authored: Wed Nov 12 11:47:40 2014 -0800 Committer: Jeffrey Zhong Committed: Wed Nov 12 12:29:33 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/9b0bb38d/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/9b0bb38d/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 285acf7..95d51b4 100644 --- a/phoenix-core/src/main/antlr3/PhoenixSQL.g +++ b/phoenix-core/src/main/antlr3/PhoenixSQL.g @@ -489,7 +489,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.