Search in sources :

Example 16 with Type

use of org.hsqldb_voltpatches.types.Type in project voltdb by VoltDB.

the class QuerySpecification method resolveTypesPartTwo.

@Override
void resolveTypesPartTwo(Session session) {
    resolveGroups();
    for (int i = 0; i < unionColumnMap.length; i++) {
        Type type = unionColumnTypes[unionColumnMap[i]];
        if (type == null) {
            throw Error.error(ErrorCode.X_42567);
        }
        exprColumns[unionColumnMap[i]].setDataType(session, type);
    }
    for (int i = 0; i < indexStartOrderBy; i++) {
        if (exprColumns[i].dataType == null) {
            throw Error.error(ErrorCode.X_42567);
        }
    }
    setReferenceableColumns();
    setUpdatability();
    createResultMetaData();
    createTable(session);
    if (isUpdatable) {
        getMergedSelect();
    }
}
Also used : Type(org.hsqldb_voltpatches.types.Type)

Example 17 with Type

use of org.hsqldb_voltpatches.types.Type in project voltdb by VoltDB.

the class ParserRoutine method readRoutineParameter.

private ColumnSchema readRoutineParameter(Routine routine) {
    HsqlName hsqlName = null;
    byte parameterMode = SchemaObject.ParameterModes.PARAM_IN;
    switch(token.tokenType) {
        case Tokens.IN:
            read();
            break;
        case Tokens.OUT:
            if (routine.getType() != SchemaObject.PROCEDURE) {
                throw unexpectedToken();
            }
            read();
            parameterMode = SchemaObject.ParameterModes.PARAM_OUT;
            break;
        case Tokens.INOUT:
            if (routine.getType() != SchemaObject.PROCEDURE) {
                throw unexpectedToken();
            }
            read();
            parameterMode = SchemaObject.ParameterModes.PARAM_INOUT;
            break;
        default:
    }
    if (!isReservedKey()) {
        hsqlName = readNewDependentSchemaObjectName(routine.getName(), SchemaObject.PARAMETER);
    }
    Type typeObject = readTypeDefinition(true);
    ColumnSchema column = new ColumnSchema(hsqlName, typeObject, false, false, null);
    column.setParameterMode(parameterMode);
    return column;
}
Also used : Type(org.hsqldb_voltpatches.types.Type) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Example 18 with Type

use of org.hsqldb_voltpatches.types.Type 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;
}
Also used : Type(org.hsqldb_voltpatches.types.Type) HsqlArrayList(org.hsqldb_voltpatches.lib.HsqlArrayList) Method(java.lang.reflect.Method)

Example 19 with Type

use of org.hsqldb_voltpatches.types.Type in project voltdb by VoltDB.

the class Table method checkColumnsMatch.

void checkColumnsMatch(ColumnSchema column, int colIndex) {
    Type type = colTypes[colIndex];
    Type otherType = column.getDataType();
    if (type.typeComparisonGroup != otherType.typeComparisonGroup) {
        throw Error.error(ErrorCode.X_42562);
    }
}
Also used : Type(org.hsqldb_voltpatches.types.Type)

Example 20 with Type

use of org.hsqldb_voltpatches.types.Type in project voltdb by VoltDB.

the class TableBase method createIndexStructure.

final Index createIndexStructure(HsqlName name, int[] columns, boolean[] descending, boolean[] nullsLast, boolean unique, boolean constraint, boolean forward) {
    if (primaryKeyCols == null) {
        // A VoltDB extension to support matview-based indexes
        primaryKeyCols = new int[0];
    /* disable 1 line ...
            throw Error.runtimeError(ErrorCode.U_S0500, "createIndex");
            ... disabled 1 line */
    // End of VoltDB extension
    }
    int s = columns.length;
    int[] cols = new int[s];
    Type[] types = new Type[s];
    for (int j = 0; j < s; j++) {
        cols[j] = columns[j];
        types[j] = colTypes[cols[j]];
    }
    long id = database.persistentStoreCollection.getNextId();
    Index newIndex = new IndexAVL(name, id, this, cols, descending, nullsLast, types, false, unique, constraint, forward);
    return newIndex;
}
Also used : Type(org.hsqldb_voltpatches.types.Type) Index(org.hsqldb_voltpatches.index.Index) IndexAVL(org.hsqldb_voltpatches.index.IndexAVL)

Aggregations

Type (org.hsqldb_voltpatches.types.Type)72 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)20 CharacterType (org.hsqldb_voltpatches.types.CharacterType)20 NumberType (org.hsqldb_voltpatches.types.NumberType)14 SchemaObject (org.hsqldb_voltpatches.SchemaObject)11 Table (org.hsqldb_voltpatches.Table)9 Iterator (org.hsqldb_voltpatches.lib.Iterator)9 WrapperIterator (org.hsqldb_voltpatches.lib.WrapperIterator)9 IntervalType (org.hsqldb_voltpatches.types.IntervalType)9 Constraint (org.hsqldb_voltpatches.Constraint)8 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)8 HsqlException (org.hsqldb_voltpatches.HsqlException)7 TextTable (org.hsqldb_voltpatches.TextTable)6 HsqlArrayList (org.hsqldb_voltpatches.lib.HsqlArrayList)6 DTIType (org.hsqldb_voltpatches.types.DTIType)6 ColumnSchema (org.hsqldb_voltpatches.ColumnSchema)4 DateTimeType (org.hsqldb_voltpatches.types.DateTimeType)4 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)3 IOException (java.io.IOException)2 Method (java.lang.reflect.Method)2