use of org.h2.result.ResultInterface in project h2database by h2database.
the class ConstraintCheck method checkExistingData.
@Override
public void checkExistingData(Session session) {
if (session.getDatabase().isStarting()) {
// don't check at startup
return;
}
String sql = "SELECT 1 FROM " + filter.getTable().getSQL() + " WHERE NOT(" + expr.getSQL() + ")";
ResultInterface r = session.prepare(sql).query(1);
if (r.next()) {
throw DbException.get(ErrorCode.CHECK_CONSTRAINT_VIOLATED_1, getName());
}
}
use of org.h2.result.ResultInterface in project h2database by h2database.
the class ConditionExists method getValue.
@Override
public Value getValue(Session session) {
query.setSession(session);
ResultInterface result = query.query(1);
session.addTemporaryResult(result);
boolean r = result.hasNext();
return ValueBoolean.get(r);
}
use of org.h2.result.ResultInterface in project h2database by h2database.
the class JdbcPreparedStatement method executeUpdateInternal.
private int executeUpdateInternal() throws SQLException {
closeOldResultSet();
synchronized (session) {
try {
setExecutingStatement(command);
ResultWithGeneratedKeys result = command.executeUpdate(generatedKeysRequest);
updateCount = result.getUpdateCount();
ResultInterface gk = result.getGeneratedKeys();
if (gk != null) {
int id = getNextId(TraceObject.RESULT_SET);
generatedKeys = new JdbcResultSet(conn, this, command, gk, id, false, true, false);
}
} finally {
setExecutingStatement(null);
}
}
return updateCount;
}
use of org.h2.result.ResultInterface in project h2database by h2database.
the class JdbcDatabaseMetaData method hasSynonyms.
private boolean hasSynonyms() {
Boolean hasSynonyms = this.hasSynonyms;
if (hasSynonyms == null) {
SessionInterface si = conn.getSession();
if (si instanceof SessionRemote) {
SessionRemote sr = (SessionRemote) si;
int clientVersion = sr.getClientVersion();
if (clientVersion >= Constants.TCP_PROTOCOL_VERSION_17) {
hasSynonyms = true;
} else if (clientVersion <= Constants.TCP_PROTOCOL_VERSION_15) {
hasSynonyms = false;
} else {
// 1.4.194-1.4.196
CommandInterface c = sr.prepareCommand("CALL H2VERSION()", Integer.MAX_VALUE);
ResultInterface result = c.executeQuery(0, false);
result.next();
String s = result.currentRow()[0].getString();
result.close();
hasSynonyms = "1.4.196".equals(s);
}
} else {
hasSynonyms = true;
}
this.hasSynonyms = hasSynonyms;
}
return hasSynonyms;
}
use of org.h2.result.ResultInterface in project h2database by h2database.
the class ViewIndex method find.
private Cursor find(Session session, SearchRow first, SearchRow last, SearchRow intersection) {
if (recursive) {
return findRecursive(first, last);
}
setupQueryParameters(session, first, last, intersection);
ResultInterface result = query.query(0);
return new ViewCursor(this, result, first, last);
}
Aggregations