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

COVERAGE SUMMARY FOR SOURCE FILE [DropTrigger.java]

nameclass, %method, %block, %line, %
DropTrigger.java100% (1/1)100% (5/5)100% (55/55)100% (17/17)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DropTrigger100% (1/1)100% (5/5)100% (55/55)100% (17/17)
DropTrigger (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)
setTriggerName (String): void 100% (1/1)100% (4/4)100% (2/2)
update (): int 100% (1/1)100% (40/40)100% (10/10)

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.Right;
12import org.h2.engine.Session;
13import org.h2.message.DbException;
14import org.h2.schema.Schema;
15import org.h2.schema.TriggerObject;
16import org.h2.table.Table;
17 
18/**
19 * This class represents the statement
20 * DROP TRIGGER
21 */
22public class DropTrigger extends SchemaCommand {
23 
24    private String triggerName;
25    private boolean ifExists;
26 
27    public DropTrigger(Session session, Schema schema) {
28        super(session, schema);
29    }
30 
31    public void setIfExists(boolean b) {
32        ifExists = b;
33    }
34 
35    public void setTriggerName(String triggerName) {
36        this.triggerName = triggerName;
37    }
38 
39    @Override
40    public int update() {
41        session.commit(true);
42        Database db = session.getDatabase();
43        TriggerObject trigger = getSchema().findTrigger(triggerName);
44        if (trigger == null) {
45            if (!ifExists) {
46                throw DbException.get(ErrorCode.TRIGGER_NOT_FOUND_1, triggerName);
47            }
48        } else {
49            Table table = trigger.getTable();
50            session.getUser().checkRight(table, Right.ALL);
51            db.removeSchemaObject(session, trigger);
52        }
53        return 0;
54    }
55 
56    @Override
57    public int getType() {
58        return CommandInterface.DROP_TRIGGER;
59    }
60 
61}

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