Ejemplo n.º 1
0
  @Test
  public void testB() throws Throwable {
    declareBaseTable();
    conn.execute("using container testcont (global)");
    conn.execute("insert into bt values (1, 'one')");
    conn.assertResults(
        "show container_tenants", br(nr, "testcont", "id:1,junk:'one'", getIgnore()));
    conn.execute("insert into bt values (2, 'two')");
    conn.assertResults(
        "show container_tenants like '%two%'", br(nr, "testcont", "id:2,junk:'two'", getIgnore()));
    conn.execute("using container testcont (1, 'one')");
    String errorMessage =
        "Internal error: Inserts into base table `bt` for container testcont must be done when in the global container context";

    // should not be able to insert into base table as a nonglobal container tenant
    new ExpectedSqlErrorTester() {
      @Override
      public void test() throws Throwable {
        conn.execute("insert into bt values (3, 'three')");
      }
    }.assertError(SchemaException.class, MySQLErrors.internalFormatter, errorMessage);
    conn.disconnect();
    conn.connect();
    conn.execute("use " + testDDL.getDatabaseName());

    // should not be able to insert into base table in the null container tenant
    new ExpectedSqlErrorTester() {
      @Override
      public void test() throws Throwable {
        conn.execute("insert into bt values (3, 'three')");
      }
    }.assertError(SchemaException.class, MySQLErrors.internalFormatter, errorMessage);
  }
Ejemplo n.º 2
0
 @Test
 public void testD() throws Throwable {
   declareBaseTable();
   conn.execute("using container testcont (global)");
   conn.execute("insert into bt values (1, 'one')");
   conn.execute("insert into bt values (2, 'two')");
   conn.execute("using container testcont (1, 'one')");
   conn.execute(
       "create table A (`id` int, `junk` varchar(32), primary key (id)) container distribute testcont");
   conn.execute(
       "create table B (`id` int, `junk` varchar(32), primary key (id)) container distribute testcont");
   conn.disconnect();
   conn.connect();
   conn.execute("use " + testDDL.getDatabaseName());
   // shouldn't be able to insert into CMT with no context specified
   new ExpectedSqlErrorTester() {
     @Override
     public void test() throws Throwable {
       conn.execute("insert into A values (1,'one')");
     }
   }.assertError(
       SchemaException.class,
       MySQLErrors.internalFormatter,
       "Internal error: Inserts into table `A` for container testcont must be done when in a specific container context");
   // shouldn't be able to insert into CMT with nonglobal context specified
   conn.execute("using container testcont (global)");
   new ExpectedSqlErrorTester() {
     @Override
     public void test() throws Throwable {
       conn.execute("insert into A values (1,'one')");
     }
   }.assertError(
       SchemaException.class,
       MySQLErrors.internalFormatter,
       "Internal error: Inserts into table `A` for container testcont must be done when in a specific container context");
 }
Ejemplo n.º 3
0
 @After
 public void teardown() throws Throwable {
   testDDL.destroy(conn);
   conn.disconnect();
   conn = null;
 }