|
* * <li> The values of IS_GRANTABLE have the following meanings:
* * <table border cellpadding="3"> * <tr> * <td nowrap>YES * <td nowrap>The privilege being described was granted * WITH GRANT OPTION and is thus grantable.</td> * <tr> * <tr> * <td nowrap>NO * <td nowrap>The privilege being described was not granted * WITH GRANT OPTION and is thus not grantable.</td> * <tr> * </table>
* <ol> */ Table SYSTEM_USAGE_PRIVILEGES() throws HsqlException { Table t = sysTables[SYSTEM_USAGE_PRIVILEGES]; if (t == null) { t = createBlankTable(sysTableHsqlNames[SYSTEM_USAGE_PRIVILEGES]); addColumn(t, "GRANTOR", Types.VARCHAR, false); // not null addColumn(t, "GRANTEE", Types.VARCHAR, false); // not null addColumn(t, "OBJECT_CATALOG", Types.VARCHAR); addColumn(t, "OBJECT_SCHEMA", Types.VARCHAR); addColumn(t, "OBJECT_NAME", Types.VARCHAR, false); // not null addColumn(t, "OBJECT_TYPE", Types.VARCHAR, 32, false); // not null addColumn(t, "IS_GRANTABLE", Types.VARCHAR, 3, false); // not null // order: COLUMN_NAME, PRIVILEGE // for unique: GRANTEE, GRANTOR, TABLE_NAME, TABLE_SCHEM, TABLE_CAT // false PK, as TABLE_SCHEM and/or TABLE_CAT may be null t.createPrimaryKey(null, new int[] { 0, 1, 2, 3, 4, 5 }, false); return t; } Result rs; rs = session.sqlExecuteDirectNoPreChecks( "SELECT '" + GranteeManager.SYSTEM_AUTHORIZATION_NAME + "', 'PUBLIC', SEQUENCE_CATALOG, SEQUENCE_SCHEMA, " + "SEQUENCE_NAME, 'SEQUENCE', 'FALSE' FROM INFORMATION_SCHEMA.SYSTEM_SEQUENCES"); t.insertSys(rs); rs = session.sqlExecuteDirectNoPreChecks( "SELECT '" + GranteeManager.SYSTEM_AUTHORIZATION_NAME + "', 'PUBLIC', COLLATION_CATALOG, COLLATION_SCHEMA, " + "COLLATION_NAME, 'COLLATION', 'FALSE' FROM INFORMATION_SCHEMA.SYSTEM_COLLATIONS"); t.insertSys(rs); t.setDataReadOnly(true); return t; } /** * The CHECK_COLUMN_USAGE table has one row for each column identified by * a <column reference> contained in the <search condition> * of a check constraint, domain constraint, or assertion. <p> * * <b>Definition:
* * <pre class="SqlCodeExample"> * CREATE TABLE CHECK_COLUMN_USAGE ( * CONSTRAINT_CATALOG VARCHAR NULL, * CONSTRAINT_SCHEMA VARCHAR NULL, * CONSTRAINT_NAME VARCHAR NOT NULL, * TABLE_CATALOG VARCHAR NULL, * TABLE_SCHEMA VARCHAR NULL, * TABLE_NAME VARCHAR NOT NULL, * COLUMN_NAME VARCHAR NOT NULL, * UNIQUE( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, * TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME ) * ) * </pre> * * <b>Description:
* * <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, TABLE_NAME, and * COLUMN_NAME are the catalog name, unqualified schema name, * qualified identifier, and column name, respectively, of a column * identified by a <column reference> explicitly or implicitly * contained in the <search condition> of the constraint * being described. * </ol> */ Table SYSTEM_CHECK_COLUMN_USAGE() throws HsqlException { Table t = sysTables[SYSTEM_CHECK_COLUMN_USAGE]; if (t == null) { t = createBlankTable(sysTableHsqlNames[SYSTEM_CHECK_COLUMN_USAGE]); addColumn(t, "CONSTRAINT_CATALOG", Types.VARCHAR); addColumn(t, "CONSTRAINT_SCHEMA", Types.VARCHAR); addColumn(t, "CONSTRAINT_NAME", Types.VARCHAR, false); // not null addColumn(t, "TABLE_CATALOG", Types.VARCHAR); addColumn(t, "TABLE_SCHEMA", Types.VARCHAR); addColumn(t, "TABLE_NAME", Types.VARCHAR, false); // not null addColumn(t, "COLUMN_NAME", Types.VARCHAR, false); // not null t.createPrimaryKey(null, new int[] { 0, 1, 2, 3, 4, 5, 6 }, false); return t; } // calculated column values String constraintCatalog; String constraintSchema; String constraintName; // Intermediate holders Iterator tables; Table table; Constraint[] constraints; int constraintCount; Constraint constraint; Expression.Collector collector; Expression expression; TableFilter tableFilter; Table columnTable; Iterator iterator; Result result; Object[] resultRow; Object[] row; // column number mappings final int icons_cat = 0; final int icons_schem = 1; final int icons_name = 2; final int itab_cat = 3; final int itab_schem = 4; final int itab_name = 5; final int itab_col = 6; // Initialization tables = database.schemaManager.allTablesIterator(); collector = new Expression.Collector(); result = new Result(ResultConstants.DATA, 4); result.metaData.colTypes[0] = result.metaData.colTypes[1] = result.metaData.colTypes[2] = result.metaData.colTypes[3] = Types.VARCHAR; // Do it. while (tables.hasNext()) { table = (Table) tables.next(); if (!isAccessibleTable(table)) { continue; } constraints = table.getConstraints(); constraintCount = constraints.length; constraintCatalog = ns.getCatalogName(table); constraintSchema = table.getSchemaName(); // process constraints for (int i = 0; i < constraintCount; i++) { constraint = (Constraint) constraints[i]; if (constraint.getType() != Constraint.CHECK) { continue; } constraintName = constraint.getName().name; result.setRows(null); collector.clear(); collector.addAll(constraint.core.check, Expression.COLUMN); iterator = collector.iterator(); // calculate distinct column references while (iterator.hasNext()) { expression = (Expression) iterator.next(); tableFilter = expression.getFilter(); columnTable = tableFilter.getTable(); if (columnTable.getTableType() == Table.SYSTEM_SUBQUERY || !isAccessibleTable(columnTable)) { continue; } result.add(new Object[] { ns.getCatalogName(columnTable), columnTable.getSchemaName(), columnTable.getName().name, expression.getColumnName() }); } /* result.removeDuplicates( database.sessionManager.getSysSession( database.schemaManager.INFORMATION_SCHEMA)); */ result.removeDuplicates(session); iterator = result.iterator(); while (iterator.hasNext()) { row = t.getEmptyRowData(); resultRow = (Object[]) iterator.next(); row[icons_cat] = constraintCatalog; row[icons_schem] = constraintSchema; row[icons_name] = constraintName; row[itab_cat] = resultRow[0]; row[itab_schem] = resultRow[1]; row[itab_name] = resultRow[2]; row[itab_col] = resultRow[3]; t.insertSys(row); } } } t.setDataReadOnly(true); return t; } /** * The CHECK_ROUTINE_USAGE base table 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:
* * <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:
* * <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> */ Table SYSTEM_CHECK_ROUTINE_USAGE() throws HsqlException { Table t = sysTables[SYSTEM_CHECK_ROUTINE_USAGE]; if (t == null) { t = createBlankTable( sysTableHsqlNames[SYSTEM_CHECK_ROUTINE_USAGE]); addColumn(t, "CONSTRAINT_CATALOG", Types.VARCHAR); addColumn(t, "CONSTRAINT_SCHEMA", Types.VARCHAR); addColumn(t, "CONSTRAINT_NAME", Types.VARCHAR, false); // not null addColumn(t, "SPECIFIC_CATALOG", Types.VARCHAR); addColumn(t, "SPECIFIC_SCHEMA", Types.VARCHAR); addColumn(t, "SPECIFIC_NAME", Types.VARCHAR, false); // not null t.createPrimaryKey(null, new int[] { 0, 1, 2, 3, 4, 5 }, false); return t; } // calculated column values String constraintCatalog; String constraintSchema; String constraintName; // Intermediate holders Iterator tables; Table table; Constraint[] constraints; int constraintCount; Constraint constraint; Expression.Collector collector; Expression expression; Function function; Iterator iterator; HashSet methodSet; Method method; Object[] row; // column number mappings final int icons_cat = 0; final int icons_schem = 1; final int icons_name = 2; final int ir_cat = 3; final int ir_schem = 4; final int ir_name = 5; tables = database.schemaManager.allTablesIterator(); collector = new Expression.Collector(); while (tables.hasNext()) { collector.clear(); table = (Table) tables.next(); if (!isAccessibleTable(table)) { continue; } constraints = table.getConstraints(); constraintCount = constraints.length; constraintCatalog = ns.getCatalogName(table); constraintSchema = table.getSchemaName(); for (int i = 0; i < constraintCount; i++) { constraint = (Constraint) constraints[i]; if (constraint.getType() != Constraint.CHECK) { continue; } constraintName = constraint.getName().name; collector.addAll(constraint.core.check, Expression.FUNCTION); methodSet = new HashSet(); iterator = collector.iterator(); while (iterator.hasNext()) { expression = (Expression) iterator.next(); function = expression.function; if (!session .isAccessible(function.getMethod() .getDeclaringClass().getName())) { continue; } methodSet.add(function.getMethod()); } iterator = methodSet.iterator(); while (iterator.hasNext()) { method = (Method) iterator.next(); row = t.getEmptyRowData(); row[icons_cat] = constraintCatalog; row[icons_schem] = constraintSchema; row[icons_name] = constraintName; row[ir_cat] = ns.getCatalogName(method); row[ir_schem] = ns.getSchemaName(method); row[ir_name] = DINameSpace.getMethodSpecificName(method); t.insertSys(row); } } } t.setDataReadOnly(true); return t; } /** * The CHECK_TABLE_USAGE table 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. <p> * * <b>Definition:
* * <pre class="SqlCodeExample"> * CREATE STABLE SYSTEM_CHECK_TABLE_USAGE ( * CONSTRAINT_CATALOG VARCHAR NULL, * CONSTRAINT_SCHEMA VARCHAR NULL, * CONSTRAINT_NAME VARCHAR NOT NULL, * TABLE_CATALOG VARCHAR NULL, * TABLE_SCHEMA VARCHAR NOT NULL, * TABLE_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, * UNIQUE( CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, * TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME ) * ) * </pre> * * <b>Description:
* * <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. * </ol> */ Table SYSTEM_CHECK_TABLE_USAGE() throws HsqlException { Table t = sysTables[SYSTEM_CHECK_TABLE_USAGE]; if (t == null) { t = createBlankTable(sysTableHsqlNames[SYSTEM_CHECK_TABLE_USAGE]); addColumn(t, "CONSTRAINT_CATALOG", Types.VARCHAR); addColumn(t, "CONSTRAINT_SCHEMA", Types.VARCHAR); addColumn(t, "CONSTRAINT_NAME", Types.VARCHAR, false); // not null addColumn(t, "TABLE_CATALOG", Types.VARCHAR); addColumn(t, "TABLE_SCHEMA", Types.VARCHAR); addColumn(t, "TABLE_NAME", Types.VARCHAR, false); // not null t.createPrimaryKey(null, new int[] { 0, 1, 2, 3, 4, 5 }, false); return t; } // Result rs = session.sqlExecuteDirectNoPreChecks( "select DISTINCT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, " + "CONSTRAINT_NAME, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME " + "from INFORMATION_SCHEMA.SYSTEM_CHECK_COLUMN_USAGE"); t.insertSys(rs); t.setDataReadOnly(true); return t; } /** * The TABLE_CONSTRAINTS table has one row for each table constraint * associated with a table. <p> * * It effectively contains a representation of the table constraint * descriptors. <p> * * <b>Definition:
* * <pre class="SqlCodeExample"> * CREATE TABLE SYSTEM_TABLE_CONSTRAINTS ( * CONSTRAINT_CATALOG VARCHAR NULL, * CONSTRAINT_SCHEMA VARCHAR NULL, * CONSTRAINT_NAME VARCHAR NOT NULL, * CONSTRAINT_TYPE VARCHAR NOT NULL, * TABLE_CATALOG VARCHAR NULL, * TABLE_SCHEMA VARCHAR NULL, * TABLE_NAME VARCHAR NOT NULL, * IS_DEFERRABLE VARCHAR NOT NULL, * INITIALLY_DEFERRED VARCHAR NOT NULL, * * CHECK ( CONSTRAINT_TYPE IN * ( 'UNIQUE', 'PRIMARY KEY', * 'FOREIGN KEY', 'CHECK' ) ), * * CHECK ( ( IS_DEFERRABLE, INITIALLY_DEFERRED ) IN * ( VALUES ( 'NO', 'NO' ), * ( 'YES', 'NO' ), * ( 'YES', 'YES' ) ) ) * ) * </pre> * * <b>Description:
* * <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. If the <table constraint * definition> or <add table constraint definition> * that defined the constraint did not specify a * <constraint name>, then the values of CONSTRAINT_CATALOG, * CONSTRAINT_SCHEMA, and CONSTRAINT_NAME are * implementation-defined. <p> * * <li> The values of CONSTRAINT_TYPE have the following meanings:
* <table border cellpadding="3"> * <tr> * <td nowrap>FOREIGN KEY * <td nowrap>The constraint being described is a * foreign key constraint.</td> * </tr> * <tr> * <td nowrap>UNIQUE * <td nowrap>The constraint being described is a * unique constraint.</td> * </tr> * <tr> * <td nowrap>PRIMARY KEY * <td nowrap>The constraint being described is a * primary key constraint.</td> * </tr> * <tr> * <td nowrap>CHECK * <td nowrap>The constraint being described is a * check constraint.</td> * </tr> * </table>
* * <li> The values of TABLE_CATALOG, TABLE_SCHEMA, and TABLE_NAME are * the catalog name, the unqualified schema name, and the * qualified identifier of the name of the table to which the * table constraint being described applies. <p> * * <li> The values of IS_DEFERRABLE have the following meanings:
* * <table> * <tr> * <td nowrap>YES * <td nowrap>The table constraint is deferrable. * </tr> * <tr> * <td nowrap>NO * <td nowrap>The table constraint is not deferrable. * </tr> * </table>
* * <li> The values of INITIALLY_DEFERRED have the following meanings:
* * <table> * <tr> * <td nowrap>YES * <td nowrap>The table constraint is initially deferred. * </tr> * <tr> * <td nowrap>NO * <td nowrap>The table constraint is initially immediate. * </tr> * </table>
* </ol> */ Table SYSTEM_TABLE_CONSTRAINTS() throws HsqlException { Table t = sysTables[SYSTEM_TABLE_CONSTRAINTS]; if (t == null) { t = createBlankTable(sysTableHsqlNames[SYSTEM_TABLE_CONSTRAINTS]); addColumn(t, "CONSTRAINT_CATALOG", Types.VARCHAR); addColumn(t, "CONSTRAINT_SCHEMA", Types.VARCHAR); addColumn(t, "CONSTRAINT_NAME", Types.VARCHAR, false); // not null addColumn(t, "CONSTRAINT_TYPE", Types.VARCHAR, 11, false); // not null addColumn(t, "TABLE_CATALOG", Types.VARCHAR); addColumn(t, "TABLE_SCHEMA", Types.VARCHAR); addColumn(t, "TABLE_NAME", Types.VARCHAR, false); // not null addColumn(t, "IS_DEFERRABLE", Types.VARCHAR, 3, false); // not null addColumn(t, "INITIALLY_DEFERRED", Types.VARCHAR, 3, false); // not null // false PK, as CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, // TABLE_CATALOG and/or TABLE_SCHEMA may be null t.createPrimaryKey(null, new int[] { 0, 1, 2, 4, 5, 6 }, false); return t; } // Intermediate holders Iterator tables; Table table; Constraint[] constraints; int constraintCount; Constraint constraint; String cat; String schem; HashSet constraintSet; Object[] row; // column number mappings final int icons_cat = 0; final int icons_schem = 1; final int icons_name = 2; final int icons_type = 3; final int itab_cat = 4; final int itab_schem = 5; final int itab_name = 6; final int iis_defr = 7; final int iinit_defr = 8; // initialization tables = database.schemaManager.allTablesIterator(); constraintSet = new HashSet(); table = null; // else complier complains // do it while (tables.hasNext()) { table = (Table) tables.next(); if (table.isView() || !isAccessibleTable(table)) { continue; } constraints = table.getConstraints(); constraintCount = constraints.length; for (int i = 0; i < constraintCount; i++) { constraint = constraints[i]; if (constraint.getType() == Constraint.FOREIGN_KEY && !isAccessibleTable(constraint.getRef())) { continue; } constraintSet.add(constraint); } } for (Iterator it = constraintSet.iterator(); it.hasNext(); ) { row = t.getEmptyRowData(); constraint = (Constraint) it.next(); switch (constraint.getType()) { case Constraint.CHECK : { row[icons_type] = "CHECK"; table = constraint.getMain(); break; } case Constraint.UNIQUE : { row[icons_type] = "UNIQUE"; table = constraint.getMain(); break; } case Constraint.FOREIGN_KEY : { row[icons_type] = "FOREIGN KEY"; table = constraint.getRef(); break; } case Constraint.PRIMARY_KEY : { row[icons_type] = "PRIMARY KEY"; table = constraint.getMain(); break; } case Constraint.MAIN : default : { continue; } } cat = ns.getCatalogName(table); schem = table.getSchemaName(); row[icons_cat] = cat; row[icons_schem] = schem; row[icons_name] = constraint.constName.name; row[itab_cat] = cat; row[itab_schem] = schem; row[itab_name] = table.getName().name; row[iis_defr] = "NO"; row[iinit_defr] = "NO"; t.insertSys(row); } t.setDataReadOnly(true); return t; } /** * The SYSTEM_VIEW_TABLE_USAGE table has one row for each table identified * by a <table name> simply contained in a <table reference> * that is contained in the <query expression> of a view. <p> * * <b>Definition
* * <pre class="SqlCodeExample"> * CREATE TABLE SYSTEM_VIEW_TABLE_USAGE ( * VIEW_CATALOG VARCHAR NULL, * VIEW_SCHEMA VARCHAR NULL, * VIEW_NAME VARCHAR NULL, * TABLE_CATALOG VARCHAR NULL, * TABLE_SCHEMA VARCHAR NULL, * TABLE_NAME VARCHAR NULL, * UNIQUE( VIEW_CATALOG, VIEW_SCHEMA, VIEW_NAME, * TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME ) * ) * </pre> * * <b>Description:
* * <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, 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> that is contained in * the <query expression> of the view being described. * </ol> */ Table SYSTEM_VIEW_TABLE_USAGE() throws HsqlException { Table t = sysTables[SYSTEM_VIEW_TABLE_USAGE]; if (t == null) { t = createBlankTable(sysTableHsqlNames[SYSTEM_VIEW_TABLE_USAGE]); addColumn(t, "VIEW_CATALOG", Types.VARCHAR); addColumn(t, "VIEW_SCHEMA", Types.VARCHAR); addColumn(t, "VIEW_NAME", Types.VARCHAR, true); // not null addColumn(t, "TABLE_CATALOG", Types.VARCHAR); addColumn(t, "TABLE_SCHEMA", Types.VARCHAR); addColumn(t, "TABLE_NAME", Types.VARCHAR, true); // not null // false PK, as VIEW_CATALOG, VIEW_SCHEMA, TABLE_CATALOG, and/or // TABLE_SCHEMA may be NULL t.createPrimaryKey(null, new int[] { 0, 1, 2, 3, 4, 5 }, false); return t; } // Result rs = session.sqlExecuteDirectNoPreChecks( "select DISTINCT VIEW_CATALOG, VIEW_SCHEMA, " + "VIEW_NAME, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME " + "from INFORMATION_SCHEMA.SYSTEM_VIEW_COLUMN_USAGE"); t.insertSys(rs); t.setDataReadOnly(true); return t; } /** * The SYSTEM_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:
* * <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:
* * <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> */ Table SYSTEM_VIEW_COLUMN_USAGE() throws HsqlException { Table t = sysTables[SYSTEM_VIEW_COLUMN_USAGE]; if (t == null) { t = createBlankTable(sysTableHsqlNames[SYSTEM_VIEW_COLUMN_USAGE]); addColumn(t, "VIEW_CATALOG", Types.VARCHAR); addColumn(t, "VIEW_SCHEMA", Types.VARCHAR); addColumn(t, "VIEW_NAME", Types.VARCHAR, true); // not null addColumn(t, "TABLE_CATALOG", Types.VARCHAR); addColumn(t, "TABLE_SCHEMA", Types.VARCHAR); addColumn(t, "TABLE_NAME", Types.VARCHAR, true); // not null addColumn(t, "COLUMN_NAME", Types.VARCHAR, true); // not null // false PK, as VIEW_CATALOG, VIEW_SCHEMA, TABLE_CATALOG, and/or // TABLE_SCHEMA may be NULL t.createPrimaryKey(null, new int[] { 0, 1, 2, 3, 4, 5, 6 }, false); return t; } // Calculated column values String viewCatalog; String viewSchema; String viewName; // Intermediate holders Iterator tables; View view; Table table; Object[] row; SubQuery[] subqueries; Select select; Expression expression; TableFilter tableFilter; Table columnTable; Result result; Object[] resultRow; Iterator iterator; Expression.Collector collector; // Column number mappings final int iv_cat = 0; final int iv_schem = 1; final int iv_name = 2; final int it_cat = 3; final int it_schem = 4; final int it_name = 5; final int it_cname = 6; // Initialization tables = database.schemaManager.allTablesIterator(); collector = new Expression.Collector(); result = new Result(ResultConstants.DATA, 4); result.metaData.colTypes[0] = result.metaData.colTypes[1] = result.metaData.colTypes[2] = result.metaData.colTypes[3] = Types.VARCHAR; // Do it. while (tables.hasNext()) { collector.clear(); result.setRows(null); table = (Table) tables.next(); if (table.isView() && isAccessibleTable(table)) { // fall through } else { continue; } viewCatalog = ns.getCatalogName(table); viewSchema = table.getSchemaName(); viewName = table.getName().name; view = (View) table; subqueries = view.viewSubqueries; collector.addAll(view.viewSelect, Expression.COLUMN); for (int i = 0; i < subqueries.length; i++) { collector.addAll(subqueries[i].select, Expression.COLUMN); } iterator = collector.iterator(); while (iterator.hasNext()) { expression = (Expression) iterator.next(); tableFilter = expression.getFilter(); columnTable = tableFilter.getTable(); if (columnTable.getTableType() == Table.SYSTEM_SUBQUERY || !isAccessibleTable(columnTable)) { continue; } result.add(new Object[] { ns.getCatalogName(columnTable), columnTable.getSchemaName(), columnTable.getName().name, expression.getColumnName() }); } /* result.removeDuplicates( database.sessionManager.getSysSession( database.schemaManager.INFORMATION_SCHEMA)); */ result.removeDuplicates(session); iterator = result.iterator(); while (iterator.hasNext()) { row = t.getEmptyRowData(); resultRow = (Object[]) iterator.next(); row[iv_cat] = viewCatalog; row[iv_schem] = viewSchema; row[iv_name] = viewName; row[it_cat] = resultRow[0]; row[it_schem] = resultRow[1]; row[it_name] = resultRow[2]; row[it_cname] = resultRow[3]; t.insertSys(row); } } t.setDataReadOnly(true); return t; } /** * The SYSTEM_VIEW_ROUTINE_USAGE table 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 a <view * definition>. <p> * * <b>Definition
* * <pre class="SqlCodeExample"> * CREATE TABLE VIEW_ROUTINE_USAGE ( * TABLE_CATALOG VARCHAR NULL, * TABLE_SCHEMA VARCHAR NULL, * TABLE_NAME VARCHAR NOT NULL, * SPECIFIC_CATALOG VARCHAR NULL, * SPECIFIC_SCHEMA VARCHAR NULL, * SPECIFIC_NAME VARCHAR NOT NULL, * UNIQUE( TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, * SPECIFIC_CATALOG, SPECIFIC_SCHEMA, * SPECIFIC_NAME ) * ) * </pre> * * <b>Description
*
* <ol>
* <li> The values of TABLE_CATALOG, TABLE_SCHEMA, and TABLE_NAME are the
* catalog name, unqualified schema name, and qualified identifier,
* respectively, of the viewed table 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>
*/
Table SYSTEM_VIEW_ROUTINE_USAGE() throws HsqlException {
Table t = sysTables[SYSTEM_VIEW_ROUTINE_USAGE];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[SYSTEM_VIEW_ROUTINE_USAGE]);
addColumn(t, "TABLE_CATALOG", Types.VARCHAR);
addColumn(t, "TABLE_SCHEMA", Types.VARCHAR);
addColumn(t, "TABLE_NAME", Types.VARCHAR, true); // not null
addColumn(t, "SPECIFIC_CATALOG", Types.VARCHAR);
addColumn(t, "SPECIFIC_SCHEMA", Types.VARCHAR);
addColumn(t, "SPECIFIC_NAME", Types.VARCHAR, true); // not null
// false PK, as VIEW_CATALOG, VIEW_SCHEMA, TABLE_CATALOG, and/or
// TABLE_SCHEMA may be NULL
t.createPrimaryKey(null, new int[] {
0, 1, 2, 3, 4, 5
}, false);
return t;
}
// Calculated column values
String viewCat;
String viewSchem;
String viewName;
// Intermediate holders
Iterator tables;
View view;
Table table;
Object[] row;
SubQuery[] subqueries;
Select select;
Expression expression;
Function function;
Expression.Collector collector;
Method method;
HashSet methodSet;
Iterator iterator;
// Column number mappings
final int iv_cat = 0;
final int iv_schem = 1;
final int iv_name = 2;
final int ir_cat = 3;
final int ir_schem = 4;
final int ir_name = 5;
final int ir_sig = 6;
// Initialization
tables = database.schemaManager.allTablesIterator();
collector = new Expression.Collector();
// Do it.
while (tables.hasNext()) {
collector.clear();
table = (Table) tables.next();
if (table.isView() && isAccessibleTable(table)) {
// fall through
} else {
continue;
}
viewCat = ns.getCatalogName(table);
viewSchem = table.getSchemaName();
viewName = table.getName().name;
view = (View) table;
subqueries = view.viewSubqueries;
collector.addAll(view.viewSelect, Expression.FUNCTION);
for (int i = 0; i < subqueries.length; i++) {
collector.addAll(subqueries[i].select, Expression.FUNCTION);
}
methodSet = new HashSet();
iterator = collector.iterator();
while (iterator.hasNext()) {
expression = (Expression) iterator.next();
function = expression.function;
if (session.isAccessible(
function.getMethod().getDeclaringClass().getName())) {
methodSet.add(function.getMethod());
}
}
iterator = methodSet.iterator();
while (iterator.hasNext()) {
method = (Method) iterator.next();
row = t.getEmptyRowData();
row[iv_cat] = viewCat;
row[iv_schem] = viewSchem;
row[iv_name] = viewName;
row[ir_cat] = ns.getCatalogName(method);
row[ir_schem] = ns.getSchemaName(method);
row[ir_name] = DINameSpace.getMethodSpecificName(method);
t.insertSys(row);
}
}
t.setDataReadOnly(true);
return t;
}
/**
* Inserts a set of procedure column description rows into the
* <code>Table specified by the t
argument.
* * @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 specificName the specific name of the procedure * (typically but not limited to * a fully qualified Java Method name and signature) * @param seq helper value to back JDBC contract sort order * @throws HsqlException if there is problem inserting the specified rows * in the table * */ 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 specificName, int seq) throws HsqlException { // 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; final int isn = 13; final int iseq = 14; Object[] row = t.getEmptyRowData(); Integer sequence = ValuePool.getInt(seq); 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; row[isn] = specificName; row[iseq] = sequence; t.insertSys(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; row[isn] = specificName; row[iseq] = sequence; t.insertSys(row); } } } /** * Inserts a set of procedure description rows into the <code>Table * object specified by the <code>t argument.
* * @param t the table into which the specified rows will eventually * be inserted * @param l the list of procedure name aliases to which the specified column * values apply * @param cat the procedure catalog name * @param schem the procedure schema name * @param pName the base (non-alias) procedure name * @param ip the procedure input parameter count * @param op the procedure output parameter count * @param rs the procedure result column count * @param remark a human-readable remark regarding the procedure * @param pType the procedure type code, indicating whether it is a * function, procedure, or uncatagorized (i.e. returns * a value, does not return a value, or it is unknown * if it returns a value) * @param origin origin of the procedure, e.g. * (["BUILTIN" | "USER DEFINED"] "ROUTINE" | "TRIGGER") | "ALIAS", etc. * @param specificName the specific name of the procedure * (typically but not limited to a * fully qualified Java Method name and signature) * @throws HsqlException if there is problem inserting the specified rows * in the table * */ protected void addProcRows(Table t, HsqlArrayList l, String cat, String schem, String pName, Integer ip, Integer op, Integer rs, String remark, Integer pType, String origin, String specificName) throws HsqlException { // column number mappings final int icat = 0; final int ischem = 1; final int ipname = 2; final int iinput_parms = 3; final int ioutput_parms = 4; final int iresult_sets = 5; final int iremark = 6; final int iptype = 7; final int iporigin = 8; final int isn = 9; Object[] row = t.getEmptyRowData(); row[icat] = cat; row[ischem] = schem; row[ipname] = pName; row[iinput_parms] = ip; row[ioutput_parms] = op; row[iresult_sets] = rs; row[iremark] = remark; row[iptype] = pType; row[iporigin] = origin; row[isn] = specificName; t.insertSys(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[ipname] = pName; row[iinput_parms] = ip; row[ioutput_parms] = op; row[iresult_sets] = rs; row[iremark] = remark; row[iptype] = pType; row[iporigin] = "ALIAS"; row[isn] = specificName; t.insertSys(row); } } } //------------------------------------------------------------------------------ // boucherb@users 20050515 further SQL2003 metadata support /** * SYSTEM_AUTHORIZATIONS<p> * * <b>Function
* * The AUTHORIZATIONS table has one row for each <role name> and * one row for each <authorization identifier > referenced in the * Information Schema. These are the <role name>s and * <authorization identifier>s that may grant privileges as well as * those that may create a schema, or currently own a schema created * through a <schema definition>. <p> * * <b>Definition
* * <pre class="SqlCodeExample"> * CREATE TABLE AUTHORIZATIONS ( * AUTHORIZATION_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, * AUTHORIZATION_TYPE INFORMATION_SCHEMA.CHARACTER_DATA * CONSTRAINT AUTHORIZATIONS_AUTHORIZATION_TYPE_NOT_NULL * NOT NULL * CONSTRAINT AUTHORIZATIONS_AUTHORIZATION_TYPE_CHECK * CHECK ( AUTHORIZATION_TYPE IN ( 'USER', 'ROLE' ) ), * CONSTRAINT AUTHORIZATIONS_PRIMARY_KEY * PRIMARY KEY (AUTHORIZATION_NAME) * ) * </pre> * * <b>Description
* * <ol> * <li> The values of AUTHORIZATION_TYPE have the following meanings:
* * <table border cellpadding="3"> * <tr> * <td nowrap>USER * <td nowrap>The value of AUTHORIZATION_NAME is a known * <user identifier>.</td> * <tr> * <tr> * <td nowrap>NO * <td nowrap>The value of AUTHORIZATION_NAME is a <role * name> defined by a <role definition>.</td> * <tr> * </table>
* </ol> */ Table SYSTEM_AUTHORIZATIONS() throws HsqlException { Table t = sysTables[SYSTEM_AUTHORIZATIONS]; if (t == null) { t = createBlankTable(sysTableHsqlNames[SYSTEM_AUTHORIZATIONS]); addColumn(t, "AUTHORIZATION_NAME", Types.VARCHAR, true); // not null addColumn(t, "AUTHORIZATION_TYPE", Types.VARCHAR, true); // not null // true PK t.createPrimaryKey(null, new int[]{ 0 }, true); return t; } // Intermediate holders HsqlArrayList users; Iterator roles; User user; int userCount; Object[] row; // Initialization users = database.getUserManager().listVisibleUsers(session, false); userCount = users.size(); // Do it. for (int i = 0; i < users.size(); i++) { row = t.getEmptyRowData(); user = (User) users.get(i); row[0] = user.getName(); row[1] = "USER"; t.insertSys(row); } roles = database.getGranteeManager().getRoleNames().iterator(); while (roles.hasNext()) { row = t.getEmptyRowData(); row[0] = roles.next().toString(); row[1] = "ROLE"; t.insertSys(row); } t.setDataReadOnly(true); return t; } /** * SYSTEM_COLLATIONS<p> * * <b>Function
* * The COLLATIONS table has one row for each character collation * descriptor. <p> * * <b>Definition * * <pre class="SqlCodeExample"> * CREATE TABLE COLLATIONS ( * COLLATION_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER, * COLLATION_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER, * COLLATION_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, * PAD_ATTRIBUTE INFORMATION_SCHEMA.CHARACTER_DATA * CONSTRAINT COLLATIONS_PAD_ATTRIBUTE_CHECK * CHECK ( PAD_ATTRIBUTE IN * ( 'NO PAD', 'PAD SPACE' ) ), * COLLATION_TYPE INFORMATION_SCHEMA.SQL_IDENTIFIER, * COLLATION_DEFINITION INFORMATION_SCHEMA.CHARACTER_DATA, * COLLATION_DICTIONARY INFORMATION_SCHEMA.CHARACTER_DATA, * CHARACTER_REPERTOIRE_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER * CONSTRAINT CHARACTER_REPERTOIRE_NAME_NOT_NULL * NOT NULL, * CONSTRAINT COLLATIONS_PRIMARY_KEY * PRIMARY KEY ( COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_NAME ), * CONSTRAINT COLLATIONS_FOREIGN_KEY_SCHEMATA * FOREIGN KEY ( COLLATION_CATALOG, COLLATION_SCHEMA ) * REFERENCES SCHEMATA * ) * </pre> * * <b>Description
* * <ol> * <li>The values of COLLATION_CATALOG, COLLATION_SCHEMA, and * COLLATION_NAME are the catalog name, unqualified schema name, * and qualified identifier, respectively, of the collation being * described.<p> * * <li>The values of COLLATION_TYPE, COLLATION_DICTIONARY, and * COLLATION_DEFINITION are the null value (deprectated). <p> * * <li>The values of PAD_ATTRIBUTE have the following meanings:
* * <table border cellpadding="3"> * <tr> * <td nowrap>NO PAD * <td nowrap>The collation being described has the NO PAD * characteristic.</td> * <tr> * <tr> * <td nowrap>PAD * <td nowrap>The collation being described has the PAD SPACE * characteristic.</td> * <tr> * </table>
* * <li>The value of CHARACTER_REPERTOIRE_NAME is the name of the * character repertoire to which the collation being described * is applicable. * </ol> */ Table SYSTEM_COLLATIONS() throws HsqlException { Table t = sysTables[SYSTEM_COLLATIONS]; if (t == null) { t = createBlankTable(sysTableHsqlNames[SYSTEM_COLLATIONS]); addColumn(t, "COLLATION_CATALOG", Types.VARCHAR); addColumn(t, "COLLATION_SCHEMA", Types.VARCHAR, true); addColumn(t, "COLLATION_NAME", Types.VARCHAR, true); addColumn(t, "PAD_ATTRIBUTE", Types.VARCHAR, 9, true); addColumn(t, "COLLATION_TYPE", Types.VARCHAR, true); addColumn(t, "COLLATION_DEFINITION", Types.VARCHAR); addColumn(t, "COLLATION_DICTIONARY", Types.VARCHAR); addColumn(t, "CHARACTER_REPERTOIRE_NAME", Types.VARCHAR, true); // false PK, as rows may have NULL COLLATION_CATALOG t.createPrimaryKey(null, new int[] { 0, 1, 2 }, false); return t; } Iterator collations; String collation; String collationSchema = SchemaManager.PUBLIC_SCHEMA; String padAttribute = "NO PAD"; String characterRepertoireName = "UNICODE"; Object[] row; final int icolcat = 0; final int icolschem = 1; final int icolname = 2; final int ipadattr = 3; final int icoltype = 4; final int icoldef = 5; final int icoldict = 6; final int icharrep = 7; collations = Collation.nameToJavaName.keySet().iterator(); while (collations.hasNext()) { row = t.getEmptyRowData(); collation = (String) collations.next(); row[icolcat] = ns.getCatalogName(collation); row[icolschem] = collationSchema; row[icolname] = collation; row[ipadattr] = padAttribute; row[icharrep] = characterRepertoireName; t.insertSys(row); } t.setDataReadOnly(true); return t; } /** * SYSTEM_ENABLED_ROLES<p> * * <b>Function
* * Identify the enabled roles for the current SQL-session.<p> * * Definition<p> * * <pre class="SqlCodeExample"> * CREATE RECURSIVE VIEW ENABLED_ROLES ( ROLE_NAME ) AS * VALUES ( CURRENT_ROLE ) * UNION * SELECT RAD.ROLE_NAME * FROM DEFINITION_SCHEMA.ROLE_AUTHORIZATION_DESCRIPTORS RAD * JOIN ENABLED_ROLES R * ON RAD.GRANTEE = R.ROLE_NAME; * * GRANT SELECT ON TABLE ENABLED_ROLES * TO PUBLIC WITH GRANT OPTION; * </pre> */ /** * SYSTEM_APPLICABLE_ROLES<p> * * <b>Function
* * Identifies the applicable roles for the current user.<p> * * <b>Definition
* * <pre class="SqlCodeExample"> * CREATE RECURSIVE VIEW APPLICABLE_ROLES ( GRANTEE, ROLE_NAME, IS_GRANTABLE ) AS * ( ( SELECT GRANTEE, ROLE_NAME, IS_GRANTABLE * FROM DEFINITION_SCHEMA.ROLE_AUTHORIZATION_DESCRIPTORS * WHERE ( GRANTEE IN ( CURRENT_USER, 'PUBLIC' ) * OR GRANTEE IN ( SELECT ROLE_NAME * FROM ENABLED_ROLES ) ) ) * UNION * ( SELECT RAD.GRANTEE, RAD.ROLE_NAME, RAD.IS_GRANTABLE * FROM DEFINITION_SCHEMA.ROLE_AUTHORIZATION_DESCRIPTORS RAD * JOIN APPLICABLE_ROLES R * ON RAD.GRANTEE = R.ROLE_NAME ) ); * * GRANT SELECT ON TABLE APPLICABLE_ROLES * TO PUBLIC WITH GRANT OPTION; * </pre> */ /** * SYSTEM_ROLE_AUTHORIZATION_DESCRIPTORS<p> * * <b>Function
* * Contains a representation of the role authorization descriptors.<p> * * <b>Definition * * <pre class="SqlCodeExample"> * CREATE TABLE ROLE_AUTHORIZATION_DESCRIPTORS ( * ROLE_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, * GRANTEE INFORMATION_SCHEMA.SQL_IDENTIFIER, * GRANTOR INFORMATION_SCHEMA.SQL_IDENTIFIER, * IS_GRANTABLE INFORMATION_SCHEMA.CHARACTER_DATA * CONSTRAINT ROLE_AUTHORIZATION_DESCRIPTORS_IS_GRANTABLE_CHECK * CHECK ( IS_GRANTABLE IN * ( 'YES', 'NO' ) ), * CONSTRAINT ROLE_AUTHORIZATION_DESCRIPTORS_PRIMARY_KEY * PRIMARY KEY ( ROLE_NAME, GRANTEE ), * CONSTRAINT ROLE_AUTHORIZATION_DESCRIPTORS_CHECK_ROLE_NAME * CHECK ( ROLE_NAME IN * ( SELECT AUTHORIZATION_NAME * FROM AUTHORIZATIONS * WHERE AUTHORIZATION_TYPE = 'ROLE' ) ), * CONSTRAINT ROLE_AUTHORIZATION_DESCRIPTORS_FOREIGN_KEY_AUTHORIZATIONS_GRANTOR * FOREIGN KEY ( GRANTOR ) * REFERENCES AUTHORIZATIONS, * CONSTRAINT ROLE_AUTHORIZATION_DESCRIPTORS_FOREIGN_KEY_AUTHORIZATIONS_GRANTEE * FOREIGN KEY ( GRANTEE ) * REFERENCES AUTHORIZATIONS * ) * </pre> * * <b>Description
* * <ol> * <li>The value of ROLE_NAME is the <role name> of some * <role granted> by the <grant role statement> or * the <role name> of a <role definition>. <p> * * <li>The value of GRANTEE is an <authorization identifier>, * possibly PUBLIC, or <role name> specified as a * <grantee> contained in a <grant role statement>, * or the <authorization identifier> of the current * SQLsession when the <role definition> is executed. <p> * * <li>The value of GRANTOR is the <authorization identifier> * of the user or role who granted the role identified by * ROLE_NAME to the user or role identified by the value of * GRANTEE. <p> * * <li>The values of IS_GRANTABLE have the following meanings:
* * <table border cellpadding="3"> * <tr> * <td nowrap>YES * <td nowrap>The described role is grantable. * <tr> * <tr> * <td nowrap>NO * <td nowrap>The described role is not grantable. * <tr> * </table>
* </ol> */ Table SYSTEM_ROLE_AUTHORIZATION_DESCRIPTORS() throws HsqlException { Table t = sysTables[SYSTEM_ROLE_AUTHORIZATION_DESCRIPTORS]; if (t == null) { t = createBlankTable( sysTableHsqlNames[SYSTEM_ROLE_AUTHORIZATION_DESCRIPTORS]); addColumn(t, "ROLE_NAME", Types.VARCHAR, true); // not null addColumn(t, "GRANTEE", Types.VARCHAR, true); // not null addColumn(t, "GRANTOR", Types.VARCHAR, true); // not null addColumn(t, "IS_GRANTABLE", Types.VARCHAR, true); // not null // true PK t.createPrimaryKey(null, new int[] { 0, 1 }, true); return t; } // Intermediate holders String grantorName = GranteeManager.SYSTEM_AUTHORIZATION_NAME; Iterator grantees; Grantee grantee; String granteeName; Iterator roles; String roleName; String isGrantable; Object[] row; final int irole = 0; final int igrantee = 1; final int igrantor = 2; final int igrantable = 3; // Initialization grantees = database.getGranteeManager().getGrantees().iterator(); // Do it. while (grantees.hasNext()) { grantee = (Grantee) grantees.next(); granteeName = grantee.getName(); roles = grantee.getDirectRoles().iterator(); while (roles.hasNext()) { row = t.getEmptyRowData(); roleName = (String) roles.next(); isGrantable = grantee.hasRole(GranteeManager.DBA_ADMIN_ROLE_NAME) ? "YES" : "NO"; row[irole] = roleName; row[igrantee] = granteeName; row[igrantor] = grantorName; row[igrantable] = isGrantable; t.insertSys(row); } } t.setDataReadOnly(true); return t; } /** * SYSTEM_SCHEMATA<p> * * <b>Function
* * The SCHEMATA table has one row for each schema. <p> * * <b>Definition
* * <pre class="SqlCodeExample"> * CREATE TABLE SCHEMATA ( * CATALOG_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, * SCHEMA_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER, * SCHEMA_OWNER INFORMATION_SCHEMA.SQL_IDENTIFIER * CONSTRAINT SCHEMA_OWNER_NOT_NULL * NOT NULL, * DEFAULT_CHARACTER_SET_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER * CONSTRAINT DEFAULT_CHARACTER_SET_CATALOG_NOT_NULL * NOT NULL, * DEFAULT_CHARACTER_SET_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER * CONSTRAINT DEFAULT_CHARACTER_SET_SCHEMA_NOT_NULL * NOT NULL, * DEFAULT_CHARACTER_SET_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER * CONSTRAINT DEFAULT_CHARACTER_SET_NAME_NOT_NULL * NOT NULL, * SQL_PATH INFORMATION_SCHEMA.CHARACTER_DATA, * * CONSTRAINT SCHEMATA_PRIMARY_KEY * PRIMARY KEY ( CATALOG_NAME, SCHEMA_NAME ), * CONSTRAINT SCHEMATA_FOREIGN_KEY_AUTHORIZATIONS * FOREIGN KEY ( SCHEMA_OWNER ) * REFERENCES AUTHORIZATIONS, * CONSTRAINT SCHEMATA_FOREIGN_KEY_CATALOG_NAMES * FOREIGN KEY ( CATALOG_NAME ) * REFERENCES CATALOG_NAMES * ) * </pre> * * <b>Description
* * <ol> * <li>The value of CATALOG_NAME is the name of the catalog of the * schema described by this row.<p> * * <li>The value of SCHEMA_NAME is the unqualified schema name of * the schema described by this row.<p> * * <li>The values of SCHEMA_OWNER are the authorization identifiers * that own the schemata.<p> * * <li>The values of DEFAULT_CHARACTER_SET_CATALOG, * DEFAULT_CHARACTER_SET_SCHEMA, and DEFAULT_CHARACTER_SET_NAME * are the catalog name, unqualified schema name, and qualified * identifier, respectively, of the default character set for * columns and domains in the schemata.<p> * * <li>Case:
* <ul> * <li>If <schema path specification> was specified in * the <schema definition> that defined the schema * described by this row and the character representation * of the <schema path specification> can be * represented without truncation, then the value of * SQL_PATH is that character representation.<p> * * <li>Otherwise, the value of SQL_PATH is the null value. * </ul> * </ol> */ Table SYSTEM_SCHEMATA() throws HsqlException { Table t = sysTables[SYSTEM_SCHEMATA]; if (t == null) { t = createBlankTable(sysTableHsqlNames[SYSTEM_SCHEMATA]); addColumn(t, "CATALOG_NAME", Types.VARCHAR); addColumn(t, "SCHEMA_NAME", Types.VARCHAR, true); addColumn(t, "SCHEMA_OWNER", Types.VARCHAR, true); addColumn(t, "DEFAULT_CHARACTER_SET_CATALOG", Types.VARCHAR); addColumn(t, "DEFAULT_CHARACTER_SET_SCHEMA", Types.VARCHAR, true); addColumn(t, "DEFAULT_CHARACTER_SET_NAME", Types.VARCHAR); addColumn(t, "SQL_PATH", Types.VARCHAR); // order: CATALOG_NAME, SCHEMA_NAME // false PK, as rows may have NULL CATALOG_NAME t.createPrimaryKey(null, new int[] { 0, 1 }, false); return t; } Iterator schemas; String schema; String schemaOwner = GranteeManager.DBA_ADMIN_ROLE_NAME; String dcsSchema = SchemaManager.INFORMATION_SCHEMA; String dcsName = ValuePool.getString("UTF16"); String sqlPath = null; Object[] row; final int ischema_catalog = 0; final int ischema_name = 1; final int ischema_owner = 2; final int idef_charset_cat = 3; final int idef_charset_schem = 4; final int idef_charset_name = 5; final int isql_path = 6; // Initialization schemas = database.schemaManager.fullSchemaNamesIterator(); // Do it. while (schemas.hasNext()) { row = t.getEmptyRowData(); schema = (String) schemas.next(); row[ischema_catalog] = ns.getCatalogName(schema); row[ischema_name] = schema; row[ischema_owner] = schemaOwner; row[idef_charset_cat] = ns.getCatalogName(dcsSchema); row[idef_charset_schem] = dcsSchema; row[idef_charset_name] = dcsName; row[isql_path] = sqlPath; t.insertSys(row); } t.setDataReadOnly(true); return t; } }
Here is a short list of links related to this HSQLDB DatabaseInformationFull.java source code file:
HSQLDB example source code file (DatabaseInformationFull.java)
The HSQLDB DatabaseInformationFull.java source code/* Copyright (c) 2001-2008, The HSQL Development Group * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of the HSQL Development Group nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG, * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.hsqldb; import java.lang.reflect.Method; import org.hsqldb.lib.FileUtil; import org.hsqldb.lib.HashMap; import org.hsqldb.lib.HashSet; import org.hsqldb.lib.HsqlArrayList; import org.hsqldb.lib.Iterator; import org.hsqldb.persist.DataFileCache; import org.hsqldb.persist.HsqlDatabaseProperties; import org.hsqldb.persist.TextCache; import org.hsqldb.scriptio.ScriptWriterBase; import org.hsqldb.store.ValuePool; // fredt@users - 1.7.2 - structural modifications to allow inheritance // boucherb@users - 1.7.2 - 20020225 // - factored out all reusable code into DIXXX support classes // - completed Fred's work on allowing inheritance // boucherb@users - 1.7.2 - 20020304 - bug fixes, refinements, better java docs // fredt@users - 1.8.0 - updated to report latest enhancements and changes // boucherb@users - 1.8.0 - 20050515 - furhter SQL 2003 metadata support /** * Extends DatabaseInformationMain to provide additional system table * support. <p> * * @author boucherb@users * @version 1.8.0 * @since 1.7.2 */ final class DatabaseInformationFull extends org.hsqldb.DatabaseInformationMain { /** Provides SQL function/procedure reporting support. */ protected DIProcedureInfo pi; /** * Constructs a new DatabaseInformationFull instance. <p> * * @param db the database for which to produce system tables. * @throws HsqlException if a database access error occurs. */ DatabaseInformationFull(Database db) throws HsqlException { super(db); pi = new DIProcedureInfo(ns); } /** * Retrieves the system table corresponding to the specified index. <p> * * @param tableIndex index identifying the system table to generate * @throws HsqlException if a database access error occurs * @return the system table corresponding to the specified index */ protected Table generateTable(int tableIndex) throws HsqlException { switch (tableIndex) { case SYSTEM_PROCEDURECOLUMNS : return SYSTEM_PROCEDURECOLUMNS(); case SYSTEM_PROCEDURES : return SYSTEM_PROCEDURES(); case SYSTEM_SUPERTABLES : return SYSTEM_SUPERTABLES(); case SYSTEM_SUPERTYPES : return SYSTEM_SUPERTYPES(); case SYSTEM_UDTATTRIBUTES : return SYSTEM_UDTATTRIBUTES(); case SYSTEM_UDTS : return SYSTEM_UDTS(); case SYSTEM_VERSIONCOLUMNS : return SYSTEM_VERSIONCOLUMNS(); // HSQLDB-specific case SYSTEM_ALIASES : return SYSTEM_ALIASES(); case SYSTEM_CACHEINFO : return SYSTEM_CACHEINFO(); case SYSTEM_CLASSPRIVILEGES : return SYSTEM_CLASSPRIVILEGES(); case SYSTEM_SESSIONINFO : return SYSTEM_SESSIONINFO(); case SYSTEM_PROPERTIES : return SYSTEM_PROPERTIES(); case SYSTEM_SESSIONS : return SYSTEM_SESSIONS(); case SYSTEM_TRIGGERCOLUMNS : return SYSTEM_TRIGGERCOLUMNS(); case SYSTEM_TRIGGERS : return SYSTEM_TRIGGERS(); case SYSTEM_VIEWS : return SYSTEM_VIEWS(); case SYSTEM_TEXTTABLES : return SYSTEM_TEXTTABLES(); case SYSTEM_USAGE_PRIVILEGES : return SYSTEM_USAGE_PRIVILEGES(); case SYSTEM_CHECK_COLUMN_USAGE : return SYSTEM_CHECK_COLUMN_USAGE(); case SYSTEM_CHECK_ROUTINE_USAGE : return SYSTEM_CHECK_ROUTINE_USAGE(); case SYSTEM_CHECK_TABLE_USAGE : return SYSTEM_CHECK_TABLE_USAGE(); case SYSTEM_TABLE_CONSTRAINTS : return SYSTEM_TABLE_CONSTRAINTS(); case SYSTEM_VIEW_TABLE_USAGE : return SYSTEM_VIEW_TABLE_USAGE(); case SYSTEM_VIEW_COLUMN_USAGE : return SYSTEM_VIEW_COLUMN_USAGE(); case SYSTEM_VIEW_ROUTINE_USAGE : return SYSTEM_VIEW_ROUTINE_USAGE(); case SYSTEM_AUTHORIZATIONS : { return SYSTEM_AUTHORIZATIONS(); } case SYSTEM_ROLE_AUTHORIZATION_DESCRIPTORS : { return SYSTEM_ROLE_AUTHORIZATION_DESCRIPTORS(); } case SYSTEM_SCHEMATA : { return SYSTEM_SCHEMATA(); } case SYSTEM_COLLATIONS : { return SYSTEM_COLLATIONS(); } default : return super.generateTable(tableIndex); } } /** * Retrieves a <code>Table object describing the aliases defined * within this database. <p> * * Currently two types of alias are reported: DOMAIN alaises (alternate * names for column data types when issuing "CREATE TABLE" DDL) and * ROUTINE aliases (alternate names that can be used when invoking * routines as SQL functions or stored procedures). <p> * * Each row is an alias description with the following columns: <p> * * <pre class="SqlCodeExample"> * OBJECT_TYPE VARCHAR type of the aliased object * OBJECT_CAT VARCHAR catalog of the aliased object * OBJECT_SCHEM VARCHAR schema of the aliased object * OBJECT_NAME VARCHAR simple identifier of the aliased object * ALIAS_CAT VARCHAR catalog in which alias is defined * ALIAS_SCHEM VARCHAR schema in which alias is defined * ALIAS VARCHAR alias for the indicated object * </pre> |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.