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

COVERAGE SUMMARY FOR SOURCE FILE [DropSequence.java]

nameclass, %method, %block, %line, %
DropSequence.java100% (1/1)100% (5/5)91%  (53/58)94%  (17/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DropSequence100% (1/1)100% (5/5)91%  (53/58)94%  (17/18)
update (): int 100% (1/1)88%  (38/43)91%  (10/11)
DropSequence (Session, Schema): void 100% (1/1)100% (5/5)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)
setSequenceName (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;
14import org.h2.schema.Sequence;
15 
16/**
17 * This class represents the statement
18 * DROP SEQUENCE
19 */
20public class DropSequence extends SchemaCommand {
21 
22    private String sequenceName;
23    private boolean ifExists;
24 
25    public DropSequence(Session session, Schema schema) {
26        super(session, schema);
27    }
28 
29    public void setIfExists(boolean b) {
30        ifExists = b;
31    }
32 
33    public void setSequenceName(String sequenceName) {
34        this.sequenceName = sequenceName;
35    }
36 
37    @Override
38    public int update() {
39        session.getUser().checkAdmin();
40        session.commit(true);
41        Database db = session.getDatabase();
42        Sequence sequence = getSchema().findSequence(sequenceName);
43        if (sequence == null) {
44            if (!ifExists) {
45                throw DbException.get(ErrorCode.SEQUENCE_NOT_FOUND_1, sequenceName);
46            }
47        } else {
48            if (sequence.getBelongsToTable()) {
49                throw DbException.get(ErrorCode.SEQUENCE_BELONGS_TO_A_TABLE_1, sequenceName);
50            }
51            db.removeSchemaObject(session, sequence);
52        }
53        return 0;
54    }
55 
56    @Override
57    public int getType() {
58        return CommandInterface.DROP_SEQUENCE;
59    }
60 
61}

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