⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 databaseinformationmain.java

📁 hsql是很有名的嵌入式数据库
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
//        while still meeting their mandates:////        1.) DatabaseInformation prevents use of reserved system table names//            for user tables and views, meaning that even under highly//            constrained use cases where the notion of DatabaseMetaData can//            be discarded (i.e. the engine operates in a distribution where//            DatabaseInforationMain/Full and jdbcDatabaseMetaData have been//            dropped from the JAR), it is still impossible to produce a//            database which will be incompatible in terms of system table <=>//            user table name clashes, if/when imported into a more//            capable operating environment.////        2.) DatabaseInformationMain builds on DatabaseInformation, providing//            at minimum what is needed for comprehensive operation under//            JDK 1.1/JDBC 1 and provides, at minimum, what was provided under//            earlier implementations.////        3.) descendents of DatabaseInformationMain (such as the current//            DatabaseInformationFull) need not (and indeed: now cannot)//            override most of the DatabaseInformationMain table producing//            methods, as for the most part they are expected to be already//            fully comprehensive, security aware and accessible to all users.        switch (tableIndex) {            case SYSTEM_BESTROWIDENTIFIER :                return SYSTEM_BESTROWIDENTIFIER();            case SYSTEM_CATALOGS :                return SYSTEM_CATALOGS();            case SYSTEM_COLUMNPRIVILEGES :                return SYSTEM_COLUMNPRIVILEGES();            case SYSTEM_COLUMNS :                return SYSTEM_COLUMNS();            case SYSTEM_CROSSREFERENCE :                return SYSTEM_CROSSREFERENCE();            case SYSTEM_INDEXINFO :                return SYSTEM_INDEXINFO();            case SYSTEM_PRIMARYKEYS :                return SYSTEM_PRIMARYKEYS();            case SYSTEM_PROCEDURECOLUMNS :                return SYSTEM_PROCEDURECOLUMNS();            case SYSTEM_PROCEDURES :                return SYSTEM_PROCEDURES();            case SYSTEM_SCHEMAS :                return SYSTEM_SCHEMAS();            case SYSTEM_TABLEPRIVILEGES :                return SYSTEM_TABLEPRIVILEGES();            case SYSTEM_TABLES :                return SYSTEM_TABLES();            case SYSTEM_TABLETYPES :                return SYSTEM_TABLETYPES();            case SYSTEM_TYPEINFO :                return SYSTEM_TYPEINFO();            case SYSTEM_USERS :                return SYSTEM_USERS();            // required by SYSTEM_TYPEINFRO            case SYSTEM_ALLTYPEINFO :                return SYSTEM_ALLTYPEINFO();            case SYSTEM_CHECK_CONSTRAINTS :                return SYSTEM_CHECK_CONSTRAINTS();            case SYSTEM_SEQUENCES :                return SYSTEM_SEQUENCES();            default :                return null;        }    }    /**     * One time initialisation of instance attributes     * at construction time. <p>     *     * @throws HsqlException if a database access error occurs     */    protected final void init() throws HsqlException {        ns = new DINameSpace(database);        // flag the Session-dependent cached tables        sysTableSessionDependent[SYSTEM_ALIASES] =            sysTableSessionDependent[SYSTEM_CLASSPRIVILEGES] =            sysTableSessionDependent[SYSTEM_BESTROWIDENTIFIER] =            sysTableSessionDependent[SYSTEM_COLUMNPRIVILEGES] =            sysTableSessionDependent[SYSTEM_COLUMNS] =            sysTableSessionDependent[SYSTEM_CROSSREFERENCE] =            sysTableSessionDependent[SYSTEM_INDEXINFO] =            sysTableSessionDependent[SYSTEM_PRIMARYKEYS] =            sysTableSessionDependent[SYSTEM_PROCEDURES] =            sysTableSessionDependent[SYSTEM_PROCEDURECOLUMNS] =            sysTableSessionDependent[SYSTEM_TABLEPRIVILEGES] =            sysTableSessionDependent[SYSTEM_TABLES] =            sysTableSessionDependent[SYSTEM_TRIGGERCOLUMNS] =            sysTableSessionDependent[SYSTEM_TRIGGERS] =            sysTableSessionDependent[SYSTEM_VIEWS] =            sysTableSessionDependent[SYSTEM_TEXTTABLES] =            sysTableSessionDependent[SYSTEM_CHECK_CONSTRAINTS] =            sysTableSessionDependent[SYSTEM_SEQUENCES] =            sysTableSessionDependent[SYSTEM_USAGE_PRIVILEGES] =            sysTableSessionDependent[SYSTEM_TABLE_CONSTRAINTS] =            sysTableSessionDependent[SYSTEM_CHECK_COLUMN_USAGE] =            sysTableSessionDependent[SYSTEM_CHECK_ROUTINE_USAGE] =            sysTableSessionDependent[SYSTEM_CHECK_TABLE_USAGE] =            sysTableSessionDependent[SYSTEM_VIEW_COLUMN_USAGE] =            sysTableSessionDependent[SYSTEM_VIEW_TABLE_USAGE] =            sysTableSessionDependent[SYSTEM_VIEW_ROUTINE_USAGE] =            sysTableSessionDependent[SYSTEM_AUTHORIZATIONS] = true;        Table t;/*        Session oldSession = session;        session = database.sessionManager.getSysSession(            database.schemaManager.INFORMATION_SCHEMA);*/        for (int i = 0; i < sysTables.length; i++) {            t = sysTables[i] = generateTable(i);            if (t != null) {                t.setDataReadOnly(true);            }        }        GranteeManager gm = database.getGranteeManager();        for (int i = 0; i < sysTableHsqlNames.length; i++) {            if (sysTables[i] != null) {                gm.grant(GranteeManager.PUBLIC_USER_NAME,                         sysTableHsqlNames[i], UserManager.SELECT);            }        }/*        session = oldSession;*/    }    /**     * Retrieves whether any form of SQL access is allowed against the     * the specified table w.r.t the database access rights     * assigned to current Session object's User. <p>     *     * @return true if the table is accessible, else false     * @param table the table for which to check accessibility     * @throws HsqlException if a database access error occurs     */    protected final boolean isAccessibleTable(Table table)    throws HsqlException {        return session.isAccessible(table.getName());    }    /**     * Creates a new primoidal system table with the specified name. <p>     *     * @return a new system table     * @param name of the table     * @throws HsqlException if a database access error occurs     */    protected final Table createBlankTable(HsqlName name)    throws HsqlException {        return new Table(database, name, Table.SYSTEM_TABLE);    }    /**     * Retrieves the system <code>Table</code> object corresponding to     * the given <code>name</code> and <code>session</code> arguments. <p>     *     * @param session the Session object requesting the table     * @param name a String identifying the desired table     * @throws HsqlException if there is a problem producing the table or a     *      database access error occurs     * @return a system table corresponding to the <code>name</code> and     *      <code>session</code> arguments     */    final Table getSystemTable(Session session,                               String name) throws HsqlException {        Table t;        int   tableIndex;        // must come first...many methods depend on this being set properly        this.session = session;        if (!isSystemTable(name)) {            return null;        }        tableIndex = getSysTableID(name);        t          = sysTables[tableIndex];        // fredt - any system table that is not supported will be null here        if (t == null) {            return t;        }        // At the time of opening the database, no content is needed        // at present.  However, table structure is required at this        // point to allow processing logged View defn's against system        // tables.  Returning tables without content speeds the database        // open phase under such cases.        if (!withContent) {            return t;        }        if (isDirty) {            cacheClear();        }        int     oldSessionId = sysTableSessions[tableIndex];        boolean tableValid   = oldSessionId != -1;        // user has changed and table is user-dependent        if (session.getId() != oldSessionId                && sysTableSessionDependent[tableIndex]) {            tableValid = false;        }        if (nonCachedTablesSet.contains(name)) {            tableValid = false;        }        // any valid cached table will be returned here        if (tableValid) {            return t;        }        // fredt - clear the contents of table and set new User        t.clearAllRows(session);        sysTableSessions[tableIndex] = session.getId();        // match and if found, generate.        t = generateTable(tableIndex);        // t will be null at this point, if the implementation        // does not support the particular table        // send back what we found or generated        return t;    }    /**     * Retrieves a <code>Table</code> object describing the optimal     * set of visible columns that uniquely identifies a row     * for each accessible table defined within this database. <p>     *     * Each row describes a single column of the best row indentifier column     * set for a particular table.  Each row has the following     * columns: <p>     *     * <pre class="SqlCodeExample">     * SCOPE          SMALLINT  scope of applicability     * COLUMN_NAME    VARCHAR   simple name of the column     * DATA_TYPE      SMALLINT  SQL data type from Types     * TYPE_NAME      VARCHAR   canonical type name     * COLUMN_SIZE    INTEGER   precision     * BUFFER_LENGTH  INTEGER   transfer size in bytes, if definitely known     * DECIMAL_DIGITS SMALLINT  scale  - fixed # of decimal digits     * PSEUDO_COLUMN  SMALLINT  is this a pseudo column like an Oracle ROWID?     * TABLE_CAT      VARCHAR   table catalog     * TABLE_SCHEM    VARCHAR   simple name of table schema     * TABLE_NAME     VARCHAR   simple table name     * NULLABLE       SMALLINT  is column nullable?     * IN_KEY         BOOLEAN   column belongs to a primary or alternate key?     * </pre> <p>     *     * <b>Notes:</b><p>     *     * <code>jdbcDatabaseMetaData.getBestRowIdentifier</code> uses its     * nullable parameter to filter the rows of this table in the following     * manner: <p>     *     * If the nullable parameter is <code>false</code>, then rows are reported     * only if, in addition to satisfying the other specified filter values,     * the IN_KEY column value is TRUE. If the nullable parameter is     * <code>true</code>, then the IN_KEY column value is ignored. <p>     *     * There is not yet infrastructure in place to make some of the ranking     * descisions described below, and it is anticipated that mechanisms     * upon which cost descisions could be based will change significantly over     * the next few releases.  Hence, in the interest of simplicity and of not     * making overly complex dependency on features that will almost certainly     * change significantly in the near future, the current implementation,     * while perfectly adequate for all but the most demanding or exacting     * purposes, is actually sub-optimal in the strictest sense. <p>     *     * A description of the current implementation follows: <p>     *     * <b>DEFINTIONS:</b>  <p>     *     * <b>Alternate key</b> <p>     *     *  <UL>     *   <LI> An attribute of a table that, by virtue of its having a set of     *        columns that are both the full set of columns participating in a     *        unique constraint or index and are all not null, yeilds the same     *        selectability characteristic that would obtained by declaring a     *        primary key on those same columns.     *  </UL> <p>     *     * <b>Column set performance ranking</b> <p>     *     *  <UL>     *  <LI> The ranking of the expected average performance w.r.t a subset of     *       a table's columns used to select and/or compare rows, as taken in     *       relation to all other distinct candidate subsets under     *       consideration. This can be estimated by comparing each cadidate     *       subset in terms of total column count, relative peformance of     *       comparisons amongst the domains of the columns and differences     *       in other costs involved in the execution plans generated using     *       each subset under consideration for row selection/comparison.     *  </UL> <p>     *     *     * <b>Rules:</b> <p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -