use of org.hsqldb_voltpatches.result.Result in project voltdb by VoltDB.
the class LobManager method setChars.
public Result setChars(Session session, long lobID, long offset, char[] chars) {
if (chars.length == 0) {
return ResultLob.newLobSetResponse(lobID, 0);
}
Object[] data = getLobHeader(session, lobID);
if (data == null) {
return Result.newErrorResult(Error.error(ErrorCode.X_0F502));
}
long length = ((Long) data[1]).longValue();
HsqlByteArrayOutputStream os = new HsqlByteArrayOutputStream(chars.length * 2);
os.write(chars, 0, chars.length);
Result result = setBytesBA(session, lobID, os.getBuffer(), offset * 2, os.getBuffer().length);
if (result.isError()) {
return result;
}
if (offset + chars.length > length) {
result = setLength(session, lobID, offset + chars.length);
if (result.isError()) {
return result;
}
}
return ResultLob.newLobSetResponse(lobID, 0);
}
use of org.hsqldb_voltpatches.result.Result in project voltdb by VoltDB.
the class ScriptWriterBase method writeDDL.
protected void writeDDL() throws IOException {
Result ddlPart = database.getScript(!includeCachedData);
writeSingleColumnResult(ddlPart);
}
use of org.hsqldb_voltpatches.result.Result in project voltdb by VoltDB.
the class ScriptReaderBinary method readDDL.
protected void readDDL(Session session) throws IOException {
Result r = Result.newResult(dataStreamIn, rowIn);
r.readAdditionalResults(session, dataStreamIn, rowIn);
RowSetNavigator nav = r.initialiseNavigator();
while (nav.hasNext()) {
Object[] data = (Object[]) nav.getNext();
String s = (String) data[0];
Result result = session.executeDirectStatement(s);
if (result.isError()) {
db.logger.appLog.logContext(SimpleLog.LOG_ERROR, result.getMainString());
throw Error.error(result);
}
}
}
use of org.hsqldb_voltpatches.result.Result in project voltdb by VoltDB.
the class BlobDataID method setBytes.
public int setBytes(SessionInterface session, long pos, byte[] bytes, int offset, int len) {
ResultLob resultOut = ResultLob.newLobSetBytesRequest(id, pos, bytes);
Result resultIn = (ResultLob) session.execute(resultOut);
if (resultIn.isError()) {
throw resultIn.getException();
}
return bytes.length;
}
use of org.hsqldb_voltpatches.result.Result in project voltdb by VoltDB.
the class FunctionSQLInvoked method getValue.
public Object getValue(Session session) {
int variableCount = routine.getVariableCount();
Result result;
int extraArg = routine.javaMethodWithConnection ? 1 : 0;
Object[] data = ValuePool.emptyObjectArray;
Object returnValue = null;
boolean push = routine.isPSM() || routine.dataImpact != Routine.NO_SQL;
if (extraArg + nodes.length > 0) {
data = new Object[nodes.length + extraArg];
if (extraArg > 0) {
data[0] = session.getInternalConnection();
}
}
for (int i = 0; i < nodes.length; i++) {
Expression e = nodes[i];
Object value = e.getValue(session, e.dataType);
if (value == null) {
if (routine.isNullInputOutput()) {
return null;
}
if (!routine.parameterNullable[i]) {
throw Error.error(ErrorCode.X_39004);
}
}
if (routine.isPSM()) {
data[i] = value;
} else {
data[i + extraArg] = e.dataType.convertSQLToJava(session, value);
}
}
if (push) {
session.sessionContext.push();
}
if (routine.isPSM()) {
session.sessionContext.routineArguments = data;
session.sessionContext.routineVariables = ValuePool.emptyObjectArray;
if (variableCount > 0) {
session.sessionContext.routineVariables = new Object[variableCount];
}
result = routine.statement.execute(session);
if (result.isError()) {
} else if (result.isSimpleValue()) {
returnValue = result.getValueObject();
} else {
result = Result.newErrorResult(Error.error(ErrorCode.X_2F005, routine.getName().name), null);
}
} else {
try {
returnValue = routine.javaMethod.invoke(null, data);
if (routine.returnsTable()) {
// convert ResultSet to table
} else {
returnValue = dataType.convertJavaToSQL(session, returnValue);
}
result = Result.updateZeroResult;
} catch (InvocationTargetException e) {
result = Result.newErrorResult(Error.error(ErrorCode.X_46000, routine.getName().name), null);
} catch (IllegalAccessException e) {
result = Result.newErrorResult(Error.error(ErrorCode.X_46000, routine.getName().name), null);
} catch (Throwable e) {
result = Result.newErrorResult(Error.error(ErrorCode.X_46000, routine.getName().name), null);
}
}
if (push) {
if (result.isError()) {
session.rollbackToSavepoint();
}
session.sessionContext.pop();
}
if (result.isError()) {
throw result.getException();
}
return returnValue;
}
Aggregations