EMMA Coverage Report (generated Sun Mar 01 22:06:14 CET 2015)
[all classes][org.h2.command.ddl]

COVERAGE SUMMARY FOR SOURCE FILE [DropSchema.java]

nameclass, %method, %block, %line, %
DropSchema.java100% (1/1)100% (5/5)91%  (51/56)94%  (17/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DropSchema100% (1/1)100% (5/5)91%  (51/56)94%  (17/18)
update (): int 100% (1/1)88%  (37/42)91%  (10/11)
DropSchema (Session): void 100% (1/1)100% (4/4)100% (2/2)
getType (): int 100% (1/1)100% (2/2)100% (1/1)
setIfExists (boolean): void 100% (1/1)100% (4/4)100% (2/2)
setSchemaName (String): void 100% (1/1)100% (4/4)100% (2/2)

1/*
2 * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (http://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6package org.h2.command.ddl;
7 
8import org.h2.api.ErrorCode;
9import org.h2.command.CommandInterface;
10import org.h2.engine.Database;
11import org.h2.engine.Session;
12import org.h2.message.DbException;
13import org.h2.schema.Schema;
14 
15/**
16 * This class represents the statement
17 * DROP SCHEMA
18 */
19public class DropSchema extends DefineCommand {
20 
21    private String schemaName;
22    private boolean ifExists;
23 
24    public DropSchema(Session session) {
25        super(session);
26    }
27 
28    public void setSchemaName(String name) {
29        this.schemaName = name;
30    }
31 
32    @Override
33    public int update() {
34        session.getUser().checkSchemaAdmin();
35        session.commit(true);
36        Database db = session.getDatabase();
37        Schema schema = db.findSchema(schemaName);
38        if (schema == null) {
39            if (!ifExists) {
40                throw DbException.get(ErrorCode.SCHEMA_NOT_FOUND_1, schemaName);
41            }
42        } else {
43            if (!schema.canDrop()) {
44                throw DbException.get(ErrorCode.SCHEMA_CAN_NOT_BE_DROPPED_1, schemaName);
45            }
46            db.removeDatabaseObject(session, schema);
47        }
48        return 0;
49    }
50 
51    public void setIfExists(boolean ifExists) {
52        this.ifExists = ifExists;
53    }
54 
55    @Override
56    public int getType() {
57        return CommandInterface.DROP_SCHEMA;
58    }
59 
60}

[all classes][org.h2.command.ddl]
EMMA 2.0.5312 (C) Vladimir Roubtsov