Search in sources :

Example 21 with Iterator

use of org.hsqldb_voltpatches.lib.Iterator 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 22 with Iterator

use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.

the class DINameSpace method iterateAllAccessibleMethods.

/** @todo - fredt - there are no class grants in 1.9 */
/**
     * @return a composite <code>Iterator</code>
     * @param session The context in which to produce the iterator
     * @param andAliases true if the alias lists for the "ROUTINE" type method
     *      elements are to be generated.
     */
Iterator iterateAllAccessibleMethods(Session session, boolean andAliases) {
    Iterator out;
    HashSet classNameSet;
    Iterator classNames;
    Iterator methods;
    String className;
    out = new WrapperIterator();
    /*
        while (classNames.hasNext()) {
            className = (String) classNames.next();
            methods   = iterateRoutineMethods(className, andAliases);
            out       = new WrapperIterator(out, methods);
        }
*/
    return out;
}
Also used : Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) HashSet(org.hsqldb_voltpatches.lib.HashSet)

Example 23 with Iterator

use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.

the class DatabaseInformationFull method JARS.

Table JARS() {
    Table t = sysTables[JARS];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[JARS]);
        addColumn(t, "JAR_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "JAR_SCHEMA", SQL_IDENTIFIER);
        addColumn(t, "JAR_NAME", SQL_IDENTIFIER);
        addColumn(t, "JAR_PATH", CHARACTER_DATA);
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[JARS].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 0, 1, 2, 3 }, false);
        return t;
    }
    // column number mappings
    final int jar_catalog = 0;
    final int jar_schema = 1;
    final int jar_name = 2;
    final int jar_path = 3;
    //
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    Iterator it;
    Object[] row;
    return t;
}
Also used : Table(org.hsqldb_voltpatches.Table) TextTable(org.hsqldb_voltpatches.TextTable) 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 24 with Iterator

use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.

the class JDBCXADataSource method getPreparedXids.

/**
     * Return the list of transactions currently <I>in prepared or
     * heuristically completed states</I>.
     * Need to find out what non-prepared states they are considering
     * <I>heuristically completed</I>.
     *
     * @see javax.transaction.xa.XAResource#recover(int)
     */
Xid[] getPreparedXids() {
    Iterator it = resources.keySet().iterator();
    Xid curXid;
    HashSet preparedSet = new HashSet();
    while (it.hasNext()) {
        curXid = (Xid) it.next();
        if (((JDBCXAResource) resources.get(curXid)).state == JDBCXAResource.XA_STATE_PREPARED) {
            preparedSet.add(curXid);
        }
    }
    return (Xid[]) preparedSet.toArray(new Xid[0]);
}
Also used : Xid(javax.transaction.xa.Xid) Iterator(org.hsqldb_voltpatches.lib.Iterator) HashSet(org.hsqldb_voltpatches.lib.HashSet)

Example 25 with Iterator

use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.

the class HsqlDatabaseProperties method supportsJavaMethod.

/**
     * If the system property "hsqldb.method_class_names" is not set, then
     * static methods of all available Java classes can be accessed as functions
     * in HSQLDB. If the property is set, then only the list of semicolon
     * seperated method names becomes accessible. An empty property value means
     * no class is accessible.<p>
     *
     * A property value that ends with .* is treated as a wild card and allows
     * access to all classe or method names formed by substitution of the
     * asterisk.<p>
     *
     * All methods of org.hsqldb_voltpatches.Library and java.lang.Math are always
     * accessible.
     *
     *
     */
public static boolean supportsJavaMethod(String name) {
    if (accessibleJavaMethodNames == null) {
        return true;
    }
    if (name.startsWith("org.hsqldb_voltpatches.Library.")) {
        return true;
    }
    if (name.startsWith("java.lang.Math.")) {
        return true;
    }
    if (accessibleJavaMethodNames.contains(name)) {
        return true;
    }
    Iterator it = accessibleJavaMethodNames.iterator();
    while (it.hasNext()) {
        String className = (String) it.next();
        int limit = className.lastIndexOf(".*");
        if (limit < 1) {
            continue;
        }
        if (name.startsWith(className.substring(0, limit + 1))) {
            return true;
        }
    }
    return false;
}
Also used : Iterator(org.hsqldb_voltpatches.lib.Iterator)

Aggregations

Iterator (org.hsqldb_voltpatches.lib.Iterator)102 WrapperIterator (org.hsqldb_voltpatches.lib.WrapperIterator)74 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)64 SchemaObject (org.hsqldb_voltpatches.SchemaObject)57 Table (org.hsqldb_voltpatches.Table)55 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)51 Constraint (org.hsqldb_voltpatches.Constraint)50 TextTable (org.hsqldb_voltpatches.TextTable)39 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)28 HsqlException (org.hsqldb_voltpatches.HsqlException)18 HsqlArrayList (org.hsqldb_voltpatches.lib.HsqlArrayList)14 NumberType (org.hsqldb_voltpatches.types.NumberType)10 HashSet (org.hsqldb_voltpatches.lib.HashSet)9 Type (org.hsqldb_voltpatches.types.Type)9 Grantee (org.hsqldb_voltpatches.rights.Grantee)8 Routine (org.hsqldb_voltpatches.Routine)7 RoutineSchema (org.hsqldb_voltpatches.RoutineSchema)7 TriggerDef (org.hsqldb_voltpatches.TriggerDef)6 CharacterType (org.hsqldb_voltpatches.types.CharacterType)6 IntervalType (org.hsqldb_voltpatches.types.IntervalType)6