Search in sources :

Example 1 with UserTypeModifier

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

the class ParserDDL method compileCreateType.

StatementSchema compileCreateType() {
    read();
    HsqlName name = readNewSchemaObjectNameNoCheck(SchemaObject.TYPE);
    readThis(Tokens.AS);
    Type type = readTypeDefinition(false).duplicate();
    readIfThis(Tokens.FINAL);
    UserTypeModifier userTypeModifier = new UserTypeModifier(name, SchemaObject.TYPE, type);
    type.userTypeModifier = userTypeModifier;
    String sql = getLastPart();
    Object[] args = new Object[] { type };
    return new StatementSchema(sql, StatementTypes.CREATE_TYPE, args, null, null);
}
Also used : Type(org.hsqldb_voltpatches.types.Type) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) UserTypeModifier(org.hsqldb_voltpatches.types.UserTypeModifier)

Example 2 with UserTypeModifier

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

the class ParserDDL method compileCreateDomain.

StatementSchema compileCreateDomain() {
    UserTypeModifier userTypeModifier = null;
    HsqlName name;
    read();
    name = readNewSchemaObjectNameNoCheck(SchemaObject.DOMAIN);
    readIfThis(Tokens.AS);
    Type type = readTypeDefinition(false).duplicate();
    Expression defaultClause = null;
    if (readIfThis(Tokens.DEFAULT)) {
        defaultClause = readDefaultClause(type);
    }
    userTypeModifier = new UserTypeModifier(name, SchemaObject.DOMAIN, type);
    userTypeModifier.setDefaultClause(defaultClause);
    type.userTypeModifier = userTypeModifier;
    HsqlArrayList tempConstraints = new HsqlArrayList();
    compileContext.currentDomain = type;
    while (true) {
        boolean end = false;
        switch(token.tokenType) {
            case Tokens.CONSTRAINT:
            case Tokens.CHECK:
                readConstraint(type, tempConstraints);
                break;
            default:
                end = true;
                break;
        }
        if (end) {
            break;
        }
    }
    compileContext.currentDomain = null;
    for (int i = 0; i < tempConstraints.size(); i++) {
        Constraint c = (Constraint) tempConstraints.get(i);
        c.prepareCheckConstraint(session, null, false);
        userTypeModifier.addConstraint(c);
    }
    String sql = getLastPart();
    Object[] args = new Object[] { type };
    return new StatementSchema(sql, StatementTypes.CREATE_DOMAIN, args, null, null);
}
Also used : Type(org.hsqldb_voltpatches.types.Type) HsqlArrayList(org.hsqldb_voltpatches.lib.HsqlArrayList) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) UserTypeModifier(org.hsqldb_voltpatches.types.UserTypeModifier)

Aggregations

HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)2 Type (org.hsqldb_voltpatches.types.Type)2 UserTypeModifier (org.hsqldb_voltpatches.types.UserTypeModifier)2 HsqlArrayList (org.hsqldb_voltpatches.lib.HsqlArrayList)1