use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method ROUTINE_COLUMN_USAGE.
Table ROUTINE_COLUMN_USAGE() {
Table t = sysTables[ROUTINE_COLUMN_USAGE];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[ROUTINE_COLUMN_USAGE]);
addColumn(t, "SPECIFIC_CATALOG", SQL_IDENTIFIER);
addColumn(t, "SPECIFIC_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "SPECIFIC_NAME", SQL_IDENTIFIER);
addColumn(t, "ROUTINE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "ROUTINE_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "ROUTINE_NAME", SQL_IDENTIFIER);
addColumn(t, "TABLE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TABLE_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "TABLE_NAME", SQL_IDENTIFIER);
addColumn(t, "COLUMN_NAME", SQL_IDENTIFIER);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[ROUTINE_COLUMN_USAGE].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 3, 4, 5, 0, 1, 2, 6, 7, 8, 9 }, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
// column number mappings
final int specific_catalog = 0;
final int specific_schema = 1;
final int specific_name = 2;
final int routine_catalog = 3;
final int routine_schema = 4;
final int routine_name = 5;
final int table_catalog = 6;
final int table_schema = 7;
final int table_name = 8;
final int column_name = 9;
//
Iterator it;
Object[] row;
it = database.schemaManager.databaseObjectIterator(SchemaObject.ROUTINE);
while (it.hasNext()) {
RoutineSchema routine = (RoutineSchema) it.next();
if (!session.getGrantee().isAccessible(routine)) {
continue;
}
Routine[] specifics = routine.getSpecificRoutines();
for (int m = 0; m < specifics.length; m++) {
OrderedHashSet set = specifics[m].getReferences();
for (int i = 0; i < set.size(); i++) {
HsqlName refName = (HsqlName) set.get(i);
if (refName.type != SchemaObject.COLUMN) {
continue;
}
if (!session.getGrantee().isAccessible(refName)) {
continue;
}
row = t.getEmptyRowData();
//
row[specific_catalog] = database.getCatalogName().name;
row[specific_schema] = specifics[m].getSchemaName().name;
row[specific_name] = specifics[m].getName().name;
row[routine_catalog] = database.getCatalogName().name;
row[routine_schema] = routine.getSchemaName().name;
row[routine_name] = routine.getName().name;
row[table_catalog] = database.getCatalogName().name;
row[table_schema] = refName.parent.schema.name;
row[table_name] = refName.parent.name;
row[column_name] = refName.name;
try {
t.insertSys(store, row);
} catch (HsqlException e) {
}
}
}
}
return t;
}
use of org.hsqldb_voltpatches.persist.PersistentStore 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;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method USER_DEFINED_TYPES.
Table USER_DEFINED_TYPES() {
Table t = sysTables[USER_DEFINED_TYPES];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[USER_DEFINED_TYPES]);
addColumn(t, "USER_DEFINED_TYPE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "USER_DEFINED_TYPE_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "USER_DEFINED_TYPE_NAME", SQL_IDENTIFIER);
addColumn(t, "USER_DEFINED_TYPE_CATEGORY", SQL_IDENTIFIER);
addColumn(t, "IS_INSTANTIABLE", YES_OR_NO);
addColumn(t, "IS_FINAL", YES_OR_NO);
addColumn(t, "ORDERING_FORM", SQL_IDENTIFIER);
addColumn(t, "ORDERING_CATEGORY", SQL_IDENTIFIER);
addColumn(t, "ORDERING_ROUTINE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "ORDERING_ROUTINE_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "ORDERING_ROUTINE_NAME", SQL_IDENTIFIER);
addColumn(t, "REFERENCE_TYPE", SQL_IDENTIFIER);
addColumn(t, "DATA_TYPE", CHARACTER_DATA);
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, "SOURCE_DTD_IDENTIFIER", CHARACTER_DATA);
addColumn(t, "REF_DTD_IDENTIFIER", CHARACTER_DATA);
addColumn(t, "DECLARED_DATA_TYPE", CHARACTER_DATA);
addColumn(t, "DECLARED_NUMERIC_PRECISION", CARDINAL_NUMBER);
addColumn(t, "DECLARED_NUMERIC_SCALE", CARDINAL_NUMBER);
addColumn(t, "EXTERNAL_NAME", CHARACTER_DATA);
addColumn(t, "EXTERNAL_LANGUAGE", CHARACTER_DATA);
addColumn(t, "JAVA_INTERFACE", CHARACTER_DATA);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[USER_DEFINED_TYPES].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 4, 5, 6 }, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
final int user_defined_type_catalog = 0;
final int user_defined_type_schema = 1;
final int user_defined_type_name = 2;
final int user_defined_type_category = 3;
final int is_instantiable = 4;
final int is_final = 5;
final int ordering_form = 6;
final int ordering_category = 7;
final int ordering_routine_catalog = 8;
final int ordering_routine_schema = 9;
final int ordering_routine_name = 10;
final int reference_type = 11;
final int data_type = 12;
final int character_maximum_length = 13;
final int character_octet_length = 14;
final int character_set_catalog = 15;
final int character_set_schema = 16;
final int character_set_name = 17;
final int collation_catalog = 18;
final int collation_schema = 19;
final int collation_name = 20;
final int numeric_precision = 21;
final int numeric_precision_radix = 22;
final int numeric_scale = 23;
final int datetime_precision = 24;
final int interval_type = 25;
final int interval_precision = 26;
final int source_dtd_identifier = 27;
final int ref_dtd_identifier = 28;
final int declared_data_type = 29;
final int declared_numeric_precision = 30;
final int declared_numeric_scale = 31;
Iterator it = database.schemaManager.databaseObjectIterator(SchemaObject.DOMAIN);
while (it.hasNext()) {
Type distinct = (Type) it.next();
if (!distinct.isDistinctType()) {
continue;
}
Object[] data = t.getEmptyRowData();
data[user_defined_type_catalog] = database.getCatalogName().name;
data[user_defined_type_schema] = distinct.getSchemaName().name;
data[user_defined_type_name] = distinct.getName().name;
data[data_type] = distinct.getFullNameString();
data[declared_data_type] = distinct.getFullNameString();
data[user_defined_type_category] = "DISTINCT";
data[is_instantiable] = "YES";
data[is_final] = "YES";
data[ordering_form] = "FULL";
data[source_dtd_identifier] = distinct.getFullNameString();
if (distinct.isCharacterType()) {
data[character_maximum_length] = ValuePool.getLong(distinct.precision);
data[character_octet_length] = ValuePool.getLong(distinct.precision * 2);
data[character_set_catalog] = database.getCatalogName().name;
data[character_set_schema] = ((CharacterType) distinct).getCharacterSet().getSchemaName().name;
data[character_set_name] = ((CharacterType) distinct).getCharacterSet().getName().name;
data[collation_catalog] = database.getCatalogName().name;
data[collation_schema] = ((CharacterType) distinct).getCollation().getSchemaName().name;
data[collation_name] = ((CharacterType) distinct).getCollation().getName().name;
} else if (distinct.isNumberType()) {
data[numeric_precision] = ValuePool.getLong(((NumberType) distinct).getPrecision());
data[declared_numeric_precision] = ValuePool.getLong(((NumberType) distinct).getPrecision());
if (distinct.typeCode != Types.SQL_DOUBLE) {
data[numeric_scale] = ValuePool.getLong(distinct.scale);
data[declared_numeric_scale] = ValuePool.getLong(distinct.scale);
}
data[numeric_precision_radix] = ValuePool.getLong(((NumberType) distinct).getPrecisionRadix());
} else if (distinct.isBooleanType()) {
} else if (distinct.isDateTimeType()) {
data[datetime_precision] = ValuePool.getLong(distinct.scale);
} else if (distinct.isIntervalType()) {
data[interval_precision] = ValuePool.getLong(distinct.precision);
data[interval_type] = distinct.getFullNameString();
data[datetime_precision] = ValuePool.getLong(distinct.scale);
} else if (distinct.isBinaryType()) {
data[character_maximum_length] = ValuePool.getLong(distinct.precision);
data[character_octet_length] = ValuePool.getLong(distinct.precision);
} else if (distinct.isBitType()) {
data[character_maximum_length] = ValuePool.getLong(distinct.precision);
data[character_octet_length] = ValuePool.getLong(distinct.precision);
}
}
return t;
}
use of org.hsqldb_voltpatches.persist.PersistentStore 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 <table name>
* simply contained in a <table reference> contained in the
* *lt;search condition> 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;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method SYSTEM_SESSIONINFO.
/**
* Retrieves a <code>Table</code> object describing attributes
* for the calling session context.<p>
*
* The rows report the following {key,value} pairs:<p>
*
* <pre class="SqlCodeExample">
* KEY (VARCHAR) VALUE (VARCHAR)
* ------------------- ---------------
* SESSION_ID the id of the calling session
* AUTOCOMMIT YES: session is in autocommit mode, else NO
* USER the name of user connected in the calling session
* (was READ_ONLY)
* SESSION_READONLY TRUE: session is in read-only mode, else FALSE
* (new)
* DATABASE_READONLY TRUE: database is in read-only mode, else FALSE
* MAXROWS the MAXROWS setting in the calling session
* DATABASE the name of the database
* IDENTITY the last identity value used by calling session
* </pre>
*
* <b>Note:</b> This table <em>may</em> become deprecated in a future
* release, as the information it reports now duplicates information
* reported in the newer SYSTEM_SESSIONS and SYSTEM_PROPERTIES
* tables. <p>
*
* @return a <code>Table</code> object describing the
* attributes of the connection associated
* with the current execution context
*/
Table SYSTEM_SESSIONINFO() {
Table t = sysTables[SYSTEM_SESSIONINFO];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[SYSTEM_SESSIONINFO]);
// not null
addColumn(t, "KEY", CHARACTER_DATA);
// not null
addColumn(t, "VALUE", CHARACTER_DATA);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[SYSTEM_SESSIONINFO].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0 }, true);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
Object[] row;
row = t.getEmptyRowData();
row[0] = "SESSION_ID";
row[1] = String.valueOf(session.getId());
t.insertSys(store, row);
row = t.getEmptyRowData();
row[0] = "AUTOCOMMIT";
row[1] = session.isAutoCommit() ? "TRUE" : "FALSE";
t.insertSys(store, row);
row = t.getEmptyRowData();
row[0] = "USER";
row[1] = session.getUsername();
t.insertSys(store, row);
row = t.getEmptyRowData();
row[0] = "SESSION_READONLY";
row[1] = session.isReadOnlyDefault() ? "TRUE" : "FALSE";
t.insertSys(store, row);
row = t.getEmptyRowData();
row[0] = "DATABASE_READONLY";
row[1] = database.isReadOnly() ? "TRUE" : "FALSE";
t.insertSys(store, row);
// fredt - value set by SET MAXROWS in SQL, not Statement.setMaxRows()
row = t.getEmptyRowData();
row[0] = "MAXROWS";
row[1] = String.valueOf(session.getSQLMaxRows());
t.insertSys(store, row);
row = t.getEmptyRowData();
row[0] = "DATABASE";
row[1] = database.getURI();
t.insertSys(store, row);
row = t.getEmptyRowData();
row[0] = "IDENTITY";
row[1] = String.valueOf(session.getLastIdentity());
t.insertSys(store, row);
row = t.getEmptyRowData();
row[0] = "SCHEMA";
row[1] = String.valueOf(session.getSchemaName(null));
t.insertSys(store, row);
return t;
}
Aggregations