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

COVERAGE SUMMARY FOR SOURCE FILE [TruncateTable.java]

nameclass, %method, %block, %line, %
TruncateTable.java100% (1/1)100% (4/4)100% (46/46)100% (12/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TruncateTable100% (1/1)100% (4/4)100% (46/46)100% (12/12)
TruncateTable (Session): void 100% (1/1)100% (4/4)100% (2/2)
getType (): int 100% (1/1)100% (2/2)100% (1/1)
setTable (Table): void 100% (1/1)100% (4/4)100% (2/2)
update (): int 100% (1/1)100% (36/36)100% (7/7)

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.Right;
11import org.h2.engine.Session;
12import org.h2.message.DbException;
13import org.h2.table.Table;
14 
15/**
16 * This class represents the statement
17 * TRUNCATE TABLE
18 */
19public class TruncateTable extends DefineCommand {
20 
21    private Table table;
22 
23    public TruncateTable(Session session) {
24        super(session);
25    }
26 
27    public void setTable(Table table) {
28        this.table = table;
29    }
30 
31    @Override
32    public int update() {
33        session.commit(true);
34        if (!table.canTruncate()) {
35            throw DbException.get(ErrorCode.CANNOT_TRUNCATE_1, table.getSQL());
36        }
37        session.getUser().checkRight(table, Right.DELETE);
38        table.lock(session, true, true);
39        table.truncate(session);
40        return 0;
41    }
42 
43    @Override
44    public int getType() {
45        return CommandInterface.TRUNCATE_TABLE;
46    }
47 
48}

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