@Test
 public void testDropOfPKInTenantTablesNotAllowed() throws Exception {
   Properties props = new Properties();
   props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(nextTimestamp()));
   Connection conn = DriverManager.getConnection(PHOENIX_JDBC_TENANT_SPECIFIC_URL, props);
   try {
     // try removing a PK col
     try {
       conn.createStatement().execute("alter table " + TENANT_TABLE_NAME + " drop column id");
       fail();
     } catch (SQLException expected) {
       assertEquals(CANNOT_DROP_PK.getErrorCode(), expected.getErrorCode());
     }
   } finally {
     conn.close();
   }
 }
  @Test
  public void testColumnMutationInParentTableWithExistingTenantTable() throws Exception {
    Properties props = new Properties();
    props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(nextTimestamp()));
    Connection conn = DriverManager.getConnection(getUrl(), props);
    try {
      // try adding a PK col
      try {
        conn.createStatement()
            .execute("alter table " + PARENT_TABLE_NAME + " add new_pk varchar primary key");
        fail();
      } catch (SQLException expected) {
        assertEquals(CANNOT_MUTATE_TABLE.getErrorCode(), expected.getErrorCode());
      }

      // try adding a non-PK col
      try {
        conn.createStatement().execute("alter table " + PARENT_TABLE_NAME + " add new_col char(1)");
        fail();
      } catch (SQLException expected) {
        assertEquals(CANNOT_MUTATE_TABLE.getErrorCode(), expected.getErrorCode());
      }

      // try removing a PK col
      try {
        conn.createStatement().execute("alter table " + PARENT_TABLE_NAME + " drop column id");
        fail();
      } catch (SQLException expected) {
        assertEquals(CANNOT_DROP_PK.getErrorCode(), expected.getErrorCode());
      }

      // try removing a non-PK col
      try {
        conn.createStatement().execute("alter table " + PARENT_TABLE_NAME + " drop column user");
        fail();
      } catch (SQLException expected) {
        assertEquals(CANNOT_MUTATE_TABLE.getErrorCode(), expected.getErrorCode());
      }
    } finally {
      conn.close();
    }
  }
  @Test
  public void testColumnMutationInParentTableWithExistingTenantTable() throws Exception {
    Connection conn = DriverManager.getConnection(getUrl());
    try {
      // try adding a PK col
      try {
        conn.createStatement()
            .execute("alter table " + PARENT_TABLE_NAME + " add new_pk varchar primary key");
        fail();
      } catch (SQLException expected) {
        assertEquals(CANNOT_MUTATE_TABLE.getErrorCode(), expected.getErrorCode());
      }

      // try adding a non-PK col
      try {
        conn.createStatement().execute("alter table " + PARENT_TABLE_NAME + " add new_col char(1)");
        fail();
      } catch (SQLException expected) {
        assertEquals(CANNOT_MUTATE_TABLE.getErrorCode(), expected.getErrorCode());
      }

      // try removing a PK col
      try {
        conn.createStatement().execute("alter table " + PARENT_TABLE_NAME + " drop column id");
        fail();
      } catch (SQLException expected) {
        assertEquals(CANNOT_DROP_PK.getErrorCode(), expected.getErrorCode());
      }

      // try removing a non-PK col
      try {
        conn.createStatement().execute("alter table " + PARENT_TABLE_NAME + " drop column user");
        fail();
      } catch (SQLException expected) {
        assertEquals(CANNOT_MUTATE_TABLE.getErrorCode(), expected.getErrorCode());
      }
    } finally {
      conn.close();
    }
  }
  @Test
  public void testMutationOfPKInTenantTablesNotAllowed() throws Exception {
    Connection conn = DriverManager.getConnection(PHOENIX_JDBC_TENANT_SPECIFIC_URL);
    try {
      try {
        conn.createStatement()
            .execute("alter table " + TENANT_TABLE_NAME + " add new_tenant_pk char(1) primary key");
        fail();
      } catch (SQLException expected) {
        assertEquals(TENANT_TABLE_PK.getErrorCode(), expected.getErrorCode());
      }

      try {
        conn.createStatement().execute("alter table " + TENANT_TABLE_NAME + " drop column id");
        fail();
      } catch (SQLException expected) {
        assertEquals(CANNOT_DROP_PK.getErrorCode(), expected.getErrorCode());
      }
    } finally {
      conn.close();
    }
  }