Debian Codegraph @

src/main/org/h2/command/ddl/AlterView.java

raw
1 /*
2 * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (https://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.SessionLocal;
10 import org.h2.message.DbException;
11 import org.h2.table.TableView;
12
13 /**
14 * This class represents the statement
15 * ALTER VIEW
16 */
17 public class AlterView extends DefineCommand {
18
19 private boolean ifExists;
20 private TableView view;
21
22 public AlterView(SessionLocal session) {
23 super(session);
24 }
25
26 public void setIfExists(boolean b) {
27 ifExists = b;
28 }
29
30 public void setView(TableView view) {
31 this.view = view;
32 }
33
34 @Override
35 public long update() {
36 if (view == null && ifExists) {
37 return 0;
38 }
39 session.getUser().checkSchemaOwner(view.getSchema());
40 DbException e = view.recompile(session, false, true);
41 if (e != null) {
42 throw e;
43 }
44 return 0;
45 }
46
47 @Override
48 public int getType() {
49 return CommandInterface.ALTER_VIEW;
50 }
51
52 }