Search in sources :

Example 21 with Session

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

the class DatabaseInformationFull method SQL_SIZING.

Table SQL_SIZING() {
    Table t = sysTables[SQL_SIZING];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[SQL_SIZING]);
        addColumn(t, "SIZING_ID", CARDINAL_NUMBER);
        addColumn(t, "SIZING_NAME", CHARACTER_DATA);
        addColumn(t, "SUPPORTED_VALUE", CARDINAL_NUMBER);
        addColumn(t, "COMMENTS", CHARACTER_DATA);
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[SQL_SIZING].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 0 }, false);
        return t;
    }
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    Session sys = database.sessionManager.newSysSession(SqlInvariants.INFORMATION_SCHEMA_HSQLNAME, session.getUser());
    String sql = (String) statementMap.get("/*sql_sizing*/");
    Result rs = sys.executeDirectStatement(sql);
    t.insertSys(store, rs);
    return t;
}
Also used : Table(org.hsqldb_voltpatches.Table) TextTable(org.hsqldb_voltpatches.TextTable) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) Session(org.hsqldb_voltpatches.Session) Result(org.hsqldb_voltpatches.result.Result)

Example 22 with Session

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

the class DatabaseInformationFull method CONSTRAINT_TABLE_USAGE.

/**
     * The CONSTRAINT_TABLE_USAGE view has one row for each table identified by a
     * <table name> simply contained in a <table reference>
     * contained in the <search condition> of a check constraint,
     * domain constraint, or assertion. It has one row for each table
     * containing / referenced by each PRIMARY KEY, UNIQUE and FOREIGN KEY
     * constraint<p>
     *
     * <b>Definition:</b> <p>
     *
     * <pre class="SqlCodeExample">
     *      CONSTRAINT_CATALOG      VARCHAR
     *      CONSTRAINT_SCHEMA       VARCHAR
     *      CONSTRAINT_NAME         VARCHAR
     *      TABLE_CATALOG           VARCHAR
     *      TABLE_SCHEMA            VARCHAR
     *      TABLE_NAME              VARCHAR
     * </pre>
     *
     * <b>Description:</b> <p>
     *
     * <ol>
     * <li> The values of CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, and
     *      CONSTRAINT_NAME are the catalog name, unqualified schema name,
     *       and qualified identifier, respectively, of the constraint being
     *      described. <p>
     *
     * <li> The values of TABLE_CATALOG, TABLE_SCHEMA, and TABLE_NAME are the
     *      catalog name, unqualified schema name, and qualified identifier,
     *      respectively, of a table identified by a &lt;table name&gt;
     *      simply contained in a &lt;table reference&gt; contained in the
     *      *lt;search condition&gt; of the constraint being described, or
     *      its columns.
     * </ol>
     *
     * @return Table
     */
Table CONSTRAINT_TABLE_USAGE() {
    Table t = sysTables[CONSTRAINT_TABLE_USAGE];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[CONSTRAINT_TABLE_USAGE]);
        addColumn(t, "CONSTRAINT_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "CONSTRAINT_SCHEMA", SQL_IDENTIFIER);
        // not null
        addColumn(t, "CONSTRAINT_NAME", SQL_IDENTIFIER);
        addColumn(t, "TABLE_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "TABLE_SCHEMA", SQL_IDENTIFIER);
        // not null
        addColumn(t, "TABLE_NAME", SQL_IDENTIFIER);
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[CONSTRAINT_TABLE_USAGE].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5 }, false);
        return t;
    }
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    //
    Session sys = database.sessionManager.newSysSession(SqlInvariants.INFORMATION_SCHEMA_HSQLNAME, session.getUser());
    Result rs = sys.executeDirectStatement("select DISTINCT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, " + "CONSTRAINT_NAME, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME " + "from INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE");
    t.insertSys(store, rs);
    sys.close();
    return t;
}
Also used : Table(org.hsqldb_voltpatches.Table) TextTable(org.hsqldb_voltpatches.TextTable) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) Session(org.hsqldb_voltpatches.Session) Result(org.hsqldb_voltpatches.result.Result)

Example 23 with Session

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

the class DatabaseInformationFull method SQL_PARTS.

Table SQL_PARTS() {
    Table t = sysTables[SQL_PARTS];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[SQL_PARTS]);
        addColumn(t, "PART", CHARACTER_DATA);
        addColumn(t, "NAME", CHARACTER_DATA);
        addColumn(t, "IS_SUPPORTED", YES_OR_NO);
        addColumn(t, "IS_VERIFIED_BY", CHARACTER_DATA);
        addColumn(t, "COMMENTS", CHARACTER_DATA);
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[SQL_PARTS].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 0 }, false);
        return t;
    }
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    Session sys = database.sessionManager.newSysSession(SqlInvariants.INFORMATION_SCHEMA_HSQLNAME, session.getUser());
    String sql = (String) statementMap.get("/*sql_parts*/");
    Result rs = sys.executeDirectStatement(sql);
    t.insertSys(store, rs);
    return t;
}
Also used : Table(org.hsqldb_voltpatches.Table) TextTable(org.hsqldb_voltpatches.TextTable) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) Session(org.hsqldb_voltpatches.Session) Result(org.hsqldb_voltpatches.result.Result)

Example 24 with Session

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

the class LobManager method setCharsForNewClob.

public Result setCharsForNewClob(long lobID, InputStream inputStream, long length) {
    Session session = sysLobSession;
    if (length == 0) {
        return ResultLob.newLobSetResponse(lobID, 0);
    }
    Result result = setBytesIS(session, lobID, inputStream, length * 2);
    if (result.isError()) {
        return result;
    }
    return ResultLob.newLobSetResponse(lobID, 0);
}
Also used : Session(org.hsqldb_voltpatches.Session) Result(org.hsqldb_voltpatches.result.Result)

Aggregations

Session (org.hsqldb_voltpatches.Session)24 Result (org.hsqldb_voltpatches.result.Result)18 Table (org.hsqldb_voltpatches.Table)17 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)16 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)16 TextTable (org.hsqldb_voltpatches.TextTable)15 EOFException (java.io.EOFException)2 IOException (java.io.IOException)2 Constraint (org.hsqldb_voltpatches.Constraint)2 HsqlException (org.hsqldb_voltpatches.HsqlException)2 ScriptReaderBase (org.hsqldb_voltpatches.scriptio.ScriptReaderBase)2 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 LineNumberReader (java.io.LineNumberReader)1 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 SchemaObject (org.hsqldb_voltpatches.SchemaObject)1 Statement (org.hsqldb_voltpatches.Statement)1 DoubleIntIndex (org.hsqldb_voltpatches.lib.DoubleIntIndex)1 HashMappedList (org.hsqldb_voltpatches.lib.HashMappedList)1