Search in sources :

Example 1 with MetaTable

use of org.h2.table.MetaTable in project h2database by h2database.

the class PageStore method openMetaIndex.

private void openMetaIndex() {
    CreateTableData data = new CreateTableData();
    ArrayList<Column> cols = data.columns;
    cols.add(new Column("ID", Value.INT));
    cols.add(new Column("TYPE", Value.INT));
    cols.add(new Column("PARENT", Value.INT));
    cols.add(new Column("HEAD", Value.INT));
    cols.add(new Column("OPTIONS", Value.STRING));
    cols.add(new Column("COLUMNS", Value.STRING));
    metaSchema = new Schema(database, 0, "", null, true);
    data.schema = metaSchema;
    data.tableName = "PAGE_INDEX";
    data.id = META_TABLE_ID;
    data.temporary = false;
    data.persistData = true;
    data.persistIndexes = true;
    data.create = false;
    data.session = pageStoreSession;
    metaTable = new RegularTable(data);
    metaIndex = (PageDataIndex) metaTable.getScanIndex(pageStoreSession);
    metaObjects.clear();
    metaObjects.put(-1, metaIndex);
}
Also used : IndexColumn(org.h2.table.IndexColumn) Column(org.h2.table.Column) Schema(org.h2.schema.Schema) RegularTable(org.h2.table.RegularTable) CreateTableData(org.h2.command.ddl.CreateTableData)

Example 2 with MetaTable

use of org.h2.table.MetaTable in project h2database by h2database.

the class Database method initMetaTables.

private void initMetaTables() {
    if (metaTablesInitialized) {
        return;
    }
    synchronized (infoSchema) {
        if (!metaTablesInitialized) {
            for (int type = 0, count = MetaTable.getMetaTableTypeCount(); type < count; type++) {
                MetaTable m = new MetaTable(infoSchema, -1 - type, type);
                infoSchema.add(m);
            }
            metaTablesInitialized = true;
        }
    }
}
Also used : MetaTable(org.h2.table.MetaTable) Constraint(org.h2.constraint.Constraint)

Example 3 with MetaTable

use of org.h2.table.MetaTable in project ignite by apache.

the class GridSqlQueryParser method parseTable.

/**
 * @param tbl Table.
 */
private GridSqlElement parseTable(Table tbl) {
    GridSqlElement res = (GridSqlElement) h2ObjToGridObj.get(tbl);
    if (res == null) {
        // Table here is semantically equivalent to a table filter.
        if (tbl instanceof TableBase || tbl instanceof MetaTable)
            return new GridSqlTable(tbl);
        // different table filters anyways. Thus the semantics will be correct.
        if (tbl instanceof TableView) {
            if (((TableView) tbl).isRecursive()) {
                throw new IgniteSQLException("Recursive CTE ('WITH RECURSIVE (...)') is not supported.", IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
            }
            Query qry = VIEW_QUERY.get((TableView) tbl);
            res = new GridSqlSubquery(parseQuery(qry));
        } else if (tbl instanceof FunctionTable)
            res = parseExpression(FUNC_EXPR.get((FunctionTable) tbl), false);
        else if (tbl instanceof RangeTable) {
            res = new GridSqlFunction(GridSqlFunctionType.SYSTEM_RANGE);
            res.addChild(parseExpression(RANGE_MIN.get((RangeTable) tbl), false));
            res.addChild(parseExpression(RANGE_MAX.get((RangeTable) tbl), false));
        } else if (tbl instanceof MetaTable)
            res = new GridSqlTable(tbl);
        else
            assert0(false, "Unexpected Table implementation [cls=" + tbl.getClass().getSimpleName() + ']');
        h2ObjToGridObj.put(tbl, res);
    }
    return res;
}
Also used : Query(org.h2.command.dml.Query) FunctionTable(org.h2.table.FunctionTable) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) MetaTable(org.h2.table.MetaTable) TableBase(org.h2.table.TableBase) TableView(org.h2.table.TableView) RangeTable(org.h2.table.RangeTable)

Aggregations

MetaTable (org.h2.table.MetaTable)2 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)1 CreateTableData (org.h2.command.ddl.CreateTableData)1 Query (org.h2.command.dml.Query)1 Constraint (org.h2.constraint.Constraint)1 Schema (org.h2.schema.Schema)1 Column (org.h2.table.Column)1 FunctionTable (org.h2.table.FunctionTable)1 IndexColumn (org.h2.table.IndexColumn)1 RangeTable (org.h2.table.RangeTable)1 RegularTable (org.h2.table.RegularTable)1 TableBase (org.h2.table.TableBase)1 TableView (org.h2.table.TableView)1