SchemaDDL { public static void createSchema (AkibanInformationSchema ais, String defaultSchemaName, CreateSchemaNode createSchema, QueryContext context) { final String schemaName = createSchema.getSchemaName(); Schema curSchema = ais.getSchema(schemaName); if((curSchema != null) && skipOrThrow(context, createSchema.getExistenceCheck(), curSchema, new DuplicateSchemaException(schemaName))) { return; } } private  SchemaDDL(); static void createSchema(AkibanInformationSchema ais,
                                   String defaultSchemaName,
                                   CreateSchemaNode createSchema,
                                   QueryContext context); static void dropSchema(DDLFunctions ddlFunctions,
            Session session,
            DropSchemaNode dropSchema,
            QueryContext context);  }
@Test public void createSchemaEmpty () throws Exception { String sql = "CREATE SCHEMA EMPTY"; AkibanInformationSchema ais = new AkibanInformationSchema(); StatementNode stmt = parser.parseStatement(sql); assertTrue (stmt instanceof CreateSchemaNode); SchemaDDL.createSchema(ais, null, (CreateSchemaNode)stmt, null); }
@Test (expected=DuplicateSchemaException.class) public void createSchemaUsed() throws Exception { String sql = "CREATE SCHEMA S"; AkibanInformationSchema ais = factory(); assertNotNull(ais.getTable("s", "t")); StatementNode stmt = parser.parseStatement(sql); assertTrue (stmt instanceof CreateSchemaNode); SchemaDDL.createSchema(ais, null, (CreateSchemaNode)stmt, null); }
@Test public void createNonDuplicateSchemaWithIfNotExist() throws Exception { String sql = "CREATE SCHEMA IF NOT EXISTS SS"; AkibanInformationSchema ais = factory(); assertNotNull(ais.getTable("s", "t")); StatementNode stmt = parser.parseStatement(sql); assertTrue (stmt instanceof CreateSchemaNode); SchemaDDL.createSchema(ais, null, (CreateSchemaNode)stmt, null); }
@Test public void createDuplicateSchemaWithIfNotExist() throws Exception { String sql = "CREATE SCHEMA IF NOT EXISTS S"; AkibanInformationSchema ais = factory(); assertNotNull(ais.getTable("s", "t")); StatementNode stmt = parser.parseStatement(sql); assertTrue (stmt instanceof CreateSchemaNode); SchemaDDL.createSchema(ais, null, (CreateSchemaNode)stmt, null); }