Search in sources :

Example 1 with Expression

use of org.hsqldb_voltpatches.Expression 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)

Aggregations

Constraint (org.hsqldb_voltpatches.Constraint)1 Expression (org.hsqldb_voltpatches.Expression)1 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)1 SchemaObject (org.hsqldb_voltpatches.SchemaObject)1 Table (org.hsqldb_voltpatches.Table)1 TextTable (org.hsqldb_voltpatches.TextTable)1 Iterator (org.hsqldb_voltpatches.lib.Iterator)1 WrapperIterator (org.hsqldb_voltpatches.lib.WrapperIterator)1 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)1 CharacterType (org.hsqldb_voltpatches.types.CharacterType)1 IntervalType (org.hsqldb_voltpatches.types.IntervalType)1 NumberType (org.hsqldb_voltpatches.types.NumberType)1 Type (org.hsqldb_voltpatches.types.Type)1