use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method COLUMN_DOMAIN_USAGE.
/**
* Domains are shown if the authorization is the user or a role given to the
* user.
*
* <p>
*
* @return Table
*/
Table COLUMN_DOMAIN_USAGE() {
Table t = sysTables[COLUMN_DOMAIN_USAGE];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[COLUMN_DOMAIN_USAGE]);
addColumn(t, "DOMAIN_CATALOG", SQL_IDENTIFIER);
addColumn(t, "DOMAIN_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "DOMAIN_NAME", SQL_IDENTIFIER);
addColumn(t, "TABLE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TABLE_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "TABLE_NAME", SQL_IDENTIFIER);
// not null
addColumn(t, "COLUMN_NAME", SQL_IDENTIFIER);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[COLUMN_DOMAIN_USAGE].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5, 6 }, 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 DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME, TABLE_CATALOG, " + "TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS " + "WHERE DOMAIN_NAME IS NOT NULL;");
t.insertSys(store, rs);
sys.close();
return t;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method DOMAIN_CONSTRAINTS.
/**
* a DEFINITION_SCHEMA table. Not in the INFORMATION_SCHEMA list
*/
/*
Table DATA_TYPE_DESCRIPTOR() {
Table t = sysTables[DATA_TYPE_DESCRIPTOR];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[DATA_TYPE_DESCRIPTOR]);
addColumn(t, "OBJECT_CATALOG", SQL_IDENTIFIER);
addColumn(t, "OBJECT_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "OBJECT_NAME", SQL_IDENTIFIER);
addColumn(t, "OBJECT_TYPE", CHARACTER_DATA);
addColumn(t, "DTD_IDENTIFIER", SQL_IDENTIFIER);
addColumn(t, "DATA_TYPE", CHARACTER_DATA);
addColumn(t, "CHARACTER_SET_CATALOG", SQL_IDENTIFIER);
addColumn(t, "CHARACTER_SET_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "CHARACTER_SET_NAME", SQL_IDENTIFIER);
addColumn(t, "CHARACTER_MAXIMUM_LENGTH", CARDINAL_NUMBER);
addColumn(t, "CHARACTER_OCTET_LENGTH", CARDINAL_NUMBER);
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, "DECLARED_DATA_TYPE", CHARACTER_DATA);
addColumn(t, "DECLARED_NUMERIC_PRECISION", CARDINAL_NUMBER);
addColumn(t, "DECLARED_NUMERIC_SCLAE", CARDINAL_NUMBER);
addColumn(t, "DATETIME_PRECISION", CARDINAL_NUMBER);
addColumn(t, "INTERVAL_TYPE", CHARACTER_DATA);
addColumn(t, "INTERVAL_PRECISION", CARDINAL_NUMBER);
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, "SCOPE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "SCOPE_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "SCOPE_NAME", SQL_IDENTIFIER);
addColumn(t, "MAXIMUM_CARDINALITY", SQL_IDENTIFIER);
t.createPrimaryKey(null, new int[] {
0, 1, 2, 4, 5, 6
}, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
final int object_catalog = 0;
final int object_schema = 1;
final int object_name = 2;
final int object_type = 3;
final int dtd_identifier = 4;
final int data_type = 5;
final int character_set_catalog = 6;
final int character_set_schema = 7;
final int character_set_name = 8;
final int character_maximum_length = 9;
final int character_octet_length = 10;
final int collation_catalog = 11;
final int collation_schema = 12;
final int collation_name = 13;
final int numeric_precision = 14;
final int numeric_precision_radix = 15;
final int numeric_scale = 16;
final int declared_data_type = 17;
final int declared_numeric_precision = 18;
final int declared_numeric_scale = 19;
final int datetime_precision = 20;
final int interval_type = 21;
final int interval_precision = 22;
final int user_defined_type_catalog = 23;
final int user_defined_type_schema = 24;
final int user_defined_type_name = 25;
final int scope_catalog = 26;
final int scope_schema = 27;
final int scope_name = 28;
final int maximum_cardinality = 29;
return t;
}
*/
/**
*
* @return Table
*/
Table DOMAIN_CONSTRAINTS() {
Table t = sysTables[DOMAIN_CONSTRAINTS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[DOMAIN_CONSTRAINTS]);
addColumn(t, "CONSTRAINT_CATALOG", SQL_IDENTIFIER);
addColumn(t, "CONSTRAINT_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "CONSTRAINT_NAME", SQL_IDENTIFIER);
addColumn(t, "DOMAIN_CATALOG", SQL_IDENTIFIER);
addColumn(t, "DOMAIN_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "DOMAIN_NAME", SQL_IDENTIFIER);
addColumn(t, "IS_DEFERRABLE", YES_OR_NO);
addColumn(t, "INITIALLY_DEFERRED", YES_OR_NO);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[DOMAIN_CONSTRAINTS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 4, 5, 6 }, false);
return t;
}
final int constraint_catalog = 0;
final int constraint_schema = 1;
final int constraint_name = 2;
final int domain_catalog = 3;
final int domain_schema = 4;
final int domain_name = 5;
final int is_deferrable = 6;
final int initially_deferred = 7;
//
PersistentStore store = database.persistentStoreCollection.getStore(t);
//
Iterator it = database.schemaManager.databaseObjectIterator(SchemaObject.DOMAIN);
while (it.hasNext()) {
Type domain = (Type) it.next();
if (!domain.isDomainType()) {
continue;
}
if (!session.getGrantee().isFullyAccessibleByRole(domain)) {
continue;
}
Constraint[] constraints = domain.userTypeModifier.getConstraints();
for (int i = 0; i < constraints.length; i++) {
Object[] data = t.getEmptyRowData();
data[constraint_catalog] = data[domain_catalog] = database.getCatalogName().name;
data[constraint_schema] = data[domain_schema] = domain.getSchemaName().name;
data[constraint_name] = constraints[i].getName().name;
data[domain_name] = domain.getName().name;
data[is_deferrable] = Tokens.T_NO;
data[initially_deferred] = Tokens.T_NO;
t.insertSys(store, data);
}
}
return t;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method CHARACTER_SETS.
Table CHARACTER_SETS() {
Table t = sysTables[CHARACTER_SETS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[CHARACTER_SETS]);
addColumn(t, "CHARACTER_SET_CATALOG", SQL_IDENTIFIER);
addColumn(t, "CHARACTER_SET_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "CHARACTER_SET_NAME", SQL_IDENTIFIER);
addColumn(t, "CHARACTER_REPERTOIRE", SQL_IDENTIFIER);
addColumn(t, "FORM_OF_USE", SQL_IDENTIFIER);
addColumn(t, "DEFAULT_COLLATE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "DEFAULT_COLLATE_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "DEFAULT_COLLATE_NAME", SQL_IDENTIFIER);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[CHARACTER_SETS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2 }, false);
return t;
}
final int character_set_catalog = 0;
final int character_set_schema = 1;
final int character_set_name = 2;
final int character_repertoire = 3;
final int form_of_use = 4;
final int default_collate_catalog = 5;
final int default_collate_schema = 6;
final int default_collate_name = 7;
//
PersistentStore store = database.persistentStoreCollection.getStore(t);
Iterator it = database.schemaManager.databaseObjectIterator(SchemaObject.CHARSET);
while (it.hasNext()) {
Charset charset = (Charset) it.next();
if (!session.getGrantee().isAccessible(charset)) {
continue;
}
Object[] data = t.getEmptyRowData();
data[character_set_catalog] = database.getCatalogName().name;
data[character_set_schema] = charset.getSchemaName().name;
data[character_set_name] = charset.getName().name;
data[character_repertoire] = "UCS";
data[form_of_use] = "UTF16";
data[default_collate_catalog] = data[character_set_catalog];
if (charset.base == null) {
data[default_collate_schema] = data[character_set_schema];
data[default_collate_name] = data[character_set_name];
} else {
data[default_collate_schema] = charset.base.schema.name;
data[default_collate_name] = charset.base.name;
}
t.insertSys(store, data);
}
return t;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method CHECK_CONSTRAINT_ROUTINE_USAGE.
/**
* The CHECK_CONSTRAINT_ROUTINE_USAGE view has one row for each
* SQL-invoked routine identified as the subject routine of either a
* <routine invocation>, a <method reference>, a
* <method invocation>, or a <static method invocation>
* contained in an <assertion definition>, a <domain
* constraint>, or a <table constraint definition>. <p>
*
* <b>Definition:</b> <p>
*
* <pre class="SqlCodeExample">
* CREATE TABLE SYSTEM_CHECK_ROUTINE_USAGE (
* CONSTRAINT_CATALOG VARCHAR NULL,
* CONSTRAINT_SCHEMA VARCHAR NULL,
* CONSTRAINT_NAME VARCHAR NOT NULL,
* SPECIFIC_CATALOG VARCHAR NULL,
* SPECIFIC_SCHEMA VARCHAR NULL,
* SPECIFIC_NAME VARCHAR NOT NULL,
* UNIQUE( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME,
* SPECIFIC_CATALOG, SPECIFIC_SCHEMA, SPECIFIC_NAME )
* )
* </pre>
*
* <b>Description:</b> <p>
*
* <ol>
* <li> The CHECK_ROUTINE_USAGE table has one row for each
* SQL-invoked routine R identified as the subject routine of either a
* <routine invocation>, a <method reference>, a <method
* invocation>, or a <static method invocation> contained in
* an <assertion definition> or in the <check constraint
* definition> contained in either a <domain constraint> or a
* <table constraint definition>. <p>
*
* <li> The values of CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, and
* CONSTRAINT_NAME are the catalog name, unqualified schema name, and
* qualified identifier, respectively, of the assertion or check
* constraint being described. <p>
*
* <li> The values of SPECIFIC_CATALOG, SPECIFIC_SCHEMA, and SPECIFIC_NAME
* are the catalog name, unqualified schema name, and qualified
* identifier, respectively, of the specific name of R. <p>
*
* </ol>
*
* @return Table
*/
Table CHECK_CONSTRAINT_ROUTINE_USAGE() {
Table t = sysTables[CHECK_CONSTRAINT_ROUTINE_USAGE];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[CHECK_CONSTRAINT_ROUTINE_USAGE]);
addColumn(t, "CONSTRAINT_CATALOG", SQL_IDENTIFIER);
addColumn(t, "CONSTRAINT_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "CONSTRAINT_NAME", SQL_IDENTIFIER);
addColumn(t, "SPECIFIC_CATALOG", SQL_IDENTIFIER);
addColumn(t, "SPECIFIC_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "SPECIFIC_NAME", SQL_IDENTIFIER);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[CHECK_CONSTRAINT_ROUTINE_USAGE].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5 }, false);
return t;
}
// column number mappings
final int constraint_catalog = 0;
final int constraint_schema = 1;
final int constraint_name = 2;
final int specific_catalog = 3;
final int specific_schema = 4;
final int specific_name = 5;
//
PersistentStore store = database.persistentStoreCollection.getStore(t);
// calculated column values
String constraintCatalog;
String constraintSchema;
String constraintName;
String specificSchema;
// Intermediate holders
Iterator tables;
Table table;
Constraint[] constraints;
int constraintCount;
Constraint constraint;
OrderedHashSet collector;
Iterator iterator;
OrderedHashSet methodSet;
Method method;
Object[] row;
tables = database.schemaManager.databaseObjectIterator(SchemaObject.TABLE);
collector = new OrderedHashSet();
while (tables.hasNext()) {
collector.clear();
table = (Table) tables.next();
if (table.isView() || !session.getGrantee().isFullyAccessibleByRole(table)) {
continue;
}
constraints = table.getConstraints();
constraintCount = constraints.length;
constraintCatalog = database.getCatalogName().name;
constraintSchema = table.getSchemaName().name;
specificSchema = database.schemaManager.getDefaultSchemaHsqlName().name;
for (int i = 0; i < constraintCount; i++) {
constraint = constraints[i];
if (constraint.getConstraintType() != Constraint.CHECK) {
continue;
}
constraintName = constraint.getName().name;
constraint.getCheckExpression().collectAllFunctionExpressions(collector);
methodSet = new OrderedHashSet();
iterator = collector.iterator();
while (iterator.hasNext()) {
/*
Function expression = (Function) iterator.next();
String className =
expression.getMethod().getDeclaringClass().getName();
String schema =
database.schemaManager.getDefaultSchemaHsqlName().name;
SchemaObject object =
database.schemaManager.getSchemaObject(className,
schema, SchemaObject.FUNCTION);
if (!session.getGrantee().isAccessible(object)) {
continue;
}
methodSet.add(expression.getMethod());
*/
}
iterator = methodSet.iterator();
while (iterator.hasNext()) {
method = (Method) iterator.next();
row = t.getEmptyRowData();
row[constraint_catalog] = constraintCatalog;
row[constraint_schema] = constraintSchema;
row[constraint_name] = constraintName;
row[specific_catalog] = database.getCatalogName();
row[specific_schema] = specificSchema;
row[specific_name] = DINameSpace.getMethodSpecificName(method);
t.insertSys(store, row);
}
}
}
return t;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method insertRoles.
private void insertRoles(Table t, Grantee role, boolean isGrantable) {
final int grantee = 0;
final int role_name = 1;
final int is_grantable = 2;
PersistentStore store = database.persistentStoreCollection.getStore(t);
if (isGrantable) {
Set roles = database.getGranteeManager().getRoleNames();
Iterator it = roles.iterator();
while (it.hasNext()) {
String roleName = (String) it.next();
Object[] row = t.getEmptyRowData();
row[grantee] = role.getNameString();
row[role_name] = roleName;
row[is_grantable] = "YES";
t.insertSys(store, row);
}
} else {
OrderedHashSet roles = role.getDirectRoles();
for (int i = 0; i < roles.size(); i++) {
String roleName = (String) roles.get(i);
Object[] row = t.getEmptyRowData();
row[grantee] = role.getNameString();
row[role_name] = roleName;
row[is_grantable] = Tokens.T_NO;
t.insertSys(store, row);
role = database.getGranteeManager().getRole(roleName);
insertRoles(t, role, isGrantable);
}
}
}
Aggregations