use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class ParserRoutine method readSimpleCaseWhen.
private HsqlArrayList readSimpleCaseWhen(Routine routine, StatementCompound context) {
HsqlArrayList list = new HsqlArrayList();
RangeVariable[] rangeVariables = context == null ? routine.getParameterRangeVariables() : context.getRangeVariables();
HsqlList unresolved = null;
Expression condition = null;
Statement statement;
Statement[] statements;
Expression predicand = XreadRowValuePredicand();
do {
readThis(Tokens.WHEN);
do {
Expression newCondition = XreadPredicateRightPart(predicand);
if (predicand == newCondition) {
newCondition = new ExpressionLogical(predicand, XreadRowValuePredicand());
}
unresolved = newCondition.resolveColumnReferences(rangeVariables, rangeVariables.length, unresolved, false);
ExpressionColumn.checkColumnsResolved(unresolved);
unresolved = null;
newCondition.resolveTypes(session, null);
if (condition == null) {
condition = newCondition;
} else {
condition = new ExpressionLogical(OpTypes.OR, condition, newCondition);
}
if (token.tokenType == Tokens.COMMA) {
read();
} else {
break;
}
} while (true);
statement = new StatementSimple(StatementTypes.CONDITION, condition);
list.add(statement);
readThis(Tokens.THEN);
statements = readSQLProcedureStatementList(routine, context);
for (int i = 0; i < statements.length; i++) {
list.add(statements[i]);
}
if (token.tokenType != Tokens.WHEN) {
break;
}
} while (true);
return list;
}
use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class ParserRoutine method readSQLProcedureStatementList.
private Statement[] readSQLProcedureStatementList(Routine routine, StatementCompound context) {
Statement e = readSQLProcedureStatementOrNull(routine, context);
if (e == null) {
throw unexpectedToken();
}
readThis(Tokens.SEMICOLON);
HsqlArrayList list = new HsqlArrayList();
list.add(e);
while (true) {
e = readSQLProcedureStatementOrNull(routine, context);
if (e == null) {
break;
}
readThis(Tokens.SEMICOLON);
list.add(e);
}
Statement[] statements = new Statement[list.size()];
list.toArray(statements);
return statements;
}
use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class Routine method getMethods.
static Method[] getMethods(String name) {
int i = name.lastIndexOf('.');
if (i == -1) {
throw Error.error(ErrorCode.X_42501, name);
}
String classname = name.substring(0, i);
String methodname = name.substring(i + 1);
Class classinstance = null;
try {
classinstance = Class.forName(classname);
} catch (Exception e) {
throw Error.error(ErrorCode.X_42501, ErrorCode.M_Message_Pair, new Object[] { classname, e });
}
Method[] methods = classinstance.getMethods();
HsqlArrayList list = new HsqlArrayList();
for (i = 0; i < methods.length; i++) {
int offset = 0;
Method m = methods[i];
int modifiers = m.getModifiers();
if (!m.getName().equals(methodname) || !Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers)) {
continue;
}
Class[] params = methods[i].getParameterTypes();
if (params.length > 0 && params[0].equals(java.sql.Connection.class)) {
offset = 1;
}
for (int j = offset; j < params.length; j++) {
Class param = params[j];
Type methodParamType = Type.getDefaultTypeWithSize(Types.getParameterSQLTypeNumber(param));
if (methodParamType == null) {
m = null;
break;
}
}
if (m == null) {
continue;
}
Type methodReturnType = Type.getDefaultTypeWithSize(Types.getParameterSQLTypeNumber(m.getReturnType()));
if (methodReturnType != null) {
list.add(methods[i]);
}
}
methods = new Method[list.size()];
list.toArray(methods);
return methods;
}
use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class Table method getSQL.
String[] getSQL(OrderedHashSet resolved, OrderedHashSet unresolved) {
for (int i = 0; i < constraintList.length; i++) {
Constraint c = constraintList[i];
if (c.isForward) {
unresolved.add(c);
} else if (c.getConstraintType() == Constraint.UNIQUE || c.getConstraintType() == Constraint.PRIMARY_KEY) {
resolved.add(c.getName());
}
}
HsqlArrayList list = new HsqlArrayList();
list.add(getSQL());
// readonly for TEXT tables only
if (isText()) {
if (((TextTable) this).isConnected() && isDataReadOnly()) {
StringBuffer sb = new StringBuffer(64);
sb.append(Tokens.T_SET).append(' ').append(Tokens.T_TABLE).append(' ');
sb.append(getName().getSchemaQualifiedStatementName());
sb.append(' ').append(Tokens.T_READONLY).append(' ');
sb.append(Tokens.T_TRUE);
list.add(sb.toString());
}
// data source
String dataSource = ((TextTable) this).getDataSourceDDL();
if (dataSource != null) {
list.add(dataSource);
}
// header
String header = ((TextTable) this).getDataSourceHeader();
if (header != null) {
list.add(header);
}
}
if (!isTemp && hasIdentityColumn()) {
list.add(NumberSequence.getRestartSQL(this));
}
for (int i = 0; i < indexList.length; i++) {
if (!indexList[i].isConstraint()) {
list.add(indexList[i].getSQL());
}
}
String[] array = new String[list.size()];
list.toArray(array);
return array;
}
use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class TransactionManager method getRowActionList.
// functional unit - list actions and translate id's
/**
* Return an array of all row actions sorted by System Change No.
*/
RowAction[] getRowActionList() {
try {
writeLock.lock();
Session[] sessions = database.sessionManager.getAllSessions();
int[] tIndex = new int[sessions.length];
RowAction[] rowActions;
int rowActionCount = 0;
{
int actioncount = 0;
for (int i = 0; i < sessions.length; i++) {
actioncount += sessions[i].getTransactionSize();
}
rowActions = new RowAction[actioncount];
}
while (true) {
boolean found = false;
long minChangeNo = Long.MAX_VALUE;
int sessionIndex = 0;
// find the lowest available SCN across all sessions
for (int i = 0; i < sessions.length; i++) {
int tSize = sessions[i].getTransactionSize();
if (tIndex[i] < tSize) {
RowAction current = (RowAction) sessions[i].rowActionList.get(tIndex[i]);
if (current.actionTimestamp < minChangeNo) {
minChangeNo = current.actionTimestamp;
sessionIndex = i;
}
found = true;
}
}
if (!found) {
break;
}
HsqlArrayList currentList = sessions[sessionIndex].rowActionList;
for (; tIndex[sessionIndex] < currentList.size(); ) {
RowAction current = (RowAction) currentList.get(tIndex[sessionIndex]);
// if the next change no is in this session, continue adding
if (current.actionTimestamp == minChangeNo + 1) {
minChangeNo++;
}
if (current.actionTimestamp == minChangeNo) {
rowActions[rowActionCount++] = current;
tIndex[sessionIndex]++;
} else {
break;
}
}
}
return rowActions;
} finally {
writeLock.unlock();
}
}
Aggregations