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 | */ |
6 | package org.h2.command.ddl; |
7 | |
8 | import org.h2.command.CommandInterface; |
9 | import org.h2.engine.Right; |
10 | import org.h2.engine.Session; |
11 | import org.h2.message.DbException; |
12 | import org.h2.table.TableView; |
13 | |
14 | /** |
15 | * This class represents the statement |
16 | * ALTER VIEW |
17 | */ |
18 | public class AlterView extends DefineCommand { |
19 | |
20 | private TableView view; |
21 | |
22 | public AlterView(Session session) { |
23 | super(session); |
24 | } |
25 | |
26 | public void setView(TableView view) { |
27 | this.view = view; |
28 | } |
29 | |
30 | @Override |
31 | public int update() { |
32 | session.commit(true); |
33 | session.getUser().checkRight(view, Right.ALL); |
34 | DbException e = view.recompile(session, false); |
35 | if (e != null) { |
36 | throw e; |
37 | } |
38 | return 0; |
39 | } |
40 | |
41 | @Override |
42 | public int getType() { |
43 | return CommandInterface.ALTER_VIEW; |
44 | } |
45 | |
46 | } |