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

COVERAGE SUMMARY FOR SOURCE FILE [AlterTableSet.java]

nameclass, %method, %block, %line, %
AlterTableSet.java100% (1/1)100% (6/6)85%  (64/75)94%  (17/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AlterTableSet100% (1/1)100% (6/6)85%  (64/75)94%  (17/18)
update (): int 100% (1/1)78%  (40/51)88%  (7/8)
AlterTableSet (Session, Schema, int, boolean): void 100% (1/1)100% (11/11)100% (4/4)
getType (): int 100% (1/1)100% (3/3)100% (1/1)
isTransactional (): boolean 100% (1/1)100% (2/2)100% (1/1)
setCheckExisting (boolean): void 100% (1/1)100% (4/4)100% (2/2)
setTableName (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.dml;
7 
8import org.h2.command.CommandInterface;
9import org.h2.command.ddl.SchemaCommand;
10import org.h2.engine.Right;
11import org.h2.engine.Session;
12import org.h2.message.DbException;
13import org.h2.schema.Schema;
14import org.h2.table.Table;
15 
16/**
17 * This class represents the statement
18 * ALTER TABLE SET
19 */
20public class AlterTableSet extends SchemaCommand {
21 
22    private String tableName;
23    private final int type;
24 
25    private final boolean value;
26    private boolean checkExisting;
27 
28    public AlterTableSet(Session session, Schema schema, int type, boolean value) {
29        super(session, schema);
30        this.type = type;
31        this.value = value;
32    }
33 
34    public void setCheckExisting(boolean b) {
35        this.checkExisting = b;
36    }
37 
38    @Override
39    public boolean isTransactional() {
40        return true;
41    }
42 
43    public void setTableName(String tableName) {
44        this.tableName = tableName;
45    }
46 
47    @Override
48    public int update() {
49        Table table = getSchema().getTableOrView(session, tableName);
50        session.getUser().checkRight(table, Right.ALL);
51        table.lock(session, true, true);
52        switch(type) {
53        case CommandInterface.ALTER_TABLE_SET_REFERENTIAL_INTEGRITY:
54            table.setCheckForeignKeyConstraints(session, value, value ?
55                    checkExisting : false);
56            break;
57        default:
58            DbException.throwInternalError("type="+type);
59        }
60        return 0;
61    }
62 
63    @Override
64    public int getType() {
65        return type;
66    }
67 
68}

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