Examples of AkibanInformationSchema


Examples of com.foundationdb.ais.model.AkibanInformationSchema

        int cId = createTable("coi", "c", "cid int not null primary key, name varchar(32)");
        int oId = createTable("coi", "o", "oid int not null primary key, c_id int, GROUPING FOREIGN KEY (c_id) REFERENCES c(cid)");
        createIndex("coi", "o", "__akiban_fk_o", "c_id");
        int iId = createTable("coi", "i", "iid int not null primary key, o_id int, idesc varchar(32), GROUPING FOREIGN KEY (o_id) REFERENCES o(oid)");
        createIndex("coi", "i", "__akiban_fk_i", "o_id");
        AkibanInformationSchema ais = ddl().getAIS(session());

        // Lots of checking, the more the merrier
        final Table cTable = ais.getTable( ddl().getTableName(session(), cId) );
        {
            assertEquals("c.columns.size()", 2, cTable.getColumns().size());
            assertEquals("c.indexes.size()", 1, cTable.getIndexes().size());
            PrimaryKey pk = cTable.getPrimaryKey();
            List<Column> expectedPkCols = Arrays.asList( cTable.getColumn("cid") );
            assertEquals("pk cols", expectedPkCols, pk.getColumns());
            assertSame("pk index", cTable.getIndex("PRIMARY"), pk.getIndex());
            assertEquals("pk index cols size", 1, pk.getIndex().getKeyColumns().size());

            assertEquals("parent join", null, cTable.getParentJoin());
            assertEquals("child joins.size", 1, cTable.getChildJoins().size());
        }
        final Table oTable = ais.getTable( ddl().getTableName(session(), oId) );
        {
            assertEquals("c.columns.size()", 2, oTable.getColumns().size());
            assertEquals("c.indexes.size()", 2, oTable.getIndexes().size());
            PrimaryKey pk = oTable.getPrimaryKey();
            List<Column> expectedPkCols = Arrays.asList( oTable.getColumn("oid") );
            assertEquals("pk cols", expectedPkCols, pk.getColumns());
            assertSame("pk index", oTable.getIndex("PRIMARY"), pk.getIndex());
            assertEquals("pk index cols size", 1, pk.getIndex().getKeyColumns().size());

            assertNotNull("parent join is null", oTable.getParentJoin());
            assertSame("parent join", cTable.getChildJoins().get(0), oTable.getParentJoin());
            assertEquals("child joins.size", 1, oTable.getChildJoins().size());
        }
        final Table iTable = ais.getTable( ddl().getTableName(session(), iId) );
        {
            assertEquals("c.columns.size()", 3, iTable.getColumns().size());
            assertEquals("c.indexes.size()", 2, iTable.getIndexes().size());
            PrimaryKey pk = iTable.getPrimaryKey();
            List<Column> expectedPkCols = Arrays.asList( iTable.getColumn("iid") );
View Full Code Here

Examples of com.foundationdb.ais.model.AkibanInformationSchema

        final TableIds tids = createTables();
        final TableName groupName = ddl().getAIS(session()).getTable(tableName(tids.i)).getGroup().getName();

        ddl().dropGroup(session(), groupName);

        AkibanInformationSchema ais = ddl().getAIS(session());
        assertNull("expected no table", ais.getTable("coi", "c"));
        assertNull("expected no table", ais.getTable("coi", "o"));
        assertNull("expected no table", ais.getTable("coi", "i"));
        assertNull("expected no group", ais.getGroup(groupName));
    }
View Full Code Here

Examples of com.foundationdb.ais.model.AkibanInformationSchema

                                  Session session,
                                  String defaultSchemaName,
                                  DropTableNode dropTable,
                                  QueryContext context) {
        TableName tableName = convertName(defaultSchemaName, dropTable.getObjectName());
        AkibanInformationSchema ais = ddlFunctions.getAIS(session);
       
        Table table = ais.getTable(tableName);
        if(table == null) {
            if(skipOrThrow(context, dropTable.getExistenceCheck(), table, new NoSuchTableException(tableName))) {
                return;
            }
        }
View Full Code Here

Examples of com.foundationdb.ais.model.AkibanInformationSchema

                                    String defaultSchemaName,
                                    DropGroupNode dropGroup,
                                    QueryContext context)
    {
        TableName tableName = convertName(defaultSchemaName, dropGroup.getObjectName());
        AkibanInformationSchema ais = ddlFunctions.getAIS(session);

        Table curTable = ais.getTable(tableName);
        if((curTable == null) &&
           skipOrThrow(context, dropGroup.getExistenceCheck(), curTable, new NoSuchTableException(tableName))) {
            return;
        }

        if (!curTable.isRoot()) {
            throw new DropGroupNotRootException (tableName);
        }
       
        final Group root = curTable.getGroup();
        for (Table table : ais.getTables().values()) {
            if (table.getGroup() == root) {
                ViewDDL.checkDropTable(ddlFunctions, session, table.getName());
                checkForeignKeyDropTable(table);
            }
        }
View Full Code Here

Examples of com.foundationdb.ais.model.AkibanInformationSchema

            throw new UnsupportedCreateSelectException();

        TableName fullName = convertName(defaultSchemaName, createTable.getObjectName());
        String schemaName = fullName.getSchemaName();
        String tableName = fullName.getTableName();
        AkibanInformationSchema ais = ddlFunctions.getAIS(session);

        Table curTable = ais.getTable(fullName);
        if((curTable != null) &&
           skipOrThrow(context, createTable.getExistenceCheck(), curTable, new DuplicateTableNameException(fullName))) {
            return;
        }
View Full Code Here

Examples of com.foundationdb.ais.model.AkibanInformationSchema

        TableName fullName = convertName(defaultSchemaName, createTable.getObjectName());
        String schemaName = fullName.getSchemaName();
        String tableName = fullName.getTableName();

        AkibanInformationSchema ais = ddlFunctions.getAIS(session);
        Table curTable = ais.getTable(fullName);
        if((curTable != null) &&
           skipOrThrow(context, createTable.getExistenceCheck(), curTable, new DuplicateTableNameException(fullName))) {
            return;
        }
View Full Code Here

Examples of com.foundationdb.ais.model.AkibanInformationSchema

    public static void addJoin(final AISBuilder builder, final FKConstraintDefinitionNode fkdn,
                               final String defaultSchemaName, final String schemaName, final String tableName)  {
        TableName parentName = getReferencedName(defaultSchemaName, fkdn);

        AkibanInformationSchema ais = builder.akibanInformationSchema();
        // Check parent table exists
        Table parentTable = ais.getTable(parentName);
        if (parentTable == null) {
            throw new JoinToUnknownTableException(new TableName(schemaName, tableName), parentName);
        }
        // Check child table exists
        Table childTable = ais.getTable(schemaName, tableName);
        if (childTable == null) {
            throw new NoSuchTableException(schemaName, tableName);
        }
        // Check that we aren't joining to ourselves
        if (parentTable == childTable) {
View Full Code Here

Examples of com.foundationdb.ais.model.AkibanInformationSchema

                                        AkibanInformationSchema sourceAIS,
                                        FKConstraintDefinitionNode fkdn,
                                        String defaultSchemaName,
                                        String referencingSchemaName,
                                        String referencingTableName) {
        AkibanInformationSchema targetAIS = builder.akibanInformationSchema();
        Table referencingTable = targetAIS.getTable(referencingSchemaName, referencingTableName);
        TableName referencedName = getReferencedName(defaultSchemaName, fkdn);
        Table referencedTable = sourceAIS.getTable(referencedName);
        if (referencedTable == null) {
            if (referencedName.equals(referencingTable.getName())) {
                referencedTable = referencingTable; // Circular reference to self.
View Full Code Here

Examples of com.foundationdb.ais.model.AkibanInformationSchema

        ddlFunctions.dropView(session, viewName);
    }

    public static void checkDropTable(DDLFunctions ddlFunctions, Session session,
                                      TableName name) {
        AkibanInformationSchema ais = ddlFunctions.getAIS(session);
        Columnar table = ais.getColumnar(name);
        if (table == null) return;
        for (View view : ais.getViews().values()) {
            if (view.referencesTable(table)) {
                throw new ViewReferencesExist(view.getName().getSchemaName(),
                                              view.getName().getTableName(),
                                              table.getName().getSchemaName(),
                                              table.getName().getTableName());
View Full Code Here

Examples of com.foundationdb.ais.model.AkibanInformationSchema

    public static void dropSchema (DDLFunctions ddlFunctions,
            Session session,
            DropSchemaNode dropSchema,
            QueryContext context)
    {
        AkibanInformationSchema ais = ddlFunctions.getAIS(session);
        final String schemaName = dropSchema.getSchemaName();

        Schema curSchema = ais.getSchema(schemaName);
        if((curSchema == null) &&
           skipOrThrow(context, dropSchema.getExistenceCheck(), curSchema, new NoSuchSchemaException(schemaName))) {
            return;
        }
        // 1 == RESTRICT, meaning no drop if the schema isn't empty
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.