Search in sources :

Example 1 with CharacterType

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

the class ParserDQL method readTypeDefinition.

Type readTypeDefinition(boolean includeUserTypes) {
    int typeNumber = Integer.MIN_VALUE;
    checkIsIdentifier();
    if (token.namePrefix == null) {
        typeNumber = Type.getTypeNr(token.tokenString);
    }
    if (typeNumber == Integer.MIN_VALUE) {
        if (includeUserTypes) {
            checkIsSchemaObjectName();
            String schemaName = session.getSchemaName(token.namePrefix);
            Type type = database.schemaManager.getDomain(token.tokenString, schemaName, false);
            if (type != null) {
                read();
                return type;
            }
        }
        throw Error.error(ErrorCode.X_42509, token.tokenString);
    }
    read();
    switch(typeNumber) {
        case Types.SQL_CHAR:
            if (token.tokenType == Tokens.VARYING) {
                read();
                typeNumber = Types.SQL_VARCHAR;
            } else if (token.tokenType == Tokens.LARGE) {
                readThis(Tokens.OBJECT);
                read();
                typeNumber = Types.SQL_CLOB;
            }
            break;
        case Types.SQL_DOUBLE:
            if (token.tokenType == Tokens.PRECISION) {
                read();
            }
            break;
        case Types.SQL_BINARY:
            if (token.tokenType == Tokens.VARYING) {
                read();
                typeNumber = Types.SQL_VARBINARY;
            } else if (token.tokenType == Tokens.LARGE) {
                readThis(Tokens.OBJECT);
                read();
                typeNumber = Types.SQL_BLOB;
            }
            break;
        case Types.SQL_BIT:
            if (token.tokenType == Tokens.VARYING) {
                read();
                typeNumber = Types.SQL_BIT_VARYING;
            }
            break;
        case Types.SQL_INTERVAL:
            return readIntervalType();
        default:
    }
    long length = typeNumber == Types.SQL_TIMESTAMP ? DTIType.defaultTimestampFractionPrecision : 0;
    int scale = 0;
    if (Types.requiresPrecision(typeNumber) && token.tokenType != Tokens.OPENBRACKET && database.sqlEnforceStrictSize) {
        throw unexpectedTokenRequire(Tokens.T_OPENBRACKET);
    }
    // A VoltDB extension to support the character in bytes.
    boolean inBytes = false;
    // End of VoltDB extension
    if (Types.acceptsPrecision(typeNumber)) {
        if (token.tokenType == Tokens.OPENBRACKET) {
            int multiplier = 1;
            read();
            switch(token.tokenType) {
                case Tokens.X_VALUE:
                    if (token.dataType.typeCode != Types.SQL_INTEGER && token.dataType.typeCode != Types.SQL_BIGINT) {
                        throw unexpectedToken();
                    }
                    break;
                case Tokens.X_LOB_SIZE:
                    if (typeNumber == Types.SQL_BLOB || typeNumber == Types.SQL_CLOB) {
                        switch(token.lobMultiplierType) {
                            case Tokens.K:
                                multiplier = 1024;
                                break;
                            case Tokens.M:
                                multiplier = 1024 * 1024;
                                break;
                            case Tokens.G:
                                multiplier = 1024 * 1024 * 1024;
                                break;
                            case Tokens.P:
                            case Tokens.T:
                            default:
                                throw unexpectedToken();
                        }
                        break;
                    } else {
                        throw unexpectedToken(token.getFullString());
                    }
                default:
                    throw unexpectedToken();
            }
            length = ((Number) token.tokenValue).longValue();
            if (length < 0 || (length == 0 && !Types.acceptsZeroPrecision(typeNumber))) {
                throw Error.error(ErrorCode.X_42592);
            }
            length *= multiplier;
            read();
            if (typeNumber == Types.SQL_CHAR || typeNumber == Types.SQL_VARCHAR || typeNumber == Types.SQL_CLOB) {
                if (token.tokenType == Tokens.CHARACTERS) {
                    read();
                } else if (token.tokenType == Tokens.OCTETS) {
                    read();
                    length /= 2;
                }
            }
            if (Types.acceptsScaleCreateParam(typeNumber) && token.tokenType == Tokens.COMMA) {
                read();
                scale = readInteger();
                if (scale < 0) {
                    throw Error.error(ErrorCode.X_42592);
                }
            }
            // A VoltDB extension to support the character in bytes.
            if (typeNumber == Types.SQL_VARCHAR) {
                inBytes = readIfThis(Tokens.BYTES);
            }
            // End of VoltDB extension
            readThis(Tokens.CLOSEBRACKET);
        } else if (typeNumber == Types.SQL_BIT) {
            length = 1;
        } else if (typeNumber == Types.SQL_BLOB || typeNumber == Types.SQL_CLOB) {
            length = BlobType.defaultBlobSize;
        } else if (database.sqlEnforceStrictSize) {
            // BIT is always BIT(1), regardless of sqlEnforceStringSize
            if (typeNumber == Types.SQL_CHAR || typeNumber == Types.SQL_BINARY) {
                length = 1;
            }
        }
        if (typeNumber == Types.SQL_TIMESTAMP || typeNumber == Types.SQL_TIME) {
            if (length > DTIType.maxFractionPrecision) {
                throw Error.error(ErrorCode.X_42592);
            }
            scale = (int) length;
            length = 0;
            if (token.tokenType == Tokens.WITH) {
                read();
                readThis(Tokens.TIME);
                readThis(Tokens.ZONE);
                if (typeNumber == Types.SQL_TIMESTAMP) {
                    typeNumber = Types.SQL_TIMESTAMP_WITH_TIME_ZONE;
                } else {
                    typeNumber = Types.SQL_TIME_WITH_TIME_ZONE;
                }
            } else if (token.tokenType == Tokens.WITHOUT) {
                read();
                readThis(Tokens.TIME);
                readThis(Tokens.ZONE);
            }
        }
    }
    Type typeObject = Type.getType(typeNumber, 0, length, scale);
    if (typeObject.isCharacterType()) {
        // A VoltDB extension to support the character in bytes.
        if (inBytes) {
            ((CharacterType) typeObject).inBytes = true;
        }
        // End of VoltDB extension
        if (token.tokenType == Tokens.CHARACTER) {
            read();
            readThis(Tokens.SET);
            checkIsSchemaObjectName();
            String schemaName = session.getSchemaName(token.namePrefix);
            Charset charset = (Charset) database.schemaManager.getSchemaObject(token.tokenString, schemaName, SchemaObject.CHARSET);
            read();
        }
    }
    return typeObject;
}
Also used : IntervalType(org.hsqldb_voltpatches.types.IntervalType) DTIType(org.hsqldb_voltpatches.types.DTIType) Type(org.hsqldb_voltpatches.types.Type) CharacterType(org.hsqldb_voltpatches.types.CharacterType) BlobType(org.hsqldb_voltpatches.types.BlobType) Charset(org.hsqldb_voltpatches.types.Charset)

Example 2 with CharacterType

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

the class Expression method prepareTable.

void prepareTable(Session session, Expression row, int degree) {
    if (nodeDataTypes != null) {
        return;
    }
    for (int i = 0; i < nodes.length; i++) {
        Expression e = nodes[i];
        if (e.opType == OpTypes.ROW) {
            if (degree != e.nodes.length) {
                throw Error.error(ErrorCode.X_42564);
            }
        } else if (degree == 1) {
            nodes[i] = new Expression(OpTypes.ROW);
            nodes[i].nodes = new Expression[] { e };
        } else {
            throw Error.error(ErrorCode.X_42564);
        }
    }
    nodeDataTypes = new Type[degree];
    for (int j = 0; j < degree; j++) {
        Type type = row == null ? null : row.nodes[j].dataType;
        for (int i = 0; i < nodes.length; i++) {
            type = Type.getAggregateType(nodes[i].nodes[j].dataType, type);
        }
        if (type == null) {
            throw Error.error(ErrorCode.X_42567);
        }
        nodeDataTypes[j] = type;
        if (row != null && row.nodes[j].isParam) {
            row.nodes[j].dataType = type;
        }
        for (int i = 0; i < nodes.length; i++) {
            if (nodes[i].nodes[j].isParam) {
                nodes[i].nodes[j].dataType = nodeDataTypes[j];
                continue;
            }
            if (nodes[i].nodes[j].opType == OpTypes.VALUE) {
                if (nodes[i].nodes[j].valueData == null) {
                    nodes[i].nodes[j].dataType = nodeDataTypes[j];
                }
            }
        }
        if (nodeDataTypes[j].isCharacterType() && !((CharacterType) nodeDataTypes[j]).isEqualIdentical()) {
        // collation issues
        }
    }
}
Also used : Type(org.hsqldb_voltpatches.types.Type) CharacterType(org.hsqldb_voltpatches.types.CharacterType) NullType(org.hsqldb_voltpatches.types.NullType) NumberType(org.hsqldb_voltpatches.types.NumberType) CharacterType(org.hsqldb_voltpatches.types.CharacterType)

Example 3 with CharacterType

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

the class DatabaseInformationFull method DOMAINS.

/**
     * The DOMAINS view has one row for each domain. <p>
     *
     *
     * <pre class="SqlCodeExample">
     *
     * </pre>
     *
     * @return Table
     */
Table DOMAINS() {
    Table t = sysTables[DOMAINS];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[DOMAINS]);
        addColumn(t, "DOMAIN_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "DOMAIN_SCHEMA", SQL_IDENTIFIER);
        addColumn(t, "DOMAIN_NAME", SQL_IDENTIFIER);
        addColumn(t, "DATA_TYPE", SQL_IDENTIFIER);
        addColumn(t, "CHARACTER_MAXIMUM_LENGTH", CARDINAL_NUMBER);
        addColumn(t, "CHARACTER_OCTET_LENGTH", CARDINAL_NUMBER);
        addColumn(t, "CHARACTER_SET_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "CHARACTER_SET_SCHEMA", SQL_IDENTIFIER);
        addColumn(t, "CHARACTER_SET_NAME", SQL_IDENTIFIER);
        addColumn(t, "COLLATION_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "COLLATION_SCHEMA", SQL_IDENTIFIER);
        addColumn(t, "COLLATION_NAME", SQL_IDENTIFIER);
        addColumn(t, "NUMERIC_PRECISION", CARDINAL_NUMBER);
        addColumn(t, "NUMERIC_PRECISION_RADIX", CARDINAL_NUMBER);
        addColumn(t, "NUMERIC_SCALE", CARDINAL_NUMBER);
        addColumn(t, "DATETIME_PRECISION", CARDINAL_NUMBER);
        addColumn(t, "INTERVAL_TYPE", CHARACTER_DATA);
        addColumn(t, "INTERVAL_PRECISION", CARDINAL_NUMBER);
        addColumn(t, "DOMAIN_DEFAULT", CHARACTER_DATA);
        addColumn(t, "MAXIMUM_CARDINALITY", SQL_IDENTIFIER);
        addColumn(t, "DTD_IDENTIFIER", SQL_IDENTIFIER);
        addColumn(t, "DECLARED_DATA_TYPE", CHARACTER_DATA);
        addColumn(t, "DECLARED_NUMERIC_PRECISION", CARDINAL_NUMBER);
        addColumn(t, "DECLARED_NUMERIC_SCLAE", CARDINAL_NUMBER);
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[DOMAINS].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 0, 1, 2, 4, 5, 6 }, false);
        return t;
    }
    final int domain_catalog = 0;
    final int domain_schema = 1;
    final int domain_name = 2;
    final int data_type = 3;
    final int character_maximum_length = 4;
    final int character_octet_length = 5;
    final int character_set_catalog = 6;
    final int character_set_schema = 7;
    final int character_set_name = 8;
    final int collation_catalog = 9;
    final int collation_schema = 10;
    final int collation_name = 11;
    final int numeric_precision = 12;
    final int numeric_precision_radix = 13;
    final int numeric_scale = 14;
    final int datetime_precision = 15;
    final int interval_type = 16;
    final int interval_precision = 17;
    final int domain_default = 18;
    final int maximum_cardinality = 19;
    final int dtd_identifier = 20;
    final int declared_data_type = 21;
    final int declared_numeric_precision = 22;
    final int declared_numeric_scale = 23;
    //
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    //
    Iterator it = database.schemaManager.databaseObjectIterator(SchemaObject.DOMAIN);
    while (it.hasNext()) {
        Type domain = (Type) it.next();
        if (!domain.isDomainType()) {
            continue;
        }
        if (!session.getGrantee().isAccessible(domain)) {
            continue;
        }
        Object[] data = t.getEmptyRowData();
        data[domain_catalog] = database.getCatalogName().name;
        data[domain_schema] = domain.getSchemaName().name;
        data[domain_name] = domain.getName().name;
        data[data_type] = domain.getFullNameString();
        if (domain.isCharacterType()) {
            data[character_maximum_length] = ValuePool.getLong(domain.precision);
            data[character_octet_length] = ValuePool.getLong(domain.precision * 2);
            data[character_set_catalog] = database.getCatalogName().name;
            data[character_set_schema] = ((CharacterType) domain).getCharacterSet().getSchemaName().name;
            data[character_set_name] = ((CharacterType) domain).getCharacterSet().getName().name;
            data[collation_catalog] = database.getCatalogName().name;
            data[collation_schema] = ((CharacterType) domain).getCollation().getSchemaName().name;
            data[collation_name] = ((CharacterType) domain).getCollation().getName().name;
        } else if (domain.isNumberType()) {
            data[numeric_precision] = ValuePool.getLong(((NumberType) domain).getPrecision());
            data[declared_numeric_precision] = data[numeric_precision];
            if (domain.typeCode != Types.SQL_DOUBLE) {
                data[numeric_scale] = ValuePool.getLong(domain.scale);
                data[declared_numeric_scale] = data[numeric_scale];
            }
            data[numeric_precision_radix] = ValuePool.getLong(((NumberType) domain).getPrecisionRadix());
        } else if (domain.isBooleanType()) {
        } else if (domain.isDateTimeType()) {
            data[datetime_precision] = ValuePool.getLong(domain.scale);
        } else if (domain.isIntervalType()) {
            data[interval_precision] = ValuePool.getLong(domain.precision);
            data[interval_type] = domain.getFullNameString();
            data[datetime_precision] = ValuePool.getLong(domain.scale);
        } else if (domain.isBinaryType()) {
            data[character_maximum_length] = ValuePool.getLong(domain.precision);
            data[character_octet_length] = ValuePool.getLong(domain.precision);
        } else if (domain.isBitType()) {
            data[character_maximum_length] = ValuePool.getLong(domain.precision);
            data[character_octet_length] = ValuePool.getLong(domain.precision);
        }
        Expression defaultExpression = domain.userTypeModifier.getDefaultClause();
        if (defaultExpression != null) {
            data[domain_default] = defaultExpression.getSQL();
        }
        t.insertSys(store, data);
    }
    return t;
}
Also used : Type(org.hsqldb_voltpatches.types.Type) CharacterType(org.hsqldb_voltpatches.types.CharacterType) NumberType(org.hsqldb_voltpatches.types.NumberType) IntervalType(org.hsqldb_voltpatches.types.IntervalType) Table(org.hsqldb_voltpatches.Table) TextTable(org.hsqldb_voltpatches.TextTable) Expression(org.hsqldb_voltpatches.Expression) Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) SchemaObject(org.hsqldb_voltpatches.SchemaObject) Constraint(org.hsqldb_voltpatches.Constraint)

Example 4 with CharacterType

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

the class DatabaseInformationFull method COLUMNS.

Table COLUMNS() {
    Table t = sysTables[COLUMNS];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[COLUMNS]);
        //0
        addColumn(t, "TABLE_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "TABLE_SCHEMA", SQL_IDENTIFIER);
        addColumn(t, "TABLE_NAME", SQL_IDENTIFIER);
        addColumn(t, "COLUMN_NAME", SQL_IDENTIFIER);
        addColumn(t, "ORDINAL_POSITION", CARDINAL_NUMBER);
        addColumn(t, "COLUMN_DEFAULT", CHARACTER_DATA);
        addColumn(t, "IS_NULLABLE", YES_OR_NO);
        addColumn(t, "DATA_TYPE", CHARACTER_DATA);
        addColumn(t, "CHARACTER_MAXIMUM_LENGTH", CARDINAL_NUMBER);
        addColumn(t, "CHARACTER_OCTET_LENGTH", CARDINAL_NUMBER);
        //10
        addColumn(t, "NUMERIC_PRECISION", CARDINAL_NUMBER);
        addColumn(t, "NUMERIC_PRECISION_RADIX", CARDINAL_NUMBER);
        addColumn(t, "NUMERIC_SCALE", CARDINAL_NUMBER);
        addColumn(t, "DATETIME_PRECISION", CARDINAL_NUMBER);
        addColumn(t, "INTERVAL_TYPE", CHARACTER_DATA);
        addColumn(t, "INTERVAL_PRECISION", CARDINAL_NUMBER);
        addColumn(t, "CHARACTER_SET_CATALOG", CHARACTER_DATA);
        addColumn(t, "CHARACTER_SET_SCHEMA", SQL_IDENTIFIER);
        addColumn(t, "CHARACTER_SET_NAME", SQL_IDENTIFIER);
        addColumn(t, "COLLATION_CATALOG", SQL_IDENTIFIER);
        //20
        addColumn(t, "COLLATION_SCHEMA", SQL_IDENTIFIER);
        addColumn(t, "COLLATION_NAME", SQL_IDENTIFIER);
        addColumn(t, "DOMAIN_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "DOMAIN_SCHEMA", SQL_IDENTIFIER);
        addColumn(t, "DOMAIN_NAME", SQL_IDENTIFIER);
        addColumn(t, "UDT_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "UDT_SCHEMA", SQL_IDENTIFIER);
        addColumn(t, "UDT_NAME", SQL_IDENTIFIER);
        addColumn(t, "SCOPE_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "SCOPE_SCHEMA", SQL_IDENTIFIER);
        //30
        addColumn(t, "SCOPE_NAME", SQL_IDENTIFIER);
        // NULL (only for array tyes)
        addColumn(t, "MAXIMUM_CARDINALITY", CARDINAL_NUMBER);
        addColumn(t, "DTD_IDENTIFIER", SQL_IDENTIFIER);
        addColumn(t, "IS_SELF_REFERENCING", YES_OR_NO);
        addColumn(t, "IS_IDENTITY", YES_OR_NO);
        // ALLWAYS / BY DEFAULT
        addColumn(t, "IDENTITY_GENERATION", CHARACTER_DATA);
        addColumn(t, "IDENTITY_START", CHARACTER_DATA);
        addColumn(t, "IDENTITY_INCREMENT", CHARACTER_DATA);
        addColumn(t, "IDENTITY_MAXIMUM", CHARACTER_DATA);
        addColumn(t, "IDENTITY_MINIMUM", CHARACTER_DATA);
        //40
        addColumn(t, "IDENTITY_CYCLE", YES_OR_NO);
        // ALLWAYS / NEVER
        addColumn(t, "IS_GENERATED", CHARACTER_DATA);
        addColumn(t, "GENERATION_EXPRESSION", CHARACTER_DATA);
        addColumn(t, "IS_UPDATABLE", YES_OR_NO);
        addColumn(t, "DECLARED_DATA_TYPE", CHARACTER_DATA);
        addColumn(t, "DECLARED_NUMERIC_PRECISION", CARDINAL_NUMBER);
        addColumn(t, "DECLARED_NUMERIC_SCALE", CARDINAL_NUMBER);
        // order: TABLE_SCHEM, TABLE_NAME, ORDINAL_POSITION
        // added for unique: TABLE_CAT
        // false PK, as TABLE_SCHEM and/or TABLE_CAT may be null
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[COLUMNS].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 3, 2, 1, 4 }, false);
        return t;
    }
    // column number mappings
    final int table_cat = 0;
    final int table_schem = 1;
    final int table_name = 2;
    final int column_name = 3;
    final int ordinal_position = 4;
    final int column_default = 5;
    final int is_nullable = 6;
    final int data_type = 7;
    final int character_maximum_length = 8;
    final int character_octet_length = 9;
    final int numeric_precision = 10;
    final int numeric_precision_radix = 11;
    final int numeric_scale = 12;
    final int datetime_precision = 13;
    final int interval_type = 14;
    final int interval_precision = 15;
    final int character_set_catalog = 16;
    final int character_set_schema = 17;
    final int character_set_name = 18;
    final int collation_catalog = 19;
    final int collation_schema = 20;
    final int collation_name = 21;
    final int domain_catalog = 22;
    final int domain_schema = 23;
    final int domain_name = 24;
    final int udt_catalog = 25;
    final int udt_schema = 26;
    final int udt_name = 27;
    final int scope_catalog = 28;
    final int scope_schema = 29;
    final int scope_name = 30;
    final int maximum_cardinality = 31;
    final int dtd_identifier = 32;
    final int is_self_referencing = 33;
    final int is_identity = 34;
    final int identity_generation = 35;
    final int identity_start = 36;
    final int identity_increment = 37;
    final int identity_maximum = 38;
    final int identity_minimum = 39;
    final int identity_cycle = 40;
    final int is_generated = 41;
    final int generation_expression = 42;
    final int is_updatable = 43;
    final int declared_data_type = 44;
    final int declared_numeric_precision = 45;
    final int declared_numeric_scale = 46;
    //
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    // intermediate holders
    int columnCount;
    Iterator tables;
    Table table;
    Object[] row;
    DITableInfo ti;
    OrderedHashSet columnList;
    Type type;
    // Initialization
    tables = allTables();
    ti = new DITableInfo();
    while (tables.hasNext()) {
        table = (Table) tables.next();
        columnList = session.getGrantee().getColumnsForAllPrivileges(table);
        if (columnList.isEmpty()) {
            continue;
        }
        ti.setTable(table);
        columnCount = table.getColumnCount();
        for (int i = 0; i < columnCount; i++) {
            ColumnSchema column = table.getColumn(i);
            type = column.getDataType();
            if (!columnList.contains(column.getName())) {
                continue;
            }
            row = t.getEmptyRowData();
            row[table_cat] = table.getCatalogName().name;
            row[table_schem] = table.getSchemaName().name;
            row[table_name] = table.getName().name;
            row[column_name] = column.getName().name;
            row[ordinal_position] = ValuePool.getInt(i + 1);
            row[column_default] = column.getDefaultSQL();
            row[is_nullable] = column.isNullable() ? "YES" : "NO";
            row[data_type] = type.getFullNameString();
            if (type.isCharacterType()) {
                row[character_maximum_length] = ValuePool.getLong(type.precision);
                row[character_octet_length] = ValuePool.getLong(type.precision * 2);
                row[character_set_catalog] = database.getCatalogName().name;
                row[character_set_schema] = ((CharacterType) type).getCharacterSet().getSchemaName().name;
                row[character_set_name] = ((CharacterType) type).getCharacterSet().getName().name;
                row[collation_catalog] = database.getCatalogName().name;
                row[collation_schema] = ((CharacterType) type).getCollation().getSchemaName().name;
                row[collation_name] = ((CharacterType) type).getCollation().getName().name;
            }
            if (type.isBinaryType()) {
                row[character_maximum_length] = ValuePool.getLong(type.precision);
                row[character_octet_length] = ValuePool.getLong(type.precision);
            }
            if (type.isNumberType()) {
                row[numeric_precision] = ValuePool.getLong(type.precision);
                row[numeric_precision_radix] = ValuePool.getLong(((NumberType) type).getPrecisionRadix());
                row[numeric_scale] = ValuePool.getLong(type.scale);
            }
            if (type.isDateTimeType()) {
                row[datetime_precision] = ValuePool.getLong(type.scale);
            }
            if (type.isIntervalType()) {
                row[interval_type] = IntervalType.getQualifier(type.typeCode);
                row[interval_precision] = ValuePool.getLong(type.precision);
                row[datetime_precision] = ValuePool.getLong(type.scale);
            }
            if (type.isDomainType()) {
                row[domain_catalog] = database.getCatalogName().name;
                row[domain_schema] = type.getSchemaName().name;
                row[domain_name] = type.getName().name;
            }
            if (type.isDistinctType()) {
                row[udt_catalog] = database.getCatalogName().name;
                row[udt_schema] = type.getSchemaName().name;
                row[udt_name] = type.getName().name;
            }
            row[scope_catalog] = null;
            row[scope_schema] = null;
            row[scope_name] = null;
            row[maximum_cardinality] = null;
            row[dtd_identifier] = null;
            row[is_self_referencing] = null;
            row[is_identity] = column.isIdentity() ? "YES" : "NO";
            if (column.isIdentity()) {
                NumberSequence sequence = column.getIdentitySequence();
                row[identity_generation] = sequence.isAlways() ? "ALWAYS" : "BY DEFAULT";
                row[identity_start] = Long.toString(sequence.getStartValue());
                row[identity_increment] = Long.toString(sequence.getIncrement());
                row[identity_maximum] = Long.toString(sequence.getMaxValue());
                row[identity_minimum] = Long.toString(sequence.getMinValue());
                row[identity_cycle] = sequence.isCycle() ? "YES" : "NO";
            }
            row[is_generated] = "NEVER";
            row[generation_expression] = null;
            row[is_updatable] = table.isWritable() ? "YES" : "NO";
            row[declared_data_type] = row[data_type];
            if (type.isNumberType()) {
                row[declared_numeric_precision] = row[numeric_precision];
                row[declared_numeric_scale] = row[numeric_scale];
            }
            t.insertSys(store, row);
        }
    }
    return t;
}
Also used : Table(org.hsqldb_voltpatches.Table) TextTable(org.hsqldb_voltpatches.TextTable) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore) NumberSequence(org.hsqldb_voltpatches.NumberSequence) ColumnSchema(org.hsqldb_voltpatches.ColumnSchema) Constraint(org.hsqldb_voltpatches.Constraint) Type(org.hsqldb_voltpatches.types.Type) CharacterType(org.hsqldb_voltpatches.types.CharacterType) NumberType(org.hsqldb_voltpatches.types.NumberType) IntervalType(org.hsqldb_voltpatches.types.IntervalType) NumberType(org.hsqldb_voltpatches.types.NumberType) Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) SchemaObject(org.hsqldb_voltpatches.SchemaObject)

Example 5 with CharacterType

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

the class JDBCResultSetMetaData method isCaseSensitive.

/**
     * <!-- start generic documentation -->
     * Indicates whether a column's case matters.
     * <!-- end generic documentation -->
     *
     * <!-- start Release-specific documentation -->
     * <div class="ReleaseSpecificDocumentation">
     * <h3>HSQLDB-Specific Information:</h3> <p>
     *
     * HSQLDB 1.7.1 did not report this value accurately.  <p>
     *
     * Starting with 1.7.2, this feature is better supported.  <p>
     *
     * This method returns true for any column whose data type is a character
     * type, with the exception of VARCHAR_IGNORECASE for which it returns
     * false. It also returns false for any column whose data type is a
     * not a character data type. <p>
     *
     * </div>
     * <!-- end release-specific documentation -->
     *
     * @param column the first column is 1, the second is 2, ...
     * @return <code>true</code> if so; <code>false</code> otherwise
     * @exception SQLException if a database access error occurs
     */
public boolean isCaseSensitive(int column) throws SQLException {
    checkColumn(column);
    Type type = resultMetaData.columnTypes[--column];
    if (type.isCharacterType()) {
        return !((CharacterType) type).isCaseInsensitive();
    }
    return false;
}
Also used : CharacterType(org.hsqldb_voltpatches.types.CharacterType) Type(org.hsqldb_voltpatches.types.Type)

Aggregations

CharacterType (org.hsqldb_voltpatches.types.CharacterType)8 Type (org.hsqldb_voltpatches.types.Type)7 IntervalType (org.hsqldb_voltpatches.types.IntervalType)5 NumberType (org.hsqldb_voltpatches.types.NumberType)5 Constraint (org.hsqldb_voltpatches.Constraint)4 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)4 SchemaObject (org.hsqldb_voltpatches.SchemaObject)4 Table (org.hsqldb_voltpatches.Table)4 TextTable (org.hsqldb_voltpatches.TextTable)4 Iterator (org.hsqldb_voltpatches.lib.Iterator)4 WrapperIterator (org.hsqldb_voltpatches.lib.WrapperIterator)4 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)4 ColumnSchema (org.hsqldb_voltpatches.ColumnSchema)1 Expression (org.hsqldb_voltpatches.Expression)1 NumberSequence (org.hsqldb_voltpatches.NumberSequence)1 Routine (org.hsqldb_voltpatches.Routine)1 RoutineSchema (org.hsqldb_voltpatches.RoutineSchema)1 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)1 BlobType (org.hsqldb_voltpatches.types.BlobType)1 Charset (org.hsqldb_voltpatches.types.Charset)1