Search in sources :

Example 46 with PersistentStore

use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.

the class TransactionManager method mergeTransaction.

/**
     * merge a transaction committed at a given timestamp.
     */
void mergeTransaction(Session session, Object[] list, int start, int limit, long timestamp) {
    for (int i = start; i < limit; i++) {
        RowAction rowact = (RowAction) list[i];
        if (rowact == null || rowact.type == RowActionBase.ACTION_NONE || rowact.type == RowActionBase.ACTION_DELETE_FINAL) {
            continue;
        }
        Row row = rowact.memoryRow;
        if (row == null) {
            PersistentStore store = rowact.session.sessionData.getRowStore(rowact.table);
            row = (Row) store.get(rowact.getPos(), false);
        }
        if (row == null) {
            continue;
        }
        synchronized (row) {
            rowact.mergeToTimestamp(row, timestamp);
        }
    }
}
Also used : PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore)

Example 47 with PersistentStore

use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.

the class TransactionManager method deleteRows.

void deleteRows(Object[] list, int start, int limit, boolean commit) {
    for (int i = start; i < limit; i++) {
        RowAction rowact = (RowAction) list[i];
        if (rowact.type == RowActionBase.ACTION_DELETE_FINAL) {
            try {
                rowact.type = RowActionBase.ACTION_DELETE_COMMITTED;
                PersistentStore store = rowact.session.sessionData.getRowStore(rowact.table);
                Row row = rowact.memoryRow;
                if (row == null) {
                    row = (Row) store.get(rowact.getPos(), false);
                }
                if (commit && rowact.table.hasLobColumn) {
                    Object[] data = row.getData();
                    rowact.table.removeLobUsageCount(rowact.session, data);
                }
                store.delete(row);
            } catch (HsqlException e) {
            //                    throw unexpectedException(e.getMessage());
            }
        }
    }
}
Also used : PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore) CachedObject(org.hsqldb_voltpatches.persist.CachedObject)

Example 48 with PersistentStore

use of org.hsqldb_voltpatches.persist.PersistentStore 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 49 with PersistentStore

use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.

the class DatabaseInformationMain method addPColRows.

/**
     * Inserts a set of procedure column description rows into the
     * <code>Table</code> specified by the <code>t</code> argument.
     *
     * <p>
     *
     * @param t the table in which the rows are to be inserted
     * @param l the list of procedure name aliases to which the specified
     *   column values apply
     * @param cat the procedure's catalog name
     * @param schem the procedure's schema name
     * @param pName the procedure's simple base (non-alias) name
     * @param cName the procedure column name
     * @param cType the column type (return, parameter, result)
     * @param dType the column's data type code
     * @param tName the column's canonical data type name
     * @param prec the column's precision
     * @param len the column's buffer length
     * @param scale the column's scale (decimal digits)
     * @param radix the column's numeric precision radix
     * @param nullability the column's java.sql.DatbaseMetaData nullabiliy code
     * @param remark a human-readable remark regarding the column
     * @param colDefault String
     * @param sqlDataType helper value to back JDBC contract sort order
     * @param sqlDateTimeSub Integer
     * @param charOctetLength Integer
     * @param ordinalPosition Integer
     * @param isNullable String
     * @param specificName the specific name of the procedure (typically but
     *   not limited to a fully qualified Java Method name and signature)
     * @param jdbcSequence int
     */
protected void addPColRows(Table t, HsqlArrayList l, String cat, String schem, String pName, String cName, Integer cType, Integer dType, String tName, Integer prec, Integer len, Integer scale, Integer radix, Integer nullability, String remark, String colDefault, Integer sqlDataType, Integer sqlDateTimeSub, Integer charOctetLength, Integer ordinalPosition, String isNullable, String specificName, int jdbcSequence) {
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    // column number mappings
    final int icat = 0;
    final int ischem = 1;
    final int iname = 2;
    final int icol_name = 3;
    final int icol_type = 4;
    final int idata_type = 5;
    final int itype_name = 6;
    final int iprec = 7;
    final int ilength = 8;
    final int iscale = 9;
    final int iradix = 10;
    final int inullable = 11;
    final int iremark = 12;
    // JDBC 4.0
    final int icol_default = 13;
    final int isql_data_type = 14;
    final int isql_datetime_sub = 15;
    final int ichar_octet_len = 16;
    final int iordinal_position = 17;
    final int iis_nullable = 18;
    final int ispecific_name = 19;
    // HSQLDB extension
    final int ijdbc_sequence = 20;
    // initialization
    Object[] row = t.getEmptyRowData();
    Integer sequence = ValuePool.getInt(jdbcSequence);
    // Do it.
    row[icat] = cat;
    row[ischem] = schem;
    row[iname] = pName;
    row[icol_name] = cName;
    row[icol_type] = cType;
    row[idata_type] = dType;
    row[itype_name] = tName;
    row[iprec] = prec;
    row[ilength] = len;
    row[iscale] = scale;
    row[iradix] = radix;
    row[inullable] = nullability;
    row[iremark] = remark;
    // JDBC 4.0
    row[icol_default] = colDefault;
    row[isql_data_type] = sqlDataType;
    row[isql_datetime_sub] = sqlDateTimeSub;
    row[ichar_octet_len] = charOctetLength;
    row[iordinal_position] = ordinalPosition;
    row[iis_nullable] = isNullable;
    row[ispecific_name] = specificName;
    // HSQLDB extension
    row[ijdbc_sequence] = sequence;
    t.insertSys(store, row);
    if (l != null) {
        int size = l.size();
        for (int i = 0; i < size; i++) {
            row = t.getEmptyRowData();
            pName = (String) l.get(i);
            row[icat] = cat;
            row[ischem] = schem;
            row[iname] = pName;
            row[icol_name] = cName;
            row[icol_type] = cType;
            row[idata_type] = dType;
            row[itype_name] = tName;
            row[iprec] = prec;
            row[ilength] = len;
            row[iscale] = scale;
            row[iradix] = radix;
            row[inullable] = nullability;
            row[iremark] = remark;
            // JDBC 4.0
            row[icol_default] = colDefault;
            row[isql_data_type] = sqlDataType;
            row[isql_datetime_sub] = sqlDateTimeSub;
            row[ichar_octet_len] = charOctetLength;
            row[iordinal_position] = ordinalPosition;
            row[iis_nullable] = isNullable;
            row[ispecific_name] = specificName;
            // HSQLDB extension
            row[ijdbc_sequence] = sequence;
            t.insertSys(store, row);
        }
    }
}
Also used : PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore) SchemaObject(org.hsqldb_voltpatches.SchemaObject) Constraint(org.hsqldb_voltpatches.Constraint)

Example 50 with PersistentStore

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

Aggregations

PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)103 Table (org.hsqldb_voltpatches.Table)74 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)73 SchemaObject (org.hsqldb_voltpatches.SchemaObject)59 Constraint (org.hsqldb_voltpatches.Constraint)57 TextTable (org.hsqldb_voltpatches.TextTable)56 Iterator (org.hsqldb_voltpatches.lib.Iterator)51 WrapperIterator (org.hsqldb_voltpatches.lib.WrapperIterator)51 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)20 HsqlException (org.hsqldb_voltpatches.HsqlException)19 Session (org.hsqldb_voltpatches.Session)16 Result (org.hsqldb_voltpatches.result.Result)16 NumberType (org.hsqldb_voltpatches.types.NumberType)10 Grantee (org.hsqldb_voltpatches.rights.Grantee)8 Type (org.hsqldb_voltpatches.types.Type)8 Routine (org.hsqldb_voltpatches.Routine)7 RoutineSchema (org.hsqldb_voltpatches.RoutineSchema)7 CachedObject (org.hsqldb_voltpatches.persist.CachedObject)7 TriggerDef (org.hsqldb_voltpatches.TriggerDef)6 CharacterType (org.hsqldb_voltpatches.types.CharacterType)6