use of org.hsqldb_voltpatches.types.Type in project voltdb by VoltDB.
the class Table method checkColumnsMatch.
/**
* Match two valid, equal length, columns arrays for type of columns
*
* @param col column array from this Table
* @param other the other Table object
* @param othercol column array from the other Table
*/
void checkColumnsMatch(int[] col, Table other, int[] othercol) {
for (int i = 0; i < col.length; i++) {
Type type = colTypes[col[i]];
Type otherType = other.colTypes[othercol[i]];
if (type.typeComparisonGroup != otherType.typeComparisonGroup) {
throw Error.error(ErrorCode.X_42562);
}
}
}
use of org.hsqldb_voltpatches.types.Type in project voltdb by VoltDB.
the class Table method enforceRowConstraints.
/**
* Enforce max field sizes according to SQL column definition.
* SQL92 13.8
*/
void enforceRowConstraints(Session session, Object[] data) {
for (int i = 0; i < defaultColumnMap.length; i++) {
Type type = colTypes[i];
data[i] = type.convertToTypeLimits(session, data[i]);
if (type.isDomainType()) {
Constraint[] constraints = type.userTypeModifier.getConstraints();
for (int j = 0; j < constraints.length; j++) {
constraints[j].checkCheckConstraint(session, this, data[i]);
}
}
if (data[i] == null) {
if (colNotNull[i]) {
Constraint c = getNotNullConstraintForColumn(i);
if (c == null) {
if (getColumn(i).isPrimaryKey()) {
c = this.getPrimaryConstraint();
}
}
String[] info = new String[] { c.getName().name, tableName.name };
throw Error.error(ErrorCode.X_23503, ErrorCode.CONSTRAINT, info);
}
}
}
}
use of org.hsqldb_voltpatches.types.Type in project voltdb by VoltDB.
the class Session method executeResultUpdate.
/**
* Retrieves the result of inserting, updating or deleting a row
* from an updatable result.
*
* @return the result of executing the statement
*/
private Result executeResultUpdate(Result cmd) {
long id = cmd.getResultId();
int actionType = cmd.getActionType();
Result result = sessionData.getDataResult(id);
if (result == null) {
return Result.newErrorResult(Error.error(ErrorCode.X_24501));
}
Object[] pvals = cmd.getParameterData();
Type[] types = cmd.metaData.columnTypes;
StatementQuery statement = (StatementQuery) result.getStatement();
QueryExpression qe = statement.queryExpression;
Table baseTable = qe.getBaseTable();
int[] columnMap = qe.getBaseTableColumnMap();
sessionContext.rowUpdateStatement.setRowActionProperties(actionType, baseTable, types, columnMap);
Result resultOut = executeCompiledStatement(sessionContext.rowUpdateStatement, pvals);
return resultOut;
}
use of org.hsqldb_voltpatches.types.Type in project voltdb by VoltDB.
the class StatementInsert method getInsertSelectNavigator.
RowSetNavigator getInsertSelectNavigator(Session session) {
Type[] colTypes = baseTable.getColumnTypes();
int[] columnMap = insertColumnMap;
//
Result result = queryExpression.getResult(session, 0);
RowSetNavigator nav = result.initialiseNavigator();
Type[] sourceTypes = result.metaData.columnTypes;
RowSetNavigatorClient newData = new RowSetNavigatorClient(2);
while (nav.hasNext()) {
Object[] data = baseTable.getNewRowData(session);
Object[] sourceData = (Object[]) nav.getNext();
for (int i = 0; i < columnMap.length; i++) {
int j = columnMap[i];
Type sourceType = sourceTypes[i];
data[j] = colTypes[j].convertToType(session, sourceData[i], sourceType);
}
newData.add(data);
}
return newData;
}
use of org.hsqldb_voltpatches.types.Type in project voltdb by VoltDB.
the class Routine method getMethod.
static Method getMethod(String name, Type[] types, Type returnType, boolean[] nullability, boolean[] hasConnection) {
int i = name.indexOf(':');
if (i != -1) {
if (!name.substring(0, i).equals(SqlInvariants.CLASSPATH_NAME)) {
throw Error.error(ErrorCode.X_46102, name);
}
name = name.substring(i + 1);
}
Method method = null;
Method[] methods = getMethods(name);
for (i = 0; i < methods.length; i++) {
int offset = 0;
Class[] params = methods[i].getParameterTypes();
if (params.length > 0 && params[0].equals(java.sql.Connection.class)) {
offset = 1;
hasConnection[0] = true;
}
if (params.length - offset != types.length) {
continue;
}
Type methodReturnType = Type.getDefaultType(Types.getParameterSQLTypeNumber(methods[i].getReturnType()));
if (methodReturnType == null) {
continue;
}
if (methodReturnType.typeCode != returnType.typeCode) {
continue;
}
method = methods[i];
for (int j = 0; j < types.length; j++) {
Class param = params[j + offset];
Type methodParamType = Type.getDefaultType(Types.getParameterSQLTypeNumber(param));
if (methodParamType == null) {
break;
}
nullability[j] = !param.isPrimitive();
if (types[j].typeCode != methodParamType.typeCode) {
method = null;
break;
}
}
if (method != null) {
break;
}
}
return method;
}
Aggregations