You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by td...@apache.org on 2019/03/28 23:59:35 UTC

[phoenix] branch 4.x-HBase-1.2 updated: PHOENIX-5207 Create index if not exists fails incorrectly if table has 'maxIndexesPerTable' indexes already

This is an automated email from the ASF dual-hosted git repository.

tdsilva pushed a commit to branch 4.x-HBase-1.2
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/4.x-HBase-1.2 by this push:
     new fcba5e2  PHOENIX-5207 Create index if not exists fails incorrectly if table has 'maxIndexesPerTable' indexes already
fcba5e2 is described below

commit fcba5e24e3c558388cc62081d60d780cf49f373b
Author: Abhishek Singh Chouhan <ab...@gmail.com>
AuthorDate: Wed Mar 27 19:00:40 2019 -0700

    PHOENIX-5207 Create index if not exists fails incorrectly if table has 'maxIndexesPerTable' indexes already
---
 .../apache/phoenix/end2end/index/BaseIndexIT.java  | 37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/BaseIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/BaseIndexIT.java
index 7c14fba..e98b7bb 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/BaseIndexIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/BaseIndexIT.java
@@ -42,6 +42,7 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Random;
 
+import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.CellScanner;
 import org.apache.hadoop.hbase.HConstants;
@@ -68,6 +69,7 @@ import org.apache.phoenix.parse.NamedTableNode;
 import org.apache.phoenix.parse.TableName;
 import org.apache.phoenix.query.BaseTest;
 import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.query.QueryServicesOptions;
 import org.apache.phoenix.schema.PTable;
 import org.apache.phoenix.schema.PTableImpl;
 import org.apache.phoenix.schema.PTableKey;
@@ -1302,5 +1304,40 @@ public abstract class BaseIndexIT extends ParallelStatsDisabledIT {
         }
     }
 
+    @Test
+    public void testMaxIndexesPerTable() throws SQLException {
+        String tableName = "TBL_" + generateUniqueName();
+        String indexName = "IND_" + generateUniqueName();
+        String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+            Configuration conf =
+                    conn.unwrap(PhoenixConnection.class).getQueryServices().getConfiguration();
+            int maxIndexes =
+                    conf.getInt(QueryServices.MAX_INDEXES_PER_TABLE,
+                        QueryServicesOptions.DEFAULT_MAX_INDEXES_PER_TABLE);
+            conn.createStatement()
+                    .execute("CREATE TABLE " + fullTableName
+                            + " (k VARCHAR NOT NULL PRIMARY KEY, \"V1\" VARCHAR, \"v2\" VARCHAR)"
+                            + tableDDLOptions);
+            for (int i = 0; i < maxIndexes; i++) {
+                conn.createStatement().execute("CREATE " + (localIndex ? "LOCAL " : "") + "INDEX "
+                        + indexName + i + " ON " + fullTableName + "(\"v2\") INCLUDE (\"V1\")");
+            }
+            try {
+                conn.createStatement()
+                        .execute("CREATE " + (localIndex ? "LOCAL " : "") + "INDEX " + indexName
+                                + maxIndexes + " ON " + fullTableName
+                                + "(\"v2\") INCLUDE (\"V1\")");
+                fail("Expected exception TOO_MANY_INDEXES");
+            } catch (SQLException e) {
+                assertEquals(e.getErrorCode(), SQLExceptionCode.TOO_MANY_INDEXES.getErrorCode());
+            }
+            conn.createStatement()
+                    .execute("CREATE " + (localIndex ? "LOCAL " : "") + "INDEX IF NOT EXISTS "
+                            + indexName + "0" + " ON " + fullTableName
+                            + "(\"v2\") INCLUDE (\"V1\")");
+        }
+    }
 
 }