use of org.hsqldb_voltpatches.Table in project voltdb by VoltDB.
the class DatabaseInformationFull method DOMAINS.
/**
* The DOMAINS view has one row for each domain. <p>
*
*
* <pre class="SqlCodeExample">
*
* </pre>
*
* @return Table
*/
Table DOMAINS() {
Table t = sysTables[DOMAINS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[DOMAINS]);
addColumn(t, "DOMAIN_CATALOG", SQL_IDENTIFIER);
addColumn(t, "DOMAIN_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "DOMAIN_NAME", SQL_IDENTIFIER);
addColumn(t, "DATA_TYPE", SQL_IDENTIFIER);
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, "DOMAIN_DEFAULT", CHARACTER_DATA);
addColumn(t, "MAXIMUM_CARDINALITY", SQL_IDENTIFIER);
addColumn(t, "DTD_IDENTIFIER", SQL_IDENTIFIER);
addColumn(t, "DECLARED_DATA_TYPE", CHARACTER_DATA);
addColumn(t, "DECLARED_NUMERIC_PRECISION", CARDINAL_NUMBER);
addColumn(t, "DECLARED_NUMERIC_SCLAE", CARDINAL_NUMBER);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[DOMAINS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 4, 5, 6 }, false);
return t;
}
final int domain_catalog = 0;
final int domain_schema = 1;
final int domain_name = 2;
final int data_type = 3;
final int character_maximum_length = 4;
final int character_octet_length = 5;
final int character_set_catalog = 6;
final int character_set_schema = 7;
final int character_set_name = 8;
final int collation_catalog = 9;
final int collation_schema = 10;
final int collation_name = 11;
final int numeric_precision = 12;
final int numeric_precision_radix = 13;
final int numeric_scale = 14;
final int datetime_precision = 15;
final int interval_type = 16;
final int interval_precision = 17;
final int domain_default = 18;
final int maximum_cardinality = 19;
final int dtd_identifier = 20;
final int declared_data_type = 21;
final int declared_numeric_precision = 22;
final int declared_numeric_scale = 23;
//
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().isAccessible(domain)) {
continue;
}
Object[] data = t.getEmptyRowData();
data[domain_catalog] = database.getCatalogName().name;
data[domain_schema] = domain.getSchemaName().name;
data[domain_name] = domain.getName().name;
data[data_type] = domain.getFullNameString();
if (domain.isCharacterType()) {
data[character_maximum_length] = ValuePool.getLong(domain.precision);
data[character_octet_length] = ValuePool.getLong(domain.precision * 2);
data[character_set_catalog] = database.getCatalogName().name;
data[character_set_schema] = ((CharacterType) domain).getCharacterSet().getSchemaName().name;
data[character_set_name] = ((CharacterType) domain).getCharacterSet().getName().name;
data[collation_catalog] = database.getCatalogName().name;
data[collation_schema] = ((CharacterType) domain).getCollation().getSchemaName().name;
data[collation_name] = ((CharacterType) domain).getCollation().getName().name;
} else if (domain.isNumberType()) {
data[numeric_precision] = ValuePool.getLong(((NumberType) domain).getPrecision());
data[declared_numeric_precision] = data[numeric_precision];
if (domain.typeCode != Types.SQL_DOUBLE) {
data[numeric_scale] = ValuePool.getLong(domain.scale);
data[declared_numeric_scale] = data[numeric_scale];
}
data[numeric_precision_radix] = ValuePool.getLong(((NumberType) domain).getPrecisionRadix());
} else if (domain.isBooleanType()) {
} else if (domain.isDateTimeType()) {
data[datetime_precision] = ValuePool.getLong(domain.scale);
} else if (domain.isIntervalType()) {
data[interval_precision] = ValuePool.getLong(domain.precision);
data[interval_type] = domain.getFullNameString();
data[datetime_precision] = ValuePool.getLong(domain.scale);
} else if (domain.isBinaryType()) {
data[character_maximum_length] = ValuePool.getLong(domain.precision);
data[character_octet_length] = ValuePool.getLong(domain.precision);
} else if (domain.isBitType()) {
data[character_maximum_length] = ValuePool.getLong(domain.precision);
data[character_octet_length] = ValuePool.getLong(domain.precision);
}
Expression defaultExpression = domain.userTypeModifier.getDefaultClause();
if (defaultExpression != null) {
data[domain_default] = defaultExpression.getSQL();
}
t.insertSys(store, data);
}
return t;
}
use of org.hsqldb_voltpatches.Table in project voltdb by VoltDB.
the class DatabaseInformationFull method ROLE_USAGE_GRANTS.
Table ROLE_USAGE_GRANTS() {
Table t = sysTables[ROLE_USAGE_GRANTS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[ROLE_USAGE_GRANTS]);
// not null
addColumn(t, "GRANTOR", SQL_IDENTIFIER);
// not null
addColumn(t, "GRANTEE", SQL_IDENTIFIER);
addColumn(t, "OBJECT_CATALOG", SQL_IDENTIFIER);
addColumn(t, "OBJECT_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "OBJECT_NAME", SQL_IDENTIFIER);
// not null
addColumn(t, "OBJECT_TYPE", CHARACTER_DATA);
addColumn(t, "PRIVILEGE_TYPE", CHARACTER_DATA);
// not null
addColumn(t, "IS_GRANTABLE", YES_OR_NO);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[ROLE_USAGE_GRANTS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 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 GRANTOR, GRANTEE, OBJECT_CATALOG, OBJECT_SCHEMA, OBJECT_NAME, " + "OBJECT_TYPE, PRIVILEGE_TYPE, IS_GRANTABLE " + "FROM INFORMATION_SCHEMA.USAGE_PRIVILEGES " + "JOIN INFORMATION_SCHEMA.APPLICABLE_ROLES ON GRANTEE = ROLE_NAME;");
t.insertSys(store, rs);
sys.close();
return t;
}
use of org.hsqldb_voltpatches.Table in project voltdb by VoltDB.
the class DatabaseInformationFull method TRANSLATIONS.
Table TRANSLATIONS() {
Table t = sysTables[TRANSLATIONS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[TRANSLATIONS]);
addColumn(t, "TRANSLATION_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TRANSLATION_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "TRANSLATION_NAME", SQL_IDENTIFIER);
addColumn(t, "SOURCE_CHARACTER_SET_CATALOG", SQL_IDENTIFIER);
addColumn(t, "SOURCE_CHARACTER_SET_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "SOURCE_CHARACTER_SET_NAME", SQL_IDENTIFIER);
addColumn(t, "TARGET_CHARACTER_SET_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TARGET_CHARACTER_SET_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "TARGET_CHARACTER_SET_NAME", SQL_IDENTIFIER);
addColumn(t, "TRANSLATION_SOURCE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TRANSLATION_SOURCE_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "TRANSLATION_SOURCE_NAME", SQL_IDENTIFIER);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[TRANSLATIONS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2 }, false);
return t;
}
return t;
}
use of org.hsqldb_voltpatches.Table in project voltdb by VoltDB.
the class DatabaseInformationFull method VIEW_COLUMN_USAGE.
/**
* The VIEW_COLUMN_USAGE table has one row for each column of a
* table that is explicitly or implicitly referenced in the
* <query expression> of the view being described. <p>
*
* <b>Definition:</b> <p>
*
* <pre class="SqlCodeExample">
* CREATE TABLE SYSTEM_VIEW_COLUMN_USAGE (
* VIEW_CATALOG VARCHAR NULL,
* VIEW_SCHEMA VARCHAR NULL,
* VIEW_NAME VARCHAR NOT NULL,
* TABLE_CATALOG VARCHAR NULL,
* TABLE_SCHEMA VARCHAR NULL,
* TABLE_NAME VARCHAR NOT NULL,
* COLUMN_NAME VARCHAR NOT NULL,
* UNIQUE ( VIEW_CATALOG, VIEW_SCHEMA, VIEW_NAME,
* TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME,
* COLUMN_NAME )
* )
* </pre>
*
* <b>Description:</b> <p>
*
* <ol>
* <li> The values of VIEW_CATALOG, VIEW_SCHEMA, and VIEW_NAME are the
* catalog name, unqualified schema name, and qualified identifier,
* respectively, of the view being described. <p>
*
* <li> The values of TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, and
* COLUMN_NAME are the catalog name, unqualified schema name,
* qualified identifier, and column name, respectively, of a column
* of a table that is explicitly or implicitly referenced in the
* <query expression> of the view being described.
* </ol>
*
* @return Table
*/
Table VIEW_COLUMN_USAGE() {
Table t = sysTables[VIEW_COLUMN_USAGE];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[VIEW_COLUMN_USAGE]);
addColumn(t, "VIEW_CATALOG", SQL_IDENTIFIER);
addColumn(t, "VIEW_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "VIEW_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[VIEW_COLUMN_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);
// Calculated column values
String viewCatalog;
String viewSchema;
String viewName;
// Intermediate holders
Iterator tables;
View view;
Table table;
Object[] row;
Iterator iterator;
// Column number mappings
final int view_catalog = 0;
final int view_schema = 1;
final int view_name = 2;
final int table_catalog = 3;
final int table_schema = 4;
final int table_name = 5;
final int column_name = 6;
// Initialization
tables = database.schemaManager.databaseObjectIterator(SchemaObject.TABLE);
// Do it.
while (tables.hasNext()) {
table = (Table) tables.next();
if (table.isView() && session.getGrantee().isFullyAccessibleByRole(table)) {
// $FALL-THROUGH$
} else {
continue;
}
viewCatalog = database.getCatalogName().name;
viewSchema = table.getSchemaName().name;
viewName = table.getName().name;
view = (View) table;
OrderedHashSet references = view.getReferences();
iterator = references.iterator();
while (iterator.hasNext()) {
HsqlName refName = (HsqlName) iterator.next();
if (refName.type == SchemaObject.COLUMN) {
row = t.getEmptyRowData();
row[view_catalog] = viewCatalog;
row[view_schema] = viewSchema;
row[view_name] = viewName;
row[table_catalog] = viewCatalog;
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.Table in project voltdb by VoltDB.
the class DatabaseInformationFull method ROUTINE_PRIVILEGES.
Table ROUTINE_PRIVILEGES() {
Table t = sysTables[ROUTINE_PRIVILEGES];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[ROUTINE_PRIVILEGES]);
// not null
addColumn(t, "GRANTOR", SQL_IDENTIFIER);
// not null
addColumn(t, "GRANTEE", SQL_IDENTIFIER);
addColumn(t, "SPECIFIC_CATALOG", SQL_IDENTIFIER);
addColumn(t, "SPECIFIC_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "SPECIFIC_NAME", SQL_IDENTIFIER);
addColumn(t, "ROUTINE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "ROUTINE_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "ROUTINE_NAME", SQL_IDENTIFIER);
// not null
addColumn(t, "PRIVILEGE_TYPE", CHARACTER_DATA);
// not null
addColumn(t, "IS_GRANTABLE", YES_OR_NO);
//
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[ROUTINE_PRIVILEGES].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, false);
return t;
}
// column number mappings
final int grantor = 0;
final int grantee = 1;
final int specific_catalog = 2;
final int specific_schema = 3;
final int specific_name = 4;
final int routine_catalog = 5;
final int routine_schema = 6;
final int routine_name = 7;
final int privilege_type = 8;
final int is_grantable = 9;
//
PersistentStore store = database.persistentStoreCollection.getStore(t);
// calculated column values
Grantee granteeObject;
String privilege;
// intermediate holders
Iterator routines;
RoutineSchema routine;
Object[] row;
OrderedHashSet grantees = session.getGrantee().getGranteeAndAllRolesWithPublic();
routines = database.schemaManager.databaseObjectIterator(SchemaObject.ROUTINE);
while (routines.hasNext()) {
routine = (RoutineSchema) routines.next();
for (int i = 0; i < grantees.size(); i++) {
granteeObject = (Grantee) grantees.get(i);
OrderedHashSet rights = granteeObject.getAllDirectPrivileges(routine);
OrderedHashSet grants = granteeObject.getAllGrantedPrivileges(routine);
if (!grants.isEmpty()) {
grants.addAll(rights);
rights = grants;
}
for (int j = 0; j < rights.size(); j++) {
Right right = (Right) rights.get(j);
Right grantableRight = right.getGrantableRights();
for (int k = 0; k < Right.privilegeTypes.length; k++) {
if (!right.canAccess(Right.privilegeTypes[k])) {
continue;
}
Routine[] specifics = routine.getSpecificRoutines();
for (int m = 0; m < specifics.length; m++) {
privilege = Right.privilegeNames[k];
row = t.getEmptyRowData();
//
row[grantor] = right.getGrantor().getName().name;
row[grantee] = right.getGrantee().getName().name;
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[privilege_type] = privilege;
row[is_grantable] = right.getGrantee() == routine.getOwner() || grantableRight.canAccess(Right.privilegeTypes[k]) ? "YES" : "NO";
try {
t.insertSys(store, row);
} catch (HsqlException e) {
}
}
}
}
}
}
return t;
}
Aggregations