Search in sources :

Example 41 with Table

use of org.hsqldb_voltpatches.Table in project voltdb by VoltDB.

the class DataFileDefrag method updateTableIndexRoots.

/**
     * called from outside after the complete end of defrag
     */
void updateTableIndexRoots() {
    HsqlArrayList allTables = database.schemaManager.getAllTables();
    for (int i = 0, size = allTables.size(); i < size; i++) {
        Table t = (Table) allTables.get(i);
        if (t.getTableType() == TableBase.CACHED_TABLE) {
            int[] rootsArray = rootsList[i];
            t.setIndexRoots(rootsArray);
        }
    }
}
Also used : Table(org.hsqldb_voltpatches.Table) HsqlArrayList(org.hsqldb_voltpatches.lib.HsqlArrayList)

Example 42 with Table

use of org.hsqldb_voltpatches.Table in project voltdb by VoltDB.

the class LobManager method createSchema.

public void createSchema() {
    sysLobSession = database.sessionManager.getSysLobSession();
    Session session = sysLobSession;
    InputStream fis = getClass().getResourceAsStream(resourceFileName);
    InputStreamReader reader = null;
    try {
        reader = new InputStreamReader(fis, "ISO-8859-1");
    } catch (Exception e) {
    }
    LineNumberReader lineReader = new LineNumberReader(reader);
    LineGroupReader lg = new LineGroupReader(lineReader, starters);
    HashMappedList map = lg.getAsMap();
    lg.close();
    String sql = (String) map.get("/*lob_schema_definition*/");
    Statement statement = session.compileStatement(sql);
    Result result = statement.execute(session);
    Table table = database.schemaManager.getTable(session, "BLOCKS", "SYSTEM_LOBS");
    //            table.isTransactional = false;
    getLob = session.compileStatement(getLobSQL);
    getLobPart = session.compileStatement(getLobPartSQL);
    createLob = session.compileStatement(createLobSQL);
    createLobPart = session.compileStatement(createLobPartSQL);
    divideLobPart = session.compileStatement(divideLobPartSQL);
    deleteLob = session.compileStatement(deleteLobSQL);
    deleteLobPart = session.compileStatement(deleteLobPartSQL);
    setLobLength = session.compileStatement(updateLobLengthSQL);
    setLobUsage = session.compileStatement(updateLobUsageSQL);
    getNextLobId = session.compileStatement(getNextLobIdSQL);
}
Also used : HashMappedList(org.hsqldb_voltpatches.lib.HashMappedList) Table(org.hsqldb_voltpatches.Table) InputStreamReader(java.io.InputStreamReader) LineGroupReader(org.hsqldb_voltpatches.lib.LineGroupReader) HsqlByteArrayInputStream(org.hsqldb_voltpatches.lib.HsqlByteArrayInputStream) InputStream(java.io.InputStream) Statement(org.hsqldb_voltpatches.Statement) IOException(java.io.IOException) EOFException(java.io.EOFException) HsqlException(org.hsqldb_voltpatches.HsqlException) Session(org.hsqldb_voltpatches.Session) LineNumberReader(java.io.LineNumberReader) Result(org.hsqldb_voltpatches.result.Result)

Example 43 with Table

use of org.hsqldb_voltpatches.Table in project voltdb by VoltDB.

the class DatabaseInformationMain method INFORMATION_SCHEMA_CATALOG_NAME.

// -----------------------------------------------------------------------------
// SQL SCHEMATA BASE TABLE
/**
     * Retrieves a <code>Table</code> object naming the accessible catalogs
     * defined within this database. <p>
     *
     * Each row is a catalog name description with the following column: <p>
     *
     * <pre class="SqlCodeExample">
     * TABLE_CAT   VARCHAR   catalog name
     * </pre> <p>
     *
     * @return a <code>Table</code> object naming the accessible
     *        catalogs defined within this database
     */
final Table INFORMATION_SCHEMA_CATALOG_NAME() {
    Table t = sysTables[INFORMATION_SCHEMA_CATALOG_NAME];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[INFORMATION_SCHEMA_CATALOG_NAME]);
        // not null
        addColumn(t, "CATALOG_NAME", SQL_IDENTIFIER);
        // order:  TABLE_CAT
        // true PK
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[INFORMATION_SCHEMA_CATALOG_NAME].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 0 }, true);
        return t;
    }
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    Object[] row = t.getEmptyRowData();
    row[0] = database.getCatalogName().name;
    t.insertSys(store, row);
    return t;
}
Also used : Table(org.hsqldb_voltpatches.Table) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) SchemaObject(org.hsqldb_voltpatches.SchemaObject)

Example 44 with Table

use of org.hsqldb_voltpatches.Table in project voltdb by VoltDB.

the class DatabaseInformationMain method SYSTEM_TABLES.

/**
     * Retrieves a <code>Table</code> object describing the accessible
     * tables defined within this database. <p>
     *
     * Each row is a table description with the following columns: <p>
     *
     * <pre class="SqlCodeExample">
     * TABLE_CAT                 VARCHAR   table catalog
     * TABLE_SCHEM               VARCHAR   table schema
     * TABLE_NAME                VARCHAR   table name
     * TABLE_TYPE                VARCHAR   {"TABLE" | "VIEW" |
     *                                      "SYSTEM TABLE" | "GLOBAL TEMPORARY"}
     * REMARKS                   VARCHAR   comment on the table.
     * TYPE_CAT                  VARCHAR   table type catalog (not implemented).
     * TYPE_SCHEM                VARCHAR   table type schema (not implemented).
     * TYPE_NAME                 VARCHAR   table type name (not implemented).
     * SELF_REFERENCING_COL_NAME VARCHAR   designated "identifier" column of
     *                                     typed table (not implemented).
     * REF_GENERATION            VARCHAR   {"SYSTEM" | "USER" |
     *                                      "DERIVED" | NULL } (not implemented)
     * HSQLDB_TYPE               VARCHAR   HSQLDB-specific type:
     *                                     {"MEMORY" | "CACHED" | "TEXT" | ...}
     * READ_ONLY                 BOOLEAN   TRUE if table is read-only,
     *                                     else FALSE.
     * COMMIT_ACTION             VARCHAR   "PRESERVE" or "DELETE" for temp tables,
     *                                     else NULL
     * </pre> <p>
     *
     * @return a <code>Table</code> object describing the accessible
     *      tables defined within this database
     */
final Table SYSTEM_TABLES() {
    Table t = sysTables[SYSTEM_TABLES];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[SYSTEM_TABLES]);
        // -------------------------------------------------------------
        // required
        // -------------------------------------------------------------
        addColumn(t, "TABLE_CAT", SQL_IDENTIFIER);
        addColumn(t, "TABLE_SCHEM", SQL_IDENTIFIER);
        // not null
        addColumn(t, "TABLE_NAME", SQL_IDENTIFIER);
        // not null
        addColumn(t, "TABLE_TYPE", CHARACTER_DATA);
        addColumn(t, "REMARKS", CHARACTER_DATA);
        // -------------------------------------------------------------
        // JDBC 3.0
        // -------------------------------------------------------------
        addColumn(t, "TYPE_CAT", SQL_IDENTIFIER);
        addColumn(t, "TYPE_SCHEM", SQL_IDENTIFIER);
        addColumn(t, "TYPE_NAME", SQL_IDENTIFIER);
        addColumn(t, "SELF_REFERENCING_COL_NAME", SQL_IDENTIFIER);
        addColumn(t, "REF_GENERATION", CHARACTER_DATA);
        // -------------------------------------------------------------
        // extended
        // ------------------------------------------------------------
        addColumn(t, "HSQLDB_TYPE", SQL_IDENTIFIER);
        // not null
        addColumn(t, "READ_ONLY", Type.SQL_BOOLEAN);
        // not null
        addColumn(t, "COMMIT_ACTION", CHARACTER_DATA);
        // ------------------------------------------------------------
        // order TABLE_TYPE, TABLE_SCHEM and TABLE_NAME
        // added for unique: TABLE_CAT
        // false PK, as TABLE_SCHEM and/or TABLE_CAT may be null
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[SYSTEM_TABLES].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 3, 1, 2, 0 }, false);
        return t;
    }
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    // intermediate holders
    Iterator tables;
    Table table;
    Object[] row;
    HsqlName accessKey;
    DITableInfo ti;
    // column number mappings
    // JDBC 1
    final int itable_cat = 0;
    final int itable_schem = 1;
    final int itable_name = 2;
    final int itable_type = 3;
    final int iremark = 4;
    // JDBC 3.0
    final int itype_cat = 5;
    final int itype_schem = 6;
    final int itype_name = 7;
    final int isref_cname = 8;
    final int iref_gen = 9;
    // hsqldb ext
    final int ihsqldb_type = 10;
    final int iread_only = 11;
    final int icommit_action = 12;
    // Initialization
    tables = allTables();
    ti = new DITableInfo();
    // Do it.
    while (tables.hasNext()) {
        table = (Table) tables.next();
        if (!isAccessibleTable(table)) {
            continue;
        }
        ti.setTable(table);
        row = t.getEmptyRowData();
        row[itable_cat] = database.getCatalogName().name;
        row[itable_schem] = table.getSchemaName().name;
        row[itable_name] = ti.getName();
        row[itable_type] = ti.getJDBCStandardType();
        row[iremark] = ti.getRemark();
        row[ihsqldb_type] = ti.getHsqlType();
        row[iread_only] = ti.isReadOnly();
        row[icommit_action] = table.isTemp() ? (table.onCommitPreserve() ? "PRESERVE" : "DELETE") : null;
        t.insertSys(store, row);
    }
    return t;
}
Also used : Table(org.hsqldb_voltpatches.Table) 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 45 with Table

use of org.hsqldb_voltpatches.Table in project voltdb by VoltDB.

the class DatabaseInformationMain method cacheClear.

/**
     * Clears the contents of cached system tables and resets user slots
     * to null. <p>
     *
     */
protected final void cacheClear() {
    int i = sysTables.length;
    while (i-- > 0) {
        Table t = sysTables[i];
        if (t != null) {
            t.clearAllData(session);
        }
        sysTableSessions[i] = null;
    }
    isDirty = false;
}
Also used : Table(org.hsqldb_voltpatches.Table) Constraint(org.hsqldb_voltpatches.Constraint)

Aggregations

Table (org.hsqldb_voltpatches.Table)94 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)86 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)74 TextTable (org.hsqldb_voltpatches.TextTable)65 Constraint (org.hsqldb_voltpatches.Constraint)61 SchemaObject (org.hsqldb_voltpatches.SchemaObject)60 Iterator (org.hsqldb_voltpatches.lib.Iterator)55 WrapperIterator (org.hsqldb_voltpatches.lib.WrapperIterator)54 HsqlException (org.hsqldb_voltpatches.HsqlException)20 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)19 Session (org.hsqldb_voltpatches.Session)17 Result (org.hsqldb_voltpatches.result.Result)14 NumberType (org.hsqldb_voltpatches.types.NumberType)10 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 HsqlArrayList (org.hsqldb_voltpatches.lib.HsqlArrayList)7 TriggerDef (org.hsqldb_voltpatches.TriggerDef)6 CharacterType (org.hsqldb_voltpatches.types.CharacterType)6