TableDDL { public static void dropTable (DDLFunctions ddlFunctions, Session session, String defaultSchemaName, DropTableNode dropTable, QueryContext context) { TableName tableName = convertName(defaultSchemaName, dropTable.getObjectName()); AkibanInformationSchema ais = ddlFunctions.getAIS(session); Table table = ais.getTable(tableName); if(table == null) { if(skipOrThrow(context, dropTable.getExistenceCheck(), table, new NoSuchTableException(tableName))) { return; } } ViewDDL.checkDropTable(ddlFunctions, session, tableName); checkForeignKeyDropTable(table); ddlFunctions.dropTable(session, tableName); } private  TableDDL(); static void dropTable(DDLFunctions ddlFunctions,
                                  Session session, 
                                  String defaultSchemaName,
                                  DropTableNode dropTable,
                                  QueryContext context); static void dropGroup(DDLFunctions ddlFunctions,
                                    Session session,
                                    String defaultSchemaName,
                                    DropGroupNode dropGroup,
                                    QueryContext context); static void renameTable(DDLFunctions ddlFunctions,
                                    Session session,
                                    String defaultSchemaName,
                                    RenameNode renameTable); static void createTable(DDLFunctions ddlFunctions,
                                   Session session,
                                   String defaultSchemaName,
                                   CreateTableNode createTable,
                                   QueryContext context); static void createTable(DDLFunctions ddlFunctions,
                                   Session session,
                                   String defaultSchemaName,
                                   CreateTableNode createTable,
                                   QueryContext context,
                                   List<DataTypeDescriptor>  descriptors,
                                   List<String> columnNames,
                                   ServerSession server); static void setStorage(DDLFunctions ddlFunctions,
                                  HasStorage object, 
                                  StorageFormatNode storage); static void setAutoIncrement(AISBuilder builder, String schema, String table, ColumnDefinitionNode cdn); static void setAutoIncrement(AISBuilder builder, String schemaName, String tableName, String columnName,
                                        boolean defaultIdentity, long start, long increment); static String addIndex(IndexNameGenerator namer, AISBuilder builder, ConstraintDefinitionNode cdn,
                                  String schemaName, String tableName, QueryContext context); static String addIndex(IndexNameGenerator namer,
                                  AISBuilder builder,
                                  IndexDefinitionNode idn,
                                  String schemaName,
                                  String tableName,
                                  QueryContext context,
                                  DDLFunctions ddl); static TableName getReferencedName(String schemaName, FKConstraintDefinitionNode fkdn); static void addJoin(final AISBuilder builder, final FKConstraintDefinitionNode fkdn,
                               final String defaultSchemaName, final String schemaName, final String tableName);  }
@Test public void dropExistingTableWithIfExists() throws StandardException { String sql = "DROP TABLE IF EXISTS " + DEFAULT_TABLE; createTableSimpleGenerateAIS(); StatementNode node = parser.parseStatement(sql); assertTrue(node instanceof DropTableNode); TableDDL.dropTable(ddlFunctions, null, DEFAULT_SCHEMA, (DropTableNode)node, null); }
@Test public void dropNonExistingTableWithIfExists() throws StandardException { String sql = "DROP TABLE IF EXISTS chair"; createTableSimpleGenerateAIS(); StatementNode node = parser.parseStatement(sql); assertTrue(node instanceof DropTableNode); TableDDL.dropTable(ddlFunctions, null, DEFAULT_SCHEMA, (DropTableNode)node, null); }
@Test public void dropTableSimple() throws Exception { String sql = "DROP TABLE t1"; dropTable = TableName.create(DEFAULT_SCHEMA, DEFAULT_TABLE); createTableSimpleGenerateAIS (); StatementNode stmt = parser.parseStatement(sql); assertTrue (stmt instanceof DropTableNode); TableDDL.dropTable(ddlFunctions, null, DEFAULT_SCHEMA, (DropTableNode)stmt, null); }
@Test public void dropTableSchemaTrue() throws Exception { String sql = "DROP TABLE test.t1"; dropTable = TableName.create(DEFAULT_SCHEMA, DEFAULT_TABLE); createTableSimpleGenerateAIS (); StatementNode stmt = parser.parseStatement(sql); assertTrue (stmt instanceof DropTableNode); TableDDL.dropTable(ddlFunctions, null, DEFAULT_SCHEMA, (DropTableNode)stmt, null); }
@Test (expected=NoSuchTableException.class) public void dropTableSchema() throws Exception { String sql = "DROP TABLE foo.t1"; createTableSimpleGenerateAIS (); dropTable = TableName.create("foo", DEFAULT_TABLE); StatementNode stmt = parser.parseStatement(sql); assertTrue (stmt instanceof DropTableNode); TableDDL.dropTable(ddlFunctions, null, DEFAULT_SCHEMA, (DropTableNode)stmt, null); }
@Test (expected=NoSuchTableException.class) public void dropTableQuoted() throws Exception { String sql = "DROP TABLE \"T1\""; dropTable = TableName.create(DEFAULT_SCHEMA, "T1"); createTableSimpleGenerateAIS (); StatementNode stmt = parser.parseStatement(sql); assertTrue (stmt instanceof DropTableNode); TableDDL.dropTable(ddlFunctions, null, DEFAULT_SCHEMA, (DropTableNode)stmt, null); }