1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.command;
import java.util.ArrayList;
import org.h2.engine.Session;
import org.h2.expression.ParameterInterface;
import org.h2.result.ResultInterface;
/**
* Represents a list of SQL statements.
*/
class CommandList extends Command {
private final Command command;
private final String remaining;
CommandList(Session session, String sql, Command c, String remaining) {
super(session, sql);
this.command = c;
this.remaining = remaining;
}
@Override
public ArrayList<? extends ParameterInterface> getParameters() {
return command.getParameters();
}
private void executeRemaining() {
Command remainingCommand = session.prepareLocal(remaining);
if (remainingCommand.isQuery()) {
remainingCommand.query(0);
} else {
remainingCommand.update();
}
}
@Override
public int update() {
int updateCount = command.executeUpdate(false).getUpdateCount();
executeRemaining();
return updateCount;
}
@Override
public void prepareJoinBatch() {
command.prepareJoinBatch();
}
@Override
public ResultInterface query(int maxrows) {
ResultInterface result = command.query(maxrows);
executeRemaining();
return result;
}
@Override
public boolean isQuery() {
return command.isQuery();
}
@Override
public boolean isTransactional() {
return true;
}
@Override
public boolean isReadOnly() {
return false;
}
@Override
public ResultInterface queryMeta() {
return command.queryMeta();
}
@Override
public int getCommandType() {
return command.getCommandType();
}
}